Forráskód Böngészése

[python] support calling Sys.command with raw cmd string

Andy Li 9 éve
szülő
commit
ec0fb468f5
3 módosított fájl, 9 hozzáadás és 4 törlés
  1. 5 2
      std/python/_std/Sys.hx
  2. 3 1
      std/python/lib/Subprocess.hx
  3. 1 1
      tests/sys/src/TestSys.hx

+ 5 - 2
std/python/_std/Sys.hx

@@ -100,8 +100,11 @@ class Sys {
 	}
 
 	public static function command( cmd : String, ?args : Array<String> ) : Int {
-		var args = args == null ? [cmd] : [cmd].concat(args);
-		return python.lib.Subprocess.call(args);
+		return
+			if (args == null)
+				python.lib.Subprocess.call(cmd, { shell: true });
+			else
+				python.lib.Subprocess.call([cmd].concat(args));
 	}
 
 	public static function cpuTime() : Float {

+ 3 - 1
std/python/lib/Subprocess.hx

@@ -21,6 +21,8 @@
  */
 package python.lib;
 
+import haxe.extern.EitherType;
+
 extern class StartupInfo {
 	public var dwFlags : Int;
 
@@ -47,6 +49,6 @@ extern class Subprocess {
 
 	public static var STDOUT:Int;
 
-	public static function call(args:Array<String>):Int;
+	public static function call(args:EitherType<String,Array<String>>, ?kwArgs:python.KwArgs<Dynamic>):Int;
 
 }

+ 1 - 1
tests/sys/src/TestSys.hx

@@ -29,7 +29,7 @@ class TestSys extends TestCommandBase {
 	}
 	#end
 
-	#if neko
+	#if (neko || python)
 	function testRawCommand() {
 		var bin = sys.FileSystem.absolutePath(ExitCode.bin);
 		var native = sys.FileSystem.absolutePath(ExitCode.getNative());