How to use conditionals

James Robertson jwrober at linuxfromscratch.org
Thu Jun 17 15:09:16 PDT 2004


Gerard Beekmans wrote:
> Hey guys,
> 
> I checked out CVS and build nALFS and am trying to use conditionals now
> to see how it all works. So far not much luck.
> 
> First off, there's a mistake in the documentation: in
> docs/syntax_doc/alfs_dtd/elem_if.xml
> 
> The following given example doesn't quite work:
> 
> <screen><userinput>
> <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>
> </userinput></screen>
> 
> That [ before '-r' should be removed.
> 
> Now, consider this piece of profile as an example:
> 
>         <stage name="Test">
>                 <if test="-r /etc/passwd">
>                 <then>
>                         <textdump>
>                                 <file>/testpassed</file>
>                                 <content>=passed</content>
>                         </textdump>
>                 </then>
>                 <else>
>                         <textdump>
>                                 <file>/testfailed</file>
>                                 <content>=failed</content>
>                         </textdump>
>                 </else>
>                 </if>
>         </stage>
> 
> 
> Either I'm doing something wrong, or it's not working as it should.
> Output in nALFS is:
> 
> I: Executing __profile...
> I:
> I:     test -r /etc/passwd
> I: Log file stored in:
> I: /home/gerard/.nALFS/packages/test.xml
> I: Execution successfully done.
> I: Total time executing: 00:00:00
> 
> And neither /testpassed or /testfiled exist after it runs. The test.xml
> log contains:
> 
>   <package mode="start">Thu, 17 Jun 2004 14:57:51 -0600</package>
>   <stage mode="start">Thu, 17 Jun 2004 14:57:51 -0600</stage>
>   <handler_action>    test -r /etc/passwd</handler_action>
>   <then mode="start">Thu, 17 Jun 2004 14:57:51 -0600</then>
>   <then mode="end" status="done">Thu, 17 Jun 2004 14:57:51 -0600</then>
>   <stage mode="end" status="done">Thu, 17 Jun 2004 14:57:51
> -0600</stage>
>   <package mode="end" status="done">Thu, 17 Jun 2004 14:57:51
> -0600</package>
> 
> So it looks it enters <then> (as it should) but doens't run anything
> there?
> 
Hi G, long time no see

AFAIK, nALFS does not yet fully support conditionals.  Kevin is getting 
that and the logging DTD into 1.3.x sometime.  Also, the syntax doc is 
for ALFS DTD 3.1 only which really did not support if/then/else, so it 
is not in there.  I am about to release it and then begin on 3.2 soon.

Hope this helps
James



More information about the alfs-discuss mailing list