coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

chmod: `-c` reports changes even on no-op

Open BenWiederhake opened this issue 1 year ago • 0 comments

Example:

$ chmod -c --reference README.md README.md  # GNU
$ cargo run --all-features chmod -c --reference README.md README.md
mode of 'README.md' changed from 0644 (rw-r--r--) to 100644 (rw-r--r--)
$ cargo run --all-features chmod -c --reference README.md README.md
mode of 'README.md' changed from 0644 (rw-r--r--) to 100644 (rw-r--r--)
$ chmod -c --reference README.md README.md  # GNU
$ cargo run --all-features chmod -c --reference README.md README.md
mode of 'README.md' changed from 0644 (rw-r--r--) to 100644 (rw-r--r--)
$ cargo run --all-features chmod -c --reference README.md README.md
mode of 'README.md' changed from 0644 (rw-r--r--) to 100644 (rw-r--r--)

Expected behavior: By definition, chmod --reference README.md README.md should not change any permissions. By definition of -c, this flag should be like verbose but report only when a change is made. Since no change was made, no change should be reported.

Actual behavior: It looks like chmod attempts to change permissions (buggy), and also reports them (buggy).

I'm not sure whether that's one or two bugs.

BenWiederhake avatar Feb 24 '24 20:02 BenWiederhake