[Portland] Bug#574131: xdg-utils: xdg-email never launchs a mua if desktop is not gnome neither kde neither xfce

Jonathan Nieder jrnieder at gmail.com
Sat Oct 23 15:22:11 PDT 2010


Per Olofsson wrote:

> Again, why not simply
>
> $EDITOR "$1"

Because that is a weird hybrid of two behaviors:

1. "$EDITOR" "$1"

does not respect shell metacharacters at all, so if you use, e.g.,
EDITOR='emacs -nw', then it will look for a binary with that name.

Advantage: can be used by C programs directly using exec().

2. sh -c '<the editor> "$1"' - filename

respects _all_ shell metacharacters, including pipes, variable
expansions, redirections etc.

3. $EDITOR "$1"

respects only the shell metacharacters that have to do with
word splitting (if I remember correctly).  It is hard to use from
C programs --- I think you have to first export EDITOR, then run

sh -c '$EDITOR "$1"' - filename

> Yeah, putting metacharacters in a variable is asking for trouble anyway.

On e.g. Windows it is common to have filenames with spaces.  It can
also be convenient to pass options with commands like this.

Anyway, luckily it is always possible to get whatever effect is
desired with a well-placed script.


More information about the Portland mailing list