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

chmod: correctly handle modes after --

This commit is contained in:
Michael Debertol 2021-08-17 15:35:14 +02:00
parent b841a11421
commit 5825889931
2 changed files with 17 additions and 0 deletions

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" // e.g. "chmod -v -xw -R FILE" -> "chmod -v xw -R FILE"
pub fn strip_minus_from_mode(args: &mut Vec<String>) -> bool { pub fn strip_minus_from_mode(args: &mut Vec<String>) -> bool {
for arg in args { for arg in args {
if arg == "--" {
break;
}
if arg.starts_with('-') { if arg.starts_with('-') {
if let Some(second) = arg.chars().nth(1) { if let Some(second) = arg.chars().nth(1) {
match second { match second {

View file

@ -532,3 +532,17 @@ fn test_no_operands() {
.code_is(1) .code_is(1)
.stderr_is("chmod: missing operand"); .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,
);
}