Skip to content
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 : treat arg as bytes if it contains a 'B' #6050

Merged
merged 1 commit into from
Mar 10, 2024

Conversation

matrixhead
Copy link
Contributor

this fixes bytes.log test case of dd in gnu test coverage #5903.

Copy link

github-actions bot commented Mar 9, 2024

GNU testsuite comparison:

Congrats! The gnu test tests/dd/bytes is no longer failing!

@cakebaker cakebaker changed the title dd : treat arg as bytes if it contatins a 'B' dd : treat arg as bytes if it contains a 'B' Mar 9, 2024
@cakebaker cakebaker linked an issue Mar 9, 2024 that may be closed by this pull request
@sylvestre
Copy link
Sponsor Contributor

Excellent and easier than it seems.
Could you please add a test to make sure we don't regress! thanks

@matrixhead
Copy link
Contributor Author

@sylvestre I've added some tests could you please take a look at that

Copy link

github-actions bot commented Mar 9, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

@tertsdiepraam
Copy link
Member

Before we merge this, I'd like to try a few inputs with the GNU version. Another hypothesis based on the given inputs is that GNU parses the B from the start of the string. So 1xBx would not be in bytes, but 1Bxx would be. I'll check this on my machine tomorrow.

@matrixhead
Copy link
Contributor Author

matrixhead commented Mar 10, 2024

@tertsdiepraam This is how i understood this and there is a huge chance that i might be wrong. Lets assume we have an argument called N, gnu uses an "operandxN" pattern to match the "N" where xN is the multiplicative suffix and N is recursively matched also the operand could have an optional B, it's kind of a "type annotation" saying that this operand represents bytes and if any one of these operands represent bytes then treat result as bytes. All of this essentially translates to if there is "B" in the argument then treat it as bytes.

for example if we give an argument "1x2Bx4"
it should take 1 as operand and x2Bx4 as suffix then 2B as operand and x4 as suffix and so on and since there is a B it should be treated as bytes.
in the case "1xBx"
it should result in an error because B is not a valid operand.
in the case "1Bxx"
it should result in an error because x is not a valid operand.

@tertsdiepraam
Copy link
Member

I've run some tests and I agree with your interpretation. Thanks for the explanation!

@tertsdiepraam tertsdiepraam merged commit a578fe9 into uutils:main Mar 10, 2024
61 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dd: incorrect seek on oseek=1Bx2x4
3 participants