Skip to content

Commit 3037ebf

Browse files
committed
[ ergonomics ] make more of an effort
Keep asking the user until we get a valid Agda executable
1 parent 493080f commit 3037ebf

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

stdlib-install.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ logHappy() {
2222
echo "\033[32m✔\033[0m $1"
2323
}
2424

25+
logUnhappy() {
26+
echo "\033[91m✗\033[0m $1."
27+
}
28+
2529
logWarning() {
2630
echo "\033[93m⚠\033[0m $1"
2731
}
@@ -51,15 +55,23 @@ checkDependency "wget"
5155
# Pick the Agda executable to analyse
5256
# unless the caller has specified one
5357
if [ -z ${AGDA_EXEC-} ]; then
54-
read -p "What's the name of your Agda executable (default: agda)? " AGDA_EXEC
55-
if [ -z "$AGDA_EXEC" ]; then
56-
AGDA_EXEC=agda
57-
fi
58-
fi
59-
60-
# Double check that the command exists
61-
if ! [ -x "$(command -v $AGDA_EXEC)" ]; then
62-
throwError "'$AGDA_EXEC' is not a valid executable"
58+
while true; do
59+
read -p "What's the name of your Agda executable (default: agda)? " AGDA_EXEC
60+
if [ -z "$AGDA_EXEC" ]; then
61+
AGDA_EXEC=agda
62+
fi
63+
# Double check that the command exists
64+
if ! [ -x "$(command -v $AGDA_EXEC)" ]; then
65+
logUnhappy "'$AGDA_EXEC' is not a valid executable"
66+
else
67+
break
68+
fi
69+
done
70+
else
71+
# Double check that the command exists
72+
if ! [ -x "$(command -v $AGDA_EXEC)" ]; then
73+
throwError "'$AGDA_EXEC' is not a valid executable"
74+
fi
6375
fi
6476

6577
logHappy "Agda executable: $AGDA_EXEC"
@@ -141,7 +153,7 @@ if [ -d "$STDLIB_DIR_NAME" ]; then
141153
case "$DIR_OVERWRITE" in
142154
[yY]*) DIR_OVERWRITE="y"; break;;
143155
[nN]*) DIR_OVERWRITE="n"; break;;
144-
*) echo "Please answer y or n.";;
156+
*) logUnhappy "Invalid answer: '$DIR_OVERWRITE'. Please answer y or n.";;
145157
esac
146158
done
147159
if [ "$DIR_OVERWRITE" = "y" ]; then

0 commit comments

Comments
 (0)