5 ms·
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’
by sshine 5y ago
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.
- kappattack 5y agoI 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.
- dorianmariefr 5y agosame for `cmd -v` `cmd --version`
- Aachen 5y agoThe 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
- saghm 5y agoI 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).
- deleted 5y ago[deleted]
- LeoPanthera 5y agoDefacto short switch for version is "-V". "-v" is verbose.
- sharken 5y agoAs 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.
- anjbe 5y agoThe 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/ http://harmful.cat-v.org/cat-v/
- randomdata 5y agoTrouble 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.
- riffraff 5y agoHonest 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&sektion=3&apropos=0&manpath=FreeBSD+13.0-RELEASE+and+Ports 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
- everybodyknows 5y ago> 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.
- randomdata 5y ago> 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.
- baby 5y agoOcaml is notorious for having CLIs that use longform options with a single dash. It’s infuriating. So it would be -help in this example
- saghm 5y agoA 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).
- tomsmeding 5y ago> 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.
- saghm 5y ago
- deleted 5y ago[deleted]
- nialv7 5y agosometimes it's because the software existed before the conventions. Such is the case for Xorg.
- deleted 5y ago[deleted]