Skip to content

Commit d40c35b

Browse files
authored
The shell function must return the exit code and redirect the stdout and stderr only when is modal. (#531)
Issue 95035
1 parent fbe0474 commit d40c35b

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

java/src/main/java/com/genexus/GXutil.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,17 +1100,25 @@ public static byte shell(String cmd, int modal)
11001100
{
11011101
try
11021102
{
1103-
List<String> al = Arrays.asList(cmd.split(" "));
1104-
ProcessBuilder pb = new ProcessBuilder(al);
1105-
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
1106-
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
1107-
pb.redirectInput(ProcessBuilder.Redirect.INHERIT);
1108-
Process p = pb.start();
1103+
if (modal == 0)
1104+
{
1105+
Runtime.getRuntime().exec(cmd);
1106+
return 0;
1107+
}
1108+
else
1109+
{
1110+
List<String> al = Arrays.asList(cmd.split(" "));
1111+
ProcessBuilder pb = new ProcessBuilder(al);
1112+
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
1113+
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
1114+
pb.redirectInput(ProcessBuilder.Redirect.INHERIT);
1115+
Process p = pb.start();
11091116

1110-
byte exitCode = (byte)p.waitFor();
1117+
byte exitCode = (byte) p.waitFor();
11111118

1112-
p.destroy();
1113-
return exitCode;
1119+
p.destroy();
1120+
return exitCode;
1121+
}
11141122
}
11151123
catch (Exception e)
11161124
{

0 commit comments

Comments
 (0)