-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
dd: interpret Stdin as File to seek it #3662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1186,3 +1186,16 @@ fn test_final_stats_si_iec() { | |
| let s = result.stderr_str(); | ||
| assert!(s.starts_with("2+0 records in\n2+0 records out\n1024 bytes (1 KB, 1024 B) copied,")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_partial_skip_stdin() { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well... I added the test, but it does not work as expected and fails with However, it can work outside the test system (for example, if I run I am confused why it does not work in the test system. Let me know if there are any insights on this. |
||
| let input = "abc\ndef\n"; | ||
| // build_test_file!("infile.txt", input.as_bytes()); | ||
| new_ucmd!() | ||
| .args(&["status=none", "bs=1", "skip=1", "count=0"]) | ||
| .pipe_in(input) | ||
| .succeeds() | ||
| .no_stderr() | ||
| .stdout_is("bc") | ||
| .success(); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(driveby comment, I don't have much context) Unless
seekable_srcis fed tomem::forgetat some point this likely is a bad idea becauseFile::dropwill then close the stdin file descriptor. You should eithertry_clone(dup) it or wrap this in aManuallyDrop.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Will fix it once I figure out why the current solution works if I use
ddin command line and does not work if I run tests fromtests/by-utils.