William A. Kennington III | 2030ea5 | 2022-07-19 17:06:39 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | TMPDIR="$(mktemp -d --tmpdir "${TMPTMPL-tmp.XXXXXXXXXX}")" || exit |
Patrick Williams | 8c0113f | 2022-12-08 06:23:37 -0600 | [diff] [blame] | 3 | function rmtmp() { |
| 4 | if [ -n "${TMP_DEBUG-}" ]; then |
| 5 | echo "Removing TMPDIR=$TMPDIR" >&2 |
| 6 | fi |
| 7 | rm -rf -- "$TMPDIR" |
William A. Kennington III | 2030ea5 | 2022-07-19 17:06:39 -0700 | [diff] [blame] | 8 | } |
| 9 | trap rmtmp EXIT |
| 10 | export TMPDIR |
| 11 | if [ -n "${TMP_DEBUG-}" ]; then |
Patrick Williams | 8c0113f | 2022-12-08 06:23:37 -0600 | [diff] [blame] | 12 | echo "Exec $* with TMPDIR=$TMPDIR" >&2 |
William A. Kennington III | 2030ea5 | 2022-07-19 17:06:39 -0700 | [diff] [blame] | 13 | fi |
| 14 | "$@" |