-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun-kontrol.sh
executable file
·70 lines (66 loc) · 1.68 KB
/
run-kontrol.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -uxo pipefail
run_folder() {
local folder=$1
if [ -d "$folder" ]; then
folder=$(basename "$folder")
cd "$folder" || exit
if [ -x "./run-kontrol.sh" ]; then
echo "Running Kontrol in $folder."
./run-kontrol.sh || true
else
echo "No executable run-kontrol.sh found in $folder."
fi
cd ..
fi
}
clean_folder() {
local folder=$1
if [ -d "$folder" ]; then
folder=$(basename "$folder")
cd "$folder" || exit
if [ -n "${FOUNDRY_PROFILE+x}" ]; then
echo "Found Foundry profile $FOUNDRY_PROFILE"
kontrol clean
unset FOUNDRY_PROFILE
fi
if [ "$folder" = "3-proof-debugging" ]; then
FOUNDRY_PROFILE=lemmas kontrol clean
unset FOUNDRY_PROFILE
fi
kontrol clean
echo "Cleaned $folder"
cd ..
fi
}
error_message() {
echo "Provide no arguments to execute all folders."
echo "Provide one folder name to execute it individually."
echo "Provide 'clean' to clean all folders"
echo "Provide 'clean \$folder' to clean \$folder"
exit 1
}
if [ "$#" -eq 0 ]; then
for folder in ./*; do
run_folder "$folder"
done
elif [ "$#" -eq 1 ]; then
if [ -d "$1" ]; then
run_folder "$1"
elif [ "$1" = "clean" ]; then
for folder in ./*; do
clean_folder "$folder"
done
else
echo "$1 is not a folder nor 'clean'!"
exit 1
fi
elif [ "$#" -eq 2 ]; then
if [ "$1" = "clean" ] && [ -d "$2" ]; then
clean_folder "$2"
else
error_message
fi
else
error_message
fi