Should substitution apply to values in the Environment's ENV dictionary?

"Andrew C. Morrow" <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <CA+Acj4f2QFQca8h71BPWzNsx+ySqM_zqcCq9piEu=xke-snJjw@mail.gmail.com>
Hi All -

I noticed recently that the following doesn't work as I had expected it
would:

env = Environment()

def generate_foo(target, source, env, for_signature):
    return 'FOO_IS_COOL'

env['FOO'] = generate_foo
env['ENV']['FOO'] = '$FOO'

cmd = env.Command(
    target='env',
    source=[],
    action='env > $TARGET'
)

env.Default(cmd)

The spawned command gets a literal $FOO for the FOO environment variable,
not the result of substituting $FOO, which should be FOO_IS_COOL.

scons && cat env
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
env > env
scons: done building targets.
FOO=*$FOO*
PATH=/usr/local/bin:/opt/bin:/bin:/usr/bin:/usr/sbin:/sbin:/opt/X11/bin
PATHOSX=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
SHLVL=1
_=/usr/bin/env

I'll admit this may be something of an edge case, but it seems to me to
violate the principle of least surprise given how pervasively substitution
is wired into SCons. I'd think it would be better if this worked. The price
would be additional subst calls the majority of which would not expand, and
subst is known to have real performance overhead.

Thoughts?

Thanks,
Andrew

_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.