20

I am interested to hear about the history because I have a prominent command line product that has decided to use -h for something that does not print a help message.

when did command line applications start using "-h" as a "standard" way to print "help"?

I guess it would be interesting to hear when it first was started and also when it became a sort of "standard" thing to do. I guess it would also be interesting to hear what system in addition to the time.

Leo B.
  • 19,082
  • 5
  • 49
  • 141

3 Answers3

30

TL;DR Never

It is common, but far from universal. For example, the ls command to this day does not have -h for help. -h is for "human readable" with only --help for help.

My hunch is that older commands tended to use -h for other things, long before help was standard, and then later added --help. Arguably a new command should use -h and --help identically, a command that does not do so will not be in any way unusual.

  • 24
    From my observations, I think the '--help' might have originated with the GNU project...? At least, many of the double-dash command extensions in documentation seem to be referencing GNU extensions to traditional UNIX utilities. I am probably wrong here, but throwing the idea out there to see if it sticks :) – bjb Mar 15 '23 at 16:26
  • 6
    @bjb true, the double hyphen convention was introduced by GNU guidelines for long options. – Raffzahn Mar 15 '23 at 17:19
  • 1
    The long options tend to be more readable for someone not knowing that manual page by heart. – Thorbjørn Ravn Andersen Mar 15 '23 at 18:31
  • 29
    Worst are the programs that respond to -h with something like Type command --help for help. They know you're asking for help, but they refuse to provide it. So very Gnu. – scruss Mar 15 '23 at 22:31
  • 8
    @scruss By returning an error message instead of doing something useful, this ensures nothing is ever coded to use -h for help, so it can be assigned in the future, without breaking compatibility. – user71659 Mar 16 '23 at 02:54
  • 2
    @user71659 I'm old enough to remember when -h meant Help on unix systems. It is needlessly mean; they could easily have pasted the help text after their smug little message, but they chose not to be helpful. Bad cess to 'em! – scruss Mar 16 '23 at 04:02
  • 8
    @scruss No it's not mean or them being cute, but a real software engineering issue. If they pasted the help text, people would simply ignore the --help message since it still does useful work. This is how APIs become bloated: somebody took advantage of unofficial or defective behavior and now you have to support it forever. – user71659 Mar 16 '23 at 04:19
  • 1
    @Raffzahn In fact I think that --version and --help were introduced by GNU in advance of the long-form options. – Mark Morgan Lloyd Mar 16 '23 at 07:29
  • 1
    @scruss Inadvertently getting a substantial amount of help text on a slow-speed output device (a Teletype or serial terminal) is counterproductive. – Mark Morgan Lloyd Mar 16 '23 at 07:31
  • 1
    @scruss -h didn't mean help on Unix systems. cat, mv, ls, cp: On all of these commands -h is either an illegal option or does something else. Likely what you were seeing was the standard text pat out when you type an illegal option. – JeremyP Mar 16 '23 at 09:22
  • @user71659 That's a valid engineering reason. It doesn't necessarily make it a valid UX reason. – chepner Mar 16 '23 at 12:58
  • @chepner That's an inherent conflict when you're mixing programmatic access to an interface, where the caller is pre-set and inflexible, with human access, where the user is often wrong but adaptable. – user71659 Mar 16 '23 at 17:40
  • 1
    @scruss these programs do not “know you're asking for help”. These program only know that you specified invalid options and respond with Type command --help for help. They do not try to guess the meaning of invalid options. By your reasoning, I could specify --I-am-lost and then complain about the response Type command --help for help because “they know I’m asking for help”. No, they don’t know. Unix programs are not ChatGPT. – Holger Mar 17 '23 at 07:49
  • 1
    @Holger - no, I've seen it in argument processing in C source: -h explicitly triggering the --help method. I love the way people are jumping on assuming I have no clue here – scruss Mar 17 '23 at 10:41
  • @scruss ok, quick test: cp -h: “cp: invalid option -- 'h' Try 'cp --help' for more information.” cp --please-help-me: “cp: unrecognized option '--please-help-me' Try 'cp --help' for more information.”, cp --I-dont-need-help: “cp: unrecognized option '--I-dont-need-help' Try 'cp --help' for more information.” Yes, surely a sign that -h is treated specially… – Holger Mar 17 '23 at 11:03
  • The original Unix commands didn't have any help options, and Gnu versions are not good examples because they can be inconsistent in accepting -h as a synonym for --help – scruss Mar 18 '23 at 14:25
19

I am interested to hear about the history because I have a prominent command line product that has decided to use -h for something that does not print a help message.

-h being help was never formally declared as standard. It's a (mostly) accepted convention. If a tool has a different, more sensible use for h, then it's up to that tool what to use.

Maybe because it's simply the most easy to guess single character to come up with when having no idea how a utility works or how to ask for more information.

I guess it would be interesting to hear when it first was started and also when it became a sort of "standard" thing to do.

I once heard this:


A Tale of Conquering the Frontier Land East of the Command Name

In 'ye olde times of total freedom' it was an anything goes - some may say a lawless time - out there in Computing Gulch.

Asking for help is an exceptional use, so quite often ? was chosen as that nicely leaves all letters free for regular use. But there wasn't any general preference for it versus using other brands. Some ranchers liked the h while others wanted to see a H.

Then sheriff POSIX was sent to town by the authorities in 1988. He was supposed to not only bring law to one town but all of the wild lands. One of his very first measures was to tame the command line with his 14 commandments of Utility Syntax Guidelines. Most relevant here are number three and four:

  • Guideline 3:

    Each option name should be a single alphanumeric character (the alnum character classification) from the portable character set.

  • Guideline 4:

    All options should be preceded by the '-' delimiter character.

Thus the humble question mark had to leave the town, -h became for many the place to ask for help. And while h wasn't really enforced, it became an accepted convention

All was nice, and the citizens of Computing Gulch did like the new cleaned up environment. Still it was a frontier place with mighty ranchers driving their GNU to town to ship them worldwide. While they liked the new conformity, they had to maintain their status as the true powers behind and insisted to tweak those 14 into Nine. At the same time felt there was still something missing. Not at least as their cattle were of course the most mighty and capable of all. They were sure that even twice 26 letters weren't enough.

So GNU introduced the long option name as part of their Program Argument Syntax Conventions. They shunned anyone calling it bloaty. To pacify their fellow citizens they added another hyphen (--option). In fact, this worked better than expected as --help can now be used everywhere, even in saloons where if -h was reserved for handling the holster rack.

That's the way law and order was brought to Command Line Valley and everyone lived happy ever after.


Of course this is just a single tale, colported by news papers and pulp 'literature'. Other valley and villages may have had different experience and still live by different conventions.

I guess it would also be interesting to hear what system in addition to the time.

While command line parameters date back to 'ancient' systems like Multics or TOPS-10 (*1), the whole modern origin is ofc. *NIX. So pick anything inbetween PDP-11 to 8086 or thereafter.


*1 - Or RDOS/AOS when it comes to the MS-DOS/Windows separator of '/'.

Raffzahn
  • 222,541
  • 22
  • 631
  • 918
  • although, i sometimes - maybe even often - see -? - wonder if that was a kind of passive-aggressive reaction to the new sheriff ...? – davidbak Mar 16 '23 at 00:10
  • 5
    -? is some sort of cultural appropriation from Windows, which generally uses /? for 'help'. – dave Mar 16 '23 at 01:07
  • 2
    @another-dave That's extremely plausible, but is it definitely true? Did Windows make it up it steal/inherit it from somewhere else? – hippietrail Mar 16 '23 at 05:01
  • One thing about ? is that in standard getopt(3) it's the character used to signal an unknown option being parsed, so it is impossible to actually define -? as an option; it always triggers the program's "sorry, unknown option encountered" message, which then may or may not output the usage text for you. (Other option parsers do not have this limitation, but most Unix-ish things written in C use getopt.) – grawity Mar 16 '23 at 16:15
  • 1
    /? might be reasonable for Windows, but not on a Unix-like system where the shell expands * and ? wildcards before the program ever sees them. – dan04 Mar 16 '23 at 17:39
  • 2
    @user1686 I think, the source of all “xyz is for help” myths is the fact that programs back then didn’t have a special help option but just printed the usage when encountering an unknown or wrong option so you could sell any actually invalid option as “help option” because it apparently worked. The long help text still was requested with “man command” though. – Holger Mar 17 '23 at 08:02
  • @dan04, this, -? could turn to -f if a file by that name existed. And in some shells, like tcsh and zsh, it'd give an error without running the command if no matching file existed. So it'd need to be given as '-?', or -\? or so, and that's not very user-friendly – ilkkachu Mar 17 '23 at 19:54
  • @ilkkachu isn't that exactly the point about there being no unified way of asking for short help before --help? – Raffzahn Mar 17 '23 at 20:21
  • 1
    @Raffzahn, huh? The point was that -? would be a really bad choice because of how it interacts with other features. I don't think that has anything to do with the lack of a unified choice per se, as e.g. -h and -H would not have that problem, even if there was no general agreement on which one to use. (Of course, the way globbing works depends on the shell, and it might have been different in the olden days, but IIRC csh isn't any newfangled thingy, so that issue might have existed a while.) – ilkkachu Mar 18 '23 at 08:22
  • @Raffzahn, anyway, I wonder about that "Then sheriff POSIX was sent to town by the authorities in 1988." I had the impression that POSIX codified existing common behaviours, so it would be interesting to hear which authorities were that "sent it to town"? Or is it just that it was noticed that ? (and other special characters) don't work too well, and so the recommendation to only use letters was made? – ilkkachu Mar 18 '23 at 08:23
  • 1
    @ilkkachu It depends heavy on what kind of nix was used. We tend to see only some vanilla flavours today, but there were almost uncountable variants of nixes. Some, like Sinix 5.x, offered runtime switchable environments where the user could choose how everything behaved (Classic Sinix vs. BSD vs. SV, IIRC). And that is where "The Authorities" stepped in. The POSIX work group was formed by several major manufacturers of *nix systems and software with a goal to unify the existing widely incompatible landscape and the command line was the very first part worked on. – Raffzahn Mar 18 '23 at 14:30
5

Python got a -h option in version 2.0, released in 2000. Vim got a -h option in version 5.0, released in 1998. Curl, originally released in 1998, had an -h option from the beginning. So, I would guess that it started around 1998. (I'm sure there are earlier programs that have -h for help, but those are some of the more prominent programs that I can think of that have it.)

And DOS has /? quite some time before that, but that's not -h, though it has the same purpose.

However, the standard way to get help on Unix has always been through man. POSIX doesn't specify -h to mean help for any utility. For some, like file, it has an entirely different meaning, but most don't have any particular meaning for -h. For many programs, still, help is provided only through the man page, and there is no command line option for it.

user24811
  • 1,022
  • 2
  • 5
  • 13
  • 6
    unless you're gnu, then it's the interminable info system and a man page that reads Read the info page!. Blecch. – scruss Mar 16 '23 at 04:04
  • 8
    @scruss info was utterly misguided. Nobody wants a help system that is harder to use than the command you are trying to get help on. – JeremyP Mar 16 '23 at 09:27
  • 6
    RE "Nobody wants a help system that is harder to use than the command you are trying to get help on": i think you have finally found the root cause of my anger every time i have to use info... it just is insane to have something like info to get help. (i have many many many MANY years of linux experience. i still to this day do not know how to use info.) – Trevor Boyd Smith Mar 16 '23 at 12:03
  • 2
    Have you read the info info page? – dan04 Mar 17 '23 at 22:25