Created attachment 1450179 [details] simple shell script highlighting the grep failures Description of problem: bash pipefail causes "grep -q" to return different results from "grep" Version-Release number of selected component (if applicable): GNU bash, version 4.4.19(1)-release (x86_64-redhat-linux-gnu) How reproducible: always Steps to Reproduce: set -o pipefail; if gcc --help=warnings | awk '{print $1}' | grep -F -q -- "-Wmisleading-indentation" ; then echo yay; fi Actual results: no output Expected results: output of "yay" Additional info: This doesn't seem to work for all grep invocations, for example -Wvla seems to work, but -Wmisleading-indentation does not. Removing the pipefail fixes this, as does removing the -q option of grep. I've added an attachment which shows each of these issues. I tried running the script through strace, but wasn't able to find anything obviously wrong.
Further testing seems to indicate this is also broken in F27.
This is not a bug. When grep is invoked with -q option, it closes input end of the pipe as soon as it hits first occurence of "-Wmisleading-indentation". That may cause awk to exit with non-zero status as the reading end of the pipe has been closed. You can workaround it by redirecting grep output to /dev/null and removing -q option.
Ahhh, yea that makes sense.