Skip to content

Instantly share code, notes, and snippets.

@echuber2
Last active March 24, 2019 19:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save echuber2/2b44d229bc7282a8839d506af2bddbfa to your computer and use it in GitHub Desktop.
Save echuber2/2b44d229bc7282a8839d506af2bddbfa to your computer and use it in GitHub Desktop.
Lifting bash commands for safety
# https://gist.github.com/echuber2/2b44d229bc7282a8839d506af2bddbfa
# Try source-ing this file first to disable the bash "times" command
# hidetimes1.sh
alias times=''
unalias times
lifted_times () {
times
}
disable_times () {
alias times='echo Sorry, no times for you'
}
disable_times
# https://gist.github.com/echuber2/2b44d229bc7282a8839d506af2bddbfa
# Then, source-ing this file will present a prompt that can launch the real times command that is now hidden otherwise
# hidetimes2.sh
# https://stackoverflow.com/questions/1885525/how-do-i-prompt-a-user-for-confirmation-in-bash-script
read -p "Are you sure you want to run the real times? " -n 1 -r
echo "" # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# do dangerous stuff
lifted_times
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment