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

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

 



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.


> > $(echo ' \\\\\' >&2)
> > `echo  ' \\\\\' >&2`
> 
> bash and dash in fact agree on these except that echo in dash
> interprets escape codes as required by POSIX.

[first] Gee, that `echo` thing (how stupid to catch it:)
        Correct test (works), question remains:

> > # (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.?

olecom@flower$ bash -s <<"E"
$(printf %s ' \\\\ ' >&2)
`printf '\n%s\n-\n'  ' \\\\ ' >&2`
$(printf %s " \\\\ " >&2)
`printf '\n%s\n-\n'  " \\\\ " >&2`
E
 \\\\
 \\
-
 \\
 \
-
olecom@flower$ sh -s <<"E"
$(printf %s ' \\\\ ' >&2)
`printf '\n%s\n-\n'  ' \\\\ ' >&2`
$(printf %s " \\\\ " >&2)
`printf '\n%s\n-\n'  " \\\\ " >&2`
E
 \\\\
 \\
-
 \\
 \
-
olecom@flower$ bash -s <<"E"
$(printf %s ' \\\ ' >&2)
`printf '\n%s\n-\n'  ' \\\ ' >&2`
$(printf %s " \\\ " >&2)
`printf '\n%s\n-\n'  " \\\ " >&2`
E
 \\\
 \\
-
 \\
 \
-
olecom@flower$ sh -s <<"E"
$(printf %s ' \\\ ' >&2)
`printf '\n%s\n-\n'  ' \\\ ' >&2`
$(printf %s " \\\ " >&2)
`printf '\n%s\n-\n'  " \\\ " >&2`
E
 \\\
 \\
-
 \\
 \
-
--
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