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

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

 



Oleg Verych <olecom@xxxxxxxxxxxxxx> wrote:
> # (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.

> # (2) parsing features?
> 
> olecom@flower:/tmp$ sh -c 'echo 1; } echo 2'
> 1
> 2
> olecom@flower:/tmp$ sh -c '} echo 2'
> sh: Syntax error: "}" unexpected
> olecom@flower:/tmp$ sh -c 'echo 2; }'
> 2
> olecom@flower:/tmp$

Yes that's a defect in the dash parser.

> # (3) '\' in `` and in $();
> # what is POSIX "literal meaning" of '\' in `` and what is '\\' then?
> # bash has its own opinion
> 
> olecom@flower:/tmp$ PS2=''
> olecom@flower:/tmp$ dash -s << '='
> `echo ' \' >&2`
> `echo ' \\' >&2`
> `echo ' \\\' >&2`
> `echo ' \\\\' >&2`
> $(echo ' \' >&2)
> $(echo ' \\' >&2)
> $(echo ' \\\' >&2)
> $(echo ' \\\\' >&2)
> echo --
> $(echo ' \\\\\' >&2)
> `echo  ' \\\\\' >&2`

bash and dash in fact agree on these except that echo in dash
interprets escape codes as required by POSIX.

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