On Sun, Jul 24, 2011 at 10:30 PM, lolilolicon <loliloli...@gmail.com> wrote:
> On Sun, Jul 24, 2011 at 10:08 PM, Christian Neukirchen
> <chneukirc...@gmail.com> wrote:
>> anonymous <p37si...@lavabit.com> writes:
>>
>>> On Sun, Jul 24, 2011 at 02:34:22PM +0800, lolilolicon wrote:
>>>> > unset IFS
>>>> >
>>>> > cmd=$(dmenu "$@" < "$CACHE") && eval exec "$cmd"
>>>> Yeah, I see you just hate backticks :P
>>>>
>>>
>>> There is a difference:
>>>
>>>     % echo `echo '\\'`
>>>     \
>>>     % echo $(echo '\\')
>>>     \\
>>
>> That must be a bashism, can't reproduce in dash, mksh, zsh.
>>
>> --
>> Christian Neukirchen  <chneukirc...@gmail.com>  http://chneukirchen.org
>>
>>
>>
>
> The builtin echo may differ from /bin/echo. For example, here in dash:
>
> $ echo '\\'
> \
> $ echo `echo '\\'`
> \
> $ echo $(echo '\\')
> \
>
> $ /bin/echo '\\'
> \\
> $ /bin/echo `/bin/echo '\\'`
> \
> $ /bin/echo $(/bin/echo '\\')
> \\
>
> In fact the builtin echo really sucks:
>
> $ echo \\
> \
> $ echo \\\\
> \
>

Sorry, but please allow me to rephrase the issue.
The `echo' builtin in dash by default behaves like `echo -e' in bash.
So it's a bit tricky to reproduce the difference in dash:

$ echo `echo '\\\\\\\\'`
\
$ echo $(echo '\\\\\\\\')
\\

Or, just use `printf %s':

$ printf '%s\n' `printf '%s\n' '\\'`
\
$ printf '%s\n' $(printf '%s\n' '\\')
\\

For the record, the sucky `echo' is what POSIX defines:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html

And thank you Szabolcs Nagy for pointing me to the lastes spec.

Cheers.

Reply via email to