Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: broken pipe message with setopt PRINT_EXIT_VALUE
On Fri, May 28, 2021 at 1:02 PM Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
>
> In both cases, tr/yes are being killed (with a SIGPIPE) because
> they're trying to write to a pipe that has no reader. [...]
>
> Which is printed (or rather here the "broken pipe" message
> corresponding to that death-by-SIGPIPE) because of
> PRINT_EXIT_VALUE.
Which is exactly what's supposed to happen when you have that set.
You can run the pipeline in a subshell to suppress this behavior:
( < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c 32; echo )
PRINT_EXIT_VALUE is disabled in subshells because subshells do not
normally maintain a jobs table like an interactive shell does.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author