Skip to content

Commit eba7fa7

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

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

stdlib-install.sh

Lines changed: 18 additions & 9 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,14 +55,19 @@ 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
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+
elif ! [ -x "$(command -v $AGDA_EXEC)" ]; then
6271
throwError "'$AGDA_EXEC' is not a valid executable"
6372
fi
6473

@@ -141,7 +150,7 @@ if [ -d "$STDLIB_DIR_NAME" ]; then
141150
case "$DIR_OVERWRITE" in
142151
[yY]*) DIR_OVERWRITE="y"; break;;
143152
[nN]*) DIR_OVERWRITE="n"; break;;
144-
*) echo "Please answer y or n.";;
153+
*) logUnhappy "Invalid answer: '$DIR_OVERWRITE'. Please answer y or n.";;
145154
esac
146155
done
147156
if [ "$DIR_OVERWRITE" = "y" ]; then

0 commit comments

Comments
 (0)