chmod: correctly handle modes after --

This commit is contained in:
Michael Debertol
2021-08-25 13:52:09 +02:00
parent b841a11421
commit 5825889931
2 changed files with 17 additions and 0 deletions
+3
View File
@@ -184,6 +184,9 @@ pub fn uu_app() -> App<'static, 'static> {
// e.g. "chmod -v -xw -R FILE" -> "chmod -v xw -R FILE"
pub fn strip_minus_from_mode(args: &mut Vec<String>) -> bool {
for arg in args {
if arg == "--" {
break;
}
if arg.starts_with('-') {
if let Some(second) = arg.chars().nth(1) {
match second {
+14
View File
@@ -532,3 +532,17 @@ fn test_no_operands() {
.code_is(1)
.stderr_is("chmod: missing operand");
}
#[test]
fn test_mode_after_dash_dash() {
let (at, ucmd) = at_and_ucmd!();
run_single_test(
&TestCase {
args: vec!["--", "-r", TEST_FILE],
before: 0o100777,
after: 0o100333,
},
at,
ucmd,
);
}