-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathselect.sh
37 lines (31 loc) · 840 Bytes
/
select.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
echo "Veuillez sélectionner une commande git parmi les suivantes :"
for dirPath in ./*; do
if [ -d "$dirPath" ]; then
prefix="./"
dirName=${dirPath#"$prefix"}
echo " - $dirName"
fi
done
read command
# The user did not write anything.
if [ -z "$command" ]
then
echo "ERREUR : La commande est introuvable!"
exit
fi
# The directory does not exists.
if [ ! -d ./$command ]
then
echo "ERREUR : La commande est introuvable!"
exit
fi
exercicesCount=`find ./$command/* -maxdepth 0 -type d | wc -l`
echo "Veuillez sélectionner un numéro d'exercice (entre 1 et $exercicesCount):"
read exerciceId
if [ $exerciceId -lt 1 -o $exerciceId -gt $exercicesCount ]
then
echo "ERREUR : L'exercice est introuvable!"
exit
fi
./configureAndStartExercice.sh `pwd` $command $exerciceId