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.
This commit is contained in:
Rodrigo Arias 2022-11-09 16:20:04 +01:00
parent b1b4f37032
commit a7097048f9
2 changed files with 2 additions and 2 deletions

View File

@ -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]}

View File

@ -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]}