diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-06-26 02:43:32 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-06-26 02:43:32 +0000 |
commit | aaeb10c0bb699b736e2b7963d70a5a498beabf57 (patch) | |
tree | 5f056813c5c45622c44934cfedee486e40298355 /usr.bin/mktemp/mktemp.1 | |
parent | 664496090300092ebbc47efde004135a40984502 (diff) |
use basename(1) in examples
Diffstat (limited to 'usr.bin/mktemp/mktemp.1')
-rw-r--r-- | usr.bin/mktemp/mktemp.1 | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/mktemp/mktemp.1 b/usr.bin/mktemp/mktemp.1 index 9df253ac2bd..5dc7dbd8ed3 100644 --- a/usr.bin/mktemp/mktemp.1 +++ b/usr.bin/mktemp/mktemp.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mktemp.1,v 1.16 2000/03/28 23:40:05 aaron Exp $ +.\" $OpenBSD: mktemp.1,v 1.17 2000/06/26 02:43:31 pjanzen Exp $ .\" .\" Copyright (c) 1996, 2000 Todd C. Miller <Todd.Miller@courtesan.com> .\" All rights reserved. @@ -121,15 +121,17 @@ 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.XXXXXXXXXX` || exit 1 +CMD=`basename $0` +TMPFILE=`mktemp /tmp/$CMD.XXXXXXXXXX` || exit 1 echo "program output" >> $TMPFILE .Ed .Pp In this case, we want the script to catch the error ourselves. .Bd -literal -offset indent -TMPFILE=`mktemp -q /tmp/$0.XXXXXXXXXX` +CMD=`basename $0` +TMPFILE=`mktemp -q /tmp/$CMD.XXXXXXXXXX` if [ $? -ne 0 ]; then - echo "$0: Can't create temp file, exiting..." + echo "$CMD: Can't create temp file, exiting..." exit 1 fi .Ed @@ -139,7 +141,8 @@ Or perhaps you don't want to exit if is unable to create the file. In this case you can protect the part of the script thusly. .Bd -literal -offset indent -TMPFILE=`mktemp /tmp/$0.XXXXXXXXXX` && { +CMD=`basename $0` +TMPFILE=`mktemp /tmp/$CMD.XXXXXXXXXX` && { # Safe to use $TMPFILE in this block echo data > $TMPFILE ... |