[Scons-users] quoting question in an Action call

Christopher Murray murpup at gmail.com
Sun Aug 4 10:39:39 EDT 2013

Thank you for the reply.

Actually, that solution does not work either. I tried that technique
first. The error message I got was:

cat: /*.diag: No such file or directory

Which implies that the variable substitution was happening immediately (the
expected behavior when env.Action() form is used). So I eliminated the use
of env and tried this:

diag_action = Action('cat ${TARGET.dir}/*.diag > diag_concat')

but got the same error as I originally reported:

cat: build/cygwin/g95/x86/debug/src/*.diag: No such file or directory

But I have been able to move past my issue with a different solution. The
following works:

def catdiags(target=None, source=None, env=None):
import subprocess
command = 'cat ' + str(target[0].dir) + '/*.diag > diag_concat'
subprocess.call(command, shell=True)
return 0

diag_action = env.Action(catdiags)
env.AddPostAction(trace, diag_action)

Thank you for the help,

On Sun, Aug 4, 2013 at 8:42 AM, David Roundy <
roundyd at physics.oregonstate.edu> wrote:

> I expect


> diag_action = env.Action('cat ${TARGET.dir}/*.diag > diag_concat')


> would work (as long as ${TARGET.dir} does not contain spaces, '>', or

> other shell-specific characters. Specifying an action as a list presumably

> bypasses the shell, as that's what it does in most other languages.


> David



> On Fri, Aug 2, 2013 at 10:20 AM, Christopher Murray <murpup at gmail.com>wrote:


>> Hi,


>> I have a situation where my compiler is able, through a command line

>> argument, to write all of the diagnostics and warnings it produces to

>> a separate file. I would like to add a function to our build scripts

>> that is able to concatenate these individual diagnostic files into one

>> file. This would allow us to easily compare it to previous code

>> versions and detect newly added warnings or other issues. I could

>> create a separate script or python function which could be run at the

>> end of the build to do this, but I figured the most elegant solution

>> would be to do this with an Action object and AddPostAction.


>> So I created a Action object like this:


>> diag_action = env.Action([['cat', '${TARGET.dir}/*.diag', '>',

>> 'diag_concat']])

>> env.AddPostAction(my_target, diag_action)


>> But when I run the build, the cat program throws the following error:


>> cat: build/cygwin/g95/x86/debug/src/*.diag: No such file or directory


>> Since all the .diag files do, in fact, exist in that build directory,

>> I figure that the "*" character must be getting interpreted literally

>> by the shell. I can replace the "*" with one of the actual file names

>> and it works just fine so it is not a relative path issue.


>> Is there a way to wrap the system call to 'cat' and its arguments to

>> prevent such quoting problems?


>> Thanks,

>> Chris

>> _______________________________________________

>> Scons-users mailing list

>> Scons-users at scons.org

>> http://four.pairlist.net/mailman/listinfo/scons-users





> --

> David Roundy


> _______________________________________________

> Scons-users mailing list

> Scons-users at scons.org

> http://four.pairlist.net/mailman/listinfo/scons-users



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20130804/2faa1f7f/attachment.htm

More information about the Scons-users mailing list