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

chmod: pad all file modes to 4 digits

This commit is contained in:
Michael Debertol 2021-08-16 00:14:50 +02:00
parent 52cfd4c6cb
commit 080998b6ef
2 changed files with 4 additions and 4 deletions

View file

@ -323,7 +323,7 @@ impl Chmoder {
} }
if self.verbose { if self.verbose {
show_error!( show_error!(
"failed to change mode of file '{}' from {:o} ({}) to {:o} ({})", "failed to change mode of file '{}' from {:04o} ({}) to {:04o} ({})",
file.display(), file.display(),
fperm, fperm,
display_permissions_unix(fperm as mode_t, false), display_permissions_unix(fperm as mode_t, false),
@ -335,7 +335,7 @@ impl Chmoder {
} else { } else {
if self.verbose || self.changes { if self.verbose || self.changes {
show_error!( show_error!(
"mode of '{}' changed from {:o} ({}) to {:o} ({})", "mode of '{}' changed from {:04o} ({}) to {:04o} ({})",
file.display(), file.display(),
fperm, fperm,
display_permissions_unix(fperm as mode_t, false), display_permissions_unix(fperm as mode_t, false),

View file

@ -330,8 +330,8 @@ fn test_chmod_recursive() {
.arg("a") .arg("a")
.arg("z") .arg("z")
.succeeds() .succeeds()
.stderr_contains(&"to 333 (-wx-wx-wx)") .stderr_contains(&"to 0333 (-wx-wx-wx)")
.stderr_contains(&"to 222 (-w--w--w-)"); .stderr_contains(&"to 0222 (-w--w--w-)");
assert_eq!(at.metadata("z/y").permissions().mode(), 0o100222); assert_eq!(at.metadata("z/y").permissions().mode(), 0o100222);
assert_eq!(at.metadata("a/a").permissions().mode(), 0o100222); assert_eq!(at.metadata("a/a").permissions().mode(), 0o100222);