Re: [Exim] String expansion depending on existance of variab…

Startseite
Nachricht löschen
Nachricht beantworten
Autor: John Jetmore
Datum:  
To: Sven Geggus
CC: exim-users
Betreff: Re: [Exim] String expansion depending on existance of variable?
On Fri, 9 May 2003, Sven Geggus wrote:

<snip suggestion and rebuttal of def:>

> The statement does _not_ say:
>
> "If the variable does not exist, the condition is false"
>
> I't OK, when there is no difference between this two statements.
>
> What I actually want to do would be something like this:
>
> ${if def:foo {expand something which uses $fo}{bar}}
>
> So the question is if bar is returned in the case, that foo is a nonexistant
> variable-name.


The first part of what you write sounds like you want a three-state
test like you can get w/ perl's defined() test, yielding true,
false(defined), and false(undefined). I'm goint to bow out at this point
because I don't know the internals of exim well enough, but I don't think
these states exist - I think you either get true or false. Or said
another way, I don't think there's such a thing as "variable does not
exist" in exim's runtime. you can probably get that message from
referencing variable relevant to things you don't have compiled in to
exim, but again I should shut up on this point.

However, from the second half of your statement above, it still looks like
def: should work for you. For instance, to do a lookup on the sender's
hostname (if it was found) or sender's IP address (if hostname was not
found), you could do something like this (just an example off the top of
my head, could be written multiple ways):

condition = ${if def:sender_host_name \
  {$lookup{$sender_host_name}lsearch{/path/to/hostnames}{Yes}{No}}\
  {$lookup{$sender_host_address}lsearch{/path/to/ips}{Yes}{No}}\
             }


If you supplied the specific result you are looking for it might help me
understand exactly what you're asking.

--John