Craig White wrote:
you may very well be right on this - I thought the shell passed the
commands over to the binary.
It does, but it doesn't interpret the arguments.
The biggest difference between GNU and other Unix systems is getopt(3).
Other Unix getopt implementations will stop interpreting arguments as
options when it finds the first non-option argument. GNU getopt doesn't
do that.
In the case of "chown root:root bin -R", a Unix getopt would see
"root:root" as a non-option argument (it doesn't start with a '-'), and
would stop looking for option arguments. getopt (and, hence, chown)
would think that '-R' was a file that should be modified.
GNU getopt will parse the same command differently. It would not stop
looking for options when it reaches a non-option argument. It will only
stop searching for option when it finds '--' as an option. Therefore,
if you *did* want to change the ownership of a file called '-R', you'd
enter something like "chown root:root -- -R".