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

od: allow trailing characters in address radix #6674

Conversation

andrewliebenow
Copy link
Contributor

No description provided.

@andrewliebenow andrewliebenow force-pushed the od-allow-trailing-characters-in-address-radix branch from 882677b to 6be3464 Compare August 31, 2024 09:18
.arg("-Anone")
.run_piped_stdin(input)
.success()
.stderr_is("od: warning: Ignored superfluous character(s) after radix specifier 'n'\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you expect a warning? GNU od doesn't seem to show a warning:

$ cat input.bin | od -Anone
 000000 000000

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I did not know that level of compatibility was the goal. I've removed the warning.

Comment on lines 180 to 185
0 => {
return Err(USimpleError::new(
1,
"Radix must be one of [d, o, n, x]".to_string(),
));
}
Copy link
Contributor

@cakebaker cakebaker Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unreachable code because this case is caught by clap:

$ cat input.bin | cargo run -q od -A
error: a value is required for '--address-radix <RADIX>' but none was supplied

So I would use something like:

0 => unreachable!("should be caught by clap"),

@andrewliebenow andrewliebenow force-pushed the od-allow-trailing-characters-in-address-radix branch from 6be3464 to 61e4bba Compare August 31, 2024 19:11
@andrewliebenow andrewliebenow force-pushed the od-allow-trailing-characters-in-address-radix branch from 61e4bba to 5ca995b Compare August 31, 2024 19:13
@cakebaker cakebaker merged commit dfe3e38 into uutils:main Sep 1, 2024
68 of 69 checks passed
@cakebaker
Copy link
Contributor

Thanks for your PR!

andrewliebenow added a commit to andrewliebenow/toybox that referenced this pull request Sep 8, 2024
POSIX only specifies the characters 'd', 'o', 'x', and 'n' as valid
`od -A` argument values. [1] Pedantic implementations of `od` may
expect the argument value to be a single character instead of ignoring
these extra characters. [2]

[1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/od.html
[2] uutils/coreutils#6674
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.

2 participants