I have the following code. I am attempting to capture both output and errors to log file and console. When the code is ran, it shows the usage but then pauses for a carriage return. Not a big deal but just wondering how this need for a carriage return can be eliminated? I have narrowed it down to the exec line as noted below. How can I achieve this without the need for the carriage return? Thank you!
#!/bin/bash
log_file=$0.log
# The following line causes need for carriage return
exec > >(tee -a ${log_file} )
exec 2> >(tee -a ${log_file} >&2)
usage()
{
echo
echo "usage: $0 --option1 --option2 --option3 --option4 | [-h]"
echo
}
while [ "$1" != "" ]; do
case $1 in
--option1 ) shift
OPTION1=$1
;;
--option2 ) shift
OPTION2=$1
;;
--option3 ) shift
OPTION3=$1
;;
--option4 ) shift
OPTION4=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
usage
exit