[Portland] Bug#574131: xdg-utils: xdg-email never launchs a mua if desktop is not gnome neither kde neither xfce
Per Olofsson
pelle at dsv.su.se
Sun Oct 24 12:58:36 PDT 2010
Hi,
2010-10-24 00:22, Jonathan Nieder skrev:
> 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.
No good.
> 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.
It might also leave a shell process hanging around. So maybe
sh -c "exec $EDITOR \"\$1\"" - "$filename"
?
>
> 3. $EDITOR "$1"
>
> respects only the shell metacharacters that have to do with
> word splitting (if I remember correctly).
In fact, it seems to only support word splitting. No quotes or anything
else.
> It is hard to use from
> C programs --- I think you have to first export EDITOR, then run
>
> sh -c '$EDITOR "$1"' - filename
OK. So maybe option 2 is the best one then.
>> 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.
It's nice to be able to say EDITOR="emacs -nw" I think. I'm not sure how
important it is to be able to quote spaces and such though. Still, if
option 2 is easier to implement from C programs, perhaps it's the best
option.
--
Pelle
More information about the Portland
mailing list