3 ms·
I find it quite annoying every time I need to check the installed version of java and `java --version` doesn't work (I need to type `java -version`).
by barbs 10y ago
I find it quite annoying every time I need to check the installed version of java and `java --version` doesn't work (I need to type `java -version`).
- lucb1e 10y agoI've made that mistake at least once, if not more than once.
- OJFord 10y agoI hate `-long` style options too. It's not just aesthetic/confusing, it's objectively worse/more limited: - It means `-thing` != `-t -h -i -n -g`, so the latter has to be that long; - You also can't have `readable-long-things-as-an-option`; - You can't (or not without crazy logic and a confusing UX) have variables passed with no space, like `-ffoobar`
- lucb1e 10y agoIn that third case, I find it crazy logic and confusing UX to have values with no space. If I type mysql -uroot on the command line, that should be equivalent to mysql -u -r -o -o -t but it's not.
- okdana 10y agoWell the argument parser knows that `-u` must take a value, and the only way it can really associate it with its value is positionally (i.e., the value is the stuff that immediately follows it). So it could force you to make the value a separate argument, but that would be a purely arbitrary restriction — it couldn't allow anything but the value to follow, so it'd just have to return an error for the sake of it. This behaviour is defined in POSIX, btw: >If the SYNOPSIS of a standard utility shows an option with a mandatory option-argument (as with [-c option_argument] in the example), a conforming application shall use separate arguments for that option and its option-argument. However, a conforming implementation shall also permit applications to specify the option and option-argument in the same argument string without intervening <blank> characters.
- lucb1e 10y agoOh, I had never thought of it like that. That makes sense! I just treated those commands (like mysql) as one of those commands where -every -option -must -be -separate. I suppose I don't mind that syntax anymore now. Thanks for changing my mind :)
- Annatar 10y agoIt is the (social contract) responsibility of the programmer to document in the usage and in the manual page that -u takes a username as an argument, and where such documentation exists, the convention is that username may be provided as -uuser or -u user. This is trivially achievable with getopts(1): while getopts u: Option do case "$Option" in u) User="$OPTARG" ;; esac done The colon tells getopts(1) that the -u option expects an argument. This behavior is also mandated by the POSIX specification.
- vacri 10y agoDon't worry, java makes up for it by putting all the config into flags. At one place, I have a triple-monitor setup, all in a horizontal line. This was still not enough for one java application (elasticsearch? logsearch?) - even stretched across all three screens, I couldn't see the full process string on a single line :)