Kaynağa Gözat

[macro] support calling sys.io.Process with raw cmd string (when args is null)

Andy Li 9 yıl önce
ebeveyn
işleme
243ce60769

+ 2 - 1
interp.ml

@@ -1862,7 +1862,8 @@ let std_lib =
 	(* process *)
 		"process_run", (Fun2 (fun p args ->
 			match p, args with
-			| VString p, VArray args -> VAbstract (AProcess (Process.run p (Array.map vstring args)))
+			| VString p, VArray args -> VAbstract (AProcess (Process.run p (Some (Array.map vstring args))))
+			| VString p, _ -> VAbstract (AProcess (Process.run p None))
 			| _ -> error()
 		));
 		"process_stdout_read", (Fun4 (fun p str pos len ->

+ 1 - 1
libs

@@ -1 +1 @@
-Subproject commit 803a97c581d8cce4649d62204498b84a758ca2c6
+Subproject commit 4c2fbca91d9cc2357dc5897bda7ddfb252c1a0ba

+ 4 - 1
std/neko/_std/sys/io/Process.hx

@@ -93,7 +93,10 @@ private class Stdout extends haxe.io.Input {
 	public var stdin(default,null) : haxe.io.Output;
 
 	public function new( cmd : String, ?args : Array<String> ) : Void {
-		p = try _run(untyped cmd.__s,neko.Lib.haxeToNeko(args)) catch( e : Dynamic ) throw "Process creation failure : "+cmd;
+		p = try 
+			_run(untyped cmd.__s, neko.Lib.haxeToNeko(args))
+		catch( e : Dynamic )
+			throw "Process creation failure : "+cmd;
 		stdin = new Stdin(p);
 		stdout = new Stdout(p,true);
 		stderr = new Stdout(p,false);

+ 7 - 0
tests/sys/src/TestCommandBase.hx

@@ -122,4 +122,11 @@ class TestCommandBase extends haxe.unit.TestCase {
 			assertEquals(code, exitCode);
 		}
 	}
+
+	function testRawCommand() {
+		var bin = sys.FileSystem.absolutePath(ExitCode.bin);
+		var native = sys.FileSystem.absolutePath(ExitCode.getNative());
+		var exitCode = run('$native 1 || $native 0');
+		assertEquals(0, exitCode);
+	}
 }

+ 0 - 7
tests/sys/src/TestSys.hx

@@ -28,11 +28,4 @@ class TestSys extends TestCommandBase {
 		Sys.setCwd(cur);
 	}
 	#end
-
-	function testRawCommand() {
-		var bin = sys.FileSystem.absolutePath(ExitCode.bin);
-		var native = sys.FileSystem.absolutePath(ExitCode.getNative());
-		var exitCode = run('$native 1 || $native 0');
-		assertEquals(0, exitCode);
-	}
 }