Hey there,
I just found this tool while searching for solutions to fool-proof rm on my system. Seeing that this distro is for linux newbies as well as advanced linux users, I would like to request this as package (Or garuda-assistant-tweak)
It could probably also help with "rm -Rf /" trolls (No I have not tried it myself yet, I don't want to risk losing all my files in case this does not work xD
I guess one of you could try that in a VM? It would take a bit too long to spin one up myself I suppose.
Thanks!
Edit: Safe-rm is in the aur, but uses the chonky 500 mb rust runtime, which I hate
You know, we have a bundle of bash shortcuts already. If I'm reading this request right, why not link that command (with specific variables) to a much safer one? Even something instructive? I don't think a great amount of detail would be warranted.
Was reading about it, someone at a company ran some scripts, and some of those scripts had rm, with an environment variable that was missing or '/', and before you knew it -- everything was gone.
That's what backups are for, but all his backups were mounted and flushed with it.
He was hosting data for lots of customers and was asking for advice online... people were like "sorry, find another job"
#!/bin/bash
_opts=1
declare -a _unsafe
for _arg in "$@"; do
case "${_arg%/}" in
--i-know-what-i-am-doing|--suicide|--seppuku|--aettestupa) (( $_opts )) && { shift; _selfharm=1; } ;;
-i|-I|--interactive*) (( $_opts )) && _i_set="$_arg" ;;
-r|-R|--recursive) (( $_opts )) && _r_set="$_arg" ;;
-*) ;;
--) _opts=0 ;;
/|/bin|/boot|/dev|/etc|/home|/initrd|/lib|/lib32|/lib64|/proc|/root|/sbin|/sys|/usr|/usr/bin|/usr/include|/usr/lib|/usr/local|/usr/local/bin|/usr/local/include|/usr/local/sbin|/usr/local/share|/usr/sbin|/usr/share|/usr/src|/var)
_opts=0 ; _unsafe+=("$_arg") ;;
*) _opts=0 ;;
esac
done
if [[ -n $_r_set && -z $_i_set && ${#_unsafe[@]} -gt 0 && ! $_selfharm -gt 0 ]]; then
echo "careful with that axe -- unsafe recursive operation detected ($_r_set)"
echo "cowardly refusing to wipe ${_unsafe[@]}"
echo "please express your death wish explicitly if that's actually your intent"
else
echo "/bin/the-real-rm $@"
fi
Beware, it’s more about humor than safety.
Probably slow. Almost surely buggy. Won’t save you from “rm /bin/*” anyways.
Configurable with your favorite text editor.
I’m surprised no one mentioned “you can’t fix stupid” – once I dodged the “rm -rf” bullet when I overlooked shell quoting issues in a script of mine, fortunately I just got a bunch of “no such file or directory” and half a heart attack.