Created
June 2, 2017 07:41
-
-
Save chrolis/59450239e372a1211392e16954948404 to your computer and use it in GitHub Desktop.
temp directory snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
unset tmpdir | |
atexit() { | |
[[ -n ${tmpdir-} ]] && rm -rf "$tmpdir" | |
} | |
trap atexit EXIT | |
trap 'trap - EXIT; atexit; exit -1' INT PIPE TERM | |
tmpdir=$(mktemp -d "/tmp/${0##*/}.tmp.XXX") | |
echo $tmpdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment