diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index c98e4af89e..f67db7c8c1 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -81,11 +81,13 @@ fn extract_negative_modes(args: impl uucore::Args) -> (Option, Vec= 2 && arg.starts_with('-') && matches!( arg.chars().nth(1).unwrap(), - 'r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0'..='7' + 'r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '=' | '+' | ',' | '0'..='7' ) }; diff --git a/tests/by-util/test_chmod.rs b/tests/by-util/test_chmod.rs index afbf7e23e1..0fe8b5192d 100644 --- a/tests/by-util/test_chmod.rs +++ b/tests/by-util/test_chmod.rs @@ -364,6 +364,31 @@ fn test_chmod_many_options() { run_tests(tests); } +#[test] +fn test_chmod_option_like_mode_starting_with_operator() { + let tests = vec![ + TestCase { + args: vec!["-=r", TEST_FILE], + before: 0o100_644, + after: 0o100_444, + umask: Some(0o022), + }, + TestCase { + args: vec!["-+x", TEST_FILE], + before: 0o100_644, + after: 0o100_755, + umask: Some(0o022), + }, + TestCase { + args: vec!["-,u+x", TEST_FILE], + before: 0o100_644, + after: 0o100_744, + umask: Some(0o022), + }, + ]; + run_tests(tests); +} + #[test] #[allow(clippy::unreadable_literal)] fn test_chmod_reference_file() {