On Wed, 17 Jan 2007, paul.mcilfatrick@??? wrote:
> But in my case there was no previous value as the ${if is not nested.
Yes there was. The default value of all the numerical values is "".
> Would it be possible for Exim to be changed so that at the end of an if
> expansion a numerical variable is only reset if it held a value before?
Anything conceivable is of course possible. However, this isn't
necessarily easy because the current code treats the variables as a set,
not one by one. The entire set is saved, and then restored. I think it
would be confusing if, say, $1 was set, you did an ${if that used both
$1 and $2, and then afterwards you ended up with the old value of $1 and
the new value of $2.
Even if you did this only when *no* variables were previously set (and
I'm assuming here that we implement a way of distinguishing between
unset and an empty string value) it is still a death-trap because an
un-nested ${if might later be modified and become nested - and so stop
working.
The long and short of it is that, in an "${if match" expansion, the
design is such that the numeric variables are isolated within that
specific item, and don't affect anything outside of it.
Changing this design isn't something one would do lightly, because it is
likely to break someone's configuration. Note that $1 etc are set by
various constructs other than ${if.
You are, of course, very welcome to add this suggestion to Bugzilla so
that it is not forgotten. Other maintainers may disagree, but for
myself, I'm inclined to put this into "something to think about for Exim
5, where non-compatible changes may be tolerable". Sorry about that, but
I feel that it's too delicate an area to touch without considerable
thought and design.
--
Philip Hazel University of Cambridge Computing Service
Get the Exim 4 book: http://www.uit.co.uk/exim-book