I have two shell scripts, one runs on a server and writes some files to a temporary directory. This directory is then sent as a tar archive to stdout. At the end (or when it gets interrupted), the temporary directory should be deleted. The server script (saved e.g. in '~/get_dumps.sh') looks like this:#!/bin/shset -etemp_dir=`mktemp -d`cd $temp_dirtrap rm -r $temp_dir; exit HUP INT TERM PIPEfor db in db1 db2 db3  do    pg_dump $db postgres > $db.sqldonetar cJf - .rm -r $temp_dirThe server script is called from a client with this script:#!/bin/shset -etemp_dir=`mktemp -d`trap rm -r $temp_dir; exit HUP INT TERM PIPEmkdir /tmp/dumpsssh server '~/get_dumps.sh' | tar xJf - -C $temp_dirls $temp_dirrm -r $temp_dirIf I run the client script and press Ctrl-C, neither on the client nor on the server the temporary directories are removed. Why does trap here not work?Edit: First I have forgotten to add set -e.
Shell scripts connected with pipe: trap termination of one script
shell script;pipe;trap