bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

proposed improvement of diagnostics for missing/extra operands


From: Paul Eggert
Subject: proposed improvement of diagnostics for missing/extra operands
Date: Wed, 09 Jun 2004 11:55:38 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

A few years ago somebody (I forgot who) suggested that "diff" output
messages like this when given too few or too many args:

   $ diff a
   diff: missing operand after `a'
   diff: Try `diff --help' for more information.
   $ diff a b c
   diff: extra operand `c'
   diff: Try `diff --help' for more information.

For new users, this gives more information than just saying "too few
operands" or "too many operands".  I installed this behavior into
diffutils 2.7.2 and it has seemed to work pretty well in practice, and
I'd like to propose similar behavior for coreutils.

In a few cases this will cause new diagnostics to lack some
information that is present in the old, e.g.:

   old output of "tr -d a b":

      tr: only one string may be given when deleting without squeezing repeats

   new output of "tr -d a b":

      tr: extra operand `b'
      Try `tr --help' for more information.

but I think the new behavior is better anyway, as its uniformity will
cause people to recognize the symptoms from similar failures in other
commands.

Here is a proposed patch.

2004-06-09  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/kill.c (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/nice.c (main): Likewise.
        * src/nohup.c (main): Likewise.
        * src/od.c (main): Likewise.
        * src/pathchk.c (main): Likewise.
        * src/pinky.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      7 Jun 2004 20:48:17 -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 after %s"), quote (argv[argc - 1]));
+      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 9 Jun 2004 07:52:22 -0000
@@ -271,7 +271,7 @@ main (int argc, char **argv)
 
   if (argc - optind + (reference_file ? 1 : 0) <= 1)
     {
-      error (0, 0, _("too few arguments"));
+      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.101
diff -p -u -r1.101 chmod.c
--- src/chmod.c 27 Mar 2004 08:43:36 -0000      1.101
+++ src/chmod.c 7 Jun 2004 20:44:48 -0000
@@ -391,7 +391,7 @@ main (int argc, char **argv)
 
   if (optind >= argc)
     {
-      error (0, 0, _("too few arguments"));
+      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 9 Jun 2004 07:52:22 -0000
@@ -287,7 +287,7 @@ main (int argc, char **argv)
 
   if (argc - optind + (reference_file ? 1 : 0) <= 1)
     {
-      error (0, 0, _("too few arguments"));
+      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.41
diff -p -u -r1.41 chroot.c
--- src/chroot.c        21 Jan 2004 22:47:09 -0000      1.41
+++ src/chroot.c        7 Jun 2004 20:44:48 -0000
@@ -77,7 +77,7 @@ main (int argc, char **argv)
                      usage, AUTHORS, (char const *) NULL);
   if (argc <= 1)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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  7 Jun 2004 20:46:24 -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,15 @@ main (int argc, char **argv)
        usage (EXIT_FAILURE);
       }
 
-  if (optind + 2 != argc)
+  if (argc - optind < 2)
     {
-      error (0, 0, _("too few arguments"));
+      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    7 Jun 2004 20:44:48 -0000
@@ -478,14 +478,9 @@ 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"));
+      error (0, 0, _("missing operand after %s"), quote (file[n_files - 1]));
       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        7 Jun 2004 20:46:41 -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,7 @@ main (int argc, char **argv)
 
   if (argc - optind < 2)
     {
-      error (0, 0, _("too few arguments"));
+      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     7 Jun 2004 20:42:25 -0000
@@ -462,17 +462,9 @@ 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]));
       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       7 Jun 2004 20:48:27 -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 after %s"), quote (argv[argc - 1]));
+      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    7 Jun 2004 20:42:28 -0000
@@ -735,9 +735,10 @@ 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]));
+         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  7 Jun 2004 20:48:48 -0000
@@ -37,6 +37,7 @@
 #include "long-options.h"
 #include "error.h"
 #include "inttostr.h"
+#include "quote.h"
 #include "quotearg.h"
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -196,7 +197,7 @@ main (int argc, char **argv)
 
   if (argc <= 1)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       usage (EXPR_INVALID);
     }
 
Index: src/hostid.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/hostid.c,v
retrieving revision 1.25
diff -p -u -r1.25 hostid.c
--- src/hostid.c        21 Jan 2004 23:08:09 -0000      1.25
+++ src/hostid.c        7 Jun 2004 20:50:29 -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"
@@ -75,7 +76,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.50
diff -p -u -r1.50 hostname.c
--- src/hostname.c      29 Mar 2004 07:30:09 -0000      1.50
+++ src/hostname.c      7 Jun 2004 20:48:55 -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"
@@ -123,7 +124,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       7 Jun 2004 20:44:48 -0000
@@ -283,7 +283,7 @@ main (int argc, char **argv)
 
   if (argc <= optind || (n_files == 1 && !dir_arg))
     {
-      error (0, 0, _("too few arguments"));
+      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  7 Jun 2004 20:44:48 -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,7 @@ main (int argc, char **argv)
 
   if (nfiles != 2)
     {
-      error (0, 0, _("too few non-option arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       usage (EXIT_FAILURE);
     }
 
Index: src/kill.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/kill.c,v
retrieving revision 1.14
diff -p -u -r1.14 kill.c
--- src/kill.c  21 Jan 2004 23:15:07 -0000      1.14
+++ src/kill.c  7 Jun 2004 20:49:14 -0000
@@ -35,6 +35,7 @@
 
 #include "system.h"
 #include "error.h"
+#include "quote.h"
 #include "sig2str.h"
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -366,7 +367,7 @@ main (int argc, char **argv)
 
   if ( ! list && argc <= optind)
     {
-      error (0, 0, _("no process ID specified"));
+      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  7 Jun 2004 20:44:48 -0000
@@ -85,13 +85,13 @@ main (int argc, char **argv)
 
   if (argc < 3)
     {
-      error (0, 0, _("too few arguments"));
+      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    7 Jun 2004 20:44:48 -0000
@@ -493,7 +493,7 @@ main (int argc, char **argv)
 
   if (argc <= optind)
     {
-      error (0, 0, _("missing file argument"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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        7 Jun 2004 20:46:55 -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,7 @@ 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]));
          usage (EXIT_FAILURE);
        }
       for (i = 0; i < n_strings; ++i)
@@ -665,8 +666,7 @@ 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]));
          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 7 Jun 2004 20:44:48 -0000
@@ -122,7 +122,7 @@ main (int argc, char **argv)
 
   if (optind == argc)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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        7 Jun 2004 20:44:48 -0000
@@ -111,7 +111,7 @@ main (int argc, char **argv)
 
   if (optind == argc)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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 7 Jun 2004 23:31:40 -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,18 @@ 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)
+    {
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
+      usage (EXIT_FAILURE);
+    }
+
+  if (expected_operands < argc - optind)
     {
-      const char *msg;
-      if (argc - optind < 2)
-       msg = _("too few arguments");
-      else if (argc - optind > 4)
-       msg = _("too many arguments");
-      else
-       msg = _("wrong number of arguments");
-      error (0, 0, "%s", msg);
+      error (0, 0, _("extra operand %s"),
+            quote (argv[optind + expected_operands]));
       usage (EXIT_FAILURE);
     }
 
@@ -167,14 +170,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 +201,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    7 Jun 2004 20:44:48 -0000
@@ -457,7 +457,7 @@ main (int argc, char **argv)
 
   if (n_files == 0 || (n_files == 1 && !target_directory_specified))
     {
-      error (0, 0, _("missing file argument"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       usage (EXIT_FAILURE);
     }
 
Index: src/nice.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/nice.c,v
retrieving revision 1.75
diff -p -u -r1.75 nice.c
--- src/nice.c  21 Jan 2004 23:28:19 -0000      1.75
+++ src/nice.c  7 Jun 2004 20:50:38 -0000
@@ -36,6 +36,7 @@
 #include "error.h"
 #include "long-options.h"
 #include "posixver.h"
+#include "quote.h"
 #include "xstrtol.h"
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -172,7 +173,7 @@ main (int argc, char **argv)
     {
       if (adjustment_given)
        {
-         error (0, 0, _("a command must be given with an adjustment"));
+         error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
          usage (EXIT_FAIL);
        }
       /* No command given; print the priority. */
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 7 Jun 2004 20:44:48 -0000
@@ -97,7 +97,7 @@ main (int argc, char **argv)
 
   if (argc <= 1)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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    7 Jun 2004 20:47:07 -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,7 @@ 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]));
          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       7 Jun 2004 20:49:38 -0000
@@ -46,6 +46,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 "pathchk"
@@ -186,7 +187,7 @@ main (int argc, char **argv)
 
   if (optind == argc)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       usage (EXIT_FAILURE);
     }
 
Index: src/pinky.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/pinky.c,v
retrieving revision 1.38
diff -p -u -r1.38 pinky.c
--- src/pinky.c 21 Jan 2004 23:38:21 -0000      1.38
+++ src/pinky.c 7 Jun 2004 20:50:46 -0000
@@ -26,6 +26,7 @@
 #include "system.h"
 
 #include "error.h"
+#include "quote.h"
 #include "readutmp.h"
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -571,8 +572,7 @@ main (int argc, char **argv)
 
   if (do_short_format == 0 && n_users == 0)
     {
-      error (0, 0, _("no username specified; at least one must be\
- specified when using -l"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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      7 Jun 2004 20:44:48 -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 after %s"), quote (argv[argc - 1]));
       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    7 Jun 2004 20:44:48 -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 after %s"), quote (argv[argc - 1]));
          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 7 Jun 2004 20:44:48 -0000
@@ -205,7 +205,7 @@ main (int argc, char **argv)
 
   if (optind == argc)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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   7 Jun 2004 20:49:46 -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 after %s"), quote (argv[argc - 1]));
       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     7 Jun 2004 20:44:48 -0000
@@ -96,7 +96,7 @@ main (int argc, char **argv)
 
   if (argc <= 2)
     {
-      error (0, 0, _("too few arguments"));
+      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 9 Jun 2004 07:52:23 -0000
@@ -1685,7 +1685,7 @@ main (int argc, char **argv)
 
   if (n_files == 0)
     {
-      error (0, 0, _("missing file argument"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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 7 Jun 2004 20:49:58 -0000
@@ -25,6 +25,7 @@
 #include "c-strtod.h"
 #include "error.h"
 #include "long-options.h"
+#include "quote.h"
 #include "xnanosleep.h"
 #include "xstrtod.h"
 
@@ -137,7 +138,7 @@ main (int argc, char **argv)
 
   if (argc == 1)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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  7 Jun 2004 20:47:33 -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,10 @@ 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"), 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  7 Jun 2004 20:44:48 -0000
@@ -821,7 +821,7 @@ main (int argc, char *argv[])
 
   if (argc == optind)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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  7 Jun 2004 20:45:53 -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 operand 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 operand %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.120
diff -p -u -r1.120 touch.c
--- src/touch.c 17 Mar 2004 10:06:57 -0000      1.120
+++ src/touch.c 7 Jun 2004 20:44:48 -0000
@@ -408,7 +408,7 @@ main (int argc, char **argv)
 
   if (optind == argc)
     {
-      error (0, 0, _("file arguments missing"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       usage (EXIT_FAILURE);
     }
 
Index: src/tr.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tr.c,v
retrieving revision 1.134
diff -p -u -r1.134 tr.c
--- src/tr.c    6 Jun 2004 19:18:49 -0000       1.134
+++ src/tr.c    7 Jun 2004 20:47:50 -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,20 @@ 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"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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]));
+      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.11
diff -p -u -r1.11 unlink.c
--- src/unlink.c        21 Jan 2004 23:47:48 -0000      1.11
+++ src/unlink.c        7 Jun 2004 20:44:48 -0000
@@ -86,13 +86,13 @@ main (int argc, char **argv)
 
   if (argc < 2)
     {
-      error (0, 0, _("too few arguments"));
+      error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
       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.92
diff -p -u -r1.92 who.c
--- src/who.c   18 Apr 2004 15:02:49 -0000      1.92
+++ src/who.c   7 Jun 2004 20:51:01 -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).  */
@@ -803,7 +804,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        6 Jun 2004 07:27:17 -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 after `$prog'\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        6 Jun 2004 06:28:09 -0000
@@ -27,8 +27,8 @@ 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"
+         . "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    6 Jun 2004 07:28:18 -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 after `$prog'\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       6 Jun 2004 06:34:26 -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 operand after `--target=d'
 Try `mv --help' for more information.
-mv: missing file argument
+mv: missing 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"}],
   );
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]