Discussion:
Problems with hooks, 'set' and quoting/escaping values
David Woodfall
2018-05-18 17:22:27 UTC
Permalink
When using hooks I find that I sometimes have problems with using
'set' and some variables that need quoting or escaping.

eg: the following work:

folder-hook =Sent 'set index_format="%3C %[!%d/%m/%y] %-15.15F %s"'
folder-hook =Folk 'set editor="vim +\':call Mailer()\' %s"'

However I'm having problems with this line:

reply-hook .* 'set editor="vim +\':call Mailer()\' %s"'

No matter how I quote/escape it I always get an error. Either
something in the lines of '+:call: unknown variable' or 'sh -c
unexpected '('' I don't know why this works with folder-hook but not
with reply-hook.

My usual way out of these situations is to put such commands in a
file and have a hook source it, but to make a file for just one
command just seems wrong.

Any ideas?
How do you guys cope with situations like this?

-Dave

--

Please don't reply directly to me or CC me.

All language designers are arrogant. Goes with the territory...
-- Larry Wall

.-. .-. .-. .-. .-. .-. .-. .-. .-.
.' `._.' `._.' `._.' `._.' `._.' `._.' `._.' `._.' `.
David Woodfall
2018-05-18 17:32:52 UTC
Permalink
On Friday 18 May 2018 18:22,
Post by David Woodfall
When using hooks I find that I sometimes have problems with using
'set' and some variables that need quoting or escaping.
folder-hook =Sent 'set index_format="%3C %[!%d/%m/%y] %-15.15F %s"'
folder-hook =Folk 'set editor="vim +\':call Mailer()\' %s"'
reply-hook .* 'set editor="vim +\':call Mailer()\' %s"'
No matter how I quote/escape it I always get an error. Either
something in the lines of '+:call: unknown variable' or 'sh -c
unexpected '('' I don't know why this works with folder-hook but not
with reply-hook.
My usual way out of these situations is to put such commands in a
file and have a hook source it, but to make a file for just one
command just seems wrong.
Any ideas?
How do you guys cope with situations like this?
Answering my own question. This works:

reply-hook .* "set editor='vim +\":call ListMailer()\" %s'"

I reversed the single and double quotes.

-Dave

--

Please don't reply directly to me or CC me.

The linuX Files -- The Source is Out There.
-- Sent in by Craig S. Bell, ***@aracnet.com

.-. .-. .-. .-. .-. .-. .-. .-. .-.
.' `._.' `._.' `._.' `._.' `._.' `._.' `._.' `._.' `.
Loading...