public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/11043] New: botched messages printed by getopt with W;
@ 2009-12-02 18:08 ebb9 at byu dot net
  2010-04-05  5:50 ` [Bug libc/11043] " drepper at redhat dot com
  2010-04-08  0:18 ` drepper at redhat dot com
  0 siblings, 2 replies; 4+ messages in thread
From: ebb9 at byu dot net @ 2009-12-02 18:08 UTC (permalink / raw)
  To: glibc-bugs

When using getopt_long with "W;", the error messages are inconsistent, and in
some cases, downright wrong.

$cat foo.c
#include <unistd.h>
#include <stdio.h>
#include <getopt.h>

static const struct option opts[] =
  {
    { "alpha",    no_argument,       NULL, 'a' },
    { "beta",     required_argument, NULL, 'b' },
    { "c1",       no_argument,       NULL, 'c' },
    { "c2",       no_argument,       NULL, 'c' },
    { NULL,       0,                 NULL, 0 }
  };

int
main (int argc, char **argv)
{
  int c = getopt_long (argc, argv, "W;", opts, NULL);
  if (c == -1)
    puts ("got -1");
  else
    printf ("got %c\n", c);
  return 0;
}
$ ./foo --al=
./foo: option `--al=' doesn't allow an argument
got ?
$ ./foo -W al=
./foo: option `-W alpha' doesn't allow an argument
got ?
$ ./foo -Wal=
./foo: option `-W alpha' doesn't allow an argument
got ?
$ ./foo --be
./foo: option `--be' requires an argument
got ?
$ ./foo -W be
./foo: option `be' requires an argument
got ?
$ ./foo -Wbe
./foo: option `-Wbe' requires an argument
got ?
$ ./foo2 -W c a
./foo2: option `-W a' is ambiguous
got ?
$ ./foo2 -W c
./foo2: option `-W (null)' is ambiguous
got ?
$ ./foo2 -Wc a
./foo2: option `-W a' is ambiguous
got ?

Notice how with -W, an extra argument prints the full text of the struct option
rather than what the user typed and prints a space after the -W whether or not
the user had a space; a missing argument prints just the argv slot containing
what the user typed but without the -W; and an ambiguous argument prints the
wrong argv slot altogether (although whether this particular example should have
been ambiguous in the first place is already the subject of 11041).

-- 
           Summary: botched messages printed by getopt with W;
           Product: glibc
           Version: 2.11
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: ebb9 at byu dot net
                CC: glibc-bugs at sources dot redhat dot com
 BugsThisDependsOn: 11041


http://sourceware.org/bugzilla/show_bug.cgi?id=11043

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/11043] botched messages printed by getopt with W;
  2009-12-02 18:08 [Bug libc/11043] New: botched messages printed by getopt with W; ebb9 at byu dot net
@ 2010-04-05  5:50 ` drepper at redhat dot com
  2010-04-08  0:18 ` drepper at redhat dot com
  1 sibling, 0 replies; 4+ messages in thread
From: drepper at redhat dot com @ 2010-04-05  5:50 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2010-04-05 05:50 -------
Should be fixed in git.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=11043

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/11043] botched messages printed by getopt with W;
  2009-12-02 18:08 [Bug libc/11043] New: botched messages printed by getopt with W; ebb9 at byu dot net
  2010-04-05  5:50 ` [Bug libc/11043] " drepper at redhat dot com
@ 2010-04-08  0:18 ` drepper at redhat dot com
  1 sibling, 0 replies; 4+ messages in thread
From: drepper at redhat dot com @ 2010-04-08  0:18 UTC (permalink / raw)
  To: glibc-bugs



-- 
Bug 11043 depends on bug 11041, which changed state.

Bug 11041 Summary: getopt -W doesn't work with optional arguments
http://sourceware.org/bugzilla/show_bug.cgi?id=11041

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

http://sourceware.org/bugzilla/show_bug.cgi?id=11043

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/11043] botched messages printed by getopt with W;
       [not found] <bug-11043-131@http.sourceware.org/bugzilla/>
@ 2014-06-30 20:35 ` fweimer at redhat dot com
  0 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2014-06-30 20:35 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=11043

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-30 20:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-02 18:08 [Bug libc/11043] New: botched messages printed by getopt with W; ebb9 at byu dot net
2010-04-05  5:50 ` [Bug libc/11043] " drepper at redhat dot com
2010-04-08  0:18 ` drepper at redhat dot com
     [not found] <bug-11043-131@http.sourceware.org/bugzilla/>
2014-06-30 20:35 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).