Confirmation.bash tweaks
This commit is contained in:
parent
ea04075156
commit
ba6ca6e2c2
@ -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>
|
||||||
@ -22,10 +23,16 @@ confirmation() {
|
|||||||
local choice
|
local choice
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user