From 116ff9a636f7e76ca70ff46c454de01dd9a6844b Mon Sep 17 00:00:00 2001 From: Sohrab Behdani Date: Sun, 17 Nov 2024 14:22:24 +0330 Subject: [PATCH] added a rm safe guard --- .../usr/share/parchlinux/zsh/functions/saferm.zsh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 rootfs/usr/share/parchlinux/zsh/functions/saferm.zsh diff --git a/rootfs/usr/share/parchlinux/zsh/functions/saferm.zsh b/rootfs/usr/share/parchlinux/zsh/functions/saferm.zsh new file mode 100644 index 0000000..fe105c2 --- /dev/null +++ b/rootfs/usr/share/parchlinux/zsh/functions/saferm.zsh @@ -0,0 +1,14 @@ +safe_rm() { + if [[ "$*" =~ (^| )/($| ) ]]; then + echo "Error: Attempt to use 'rm' on root (/) is blocked for your safety!" + return 1 + elif [[ "$*" =~ "--no-preserve-root" ]]; then + echo "Error: '--no-preserve-root' usage is blocked for your safety!" + return 1 + fi + + command rm "$@" +} + +alias rm="safe_rm" +