SHA256
1
0
forked from pool/gzip
gzip/tempfile.diff

25 lines
638 B
Diff
Raw Normal View History

--- znew.in
+++ znew.in
@@ -55,8 +55,9 @@
# block is the disk block size (best guess, need not be exact)
warn="(does not preserve modes and timestamp)"
-tmp=/tmp/zfoo.$$
-set -C
+dtmp=`mktemp -d -t znew.XXXXXXXX` || exit
+trap 'rm -rf $dtmp' HUP INT PIPE TERM 0
+tmp=$dtmp/znew
echo hi > $tmp || exit
if test -z "`(${CPMOD-cpmod} $tmp $tmp) 2>&1`"; then
cpmod=${CPMOD-cpmod}
@@ -72,7 +73,8 @@
# check if GZIP env. variable uses -S or --suffix
gzip -q $tmp
ext=`echo $tmp* | sed "s|$tmp||"`
-rm -f $tmp*
+rm -f $dtmp
+trap - HUP INT PIPE TERM 0
if test -z "$ext"; then
echo znew: error determining gzip extension
exit 1