22nd September 2016

22nd September 2016 at 12:36pm
Journal

Reminder: I need to better understand and then write up Bash traps specifically in conjunction with subshell interactions.

http://unix.stackexchange.com/questions/13719/can-you-specify-a-separate-trap-in-a-subshell-created-with

function trap_subshell {
  if (( $BASH_SUBSHELL >= 1 )) ; then
    kill $$
  fi
}
set -o errtrace
trap trap_subshell ERR

...and coproc stuff http://wiki.bash-hackers.org/syntax/keywords/coproc:

barf () {
  echo "Hello world"
}
trap barf EXIT SIGINT
 
{ coproc { tee; } >&3; } 3>&1

exec 1<&${COPROC[1]}

echo "foo"
sleep 5
echo "bar"