From a99c35b04d9ab601e4fa98319c56fbdbde6b420a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 8 Jan 2009 06:33:16 -0700 Subject: option handling: make exceptions more consistent * 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 | 2 +- src/chroot.c | 5 +++-- src/echo.c | 7 +++++-- src/hostid.c | 8 +++----- src/setuidgid.c | 6 +++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 51145de19..1cc237c3a 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -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 diff --git a/src/chroot.c b/src/chroot.c index 1eb443c24..6d3fddf77 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -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")); diff --git a/src/echo.c b/src/echo.c index d549cda2b..c4b7ca939 100644 --- a/src/echo.c +++ b/src/echo.c @@ -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\ diff --git a/src/hostid.c b/src/hostid.c index f3cabc47b..1da5a0c5c 100644 --- a/src/hostid.c +++ b/src/hostid.c @@ -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 (); diff --git a/src/setuidgid.c b/src/setuidgid.c index 057002cbf..beff04acb 100644 --- a/src/setuidgid.c +++ b/src/setuidgid.c @@ -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); -- cgit v1.2.3-70-g09d2