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

hashsum: Refactor uu_app to isolate non-"GNU Coreutils" options #3593

Merged
merged 1 commit into from
Jun 12, 2022

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Jun 4, 2022

Several binaries have been added to hashsum that have never been part
of GNU Coreutils:

In particular, the --bits option, and the --no-names option added in
#3361, are not valid for any GNU Coreutils *sum binary
(as of Coreutils 9.0).

This commit refactors the argument parsing so that --bits and
--no-names become invalid options for the binaries intended to match
the GNU Coreutils API, instead of being ignored options. It also
refactors the custom binary name handling to distinguish between
binaries intended to match the GNU Coreutils API, and binaries that
don't have that constraint.

Part of #2930.

@str4d str4d force-pushed the 2930-hashsum-isolate-non-gnu-options branch from fbd0d0e to c2a6ea5 Compare June 4, 2022 23:43
@str4d
Copy link
Contributor Author

str4d commented Jun 4, 2022

Force-pushed to fix a bug: sha3-*sum binaries don't use--bits, but sha3sum itself requires it like shake*sum do.

@str4d str4d force-pushed the 2930-hashsum-isolate-non-gnu-options branch from c2a6ea5 to e243a26 Compare June 5, 2022 12:42
@str4d
Copy link
Contributor Author

str4d commented Jun 5, 2022

Force-pushed to fix clippy lints.

Comment on lines +412 to +415
// Needed for variable-length output sums (e.g. SHAKE)
command.arg(
Arg::new("bits")
.long("bits")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The core motivation for this refactor is that GNU Coreutils has -l/--length for specifying the output length, which b2sum expects, while --bits is an invalid command on any GNU Coreutils *sum binary. We could simplify this if we removed this flag and instead used -l/--length for sha3sum and shake*sum (if the resolution to #2930 (comment) is to interpret -l/--length as bits), but that would be a breaking change for previous users of coreutils.

Several binaries have been added to `hashsum` that have never been part
of GNU Coreutils:

- `sha3*sum` (uutils#869)
- `shake*sum` (uutils#987)
- `b3sum` (uutils#3108 and uutils#3164)

In particular, the `--bits` option, and the `--no-names` option added in
uutils#3361, are not valid for any GNU Coreutils `*sum` binary
(as of Coreutils 9.0).

This commit refactors the argument parsing so that `--bits` and
`--no-names` become invalid options for the binaries intended to match
the GNU Coreutils API, instead of being ignored options. It also
refactors the custom binary name handling to distinguish between
binaries intended to match the GNU Coreutils API, and binaries that
don't have that constraint.

Part of uutils#2930.
@sylvestre sylvestre force-pushed the 2930-hashsum-isolate-non-gnu-options branch from e243a26 to fccab8a Compare June 10, 2022 08:07
@sylvestre sylvestre merged commit f36b588 into uutils:main Jun 12, 2022
@sylvestre
Copy link
Sponsor Contributor

thanks and sorry for the latency :)

@str4d str4d deleted the 2930-hashsum-isolate-non-gnu-options branch June 12, 2022 14:10
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.

None yet

2 participants