5 ms·
I always forget the "version" switch. Is it '-v' or '--version' or '-version', everything's just a bit different and I can never remember what needs what to tel
by blakesterz 5y ago
I always forget the "version" switch. Is it '-v' or '--version' or '-version', everything's just a bit different and I can never remember what needs what to tell me its version.
[edited to add] As others have reminded me, there's also simply 'version'
- pphysch 5y agoI automatically assume `-v` is short for `--verbose` rather than `--version`, and always type out the latter.
- cute_boi 5y agoI don't know but I always expect -V for verbose, and -v for version. However, I do acknowledge its not consistent :(
- timoteostewart 5y agoAnd not to leave out `go version`...
- laurent92 5y agoEverything uses --version, except `java -version`. Except Java 17. Java 17 went to `java --version`. And `java -version` doesn’t work anymore (Yes I jumped from Java 8 to 17, but most people did).
- Wevah 5y agoAnd (e.g.) OpenSSL IS `openssl version`, with no dashes at all.
- saghm 5y agoTo be fair, when deciding how to implement CLI options, it's probably advisable to run as far away as you can from drawing any sort of inspiration from openssl. Even git looks like a paragon of UX compared to the openssl CLI.
- account42 5y agoYou don't think that -text -noout is an intuitive way to output something as text?
- yakubin 5y agomawk is the worst, which, given the article's claim about POSIX, is ironic, because mawk is POSIX-compliant. $ mawk --version mawk: not an option: --version $ mawk --help mawk: not an option: --help $ mawk -W version mawk 1.3.4 20200120 Copyright 2008-2019,2020, Thomas E. Dickey Copyright 1991-1996,2014, Michael D. Brennan random-funcs: srandom/random regex-funcs: internal compiled limits: sprintf buffer 8192 maximum-integer 2147483647 And mawk is (was in 16.04 at least) the default version of awk on Ubuntu. How is the user supposed to know this magic incantation? ¯\_(ツ)_/¯
- mananaysiempre 5y agoTo be fair, I can see this coming out of a strict reading of POSIX: it doesn’t say a single word about GNU-style long options (though there is an implied hole where they can fit), but explicitly leaves -W with an argument as a place for implementation-defined crufties when passed to Awk (I haven’t the slightest idea why). (Honestly I’d rather not have the convention of programs themselves handling this at all and instead have this be `ident awk` or similar, but I understand this is not going to happen.)
- saghm 5y agoI can only imagine that the "w" stands for "what the hell do I need to pass this thing to get it to tell me something useful"
- layer8 5y agoWhen development on Java started in 1991, double-dash long options weren’t as prevalent as they are today.
- twic 5y ago-version still works: $ java -version openjdk version "18" 2022-03-22 OpenJDK Runtime Environment Temurin-18+36 (build 18+36) OpenJDK 64-Bit Server VM Temurin-18+36 (build 18+36, mixed mode, sharing)
- dcminter 5y agoI think at one point the canonical approach may even have been: java -D-version
- gotaquestion 5y agoI laugh at verbose options that are: -v for basic verbose -vv for more -vvv for even more -vvvv oh come on you've got to be kidding -vvvvv nope, they're not kidding
- banana_giraffe 5y agoI keep hoping someone will do this with -v², -v³, and so on.
- Aachen 5y agoWhere the base value is two and -v³ is a shortcut for -vvvvvvvv? Because it wouldn't work with a base of one (1³=1). Just assessing expectations because I do like the idea and would implement it (in addition to the expected way) next time it comes up
- banana_giraffe 5y agoIn my mind, -v³ would be the same as -vvv, and -v⁴ for -vvvv, and on and on. I suppose you could really take it to some absurd level with -v¹⁰ for -vvvvvvvvvv
- layer8 5y agoThe v is log scale, which does make some sense in terms of output volume. ;)
- na85 5y agoAh, but you'd have to error on any even power, since of course a negative squared is positive, thus -v^2 would be v^2 and without the dash you can't be sure it's a switch.
- floodle 5y agoThere's an easy solution to this: just use i for even exponents. So (-iv)² = -vv and once you've escaped the brackets in bash all is good. I think we're on to something here....
- bxparks 5y agoI went through this ritual almost every time: $ java --version Unrecognized option: --version $ java -v Unrecognized option: -v $ java -version openjdk version "1.8.0_312" Looks like this was fixed in JDK 11. But Java isn't as sadistic as Go lang: $ go --version [scrolls off screen] $ go --version | less [scrolls off screen] $ go --version 2>&1 | less [search for 'version' command] $ go version go version go1.17.2 linux/amd64
- MawKKe 5y agoRelated: my feeble attempt at adding -h and --help to go subcommands: https://gist.github.com/MawKKe/485ad4ce21223309d2e90713f3b9b5ba https://gist.github.com/MawKKe/485ad4ce21223309d2e90713f3b9b... (might be really buggy, let me know)
- skrtskrt 5y agodon't forget grep -v: "-v, --invert-match"
- distortedsignal 5y agoThis one is actually really interesting! I would guess that it comes from electrical engineering, and specifically the signal processing side of things where filters happen. One option for filters are “notch filters” [1], and the letter “v” looks like a notch. So just think of “notching-out” a signal when you’re trying to remove something from your grip results. [1] https://en.wikipedia.org/wiki/Band-stop_filter https://en.wikipedia.org/wiki/Band-stop_filter
- Brian_K_White 5y agoMight just be that i was taken for case insensitive. 62 characters is not a lot for tools that have a lot of settings. In the case of tools like grep, the settings are really more of a command vocabulary, and should rightly be written in their own language in a script file, like sed and awk, but grep makes some especially commonly needed ops available as a simpler command with switches for convenience. And that results in some seemingly arcane and inconsistent commandlines. Defining how to search for something is just not a simple 2 or 3 options covers it kind of job. By contrast, another tool with the same problem but clearly originated from a different starting idea is 'find'. It also has to have essentially a vocabulary to express your intentions in composed sentences, and it ends up with a mix of switches and words.
- saghm 5y agoI'd guess that it's probably just that `-i` and `-n` were used for other options, and `-v` is the next letter and a fairly prominent sound in the word.
- cpu 5y agoPerhaps it was simply an available letter, as saghm said, but I've always imagined that at least part of the origin story is that it's a mnemonic for "invert" or "negative".
- amanzi 5y agoDon't forget the capital 'V' option, e.g. `python3 -V` I usually assume that lower-case 'v' is for verbose.
- Brian_K_White 5y ago...which is often confused with the switch for verbose
- mc4ndr3 5y agoI tend to dedicate -v for version data in my apps, and use a -d(ebug) flag for more verbose logging. Or even follow the VERBOSE env var convention. With some apps it's damn near impossible to query the version, especially cross platform. I used to manage a database of that syntax with a tool called "specs".
- IgorPartola 5y ago-d is for daemon mode (never default to this) -p is for PID file -l is for log file -v is for version -L is for verbosity level (e.g.: -L debug) -c is for config file (where all the other options may be specified instead) -h is for help The rest are context-specific.