[Scons-users] env.command fails on mingw shell
Evan Driscoll
driscoll at cs.wisc.edu
Thu Oct 25 20:34:09 EDT 2012
The following works for me:
from SCons.Platform.win32 import exec_spawn
import os
env = Environment(ENV = {'PATH' : os.environ["PATH"]})
env["SHELL"]=env.WhereIs("bash")
env["SPAWN"] = (lambda sh, esc, cmd, args, env_param:
exec_spawn([sh, '-c', ' '.join(args)], env_param))
env.Command("test", "", "ls;")
You may wish to factor out the definition of env["SPAWN"] to a named
function, and of course you must only set that on Windows.
Evan
On 10/25/2012 5:51 PM, Gary Oberbrunner wrote:
> Probably need to set env[SPAWN] in that case.
>
> On Oct 25, 2012 6:29 PM, "Evan Driscoll" <driscoll at cs.wisc.edu
> <mailto:driscoll at cs.wisc.edu>> wrote:
>
> On 10/25/2012 05:20 PM, Kraus Philipp wrote:
> > I posted the last 3 answer in one
> >
> > I run this Scons code
> >
> > import os
> > env = Environment(ENV = {'PATH' : os.environ["PATH"]})
> > env.Command("test", "", "ls;") # ls; and ls ; are the same
> >
> > and get
> >
> > Administrator at win7mingw /c/Users/Administrator/Documents
> > $ scons
> > scons: Reading SConscript files ...
> > scons: done reading SConscript files.
> > scons: Building targets ...
> > ls;
> > ls: ;: No such file or directory
> > scons: *** [test] Error 2
> > scons: building terminated because of errors.
>
> Bmitry Mikhin already explained that: scons is executing "ls;" through
> cmd.exe, because that's the value of env["SHELL"]. (Note: not
> os.environ["SHELL"]).
>
>
> Theoretically you could get it to use the MinGW shell by setting
> env["SHELL"] = env.WhereIs("bash")
> or whatever, but this won't actually work: SCons will try to run
> bash /C ls
> instead of
> bash -c ls
> because /C is what cmd uses. I'm not sure how to fix this -- any
> suggestions?
>
>
> Evan
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org <mailto:Scons-users at scons.org>
> http://four.pairlist.net/mailman/listinfo/scons-users
>
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users
>
More information about the Scons-users
mailing list