sync: fix error msg

This commit is contained in:
John Shin 2023-06-17 19:31:27 -07:00
parent 07c538f090
commit 47d0ac4a42
2 changed files with 5 additions and 5 deletions

View file

@ -173,7 +173,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let path = Path::new(&f); let path = Path::new(&f);
if let Err(e) = open(path, OFlag::O_NONBLOCK, Mode::empty()) { if let Err(e) = open(path, OFlag::O_NONBLOCK, Mode::empty()) {
if e != Errno::EACCES || (e == Errno::EACCES && path.is_dir()) { if e != Errno::EACCES || (e == Errno::EACCES && path.is_dir()) {
return e.map_err_context(|| format!("cannot stat {}", f.quote()))?; return e.map_err_context(|| format!("error opening {}", f.quote()))?;
} }
} }
} }
@ -183,7 +183,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
if !Path::new(&f).exists() { if !Path::new(&f).exists() {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,
format!("cannot stat {}: No such file or directory", f.quote()), format!("error opening {}: No such file or directory", f.quote()),
)); ));
} }
} }

View file

@ -41,7 +41,7 @@ fn test_sync_no_existing_files() {
.arg("--data") .arg("--data")
.arg("do-no-exist") .arg("do-no-exist")
.fails() .fails()
.stderr_contains("cannot stat"); .stderr_contains("error opening");
} }
#[test] #[test]
@ -63,9 +63,9 @@ fn test_sync_no_permission_dir() {
ts.ccmd("chmod").arg("0").arg(dir).succeeds(); ts.ccmd("chmod").arg("0").arg(dir).succeeds();
let result = ts.ucmd().arg("--data").arg(dir).fails(); let result = ts.ucmd().arg("--data").arg(dir).fails();
result.stderr_contains("sync: cannot stat 'foo': Permission denied"); result.stderr_contains("sync: error opening 'foo': Permission denied");
let result = ts.ucmd().arg(dir).fails(); let result = ts.ucmd().arg(dir).fails();
result.stderr_contains("sync: cannot stat 'foo': Permission denied"); result.stderr_contains("sync: error opening 'foo': Permission denied");
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]