Re: [dev] Re: [dmenu] dmenu_run improvements

From: lolilolicon <lolilolicon_AT_gmail.com>
Date: Mon, 25 Jul 2011 00:06:11 +0800

On Sun, Jul 24, 2011 at 10:30 PM, lolilolicon <lolilolicon_AT_gmail.com> wrote:
> On Sun, Jul 24, 2011 at 10:08 PM, Christian Neukirchen
> <chneukirchen_AT_gmail.com> wrote:
>> anonymous <p37sitdu_AT_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  <chneukirchen@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.
Received on Sun Jul 24 2011 - 18:06:11 CEST

This archive was generated by hypermail 2.2.0 : Sun Jul 24 2011 - 18:12:02 CEST