[jamming] Command built-in questions (was Re: Executing shell command, save results to variable)

David Turner david at freetype.org
Fri Mar 23 08:25:08 PST 2007


Hi,

> AFAIK, it is been problem on Win32 for an ages, and no one provided an
> good alternative for unix implementation. I didn't used it on Win32 side and
> not sure what are pros/cons of current implementation, but after quick
> search I found some alternative on qt list:
> http://lists.trolltech.com/qt-interest/1999-09/thread00282-0.html
> 
> I am not able to decipher german comments, but hoping this can be good
> starting point.
> 
That's not too bad. Fortunately, I have some code, written several years ago
that implement exactly what we need, i.e. a cross-platform "spawn" function that
can be used to control the inputs and outputs of external programs.

My code did work on Win32, OS/2 and Unix, and I'm currently stripping it down
to use it in Jam. The Win32 code already works pretty fine, but could be a bit
simpler since we don't need to do a lot of the fancy things that were part of
the initial requirements. I think I'll have something good to show next week.

By the way, what does "popen" does with the non-redirected standard streams of the
executed commands on Unix. For now, I have the choice of implementing any of the
following, I don't have made any decision yet:

- redirect stdin to /dev/zero
- redirect stdin to /dev/nul   (blocking)
- redirect stderr to stdout
- redirect stderr to /dev/null
- keep stdin and stderr as they are, they're inherited by the child process

Do any of you guys can think of a good rationale for thinking about a consistent
behaviour. I plan to implement the same one on all platforms.

Any VMS hacker to implement "popen" or something like that as well ?

Apart from that, I think that "lines" should be a reasonable default. I'd rather
see a new "Split" built-in to perform the lines-to-word separation than add
arguments to the "Command" built-in

Regards,

- David

of the executed commands

> > - is there some serious use to the "mixed" and "lines" cases ? we really don't want
> >   to turn Jamfiles into parsing programs, don't we.
> 
> For "lines" (thought): for example we know that program outputs our
> interested data on second or third line (gcc -v for example). But this
> is probably better to be handled via external script, keeping jam source
> simple.
> 
> > - which default behaviour would you prefer ? (I'm for "words", but YMMV)
> 
> I am for "words" too (and only "words" :)).
> 
> --
> Sanel
> _______________________________________________
> jamming mailing list  -  jamming at perforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming


More information about the jamming mailing list