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

chmod: fail if the operand list is empty

This commit is contained in:
Michael Debertol 2021-08-17 15:27:34 +02:00
parent 945e57ea22
commit b841a11421
2 changed files with 13 additions and 0 deletions

View file

@ -98,6 +98,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
Some(cmode) Some(cmode)
}; };
if files.is_empty() {
crash!(1, "missing operand");
}
let chmoder = Chmoder { let chmoder = Chmoder {
changes, changes,
quiet, quiet,

View file

@ -523,3 +523,12 @@ fn test_chmod_keep_setgid() {
assert_eq!(at.metadata("dir").permissions().mode(), to); assert_eq!(at.metadata("dir").permissions().mode(), to);
} }
} }
#[test]
fn test_no_operands() {
new_ucmd!()
.arg("777")
.fails()
.code_is(1)
.stderr_is("chmod: missing operand");
}