[jamming] Executing shell command, save results to variable

Diane Holt holt.diane at gmail.com
Wed Feb 28 09:19:20 PST 2007


I didn't do it as a back-tick, but as a new built-in rule, which I call
Command. It's used inside square brackets.

For example, this just captures the return code (note: the square brackets
passed in the Command itself is the shell's 'test', not Jam's brackets):

RT_OK = [ Command "[ -e /lib/libc.so -o -e /usr/lib/libc.so ] ; echo $?" ] ;
if $(RT_OK) != 0 { Exit "Error: You must install the C runtime before
building." ; }

(P.S. So you don't think I'm crazy, testing for something like that --
that's being run inside a chroot'd environment :)

This one captures the actual output:

local libname = [ Command "echo $(shared_lib) | sed -e
's:\\(.*\\)\\.so\\..*$:\\1.so:'" ] ;

If you're still interested, I can send the diff of builtins.c.

Diane

On 2/28/07, Gary Gendel <gary at icmanage.com> wrote:
>
> Diane,
>
> Any chance of sharing your vision and some of your enhancements with us? I
> would
> love to see a back-tick capability for Jam.
>
> Gary
>
> Diane Holt wrote:
> > I've done both. I pass back-ticked pkg-config commands on my compile and
> > link lines -- ie., I add them to the flags for each (from a new rule,
> > though, not an override on Cc/C++/Link -- although I do have overrides
> > for those rules, but for other reasons). And I also modified Jam to be
> > able to run a shell command from a rule (it bugged me that there was
> > something Make could do that Jam couldn't :)
> >
> > In your case, Chris, if all you need is to pass that wx-config in on the
> > command line, adding it to the flags is the easiest way to go.
> >
> > Diane
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > jamming mailing list  -  jamming at perforce.com
> > http://maillist.perforce.com/mailman/listinfo/jamming
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://maillist.perforce.com/pipermail/jamming/attachments/20070228/38346e65/attachment.html


More information about the jamming mailing list