I have a shell script which sucessfully redirects all output to a log file and stdout (console) at the same time. However, when it exits it seems to wait for some user input from the keyboard (experimentally, any key seems to work)... So, I run the script, see the output, it exits and I have to hit e.g. the spacebar before the terminal prompt re-appears. Typing echo $?
then gives the correct exit code.
The basics of the script are:
#!/bin/bash
LOG="./test.log"
rm -f $LOG
exec > >(tee $LOG) 2>&1
if [[ "$1" = "T" ]]; then
echo "twas true..."
exit 0
else
echo "twas false..."
exit 100
fi
Any help appreciated... not only do I not want to hit the spacebar but I would like to understand what is going on?
Amendment: it appears that I have to hit enter to get the terminal prompt back. From my limited experience using the ps command it would seem that my script has terminated and the bash shell is in the interruptible sleep state S. It would appear that maybe the terminal prompt output has been consumed or incorrectly redirected? I cannot see why...
> >
" looks wrong. Use ">>
".exec >>(tee $LOG) 2>&1
gives a syntax error?