mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
chmod: match GNU error
Related to #2260 Signed-off-by: Dean Li <deantvv@gmail.com>
This commit is contained in:
parent
c08eae8e9a
commit
fe25b51a66
2 changed files with 23 additions and 1 deletions
|
@ -262,8 +262,10 @@ impl Chmoder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
} else if err.kind() == std::io::ErrorKind::PermissionDenied {
|
||||||
|
show_error!("'{}': Permission denied", file.display());
|
||||||
} else {
|
} else {
|
||||||
show_error!("{}: '{}'", err, file.display());
|
show_error!("'{}': {}", file.display(), err);
|
||||||
}
|
}
|
||||||
return Err(1);
|
return Err(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,6 +282,26 @@ fn test_chmod_reference_file() {
|
||||||
run_single_test(&tests[0], at, ucmd);
|
run_single_test(&tests[0], at, ucmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_permission_denied() {
|
||||||
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
|
at.mkdir("d/");
|
||||||
|
at.mkdir("d/no-x");
|
||||||
|
at.mkdir("d/no-x/y");
|
||||||
|
|
||||||
|
scene.ucmd().arg("u=rw").arg("d/no-x").succeeds();
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-R")
|
||||||
|
.arg("o=r")
|
||||||
|
.arg("d")
|
||||||
|
.fails()
|
||||||
|
.stderr_is("chmod: 'd/no-x/y': Permission denied");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_chmod_recursive() {
|
fn test_chmod_recursive() {
|
||||||
let _guard = UMASK_MUTEX.lock();
|
let _guard = UMASK_MUTEX.lock();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue