Skip to content

Commit ef6648d

Browse files
committed
add (unix only) nqp::shell for jvm
sorear++
1 parent 6602633 commit ef6648d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,7 @@ QAST::OperationsJAST.map_classlib_core_op('mkdir', $TYPE_OPS, 'mkdir', [$RT_STR,
19011901
QAST::OperationsJAST.map_classlib_core_op('rename', $TYPE_OPS, 'rename', [$RT_STR, $RT_STR], $RT_INT);
19021902
QAST::OperationsJAST.map_classlib_core_op('copy', $TYPE_OPS, 'copy', [$RT_STR, $RT_STR], $RT_INT);
19031903
QAST::OperationsJAST.map_classlib_core_op('link', $TYPE_OPS, 'link', [$RT_STR, $RT_STR], $RT_INT);
1904+
QAST::OperationsJAST.map_classlib_core_op('shell', $TYPE_OPS, 'shell', [$RT_STR], $RT_INT);
19041905
QAST::OperationsJAST.map_classlib_core_op('symlink', $TYPE_OPS, 'symlink', [$RT_STR, $RT_STR], $RT_INT);
19051906

19061907

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,21 @@ public static long link(String before, String after) {
611611
}
612612
return 0;
613613
}
614+
615+
public static long shell(String cmd) {
616+
long retval = 255;
617+
try {
618+
Process proc = new ProcessBuilder("sh", "-c", cmd)
619+
.inheritIO().start();
620+
proc.waitFor();
621+
retval = proc.exitValue();
622+
}
623+
catch (IOException e) {
624+
}
625+
catch (InterruptedException e) {
626+
}
627+
return retval;
628+
}
614629

615630
public static long symlink(String before, String after) {
616631
Path before_o = Paths.get(before);

0 commit comments

Comments
 (0)