summaryrefslogtreecommitdiff
path: root/zdiff.in
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2018-01-06 14:59:47 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2018-01-06 15:02:02 -0800
commit63aa2268a5abfed0116d04bbe3952e4a753af91d (patch)
tree5e04f5cf72d52168a57bd6fdbd641bae4a405f6c /zdiff.in
parent975508caa09d733099498ff9f7b8079cd71d7109 (diff)
downloadgzip-63aa2268a5abfed0116d04bbe3952e4a753af91d.tar.gz
gzexe: port to macOS mktemp
Problem reported by Jeffrey Walton (Bug#30000). * gzexe.in, zdiff.in, zgrep.in: Don’t assume that mktemp works when given no arguments, as this is not true for macOS. Instead, use a syntax that should work with coreutils, NetBSD, and macOS. While we’re in the neighborhood, be more consistent about how program names are used in temporary file names. Also, watch out for TMPDIR values that are not absolute file names, since they can cause problems (e.g., leading "-").
Diffstat (limited to 'zdiff.in')
-rw-r--r--zdiff.in11
1 files changed, 8 insertions, 3 deletions
diff --git a/zdiff.in b/zdiff.in
index bf644dd..960bf86 100644
--- a/zdiff.in
+++ b/zdiff.in
@@ -116,12 +116,17 @@ elif test $# -eq 2; then
test -n "$tmp" && rm -f "$tmp"
(exit 2); exit 2
' HUP INT PIPE TERM 0
+ case $TMPDIR in
+ / | /*/) ;;
+ /*) TMPDIR=$TMPDIR/;;
+ *) TMPDIR=/tmp/;;
+ esac
if type mktemp >/dev/null 2>&1; then
- tmp=`mktemp` || exit 2
+ tmp=`mktemp "${TMPDIR}zdiffXXXXXXXXX"` ||
+ exit 2
else
- F=`expr "/$2" : '.*/\(.*\)[-.][zZtga]*$'` || F=$prog
set -C
- tmp=${TMPDIR-/tmp}/$F.$$
+ tmp=${TMPDIR}zdiff$$
fi
gzip -cdfq -- "$2" > "$tmp" || exit 2
gzip_status=$(