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


"Michael T Kerrisk" <mtk-lists@gmx.net> writes:

> we can construct other examples

Sure, but you'd have a more convincing argument if you had real-world
examples rather than artificial ones.


> My point is that glibc's getopt() behaviour introduces a 
> behaviour not present on other Unix systems.

No, similar behavior is present on other Unix systems, in some cases.
Here's Solaris 9, for example:

   $ export PATH=/usr/xpg4/bin:/usr/bin
   $ ls
   $ echo foo >foo
   $ sort foo -o bar
   $ ls
   bar  foo

This behavior does not conform to POSIX 1003.1-2001 (which says that
"sort" must try to read a file named "-o"), but it's quite common on
older platforms and was even required by some earlier standards.


>> As a practical matter, portable scripts cannot assume the
>> POSIX-specified behavior here.  
>
> You mean because of the glibc behaviour?

Yes, that's mainly it.  Though I wouldn't be surprised if some other
implementations worked similarly.


> I don't have any broken scripts.

Cool.  Then let's not worry about this now.


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