Command w/o args displaying usage should return non-zero
See original GitHub issueTry running git
, and you will see its usage. You will also receive a non-zero return code, indicating failure. This can be vital in case arguments got truncated.
Current behavior of showing usage instructions (help_text
) is great!
But it should also error out with a code 1
.
Example:
➜ git
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
(snip)
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
➜ echo $?
1
Reference: https://github.com/learningequality/kolibri/pull/5937
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Python: get output from a command line which exits with ...
I'm trying to get the output of a command line process which gives a nonzero exit status after outputting the information I need....
Read more >subprocess — Subprocess management — Python 3.11.1 ...
Run the command described by args. Wait for command to complete, then return a CompletedProcess instance. The arguments shown above are merely the...
Read more >Bash command line exit codes demystified | Enable Sysadmin
To display the exit code for the last command you ran on the command line, use the following command: $ echo $?.
Read more >xargs - Construct an argument list and run a command - IBM
The xargs command line typically contains the skeleton, ... it should explicitly contain an exit command to avoid returning a nonzero by accident; ......
Read more >Batch Script - Return Code - Tutorialspoint
Batch Script - Return Code, By default when a command line execution is completed it should either return zero when execution succeeds or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This only happens with groups - invoking a (sub-)command requiring arguments, without arguments, will raise and exit with a non-zero status code. The default behaviour of a group is not to call the callback (i.e. the wrapped function) if the argument is not supplied, which presupposes that it is required. Click should exit with a non-zero status code if
invoke_without_command
is false and defer to the callback if it’s true.@davidism
mycommand $filename
<= if$filename
is empty by mistake, then it will return 0 as if execution was successful.