GNU chmod has some... ehh... interesting behaviour when it comes to leading hyphens in the mode:
changes the permissions of f (and not of a file called -w). uutils simply throws an error because it does not expect the flag -w.
On the other hand,
does try to change the permissions of a-w and f.
However, this behaviour changes when the -w is passed after --, because
tries to modify both -w and f. This case is currently handled correctly in uutils, but I still included it here, because it is likely to break for some naive solutions to this issue.
All this is tested in the chmod/usage.sh tests from GNU. The cases tested there are listed below, where the provided arguments are on the left, followed by a colon and the files that it will try to chmod:
-- :
-- -- :
-- -- -- f : -- f
-- -- -w f : -w f
-- -- f : f
-- -w :
-- -w -- f : -- f
-- -w -w f : -w f
-- -w f : f
-- f :
-w :
-w -- :
-w -- -- f : -- f
-w -- -w f : -w f
-w -- f : f
-w -w :
-w -w -- f : f
-w -w -w f : f
-w -w f : f
-w f : f
f :
f -- :
f -w : f
f f :
u+gr f :
ug,+x f :
GNU
chmodhas some... ehh... interesting behaviour when it comes to leading hyphens in the mode:changes the permissions of
f(and not of a file called-w). uutils simply throws an error because it does not expect the flag-w.On the other hand,
does try to change the permissions of
a-wandf.However, this behaviour changes when the
-wis passed after--, becausetries to modify both
-wandf. This case is currently handled correctly in uutils, but I still included it here, because it is likely to break for some naive solutions to this issue.All this is tested in the
chmod/usage.shtests from GNU. The cases tested there are listed below, where the provided arguments are on the left, followed by a colon and the files that it will try to chmod: