18 ms·
-h –Help -help Help –? –?
- ktpsns 5y agoThe list is probably ignoring 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.
- anjbe 5y agoI always default to “man foo”, because of the occasional tool that when presented with -h or --help creates a file with that name; even if there’s no manpage, “man foo” will never have any undesired side effects. 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.
- gifnamething 5y agoThere is the occasion where the manpage is useless compared to the help or the website docs. For example, the ironic 'man doxygen'.
- SAI_Peregrinus 5y agoOr the man page for OpenSSL's config, which actually has many of the options in the man pages for `req`, `x509`, and `ca`.
- twic 5y agoHey, at least this doesn't create a file: shutdown -h
- pcthrowaway 5y ago> Fun aside, I think -h/--help is nowadays the most widespread and accepted version in Linux/Unix-Land The 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
- ktpsns 5y agoIt would be easy for the authors of this tool to fix this behaviour. Checkout `git --help` vs `git help`, both versions work. That's just being nice to the user.
- blueflow 5y agoman $command
- nixpulvis 5y agoCan someone remind me what tool I use to convert markdown to man pages? Even better, anyone have a good way to embed a man page into my README?
- sidpatil 5y agoTry pandoc [1]. You can convert back and forth between manpage and Markdown with it. [1] https://pandoc.org/index.html https://pandoc.org/index.html
- AlexanderDhoore 5y agoAnd also a few other formats. Wanna convert LaTeX to Black Speech? No problem! Use pandoc!
- anjbe 5y agoMandoc, the default manpage formatter on OpenBSD, FreeBSD, NetBSD, macOS, and some Linuxes (as well as web frontends like manpages.debian.org and man.archlinux.org), can convert manpages to Markdown, or to HTML directly: https://mandoc.bsd.lv/man/mandoc.1.html#Markdown_Output https://mandoc.bsd.lv/man/mandoc.1.html#Markdown_Output
- jve 5y agoOr "help command" in powershell world. But applies to powershell cmdlets/functions only. Edit: I just checked on windows, man is actually alias for help in PowerShell :)
- yread 5y ago/?
- pjmlp 5y ago/help
- deleted 5y ago[deleted]
- kazinator 5y agoWatch out for bloggers: they tend to make stuff up. 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.
- pjmlp 5y agoI feel the same when they talk about UNIX, but are actually describing GNU/Linux.
- kazinator 5y agoGNU/Linux == GNU is not Unix (even) over Linux. :)
- thecosmicfrog 5y agoI usually refer to these as "GNU-style arguments", whether or not that's the correct terminology. The fact that Go-based utilities tend to use the `-option` style (with a single hyphen) still bothers me.
- hvdijk 5y agoAnd since the article is using podman as an example: podman does have a manpage. The actual standard way of getting documentation on utilities, man podman, works just fine.
- 5y ago
- tedunangst 5y ago> ???? I have no idea where these came from, but my guess is that they are migrants from the wild west Windows-land, where I assume the shell won't try to expand ? into anything. Using these options will cause problems for anyone using common shells like bash, zsh, others. Don't do it. 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.
- unfocussed_mike 5y agoThe bit about help as a subcommand and having to edit it out in a cumbersome way really hits home. I'm looking at you, otherwise-excellent wp-cli. :-)
- AlexanderDhoore 5y agoYou need to discover either emacs or vim shortcuts for bash. I can't imagine living without `set -o vi`
- yjftsjthsd-h 5y agoAt least in bash, just run ^help^^ Which will rerun the previous command but substitute "help" with "" (nothing).
- unfocussed_mike 5y agoIt is in the nature of bash that you can go a decade without ever figuring something out only to have your life changed by a random comment on the internet. So thank you. That changes everything!
- yjftsjthsd-h 5y ago:D I have been on the receiving end enough times that I am very very happy to have passed it on this time.
- laurent92 5y agoIs there a shortcut to reuse the result of the last command? “which java => ll $(!!)”, but the “!!” reexecutes the last command, I’d like something which doesn’t.
- yjftsjthsd-h 5y agoI'm not personally aware of a way to do that. When I need to do that I do indeed just run $(!!)
- blt 5y agoThe last point reminds me of the frustration of quitting the Python REPL.
- tomerv 5y ago> Honestly, in practice, I've seen many tools that support -help also allow --help and -h for those who have the muscle memory reflex for those, so it's not nearly as problematic. $ javac --help javac: invalid flag: --help Usage: javac <options> <source files> use -help for a list of possible options :-(
- AlexanderDhoore 5y agoUsing double -- for long named flags is a GNU-ism. Java came from Sun and so prefers the single dashes.
- oneeyedpigeon 5y agoBut "-help" is just "-h -e -l -p" ...
- VWWHFSfQ 5y agoWhich is also a gnuism
- oneeyedpigeon 5y agoThat's my point - "-help" violates the gnu standard.
- anjbe 5y ago“-help” being equivalent to “-h -e -l -p” is not a GNUism. It’s described by POSIX. If a utility takes the options “-a” and “-o something” and uses POSIX getopt(), then these are all equivalent: 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 path
- blakesterz 5y agoI always forget the "version" switch. Is it '-v' or '--version' or '-version', everything's just a bit different and I can never remember what needs what to tell me its version. [edited to add] As others have reminded me, there's also simply 'version'
- pphysch 5y agoI automatically assume `-v` is short for `--verbose` rather than `--version`, and always type out the latter.
- cute_boi 5y agoI don't know but I always expect -V for verbose, and -v for version. However, I do acknowledge its not consistent :(
- timoteostewart 5y agoAnd not to leave out `go version`...
- laurent92 5y agoEverything uses --version, except `java -version`. 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).
- Wevah 5y agoAnd (e.g.) OpenSSL IS `openssl version`, with no dashes at all.
- saghm 5y agoTo be fair, when deciding how to implement CLI options, it's probably advisable to run as far away as you can from drawing any sort of inspiration from openssl. Even git looks like a paragon of UX compared to the openssl CLI.
- pphysch 5y agothe clever way to parse `-help` is to treat it as multiple options, but design your argument handler so that the `help` handler short-circuits and doesn't do anything except output help text and exit (i.e. it reads '-h' then calls the help handler and exits, doesn't matter if -e isn't a valid option).
- oneeyedpigeon 5y agoWouldn't that make it awkward to combine help with any other option? I guess that's an edge case, but still...
- pphysch 5y agoMost commands IME will have this short-circuit behavior $ 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
- sshine 5y agoWhenever 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.
- eadmund 5y ago> This pattern is cumbersome to deal with in practice, especially in tools that use subcommands. Instead of typing foo bar -h to get help, you have to move the cursor between foo and bar to insert help: foo help bar in order to get help about the bar subcommand. Then, once you presumably know how to use it, up-arrow, remove help from between the tool and subcommand, move to the end of the line, and continue on. 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.
- thestoicattack 5y ago> No doubt it's similarly easy using the vi keybindings. I'd do kbihelp for the first and k2bdwA for the second.
- ducaale 5y agoor you can use C-x C-e to edit the command in $EDITOR
- slondr 5y agoIronically when I tried to run that in vterm in emacs it triggered an Emacs command which failed.
- forty 5y agoI hate when a program tells me what I have to do. I always think "damn it program, if you know what to do, just do it already. I say what to do, and you do it". For example when terraform tells me to run "terraform init", as if actually typing the letters on the keyboard had any benefit...
- skykooler 5y agoSame thing with Python: >>> 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!
- dataflow 5y ago>>> print "hi" SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)? I would be in favor of that for this one!
- 3np 5y agoThat was the behavior in python2 and it was changed for good reason. If you do want this, consider ipython as your Python REPL. https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-autocall https://ipython.readthedocs.io/en/stable/interactive/magics....
- dataflow 5y agoYes, hence the semi-joke. But I actually do think it was a good feature and a bad idea to remove it.
- usui 5y agoIsn't this due to some REPL-constraints or not wanting to break the way the language works? Maybe there's no way to evaluate the "exit" and "help" objects replaced by "exit()" and "help()", and that making exceptions would clutter the code. Not sure the reasoning behind it, but that's what it seems.
- bgro 5y agoI have been trying to google this concept of confusion for years. Finally, an article where someone has had the same thought as me about the consistency. This has been one of those things that's impossible to search for because everything routes into a technical syntax discussion (like a MAN summary page) instead.
- airstrike 5y agoDon't forget /?
- Volundr 5y agoThe only place I've seen this is windows world where /arg and -arg are the same thing. Don't ask me how this came about.
- weikju 5y agoDOS, where /arg was the way
- samatman 5y agoWhich it got from CP/M, which borrowed the idiom from VMS.
- garaetjjte 5y agoThey originally used - but IBM wanted /
- glandium 5y agoIIRC, it's up to the application whether they handle /arg and -arg forms. They might just as well not support the latter.
- aflam 5y ago-hh is what a major app at work requires. Engineering indeed provides room for creativity.
- bgro 5y agoI want to throw out there that in addition to these parameters and how you call them in different ways, the order of operations for them is also very frustrating. 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.
- ZoomZoomZoom 5y ago> 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. 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
- lou1306 5y ago> As in the case of podman above, if you know your user is asking for help, show them the damn help. 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.
- dennis-tra 5y agoThis post resonated with me and the inconsistencies certainly don’t add to the already bad discoverability of CLI arguments. Personally, I find using -h/—-help the most sane way (YMMV).
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- andrewmcwatters 5y agoLearn to read manuals, not blogs or Q&A sites. POSIX.1-2017 https://pubs.opengroup.org/onlinepubs/9699919799/ https://pubs.opengroup.org/onlinepubs/9699919799/ GNU Manuals Online https://www.gnu.org/manual/ https://www.gnu.org/manual/ Linux man pages online https://man7.org/linux/man-pages/index.html https://man7.org/linux/man-pages/index.html Ubuntu Manpage Repository https://manpages.ubuntu.com https://manpages.ubuntu.com Reading UNIX Manual Pages | Apple Developer Documentation https://developer.apple.com/documentation/os/reading_unix_manual_pages https://developer.apple.com/documentation/os/reading_unix_ma... Windows Commands https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands https://docs.microsoft.com/en-us/windows-server/administrati...
- whatsakandr 5y agoIs or was -q ever used for help? Or is this a weird thing one of my coworkers started?
- mc4ndr3 5y agoSome apps don't even provide a help menu. They may come with a man page.
- SAI_Peregrinus 5y agoAnd some come with dozens of man pages, several of which need to be combined to find the syntax allowed by certain commands (often also needing a help command)! OpenSSL is bad in this way.
- gerdesj 5y ago"You: Hi! I won! Here's my ticket! Where do I collect my winnings?" 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.
- yegle 5y agoAbseil flag library has --help and --helpfull flag. 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. https://abseil.io/docs/python/guides/flags#special-flags https://abseil.io/docs/python/guides/flags#special-flags
- dbtc 5y agoI would prefer to (and do) just add the pipe myself. More often I pipe to grep.
- 10000truths 5y agoIf I’m looking for a specific flag, or trying to understand what a specific flag does, I prefer to pipe the --help output to grep: ./my_cli —-help | grep -C 2 —- —-someflag
- anjbe 5y agoI tend to avoid doing this, for reasons someone else described in a comment (https://news.ycombinator.com/item?id=30993390 https://news.ycombinator.com/item?id=30993390): some programs spit --help output to stdout, but others to stderr, so you wind up running it a second time as “my_cli --help 2>&1 | grep ...”. In 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.
- saghm 5y agoIt took me a second to realize that this option was supposed to comprise of both the words "help" and "full". At first I was wondering if "helpfull" was a British spelling of "helpful" that I had somehow never come across below.
- gumby 5y ago> Ah, the POSIX short/long help options 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.
- asiachick 5y agohow do you invent something by seeing it somewhere else? doesnt seeing it somewhere else mean it was invented somewhere else?
- gumby 5y agoAh, maybe “invent” is too strong a word but OTOH every invention is built on something beforehand (even the wheel presumably followed rolling something heavy over logs, presumably after making the connection about circular things rolling downhill etc…) 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!
- 5y ago
- xarope 5y agoIn the same vein, as an old unix dog, I'm very annoyed by golang's -help vs -h and --help. Given the pedigree of the creators, I really am quite puzzled as to why they took this approach. Is there some sort of injoke where -help meant -h[elp] which would therefore expand to e.g. -he, -hl, -hp, -hel, -hlp, -hep ad nauseum?
- layer8 5y agoMaybe they were inspired by Java: https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html#BABDJJFI https://docs.oracle.com/javase/8/docs/technotes/tools/unix/j...
- mikojan 5y agoHeres the why: https://groups.google.com/g/golang-nuts/c/3myLL-6mA94/m/VUkLtSOyS-YJ https://groups.google.com/g/golang-nuts/c/3myLL-6mA94/m/VUkL...
- deleted 5y ago[deleted]
- scbrg 5y agoIs that so odd? The creators have a background that predate the (relatively recent - even more so when golang was created) GNU convention. A convention that is (or at least was) mostly prevalent on Linux anyway. Personally, I'm puzzled when people act as if the GNU double dash convention is a universal standard.
- int_19h 5y ago-foo wasn't all that uncommon in Unix, especially before GNU. Do you remember command line options for oldschool X11 stuff? e.g. xterm -fn 7x13bold -geometry 80x32+10+50
- krnlpnc 5y agoThere’s a special place in hell for those pushing long argument names with single hyphens. One hyphen is for shorthand, two for long name.
- jonpalmisc 5y agoClang, swiftc, etc. would like a word with you... :) (It bothers me too.)
- sp332 5y ago-fpic is a single letter option, -f, followed by the parameter pic. Clang still uses two hyphens for long options including --help.
- lifthrasiir 5y agoThere are tons of options that start with -f and can't be decomposed in that way [1, e.g. -framework]. They are essentially atomic options with a loose naming convention. [1] https://clang.llvm.org/docs/ClangCommandLineReference.html https://clang.llvm.org/docs/ClangCommandLineReference.html
- IgorPartola 5y agoCorrect. You cannot use “ramework” as an argument to “-f”. Instead use two dashes and it is unambiguous.
- lifthrasiir 5y agoIt took me some thoughts to realize what you wanted to say, and you are incorrect: there is no single option `-f` in cc options! `-f` is just a common prefix of hundreds of independent options, like `-fsanitize=...` (which can't be used as `-f sanitize=...`). As I've iterated before, those prefixes mostly represent broad categories of options and not hard and fast rules: `-g` for debug, `-i` for directories, `-m` for target architectures, `-W` for warnings, and `-f` for virtually everything else.
- phendrenad2 5y agoI want -h -help --help and -? to all print the usage text. The fact that so many CLI tool programmers either don't realize that this is the right thing to do, or don't bother to do it, is just part and parcel of how user-hostile most programmers are.
- mananaysiempre 5y agoI’m against lowercase -h for help (pretty common, but not universal, like in -h for human-readable sizes in GNU coreutils) for the same reason as lowercase -v for version (very rare, uppercase -V is more frequent, but the Lua interpreter does use lowercase): it hogs a valuable mnemonic for a case that doesn’t really need to allow for muscle memory to develop (the best motivation and use case for short options IMO): if you are reaching for help or the version number, you’re likely already out of the flow and are actively thinking about what you’re typing, and these options don’t need to combine with others anyway. 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.
- saghm 5y agoNeeding to get info on command line flags is not only such a common thing but also a kind of recursive problem (you can't find out what flag to pass without being able to invoke the help text in the first place) that I'd argue it's the most valuable possible recipient of a single letter mnemonic. Having a universal and short way to print out the list of options seems way more beneficial than something like human-readables sizes, which only even makes sense for a certain subset of command line tools (what would it mean to invoke `python` or `docker` with a request for "human-readable sizes?).
- twic 5y agoIf commands print out their help message, or even just tell you how to print out the help message, when given a bad flag, then you can use: foo --$(uuid)
- octagons 5y agoI just experienced this scenario today with aurutils [0]. Perhaps I needed to reboot after building it, but it only gave me any insight into its syntax when I typed “aur” with no other flags. [0] https://github.com/AladW/aurutils https://github.com/AladW/aurutils
- tedmiston 5y agoThis is part of the reason I only use long args in scripts... to make them more self-documenting and discoverable / less ambiguous. Takes a little more effort upfront, but no need to check man pages, help, etc for random single-char args later. (This tip probably came from another HN user long ago.)
- perryizgr8 5y agoI hate the commands that pretend that the only way to bring up help is "--help" and that "-h" isn't anything. Just show the help text, you know "-h" means I want help.
- scubbo 5y agoAh, another reminder of my ex-coworker who wrote a script that: * 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.
- vmception 5y agoand then you launch from the command line into the app’s own console starting with > where no flags work and maybe informative commands are actually function names ending in () But no, maybe that doesnt work either
- ChiefOBrien 5y agoAnd then you encounter some ancient apps without GNU readline support (oracle sqlplus and mysql, I'm looking at both of you). No history support, cursor keys emit characters on the line, literal hell when trying to quickly fix remote database...
- gorgoiler 5y agoAhhh, and of course: $ foo -h | grep bar The … … entire … … usage … … message! Never stop being you, Free Software, you lovable and quirky bunch of old coots.
- RJIb8RBYxzAMX9u 5y agoI think this is because some tools print the usage message to stderr rather than stdout (ironically I couldn't find an example while typing up this reply). Try: $ foo -h 2>&1 | grep bar
- gorgoiler 5y agoThanks, but you’re explaining that my finger hurts because I hit it with a hammer when I’m complaining (in a kind hearted way, I hope!) that Free Software hammers have angled heads which skid off the nail sideways onto my finger. $ zfs -h | grep help (Edit: ah, not a very fair example, and a topical one too :)
- dmitriid 5y agoIt's not just help. The example shows this $ 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)
- oedo 5y agoIt appears that docker cli will also eventually remove the short option for help. Their reasoning for it is to avoid conflicts with args (eg hostname '-h') in certain subcommands.[0][1] 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---help https://docs.docker.com/engine/deprecated/#-h-shorthand-for-... [1] https://github.com/docker/cli/issues/3249 https://github.com/docker/cli/issues/3249
- inetknght 5y agoThe worst offenders are apps that do something even though you ask for --help. Oh 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!
- hardfire 5y agosame thing goes for -v -Version -version --version --v ?
- elboulangero 5y ago"-?" is supported by apps that use GLib for option parsing: > 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.c#L52 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...
- _8j50 5y ago/?
- ainar-g 5y agoAnother disturbing pattern I've noticed is that a lot of newer command-line programs refuse to have a proper man page. Instead, they put massive dumps of preformatted text behind one of those --help flags, which has several obvious issues. In the worst of cases, the text also uses colours, with no way to remove them without piping the output thru a sed filter.
- todd8 5y agoFrom its earliest days, Unix has used a single hyphen to introduce command options or flags, like 'ls -l', which produces the long form directory listing, and 'cat -n', which numbers the lines that it outputs. 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'.
- srg0 5y agoI find it hilarious that on Windows there are commands using Windows style options (ipconfig, robocopy) and Unix style options (netstat, tracert). That's probably part of the POSIX compliance. So the list of possible help options to try is even longer: "/?", "-?", "/h", "-h", "/help", "-help", and "--help". For most of the utilities distributed by MS "/?" works even if the command uses dash options, but third party utilities usually support only their "native" options. 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.