mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
chmod: supress verbose output when not verbose
This commit is contained in:
parent
bc0273f48f
commit
dd4299c32e
2 changed files with 19 additions and 6 deletions
|
@ -190,16 +190,18 @@ impl Chmoder {
|
|||
let file = Path::new(filename);
|
||||
if !file.exists() {
|
||||
if file.is_symlink() {
|
||||
println!(
|
||||
"failed to change mode of {} from 0000 (---------) to 0000 (---------)",
|
||||
filename.quote()
|
||||
);
|
||||
if !self.quiet {
|
||||
show!(USimpleError::new(
|
||||
1,
|
||||
format!("cannot operate on dangling symlink {}", filename.quote()),
|
||||
));
|
||||
}
|
||||
if self.verbose {
|
||||
println!(
|
||||
"failed to change mode of {} from 0000 (---------) to 1500 (r-x-----T)",
|
||||
filename.quote()
|
||||
);
|
||||
}
|
||||
} else if !self.quiet {
|
||||
show!(USimpleError::new(
|
||||
1,
|
||||
|
|
|
@ -414,7 +414,7 @@ fn test_chmod_symlink_non_existing_file() {
|
|||
let non_existing = "test_chmod_symlink_non_existing_file";
|
||||
let test_symlink = "test_chmod_symlink_non_existing_file_symlink";
|
||||
let expected_stdout = &format!(
|
||||
"failed to change mode of '{test_symlink}' from 0000 (---------) to 0000 (---------)"
|
||||
"failed to change mode of '{test_symlink}' from 0000 (---------) to 1500 (r-x-----T)"
|
||||
);
|
||||
let expected_stderr = &format!("cannot operate on dangling symlink '{test_symlink}'");
|
||||
|
||||
|
@ -442,6 +442,17 @@ fn test_chmod_symlink_non_existing_file() {
|
|||
.code_is(1)
|
||||
.no_stderr()
|
||||
.stdout_contains(expected_stdout);
|
||||
|
||||
// this should only include the dangling symlink message
|
||||
// NOT the failure to change mode
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("755")
|
||||
.arg(test_symlink)
|
||||
.run()
|
||||
.code_is(1)
|
||||
.no_stdout()
|
||||
.stderr_contains(expected_stderr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -616,7 +627,7 @@ fn test_chmod_file_symlink_after_non_existing_file() {
|
|||
let non_existing = "test_chmod_symlink_non_existing_file";
|
||||
let test_dangling_symlink = "test_chmod_symlink_non_existing_file_symlink";
|
||||
let expected_stdout = &format!(
|
||||
"failed to change mode of '{test_dangling_symlink}' from 0000 (---------) to 0000 (---------)"
|
||||
"failed to change mode of '{test_dangling_symlink}' from 0000 (---------) to 1500 (r-x-----T)"
|
||||
);
|
||||
let expected_stderr = &format!("cannot operate on dangling symlink '{test_dangling_symlink}'");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue