Skip to content

Commit

Permalink
hashsum: use file_stem() instead of file_name()
Browse files Browse the repository at this point in the history
This program matches the binary name to determine which
algorithm to use. On Windows, `file_name()` was matching
against a string with `.exe`, causing binaries like
`sha256sum.exe` to not properly detect the algorithm.

By using `file_stem()`, we exclude the `.exe` from matching,
achieving similar and correct behavior on Windows.
  • Loading branch information
indygreg committed Jun 29, 2023
1 parent 682e0e3 commit 5fd4edf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/uu/hashsum/src/hashsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
// if there is no program name for some reason, default to "hashsum"
let program = args.next().unwrap_or_else(|| OsString::from(NAME));
let binary_name = Path::new(&program)
.file_name()
.file_stem()
.unwrap_or_else(|| OsStr::new(NAME))
.to_string_lossy();

Expand Down

0 comments on commit 5fd4edf

Please sign in to comment.