Skip to content

Commit 3214c4d

Browse files
authored
install: don't error when multiple arguments of the same type are given, instead override with last one (#8033) (#8053)
1 parent 46cfead commit 3214c4d

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

src/uu/install/src/install.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ pub fn uu_app() -> Command {
187187
.about(get_message("install-about"))
188188
.override_usage(format_usage(&get_message("install-usage")))
189189
.infer_long_args(true)
190+
.args_override_self(true)
190191
.arg(backup_control::arguments::backup())
191192
.arg(backup_control::arguments::backup_no_args())
192193
.arg(

tests/by-util/test_install.rs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,80 @@ fn test_install_nested_paths_copy_file() {
447447
assert!(at.file_exists(format!("{dir2}/{file1}")));
448448
}
449449

450+
#[test]
451+
fn test_multiple_mode_arguments_override_not_error() {
452+
let scene = TestScenario::new(util_name!());
453+
let at = &scene.fixtures;
454+
let dir = "source_dir";
455+
456+
let file = "source_file";
457+
let gid = getegid();
458+
let uid = geteuid();
459+
460+
at.touch(file);
461+
at.mkdir(dir);
462+
463+
scene
464+
.ucmd()
465+
.args(&[
466+
file,
467+
&format!("{dir}/{file}"),
468+
"--owner=invalid_owner",
469+
"--owner",
470+
&uid.to_string(),
471+
])
472+
.succeeds()
473+
.no_stderr();
474+
475+
scene
476+
.ucmd()
477+
.args(&[
478+
file,
479+
&format!("{dir}/{file}"),
480+
"-o invalid_owner",
481+
"-o",
482+
&uid.to_string(),
483+
])
484+
.succeeds()
485+
.no_stderr();
486+
487+
scene
488+
.ucmd()
489+
.args(&[file, &format!("{dir}/{file}"), "--mode=999", "--mode=200"])
490+
.succeeds()
491+
.no_stderr();
492+
493+
scene
494+
.ucmd()
495+
.args(&[file, &format!("{dir}/{file}"), "-m 999", "-m 200"])
496+
.succeeds()
497+
.no_stderr();
498+
499+
scene
500+
.ucmd()
501+
.args(&[
502+
file,
503+
&format!("{dir}/{file}"),
504+
"--group=invalid_group",
505+
"--group",
506+
&gid.to_string(),
507+
])
508+
.succeeds()
509+
.no_stderr();
510+
511+
scene
512+
.ucmd()
513+
.args(&[
514+
file,
515+
&format!("{dir}/{file}"),
516+
"-g invalid_group",
517+
"-g",
518+
&gid.to_string(),
519+
])
520+
.succeeds()
521+
.no_stderr();
522+
}
523+
450524
#[test]
451525
fn test_install_failing_omitting_directory() {
452526
let scene = TestScenario::new(util_name!());

0 commit comments

Comments
 (0)