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

From: Josh Rickmar <jrick_AT_devio.us>
Date: Sun, 24 Jul 2011 12:22:09 -0400

lolilolicon <lolilolicon_AT_gmail.com> wrote:

> 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.
>

This is why ksh added the print builtin; echo is different on so many
systems it's not practical to write programs using it.

Not that I think adding yet another command is a good idea to solve
the situation, but it has helped with some of my own scripts.
Received on Sun Jul 24 2011 - 18:22:09 CEST

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