This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/4116] New: getopt_long does *not* return (or indicate in any way) error condition (if occured) to programmer.
- From: "edvotsyivj at datatech dot ru" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 1 Mar 2007 11:58:05 -0000
- Subject: [Bug libc/4116] New: getopt_long does *not* return (or indicate in any way) error condition (if occured) to programmer.
- Reply-to: sourceware-bugzilla at sourceware dot org
There are a lot of situations, where errors in options (and its arguments) can
not be reported to user by "getopt" internal routine:
fprintf (stderr, _("%s: option `%s' ...
That's why variable "opterr" and optstring prefix ":" do exist: for disabling
"getopt" internal error reporting. The most apparent examples of such situations
are:
-- we need to localize error messages for application which does not use
gettext, because it's mono-language (but not English).
-- in GUI application stderr is not visible to user (or even closed), and we
need to display errors in dialog window.
The plain short-option "getopt" provides programmer with sufficient information
to catch and handle errors: ":"/"?" as return code and "optopt" as subject of error.
But "getopt_long" provides NONE information to programmer. There are at least 4
(four) indistinguishable error conditions:
1) option is ambiguous
2) unrecognized/invalid option
3) option doesn't allow an argument
4) option requires an argument
In either of above "getopt_long" just return "?", leaving the programmer to
guess what's happened. Moreover, in cases (1) and (2) programmer doesn't even
know, which option has triggered the error.
So, "getopt_long" must be fixed to indicate
A) different error conditions
B) the option (text) caused the error
--
Summary: getopt_long does *not* return (or indicate in any way)
error condition (if occured) to programmer.
Product: glibc
Version: 2.4
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: edvotsyivj at datatech dot ru
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=4116
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.