diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-01-26 15:42:55 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-01-26 15:44:49 -0500 |
commit | f3164f2615ce18d3ea7b5ce122dfe2a381d1b3f4 (patch) | |
tree | dc67e0cfec9a55236526ee9dac0aac96255dca17 /doc | |
parent | 31d3e241306f305c1cb94e1882511da2b48dcd36 (diff) |
exit: tweak exit status logic
This changes how ripgrep emit exit status codes. In particular, any error
that occurs while searching will now cause ripgrep to emit a `2` exit
code, where as it previously would emit either a `0` or a `1` code based
on whether it matched or not. That is, ripgrep would only emit a `2` exit
code for a catastrophic error.
This tweak includes additional logic that GNU grep adheres to, which seems
like good sense. Namely, if -q/--quiet is given, and an error occurs and
a match occurs, then ripgrep will emit a `0` exit code.
Closes #1159
Diffstat (limited to 'doc')
-rw-r--r-- | doc/rg.1.txt.tpl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/rg.1.txt.tpl b/doc/rg.1.txt.tpl index c9a08f97..a6f72260 100644 --- a/doc/rg.1.txt.tpl +++ b/doc/rg.1.txt.tpl @@ -90,7 +90,15 @@ EXIT STATUS ----------- If ripgrep finds a match, then the exit status of the program is 0. If no match could be found, then the exit status is 1. If an error occurred, then the exit -status is 2. +status is always 2 unless ripgrep was run with the *--quiet* flag and a match +was found. In summary: + +* `0` exit status occurs only when at least one match was found, and if + no error occurred, unless *--quiet* was given. +* `1` exit status occurs only when no match was found and no error occurred. +* `2` exit status occurs when an error occurred. This is true for both + catastrophic errors (e.g., a regex syntax error) and for soft errors (e.g., + unable to read a file). CONFIGURATION FILES |