aboutsummaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/gzip/znew
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/gzip/znew')
-rw-r--r--gnu/usr.bin/gzip/znew20
1 files changed, 12 insertions, 8 deletions
diff --git a/gnu/usr.bin/gzip/znew b/gnu/usr.bin/gzip/znew
index 8e0e26bc76bd..52b0ae963c2f 100644
--- a/gnu/usr.bin/gzip/znew
+++ b/gnu/usr.bin/gzip/znew
@@ -14,24 +14,28 @@ block=1024
# block is the disk block size (best guess, need not be exact)
warn="(does not preserve modes and timestamp)"
-tmp=/tmp/zfoo.$$
-echo hi > $tmp.1
-echo hi > $tmp.2
-if test -z "`(${CPMOD-cpmod} $tmp.1 $tmp.2) 2>&1`"; then
+tmp=`mktemp -d -t znew`
+if test -z "$tmp"; then
+ echo znew: could not create temporary directory
+ exit 1
+fi
+echo hi > $tmp/1
+echo hi > $tmp/2
+if test -z "`(${CPMOD-cpmod} $tmp/1 $tmp/2) 2>&1`"; then
cpmod=${CPMOD-cpmod}
warn=""
fi
-if test -z "$cpmod" && ${TOUCH-touch} -r $tmp.1 $tmp.2 2>/dev/null; then
+if test -z "$cpmod" && ${TOUCH-touch} -r $tmp/1 $tmp/2 2>/dev/null; then
cpmod="${TOUCH-touch}"
cpmodarg="-r"
warn="(does not preserve file modes)"
fi
# check if GZIP env. variable uses -S or --suffix
-gzip -q $tmp.1
-ext=`echo $tmp.1* | sed "s|$tmp.1||"`
-rm -f $tmp.[12]*
+gzip -q $tmp/1
+ext=`echo $tmp/1* | sed "s|$tmp/1||"`
+rm -rf $tmp
if test -z "$ext"; then
echo znew: error determining gzip extension
exit 1