diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-01-06 14:59:47 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-01-06 15:02:02 -0800 |
commit | 63aa2268a5abfed0116d04bbe3952e4a753af91d (patch) | |
tree | 5e04f5cf72d52168a57bd6fdbd641bae4a405f6c /zdiff.in | |
parent | 975508caa09d733099498ff9f7b8079cd71d7109 (diff) | |
download | gzip-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.in | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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=$( |