1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

hashsum: use file_stem() instead of file_name()

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.
This commit is contained in:
Gregory Szorc 2023-06-28 21:38:13 -07:00 committed by Sylvestre Ledru
parent 5c10180f6d
commit a7f95d5a23

View file

@ -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();