diff options
author | Eric Schrock <Eric.Schrock@delphix.com> | 2012-05-14 12:05:00 -0700 |
---|---|---|
committer | Eric Schrock <Eric.Schrock@delphix.com> | 2012-05-14 12:05:00 -0700 |
commit | e8d80663e4f91871f843bb8ad9108dc0b76dfcf3 (patch) | |
tree | 62ee5365ffcd8e2428a7c78d6789c791e6c2d917 | |
parent | 979bfc6b3147fce227943f8095a6d30cb9f7870c (diff) | |
download | illumos-joyent-e8d80663e4f91871f843bb8ad9108dc0b76dfcf3.tar.gz |
2733 pgrep/pkill prints misleading error on missing option argument
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r-- | usr/src/cmd/pgrep/pgrep.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr/src/cmd/pgrep/pgrep.c b/usr/src/cmd/pgrep/pgrep.c index a8371dd6d8..4531f11267 100644 --- a/usr/src/cmd/pgrep/pgrep.c +++ b/usr/src/cmd/pgrep/pgrep.c @@ -22,8 +22,7 @@ * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 2012 by Delphix. All rights reserved */ #include <sys/types.h> #include <sys/stat.h> @@ -164,8 +163,8 @@ Usage: %s [-signal] [-fnovx] [-P ppidlist] [-g pgrplist] [-s sidlist]\n\ [-u euidlist] [-U uidlist] [-G gidlist] [-J projidlist]\n\ [-T taskidlist] [-t termlist] [-z zonelist] [-c ctidlist] [pattern]\n"; -static const char PGREP_OPTS[] = "flnovxc:d:D:u:U:G:P:g:s:t:z:J:T:"; -static const char PKILL_OPTS[] = "fnovxc:D:u:U:G:P:g:s:t:z:J:T:"; +static const char PGREP_OPTS[] = ":flnovxc:d:D:u:U:G:P:g:s:t:z:J:T:"; +static const char PKILL_OPTS[] = ":fnovxc:D:u:U:G:P:g:s:t:z:J:T:"; static const char LSEP[] = ",\t "; /* Argument list delimiter chars */ @@ -630,8 +629,13 @@ main(int argc, char *argv[]) while (optind < argc) { while ((c = getopt(argc, argv, optstr)) != (int)EOF) { - if (c == '?' || g_optdtab[c - 'A'].o_opts == 0) { - if (optopt != '?') { + if (c == ':' || c == '?' || + g_optdtab[c - 'A'].o_opts == 0) { + if (c == ':') { + uu_warn( + gettext("missing argument -- %c\n"), + optopt); + } else if (optopt != '?') { uu_warn( gettext("illegal option -- %c\n"), optopt); |