On Fri, 8 Feb 2008 08:42:28 -0600 Shawn Walker wrote:
> > Change
> >         printf "----------------------\n\n"
> > to
> >         printf -- "----------------------\n\n"

> In this case, it isn't a script I wrote.

> It's part of a shell script that is used during a driver install for a
> Marvell Yukon Gigabit Ehternet Adapter.

> Sadly, Solaris' version of bourne shell? /sbin/sh allows the "bad
> syntax" I mentioned above.

> I wonder if some sort of compatibility mode can be achieved for
> bourne's printf syntax.

its not Bourne's syntax, its a general guideline for all posix utilities:
any utility implementation, unless explicitly specified otherwise
(see test(1)), may accept options (even if the posix OPTIONS description
is "None")

every portable application must take care to insert "--" just before
the first operand of any utility invocation that may start with the
'-' character

so even though the script has worked, it will eventually fail on
some conforming posix implementation

-- Glenn Fowler -- AT&T Research, Florham Park NJ --

--

posix section 1.11 Utility Description Defaults

  OPTIONS:

    Default Behavior: When this section is listed as "None.", it means
    that the implementation need not support any options. Standard
    utilities that do not accept options, but that do accept operands,
    shall recognize "--" as a first argument to be discarded.

    The requirement for recognizing "--" is because conforming
    applications need a way to shield their operands from any
    arbitrary options that the implementation may provide as an
    extension.


Reply via email to