Here's the command:
{ ( echo "to stdout"; echo "to stderr" >&2 ) > >(sleep 1; tee stdout.txt); } 2> >(sleep 2; tee stderr.txt >&2 )
And here's what I see:
zsh
% { ( echo "to stdout"; echo "to stderr" >&2 ) > >(sleep 1; tee stdout.txt); } 2> >(sleep 2; tee stderr.txt >&2 )
to stdout
to stderr
%
bash
$ { ( echo "to stdout"; echo "to stderr" >&2 ) > >(sleep 1; tee stdout.txt); } 2> >(sleep 2; tee stderr.txt >&2 )
$ to stdout
to stderr
Note that bash writes it's prompt $
before output completes, but zsh waits for the substituted processes to complete before prompting the user %
.
I suppose a reasonable answer might be "because that's how zsh works", but I want to know if this is documented anywhere so that I can learn more. As a zsh user among many bash users, I try to know the differences so that I know what to expect when I say "hey run this command".
(related question: https://stackoverflow.com/a/53051506/1054322)