(main): Use a better diagnostic when someone uses a
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 31 Jan 2006 01:38:30 +0000 (01:38 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 31 Jan 2006 01:38:30 +0000 (01:38 +0000)
trailing numeric option in an invalid way.

src/head.c

index 9510025..4038722 100644 (file)
@@ -1,5 +1,5 @@
 /* head -- output first part of file(s)
-   Copyright (C) 89, 90, 91, 1995-2005 Free Software Foundation, Inc.
+   Copyright (C) 89, 90, 91, 1995-2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -973,7 +973,7 @@ main (int argc, char **argv)
              break;
 
            default:
-             error (0, 0, _("unrecognized option `-%c'"), *a);
+             error (0, 0, _("invalid trailing option -- %c"), *a);
              usage (EXIT_FAILURE);
            }
        }
@@ -992,7 +992,8 @@ main (int argc, char **argv)
       argc--;
     }
 
-  while ((c = getopt_long (argc, argv, "c:n:qv", long_options, NULL)) != -1)
+  while ((c = getopt_long (argc, argv, "c:n:qv0123456789", long_options, NULL))
+        != -1)
     {
       switch (c)
        {
@@ -1029,6 +1030,8 @@ main (int argc, char **argv)
        case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
 
        default:
+         if (ISDIGIT (c))
+           error (0, 0, _("invalid trailing option -- %c"), c);
          usage (EXIT_FAILURE);
        }
     }