top | item 30993206

(no title)

laurent92 | 3 years ago

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

discuss

order

yakubin|3 years ago

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

mananaysiempre|3 years ago

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

saghm|3 years ago

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"

twic|3 years 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)

Wevah|3 years ago

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

saghm|3 years ago

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.

layer8|3 years ago

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

dcminter|3 years ago

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

java -D-version