You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotbare/helper/get_confirmation.sh

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}"
}