From 8cb7617c625276309eb98df42bd37f60f43a4197 Mon Sep 17 00:00:00 2001 From: eadler Date: Wed, 10 Oct 2012 21:21:53 +0000 Subject: [PATCH] MFC r241118: Implement the Sun/GNU extension of using a default prefix when no arguments are supplied. Approved by: cperciva (implicit) git-svn-id: svn://svn.freebsd.org/base/stable/8@241422 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.bin/mktemp/mktemp.1 | 8 ++++++++ usr.bin/mktemp/mktemp.c | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/usr.bin/mktemp/mktemp.1 b/usr.bin/mktemp/mktemp.1 index 6e3575977..5359cbabd 100644 --- a/usr.bin/mktemp/mktemp.1 +++ b/usr.bin/mktemp/mktemp.1 @@ -103,6 +103,14 @@ Care should be taken to ensure that it is appropriate to use an environment variable potentially supplied by the user. .Pp +If no arguments are passed or if only the +.Fl d +flag is passed +.Nm +behaves as if +.Fl t Li tmp +was supplied. +.Pp Any number of temporary files may be created in a single invocation, including one based on the internal template resulting from the .Fl t diff --git a/usr.bin/mktemp/mktemp.c b/usr.bin/mktemp/mktemp.c index b58ac4b9d..7618fd4fb 100644 --- a/usr.bin/mktemp/mktemp.c +++ b/usr.bin/mktemp/mktemp.c @@ -87,6 +87,11 @@ main(int argc, char **argv) argc -= optind; argv += optind; + if (!tflag && argc < 1) { + tflag = 1; + prefix = "tmp"; + } + if (tflag) { tmpdir = getenv("TMPDIR"); if (tmpdir == NULL) @@ -100,8 +105,6 @@ main(int argc, char **argv) else errx(1, "cannot generate template"); } - } else if (argc < 1) { - usage(); } /* generate all requested files */ -- 2.45.0