Add prod command trap to save myself from utter destruction.

This commit is contained in:
Jeff Geerling
2014-11-06 12:35:45 -06:00
parent fd15b9d06e
commit 237ce731d2
+17
View File
@@ -66,3 +66,20 @@ export ANSIBLE_NOCOWS=1
# Ansible aliases. # Ansible aliases.
alias an='ansible' alias an='ansible'
alias ap='ansible-playbook' alias ap='ansible-playbook'
# Ask for confirmation when 'prod' is in a command string.
prod_command_trap () {
if [[ $BASH_COMMAND == *prod* ]]
then
read -p "Are you sure you want to run this command on prod [Y/n]? " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo -e "\nRunning command \"$BASH_COMMAND\" \n"
else
echo -e "\nCommand was not run.\n"
return 1
fi
fi
}
shopt -s extdebug
trap prod_command_trap DEBUG