<!ELEMENT if (then?,else?)> <!ATTLIST if test CDATA #IMPLIED package CDATA #IMPLIED condition (eq|ne|gt|ge|lt|le) #IMPLIED version CDATA #IMPLIED> |
This element occurs in the elements alfs, else, stage, and then.
The element if perform either a test either of a shell expression (if the test attribute is specified), or an evaluation on the existence or version of a package (if the package attribute is specified.
If the test attribute is specified, one look first for four special values : "0", "1", "false", and "true", which have the usual meaning. If the attribute has another value, one executes the attribute as a shell expression, and consider that the test is satisfied of the status is 0.
If the package attribute is specified but the condition attribute is not specified, the test will be satisfied if the specified package has been build.
If the attributes package, condition and version are specified, the test will be satisfied if the condition on the vaersion of the package is satisfied. The condition is evaluated the same was as when evaluating the version element.
The two attributes test and package are mutually exclusive.
<if test="0"> <then><execute command="echo this should be executed." /></then> <else><execute command="echo this should not be executed." /></else> </if> |
<execute command="touch /tmp/foo" /> <if test="[-r /tmp/foo"> <then><execute command="echo this should be executed." /></then> <else><execute command="echo this should not be executed." /></else> </if> |
<if package="bison"> <then><execute command="echo this should be executed if bison is build." /></then> <else><execute command="echo this should not be executed if bison is build." /></else> </if> |
<if package="bison" condition="ge" version="1.875"> <then><execute command="echo this should be executed if bison 1.875 or greater is build." /></then> </if> |