From 920a817c78fa8a0e89c246f76efc6bb78f0f99e1 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Thu, 24 May 2018 22:15:47 +0000 Subject: [PATCH] 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 --- usr.bin/grep/zgrep.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.bin/grep/zgrep.sh b/usr.bin/grep/zgrep.sh index 8cc49f95291..c645b1ca590 100755 --- a/usr.bin/grep/zgrep.sh +++ b/usr.bin/grep/zgrep.sh @@ -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}