[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 'printf' is not SuSv3 compliant (and maybe not POSIX...?)
From: |
Jim Meyering |
Subject: |
Re: 'printf' is not SuSv3 compliant (and maybe not POSIX...?) |
Date: |
Fri, 13 Sep 2002 11:37:59 +0200 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (i686-pc-linux-gnu) |
address@hidden (Bob Proulx) wrote:
> DervishD <address@hidden> [2002-08-19 20:37:55 +0200]:
>> The 'printf' command (no matter the POSIXLY_CORRECT var), chokes
>> on the following:
>>
>> > printf -- "Hi there\n"
>> --printf: warning: excess arguments have been ignored
>>
>> The correct behaviour, according to Single UNIX Specification
>> version 3 (don't know the POSIX behaviour), is that 'printf' shall
>> recognize '--' as a first argument to be discarded. That is, if I
>> want to print '--help', I shouldn't need to set POSIXLY_CORRECT, but
>> just do 'printf -- --help'.
>
> Thanks for the report. I logged this as a bug against GNU coreutils
> and it is now in the database.
Thank you for the report! And thanks for filing it, Bob!
I've just fixed the bug.
Here's the patch (against coreutils-4.5.1):
Index: printf.c
===================================================================
RCS file: /fetish/cu/src/printf.c,v
retrieving revision 1.69
diff -u -p -u -p -r1.69 printf.c
--- printf.c 31 Aug 2002 08:52:11 -0000 1.69
+++ printf.c 13 Sep 2002 09:37:06 -0000
@@ -545,6 +545,14 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
AUTHORS, usage);
+ /* The above handles --help and --version.
+ Since there is no other invocation of getopt, handle `--' here. */
+ if (1 < argc && STREQ (argv[1], "--"))
+ {
+ --argc;
+ ++argv;
+ }
+
if (argc == 1)
{
fprintf (stderr, _("Usage: %s format [argument...]\n"), program_name);