-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
dd: unexpectedly consumes all bytes from stdin #3008
Comments
The corresponding GNU test for dd is in |
There's a similar issue with |
I made an attempt to solve this issue. The problem is that an attempt to skip bytes by A possible workaround is to seek Inspired by rust-lang/rust#72802 Let me know your opinions for the approach suggested. |
I think it would be a welcome addition. |
Alright, I'll clean that up and make a PR. |
Executive summary:
Setup:
GNU dd:
uutils dd:
(it produces no output).
I'm going to be very explicit about this because it helped me understand the problem here. The way I'm reading the command line is:
dd
means copy bytes from stdin to stdout,bs=1
means blocks of 1 byte from the input and write blocks of 1 byte to the output,skip=1
means skip 1 block of the input,count=0
means write 0 blocks to the output,&&
means do the second command only if the first command terminates with exit status 0,cat -
means copy bytes from stdin to stdout,< infile
means redirect the bytes ofinfile
into stdin,Altogether this could be described in English as "send bytes of
infile
into stdin, havedd
skip the first byte and stop, then havecat
copy the remaining bytes to stdout".So the problem seems to be that by the time
cat
attempts to read fromstdin
, there are no bytes available to read, but there should be. I took a look in the code fordd
and it doesn't seem to be reading more bytes than it should:coreutils/src/uu/dd/src/dd.rs
Line 182 in 1194a8c
(I discovered this issue when looking into test failures in the GNU test
tests/misc/head-c.sh
.)The text was updated successfully, but these errors were encountered: