mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #4366 from BartMassey-upstream/name-weirdness
coreutils: fixed panic when multi-call binary has funny name
This commit is contained in:
@@ -43,8 +43,8 @@ fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
fn name(binary_path: &Path) -> &str {
|
||||
binary_path.file_stem().unwrap().to_str().unwrap()
|
||||
fn name(binary_path: &Path) -> Option<&str> {
|
||||
binary_path.file_stem()?.to_str()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -54,7 +54,10 @@ fn main() {
|
||||
let mut args = uucore::args_os();
|
||||
|
||||
let binary = binary_path(&mut args);
|
||||
let binary_as_util = name(&binary);
|
||||
let binary_as_util = name(&binary).unwrap_or_else(|| {
|
||||
usage(&utils, "<unknown binary name>");
|
||||
process::exit(0);
|
||||
});
|
||||
|
||||
// binary name equals util name?
|
||||
if let Some(&(uumain, _)) = utils.get(binary_as_util) {
|
||||
|
||||
Reference in New Issue
Block a user