mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00: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:
commit
b33986de86
1 changed files with 6 additions and 3 deletions
|
@ -43,8 +43,8 @@ fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name(binary_path: &Path) -> &str {
|
fn name(binary_path: &Path) -> Option<&str> {
|
||||||
binary_path.file_stem().unwrap().to_str().unwrap()
|
binary_path.file_stem()?.to_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -54,7 +54,10 @@ fn main() {
|
||||||
let mut args = uucore::args_os();
|
let mut args = uucore::args_os();
|
||||||
|
|
||||||
let binary = binary_path(&mut args);
|
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?
|
// binary name equals util name?
|
||||||
if let Some(&(uumain, _)) = utils.get(binary_as_util) {
|
if let Some(&(uumain, _)) = utils.get(binary_as_util) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue