Detect mktemp from coreutils

GNU mktemp and BSD mktemp have different command line flags. On some
macOS systems users have mktemp from coreutils in their PATH overriding
the system mktemp from BSD. This commit adds detection for the coreutils
mktemp versus the BSD mktemp and uses the appropriate syntax based on
the detection.

Relates #27659
This commit is contained in:
Jason Tedor 2017-12-04 19:53:14 -05:00 committed by GitHub
parent 8635f68ece
commit 2208a1a7b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -75,9 +75,13 @@ if [ -z "$ES_PATH_CONF" ]; then
fi
if [ -z "$ES_TMPDIR" ]; then
if [ "`uname`" == "Darwin" ]; then
ES_TMPDIR=`mktemp -d -t elasticsearch`
set +e
mktemp --version 2>&1 | grep coreutils > /dev/null
mktemp_coreutils=$?
set -e
if [ $mktemp_coreutils -eq 0 ]; then
ES_TMPDIR=`mktemp -d --tmpdir "elasticearch.XXXXXXXX"`
else
ES_TMPDIR=`mktemp -d -t elasticsearch.XXXXXXXX`
ES_TMPDIR=`mktemp -d -t elasticsearch`
fi
fi