From bf902f4f7ebc8ec96cbee710b900f8d4f11ed3f4 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 18 Aug 2023 22:46:49 +0200 Subject: [PATCH] warn if user does not supply y/n in askYesOrNo --- src/utility/ask.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utility/ask.sh b/src/utility/ask.sh index 30a49b61..83610f3a 100644 --- a/src/utility/ask.sh +++ b/src/utility/ask.sh @@ -60,5 +60,12 @@ function askYesOrNo() { printf "\n" logInfo "no user interaction after %s seconds, going to interpret that as a 'no'." "$timeout" fi - [[ $answer == y ]] || [[ $answer == Y ]] + if [[ $answer == y ]] || [[ $answer == Y ]]; then + return 0 + elif [[ $answer == n ]] || [[ $answer == N ]]; then + return 1 + else + logWarning "got \033[0;36m%s\033[0m as answer (instead of y for yes or n for no), interpreting it as a n, i.e. as a no" "$answer" + return 1 + fi }