forked from MarcVillain/Confloose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·52 lines (43 loc) · 889 Bytes
/
run.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
scripts_count=${#scripts[@]}
# Display all scripts
display_scripts()
{
echo "Scripts:"
i=1
for script in ${scripts[@]}; do
echo " $i) $script"
i=$((i+1))
done
echo
echo " 0) quit"
echo
}
display_scripts
while true; do
# Ask for input
echo -n "Select: "
read selected
# Check input is numeric
re='^[0-9]+$'
if ! [[ $selected =~ $re ]] ; then
echo "error: Not a number" >&2
selected=-1
continue
fi
# Check input is in bounds
if [ $selected -gt $scripts_count ]; then
echo "error: Input value too high"
selected=-1
continue
fi
# Handle exit option (value 0)
if [ $selected -eq 0 ]; then
break
fi
echo "-----"
index=$((selected - 1))
eval "run_${scripts[$index]}"
echo "-----"
display_scripts
done