-h –Help -help Help –? –?
blog.craftyguy.net
blog.craftyguy.net
One hyphen is for shorthand, two for long name.
See the Unix v5 man page source: https://github.com/aap/unixman/blob/master/v5man/man1/find.1. (If anyone has a link where those are rendered, please let me know.)
Find Files $ find|sort|egrep -i 'file.name'
Find Text $ find|sort|egrep -iR 'text.in.files'
Unrecognized bar "--help", aborting!
Use: "footool help" to display usage information
>$ man footool
No manual entry for footool
Those people are psychopathic abusers, and for some bizarre reason seem to be drawn to computers. I haven't figured out why yet.
Also --long_options_with_snake_case
java -agentpath:/opt/agent.jar --module-path /opt/modules -XX:HeapDumpPath=/tmp/heapdumpsThe double hyphen thing was standardised by the GNU project.
James Gosling didn't like GNU (I think based on something that happened in the Lisp days?).
(It bothers me too.)
[1] https://clang.llvm.org/docs/ClangCommandLineReference.html
We built a million GUIs for these, why did we never build CLIs for bad CLIs?
Why do I have to laboriously type two hypens for a readable option ? Causes finger pain especially when you have a large number of options.
Suppose you have a CLI app that supports the following parameters:
-e extrapolate your foos
-h highlight your bars
-l line up your bazs
-p print the aforementioned as they're being processed
So you might run the CLI as: cli -ep
cli -hp
cli -ehp
cli -lp
# a bunch of other combinations, including
cli -ehlp
# but since the order doesn't matter, also
cli -help
Do you see why that might be a problem with the short parameters?Now, most applications would reserve -h for help, so instead you'd still end up with the following:
cli -help
# so, the user wants to
# -h get help information
# -e extrapolate your foos
# -l line up your bazs
# -p print the aforementioned as they're being processed
which does not make a lot of sense. That's why you'd normally have something like: -e --extrapolate extrapolate your foos
-h --help get help information
-i --highlight (-i seems close enough) highlight your bars
-l --line line up your bazs
-p --print print the aforementioned as they're being processed (though this is just an example, a lot of packages also use -v --verbose)
So then there's no such confusion: cli -ielp # makes sense, a bunch of commands
cli -help # still doesn't make (much) sense, help shorthand mixed in with arguments for data processing
cli -h # makes sense, short hand for --help
cli --help # verbose help command
cli --highlight --extrapolate --line --print # also makes sense, just more verbose"go -h" is same as "go help".
Well, for the most part i wanted to show that:
cli -help
might actually be interpreted as 4 short arguments (grouped with -), instead 1 long argument (--), these are the same if you go by GNU conventions: cli -h -e -l -p
cli -help
Thus using -help like you're offering doesn't make sense whether -h is for "help" or for "highlighting" (example of a fictional action that the CLI might support) or anything else. In practice you won't see many software packages reserving -h for anything but help, but -elp would be a stupid example.To understand this better, consider the following in a case where the file you want to process is literally called "help" with no extension (which is valid):
cli <ARGUMENTS> <FILE_TO_PROCESS>
1) cli -h -e -l -p help # uses 4 arguments on a file called "help"
2) cli -help help # uses those same 4 arguments on a file called "help"
3) cli help # processes a file called "help" with no arguments
4) cli -h # invokes whatever is under -h, be it help/highlight or anything else
5) cli --help # the help argument, if present
6) cli --highlight help # the highlight argument, if present, on a file called "help"
With what you're offering, options 1, 2 and 3 probably wouldn't do what you expect them to, unless you reject GNU semantics.But thanks for detailed response. Upvoted for explanation. :).
Rather annoyingly that is often the only third party dependency required…
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
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.
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.
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.
There's the "Thing of int" weirdness also
And then there's grep
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/
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.
The long arguments are not in POSIX. They were invented by RMS having seen them in TOPS-20. (The short options come from Multics).
The other case ignored by the author is to print out a diagnostic plus help when there is a syntax error in the invocation. This works when the command arguments are few and simple, else the case cited (explain how to ask for help) is the right thing to do.
Single-dash long arguments are indeed generally bad.
But long options are not so complicated an idea that “invent” might be too high falutin’.
Just for fun I’ll split hairs though: TOPS-20 (and VMS) basically only had “long” options (they could be a single character of course). CP/M and DOS got their arg syntax from TOPS-10 & RSTS but we never had TOPS-10 at MIT AI.
What RMS came up with was to have both long and short, to use two dashes to disambiguate from concatenated short options, and used the = syntax (which dd, at least, already used). Then bfox put command completion into readline, which definitely was inspired by TOPS-20 command completion (itself from TENEX).
Before that we had our own OS, ITS, and most programs didnt take options because the system didn’t really have a command line at all: instead of what is called a ‘shell’ in Multics (and copied by Unix) we just used the debugger. And of course lispms, where the whole concept of command line doesn’t make sense.
By 1984 there was one Unix machine, a VAX, in the lab but nobody used it (small word size, didn’t have much software, primitive development environment compared to what we were used to) which is why rms started using it to develop GNU.
Whew. More than I thought one could write on the topic!
Now ELF is ubiquitous I wish the tab command completion were built into a section of the binary rather than being in sidecar files elsewhere in the filesystem, which is fragile.
[edited to add] As others have reminded me, there's also simply 'version'
$ java --version
Unrecognized option: --version
$ java -v
Unrecognized option: -v
$ java -version
openjdk version "1.8.0_312"
Looks like this was fixed in JDK 11.But Java isn't as sadistic as Go lang:
$ go --version
[scrolls off screen]
$ go --version | less
[scrolls off screen]
$ go --version 2>&1 | less
[search for 'version' command]
$ go version
go version go1.17.2 linux/amd64(might be really buggy, let me know)
-v for basic verbose
-vv for more
-vvv for even more
-vvvv oh come on you've got to be kidding
-vvvvv nope, they're not kidding
-vv ⇒ -w
-vvvv ⇒ -ww
Just a joke :)Just assessing expectations because I do like the idea and would implement it (in addition to the expected way) next time it comes up
So (-iv)² = -vv and once you've escaped the brackets in bash all is good.
I think we're on to something here....
I suppose you could really take it to some absurd level with -v¹⁰ for -vvvvvvvvvv
I usually assume that lower-case 'v' is for verbose.
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).
$ 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? ¯\_(ツ)_/¯(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.)
$ 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)java -D-version
"-v, --invert-match"
62 characters is not a lot for tools that have a lot of settings.
In the case of tools like grep, the settings are really more of a command vocabulary, and should rightly be written in their own language in a script file, like sed and awk, but grep makes some especially commonly needed ops available as a simpler command with switches for convenience. And that results in some seemingly arcane and inconsistent commandlines.
Defining how to search for something is just not a simple 2 or 3 options covers it kind of job.
By contrast, another tool with the same problem but clearly originated from a different starting idea is 'find'. It also has to have essentially a vocabulary to express your intentions in composed sentences, and it ends up with a mix of switches and words.
With some apps it's damn near impossible to query the version, especially cross platform. I used to manage a database of that syntax with a tool called "specs".
-p is for PID file
-l is for log file
-v is for version
-L is for verbosity level (e.g.: -L debug)
-c is for config file (where all the other options may be specified instead)
-h is for help
The rest are context-specific.
There are no "Posix long options" and therefore a "Posix-compliant" argument parser will not handle them just fine.
Long options set off using two dashes were popularized by the GNU utilities.
POSIX describes a getopt C library function and a getopts utility command. Neither of them specify any requirements for long options. They will not parse long options "just fine"; not without extensions for it.
In the GNU C library (and compatibles), there is a getopt_long function that supports long options; there is no attempt made to extend the POSIX getopt to handle long options.
POSIX does not have a help option convention: -h is not consistently a help option. The "Utility Syntax Guidelines" makes numerous recommendations about options; no mention is made of anything resembling long options, or that if there is a help option, it should have such and such name.
I don't know of any utility for which POSIX requires some kind of help option; it describes only the man command.
What you’re describing as a POSIX convention is really a GNU convention. But the world of POSIX consists of more than just GNU. So the grandparent post is correct.
> HISTORY
> The getopt_long() and getopt_long_only() functions first appeared in the GNU libiberty library. The first BSD implementation of getopt_long() appeared in NetBSD 1.5, the first BSD implementation of getopt_long_only() in OpenBSD 3.3. FreeBSD first included getopt_long() in FreeBSD 5.0, getopt_long_only() in FreeBSD 5.2.
So the parsing support is there. And it is used, e.g. tar aka bsdtar:
https://www.freebsd.org/cgi/man.cgi?tar(1)
So long options were popularized by GNU but have since become common across different POSIX operating systems.
Yes, the parsing support is there, so software written in the GNU style does build and run correctly on BSD systems. But although you bring up tar (a command that is well known for its unusual and unconventional flag handling), it is generally the case that commands on BSD operating systems do not use long options.
Representative examples of prominent 21st century BSD software that do not use long options:
mandoc: https://mandoc.bsd.lv/man/mandoc.1.html
jail: https://www.freebsd.org/cgi/man.cgi?jail(8)
zfs: https://www.freebsd.org/cgi/man.cgi?zfs(8)
acme-client: https://man.openbsd.org/acme-client.1
signify: https://man.openbsd.org/signify.1
doas: https://man.openbsd.org/doas.1
smtpd: https://man.openbsd.org/smtpd.8
And of course old classics like ssh: https://man.openbsd.org/ssh.1
kazinator’s point, that there is no POSIX convention of using -h for help, is correct. That convention came from GNU, and while the idea has spread due to GNU’s influence, there are other prominent schools of thought in the POSIX or Unix‐like ecosystem. I would certainly not agree that long options are the common case on BSD systems.
The POSIX strictness battle have been lost more than two decades ago. Behaving as if it did not, is overly pedantic.
The specification is online and people use it when coding, refer to it it in discussions and when filing bug reports.
2018 edition: https://pubs.opengroup.org/onlinepubs/9699919799.2018edition...
It's been my experience that the maintainers of major FOSS projects take it seriously when something is reported as being at odds with POSIX.
I don't remember any recent "POSIX strictness battle"; you didn't just make that up, did you?
There was as struggle starting in the 1980's to deal with incompatibilities among large numbers of vendor-specific derivatives of Unix that were cropping up everywhere. Unix brand incompatibilities negatively affected the users, who wanted their programs (and skills) to transfer. That is more ancient history. In retrospect, it looks like the standardization effort was broadly successful.
POSIX is not exactly standing still; it has been amassing new interfaces, and vendors adapt them as specified.
When I started coding in Unix, gethostbyname was the way to resolve DNS; now you have getaddrinfo, which is more generic and can give you IPv6 and IPv4 results in the same call. Even in basic Unix functionality, there are new features: for instance, various "at" functions, like openat: open a file relative to a specified directory descriptor, rather than the current working directory. POSIX specified threads that work everywhere, shared memory that works everywhere and other things.
There is rather a struggle between "use latest stuff in POSIX" versus "have code work on older systems".
But, overall, POSIX is a huge relief.
POSIX is a big reason why you can take code written using Glibc and get it running on Musl. Or on Cygwin.
An alternative C library that has Glibc compatibility as its goal would be a lot more difficult to develop if it had to be based entirely on reverse engineering Glibc. The Glibc documentation isn't complete enough. (And, doh, that's because it expects you to refer to POSIX for the details.)
:)
Put another way, I think `--help` is basically the CLI equivalent of generated API docs, whereas manpages are like long-form prose documentation. While you can get by with just one of them, the experience is going to be worse for certain use cases, and generally for anything beyond a certain level of complexity, your users will be better off if you provide both.
Allowing -? would be nice, even if only to make life easier for recent DOS/Windows expatriates, but for C programs there’s an unfortunate historical accident making this awkward: POSIX getopt(3) returns the next option character on success and a question mark on error. No reason it couldn’t return something else in principle, but realistically it’s not going to change at this point in history.
man command
*ducks*Seriously, though, man pages are not perfect (among other things because they only work as a quick reference for commands with a small amount of knobs), but I do think that the tension you are referring to is best resolved by accessing the option reference through an out-of-band mechanism (even if it is actually stored in-band, such as when using the ancient ident(1) to retreive version strings).
> what would it mean to invoke `python` or `docker` with a request for "human-readable sizes"?
I will not deny my desire for a common glossary of short options (see the train wreck that is the SysV / GNU coreutils delimited-text suite), but at the same time I don't think it's realistic for every option letter to have a single meaning throughout the whole of the system, which is how you seem to have interpreted my statement. I do think that being able to type -h instead of --help is less valuable than being able to not use a contrived second-choice letter for something else that really wants to be called -h.
I won't bother restating the whole thing here, but basically, having a giant wall of text dumped into a pager is not super ergonomic if you just want to look at a couple examples while typing. Man pages are definitely useful, but for a different type of thing.
foo --$(uuid)Personally, I'm puzzled when people act as if the GNU double dash convention is a universal standard.
man foo
apropos foo
Info foo
;-)Fun aside, I think -h/--help is nowadays the most widespread and accepted version in Linux/Unix-Land. A good CLI argument parser accepts both variants.
Nearly every tool does have a manpage (even a basic one) thanks to Debian’s manpage policy: “Each program, utility, and function should have an associated manual page included in the same package or a dependency.… If no manual page is available, this is considered as a bug and should be reported to the Debian Bug Tracking System.”
The rare times I encounter a command‐line tool that has no manpage, I’ll sometimes write one and contribute it upstream.
Of course some programs have a useless manpage that points to info. Thankfully that is pretty much limited to GNU tools which I’m lucky enough to not have to use very often.
shutdown -hThe most notable exception (to me) among modern tooling is the `aws` cli, which parses help as a subcommand. And if you try `--help` it just gives you an `Unkown option` response.
I'm mildly amused by the need to reserve a little bit of brain-space for the ways to ask cli tooling for help
$ podman -h
Error: pflag: help requested
See 'podman --help'
The program recognised the flag. But instead of running the intended functionality, it tells you to re-run it. And this maddening behaviour is pervasive. You already have the code processing this, you've coded the functionality to output "you wanted X, but typed Y" because apparently this is a common thing for people to do, why don't you just run X?(Looking at `brew upgrade/update` in silent fury)
But I don't see why they couldn't leave the base command's short option alone-- the user intent of a bare "docker -h" (or "podman -h") seems obvious.
[0] https://docs.docker.com/engine/deprecated/#-h-shorthand-for-...
Every author of a command makes up the conventions for these flags. The shell processes the command line, invokes the command and passes the processed words to the command as arguments. While there are standard library routines for parsing these arguments, they don't have to be used and many original Unix commands would have been written with their own parsing code.
The oldest Unix commands like 'ls', 'cp', 'rm', and 'ps' mostly take single letter arguments. Authors often allowed such single letter arguments to be stacked up: 'ls -l' means list directory contents in long form while 'ls -r' means list directory in reverse alphabetic order and 'ls -lr', 'ls -l -r', and 'ls -r -l' mean all do the same thing, list the directory contents in long form in reverse alphabetic order.
It wasn't always the case, but by now, 'ls' has over 40 or 50 single character arguments so I find myself needing to check the man page for the less common ones. There are other quirks too. Both 'tar' and 'ps' accept arguments that don't have the dash. 'ps -a' does (almost) the same thing as 'ps a'. 'tar -xv' will extract an archive, verbosely, but so will 'tar xv'. The author of these ancient Unix commands just decided to parse the command line arguments this way.
What always bothered me was the use of full words instead of single character options introduced by a single dash. The 'find' command is one of these early Unix commands (introduced 44 years ago) that does this. "find /home/joe -name 'x*y' -print" outputs every file under directory /home/joe with a name starting with x and ending in y. This very useful command has a dizzying list of uses so the author made it easier to understand by using full words after the single dashes for elements on the command line. The recent versions of 'find' also take some single character flags: "find -d /home/joe -name 'x*y' -print" does almost the same thing as the previous example in this paragraph, but it descends into directories in a depth-first order.
Compilers, with there own complex set of command line flags, options, and arguments have long used their own, offbeat, interpretations of their command lines arguments.
Most Unix commands attempt to parse their command line arguments and if they couldn't, they would print out a few lines with a compact usage description. For example 'ps -Q' is not something that the 'ps' command understands so it produces:
ps: illegal option -- Q
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
[-g grp[,grp...]] [-u [uid,uid...]]
[-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
ps [-L]
If this isn't enough help, one would check the man pages (with 'man ps'). I know that I saw commands written to use help when passed '-h' long ago, but around 1986 or so it wasn't common and often '-h' simply triggered the standard usage output because there was no option '-h'.For a code base as large as Google's, using --helpfull to output every single flag that is defined in the libraries you depend on will output a huge wall of text and often not very useful.
I always had an idea to write a --helpful flag that will pipe --helpfull output to $PAGER. That's definitely more helpful than --helpfull.
./my_cli —-help | grep -C 2 —- —-someflagIn addition, if I don’t perfectly know what I’m searching for, I’ll often get the regular expression wrong. So I prefer to check the manpage first, since it’s a lot quicker to try different search strings in my pager than by repeatedly modifying my previous command string in the shell.
FFMPEG comes to mind immediately as an example. Essentially, you call ffmpeg to convert media1 with specs and provide media2 as an output for it. I'm mostly understanding and accepting that this ordering matters, because you're applying arguments onto the input instead of trying to do something on the output for some reason.
Where it gets confusing, though, is if you want to resize and crop an image for example. You may end up with different results depending on the order you specify these operations.
Maybe this particular use case makes sense because resizing and cropping hard-coded coordinates could be confusing. However, other operations that seem like they shouldn't interfere with each other sometimes do.
It would be nice to see some type of handling so there isn't this type of confusion. Perhaps some type of --override command, otherwise default to a consistent output regardless of order.
In contrast, I can't think of any issue I've had with "ls". I like that -l -a -t -r can be combined into -latr, but it does make learning the terminal very confusing for beginners when this isn't always supported or consistent in other programs.
Could you clarify, what's confusing about it? The operations in ffmpeg are sequential, unless you use advanced chaining capabilities. If you look at a crop as a substraction, and at a resampling as a multiplication, it becomes evident, how the order affects the result.
(24 - 4) * 0.25 = 5 24 * 0.25 - 4 = 2
This is not a pain if you are using the default readline keybindings (which ape those of Emacs): up arrow, M-b to move back one word, type 'help ', hit RET; for the next bit, up arrow, M-b M-b to move back two words (to the beginning of 'help'), M-d to delete forward one word, C-e to go to the end of the line and you're done. No doubt it's similarly easy using the vi keybindings.
That sounds complex, but really it's second nature.
> As in the case of podman above, if you know your user is asking for help, show them the damn help.
The issue there is that it doesn't know the user is asking for help, because the way one asks for help with podman is with --help; -h is meaningless to podman. Note that -h isn't always the flag for help; just off the top of my head, in several command-line tools it is the flag for human-readable file sizes.
I'd do kbihelp for the first and k2bdwA for the second.
$ javac --help
javac: invalid flag: --help
Usage: javac <options> <source files>
use -help for a list of possible options
:-(https://bugs.java.com/bugdatabase/view_bug.do?bug_id=5083924
cmd -ao arg path path
cmd -a -o arg path path
cmd -o arg -a path path
cmd -a -o arg -- path path
cmd -a -oarg path path
cmd -aoarg path pathOh you asked for --help? No worries... I won't complain about an unknown argument nor will I complain about having no arguments at all! I'll just go ahead and do whatever I think you're asking for help about even (especially) if it's destructive!
For example when terraform tells me to run "terraform init", as if actually typing the letters on the keyboard had any benefit...
>>> help
Type help() for interactive help, or help(object) for help about object.
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
If you know what I'm trying to do, then just do it!
If you really want this, consider using ipython with %autocall as your Python REPL.
https://ipython.readthedocs.io/en/stable/interactive/magics....
Type "help", "copyright", "credits" or "license()" for more information.
>>> help
Type help() for interactive help, or help(object) for help about object.
>>>
Python tells you to type "help", but when you do it turns out that that doesn't do much. I get it, they want to make the distinction between help() and help(object), but I feel that could have done a bit more friendly. >>> print "hi"
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
I would be in favor of that for this one!If you do want this, consider ipython as your Python REPL.
https://ipython.readthedocs.io/en/stable/interactive/magics....
This is the reason. "help" and "exit" (as well as "quit") are perfectly cromulent variable names in Python. So the REPL does the best possible thing, i.e., try and evaluate the expression and shoot a message if it fails. Case in point:
>>> help = "hi"
>>> help
"hi"
>>> del help
>>> help
Type help() for interactive help, or help(object) for help about object. - check if a variable called "help" is in scope
- if not, call help().
- otherwise, print its value.I think anyone crying and baffled about this is fundamentally not well suited to programming. This sort of logical problem should be intuitive.
The seeming irrationality of the special case behavior is just something funny to make your mom laugh, not something that's actually illogical or inconsistent or stupid.
REPL should be as dumb as possible. That's a feature, not a bug.
Not sure if this is a good idea however.
Since (as other comments say) you can never know for sure that the user is asking for helo, the only sane way to actually implement this is to show the "usage" message on every incorrect invocation of the command.
This has two drawbacks, however:
* It makes the output of an incorrect invocation much longer. Personally, I prefer the 2-line output approach (1 line for the error, 1 explaining how to ask for help)
* You still need to have an explicit help command, because I sure as hell don't want to craft an intentionally incorrect invocation every time I want to see the usage message.
My 2 cents: just use "--help/-h" or a "help" subcommand. They are by large the most popular ways to check out usage, no need to be creative here.
I'm looking at you, otherwise-excellent wp-cli. :-)
^help^^
Which will rerun the previous command but substitute "help" with "" (nothing).So thank you. That changes everything!
^help^
does the same thing. The bash manual says ^string1^string2^ is equivalent to !!:s/string1/string2/
where / can be any delimiter, and the "final delimiter is optional if it is the last character of the event line." So, not so surprising that the third ^ is optional too.TIL: In either of these forms, if string1 is empty, it is set to the last string1, or, "if no previous history substitutions took place, the last string in a !?string[?] search." E.g.
$ echo foofoo
foofoo
$ ^foo^
echo foo
foo
$ ^^bar
echo bar
bar> !!:s/string1/string2/
I didn't know about this syntax either.
I thought I knew a bit of bash and it turns out I'm a novice after all this time. How fun.
$ cmd --with -a --lot -of --options
(fails)
$ cmd --with -a --lot -of --options --help
(behaves as if --help was the only option)
From a terminal perspective, up-arrow + space + -h is often the fewest keystrokes to get what I want
$ foo -h | grep bar
The
…
…
entire
…
…
usage
…
…
message!
Never stop being you, Free Software, you lovable and quirky bunch of old coots.$ foo -h 2>&1 | grep bar
$ zfs -h | grep help
(Edit: ah, not a very fair example, and a topical one too :) git /?: '/?' is not a git command. See 'git --help'.
7z /?: Unsupported command
psql /?: trying to connect
And for PowerShell cmdlets you should use "help Verb-Thing" or "help Verb-Thing --Online".Just if the mess couldn't get any messier.
You think you are talking to the clerk that will initiate the payout but actually you are talking to the machine that made the draw.
When you try -h or --help then the result can be nice or not. In general the author gives quite a lot of pointers. However the docs are where it is at and that is from man or Help -> etc.
If the docs are provided and if you can't be arsed to read the docs then bugger off! Now this is where it gets tricky. Not all programmers are decent writers of docs nor are all potential consumers of docs decent readers.
Now OP is whittering on about incantations requesting help. They only demonstrate a few examples so eventually one of those incantations might work.
The important thing is to ensure that a request for help does one of two things: provide help or no op.
> GOption will recognize the `--help`, `-?`, `--help-all` > and `--help-groupname` options * (where `groupname` is > the name of a #GOptionGroup)
Ref: https://gitlab.gnome.org/GNOME/glib/-/blob/main/glib/goption...
Looking at the Git history, it was recognized straight from the start, when GOption was introduced in 2004. No idea why they chose it, and if it was their own idea, or if they followed some existing convention from somewhere else...
But no, maybe that doesnt work either
* operated on production data (rather than beta/pre-prod data, or failing if stage is not specified) by default * did not recognize `--help/-h` as flags, but would simply ignore them and continue to run
I'm not exactly happy in my role currently, but I'm a damn sight happier not having to deal with him anymore.
(This tip probably came from another HN user long ago.)
They come from getopt() returning '?' for any unknown option, which usually ends up being the default case in your switch, but could be '?' to be explicit.
Edit: I just checked on windows, man is actually alias for help in PowerShell :)
POSIX.1-2017 https://pubs.opengroup.org/onlinepubs/9699919799/
GNU Manuals Online https://www.gnu.org/manual/
Linux man pages online https://man7.org/linux/man-pages/index.html
Ubuntu Manpage Repository https://manpages.ubuntu.com
Reading UNIX Manual Pages | Apple Developer Documentation https://developer.apple.com/documentation/os/reading_unix_ma...
Windows Commands https://docs.microsoft.com/en-us/windows-server/administrati...