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

23 lines
529 B
Bash
Raw Normal View History

2020-04-11 05:32:37 +00:00
#!/bin/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
#######################################
2020-04-11 05:32:37 +00:00
function get_confirmation() {
local confirm
while [ "${confirm}" != 'y' ] && [ "${confirm}" != 'n' ]; do
read -r -p "$1(y/n): " confirm
2020-04-11 05:32:37 +00:00
done
echo "${confirm}"
2020-04-11 05:32:37 +00:00
}