mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
cp: make --backup and --no-clobber are mutually exclusive (#7082)
* cp: make --backup and --no-clobber are mutually exclusive Should fix tests/cp/cp-i.sh * simplify the test Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com> --------- Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
co-authored by
Daniel Hofstetter
parent
7a78213edb
commit
934e85f4cd
@@ -932,6 +932,16 @@ impl Options {
|
||||
};
|
||||
let update_mode = update_control::determine_update_mode(matches);
|
||||
|
||||
if backup_mode != BackupMode::NoBackup
|
||||
&& matches
|
||||
.get_one::<String>(update_control::arguments::OPT_UPDATE)
|
||||
.map_or(false, |v| v == "none" || v == "none-fail")
|
||||
{
|
||||
return Err(Error::InvalidArgument(
|
||||
"--backup is mutually exclusive with -n or --update=none-fail".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let backup_suffix = backup_control::determine_backup_suffix(matches);
|
||||
|
||||
let overwrite = OverwriteMode::from_matches(matches);
|
||||
|
||||
@@ -2422,6 +2422,17 @@ fn test_cp_reflink_bad() {
|
||||
.stderr_contains("error: invalid value 'bad' for '--reflink[=<WHEN>]'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cp_conflicting_update() {
|
||||
new_ucmd!()
|
||||
.arg("-b")
|
||||
.arg("--update=none")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.fails()
|
||||
.stderr_contains("--backup is mutually exclusive with -n or --update=none-fail");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn test_cp_reflink_insufficient_permission() {
|
||||
|
||||
Reference in New Issue
Block a user