This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: getopt() argument permuting considered risky


prj@po.cwru.edu (Paul Jarc) writes:

> Måns Rullgård <mru@kth.se> wrote:
>> Simon Josefsson <jas@extundo.com> writes:
>>> On the ranting side, I think it would have been better if this feature
>>> had originally been introduced via a separate API, say getopt_gnu,
>>> instead.  That would have minimized surprises, both pleasant and
>>> unpleasant ones.
>>
>> Then programs using that function would not compile on non-glibc
>> systems.
>
> That's a good thing: the program expects a certain behavior; the
> behavior is unavailable on that platform; the problem is detected at
> compile time.

No, it's the user who expects that behavior.  Users on systems with
non-GNU getopt() expect the traditional behavior.  The program will
work as the user expects on either system.  If the command line is
written properly, the program will still have full functionality, and
furthermore has no means of determining whether getopt() permuted the
arguments or if they were originally given in that order.  Of course a
program could examine its arguments before calling getopt(), but I
suspect that such behavior is quite unusual.

-- 
Måns Rullgård
mru@kth.se


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]