We've already seen the issue with echo(1): Before we changed it to
ignore "--", the command
$ echo --
did not work as expected. Given POSIX mandated this and makes most
sense, in the interest of consistency the other tools need to be
streamlined for that as well.
Looking at yes(1) for instance, there's no reason to skip "--" in
the argument list.
We do not have long options like GNU does and there's no reason to
tinker with that here.
The majority of tools changed are ones taking lists of arguments
or only a single one. There's no reason why dirname should "fail"
on "--". In the end, this is a valid name.
The practice of hand-holding the user was established with the GNU
coreutils. "--help" and "--version" long-options are a disgrace to
what could've been done properly with manpages.
Quoting POSIX[0]:
"Care should be taken, also, to call _exit() rather than exit() if exec cannot be used, since
exit() flushes and closes standard I/O channels, thereby damaging the parent process' standard
I/O data structures. (Even with fork(), it is wrong to call exit(), since buffered data would
then be flushed twice.)"
[0]: http://pubs.opengroup.org/onlinepubs/009695399/functions/vfork.html
1) no need to include sys/stat.h
2) remove the enum which just added a layer too thick on this simple
program
3) argc-style, other style
4) weprintf instead of enprintf, then save the error-message of
execvp before and return the proper status.
5) write consistent "not reached" comment.