[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: proposed improvement of diagnostics for missing/extra operands
From: |
Paul Eggert |
Subject: |
Re: proposed improvement of diagnostics for missing/extra operands |
Date: |
Sun, 20 Jun 2004 01:18:14 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Jim Meyering <address@hidden> writes:
> I have mixed feelings about it.
OK, some good points there, and I've composed a revised patch (below)
which I hope addresses almost all the problems you mentioned. The
only exception is the last problem (when getopt reorders arguments),
which I'll discuss below.
> cur$ md5sum --check f a
> md5sum: only one argument may be specified when using --check
> new$ ./md5sum --check f a
> ./md5sum: extra operand `a'
Revised new behavior:
./md5sum: extra operand `a'
Only one operand may be specified when using --check.
Try `./md5sum --help' for more information.
> cur$ cp
> cp: missing file argument
> new$ ./cp
> ./cp: missing operand after `./cp'
Revised new behavior:
./cp: missing file operand
Try `./cp --help' for more information.
> cur$ cp a
> cp: missing destination file
> new$ ./cp a
> ./cp: missing operand after `a'
Revised new behavior:
./cp: missing destination file operand after `a'
Try `./cp --help' for more information.
> And if I happen to be using `mv' via an alias like `mv -i',
> then I get this:
>
> new$ alias mv='command mv -i'
> new$ PATH=. mv
> mv: missing operand after `-i'
>
> I prefer the current diagnostic:
>
> cur$ mv
> mv: missing file argument
Revised new behavior:
mv: missing file operand
Try `mv --help' for more information.
> Going a little overboard, it can get a ugly if getopt
> ends up reordering arguments:
>
> new$ ./mv a --force
> ./mv: missing operand after `a'
Here I think the new behavior is OK, since if you add the missing
operand after the `a', things will work; and that's the most natural
place to add the missing operand.
Here's the revised patch:
2004-06-20 Paul Eggert <address@hidden>
* src/basename.c (main):
Standardize on the diagnostics given when someone gives
too few operands ("missing operand after `xxx'") or
too many operands ("extra operand `xxx'").
Include "quote.h" and/or "error.h" if it wasn't already being included.
* src/chgrp.c (main): Likewise.
* src/chmod.c (main): Likewise.
* src/chown.c (main): Likewise.
* src/chroot.c (main): Likewise.
* src/comm.c (main): Likewise.
* src/cp.c (do_copy): Likewise.
* src/csplit.c (main): Likewise.
* src/date.c (main): Likewise.
* src/dircolors.c (main): Likewise.
* src/dirname.c (main): Likewise.
* src/du.c (main): Likewise.
* src/expr.c (main): Likewise.
* src/hostid.c (main): Likewise.
* src/hostname.c (main): Likewise.
* src/id.c (main): Likewise.
* src/install.c (main): Likewise.
* src/join.c (add_file_name, main): Likewise.
* src/link.c (main): Likewise.
* src/ln.c (main): Likewise.
* src/logname.c (main): Likewise.
* src/md5sum.c (main): Likewise.
* src/mkdir.c (main): Likewise.
* src/mkfifo.c (main): Likewise.
* src/mknod.c (main): Likewise.
* src/mv.c (main): Likewise.
* src/nohup.c (main): Likewise.
* src/od.c (main): Likewise.
* src/pathchk.c (main): Likewise.
* src/ptx.c (main): Likewise.
* src/readlink.c (main): Likewise.
* src/rm.c (main): Likewise.
* src/rmdir.c (main): Likewise.
* src/seq.c (main): Likewise.
* src/setuidgid.c (main): Likewise.
* src/shred.c (main): Likewise.
* src/sleep.c (main): Likewise.
* src/sort.c (main): Likewise.
* src/split.c (main): Likewise.
* src/stat.c (main): Likewise.
* src/test.c (beyond, main): Likewise.
* src/touch.c (main): Likewise.
* src/tr.c (main): Likewise.
* src/tsort.c (main): Likewise.
* src/tty.c (main): Likewise.
* src/uname.c (main): Likewise.
* src/uniq.c (main): Likewise.
* src/unlink.c (main): Likewise.
* src/uptime.c (main): Likewise.
* src/users.c (main): Likewise.
* src/who.c (main): Likewise.
* src/whoami.c (main): Likewise.
* tests/basename/basic: Adjust to new diagnostics.
* tests/du/files0-from: Likewise.
* tests/expr/basic: Likewise.
* tests/mv/diag: Likewise.
* tests/tsort/basic-1: Likewise.
Index: src/basename.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/basename.c,v
retrieving revision 1.56
diff -p -u -r1.56 basename.c
--- src/basename.c 21 Jan 2004 22:42:34 -0000 1.56
+++ src/basename.c 20 Jun 2004 06:36:14 -0000
@@ -33,6 +33,7 @@
#include "long-options.h"
#include "dirname.h"
#include "error.h"
+#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "basename"
@@ -109,10 +110,15 @@ main (int argc, char **argv)
++argv;
}
- if (argc <= 1 || argc > 3)
+ if (argc < 2)
{
- error (0, 0, (argc <= 1 ? _("too few arguments")
- : _("too many arguments")));
+ error (0, 0, _("missing operand"));
+ usage (EXIT_FAILURE);
+ }
+
+ if (3 < argc)
+ {
+ error (0, 0, _("extra operand %s"), quote (argv[3]));
usage (EXIT_FAILURE);
}
Index: src/chgrp.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/chgrp.c,v
retrieving revision 1.111
diff -p -u -r1.111 chgrp.c
--- src/chgrp.c 8 Jun 2004 13:40:00 -0000 1.111
+++ src/chgrp.c 20 Jun 2004 07:29:22 -0000
@@ -269,9 +269,12 @@ main (int argc, char **argv)
chopt.affect_symlink_referent = (dereference != 0);
}
- if (argc - optind + (reference_file ? 1 : 0) <= 1)
+ if (argc - optind < (reference_file ? 1 : 2))
{
- error (0, 0, _("too few arguments"));
+ if (argc <= optind)
+ error (0, 0, _("missing operand"));
+ else
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
usage (EXIT_FAILURE);
}
Index: src/chmod.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/chmod.c,v
retrieving revision 1.103
diff -p -u -r1.103 chmod.c
--- src/chmod.c 9 Jun 2004 09:06:34 -0000 1.103
+++ src/chmod.c 20 Jun 2004 07:29:22 -0000
@@ -425,7 +425,10 @@ main (int argc, char **argv)
if (optind >= argc)
{
- error (0, 0, _("too few arguments"));
+ if (modeind == 0 || modeind != argc - 1)
+ error (0, 0, _("missing operand"));
+ else
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
usage (EXIT_FAILURE);
}
Index: src/chown.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/chown.c,v
retrieving revision 1.116
diff -p -u -r1.116 chown.c
--- src/chown.c 8 Jun 2004 13:37:40 -0000 1.116
+++ src/chown.c 20 Jun 2004 07:29:22 -0000
@@ -285,9 +285,12 @@ main (int argc, char **argv)
chopt.affect_symlink_referent = (dereference != 0);
}
- if (argc - optind + (reference_file ? 1 : 0) <= 1)
+ if (argc - optind < (reference_file ? 1 : 2))
{
- error (0, 0, _("too few arguments"));
+ if (argc <= optind)
+ error (0, 0, _("missing operand"));
+ else
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
usage (EXIT_FAILURE);
}
Index: src/chroot.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/chroot.c,v
retrieving revision 1.42
diff -p -u -r1.42 chroot.c
--- src/chroot.c 17 Jun 2004 13:09:21 -0000 1.42
+++ src/chroot.c 20 Jun 2004 06:49:57 -0000
@@ -86,7 +86,7 @@ main (int argc, char **argv)
if (argc <= 1)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAIL);
}
Index: src/comm.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/comm.c,v
retrieving revision 1.74
diff -p -u -r1.74 comm.c
--- src/comm.c 21 Feb 2004 09:21:15 -0000 1.74
+++ src/comm.c 20 Jun 2004 07:29:22 -0000
@@ -26,6 +26,7 @@
#include "linebuffer.h"
#include "error.h"
#include "hard-locale.h"
+#include "quote.h"
#include "xmemcoll.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -283,9 +284,18 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- if (optind + 2 != argc)
+ if (argc - optind < 2)
{
- error (0, 0, _("too few arguments"));
+ if (argc <= optind)
+ error (0, 0, _("missing operand"));
+ else
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
+ usage (EXIT_FAILURE);
+ }
+
+ if (2 < argc - optind)
+ {
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 2]));
usage (EXIT_FAILURE);
}
Index: src/cp.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/cp.c,v
retrieving revision 1.193
diff -p -u -r1.193 cp.c
--- src/cp.c 13 Mar 2004 08:09:58 -0000 1.193
+++ src/cp.c 20 Jun 2004 06:52:31 -0000
@@ -478,14 +478,13 @@ do_copy (int n_files, char **file, const
int ret = 0;
int dest_is_dir = 0;
- if (n_files <= 0)
+ if (n_files <= !target_directory)
{
- error (0, 0, _("missing file argument"));
- usage (EXIT_FAILURE);
- }
- if (n_files == 1 && !target_directory)
- {
- error (0, 0, _("missing destination file"));
+ if (n_files == 0)
+ error (0, 0, _("missing file operand"));
+ else
+ error (0, 0, _("missing destination file operand after %s"),
+ quote (file[0]));
usage (EXIT_FAILURE);
}
Index: src/csplit.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/csplit.c,v
retrieving revision 1.127
diff -p -u -r1.127 csplit.c
--- src/csplit.c 21 Apr 2004 12:57:33 -0000 1.127
+++ src/csplit.c 20 Jun 2004 07:29:50 -0000
@@ -32,6 +32,7 @@
#include "error.h"
#include "inttostr.h"
#include "safe-read.h"
+#include "quote.h"
#include "xstrtol.h"
#ifndef SA_NOCLDSTOP
@@ -1374,7 +1375,10 @@ main (int argc, char **argv)
if (argc - optind < 2)
{
- error (0, 0, _("too few arguments"));
+ if (argc <= optind)
+ error (0, 0, _("missing operand"));
+ else
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
usage (EXIT_FAILURE);
}
Index: src/date.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/date.c,v
retrieving revision 1.136
diff -p -u -r1.136 date.c
--- src/date.c 1 Jun 2004 12:52:31 -0000 1.136
+++ src/date.c 7 Jun 2004 20:42:21 -0000
@@ -373,8 +373,7 @@ main (int argc, char **argv)
if (n_args > 1)
{
- error (0, 0, _("too many non-option arguments: %s%s"),
- argv[optind + 1], n_args == 2 ? "" : " ...");
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
usage (EXIT_FAILURE);
}
Index: src/dircolors.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/dircolors.c,v
retrieving revision 1.81
diff -p -u -r1.81 dircolors.c
--- src/dircolors.c 21 Jan 2004 22:56:22 -0000 1.81
+++ src/dircolors.c 20 Jun 2004 07:54:22 -0000
@@ -462,17 +462,13 @@ to select a shell syntax are mutually ex
usage (EXIT_FAILURE);
}
- if (print_database && argc > 0)
+ if (!print_database < argc)
{
- error (0, 0,
- _("no FILE arguments may be used with the option to output\n\
-dircolors' internal database"));
- usage (EXIT_FAILURE);
- }
-
- if (!print_database && argc > 1)
- {
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[!print_database]));
+ if (print_database)
+ fprintf (stderr, "%s\n",
+ _("File operands cannot be combined with "
+ "--print-database (-p)."));
usage (EXIT_FAILURE);
}
Index: src/dirname.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/dirname.c,v
retrieving revision 1.62
diff -p -u -r1.62 dirname.c
--- src/dirname.c 21 Jan 2004 22:56:47 -0000 1.62
+++ src/dirname.c 20 Jun 2004 06:55:48 -0000
@@ -25,6 +25,7 @@
#include "long-options.h"
#include "error.h"
#include "dirname.h"
+#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "dirname"
@@ -84,10 +85,15 @@ main (int argc, char **argv)
++argv;
}
- if (argc != 2)
+ if (argc < 2)
{
- error (0, 0, argc < 2 ? _("too few arguments")
- : _("too many arguments"));
+ error (0, 0, _("missing operand"));
+ usage (EXIT_FAILURE);
+ }
+
+ if (2 < argc)
+ {
+ error (0, 0, _("extra operand %s"), quote (argv[2]));
usage (EXIT_FAILURE);
}
Index: src/du.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/du.c,v
retrieving revision 1.195
diff -p -u -r1.195 du.c
--- src/du.c 27 Apr 2004 16:34:47 -0000 1.195
+++ src/du.c 20 Jun 2004 07:52:53 -0000
@@ -735,9 +735,12 @@ main (int argc, char **argv)
/* When using --files0-from=F, you may not specify any files
on the command-line. */
if (optind < argc)
- error (EXIT_FAILURE, 0,
- _("%s: you may not specify command-line arguments with\
- --files0-from"), quotearg_colon (argv[optind]));
+ {
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
+ fprintf (stderr, "%s\n",
+ _("File operands cannot be combined with --files0-from."));
+ usage (EXIT_FAILURE);
+ }
istream = (STREQ (files_from, "-") ? stdin : fopen (files_from, "r"));
if (istream == NULL)
Index: src/expr.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/expr.c,v
retrieving revision 1.93
diff -p -u -r1.93 expr.c
--- src/expr.c 1 Jun 2004 12:52:14 -0000 1.93
+++ src/expr.c 20 Jun 2004 06:56:27 -0000
@@ -196,7 +196,7 @@ main (int argc, char **argv)
if (argc <= 1)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXPR_INVALID);
}
Index: src/hostid.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/hostid.c,v
retrieving revision 1.26
diff -p -u -r1.26 hostid.c
--- src/hostid.c 17 Jun 2004 13:09:37 -0000 1.26
+++ src/hostid.c 20 Jun 2004 05:21:43 -0000
@@ -26,6 +26,7 @@
#include "system.h"
#include "long-options.h"
#include "error.h"
+#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "hostid"
@@ -83,7 +84,7 @@ main (int argc, char **argv)
if (argc > 1)
{
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[1]));
usage (EXIT_FAILURE);
}
Index: src/hostname.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/hostname.c,v
retrieving revision 1.51
diff -p -u -r1.51 hostname.c
--- src/hostname.c 17 Jun 2004 13:09:32 -0000 1.51
+++ src/hostname.c 20 Jun 2004 05:21:43 -0000
@@ -24,6 +24,7 @@
#include "system.h"
#include "long-options.h"
#include "error.h"
+#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "hostname"
@@ -131,7 +132,7 @@ main (int argc, char **argv)
}
else
{
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[2]));
usage (EXIT_FAILURE);
}
Index: src/id.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/id.c,v
retrieving revision 1.76
diff -p -u -r1.76 id.c
--- src/id.c 6 May 2004 14:46:00 -0000 1.76
+++ src/id.c 7 Jun 2004 20:49:03 -0000
@@ -28,6 +28,7 @@
#include "system.h"
#include "error.h"
+#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "id"
@@ -166,7 +167,10 @@ main (int argc, char **argv)
_("cannot print only names or real IDs in default format"));
if (argc - optind > 1)
- usage (EXIT_FAILURE);
+ {
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
+ usage (EXIT_FAILURE);
+ }
if (argc - optind == 1)
{
Index: src/install.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/install.c,v
retrieving revision 1.159
diff -p -u -r1.159 install.c
--- src/install.c 21 Apr 2004 12:25:18 -0000 1.159
+++ src/install.c 20 Jun 2004 07:29:22 -0000
@@ -283,7 +283,10 @@ main (int argc, char **argv)
if (argc <= optind || (n_files == 1 && !dir_arg))
{
- error (0, 0, _("too few arguments"));
+ if (argc <= optind)
+ error (0, 0, _("missing operand"));
+ else
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
usage (EXIT_FAILURE);
}
Index: src/join.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/join.c,v
retrieving revision 1.129
diff -p -u -r1.129 join.c
--- src/join.c 17 Apr 2004 14:05:37 -0000 1.129
+++ src/join.c 20 Jun 2004 07:29:22 -0000
@@ -736,7 +736,7 @@ add_file_name (char const *name, char co
{
if (*nfiles == 2)
{
- error (0, 0, _("too many non-option arguments"));
+ error (0, 0, _("extra operand %s"), quote (name));
usage (EXIT_FAILURE);
}
names[(*nfiles)++] = name;
@@ -848,7 +848,10 @@ main (int argc, char **argv)
if (nfiles != 2)
{
- error (0, 0, _("too few non-option arguments"));
+ if (nfiles == 0)
+ error (0, 0, _("missing operand"));
+ else
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
usage (EXIT_FAILURE);
}
Index: src/link.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/link.c,v
retrieving revision 1.11
diff -p -u -r1.11 link.c
--- src/link.c 21 Jan 2004 23:15:17 -0000 1.11
+++ src/link.c 20 Jun 2004 07:29:22 -0000
@@ -85,13 +85,16 @@ main (int argc, char **argv)
if (argc < 3)
{
- error (0, 0, _("too few arguments"));
+ if (argc < 2)
+ error (0, 0, _("missing operand"));
+ else
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
usage (EXIT_FAILURE);
}
if (3 < argc)
{
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[3]));
usage (EXIT_FAILURE);
}
Index: src/ln.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/ln.c,v
retrieving revision 1.134
diff -p -u -r1.134 ln.c
--- src/ln.c 27 Apr 2004 16:36:03 -0000 1.134
+++ src/ln.c 20 Jun 2004 07:07:00 -0000
@@ -493,7 +493,7 @@ main (int argc, char **argv)
if (argc <= optind)
{
- error (0, 0, _("missing file argument"));
+ error (0, 0, _("missing file operand"));
usage (EXIT_FAILURE);
}
Index: src/logname.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/logname.c,v
retrieving revision 1.53
diff -p -u -r1.53 logname.c
--- src/logname.c 21 Jan 2004 23:16:01 -0000 1.53
+++ src/logname.c 7 Jun 2004 20:49:30 -0000
@@ -23,6 +23,7 @@
#include "system.h"
#include "error.h"
#include "long-options.h"
+#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "logname"
@@ -88,7 +89,7 @@ main (int argc, char **argv)
if (optind < argc)
{
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
usage (EXIT_FAILURE);
}
Index: src/md5sum.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/md5sum.c,v
retrieving revision 1.123
diff -p -u -r1.123 md5sum.c
--- src/md5sum.c 6 May 2004 14:51:20 -0000 1.123
+++ src/md5sum.c 20 Jun 2004 07:59:08 -0000
@@ -30,6 +30,7 @@
#include "checksum.h"
#include "getline.h"
#include "error.h"
+#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME (algorithm == ALG_MD5 ? "md5sum" : "sha1sum")
@@ -644,7 +645,9 @@ verifying checksums"));
if (optind < argc)
{
- error (0, 0, _("no files may be specified when using --string"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
+ fprintf (stderr, "%s\n",
+ _("File operands cannot be combined with --string."));
usage (EXIT_FAILURE);
}
for (i = 0; i < n_strings; ++i)
@@ -665,8 +668,9 @@ verifying checksums"));
{
if (optind + 1 < argc)
{
- error (0, 0,
- _("only one argument may be specified when using --check"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
+ fprintf (stderr, "%s\n",
+ _("Only one operand may be specified when using --check."));
usage (EXIT_FAILURE);
}
Index: src/mkdir.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/mkdir.c,v
retrieving revision 1.88
diff -p -u -r1.88 mkdir.c
--- src/mkdir.c 21 Jan 2004 23:21:31 -0000 1.88
+++ src/mkdir.c 20 Jun 2004 07:08:12 -0000
@@ -122,7 +122,7 @@ main (int argc, char **argv)
if (optind == argc)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
Index: src/mkfifo.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/mkfifo.c,v
retrieving revision 1.70
diff -p -u -r1.70 mkfifo.c
--- src/mkfifo.c 21 Jan 2004 23:22:07 -0000 1.70
+++ src/mkfifo.c 20 Jun 2004 07:08:42 -0000
@@ -111,7 +111,7 @@ main (int argc, char **argv)
if (optind == argc)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
Index: src/mknod.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/mknod.c,v
retrieving revision 1.79
diff -p -u -r1.79 mknod.c
--- src/mknod.c 21 Jan 2004 23:22:33 -0000 1.79
+++ src/mknod.c 20 Jun 2004 08:00:18 -0000
@@ -91,6 +91,7 @@ main (int argc, char **argv)
struct mode_change *change;
const char *specified_mode;
int optc;
+ int expected_operands;
mode_t node_type;
initialize_main (&argc, &argv);
@@ -131,16 +132,27 @@ main (int argc, char **argv)
newmode = mode_adjust (newmode, change);
}
- if (argc - optind != 2 && argc - optind != 4)
+ expected_operands = (argv[optind + 1][0] == 'p' ? 2 : 4);
+
+ if (argc - optind < expected_operands)
{
- const char *msg;
- if (argc - optind < 2)
- msg = _("too few arguments");
- else if (argc - optind > 4)
- msg = _("too many arguments");
+ if (argc <= optind)
+ error (0, 0, _("missing operand"));
else
- msg = _("wrong number of arguments");
- error (0, 0, "%s", msg);
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
+ if (expected_operands == 4 && argc - optind == 2)
+ fprintf (stderr, "%s\n",
+ _("Special files require major and minor device numbers."));
+ usage (EXIT_FAILURE);
+ }
+
+ if (expected_operands < argc - optind)
+ {
+ error (0, 0, _("extra operand %s"),
+ quote (argv[optind + expected_operands]));
+ if (expected_operands == 2 && argc - optind == 4)
+ fprintf (stderr,
+ _("Fifos do not have major and minor device numbers."));
usage (EXIT_FAILURE);
}
@@ -167,14 +179,6 @@ main (int argc, char **argv)
goto block_or_character;
block_or_character:
- if (argc - optind != 4)
- {
- error (0, 0, _("\
-when creating special files, major and minor device\n\
-numbers must be specified"));
- usage (EXIT_FAILURE);
- }
-
{
char const *s_major = argv[optind + 2];
char const *s_minor = argv[optind + 3];
@@ -206,12 +210,6 @@ numbers must be specified"));
#ifndef S_ISFIFO
error (EXIT_FAILURE, 0, _("fifo files not supported"));
#else
- if (argc - optind != 2)
- {
- error (0, 0, _("\
-major and minor device numbers may not be specified for fifo files"));
- usage (EXIT_FAILURE);
- }
if (mkfifo (argv[optind], newmode))
error (EXIT_FAILURE, errno, "%s", quote (argv[optind]));
#endif
Index: src/mv.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/mv.c,v
retrieving revision 1.153
diff -p -u -r1.153 mv.c
--- src/mv.c 29 May 2004 22:06:25 -0000 1.153
+++ src/mv.c 20 Jun 2004 07:29:22 -0000
@@ -457,7 +457,11 @@ main (int argc, char **argv)
if (n_files == 0 || (n_files == 1 && !target_directory_specified))
{
- error (0, 0, _("missing file argument"));
+ if (n_files == 0)
+ error (0, 0, _("missing file operand"));
+ else
+ error (0, 0, _("missing file operand after %s"),
+ quote (argv[argc - 1]));
usage (EXIT_FAILURE);
}
Index: src/nohup.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/nohup.c,v
retrieving revision 1.14
diff -p -u -r1.14 nohup.c
--- src/nohup.c 20 Apr 2004 10:44:42 -0000 1.14
+++ src/nohup.c 20 Jun 2004 07:15:19 -0000
@@ -97,7 +97,7 @@ main (int argc, char **argv)
if (argc <= 1)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (NOHUP_FAILURE);
}
Index: src/od.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/od.c,v
retrieving revision 1.148
diff -p -u -r1.148 od.c
--- src/od.c 13 May 2004 07:26:14 -0000 1.148
+++ src/od.c 20 Jun 2004 08:01:23 -0000
@@ -26,6 +26,7 @@
#include "system.h"
#include "error.h"
#include "posixver.h"
+#include "quote.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -1873,8 +1874,9 @@ it must be one character from [doxn]"),
}
else if (n_files > 3)
{
- error (0, 0,
- _("compatibility mode supports at most three arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 3]));
+ fprintf (stderr, "%s\n",
+ _("Compatibility mode supports at most three operands."));
usage (EXIT_FAILURE);
}
Index: src/pathchk.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/pathchk.c,v
retrieving revision 1.76
diff -p -u -r1.76 pathchk.c
--- src/pathchk.c 21 Jan 2004 23:38:15 -0000 1.76
+++ src/pathchk.c 20 Jun 2004 07:15:48 -0000
@@ -186,7 +186,7 @@ main (int argc, char **argv)
if (optind == argc)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
Index: src/ptx.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/ptx.c,v
retrieving revision 1.42
diff -p -u -r1.42 ptx.c
--- src/ptx.c 1 Jun 2004 13:05:27 -0000 1.42
+++ src/ptx.c 7 Jun 2004 20:47:23 -0000
@@ -27,6 +27,7 @@
#include "argmatch.h"
#include "diacrit.h"
#include "error.h"
+#include "quote.h"
#include "quotearg.h"
#include "regex.h"
#include "xstrtol.h"
@@ -2162,7 +2163,10 @@ Inc., 59 Temple Place - Suite 330, Bosto
/* Diagnose any other argument as an error. */
if (optind < argc)
- usage (EXIT_FAILURE);
+ {
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
+ usage (EXIT_FAILURE);
+ }
}
/* If the output format has not been explicitly selected, choose dumb
Index: src/readlink.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/readlink.c,v
retrieving revision 1.10
diff -p -u -r1.10 readlink.c
--- src/readlink.c 1 Jun 2004 13:37:01 -0000 1.10
+++ src/readlink.c 20 Jun 2004 07:18:00 -0000
@@ -125,7 +125,7 @@ main (int argc, char *const argv[])
if (optind >= argc)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
@@ -133,7 +133,7 @@ main (int argc, char *const argv[])
if (optind < argc)
{
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
usage (EXIT_FAILURE);
}
Index: src/rm.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/rm.c,v
retrieving revision 1.128
diff -p -u -r1.128 rm.c
--- src/rm.c 29 May 2004 22:07:03 -0000 1.128
+++ src/rm.c 20 Jun 2004 07:18:21 -0000
@@ -231,7 +231,7 @@ main (int argc, char **argv)
exit (EXIT_SUCCESS);
else
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
}
Index: src/rmdir.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/rmdir.c,v
retrieving revision 1.75
diff -p -u -r1.75 rmdir.c
--- src/rmdir.c 22 Jan 2004 20:48:38 -0000 1.75
+++ src/rmdir.c 20 Jun 2004 07:18:40 -0000
@@ -205,7 +205,7 @@ main (int argc, char **argv)
if (optind == argc)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
Index: src/seq.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/seq.c,v
retrieving revision 1.80
diff -p -u -r1.80 seq.c
--- src/seq.c 23 Feb 2004 21:22:34 -0000 1.80
+++ src/seq.c 20 Jun 2004 07:19:01 -0000
@@ -26,6 +26,7 @@
#include "system.h"
#include "c-strtod.h"
#include "error.h"
+#include "quote.h"
#include "xstrtol.h"
#include "xstrtod.h"
@@ -371,13 +372,13 @@ main (int argc, char **argv)
if (argc - optind < 1)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
if (3 < argc - optind)
{
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 3]));
usage (EXIT_FAILURE);
}
Index: src/setuidgid.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/setuidgid.c,v
retrieving revision 1.9
diff -p -u -r1.9 setuidgid.c
--- src/setuidgid.c 22 Jan 2004 20:53:55 -0000 1.9
+++ src/setuidgid.c 20 Jun 2004 07:20:36 -0000
@@ -96,7 +96,10 @@ main (int argc, char **argv)
if (argc <= 2)
{
- error (0, 0, _("too few arguments"));
+ if (argc < 2)
+ error (0, 0, _("missing operand"));
+ else
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
usage (SETUIDGID_FAILURE);
}
Index: src/shred.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/shred.c,v
retrieving revision 1.97
diff -p -u -r1.97 shred.c
--- src/shred.c 8 Jun 2004 06:47:43 -0000 1.97
+++ src/shred.c 20 Jun 2004 07:21:06 -0000
@@ -1685,7 +1685,7 @@ main (int argc, char **argv)
if (n_files == 0)
{
- error (0, 0, _("missing file argument"));
+ error (0, 0, _("missing file operand"));
usage (EXIT_FAILURE);
}
Index: src/sleep.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/sleep.c,v
retrieving revision 1.84
diff -p -u -r1.84 sleep.c
--- src/sleep.c 21 Jan 2004 23:44:47 -0000 1.84
+++ src/sleep.c 20 Jun 2004 07:21:48 -0000
@@ -137,7 +137,7 @@ main (int argc, char **argv)
if (argc == 1)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
Index: src/sort.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/sort.c,v
retrieving revision 1.287
diff -p -u -r1.287 sort.c
--- src/sort.c 1 Jun 2004 13:00:28 -0000 1.287
+++ src/sort.c 20 Jun 2004 05:47:49 -0000
@@ -34,6 +34,7 @@
#include "long-options.h"
#include "physmem.h"
#include "posixver.h"
+#include "quote.h"
#include "stdio-safer.h"
#include "xmemcoll.h"
#include "xstrtol.h"
@@ -2511,8 +2512,11 @@ main (int argc, char **argv)
if (checkonly)
{
if (nfiles > 1)
- error (SORT_FAILURE, 0, _("extra operand `%s' not allowed with -c"),
- files[1]);
+ {
+ error (0, 0, _("extra operand %s not allowed with -c"),
+ quote (files[1]));
+ usage (SORT_FAILURE);
+ }
/* POSIX requires that sort return 1 IFF invoked with -c and the
input is not properly sorted. */
Index: src/split.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/split.c,v
retrieving revision 1.98
diff -p -u -r1.98 split.c
--- src/split.c 15 Apr 2004 09:10:54 -0000 1.98
+++ src/split.c 7 Jun 2004 20:47:41 -0000
@@ -35,6 +35,7 @@
#include "full-write.h"
#include "inttostr.h"
#include "posixver.h"
+#include "quote.h"
#include "safe-read.h"
#include "xstrtol.h"
@@ -532,7 +533,7 @@ main (int argc, char **argv)
if (optind < argc)
{
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
usage (EXIT_FAILURE);
}
Index: src/stat.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/stat.c,v
retrieving revision 1.70
diff -p -u -r1.70 stat.c
--- src/stat.c 1 Jun 2004 13:36:40 -0000 1.70
+++ src/stat.c 20 Jun 2004 07:22:04 -0000
@@ -821,7 +821,7 @@ main (int argc, char *argv[])
if (argc == optind)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
Index: src/test.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/test.c,v
retrieving revision 1.100
diff -p -u -r1.100 test.c
--- src/test.c 1 Jun 2004 13:17:08 -0000 1.100
+++ src/test.c 20 Jun 2004 06:13:17 -0000
@@ -43,6 +43,7 @@
#include "system.h"
#include "error.h"
#include "euidaccess.h"
+#include "quote.h"
#ifndef _POSIX_VERSION
# include <sys/param.h>
@@ -199,7 +200,7 @@ advance (int f)
static void
beyond (void)
{
- test_syntax_error (_("argument expected\n"), NULL);
+ test_syntax_error (_("missing argument after %s"), quote (argv[argc - 1]));
}
/* Syntax error for when an integer argument was expected, but
@@ -1116,7 +1117,7 @@ main (int margc, char **margv)
value = posixtest (argc - 1);
if (pos != argc)
- test_syntax_error (_("too many arguments\n"), NULL);
+ test_syntax_error (_("extra argument %s"), quote (argv[pos]));
test_exit (SHELL_BOOLEAN (value));
}
Index: src/touch.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/touch.c,v
retrieving revision 1.121
diff -p -u -r1.121 touch.c
--- src/touch.c 9 Jun 2004 14:47:29 -0000 1.121
+++ src/touch.c 20 Jun 2004 07:23:05 -0000
@@ -409,7 +409,7 @@ main (int argc, char **argv)
if (optind == argc)
{
- error (0, 0, _("file arguments missing"));
+ error (0, 0, _("missing file operand"));
usage (EXIT_FAILURE);
}
Index: src/tr.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tr.c,v
retrieving revision 1.135
diff -p -u -r1.135 tr.c
--- src/tr.c 17 Jun 2004 21:32:45 -0000 1.135
+++ src/tr.c 20 Jun 2004 07:47:08 -0000
@@ -26,6 +26,7 @@
#include "system.h"
#include "error.h"
+#include "quote.h"
#include "safe-read.h"
#include "xstrtol.h"
@@ -1671,6 +1672,8 @@ main (int argc, char **argv)
{
int c;
int non_option_args;
+ int min_operands;
+ int max_operands;
struct Spec_list buf1, buf2;
struct Spec_list *s1 = &buf1;
struct Spec_list *s2 = &buf2;
@@ -1719,35 +1722,34 @@ main (int argc, char **argv)
non_option_args = argc - optind;
translating = (non_option_args == 2 && !delete);
+ min_operands = 1 + (delete == squeeze_repeats);
+ max_operands = 1 + (delete <= squeeze_repeats);
- /* Change this test if it is valid to give tr no options and
- no args at all. POSIX doesn't specifically say anything
- either way, but it looks like they implied it's invalid
- by omission. If you want to make tr do a slow imitation
- of `cat' use `tr a a'. */
- if (non_option_args > 2)
+ if (non_option_args < min_operands)
{
- error (0, 0, _("too many arguments"));
+ if (non_option_args == 0)
+ error (0, 0, _("missing operand"));
+ else
+ {
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
+ fprintf (stderr, "%s\n",
+ _(squeeze_repeats
+ ? ("Two strings must be given when "
+ "both deleting and squeezing repeats.")
+ : "Two strings must be given when translating."));
+ }
usage (EXIT_FAILURE);
}
- if (!delete && !squeeze_repeats && non_option_args != 2)
- error (EXIT_FAILURE, 0, _("two strings must be given when translating"));
-
- if (delete && squeeze_repeats && non_option_args != 2)
- error (EXIT_FAILURE, 0, _("two strings must be given when both \
-deleting and squeezing repeats"));
-
- /* If --delete is given without --squeeze-repeats, then
- only one string argument may be specified. */
- if ((delete && !squeeze_repeats) && non_option_args != 1)
- error (EXIT_FAILURE, 0,
- _("only one string may be given when deleting \
-without squeezing repeats"));
-
- if (squeeze_repeats && non_option_args == 0)
- error (EXIT_FAILURE, 0,
- _("at least one string must be given when squeezing repeats"));
+ if (max_operands < non_option_args)
+ {
+ error (0, 0, _("extra operand %s"), quote (argv[optind + max_operands]));
+ if (non_option_args == 2)
+ fprintf (stderr, "%s\n",
+ _("Only one string may be given when "
+ "deleting without squeezing repeats."));
+ usage (EXIT_FAILURE);
+ }
spec_init (s1);
if (!parse_str (argv[optind], s1))
Index: src/tsort.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tsort.c,v
retrieving revision 1.40
diff -p -u -r1.40 tsort.c
--- src/tsort.c 21 Mar 2004 18:45:54 -0000 1.40
+++ src/tsort.c 7 Jun 2004 20:47:59 -0000
@@ -31,6 +31,7 @@
#include "system.h"
#include "long-options.h"
#include "error.h"
+#include "quote.h"
#include "readtokens.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -573,7 +574,7 @@ main (int argc, char **argv)
if (1 < argc - optind)
{
- error (0, 0, _("only one argument may be specified"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
usage (EXIT_FAILURE);
}
Index: src/tty.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tty.c,v
retrieving revision 1.54
diff -p -u -r1.54 tty.c
--- src/tty.c 22 Jan 2004 21:09:33 -0000 1.54
+++ src/tty.c 7 Jun 2004 20:50:06 -0000
@@ -29,6 +29,7 @@
#include "system.h"
#include "error.h"
+#include "quote.h"
/* Exit statuses. */
enum
@@ -116,7 +117,7 @@ main (int argc, char **argv)
}
if (optind < argc)
- error (0, 0, _("ignoring all arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
tty = ttyname (0);
if (!silent)
Index: src/uname.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/uname.c,v
retrieving revision 1.58
diff -p -u -r1.58 uname.c
--- src/uname.c 8 Jun 2004 07:13:10 -0000 1.58
+++ src/uname.c 9 Jun 2004 07:52:49 -0000
@@ -46,6 +46,7 @@
#include "system.h"
#include "error.h"
+#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "uname"
@@ -212,7 +213,7 @@ main (int argc, char **argv)
if (argc != optind)
{
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
usage (EXIT_FAILURE);
}
Index: src/uniq.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/uniq.c,v
retrieving revision 1.110
diff -p -u -r1.110 uniq.c
--- src/uniq.c 21 Jan 2004 23:47:28 -0000 1.110
+++ src/uniq.c 7 Jun 2004 20:48:09 -0000
@@ -29,6 +29,7 @@
#include "error.h"
#include "hard-locale.h"
#include "posixver.h"
+#include "quote.h"
#include "xmemcoll.h"
#include "xstrtol.h"
#include "memcasecmp.h"
@@ -435,7 +436,7 @@ main (int argc, char **argv)
break;
if (nfiles == 2)
{
- error (0, 0, _("extra operand `%s'"), argv[optind]);
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
usage (EXIT_FAILURE);
}
file[nfiles++] = argv[optind++];
@@ -452,7 +453,7 @@ main (int argc, char **argv)
skip_chars = size;
else if (nfiles == 2)
{
- error (0, 0, _("extra operand `%s'"), optarg);
+ error (0, 0, _("extra operand %s"), quote (optarg));
usage (EXIT_FAILURE);
}
else
Index: src/unlink.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/unlink.c,v
retrieving revision 1.12
diff -p -u -r1.12 unlink.c
--- src/unlink.c 15 Jun 2004 18:04:13 -0000 1.12
+++ src/unlink.c 20 Jun 2004 07:25:03 -0000
@@ -84,13 +84,13 @@ main (int argc, char **argv)
if (argc < 2)
{
- error (0, 0, _("too few arguments"));
+ error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
if (2 < argc)
{
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[2]));
usage (EXIT_FAILURE);
}
Index: src/uptime.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/uptime.c,v
retrieving revision 1.40
diff -p -u -r1.40 uptime.c
--- src/uptime.c 5 Feb 2004 09:51:49 -0000 1.40
+++ src/uptime.c 7 Jun 2004 20:51:09 -0000
@@ -30,6 +30,7 @@
#include "error.h"
#include "long-options.h"
+#include "quote.h"
#include "readutmp.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -244,7 +245,7 @@ main (int argc, char **argv)
break;
default: /* lose */
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
usage (EXIT_FAILURE);
}
Index: src/users.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/users.c,v
retrieving revision 1.34
diff -p -u -r1.34 users.c
--- src/users.c 6 May 2004 14:49:32 -0000 1.34
+++ src/users.c 7 Jun 2004 20:50:53 -0000
@@ -26,6 +26,7 @@
#include "error.h"
#include "long-options.h"
+#include "quote.h"
#include "readutmp.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -168,7 +169,7 @@ main (int argc, char **argv)
break;
default: /* lose */
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
usage (EXIT_FAILURE);
}
Index: src/who.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/who.c,v
retrieving revision 1.94
diff -p -u -r1.94 who.c
--- src/who.c 13 Jun 2004 22:03:07 -0000 1.94
+++ src/who.c 20 Jun 2004 05:21:44 -0000
@@ -33,6 +33,7 @@
#include "readutmp.h"
#include "error.h"
+#include "quote.h"
#include "vasprintf.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -802,7 +803,7 @@ main (int argc, char **argv)
break;
default: /* lose */
- error (0, 0, _("too many arguments"));
+ error (0, 0, _("extra operand %s"), quote (argv[optind + 2]));
usage (EXIT_FAILURE);
}
Index: src/whoami.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/whoami.c,v
retrieving revision 1.41
diff -p -u -r1.41 whoami.c
--- src/whoami.c 21 Jan 2004 23:50:31 -0000 1.41
+++ src/whoami.c 7 Jun 2004 20:50:13 -0000
@@ -27,7 +27,9 @@
#include <getopt.h>
#include "system.h"
+#include "error.h"
#include "long-options.h"
+#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "whoami"
@@ -94,7 +96,10 @@ main (int argc, char **argv)
}
if (optind != argc)
- usage (EXIT_FAILURE);
+ {
+ error (0, 0, _("extra operand %s"), quote (argv[optind]));
+ usage (EXIT_FAILURE);
+ }
uid = geteuid ();
pw = getpwuid (uid);
Index: tests/basename/basic
===================================================================
RCS file: /home/meyering/coreutils/cu/tests/basename/basic,v
retrieving revision 1.4
diff -p -u -r1.4 basic
--- tests/basename/basic 8 Apr 2003 10:55:01 -0000 1.4
+++ tests/basename/basic 20 Jun 2004 07:30:57 -0000
@@ -24,9 +24,9 @@ my $prog = $ENV{PROG} || die "$0: \$PROG
my @Tests =
(
- ['fail-1', {ERR => "$prog: too few arguments\n"
+ ['fail-1', {ERR => "$prog: missing operand\n"
. "Try `$prog --help' for more information.\n"}, {EXIT => '1'}],
- ['fail-2', qw(a a a), {ERR => "$prog: too many arguments\n"
+ ['fail-2', qw(a b c), {ERR => "$prog: extra operand `c'\n"
. "Try `$prog --help' for more information.\n"}, {EXIT => '1'}],
['a', qw(d/f), {OUT => 'f'}],
Index: tests/du/files0-from
===================================================================
RCS file: /home/meyering/coreutils/cu/tests/du/files0-from,v
retrieving revision 1.6
diff -p -u -r1.6 files0-from
--- tests/du/files0-from 29 Mar 2004 09:37:23 -0000 1.6
+++ tests/du/files0-from 20 Jun 2004 08:03:44 -0000
@@ -27,8 +27,9 @@ my @Tests =
(
# invalid extra command line argument
['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1},
- {ERR => "du: no-such: you may not specify command-line arguments "
- . "with --files0-from\n"}
+ {ERR => "du: extra operand `no-such'\n"
+ . "File operands cannot be combined with --files0-from.\n"
+ . "Try `du --help' for more information.\n"}
],
# missing input file
Index: tests/expr/basic
===================================================================
RCS file: /home/meyering/coreutils/cu/tests/expr/basic,v
retrieving revision 1.9
diff -p -u -r1.9 basic
--- tests/expr/basic 22 Feb 2004 14:57:20 -0000 1.9
+++ tests/expr/basic 20 Jun 2004 07:31:34 -0000
@@ -59,7 +59,7 @@ my @Tests =
['fail-b', '9 9', {ERR => "$prog: syntax error\n"},
{EXIT => 2}],
- ['fail-c', {ERR => "$prog: too few arguments\n"
+ ['fail-c', {ERR => "$prog: missing operand\n"
. "Try `$prog --help' for more information.\n"},
{EXIT => 2}],
);
Index: tests/mv/diag
===================================================================
RCS file: /home/meyering/coreutils/cu/tests/mv/diag,v
retrieving revision 1.5
diff -p -u -r1.5 diag
--- tests/mv/diag 28 Oct 2000 13:49:43 -0000 1.5
+++ tests/mv/diag 20 Jun 2004 07:32:32 -0000
@@ -39,9 +39,9 @@ mv f1 f2 f1 >> out 2>&1 && fail=1
mv --target=f2 f1 >> out 2>&1 && fail=1
cat > exp <<\EOF
-mv: missing file argument
+mv: missing file operand
Try `mv --help' for more information.
-mv: missing file argument
+mv: missing file operand after `no-file'
Try `mv --help' for more information.
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
Index: tests/tsort/basic-1
===================================================================
RCS file: /home/meyering/coreutils/cu/tests/tsort/basic-1,v
retrieving revision 1.7
diff -p -u -r1.7 basic-1
--- tests/tsort/basic-1 24 Apr 2003 13:36:03 -0000 1.7
+++ tests/tsort/basic-1 6 Jun 2004 06:36:17 -0000
@@ -51,7 +51,7 @@ my @Tests =
['only-one', {IN => {f => ""}}, {IN => {g => ""}},
{EXIT => 1},
- {ERR => "tsort: only one argument may be specified\n"
+ {ERR => "tsort: extra operand `g'\n"
. "Try `tsort --help' for more information.\n"}],
);