2
0
mirror of https://github.com/kazhala/dotbare synced 2024-11-06 09:20:25 +00:00
dotbare/helper/get_confirmation.sh

24 lines
578 B
Bash
Raw Normal View History

2020-05-11 01:56:27 +00:00
#!/usr/bin/env bash
2020-04-11 05:32:37 +00:00
#
# confirmaiton helper
#######################################
# Helper function to get user confirmation
# Globals:
# None
# Locals:
# ${confirm}: user confirmation status
# Arguments:
# $1: confirmation message to show during confirm
# Outputs:
# ${confirm}: y or n indicating user response
#######################################
2020-04-11 05:32:37 +00:00
function get_confirmation() {
local confirm
2020-05-01 02:51:12 +00:00
local message="${1:-Confirm?}"
while [ "${confirm}" != 'y' ] && [ "${confirm}" != 'n' ]; do
2020-05-01 02:51:12 +00:00
read -r -p "${message}(y/n): " confirm
2020-04-11 05:32:37 +00:00
done
echo "${confirm}"
2020-04-11 05:32:37 +00:00
}