2
0
mirror of https://github.com/kazhala/dotbare synced 2024-11-19 15:25:46 +00:00
dotbare/helper/get_confirmation.sh
2020-05-11 12:42:19 +10:00

24 lines
578 B
Bash

#!/usr/bin/env bash
#
# 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
#######################################
function get_confirmation() {
local confirm
local message="${1:-Confirm?}"
while [ "${confirm}" != 'y' ] && [ "${confirm}" != 'n' ]; do
read -r -p "${message}(y/n): " confirm
done
echo "${confirm}"
}