changeset 674:80d4c32c8103

0.6dev: Follow-up to #441 / [745]. Of course, cmd.exe built-ins was the reason for executing through shell on Windows... This fix adds back support for important built-ins by essentially calling `cmd.exe /C command + args`.
author osimons
date Mon, 07 Sep 2009 08:56:32 +0000
parents 22bbda64c9f5
children 251be647314c
files bitten/build/shtools.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/build/shtools.py
+++ b/bitten/build/shtools.py
@@ -107,6 +107,12 @@
     elif file_:
         args[:0] = [file_]
 
+    # Support important Windows CMD.EXE built-ins (and it does its own quoting)
+    if os.name == 'nt' and executable.upper() in ['COPY', 'DIR', 'ECHO',
+                'ERASE', 'DEL', 'MKDIR', 'MD', 'MOVE', 'RMDIR', 'RD', 'TYPE']:
+        args = ['/C', executable] + [arg.strip('"') for arg in args]
+        executable = os.environ['COMSPEC']
+
     if input_:
         input_file = file(resolve(input_), 'r')
     else:
Copyright (C) 2012-2017 Edgewall Software