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
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
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 "\
cd /tmp/$2 ; \
gcc -std=c11 -o binary -x c code.code ; \
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
#!/usr/bin/bash
runuser runner$1 -c "
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 "\
cd /tmp/$2 ; \
g++ -std=c++17 -o binary -x c++ code.code ; \
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
#!/bin/bash
runuser runner$1 -c "
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 "\
cd /tmp/$2 ; \
mcs $(echo code.code | sed 's/\///') -nowarn:0219 -out:binary ; \
cat args.args | xargs -d '\n' timeout -s KILL 3 mono binary < stdin.stdin"
#!/bin/bash
runuser runner$1 -c "
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 "cd /tmp/$2 ; timeout -s KILL 3 deno run code.code < stdin.stdin"
else
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 deno run code.code < stdin.stdin"
fi
runuser runner$1 -c "
cd /tmp/$2
timeout -s KILL 3 xargs -a args.args -d '\n' deno run code.code < stdin.stdin
"

View File

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

View File

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

View File

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

View File

@ -1,7 +1,8 @@
cd /tmp/$2
mv code.code code.hs
#!/bin/bash
runuser runner$1 -c "\
cd /tmp/$2 ; \
ghc -dynamic -o binary code.hs > /dev/null 2>&1 ; \
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
cd /tmp/$2
cp code.code code.hs
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
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
#!/bin/bash
runuser runner$1 -c "\
cd /tmp/$2 ; \
javac $name.java ; \
cat args.args | xargs -d '\n' timeout -s KILL 3 java $name < stdin.stdin"
cd /tmp/$2
name=$(grep -Po "(?<=\n|\A)\s*(public\s+)?(class|interface)\s+\K([^\/\\\n\s{]+)" code.code)
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
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
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
cp code.code code.kt
runuser runner$1 -c "\
cd /tmp/$2 ; \
kotlinc code.kt -include-runtime -d code.jar ; \
cat args.args | xargs -d '\n' timeout -s KILL 3 java -jar code.jar < stdin.stdin"
kotlinc code.kt -include-runtime -d code.jar
timeout -s KILL 3 xargs -a args.args -d '\n' java -jar code.jar < stdin.stdin
"

View File

@ -1,2 +1,6 @@
#!/bin/bash
runuser runner$1 -c "
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 "\
cd /tmp/$2 ; \
nasm -f elf32 -o binary.o code.code ; \
ld -m elf_i386 binary.o -o binary ; \
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2
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 "\
cd /tmp/$2 ; \
nasm -f elf64 -o binary.o code.code ; \
ld -m elf_x86_64 binary.o -o binary ; \
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
#!/bin/bash
runuser runner$1 -c "
cd /tmp/$2
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 "cd /tmp/$2 ; timeout -s KILL 3 node code.code < stdin.stdin"
else
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 node code.code < stdin.stdin"
fi
runuser runner$1 -c "
cd /tmp/$2
timeout -s KILL 3 xargs -a args.args -d '\n' node code.code < stdin.stdin
"

View File

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