Fix stdin for most languages

This commit is contained in:
Vrganj 2021-01-17 00:54:57 +00:00
parent b7ba08ccdf
commit 008d55643b
26 changed files with 172 additions and 103 deletions

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 bash code.code < stdin.stdin" xargs -a args.args -d '\n' timeout -s KILL 3 bash code.code < stdin.stdin
"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 brainfuck code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' brainfuck code.code < stdin.stdin
"

View File

@ -1,4 +1,7 @@
runuser runner$1 -c "\ #!/usr/bin/bash
cd /tmp/$2 ; \
gcc -std=c11 -o binary -x c code.code ; \ runuser runner$1 -c "
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin" cd /tmp/$2
gcc -std=c11 -o binary -x c code.code
timeout -s KILL 3 xargs -a args.args ./binary < stdin.stdin
"

View File

@ -1,4 +1,7 @@
runuser runner$1 -c "\ #!/bin/bash
cd /tmp/$2 ; \
g++ -std=c++17 -o binary -x c++ code.code ; \ runuser runner$1 -c "
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin" cd /tmp/$2
g++ -std=c++17 -o binary -x c++ code.code
timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin
"

View File

@ -1,4 +1,7 @@
runuser runner$1 -c "\ #!/bin/bash
cd /tmp/$2 ; \
mcs $(echo code.code | sed 's/\///') -nowarn:0219 -out:binary ; \ runuser runner$1 -c "
cat args.args | xargs -d '\n' timeout -s KILL 3 mono binary < stdin.stdin" cd /tmp/$2
mcs $(echo code.code | sed 's/\///') -nowarn:0219 -out:binary
timeout -s KILL 3 xargs -a args.args -d '\n' mono binary < stdin.stdin
"

View File

@ -1,7 +1,6 @@
cd /tmp/$2 #!/bin/bash
if [[ -z $(grep '[^[:space:]]' args.args) ]]; then runuser runner$1 -c "
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 deno run code.code < stdin.stdin" cd /tmp/$2
else timeout -s KILL 3 xargs -a args.args -d '\n' deno run code.code < stdin.stdin
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 deno run code.code < stdin.stdin" "
fi

View File

@ -1,7 +1,6 @@
cd /tmp/$2 #!/bin/bash
if [[ -z $(grep '[^[:space:]]' args.args) ]]; then runuser runner$1 -c "
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 elixir code.code" cd /tmp/$2
else timeout -s KILL 3 xargs -a args.args -d '\n' elixir code.code < stdin.stdin
runuser runner$1 -c "cd /tmp/$2 ; cat args.args ; xargs -d '\n' timeout -s KILL 3 elixir code.code < stdin.stdin" "
fi

View File

@ -1,7 +1,6 @@
cd /tmp/$2 #!/bin/bash
if [[ -z $(grep '[^[:space:]]' args.args) ]]; then runuser runner$1 -c "
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 emacs -Q --script code.code" cd /tmp/$2
else timeout -s KILL 3 xargs -a args.args -d '\n' emacs -Q --script code.code < stdin.stdin
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 emacs -Q --script code.code < stdin.stdin" "
fi

View File

@ -1,6 +1,8 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
cp code.code interim.go cp code.code interim.go
file="interim.go" go build interim.go
go build $file timeout -s KILL 3 xargs -a args.args -d '\n' ./interim < stdin.stdin
file=${file%%.*} "
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 ./$file < stdin.stdin"

View File

@ -1,7 +1,8 @@
cd /tmp/$2 #!/bin/bash
mv code.code code.hs
runuser runner$1 -c "\ runuser runner$1 -c "\
cd /tmp/$2 ; \ cd /tmp/$2
ghc -dynamic -o binary code.hs > /dev/null 2>&1 ; \ cp code.code code.hs
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin" ghc -dynamic -o binary code.hs > /dev/null 2>&1
timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin
"

View File

@ -1,9 +1,11 @@
cd /tmp/$2 #!/bin/bash
cp code.code interim.java
name=$(grep -Po "(?<=\n|\A)\s*(public\s+)?(class|interface)\s+\K([^\/\\\n\s{]+)" interim.java)
mv interim.java $name.java
runuser runner$1 -c "\ cd /tmp/$2
cd /tmp/$2 ; \ name=$(grep -Po "(?<=\n|\A)\s*(public\s+)?(class|interface)\s+\K([^\/\\\n\s{]+)" code.code)
javac $name.java ; \
cat args.args | xargs -d '\n' timeout -s KILL 3 java $name < stdin.stdin" runuser runner$1 -c "
cd /tmp/$2
cp code.code $name.java
javac $name.java
timeout -s KILL 3 xargs -a args.args -d '\n' java $name < stdin.stdin
"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 jelly fu code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' jelly fu code.code < stdin.stdin
"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 julia code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' julia code.code < stdin.stdin
"

View File

@ -1,6 +1,8 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
cp code.code code.kt cp code.code code.kt
runuser runner$1 -c "\ kotlinc code.kt -include-runtime -d code.jar
cd /tmp/$2 ; \ timeout -s KILL 3 xargs -a args.args -d '\n' java -jar code.jar < stdin.stdin
kotlinc code.kt -include-runtime -d code.jar ; \ "
cat args.args | xargs -d '\n' timeout -s KILL 3 java -jar code.jar < stdin.stdin"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 lua code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' lua code.code < stdin.stdin
"

View File

@ -1,5 +1,8 @@
runuser runner$1 -c "\ #!/bin/bash
cd /tmp/$2 ; \
nasm -f elf32 -o binary.o code.code ; \ runuser runner$1 -c "
ld -m elf_i386 binary.o -o binary ; \ cd /tmp/$2
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin" nasm -f elf32 -o binary.o code.code
ld -m elf_i386 binary.o -o binary
timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin
"

View File

@ -1,5 +1,8 @@
runuser runner$1 -c "\ #!/bin/bash
cd /tmp/$2 ; \
nasm -f elf64 -o binary.o code.code ; \ runuser runner$1 -c "
ld -m elf_x86_64 binary.o -o binary ; \ cd /tmp/$2
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin" nasm -f elf64 -o binary.o code.code
ld -m elf_x86_64 binary.o -o binary
timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin
"

View File

@ -1,7 +1,6 @@
cd /tmp/$2 #!/bin/bash
if [[ -z $(grep '[^[:space:]]' args.args) ]]; then runuser runner$1 -c "
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 node code.code < stdin.stdin" cd /tmp/$2
else timeout -s KILL 3 xargs -a args.args -d '\n' node code.code < stdin.stdin
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 node code.code < stdin.stdin" "
fi

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 perl code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' perl code.code < stdin.stdin
"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 php code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' php code.code < stdin.stdin
"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 python code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' python code.code < stdin.stdin
"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 python3.8 code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' python3.8 code.code < stdin.stdin
"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 ruby code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' ruby code.code < stdin.stdin
"

View File

@ -1,5 +1,9 @@
#!/bin/bash
cd /tmp/$2 cd /tmp/$2
rustc -o binary code.code rustc -o binary code.code
runuser runner$1 -c "\
cd /tmp/$2 ; \ runuser runner$1 -c "
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin" cd /tmp/$2
timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin
"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2 cd /tmp/$2
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 swift code.code < stdin.stdin" timeout -s KILL 3 xargs -a args.args -d '\n' swift code.code < stdin.stdin
"

View File

@ -1,7 +1,10 @@
runuser runner$1 -c "\ #!/bin/bash
cd /tmp/$2 ; \
mv code.code interim.ts ; \ runuser runner$1 -c "
tsc interim.ts ; \ cd /tmp/$2
rm -f interim.ts ; \ mv code.code interim.ts
mv interim.js code.code ; \ tsc interim.ts
cat args.args | xargs -d '\n' timeout -s KILL 3 node code.code < stdin.stdin" rm -f interim.ts
mv interim.js code.code
xargs -a args.args -d '\n' timeout -s KILL 3 node code.code < stdin.stdin
"