.
I :
Mac OS X 10.10.3.
OPT_LOG=file.name
if [[ $OPT_LOG ]]
then exec > >(tee -a $OPT_LOG)
fi
for ((i = 0; i < 10; i++))
do
echo "Logging message $i at $(date)"
sleep 1
done
, , , . ? bash -x yourscript.sh?
chatraed
, script , :
OPT_LOG=file.name;
if [[ $OPT_LOG ]]; then exec > >(tee -a $OPT_LOG); fi;
for ((i = 0; i < 10; i++)); do echo "Logging message $i"; done
:
, ! .
:
pwd for " ", ( pwd, , Bash).bash -c 'exit 0' ( ), .> >(tee -a $OPT_LOG &), - . ( , , .)
, Bash, . (. Bash , .) , , , - . , Apple Bash 3.2.57; Bash 4.3.27 ( , ShellShock).
, script exec, , .
, chatraed , , . sleep 0, , sleep 0.1. ; ( POSIX) sleep . OTOH, sleep 0.1, , 0, , ; .1 .