[illumos-Developer] webrev: printf
Garrett D'Amore
garrett at nexenta.com
Thu Oct 14 09:32:04 PDT 2010
On Thu, 2010-10-14 at 18:07 +0200, Nicholas George wrote:
> On 14 October 2010 17:41, Garrett D'Amore <garrett at nexenta.com> wrote:
> > So I did find one statement, which caused to add a few lines of code:
> >
> > Standard utilities that do not accept options,
> > * but that do accept operands, shall recognize "--" as a
> > * first argument to be discarded.
> >
> >
> > So I added this to the program:
> >
> > /*
> > * POSIX says: Standard utilities that do not accept options,
> > * but that do accept operands, shall recognize "--" as a
> > * first argument to be discarded.
> > */
> > if (strcmp(argv[0], "--") == 0) {
> > argc--;
> > argv++;
> > }
> >
> > (Argv[0] here is after we've skipped past argv[0] for the program name
> > itself.)
> >
> > Apart from that particular test, I can't imagine what kind of tests
> > you'd have for - arguments.
> >
> > My testing shows that legacy printf also behaves the same way... it will
> > discard -- but not -<letter>.
>
> Yes, but this is a BUG and not allowed for a POSIX conforming utility.
> You're merely repeating the argumentation we had in the bash list
> [http://www.mail-archive.com/bug-bash@gnu.org/msg03483.html] which was
> the prelude to the Austin discussion and interpretation request. But
> it does not make Solaris10 /bin/printf nor your printf conform to the
> standard.
> You have to choose - standard conformance or a buggy legacy
> implementation which breaks conforming scripts.
Explain to me how this behavior breaks conforming scripts? If a script
doesn't rely on the "broken behavior", it should be fine, right? A
conforming script that wants to output "-a" will do printf -- -a this
will work with both ksh93 and my implementation. And legacy closed
printf.
- Garrett
>
> Nicholas
More information about the Developer
mailing list