Re: strange `printf` arguments, parsing features (bugs?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 18, 2008 at 06:40:26PM +0200, Oleg Verych wrote:
> Herbert Xu @ Sun, May 18, 2008 at 11:41:08PM +0800:
> 
> > > # (1) parameters to `printf`?
> > > 
> > > olecom@flower:/tmp$ sh -c 'printf "-1"'
> > > printf: 1: Illegal option -1
> > 
> > This is expected.  Use printf -- if you want to disable option parsing.
> 
> [second] Again for `echo` it's not so, `printf` is a mean for "propper"
>          (portable) `echo`, nothing about getopt() stuff is mentioned in
> 	 POSIX spec.

All POSIX utilities accept -- by default.  The specification for
echo specifically forbids --, while that of printf does not.

> > > # (3) '\' in `` and in $();
> > > # what is POSIX "literal meaning" of '\' in `` and what is '\\' then?
> (bash removed)
> 
> $( ' \\\\ ' ) ; ` ' \\\\ ' ` ; $( ' \\\ ' ) ; ` ' \\\ ' `
>       (4)            (2)            (3)           (2)
> $( " \\\\ " ) ; ` " \\\\ " ` ; $( " \\\ " ) ; ` " \\\ " `
> 
> it is so, but how to explain this wrt spec.?

Section 2.6.3, "Command Substitution":

            Within the backquoted style of command substitution, backslash
            shall retain its literal meaning, except when followed by:
            '$', '`', or '\\' (dollar sign, backquote, backslash).

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux