diff options
author | Steven Knight <knight@baldmt.com> | 2002-11-13 01:39:45 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-11-13 01:39:45 (GMT) |
commit | 75a90274cf324056b49f53d634cd3f0c3c52fe85 (patch) | |
tree | 105ca0ac902036a73c7a76839944bdb11fcc91c5 /etc/TestCmd.py | |
parent | 889f0c7238da15a89be500e40ce9f73102e31b8c (diff) | |
download | SCons-75a90274cf324056b49f53d634cd3f0c3c52fe85.zip SCons-75a90274cf324056b49f53d634cd3f0c3c52fe85.tar.gz SCons-75a90274cf324056b49f53d634cd3f0c3c52fe85.tar.bz2 |
Support special characters in file names. (Charles Crain)
Diffstat (limited to 'etc/TestCmd.py')
-rw-r--r-- | etc/TestCmd.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/etc/TestCmd.py b/etc/TestCmd.py index 2718494..bac0a93 100644 --- a/etc/TestCmd.py +++ b/etc/TestCmd.py @@ -74,6 +74,26 @@ else: tempfile.template = 'testcmd.' +if os.name == 'posix': + + def escape_cmd(arg): + "escape shell special characters" + slash = '\\' + special = '"$' + + arg = string.replace(arg, slash, slash+slash) + for c in special: + arg = string.replace(arg, c, slash+c) + + return '"' + arg + '"' + +else: + + # Windows does not allow special characters in file names + # anyway, so no need for an escape function, we will just quote + # the arg. + escape_cmd = lambda x: '"' + x + '"' + _Cleanup = [] def _clean(): @@ -454,7 +474,7 @@ class TestCmd: if program: if not os.path.isabs(program): program = os.path.join(self._cwd, program) - cmd = program + cmd = escape_cmd(program) if interpreter: cmd = interpreter + " " + cmd else: |