Bug #605 -- Conditional execution

Kevin P. Fleming kpfleming at linuxfromscratch.org
Sun Feb 1 07:03:14 PST 2004


Alex Potter wrote:

> Do you mean something like
> if <test> then
> 	pass_action
> else
> 	fail_action
> endif
> 
> where <test> =[ [not]"shell test function expression" ]
>        [[&& or || [not]]<package-built>package-name</package-built>]
>        [[&& or || [not] ] <package-version condition="[eq | ge |le]">
> 		3.1.2</package-version>]

I hadn't considered adding <not>, but that would make sense, yes.

> 
> and actions may include further if statements or any legal code for the
> element that encloses the outermost if.

Yes, <then>/<else> are exactly the same as <stage> (in fact they are in 
the same source file so they can share common code), except that they 
are only invoked when the test result warrants.

> I think your "implicit AND" may well prove to be a PITA.....

Possibly, although even in the worst case someone could use:

<if>
   <or>
     <test>...</test>
     <test>...</test>
   </or>
   <then>
      ...
   </then>
</if>

I just have a feeling that most often if you want to have multiple 
conditions in the <if> statement they would be chained together with 
AND, and the "implicit" AND removes the need for adding an <and> element 
everytime you need an <if> statement which has (for example) two conditions.




More information about the alfs-discuss mailing list