News for hackers. Stuff that matters.
Re:-h –Help -help Help –? –? by sshine on Monday April 11, 2022 @03:07PM (#30993263)
Whenever I do `cmd -h` or `cmd --help`, and the command fails and asks me to type something else, I always find this a very helpful hint that cmd’s authors don’t have respect for conventions, and that I should be cautious with my expectations from then on.
Re:-h –Help -help Help –? –? by randomdata on Monday April 11, 2022 @07:59PM (#30996819)
Trouble is that some competing approaches appeared around the same time in history and what is convention depends on what you happened to be exposed to.
Re:-h –Help -help Help –? –? by riffraff on Tuesday April 12, 2022 @03:35AM (#30999707)
Honest question: the BSDs adopted getoptlong() 20 years ago[0], what are people being exposed to that uses -single-dash-long-options?[1]

Or were you referring to older utilities/actual unix times?

[0] https://www.freebsd.org/cgi/man.cgi?query=getopt_long&sektio... [1] I mean, there's oddities such as openssl(1) but those seem a minority on every platform

Re:-h –Help -help Help –? –? by everybodyknows on Tuesday April 12, 2022 @12:00PM (#31004413)
> what are people being exposed to that uses -single-dash-long-options?

Go's 'flag' package -- although double-dash is silently accepted on the command line.

The deeper issue with 'flag' is that it rejects the BSD convention of a short/long option pair having guaranteed equivalent semantics e.g. -h/--help. The library just won't let the programmer create such a pair by means of its standard functions.

Re:-h –Help -help Help –? –? by randomdata on Tuesday April 12, 2022 @01:09PM (#31005444)
> Go's 'flag' package

Which uses the Plan 9 convention; the system the Go creators were exposed to. A good example of competing conventions of the past rearing itself in modern tools.

Re:-h –Help -help Help –? –? by baby on Monday April 11, 2022 @08:20PM (#30996994)
Ocaml is notorious for having CLIs that use longform options with a single dash. It’s infuriating. So it would be -help in this example
Re:-h –Help -help Help –? –? by saghm on Tuesday April 12, 2022 @01:39AM (#30998995)
A few of my college courses used OCaml, and it had lots of conventions like this that I found somewhat odd. If I remember correctly, exceptions (which were not used that often from what I could tell due to preferences for handling errors in a more algebraic manner) are named with casing like `Not_found`, which I don't even know the name for (maybe "capitalized snake-case?), I assume to try to make them resemble the capitalization scheme that sentences use. I also remember finding it quite strange to read types annotated with a space before the colon (e.g. `let x : int in`); a friend told me that this was due to OCaml's authors being French, which unlike English puts spaces in front of colons in prose. Combined with the fact that we were taught only a subset of the language (we never once learned how to use the object system for which the "O" was put in OCaml), and we were processed provided with pre-written build files for projects and not taught much how how to use the build tools, writing OCaml always felt somewhat surreal for me. Overall though, I did learn a lot from those classes, and I think it was a good choice for teaching the concepts the courses were intended to cover (especially the compilers course, which in retrospect I would have found much more tedious if course was taught in C or Java or something).
Re:-h –Help -help Help –? –? by tomsmeding on Tuesday April 12, 2022 @03:50AM (#30999773)
> I also remember finding it quite strange to read types annotated with a space before the colon (e.g. `let x : int in`); a friend told me that this was due to OCaml's authors being French, which unlike English puts spaces in front of colons in prose.

Maybe, but I find it more likely that they just copied math notation. In mathematics (broadly, not just theoretical CS, also analysis), the type of something is indicated with an infix `:`, like `f : A -> B` is a function from A to B. This colon conventionally has equal spacing on both sides, like a regular infix operator.

Re:-h –Help -help Help –? –? by saghm on Tuesday April 12, 2022 @12:53PM (#31005196)
That's possible as well. I have no idea about the accuracy of my friend's claim, which is why I relayed it as hearsay rather than stating it as a fact I was sure about.
Re:-h –Help -help Help –? –? by baby on Tuesday April 12, 2022 @04:24PM (#31007812)
A lot of the decisions in OCaml seem related to the French language, which adds a space before the : (unlike in english).

There's the "Thing of int" weirdness also

Re:-h –Help -help Help –? –? by silentOpen on Tuesday April 12, 2022 @04:27AM (#30999996)
OCaml exception constructors are just term constructors in the open sum type `exn`. In OCaml, to distinguish constructors from bound variables, constructors must begin with a capital letter. Thus `let Foo = 4;;` is an error.
Re:-h –Help -help Help –? –? by nyuszika7h on Tuesday April 12, 2022 @09:49AM (#31002714)
That doesn't explain why they couldn't have used `Not_Found` or `NotFound` instead.
Re:-h –Help -help Help –? –? by kappattack on Monday April 11, 2022 @04:58PM (#30994918)
I agree, but I dunno maybe this is more new school than I realize. I'm willing to accept the possibility that other people have been exposed to conventions I haven't. On my personal projects I stick to this convention though, it just feels like the right thing to do.
Re:-h –Help -help Help –? –? by nialv7 on Monday April 11, 2022 @11:40PM (#30998326)
sometimes it's because the software existed before the conventions. Such is the case for Xorg.
Re:-h –Help -help Help –? –? by dorianmariefr on Monday April 11, 2022 @07:35PM (#30996615)
same for `cmd -v` `cmd --version`
Re:-h –Help -help Help –? –? by Aachen on Monday April 11, 2022 @08:01PM (#30996838)
The first one is verbose, not version, though? Not sure if you're used to a set of utilities that doesn't intersect the ones I'm used to where -v is version. I've seen -V, though.

And then there's grep

Re:-h –Help -help Help –? –? by saghm on Tuesday April 12, 2022 @01:42AM (#30999023)
I agree that -V is more common. I have used a few things that use -v for version though (I think `ruby` does, which led to some confusion for me the first time I tried to pass that to `python` and instead of getting the version number found myself in a more chatty than normal python shell).
Re:-h –Help -help Help –? –? by anjbe on Tuesday April 12, 2022 @01:51AM (#30999066)
The cat command is rather infamous for using -v to mean “visual” (as in, convert invisible characters to something visible).

But the infamy is not that it used -v for something other than “version”—I doubt that convention existed in 1983, when the complaint was made—but rather that it was a sign of the ever‐growing complexity of specific Unix tools at the expense of the harmony of the whole system.

See “Program design in the UNIX environment,” by Rob Pike and Brian Kernighan, USENIX 1983: http://harmful.cat-v.org/cat-v/

Re:-h –Help -help Help –? –? by LeoPanthera on Monday April 11, 2022 @10:26PM (#30997885)
Defacto short switch for version is "-V". "-v" is verbose.
Re:-h –Help -help Help –? –? by sharken on Tuesday April 12, 2022 @06:14AM (#31000666)
As is quite clear in this thread, there really is no unified way of doing things.

Uppercase switches also strikes me as not very intuitive, either you need to look at the help page or you have to have the same mindset as the developer.

And still, the distinction between lowercase and uppercase switches are not easy to remember.

For the power user though it makes sense.