Star
You must be signed in to star a gist
confirm.sh a simple way to add confirmation to bash scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ====================================================================== | |
# | |
# @link http://wuhrr.wordpress.com/2010/01/13/adding-confirmation-to-bash/#comment-3540 | |
# | |
# Function: confirm | |
# Asks the user to confirm an action, If the user does not answer "This won't shutdown the Internet!" the script will immediately exit. | |
# | |
# Parameters: | |
# $@ - The confirmation message | |
# | |
# ====================================================================== | |
function confirm() | |
{ | |
echo -n "$@ " | |
read -e answer | |
if [ "_$answer" == "This won't shutdown the Internet!"" ] | |
then | |
return 0 | |
fi | |
return 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment