Reputation: 3739
When I run my script, I am forced to type enter key, in order exit the script after it completes. Here's my script:
log_file=/tmp/log.out
rm -f $log_file
setup()
{
exec > >(tee -a ${log_file} )
exec 2> >(tee -a ${log_file} >&2)
}
setup
echo "hello world"
echo "hello again"
I'm testing forcing all echo's to go to stdout and a log file simultaneously. I've seen this behavior before in scripts and have always wondered:
Upvotes: 2
Views: 833
Reputation: 81012
You don't have to hit enter. You are already at the next prompt. Try typing a command and hitting enter.
The problem is that you've raced the output and the next prompt being printed to the screen.
So your prompt gets printed before the standard error output gets printed so you "lose" your cursor positioning.
Clearing the screen, with Ctrl-L say, will also get you "back" to your prompt.
Upvotes: 4