Skip to content

Commit 3340c36

Browse files
hashsum: fix help text to show actual utility name
Fix all hashsum utilities (md5sum, b2sum, sha256sum, etc.) to display their actual name in help output instead of generic 'hashsum --<digest>'. Override help_template and usage for specific utilities while preserving the original hashsum behavior for the generic multicall case. Fixes #8614
1 parent aaf742d commit 3340c36

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/uu/hashsum/src/hashsum.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ pub fn uu_app_custom() -> Command {
498498
/// hashsum is handled differently in build.rs
499499
/// therefore, this is different from other utilities.
500500
fn uu_app(binary_name: &str) -> (Command, bool) {
501-
match binary_name {
501+
let (mut command, is_hashsum_bin) = match binary_name {
502502
// These all support the same options.
503503
"md5sum" | "sha1sum" | "sha224sum" | "sha256sum" | "sha384sum" | "sha512sum" => {
504504
(uu_app_common(), false)
@@ -516,7 +516,17 @@ fn uu_app(binary_name: &str) -> (Command, bool) {
516516
"b3sum" => (uu_app_b3sum(), false),
517517
// We're probably just being called as `hashsum`, so give them everything.
518518
_ => (uu_app_custom(), true),
519+
};
520+
521+
// If not called as generic hashsum, override the command name and usage
522+
if !is_hashsum_bin {
523+
let usage = format!("{} [OPTION]... [FILE]...", binary_name);
524+
command = command
525+
.help_template(uucore::localized_help_template(binary_name))
526+
.override_usage(format_usage(&usage));
519527
}
528+
529+
(command, is_hashsum_bin)
520530
}
521531

522532
#[allow(clippy::cognitive_complexity)]

0 commit comments

Comments
 (0)