mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07: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:
committed by
Sylvestre Ledru
parent
5c10180f6d
commit
a7f95d5a23
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user