# BSD documentation says 'X' is to be ignored unless # the operator is '+'. GNU, HP, SunOS and Solaris handle # '-' and '=', while OpenBSD ignores only '-'. # Solaris, HP and OpenBSD all turn a file with permission # 666 to a file with permission 000 if chmod =X is # is applied on it. SunOS and GNU act as if chmod = was # applied to it. I cannot find out what the reasoning # behind the choices of Solaris, HP and OpenBSD is. # GNU and SunOS seem to ignore the 'X', which, after # careful studying of the documentation seems to be # the right choice. # Therefore, remove any 'X' if the operator ain't '+'; $perms =~ s/X+//g unless $operator eq '+'; # We know the operator eq '+'. # Permission of `X' is special. If used on a regular file, # the execution bit will only be turned on if any of the # execution bits of the _unmodified_ file are turned on. # That is, # chmod 600 file; chmod u+x,a+X file; # should result in the file having permission 700, not 711. # GNU and SunOS get this wrong; # Solaris, HP and OpenBSD get it right. next unless -d $file || grep {$orig {$_} & 1} @ugo; #### =item B The execute permission bit, but only if the target is either a directory, or has at least one execution bit set in the unmodified permission bits. Furthermore, this permission is ignored if I is either B> or B>.