1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

sync: make fail like GNU - tests/misc/sync.sh

This commit is contained in:
Sylvestre Ledru 2022-09-24 12:46:15 +02:00
parent e523a56dab
commit fc1c7755b9
2 changed files with 12 additions and 0 deletions

View file

@ -169,6 +169,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.map(|v| v.map(ToString::to_string).collect()) .map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default(); .unwrap_or_default();
if matches.is_present(options::DATA) && files.is_empty() {
return Err(USimpleError::new(1, "--data needs at least one argument"));
}
for f in &files { for f in &files {
if !Path::new(&f).exists() { if !Path::new(&f).exists() {
return Err(USimpleError::new( return Err(USimpleError::new(

View file

@ -44,3 +44,11 @@ fn test_sync_no_existing_files() {
.fails() .fails()
.stderr_contains("cannot stat"); .stderr_contains("cannot stat");
} }
#[test]
fn test_sync_data_but_not_file() {
new_ucmd!()
.arg("--data")
.fails()
.stderr_contains("sync: --data needs at least one argument");
}