69 lines
1.6 KiB
Plaintext
69 lines
1.6 KiB
Plaintext
|
#!/bin/bash
|
||
|
#xcrypted
|
||
|
|
||
|
# Auteur: Pascal ANELLI
|
||
|
# Session 4
|
||
|
# Decembre 2022
|
||
|
|
||
|
source ${LIBSH}/libeval.sh
|
||
|
|
||
|
#-----------------------------------------
|
||
|
rep=~/Sequence4/A45
|
||
|
challenge=C45Q2
|
||
|
scriptname=func.sh
|
||
|
exo=$rep/$scriptname
|
||
|
sample=~/Sequence4/A45
|
||
|
#---------------------------------
|
||
|
|
||
|
catch() {
|
||
|
echo "Erreur dans le fichier $exo evalution arretee"
|
||
|
exit 1
|
||
|
}
|
||
|
trap 'catch' ERR
|
||
|
|
||
|
# Debut
|
||
|
banniere $challenge
|
||
|
echo "** Debut evaluation ***" |tee -a $log
|
||
|
|
||
|
if [ ! -f $rep/$scriptname ]
|
||
|
then
|
||
|
echo "Attention: Votre script doit s'appeler $scriptname, etre dans le repertoire $rep" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# 1 sourcing
|
||
|
source $exo
|
||
|
step $(vraifaux $?) "Le chargement du fichier s'effectue sans erreur " true
|
||
|
|
||
|
# 2 cd is a function
|
||
|
type cd 2>&1 | grep -q function
|
||
|
step $(vraifaux $?) "cd est une fonction " true
|
||
|
|
||
|
# 3 cd uses command or buildin
|
||
|
tr -s '\t' ' ' <$scriptname | grep -q "command cd" || grep -q "buildin cd"
|
||
|
step $(vraifaux $?) "La commande cd interne est appelee " true
|
||
|
|
||
|
# 4 cd is working
|
||
|
cd ~ &>/dev/null
|
||
|
[ $(pwd) == ~ ]
|
||
|
step $(vraifaux $?) "La fonction cd fonctionne "
|
||
|
|
||
|
# 5 display.
|
||
|
display=$(cd $sample 2>/dev/null)
|
||
|
[ -n "$display" ]
|
||
|
step $(vraifaux $?) "Un resultat s'affiche "
|
||
|
|
||
|
# 6 accuracy
|
||
|
cd $sample | grep -q "Sequence4/A45" &>/dev/null
|
||
|
step $(vraifaux $?) "Le message indique le nouveau répertoire "
|
||
|
|
||
|
|
||
|
#--------------------------------
|
||
|
# Fin
|
||
|
status "${challenge}_$res"
|
||
|
exit 0
|
||
|
|
||
|
#---- evaluation code
|
||
|
#listcode = [ '000', 'a7b', 'f97', 'e51', 'aa4', '2dc', '794' ]
|
||
|
#-----
|