Author: bdrewery
Date: Thu May 24 22:15:47 2018
New Revision: 334190
URL: https://svnweb.freebsd.org/changeset/base/334190

Log:
  Fix exit code for mismatches after r333013.
  
  The -c flag still does the wrong thing versus the older version due to
  lack of pipefail support.
  
  Reported by:  antoine

Modified:
  head/usr.bin/grep/zgrep.sh

Modified: head/usr.bin/grep/zgrep.sh
==============================================================================
--- head/usr.bin/grep/zgrep.sh  Thu May 24 21:38:18 2018        (r334189)
+++ head/usr.bin/grep/zgrep.sh  Thu May 24 22:15:47 2018        (r334190)
@@ -138,19 +138,21 @@ then
     fi
 fi
 
+ret=0
 # call grep ...
 if [ $# -lt 1 ]
 then
     # ... on stdin
-    ${cattool} ${catargs} - | ${grep} ${grep_args} -- "${pattern}" -
+    ${cattool} ${catargs} - | ${grep} ${grep_args} -- "${pattern}" - || ret=$?
 else
     # ... on all files given on the command line
     if [ ${silent} -lt 1 -a $# -gt 1 ]; then
        grep_args="-H ${grep_args}"
     fi
     for file; do
-       ${cattool} ${catargs} -- "${file}" | ${grep} --label="${file}" 
${grep_args} -- "${pattern}" -
+       ${cattool} ${catargs} -- "${file}" |
+           ${grep} --label="${file}" ${grep_args} -- "${pattern}" - || ret=$?
     done
 fi
 
-exit 0
+exit ${ret}
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to