Skip to content

Instantly share code, notes, and snippets.

@zw963
Created April 9, 2022 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zw963/86856784d0e9e2d83d64f4480ce0adf4 to your computer and use it in GitHub Desktop.
Save zw963/86856784d0e9e2d83d64f4480ce0adf4 to your computer and use it in GitHub Desktop.
#!/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