4 ms·
It’s not just “easier for a human” but more stable over time as commands evolve, and less likely to do weird things across Unix variants. Some command-line par
by makecheck 6y ago
It’s not just “easier for a human” but more stable over time as commands evolve, and less likely to do weird things across Unix variants.
Some command-line parsers will auto-complete partial options so you’re less likely to see ambiguity errors in future versions if you picked long-form options. (This isn’t completely foolproof, e.g. a command could have "--foo" and later add "--foobar" but it does help in most cases.)
And unfortunately, some tools with the same name will use the same letter to mean different things across Unix variants. You are asking for trouble if you aren’t being clear about what you want.
- zbuf 6y ago> Some command-line parsers will auto-complete partial options This sort of behaviour is tortuous, and should be against international laws. Where _adding_ new, unrelated, options to the interface now changes or breaks the behaviour of existing calling scripts. Plus you never know which abbreviations are in use in the wild. It makes it virtually impossible to maintain a stable interface without just freezing it long-hand. I found this in Perl code; I believe it might be the default behaviour in the standard parser? Our developer really did like the philosophy that "the user may want 50 different ways to express the same thing".
- ucarion 6y agoUnfortunately, this isn't quite true. At least if by Unix you mean POSIX, i.e. you include macOS in your considerations. 1. Sadly, short options are in fact more portable than long options if you're targeting POSIX. For instance, macOS ships with versions of ls, rm, et cetera that only support short flags. This is because long options don't exist at all in POSIX (they're formalized here: https://pubs.opengroup.org/onlinepubs/009695399/functions/getopt.html https://pubs.opengroup.org/onlinepubs/009695399/functions/ge...). 2. Auto-completing partial options only happens for long flags, and it's a bit more than "some" parsers; the canonical implementation of "long" options, GNU's getopt_long, has it as a documented feature: > Long option names may be abbreviated if the abbreviation is unique or is an exact match for some defined option. https://linux.die.net/man/3/getopt_long https://linux.die.net/man/3/getopt_long I 100% agree it's a poor feature. You basically entirely preclude yourself from adding features in a backwards-compatible way.