mooc/filesystem/usr/evalp2/archives/evalQ413.ses3

51 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
#xcrypted
# Auteur: Pascal Anelli
# adaptation session 2 : Denis Payet
# modification session 3: pascal ANELLI
# version 23 mars 2020
source ${LIBSH}/libeval.sh
#-----------------------------------------
rep=~/Sequence4/A41
dir=/tmp
challenge=C41Q3
scriptname=tagalice.sh
exo=$rep/$scriptname
sample="sample 1.tar.gz"
samplealice="sample 1_alice.tar.gz"
#---------------------------------
# Debut
firstcheck
# Create a sample file
[ -f "$dir/$sample" ] || touch "$dir/$sample"
[ -f "$dir/$samplealice" ] && rm $dir/$samplealice
# 1 working
$rep/$scriptname "$dir/$sample" &>/dev/null
step $(vraifaux $?) "Le script fonctionne " true
# 2 renaming
[ -f "$dir/$samplealice" ]
step $(vraifaux $?) "Le renommage du fichier est correct "
rm -f $dir/sample*
# 3 argument missing
$rep/$scriptname &>/dev/null
[ $? -eq 1 ]
step $(vraifaux $?) "Code de retour erreur en cas d'absence de l'argument"
# 4 error message
$rep/$scriptname 2>&1 | grep -q -i "Erreur" >/dev/null
step $(vraifaux $?) "En cas d'absence de l'argument, affichage du message ERREUR..."
#-----------------------------------------
# Fin
status "${challenge}_$res"
exit 0
# listcode = [ '000', 'aef', '13e', '9b0', 'c34' ]