summaryrefslogtreecommitdiff
path: root/usr.bin/mktemp
diff options
context:
space:
mode:
authorjmmv <jmmv@NetBSD.org>2004-04-02 10:44:22 +0000
committerjmmv <jmmv@NetBSD.org>2004-04-02 10:44:22 +0000
commitcc48ee25f53ae7e06cbddba538da7fb2e279b793 (patch)
tree15056b594ca4b90ee05de38829a73681a38f44dc /usr.bin/mktemp
parent36fa2ebfb9b3627a3eec99f076671c1b5e273d8a (diff)
Use ${0##*/} in examples instead of $0, so that they can successfully create
the temporary file even if the test program is executed given its full path. That is, running /somewhere/test.sh could result in a call to mktemp like mktemp /tmp//somewhere/test.sh.XXXXX, which fails. Fixes PR misc/23447 by Piotr Meyer.
Diffstat (limited to 'usr.bin/mktemp')
-rw-r--r--usr.bin/mktemp/mktemp.18
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/mktemp/mktemp.1 b/usr.bin/mktemp/mktemp.1
index 51d63831319..8574509b342 100644
--- a/usr.bin/mktemp/mktemp.1
+++ b/usr.bin/mktemp/mktemp.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: mktemp.1,v 1.9 2003/08/07 11:15:16 agc Exp $
+.\" $NetBSD: mktemp.1,v 1.10 2004/04/02 10:44:22 jmmv Exp $
.\" From: $FreeBSD: src/usr.bin/mktemp/mktemp.1,v 1.5 1999/08/28 01:04:13 peter Exp $
.\" From: $OpenBSD: mktemp.1,v 1.8 1998/03/19 06:13:37 millert Exp $
.\"
@@ -159,19 +159,19 @@ fragment illustrates a simple use of
where the script should quit if it cannot get a safe
temporary file.
.Bd -literal -offset indent
-TMPFILE=`mktemp /tmp/$0.XXXXXX` || exit 1
+TMPFILE=`mktemp /tmp/${0##*/}.XXXXXX` || exit 1
echo "program output" \*[Gt]\*[Gt] $TMPFILE
.Ed
.Pp
To allow the use of $TMPDIR:
.Bd -literal -offset indent
-TMPFILE=`mktemp -t $0` || exit 1
+TMPFILE=`mktemp -t ${0##*/}` || exit 1
echo "program output" \*[Gt]\*[Gt] $TMPFILE
.Ed
.Pp
In this case, we want the script to catch the error itself.
.Bd -literal -offset indent
-TMPFILE=`mktemp -q /tmp/$0.XXXXXX`
+TMPFILE=`mktemp -q /tmp/${0##*/}.XXXXXX`
if [ $? -ne 0 ]; then
echo "$0: Can't create temp file, exiting..."
exit 1