From a7097048f91e3df2ca55ff7441aaa1973a38c977 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Wed, 9 Nov 2022 16:20:04 +0100 Subject: [PATCH] Prevent grep from closing stdin The -q flag was causing grep to close the stdin as the first match is found, causing the exit code of the programs in the pipe to return non-zero, as stdout is closed. --- test/match-error.sh | 2 +- test/match-ok.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/match-error.sh b/test/match-error.sh index fc0b5ca..d64e318 100755 --- a/test/match-error.sh +++ b/test/match-error.sh @@ -11,7 +11,7 @@ regex="$1" shift -"${@}" 2>&1 | stdbuf -i0 -o0 tee /dev/stderr | grep -q "${regex}" +"${@}" 2>&1 | stdbuf -i0 -o0 tee /dev/stderr | grep "${regex}" >/dev/null rcprog=${PIPESTATUS[0]} rcgrep=${PIPESTATUS[2]} diff --git a/test/match-ok.sh b/test/match-ok.sh index 1af0c0a..9570d3c 100755 --- a/test/match-ok.sh +++ b/test/match-ok.sh @@ -11,7 +11,7 @@ regex="$1" shift -"${@}" 2>&1 | stdbuf -i0 -o0 tee /dev/stderr | grep -q "${regex}" +"${@}" 2>&1 | stdbuf -i0 -o0 tee /dev/stderr | grep "${regex}" >/dev/null rcprog=${PIPESTATUS[0]} rcgrep=${PIPESTATUS[2]}