aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacques Vidrine <nectar@FreeBSD.org>2002-01-28 01:29:22 +0000
committerJacques Vidrine <nectar@FreeBSD.org>2002-01-28 01:29:22 +0000
commiteb4c6c6cc790e5a864ea140614e183d135948f35 (patch)
tree126fc58feccdad6d32c37344033e459dbff3e9bd
parent7b66b3d610a0ce509b309a7ba5e5d4b31500f36d (diff)
downloadsrc-eb4c6c6cc790e5a864ea140614e183d135948f35.tar.gz
src-eb4c6c6cc790e5a864ea140614e183d135948f35.zip
MFC 1.6: Use mktemp(1) when creating temporary files.
Notes
Notes: svn path=/releng/4.3/; revision=89895
-rw-r--r--gnu/usr.bin/gzip/zdiff7
-rw-r--r--gnu/usr.bin/gzip/znew20
2 files changed, 16 insertions, 11 deletions
diff --git a/gnu/usr.bin/gzip/zdiff b/gnu/usr.bin/gzip/zdiff
index ebc9eca485a3..310a201e1a34 100644
--- a/gnu/usr.bin/gzip/zdiff
+++ b/gnu/usr.bin/gzip/zdiff
@@ -47,10 +47,11 @@ elif test $# -eq 2; then
case "$2" in
*[-.]gz* | *[-.][zZ] | *.t[ga]z)
F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*||'`
- gzip -cdfq "$2" > /tmp/"$F".$$
- gzip -cdfq "$1" | $comp $OPTIONS - /tmp/"$F".$$
+ tmp=`mktemp -t "$F"`
+ gzip -cdfq "$2" > "$tmp"
+ gzip -cdfq "$1" | $comp $OPTIONS - "$tmp"
STAT="$?"
- /bin/rm -f /tmp/"$F".$$;;
+ /bin/rm -f "$tmp";;
*) gzip -cdfq "$1" | $comp $OPTIONS - "$2"
STAT="$?";;
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