Make it work with non-executable scripts

This commit is contained in:
xpetit 2021-06-30 19:26:59 +02:00
parent d7e724d52e
commit dd0b515691
No known key found for this signature in database
GPG Key ID: 97C60669182C17A5
9 changed files with 18 additions and 19 deletions

View File

@ -8,8 +8,8 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/mastertheLS)
expected=$(cd "$1" && "$script_dirS"/solutions/mastertheLS)
submitted=$(cd "$1" && bash "$script_dirS"/student/mastertheLS)
expected=$(cd "$1" && bash "$script_dirS"/solutions/mastertheLS)
diff <(echo "$submitted") <(echo "$expected")
}

View File

@ -8,8 +8,8 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/look)
expected=$(cd "$1" && "$script_dirS"/solutions/look)
submitted=$(cd "$1" && bash "$script_dirS"/student/look)
expected=$(cd "$1" && bash "$script_dirS"/solutions/look)
diff <(echo "$submitted") <(echo "$expected")
}

View File

@ -9,8 +9,8 @@ echo insecure >> ~/.curlrc
caddy start &>/dev/null
challenge() {
submitted=$(./student/myfamily.sh)
expected=$(./solutions/myfamily.sh)
submitted=$(bash student/myfamily.sh)
expected=$(bash solutions/myfamily.sh)
diff <(echo "$submitted") <(echo "$expected")
}

View File

@ -8,8 +8,8 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/lookagain.sh)
expected=$(cd "$1" && "$script_dirS"/solutions/lookagain.sh)
submitted=$(cd "$1" && bash "$script_dirS"/student/lookagain.sh)
expected=$(cd "$1" && bash "$script_dirS"/solutions/lookagain.sh)
diff <(echo "$submitted") <(echo "$expected")
}

View File

@ -8,8 +8,8 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/countfiles.sh)
expected=$(cd "$1" && "$script_dirS"/solutions/countfiles.sh)
submitted=$(cd "$1" && bash "$script_dirS"/student/countfiles.sh)
expected=$(cd "$1" && bash "$script_dirS"/solutions/countfiles.sh)
diff <(echo "$submitted") <(echo "$expected")
}

View File

@ -7,7 +7,7 @@ IFS='
cd cl-camp8
submitted=$(../student/skip.sh)
expected=$(../solutions/skip.sh)
submitted=$(bash ../student/skip.sh)
expected=$(bash ../solutions/skip.sh)
diff <(echo "$submitted") <(echo "$expected")

View File

@ -5,8 +5,8 @@ set -euo pipefail
IFS='
'
submitted=$(student/explain.sh)
expected=$(solutions/explain.sh)
submitted=$(bash student/explain.sh)
expected=$(bash solutions/explain.sh)
if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then
echo "Wrong answer, detective."

View File

@ -5,8 +5,8 @@ set -euo pipefail
IFS='
'
submitted=$(student/my_answer.sh)
expected=$(solutions/my_answer.sh)
submitted=$(bash student/my_answer.sh)
expected=$(bash solutions/my_answer.sh)
if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then
echo "Wrong answer, detective."

View File

@ -7,10 +7,9 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/teacher.sh) || (echo "Your script exited with a non-zero status code"; exit 1)
expected=$(cd "$1" && "$script_dirS"/solutions/teacher.sh)
submitted=$(cd "$1" && bash "$script_dirS"/student/teacher.sh) || (echo "Your script exited with a non-zero status code"; exit 1)
expected=$(cd "$1" && bash "$script_dirS"/solutions/teacher.sh)
if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then
echo "??? What ?? Wrong answer, teacher. Did you really do the job previously? Or was is just an \"echo\" of luck??"