Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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'



I 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


Related: my feeble attempt at adding -h and --help to go subcommands: https://gist.github.com/MawKKe/485ad4ce21223309d2e90713f3b9b...

(might be really buggy, let me know)


I automatically assume `-v` is short for `--verbose` rather than `--version`, and always type out the latter.


I don't know but I always expect -V for verbose, and -v for version. However, I do acknowledge its not consistent :(


I 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


I absolutely hate this convention. Not only is there often very little documentation about what exactly gets added in for each verbosity level, making me guess randomly and then maybe binary search to find what I need with minimal noise, its basically impossible for me to differentiate repeated characters beyond 4 without using a cursor to step though them. I don't have any opposition to fine-grained log levels, but geez, just make it `-v [VERBOSITY (default 1)]` or something sane like that.


  -vv ⇒ -w
  -vvvv ⇒ -ww
Just a joke :)


-w should be equivalent to -uu surely!


Not in France ;)


Well usually you can use -vvvv -> -vv -vv so if you make your font size small enough that vv looks like a w..


And yet… now I am deeply wishing for this. :-)


I keep hoping someone will do this with -v², -v³, and so on.


Where 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


Ah, 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.


There'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....


Nah exponents have higher precedence than signs, it gets annoying otherwise.


The v is log scale, which does make some sense in terms of output volume. ;)


In 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


Don't forget the capital 'V' option, e.g. `python3 -V`

I usually assume that lower-case 'v' is for verbose.


Everything 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).


mawk 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? ¯\_(ツ)_/¯


To 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.)


I 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"


-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)


And (e.g.) OpenSSL IS `openssl version`, with no dashes at all.


To 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.


You don't think that -text -noout is an intuitive way to output something as text?


When development on Java started in 1991, double-dash long options weren’t as prevalent as they are today.


I think at one point the canonical approach may even have been:

java -D-version


don't forget grep -v:

"-v, --invert-match"


This 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


I'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.


Might 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.


Perhaps 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".


I 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".


-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.


-f can be for configuration file as well (see: apache httpd, mongod, and sshd)


-c is often command


And not to leave out `go version`...


...which is often confused with the switch for verbose




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: