Take the following Bash script 3-output-writer.sh:
echo A >&1
echo B >&2
echo C >&3
Of course when ran as . 3-output-writer.sh it gets the error 3: Bad file descriptor, because Bash doesn't know what to do with the 3rd output stream. One can easily . 3-output-writer.sh 3>file.txt, though, and Bash is made happy.
But here's the question: how do I pipe all these into another process, so that it would have all three to work with? Is there any way other than creating three named pipes, as in,
mkfifo pipe1 pipe2 pipe3 # prepare pipes
. 3-output-writer.sh 1>pipe1 2>pipe2 3>pipe3 & # background the writer, awaiting readers
3-input-reader pipe1 pipe2 pipe3 # some sort of reader, careful not to block
rm pipe1 pipe2 pipe3
?