Skip to content

Instantly share code, notes, and snippets.

What would you like to do? a simple way to add confirmation to bash scripts
# ======================================================================
# @link
# 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!"" ]
return 0
return 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.