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

pass single-quoted arguments to external script



Hi all.

I have some trouble with Mutt's quoting conventions in hooks etc.

At first, what I already have and what works is (a) or (b), which does the
same:

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

Now, I want to replace `vim` with a script `xvim` which essentially does:

    xterm -e vim "$@" &

Simply dropping `xvim` into (a) fails:

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

I get a vim error:    

    "]*$" [New File]
    Error detected while processing command line:
    E486: Pattern not found: ^--[
    E16: Invalid range: -2
    Press ENTER or type command to continue

i.e. the single-quotes are eaten up and the cmd line args are split at
whitespaces. I tried to escape the single quotes. Increasing the number of `\'
changes nothing until I use four: \\\\' which produces a mutt error:

    Error running "xvim \'+/^--[ ]*$\' -c \'-2; read 
/home/elcorto/.mutt/greeting_mefx.txt\'  '/tmp/mutt-ramrod-1000-9263-0'"!

So how do I properly escape the single quotes in the vim args

     '+/^--[ ]*$'
     -c 'read <some_file>'

TIA!

steve