Last active
July 17, 2022 11:07
-
-
Save Sfinx/76a92648e7cf8c071087958847933e92 to your computer and use it in GitHub Desktop.
Simple bashrc protection for accidental "rm *"
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
rm_protect() { | |
for i in "$@" | |
do | |
if [ "$i" = '*' ] ;then | |
echo -n "Are you sure [rm * in $PWD] ? " | |
read j | |
if [ "$j" != y ]; then return; fi | |
fi | |
done | |
set +f | |
bash -c "/bin/rm $*" | |
} | |
alias rm='set -f; rm_protect' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment