I am trying to understand the reason behind the difference in redirections of bash output. Here are two approaches:
- Redirection of the output to named pipe:
/bin/bash -i 2>&1 1>/tmp/fifo
- Redirection using unnamed pipe to another script reading from stdin:
/bin/bash -i 2>&1 | ./reader.sh
reader.sh is supposed to read line by line from stdin:
while read LINE; do
echo ${LINE} # do something with it here
done
exit 0
The question is: Why when redirecting to fifo (approach#1) the prompt information (username@host: $) is not redirected, but when redirecting to another program/script (approach#2), it does?