Skip to content

Commit f04bb82

Browse files
author
Clifford Ressel
committed
Correct chmod -R on dangling symlink and tests
1 parent 61b7f4b commit f04bb82

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/uu/chmod/src/chmod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,11 @@ impl Chmoder {
259259
// Don't try to change the mode of the symlink itself
260260
continue;
261261
}
262-
if !self.quiet {
262+
if self.recursive {
263+
// With recursive, we should ignore dangling symlinks
264+
continue;
265+
}
266+
if !self.recursive && !self.quiet {
263267
show!(USimpleError::new(
264268
1,
265269
format!("cannot operate on dangling symlink {}", filename.quote()),

tests/by-util/test_chmod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,9 @@ fn test_chmod_symlink_to_dangling_recursive() {
892892
.arg("755")
893893
.arg("-R")
894894
.arg(symlink)
895-
.fails()
896-
.stderr_is("chmod: cannot operate on dangling symlink 'symlink'\n");
895+
.succeeds()
896+
.stdout_is("")
897+
.stderr_is("");
897898
assert_eq!(
898899
at.symlink_metadata(symlink).permissions().mode(),
899900
get_expected_symlink_permissions(),

0 commit comments

Comments
 (0)