Boost logo

Boost-Build :

Subject: [Boost-build] Variable expansion in actions - bug or feature?
From: Jurko Gospodnetiæ (jurko.gospodnetic_at_[hidden])
Date: 2012-05-26 13:36:02


   Hi all.

   Just wandering if I'm reading something wrong here, but I do not
understand why variable expansion seems to work differently in regular
(non-action) Boost Jam code and inside action code. Is this intentional
or is this a bug? An if it is intentional - I know of at least one place
in Boost Build code that is broken by this feature ('time' action in the
testing.jam module).

   It seems like variable expansion in action code treats double quotes
as regular characters and not as delimiters marking a string literal.

   For example, with variable 'a' set to list [1, 2, 3] non-action code:

     $(a)" seconds"

   gets expanded to '1 seconds 2 seconds 3 seconds' as expected, while
in action code it gets expanded to '1" 2" 3" seconds"'.

   To demonstrate run the 'bjam -f source.jam' command in a folder
containing a file named source.jam with the following content:
     ---------------
     rule dummy ( i )
     {
         local a = 1 2 3 ;
         ECHO From rule: $(a)" seconds" ;
         a on $(i) = $(a) ;
     }

     actions dummy
     {
         echo From action: $(a)" seconds"
     }

     dummy all ;
     ---------------

   You should get output like this:
     ---------------
     From rule: 1 seconds 2 seconds 3 seconds
     ...found 1 target...
     ...updating 1 target...
     dummy all
     From action: 1" 2" 3" seconds"
     ...updated 1 target...
     ---------------

   I'll look into the Boost Jam source code now to see if I can dig up
anything interesting regarding this but hopefully someone more actively
involved with that code-base can shed some light a bit sooner.

   Best regards,
     Jurko Gospodnetiæ


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk