On Sat, 19 Feb 2022 08:01:20 -0800
Paul Eggert <egg...@cs.ucla.edu> wrote:
> bash --norc --noprofile -c 'set -eo pipefail; cat 
> /usr/share/dict/american-english | grep -l "^"; echo done'
> 
> the output is:
> 
> (standard input)
> 
> which means that Bash exited without doing the 'echo done'.

I'm running fish as shell, and that doesn't do that. Using bash, it
behaves as you describe. Just for my understanding, grep stops reading
when it finds the first match and then the shell closes the output
stream of cat. That in turn causes cat to fail (exit code 141, meaning
SIGPIPE), because it can't write the rest of the data that it wants,
right?


In any case, you have delivered some convincing arguments. I'll turn my
attention on the manpage instead. The benchmark (if that's what you
want to call it) that brought me to this was that grep behaviour
confused me and that I couldn't find anything even from reading the
docs. I think that short reads (which could cause SIGPIPE) and the
non-error exit code 1 deserve mention there. I'll take a look and
perhaps file another patch.


So long...


Uli



Reply via email to