Mailing List Archive

[Bug 167] Make "true" and "false" valid expansion conditions
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167




--- Comment #1 from Magnus Holmgren <holmgren@lysator.liu.se> 2007-08-01 20:19:22 ---
On Wednesday 01 August 2007 20:34, Brian Blood wrote:
> On Aug 1, 2007, at 12:46 PM, Dean Brooks wrote:
> > Certain condition= statements in ACL will accept values such as "true"
> > or "1" to indicate a positive value, but that is only after regular
> > string expansions have been performed on the value of the condition
> > statement.
>
> I'll second my vote for the wishlist item mentioned by John.

I' had trouble seeing the benefit of adding "true" and "false" as trivial
conditions, taking no arguments. If what was originally asked for is for
subconditions of and/or to be expanded, yielding "true", "false", or possibly
an entirely new condition, it makes more sense.

The way things work now is that conditions appear certain places where a
condition is expected and nothing else, while expansion items and variables
are signalled by a '$'. But it shouldn't be too hard to check if the first
character is a '$' and, in that case, perform a string expansion and evaluate
the result as a boolean instead. That won't be possible directly in an ${if},
though, so you can have ${if and{{${lookup mysql{SELECT 1 FROM users WHERE
name = '$local_part'}}{$acl_m1}}}, but not simply ${if ${lookup mysql{SELECT
enabled FROM users WHERE name = '$local_part'}} {foo}{bar}}.


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 167] Make "true" and "false" valid expansion conditions [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167




--- Comment #2 from Philip Hazel <ph10@hermes.cam.ac.uk> 2007-08-02 09:18:12 ---
On Wed, 1 Aug 2007, Magnus Holmgren wrote:

> I' had trouble seeing the benefit of adding "true" and "false" as trivial
> conditions, taking no arguments.

Note also that Exim expands left to right. You are asking for something
like {$something} to work as a condition if the expansion of $something
is a truth value. The code doesn't work like that. After Exim has read

${if and {{

it looks for one of the known condition names (eq, >, matches, etc) as a
*literal string*. After it has found something it recognizes, it then
knows how many arguments are required, and then it expands each of the
arguments *independently*. Consider

${if and { \
{eq{$something}{true}} \
{some other condition} \
} \
{yes string}{no string}}

It won't expand $something until it has seen "eq", after which it knows
to expect two arguments.

If Exim did any kind of "pre-expansion" it would often be expanding
substrings that it then discarded.

One could implement the literal condition "true" (with zero arguments),
but it would be pretty useless, wouldn't it?

Another way of looking at what I am saying is that Exim doesn't expand
strings twice by default. ... Hmm, you can of course make it do so by
using the "expand" operator. So if you could say

${if true {x}{y}}

then you could also say

${expand: \${if ${lookup...} {yes}{no} }

and if the lookup returned "true" it would work. But is not, IMHO, a
great advance on what you can already do:

${lookup... {${if eq{$value}{true}{yes}{no}} {no} }


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 167] Make "true" and "false" valid expansion conditions [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167

Nico Erfurth <masta@perlgolf.de> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |masta@perlgolf.de




--- Comment #3 from Nico Erfurth <masta@perlgolf.de> 2007-08-02 09:37:02 ---
(In reply to comment #2)

> ${lookup... {${if eq{$value}{true}{yes}{no}} {no} }

Well, i think a new condtion like true would be nice, as it could evaluate
true/false as confirming to the everything else in the expansion
code(expand_check_condition). Adding the new condition shouldn't be a problem
and could prove pretty useful.


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 167] Make "true" and "false" valid expansion conditions [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167




--- Comment #4 from Philip Hazel <ph10@hermes.cam.ac.uk> 2007-08-02 09:40:56 ---
On Thu, 2 Aug 2007, Nico Erfurth wrote:

> Well, i think a new condtion like true would be nice, as it could evaluate
> true/false as confirming to the everything else in the expansion
> code(expand_check_condition). Adding the new condition shouldn't be a problem
> and could prove pretty useful.

Please show an example of where it could be useful.

Philip


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 167] Make "true" and "false" valid expansion conditions [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167




--- Comment #5 from Nico Erfurth <masta@perlgolf.de> 2007-08-02 10:19:01 ---
Philip Hazel wrote:

>> Well, i think a new condtion like true would be nice, as it could evaluate
>> true/false as confirming to the everything else in the expansion
>> code(expand_check_condition). Adding the new condition shouldn't be a problem
>> and could prove pretty useful.
>
> Please show an example of where it could be useful.

I had some of this cases in my old configuration. But, the dog ate it
^W^W^W^W it went down with the harddrive in my old server.

I used it mostly to set acl-variables somewhere in the acls, and later
checked them in the routers in some pretty weird conditions including
databaselookups etc.

I just think that something like
${if true:acl_m1}

is more intuitive than:
${if eq{$acl_m1}{1}}

Where you also have to remember whatever you set acl_m1 to true/1/yes
(I'm pretty bad in remembering these things).

Nico


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 167] Make "true" and "false" valid expansion conditions [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167




--- Comment #6 from Magnus Holmgren <holmgren@lysator.liu.se> 2007-08-02 10:33:28 ---
On Thursday 02 August 2007 11:19, Nico Erfurth wrote:
> I just think that something like
> ${if true:acl_m1}
>
> is more intuitive than:
> ${if eq{$acl_m1}{1}}
>
> Where you also have to remember whatever you set acl_m1 to true/1/yes
> (I'm pretty bad in remembering these things).

It's easier to leave the variable empty for "false" and set it to anything at
all for "true". Then you can simply check it with def:.


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 167] Make "true" and "false" valid expansion conditions [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167




--- Comment #7 from Philip Hazel <ph10@hermes.cam.ac.uk> 2007-08-02 11:29:43 ---
On Thu, 2 Aug 2007, Nico Erfurth wrote:

> I just think that something like
> ${if true:acl_m1}

1. That is not the same as making "true" a parameterless condition. :-)

2. There is no syntax of that form currently defined. It would have to
be ${if true{$acl_m1}}

... and then people might think it was a text test, and might try

${if oui{$acl_m1}}

:-)

Philip


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 167] Make "true" and "false" valid expansion conditions [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167




--- Comment #8 from Nico Erfurth <masta@perlgolf.de> 2007-08-02 11:33:17 ---
Philip Hazel wrote:

> 2. There is no syntax of that form currently defined. It would have to
> be ${if true{$acl_m1}}

${if def:} .....?


Nico


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 167] Make "true" and "false" valid expansion conditions [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167




--- Comment #9 from Philip Hazel <ph10@hermes.cam.ac.uk> 2007-08-02 11:38:45 ---
On Thu, 2 Aug 2007, Nico Erfurth wrote:

> ${if def:} .....?

Oops. See. I *do* need to retire. :-)

Philip


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 167] Make "true" and "false" valid expansion conditions [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug.

http://bugs.exim.org/show_bug.cgi?id=167




--- Comment #10 from Nico Erfurth <masta@perlgolf.de> 2007-08-02 11:45:09 ---
Philip Hazel wrote:

>> ${if def:} .....?
>
> Oops. See. I *do* need to retire. :-)

I had a quick look earlier, the COND_DEF code could be easily extended
to support a COND_TRUE/COND_ISTRUE.

But well, after thinking again, it really won't be THE killer-feature to
get admins away from their good old $acl_m_my_most_hated_mta. ;)

Nico


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##