mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
cp: Error out if cp only contains source
This commit is contained in:
parent
f71a7bc0c4
commit
8be6338da9
2 changed files with 15 additions and 0 deletions
|
@ -1073,6 +1073,9 @@ fn parse_path_args(
|
||||||
if paths.is_empty() {
|
if paths.is_empty() {
|
||||||
// No files specified
|
// No files specified
|
||||||
return Err("missing file operand".into());
|
return Err("missing file operand".into());
|
||||||
|
} else if paths.len() == 1 && options.target_dir.is_none() {
|
||||||
|
// Only one file specified
|
||||||
|
return Err(format!("missing destination file operand after {:?}", paths[0]).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an error if the user requested to copy more than one
|
// Return an error if the user requested to copy more than one
|
||||||
|
|
|
@ -3231,3 +3231,15 @@ fn test_cp_debug_sparse_always_reflink_auto() {
|
||||||
panic!("Failure: stdout was \n{stdout_str}");
|
panic!("Failure: stdout was \n{stdout_str}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cp_only_source_no_target() {
|
||||||
|
let ts = TestScenario::new(util_name!());
|
||||||
|
let at = &ts.fixtures;
|
||||||
|
at.touch("a");
|
||||||
|
let result = ts.ucmd().arg("a").fails();
|
||||||
|
let stderr_str = result.stderr_str();
|
||||||
|
if !stderr_str.contains("missing destination file operand after \"a\"") {
|
||||||
|
panic!("Failure: stderr was \n{stderr_str}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue