Skip to content

Commit

Permalink
warn if user does not supply y/n in askYesOrNo
Browse files Browse the repository at this point in the history
  • Loading branch information
robstoll committed Aug 18, 2023
1 parent 7a69d30 commit bf902f4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/utility/ask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit bf902f4

Please sign in to comment.