Skip to content

Commit 2617ddb

Browse files
committed
heredoc!
1 parent 163928b commit 2617ddb

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎v4-cokapi/backends/java/run-java-backend.sh‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# expects as input, such as: java_jail/cp/traceprinter/test-input.txt
55

66
# this will be run within Docker
7-
echo $1 | java -cp /tmp/java_jail/cp:/tmp/java_jail/cp/javax.json-1.0.jar:/usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar traceprinter.InMemory
87

9-
#echo '{ "usercode": "public class Test { public static void main(String[] args) { int x = 3; x += x; } }", "options": {}, "args": [], "stdin": "" }' | java -cp /tmp/java_jail/cp:/tmp/java_jail/cp/javax.json-1.0.jar:/usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar traceprinter.InMemory
8+
# tricky! use a heredoc to pipe the $1 argument into the stdin of the
9+
# java executable WITHOUT interpreting escape chars such as '\n' ...
10+
# echo doesn't work here since it interprets '\n' and other chars
11+
cat <<ENDEND | java -cp /tmp/java_jail/cp:/tmp/java_jail/cp/javax.json-1.0.jar:/usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar traceprinter.InMemory
12+
$1
13+
ENDEND

0 commit comments

Comments
 (0)