Confirmation.bash tweaks

This commit is contained in:
Price Hiller 2021-07-31 18:45:47 -05:00
parent ea04075156
commit ba6ca6e2c2

View File

@ -2,6 +2,7 @@
confirmation() { confirmation() {
# Receive confirmation from user as y, Y, n, or N # Receive confirmation from user as y, Y, n, or N
# returns 0 when answer is yes and 1 when answer is no
# #
# Arguments: # Arguments:
# message <type: string> <position: 1> <required: true> # message <type: string> <position: 1> <required: true>
@ -24,8 +25,14 @@ confirmation() {
while true; do while true; do
read -p "${message} " -n 1 -r choice read -p "${message} " -n 1 -r choice
case "$choice" in case "$choice" in
y | Y) return 1 ;; y | Y)
n | N) return 0 ;; echo ""
return 0
;;
n | N)
echo ""
return 1
;;
*) echo -e "\nInput must be either y, Y, n, or N" ;; *) echo -e "\nInput must be either y, Y, n, or N" ;;
esac esac
done done