Confirmation.bash tweaks
This commit is contained in:
parent
ea04075156
commit
ba6ca6e2c2
@ -2,6 +2,7 @@
|
||||
|
||||
confirmation() {
|
||||
# Receive confirmation from user as y, Y, n, or N
|
||||
# returns 0 when answer is yes and 1 when answer is no
|
||||
#
|
||||
# Arguments:
|
||||
# message <type: string> <position: 1> <required: true>
|
||||
@ -22,10 +23,16 @@ confirmation() {
|
||||
local choice
|
||||
|
||||
while true; do
|
||||
read -p "${message}" -n 1 -r choice
|
||||
read -p "${message} " -n 1 -r choice
|
||||
case "$choice" in
|
||||
y | Y) return 1 ;;
|
||||
n | N) return 0 ;;
|
||||
y | Y)
|
||||
echo ""
|
||||
return 0
|
||||
;;
|
||||
n | N)
|
||||
echo ""
|
||||
return 1
|
||||
;;
|
||||
*) echo -e "\nInput must be either y, Y, n, or N" ;;
|
||||
esac
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user