option handling: make exceptions more consistent
authorEric Blake <ebb9@byu.net>
Thu, 8 Jan 2009 13:33:16 +0000 (06:33 -0700)
committerEric Blake <ebb9@byu.net>
Thu, 8 Jan 2009 14:57:36 +0000 (07:57 -0700)
* doc/coreutils.texi (Common options): Not all utilities reject
option abbreviations.
* src/chroot.c (main): Report correct name on failure.
* src/echo.c (usage): Clarify long option usage.
* src/setuidgid.c (usage): Likewise.
* src/hostid.c (usage): Condense.

doc/coreutils.texi
src/chroot.c
src/echo.c
src/hostid.c
src/setuidgid.c

index 51145de197b6c2b0535003ec9fc322eba3b99216..1cc237c3a89ae366e7df0797a7fe55f23ba5ecf5 100644 (file)
@@ -681,7 +681,7 @@ abbreviations of those options.  For example, @samp{rmdir
 
 Some of these programs recognize the @option{--help} and @option{--version}
 options only when one of them is the sole command line argument.  For
-these programs, abbreviations of the long options are not recognized.
+these programs, abbreviations of the long options are not always recognized.
 
 @table @samp
 
index 1eb443c2461c0d6d299feeed7b7384bd1b150346..6d3fddf77232576a22b8fa66fda738207a002203 100644 (file)
@@ -1,5 +1,5 @@
 /* chroot -- run command or shell with special root directory
-   Copyright (C) 95, 96, 1997, 1999-2004, 2007-2008
+   Copyright (C) 95, 96, 1997, 1999-2004, 2007-2009
    Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -83,7 +83,8 @@ main (int argc, char **argv)
     }
 
   if (chroot (argv[optind]) != 0)
-    error (EXIT_FAILURE, errno, _("cannot change root directory to %s"), argv[1]);
+    error (EXIT_FAILURE, errno, _("cannot change root directory to %s"),
+          argv[optind]);
 
   if (chdir ("/"))
     error (EXIT_FAILURE, errno, _("cannot chdir to root directory"));
index d549cda2be22e6bfaddc2315f8c2f443b8e2aabb..c4b7ca939dfb4315f3c0acdd0a607c7f833203ed 100644 (file)
@@ -1,5 +1,5 @@
 /* echo.c, derived from code echo.c in Bash.
-   Copyright (C) 87,89, 1991-1997, 1999-2005, 2007-2008 Free Software
+   Copyright (C) 87,89, 1991-1997, 1999-2005, 2007-2009 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -41,7 +41,10 @@ usage (int status)
             program_name);
   else
     {
-      printf (_("Usage: %s [OPTION]... [STRING]...\n"), program_name);
+      printf (_("\
+Usage: %s [SHORT-OPTION]... [STRING]...\n\
+  or:  %s LONG-OPTION\n\
+"), program_name, program_name);
       fputs (_("\
 Echo the STRING(s) to standard output.\n\
 \n\
index f3cabc47b4d44a9daf2e9e3729285fc0600ed892..1da5a0c5cedb45c990d85c81a1b286f578a7beb2 100644 (file)
@@ -1,6 +1,6 @@
 /* print the hexadecimal identifier for the current host
 
-   Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2007-2008 Free
+   Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2007-2009 Free
    Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -42,12 +42,10 @@ usage (int status)
   else
     {
       printf (_("\
-Usage: %s\n\
-  or:  %s OPTION\n\
+Usage: %s [OPTION]\n\
 Print the numeric identifier (in hexadecimal) for the current host.\n\
 \n\
-"),
-             program_name, program_name);
+"), program_name);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
       emit_bug_reporting_address ();
index 057002cbfec28a39944d60c4a396a183b601e958..beff04acb3be5477c7711df53690ad588dd0b8b0 100644 (file)
@@ -1,5 +1,5 @@
 /* setuidgid - run a command with the UID and GID of a specified user
-   Copyright (C) 2003-2008 Free Software Foundation, Inc.
+   Copyright (C) 2003-2009 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
@@ -48,8 +48,8 @@ usage (int status)
   else
     {
       printf (_("\
-Usage: %s OPTION USER COMMAND [ARGUMENT]...\n\
-  or:  %s OPTION\n\
+Usage: %s [SHORT-OPTION]... USER COMMAND [ARGUMENT]...\n\
+  or:  %s LONG-OPTION\n\
 "),
               program_name, program_name);