Re: [exim] Quote problem with ${run}

Góra strony
Delete this message
Reply to this message
Autor: Phil Pennock
Data:  
Dla: Stephan Helma
CC: exim-users
Temat: Re: [exim] Quote problem with ${run}
On 2013-02-06 at 22:28 +0000, Stephan Helma wrote:
> The file .vacation.msg should call
>     /bin/date --date=2013-02-07 +"%A, %-d %B"
> to format a time string. Whatever I do, I get the this error from /bin/date:
>     bin/date: extra operand `%-d'
>     Try `/bin/date --help' for more information.


Exim is parsing the quotes, where normally the shell would.

In shell, a" foo" is the same as "a foo". The full shell grammar is
hideously complex and has led to more hidden surprises than I care to
remember.

Exim's parsing is much simpler. If you want to group things together,
use the double-quotes at the outside of the parameter. Note that the
shell can tell if a double-quotes occurs from expanding a variable; in
Exim, because of how things are structured, that's much harder and the
information is gone by the time the command is run. Exim's not
_designed_ to run external commands, it's just one facility offered, so
we're not going to restructure how parsing happens, to change this.

The simple Exim way means that it's immune to the contents of a string.
You can pass "$variable" and it will be one argument, no matter what's
in $variable.

Your +"%whatever" is a convention in a writing style to call out that
the + is the first character, so this is a format string, while still
protecting the contents. It's exactly the same, to shell, as
"+%whatever".

Run `exim -be` at a command-prompt, and enter expressions in there. A
good tool is printf(1) because it will repeat the format string as often
as needed to consume all the arguments.

----------------------------8< cut here >8------------------------------
> ${run {/usr/bin/printf "%s\n" a "b, c" d}{$value}{STDERR<<$value>>}}

a
b, c
d

> ${run {/usr/bin/printf "%s\n" a "+b, c" d}{$value}{STDERR<<$value>>}}

a
+b, c
d

> ${run {/usr/bin/printf "%s\n" a +"b, c" d}{$value}{STDERR<<$value>>}}

a
+"b,
c"
d

> ${run {/usr/local/bin/gdate --date=2013-02-07 "+%A, %-d %B"}{$value}{$value}}

Thursday, 7 February

----------------------------8< cut here >8------------------------------

Regards,
-Phil