mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #4402 from dmatos2012/chmod-verbose-message
chmod: supress verbose output when not verbose
This commit is contained in:
commit
9d655bf672
2 changed files with 19 additions and 6 deletions
|
@ -190,16 +190,18 @@ impl Chmoder {
|
||||||
let file = Path::new(filename);
|
let file = Path::new(filename);
|
||||||
if !file.exists() {
|
if !file.exists() {
|
||||||
if file.is_symlink() {
|
if file.is_symlink() {
|
||||||
println!(
|
|
||||||
"failed to change mode of {} from 0000 (---------) to 0000 (---------)",
|
|
||||||
filename.quote()
|
|
||||||
);
|
|
||||||
if !self.quiet {
|
if !self.quiet {
|
||||||
show!(USimpleError::new(
|
show!(USimpleError::new(
|
||||||
1,
|
1,
|
||||||
format!("cannot operate on dangling symlink {}", filename.quote()),
|
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 {
|
} else if !self.quiet {
|
||||||
show!(USimpleError::new(
|
show!(USimpleError::new(
|
||||||
1,
|
1,
|
||||||
|
|
|
@ -414,7 +414,7 @@ fn test_chmod_symlink_non_existing_file() {
|
||||||
let non_existing = "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 test_symlink = "test_chmod_symlink_non_existing_file_symlink";
|
||||||
let expected_stdout = &format!(
|
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}'");
|
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)
|
.code_is(1)
|
||||||
.no_stderr()
|
.no_stderr()
|
||||||
.stdout_contains(expected_stdout);
|
.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]
|
#[test]
|
||||||
|
@ -616,7 +627,7 @@ fn test_chmod_file_symlink_after_non_existing_file() {
|
||||||
let non_existing = "test_chmod_symlink_non_existing_file";
|
let non_existing = "test_chmod_symlink_non_existing_file";
|
||||||
let test_dangling_symlink = "test_chmod_symlink_non_existing_file_symlink";
|
let test_dangling_symlink = "test_chmod_symlink_non_existing_file_symlink";
|
||||||
let expected_stdout = &format!(
|
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}'");
|
let expected_stderr = &format!("cannot operate on dangling symlink '{test_dangling_symlink}'");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue