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

chmod: match GNU error

Related to #2260

Signed-off-by: Dean Li <deantvv@gmail.com>
This commit is contained in:
Dean Li 2021-05-26 21:34:02 +08:00
parent c08eae8e9a
commit fe25b51a66
No known key found for this signature in database
GPG key ID: 4F55BB69D480672A
2 changed files with 23 additions and 1 deletions

View file

@ -262,8 +262,10 @@ impl Chmoder {
);
}
return Ok(());
} else if err.kind() == std::io::ErrorKind::PermissionDenied {
show_error!("'{}': Permission denied", file.display());
} else {
show_error!("{}: '{}'", err, file.display());
show_error!("'{}': {}", file.display(), err);
}
return Err(1);
}

View file

@ -282,6 +282,26 @@ fn test_chmod_reference_file() {
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]
fn test_chmod_recursive() {
let _guard = UMASK_MUTEX.lock();