73 lines
1.4 KiB
Plaintext
73 lines
1.4 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
# Tahiry Razafindralambo
|
||
|
# v1.0 du 2019.05.30
|
||
|
# Pascal ANELLI
|
||
|
# v2.0 du 2020.03.30
|
||
|
# Session 3
|
||
|
|
||
|
source ${LIBSH}/libeval.sh
|
||
|
|
||
|
a=2
|
||
|
b=3
|
||
|
|
||
|
#--------------
|
||
|
challenge=C34Q3b
|
||
|
#--------------
|
||
|
# Debut
|
||
|
banniere $challenge
|
||
|
|
||
|
readline
|
||
|
|
||
|
|
||
|
# 1 doit contenir la commande expr
|
||
|
[ $(echo "$line" | grep -c 'expr') -eq 0 ]
|
||
|
step $(vraifaux $?) "Votre commande ne contient pas la commande expr" true
|
||
|
|
||
|
# 2 doit contenir un ((
|
||
|
[ $(echo "$line" | grep -c "((") -ne 0 ]
|
||
|
step $(vraifaux $?) "Il y a l'operateur abrege de let"
|
||
|
|
||
|
# 3 doit contenir un i
|
||
|
[ $(echo "$line" | grep -c "i") -ne 0 ]
|
||
|
step $(vraifaux $?) "Il y a la variable i"
|
||
|
|
||
|
# 4 doit contenir un a
|
||
|
[ $(echo "$line" | grep -c "a") -ne 0 ]
|
||
|
step $(vraifaux $?) "Il y a la variable a"
|
||
|
|
||
|
# 5 doit contenir un b
|
||
|
[ $(echo "$line" | grep -c "b") -ne 0 ]
|
||
|
step $(vraifaux $?) "Il y a la variable b"
|
||
|
|
||
|
err="$(mktemp)"
|
||
|
fres="$(mktemp)"
|
||
|
|
||
|
eval $line 1>$fres 2>$err
|
||
|
echo "$i" > "$fres"
|
||
|
|
||
|
|
||
|
# 6 le fichier d'erreur doit etre vide
|
||
|
[ ! -s "$err" ]
|
||
|
step $(vraifaux $?) "Votre calcul est sans erreur" true
|
||
|
|
||
|
# 7 un resultat existe
|
||
|
[ -s "$fres" ]
|
||
|
step $(vraifaux $?) "Un resultat a ete produit" true
|
||
|
|
||
|
# 8 accuracy
|
||
|
[ $(cat "$fres") == "6" ]
|
||
|
step $(vraifaux $?) "Le resultat est juste"
|
||
|
|
||
|
|
||
|
echo -e "\n Le resultat de votre calcul est: $(cat "$fres") \n"
|
||
|
|
||
|
#--------------------------------
|
||
|
# Fin
|
||
|
status "${challenge}_$res"
|
||
|
|
||
|
rm -f "$fres" "$err"
|
||
|
exit 0
|
||
|
|
||
|
|