2020-05-11 01:56:27 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-04-11 05:32:37 +00:00
|
|
|
#
|
|
|
|
# confirmaiton helper
|
|
|
|
|
2020-04-14 07:00:37 +00:00
|
|
|
#######################################
|
|
|
|
# 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() {
|
2020-04-14 07:00:37 +00:00
|
|
|
local confirm
|
2020-05-01 02:51:12 +00:00
|
|
|
local message="${1:-Confirm?}"
|
2020-04-14 07:00:37 +00:00
|
|
|
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
|
2020-04-14 07:00:37 +00:00
|
|
|
echo "${confirm}"
|
2020-04-11 05:32:37 +00:00
|
|
|
}
|