1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-01-11 05:48:01 -05:00

Run powershell -Command instead of cmd /c

This commit is contained in:
Reinhard Pointner 2017-02-05 16:12:31 +08:00
parent 407a7074e6
commit 2efc3c17fa

View File

@ -289,23 +289,17 @@ public abstract class ScriptShellBaseClass extends Script {
} }
public int execute(Object... args) throws Exception { public int execute(Object... args) throws Exception {
List<String> cmd = new ArrayList<String>(); Stream<String> cmd = stream(args).map(Objects::toString);
if (Platform.isWindows()) { if (Platform.isWindows()) {
// normalize file separator for windows and run with powershell so any executable in PATH will just work // normalize file separator for windows and run with powershell so any executable in PATH will just work
cmd.add("powershell"); cmd = Stream.concat(Stream.of("powershell", "-Command"), cmd);
cmd.add("-Command");
} else if (args.length == 1) { } else if (args.length == 1) {
// make unix shell parse arguments // make Unix shell parse arguments
cmd.add("sh"); cmd = Stream.concat(Stream.of("sh", "-c"), cmd);
cmd.add("-c");
} }
for (Object it : args) { ProcessBuilder process = new ProcessBuilder(cmd.toArray(String[]::new)).inheritIO();
cmd.add(it.toString());
}
ProcessBuilder process = new ProcessBuilder(cmd).inheritIO();
return process.start().waitFor(); return process.start().waitFor();
} }