<<< Date Index >>>     <<< Thread Index >>>

Re: pass single-quoted arguments to external script



On May 10 17:31, David Champion wrote:
> > So how do I properly escape the single quotes in the vim args
> 
> Personally, as soon as I start having trouble figuring out how to quote
> things withing multiple layers of parser, I ditch the headache and
> put the command into an external script that accepts only the minimum
> arguments from mutt (i.e., the values that only mutt knows).
> 
> In you case, I guess that would be approximately:
> 
> send-hook ... 'set editor=mutt-xvim'
> 
> $ cat mutt-xvim
> #!/bin/sh
> exec xterm -e vim '+/^--[ ]*$' -c 'read <some_file>' "$@"
> 
> I know that's a level of abstraction away from what you were aiming for,
> but time is just too precious to spend it on all the various (and they
> indeed vary) quoting idiosyncrasies, unless that sort of thing is fun or
> educational for you.  And by putting mutt-specific scripts into a mutt
> namespace, as it were, you're not really causing any layering conflicts.

Hi David

Of course, that's always an option and I do that in other situations. In fact,
the solution here would be even simpler:

    send-hook ... "set editor=\"xterm -e vim '+/^--[ ]*$' -c 'read <some_file>' 
"

The reasons for the whole stunt are:

1) I'm using this xvim script in other places fairly frequently and pass some
additional args to xterm inside it.  Since I want to keep these in one place, I
wanted to use the script rather than duplicating the command 

    xterm <options> -e vim

in my muttrc.

2) In different hooks, I pass different args to vim and was really looking for
a (nearly) drop-in replacement vim -> xvim. Otherwise one would have to
create a mutt-xvim script for each hook. I thought it can't be so hard to do it
from within muttrc. I'll see which workaround I choose should I finally give up
fighting with Mutt's escaping conventions.

steve