53 lines
1.4 KiB
Bash
53 lines
1.4 KiB
Bash
#!/bin/bash
|
|
#xcrypted
|
|
# Auteur: Pascal Anelli
|
|
# adaptation session 2 : Denis Payet
|
|
|
|
source ${LIBSH}/libeval.sh
|
|
|
|
#-----------------------------------------
|
|
rep=/home/alice/Sequence4/A44
|
|
challenge=C44Q2
|
|
scriptname=size_movie_mkv.sh
|
|
#---------------------------------
|
|
# Debut
|
|
firstcheck
|
|
|
|
# 1 working
|
|
number=$($rep/$scriptname)
|
|
step $(vraifaux $?) "Le script fonctionne correctement"
|
|
|
|
# 2 display
|
|
[ -n "$number" ]
|
|
step $(vraifaux $?) "Le resultat est affiche"
|
|
|
|
# THE good value
|
|
declare -i taille=0 # taille total
|
|
for file in $(ls /home/alice/Movies/*.mkv)
|
|
do
|
|
sizes=$(ls -l $file | tr -s ' ' | cut -d' ' -f5)
|
|
((taille+=sizes))
|
|
done
|
|
|
|
# 3 is integer
|
|
#isinteger "$number" && ((res+=1)) || echo "Le resultat n'est pas un entier"
|
|
isinteger "$number"
|
|
step $(vraifaux $?) "Le resultat est un entier" true
|
|
|
|
# 4 accuracy
|
|
typeset -i total=$number
|
|
[ "$total" -eq "$taille" ]
|
|
step $(vraifaux $?) "Le calcul est correct"
|
|
|
|
# 5 for
|
|
grep -q for $rep/$scriptname 2>/dev/null
|
|
[ $? -eq 1 ]
|
|
step $(vraifaux $?) "Le script fait le bon traitement"
|
|
|
|
#-------------------------------------
|
|
# Fin
|
|
status "${challenge}_$res"
|
|
exit 0
|
|
|
|
# listcode = [ '000', '144', '59a', 'e90', '3fb' ]
|