Last active
April 19, 2016 04:12
-
-
Save bhcleek/a630611dfe7ce07bbc23 to your computer and use it in GitHub Desktop.
linux-osx.mktemp.sh
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
# try to create a temporary directory on osx first. | |
# `mktemp -d` works on OSX and Linux The basename will be random: | |
TMPDIR=$(mktemp -d) | |
# `mktemp -d -t FOO` is valid on OSX and uses TMPDIR, but will cause an error on Linux. | |
# `mktemp -d -t FOO.XXXXXX is valid on both: on Linux will do substitution of the Xs; but on OSX, the Xs are taken literally. | |
TMPDIR=$(mktemp -d -t ${PREFIX} 2>/dev/null || mktemp -d -t ${PREFIX}.XXXXXX) | |
# this can be shorted to | |
TMPDIR=$(mktemp -d "${TMPDIR-:/tmp/}$PREFIX.XXXXXX") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment