4 ms·
Semi related: if you write software that takes only one of -h or --help, but not both, you are bad and you should feel bad.
by adhesive_wombat 5y ago
Semi related: if you write software that takes only one of -h or --help, but not both, you are bad and you should feel bad.
- scubbo 5y agoEven more so, the worst coworker I ever had once wrote a script that accepted neither, and (when run) would default to trying to process data (and deleting it whether or not it was fully handled) _in production_. The first time we ever ran it (unsuspectingly) was after he'd left for Facebook. Good riddance.
- adhesive_wombat 5y agoOooo, not failing on unknown arguments is evil. It's almost guaranteed at that point that what you're about to do is not what the user expects to happen.
- codeflo 5y agoOne place I worked had very explicit rules about that that would be drilled into new recruits. Besides --help, running without argument was also required to print the help. I was told that this rule came about when they "discovered", presumably at nontrivial cost, a disk imaging tool that would default to unconditionally mirroring the first hard disk onto the second.
- tedunangst 5y agoNot as bad as blindly assuming -h prints help.
- trashburger 5y agoTo be honest, it should, or if you feel like your program is very simple then you could do what feh(1) does and simply print "see man $PROGRAM". Running -h or --help on a program which spits out an "unknown argument" error is one of my pet peeves.
- MaxBarraclough 5y agoGNU cat is on the naughty list, supporting --help but not -h. less is the same (and is not part of GNU). edit Looks like the GNU echo, sort, and uniq programs are the same. GNU has an official policy endorsing --help but not -h. [0] Also related: --version should print the version numbers (and perhaps build details) of the software, and immediately terminate. -v lacks the (at least somewhat) universal meaning of -h, though. Some commands, such as curl, use -v as shorthand for --verbose rather than --version, but all commands should support --version. I believe Java HotSpot used to use -version, supporting neither -v nor --version. Now it supports both --version and -version, but not -v. [0] https://www.gnu.org/prep/standards/html_node/_002d_002dhelp.html https://www.gnu.org/prep/standards/html_node/_002d_002dhelp....
- benibela 5y agoAnd do not forget the most important flag: /?