SUSv3 -q compatibily exit status correction for grep again
author"Vladimir N. Oleynik" <dzo@simtreas.ru>
Fri, 23 Sep 2005 13:50:24 +0000 (13:50 -0000)
committer"Vladimir N. Oleynik" <dzo@simtreas.ru>
Fri, 23 Sep 2005 13:50:24 +0000 (13:50 -0000)
findutils/grep.c

index 986804553451fb775096227e862b9cbeeaa850c4..e41f1a3be46e54fef943c2b50d7c37de8e847c55 100644 (file)
@@ -398,7 +398,9 @@ extern int grep_main(int argc, char **argv)
        }
 #endif
 
-       if(be_quiet)
-               return error_open_count ? 2 : 0;
+       if(be_quiet && matched)
+               return 0;
+       if(error_open_count)
+               return 2;
        return !matched; /* invert return value 0 = success, 1 = failed */
 }