This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: getopt() argument permuting considered risky
- From: Paul Eggert <eggert at CS dot UCLA dot EDU>
- To: "Michael T Kerrisk" <mtk-lists at gmx dot net>
- Cc: libc-alpha at sources dot redhat dot com, geoff at gclare dot org dot uk
- Date: Wed, 04 Aug 2004 13:47:32 -0700
- Subject: Re: getopt() argument permuting considered risky
- References: <87llgured9.fsf@penguin.cs.ucla.edu><24758.1091647870@www15.gmx.net>
"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.