[Scons-users] escaping brackets () in file path
Bill Deegan
bill at baddogconsulting.com
Mon Feb 29 14:08:29 EST 2016
I just pushed a fix for this.
It should make it into 2.5.
If you'd like to try the current default branch and let us know if it
resolves your issue.
https://bitbucket.org/scons/scons/pull-requests/307/fix-for-bug-2225/diff
-Bill
On Mon, Feb 29, 2016 at 11:05 AM, Plunket, Tom <
tom.plunket at aristocrat-inc.com> wrote:
> The filename is presumably "(bar)" though, putting quotes around the whole
> thing is telling the command that the file you want processed is named "foo
> (bar) qux".
>
> I use subprocess-based actions a lot myself also due to quoting issues and
> frankly am surprised that that's not just the way SCons does it anyway as
> it seems so much superior (and multiplatform) than trying to reintroduce
> the vagaries of shell processing.
>
> But if you want to quote arguments on the command line, you quote each
> argument separately.
>
> -----Original Message-----
> From: carandraug at gmail.com [mailto:carandraug at gmail.com] On Behalf Of
> Carnë Draug
> Sent: Saturday, February 27, 2016 4:42 AM
> To: Plunket, Tom <tom.plunket at aristocrat-inc.com>
> Cc: SCons users mailing list <scons-users at scons.org>
> Subject: Re: [Scons-users] escaping brackets () in file path
>
> On 27 February 2016 at 00:19, Plunket, Tom <tom.plunket at aristocrat-inc.com>
> wrote:
> > It's not a direct answer to your query, but can you just quote your
> > file arguments? I have to do that anyway because my users love to put
> > spaces in their filenames but it also covers other shell characters
> pretty well.
> > The only character I need to handle manually (presumably because I
> > can't figure out how to get env.Literal to work) is the dollar symbol
> > $ but that's because SCons tries to process it before it gets to the
> shell.
> >
>
> I tried it but it does not work. The quotes become part of the argument.
>
> $ cat SConstruct
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> Command(target='foo (bar) qux', source=None, action="touch '$TARGET'")
>
> $ scons
> scons: Reading SConscript files ...
> scons: done reading SConscript files.
> scons: Building targets ...
> touch "'foo (bar) qux'"
> scons: done building targets.
>
> $ ls
> 'foo (bar) qux' SConstruct
>
> Changing to quotes does not fix it either:
>
> $ cat SConstruct
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> Command(target='foo (bar) qux', source=None, action='touch "$TARGET"')
>
> $ scons
> scons: Reading SConscript files ...
> scons: done reading SConscript files.
> scons: Building targets ...
> touch ""foo (bar) qux""
> sh: 1: Syntax error: "(" unexpected
> scons: *** [foo (bar) qux] Error 2
> scons: building terminated because of errors.
>
> I have previously bumped into similar issues where my arguments were
> regular expressions and I couldn't trust SCons to quote things correctly.
> This may be of help to you. My solution at the time was the following:
>
> ## Add a NoShellCommand builder to be used like Command()
> ##
> ## This has the advantage that there's no shell involved, saving us
> ## from having to escape quotes, spaces, wildcards, and whatsnot.
>
> import subprocess
> def no_shell_command(target, source, env):
> return subprocess.call(env['action'])
> def no_shell_command_strfunc(target, source, env):
> args = env['action']
> return "$ %s " % (args[0]) + " ".join(["'%s'" % (arg) for arg in
> args[1:]])
> no_shell_command_action = Action(no_shell_command,
> strfunction=no_shell_command_strfunc)
> env.Append(BUILDERS={'NoShellCommand' :
> Builder(action=no_shell_command_action)})
>
> Which you can then use like this:
>
> NoShellCommand(source = foo, target = bar, action = [prog, foo, bar,
> arg1, arg2])
>
> Carnë
>
>
> IMPORTANT CONFIDENTIALITY NOTICE:
>
> This E-mail(including any documents referred to in, or attached, to this
> E-mail) may contain information that is personal, confidential or the
> subject of copyright or other proprietary rights in favor of Aristocrat,
> its affiliates or third parties. This E-mail is intended only for the named
> addressee. Any privacy, confidence, copyright or other proprietary rights
> in favor of Aristocrat, its affiliates or third parties, is not lost
> because this E-mail was sent to you by mistake.
>
> If you received this E-mail by mistake you should: (i) not copy, disclose,
> distribute or otherwise use it, or its contents, without the consent of
> Aristocrat or the owner of the relevant rights; (ii) let us know of the
> mistake by reply E-mail or by telephone (US 1-877-274-9661, or AU +61 2
> 9013 6000); and (iii) delete it from your system and destroy all copies.
>
> Any personal information contained in this E-mail must be handled in
> accordance with applicable privacy laws.
>
> Electronic and internet communications can be interfered with or affected
> by viruses and other defects. As a result, such communications may not be
> successfully received or, if received, may cause interference with the
> integrity of receiving, processing or related systems (including hardware,
> software and data or information on, or using, that hardware or software).
> Aristocrat gives no assurances in relation to these matters.
>
> If you have any doubts about the veracity or integrity of any electronic
> communication we appear to have sent you, please call (US 1-877-274-9661,
> or AU +61 2 9013 6000) for clarification.
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20160229/3d45dafd/attachment-0001.html>
More information about the Scons-users
mailing list