Created
April 9, 2022 10:05
-
-
Save zw963/86856784d0e9e2d83d64f4480ce0adf4 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# ensure add this rm script's $PATH before system /usr/bin/rm command. | |
# a linux rm (wrapper) script which can only use -rf/-r/-f option immediately following rm command. | |
# e.g. | |
# rm ~/.cache -rf # failed! with rm: -rf: No such file or directory | |
# rm -rf ~/.cache # success! | |
case "${@:(-1)}" in | |
'-rf') | |
echo 'rm: -rf: No such file or directory' | |
exit 1 | |
;; | |
'-r') | |
echo 'rm: -r: No such file or directory' | |
exit 1 | |
;; | |
'-f') | |
echo 'rm: -f: No such file or directory' | |
exit 1 | |
esac | |
/usr/bin/rm -i --one-file-system --preserve-root "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment