diff --git a/docker/apl/run.sh b/docker/apl/run.sh index 581f1e7..ca97857 100644 --- a/docker/apl/run.sh +++ b/docker/apl/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.apl -apl --OFF -s -f program.apl +apl --OFF -s -f program.apl || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/bash/run.sh b/docker/bash/run.sh index 16bffa5..f2b44e4 100644 --- a/docker/bash/run.sh +++ b/docker/bash/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.sh -bash program.sh +bash program.sh || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/brainfuck/run.sh b/docker/brainfuck/run.sh index 46b195d..b9bdc7a 100644 --- a/docker/brainfuck/run.sh +++ b/docker/brainfuck/run.sh @@ -1 +1 @@ -printf %s "$1" | bf +printf %s "$1" | bf || true diff --git a/docker/c/run.sh b/docker/c/run.sh index ae6b9d3..bffd691 100644 --- a/docker/c/run.sh +++ b/docker/c/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.c -gcc program.c -o program && ./program +gcc program.c -o program && ./program || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/clojure/run.sh b/docker/clojure/run.sh index 4b2f897..43196d7 100644 --- a/docker/clojure/run.sh +++ b/docker/clojure/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.clj -clojure program.clj +clojure program.clj || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/cpp/run.sh b/docker/cpp/run.sh index b9236b9..b708d1f 100644 --- a/docker/cpp/run.sh +++ b/docker/cpp/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.cpp -g++ program.cpp -o program && ./program +g++ program.cpp -o program && ./program || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/csharp/run.sh b/docker/csharp/run.sh index d050032..934f897 100644 --- a/docker/csharp/run.sh +++ b/docker/csharp/run.sh @@ -4,7 +4,7 @@ else mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.cs - csc program.cs >/dev/null && mono program.exe + csc program.cs >/dev/null && mono program.exe || true cd .. && rm -rf "$CODEDIR" fi diff --git a/docker/elixir/run.sh b/docker/elixir/run.sh index 71a36e9..50d1768 100644 --- a/docker/elixir/run.sh +++ b/docker/elixir/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.exs -elixir program.exs +elixir program.exs || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/fsharp/run.sh b/docker/fsharp/run.sh index 79a7703..fe0fa14 100644 --- a/docker/fsharp/run.sh +++ b/docker/fsharp/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.fs -fsharpc --optimize- program.fs >/dev/null && mono program.exe +fsharpc --optimize- program.fs >/dev/null && mono program.exe || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/go/run.sh b/docker/go/run.sh index 642b42a..a6ee9a5 100644 --- a/docker/go/run.sh +++ b/docker/go/run.sh @@ -2,6 +2,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" export GOCACHE=/tmp/"$CODEDIR"/cache printf %s "$1" > program.go -go run program.go +go run program.go || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/haskell/run.sh b/docker/haskell/run.sh index 62c45b4..1017cb1 100644 --- a/docker/haskell/run.sh +++ b/docker/haskell/run.sh @@ -1,10 +1,10 @@ if [ "$EVAL_EXPR" = "true" ]; then - ghc -e "$1" + ghc -e "$1" || true else mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.hs - ghc -e main program.hs + ghc -e main program.hs || true cd .. && rm -rf "$CODEDIR" fi diff --git a/docker/java/run.sh b/docker/java/run.sh index 565e6f4..5f54b23 100644 --- a/docker/java/run.sh +++ b/docker/java/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > Main.java -javac Main.java && java Main +javac Main.java && java Main || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/javascript/run.sh b/docker/javascript/run.sh index d6a9e60..c82d76d 100644 --- a/docker/javascript/run.sh +++ b/docker/javascript/run.sh @@ -1,5 +1,5 @@ if [ "$EVAL_HARMONY" = "true" ]; then - printf %s "$1" | node --harmony -p + printf %s "$1" | node --harmony -p || true else - printf %s "$1" | node -p + printf %s "$1" | node -p || true fi diff --git a/docker/julia/run.sh b/docker/julia/run.sh index c299f35..24de6e6 100644 --- a/docker/julia/run.sh +++ b/docker/julia/run.sh @@ -1,5 +1,5 @@ if [ "$EVAL_EXPR" = "true" ]; then - printf %s "$1" | julia -E + printf %s "$1" | julia -E || true else - printf %s "$1" | julia -e + printf %s "$1" | julia -e || true fi diff --git a/docker/lua/run.sh b/docker/lua/run.sh index 6ac81b0..eea2f9f 100644 --- a/docker/lua/run.sh +++ b/docker/lua/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.lua -lua5.3 program.lua +lua5.3 program.lua || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/ocaml/run.sh b/docker/ocaml/run.sh index caccd04..2c56ae7 100644 --- a/docker/ocaml/run.sh +++ b/docker/ocaml/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.ml -ocamlopt -cclib --static -o program program.ml && ./program +ocamlopt -cclib --static -o program program.ml && ./program || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/pascal/run.sh b/docker/pascal/run.sh index 2d23489..26a3896 100644 --- a/docker/pascal/run.sh +++ b/docker/pascal/run.sh @@ -6,10 +6,9 @@ printf %s "$1" > program.pas res="$(fpc program.pas 2>&1)" if [ $? -eq 0 ]; then - ./program + ./program || true else - printf %s "$res" - exit 1 + printf %s "$res" fi cd .. && rm -rf "$CODEDIR" diff --git a/docker/perl/run.sh b/docker/perl/run.sh index 7778c41..12dda3e 100644 --- a/docker/perl/run.sh +++ b/docker/perl/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.pl -perl program.pl +perl program.pl || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/php/run.sh b/docker/php/run.sh index 082f83b..3e5631f 100644 --- a/docker/php/run.sh +++ b/docker/php/run.sh @@ -1 +1 @@ -printf %s "$1" | php -r +printf %s "$1" | php -r || true diff --git a/docker/prolog/run.sh b/docker/prolog/run.sh index 5a37620..7e6ad7a 100644 --- a/docker/prolog/run.sh +++ b/docker/prolog/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.pl -swipl --quiet program.pl +swipl --quiet program.pl || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/python2/run.sh b/docker/python2/run.sh index 7496968..3f782bb 100644 --- a/docker/python2/run.sh +++ b/docker/python2/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.py -python program.py +python program.py || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/python3/run.sh b/docker/python3/run.sh index 7496968..3f782bb 100644 --- a/docker/python3/run.sh +++ b/docker/python3/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.py -python program.py +python program.py || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/racket/run.sh b/docker/racket/run.sh index 60dd11d..e371054 100644 --- a/docker/racket/run.sh +++ b/docker/racket/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.rkt -racket program.rkt +racket program.rkt || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/ruby/run.sh b/docker/ruby/run.sh index 3146029..8090145 100644 --- a/docker/ruby/run.sh +++ b/docker/ruby/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.rb -ruby program.rb +ruby program.rb || true cd .. && rm -rf "$CODEDIR" diff --git a/docker/rust/run.sh b/docker/rust/run.sh index 8890f12..5b8eba6 100644 --- a/docker/rust/run.sh +++ b/docker/rust/run.sh @@ -1,6 +1,6 @@ mkdir "$CODEDIR" && cd "$CODEDIR" printf %s "$1" > program.rs -rustc -C opt-level=0 --color never program.rs && ./program +rustc -C opt-level=0 --color never program.rs && ./program || true cd .. && rm -rf "$CODEDIR" diff --git a/src/listeners/messageInvalid.js b/src/listeners/messageInvalid.js index c2ad835..8fe32e1 100644 --- a/src/listeners/messageInvalid.js +++ b/src/listeners/messageInvalid.js @@ -29,7 +29,13 @@ class MessageInvalidListener extends Listener { let errored = false; let result; try { - result = await this.client.languageHandler.evalCode(parse); + const { stdout, stderr } = await this.client.languageHandler.evalCode(parse); + if (stderr) { + errored = true; + result = stderr; + } else { + result = stdout; + } } catch (e) { errored = true; result = e.message; diff --git a/src/struct/LanguageHandler.js b/src/struct/LanguageHandler.js index 06c2207..f20df39 100644 --- a/src/struct/LanguageHandler.js +++ b/src/struct/LanguageHandler.js @@ -155,14 +155,15 @@ class LanguageHandler extends AkairoHandler { }, timeout); } - let data = ''; + let stdout = ''; + let stderr = ''; let error; proc.stdout.on('data', chunk => { - data += chunk; + stdout += chunk; }); proc.stderr.on('data', chunk => { - data += chunk; + stderr += chunk; }); proc.on('error', e => { @@ -174,12 +175,12 @@ class LanguageHandler extends AkairoHandler { handled = true; if (status !== 0 || error) { if (!error) { - error = new Error(data || 'Something went wrong'); + error = new Error(stderr || 'Something went wrong'); } reject(error); } else { - resolve(data); + resolve({ stdout, stderr }); } } });