grep: make errors other than "not found" result in exit code 2. Closes 8796
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 28 Mar 2016 20:12:09 +0000 (22:12 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 28 Mar 2016 20:12:09 +0000 (22:12 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
findutils/grep.c

index 10b69275a9a18fdb913c6c02bd48c8b48592037b..dece90c580234deca1adf71b7f9a92f6a76addde 100644 (file)
@@ -681,11 +681,15 @@ int grep_main(int argc UNUSED_PARAM, char **argv)
        FILE *file;
        int matched;
        llist_t *fopt = NULL;
-
-       /* do normal option parsing */
 #if ENABLE_FEATURE_GREP_CONTEXT
        int Copt, opts;
+#endif
 
+       /* For grep, exitcode of 1 is "not found". Other errors are 2: */
+       xfunc_error_retval = 2;
+
+       /* do normal option parsing */
+#if ENABLE_FEATURE_GREP_CONTEXT
        /* -H unsets -h; -C unsets -A,-B; -e,-f are lists;
         * -m,-A,-B,-C have numeric param */
        opt_complementary = "H-h:C-AB:e::f::m+:A+:B+:C+";