|
@@ -39,14 +39,29 @@ class Process {
|
|
|
public function new( cmd : String, ?args : Array<String> ) : Void
|
|
|
{
|
|
|
this.native = new NativeProcess();
|
|
|
- // mono 4.2.1 on Windows doesn't support relative path correctly
|
|
|
- if (cmd.indexOf("/") != -1 || cmd.indexOf("\\") != -1)
|
|
|
- cmd = sys.FileSystem.fullPath(cmd);
|
|
|
- native.StartInfo.FileName = cmd;
|
|
|
native.StartInfo.CreateNoWindow = true;
|
|
|
- native.StartInfo.Arguments = buildArgumentsString(args);
|
|
|
native.StartInfo.RedirectStandardError = native.StartInfo.RedirectStandardInput = native.StartInfo.RedirectStandardOutput = true;
|
|
|
- native.StartInfo.UseShellExecute = false;
|
|
|
+ if (args != null) {
|
|
|
+ // mono 4.2.1 on Windows doesn't support relative path correctly
|
|
|
+ if (cmd.indexOf("/") != -1 || cmd.indexOf("\\") != -1)
|
|
|
+ cmd = sys.FileSystem.fullPath(cmd);
|
|
|
+ native.StartInfo.FileName = cmd;
|
|
|
+ native.StartInfo.UseShellExecute = false;
|
|
|
+ native.StartInfo.Arguments = buildArgumentsString(args);
|
|
|
+ } else {
|
|
|
+ switch (Sys.systemName()) {
|
|
|
+ case "Windows":
|
|
|
+ native.StartInfo.FileName = switch (Sys.getEnv("COMSPEC")) {
|
|
|
+ case null: "cmd.exe";
|
|
|
+ case comspec: comspec;
|
|
|
+ }
|
|
|
+ native.StartInfo.Arguments = '/C "$cmd"';
|
|
|
+ case _:
|
|
|
+ native.StartInfo.FileName = "/bin/sh";
|
|
|
+ native.StartInfo.Arguments = buildArgumentsString(["-c", cmd]);
|
|
|
+ }
|
|
|
+ native.StartInfo.UseShellExecute = false;
|
|
|
+ }
|
|
|
|
|
|
native.Start();
|
|
|
|