X-Git-Url: https://git.madduck.net/code/pulserecorder.git/blobdiff_plain/fb1414bb84493438c4404c07172bb15da1d96a7c..7cd55a11575980fba5232c781b41fab469d00ec7:/pulserecorder diff --git a/pulserecorder b/pulserecorder index 65a40ce..a9f4cdc 100755 --- a/pulserecorder +++ b/pulserecorder @@ -20,6 +20,17 @@ # set -eu +cleanup_commands= +cleanup() { + set +e + eval $cleanup_commands 2>/dev/null + trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15 +} +trap cleanup 1 2 3 4 5 6 7 8 10 11 12 13 14 15 +cleanup_hook() { + cleanup_commands="$@${cleanup_commands:+; $cleanup_commands}" +} + if [ -z "${TMPDIR:-}" ]; then TMPDIR=/tmp fi @@ -31,17 +42,8 @@ for i in $LOGNAME volatile; do done export TMPDIR TMPDIR=$(mktemp -dp "$TMPDIR" parec.XXXXXXXXXX) +cleanup_hook rm -r $TMPDIR -cleanup_commands="rm -r $TMPDIR" -cleanup() { - set +e - eval $cleanup_commands 2>/dev/null - trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15 -} -trap cleanup 1 2 3 4 5 6 7 8 10 11 12 13 14 15 -cleanup_hook() { - cleanup_commands="$@${cleanup_commands:+; $cleanup_commands}" -} state= outfile= index= clobber=0 for arg in "$@"; do