3 ms·
Equally I don't like how many instructions and scripts everywhere use shorthands. Sometimes you see curl -sSLfO. Please, use the long form. It makes life easie
by OptionOfT 10mo ago
Equally I don't like how many instructions and scripts everywhere use shorthands.
Sometimes you see curl -sSLfO. Please, use the long form. It makes life easier for everybody. It makes it easier to verify, and to look up. Finding --silent in curl's docs is easier than reading through every occurrence of -s.
curl --silent --show-error --location --fail --remote name https://example.com/script.sh
Obligatory xkcd: https://xkcd.com/1168/ https://xkcd.com/1168/
- ndsipa_pomu 10mo agoAbsolutely agree. The shorthands are for when typing it at a console and the long form versions should be used in scripts.
- Terr_ 10mo agoFor a small flight of fancy, imagine if each program had a --for-docs argument, which causes it to simply spit out the canonical long-form version equivalent to whatever else it has been called with.
- ndsipa_pomu 10mo agoOr, a separate program that can convert from short to long form: > for-docs "ls -lrth /mnt/data" ls -l --reverse -t --human-readable -- /mnt/data (I'd put in an option to put the options alphabetically too)
- Terr_ 10mo agoWhile I'd appreciate that facility too, it seems... even-more-fanciful, as one tool would need to somehow incorporate all the logic and quirks of all supported commands, including ones which could be very destructive if anything went wrong. Kind of like positing a master `dry-run` command as opposed to different commands implementing `--dry-run` arguments.
- ndsipa_pomu 10mo agoI did muck around with using "sed" to process the "man" output to find a relevant long option in a one-liner, so it wouldn't be too difficult to implement. I did something like this: _command="sed" _option="n" man -- "${_command}" | sed --quiet --expression "s/^ -${_option}.*, //p" Then I realised that a bit of logic is needed (or more complicated regexp) to deal with some exceptions and moved onto something else.
- scrame 10mo agoagreed. i get if you're great at cli usage or have your own scripts, but if you're publishing for general use, it should be long form. that includes even utility scripts for a small team. also, putting it out long-form you might catch some things you do out of habit, rather than what's necessary for the job.
- ndsipa_pomu 10mo agoAnother possible advantage is that I invariably have to check the man page to find the appropriate long-form option and sometimes spot an option that I didn't know about.
- yjftsjthsd-h 10mo ago> Finding --silent in curl's docs is easier than reading through every occurrence of -s. Dumb trick: Search prefixed with 2 spaces. man curl / -s Yields exactly one hit on my machine. In the general case, you may have to try one and two spaces.
- lionkor 10mo agoAren't there tools for which the short flags are standardized (e.g. POSIX) but the long flags aren't?