I piped my own shell scripts for some testing and accidentally noticed something strange. Namely, the stderr of those piped processes isn't always displayed on the screen.
I simplified the scripts and here's my session with bash:
$ cat file1 echo stdout echo stderr 1>&2 $ cat file2 echo stdout2 echo stderr2 1>&2 $ cat file3 echo stdout3 echo stderr3 1>&2 $ ./file1 | ./file2 | ./file3 stderr2 stderr stdout3 stderr3 $ ./file1 | ./file2 | ./file3 stderr stdout3 stderr3 $ ./file1 | ./file2 | ./file3 stderr2 stdout3 stderr3
I know that the stdout of the first two scripts is lost, since file3 doesn't read anything, but it doesn't matter here.
What's happening with the
stderr outputs in the 2nd and 3rd case, respectively?