On 2024-12-04 15:43, Frank Reppin wrote:
Some claim that this is due to 'set -o pipefail' beeing used in the
script... but this does not really explain why it only _sometimes_ happens.
I don't see why not. Pipe buffering is an "it all depends" situation.
Anyway, I tried your script on bleeding-edge grep on Fedora 40 and it
worked fine for me. You didn't mention your grep version; behavior in
this area changed in 2016, though I doubt your version is that old.
One workaround is to use "set -o pipefail" only for pipelines where you
want the entire pipeline to fail merely because one component failed.