added a rm safe guard
This commit is contained in:
parent
e96766feb8
commit
116ff9a636
1 changed files with 14 additions and 0 deletions
14
rootfs/usr/share/parchlinux/zsh/functions/saferm.zsh
Normal file
14
rootfs/usr/share/parchlinux/zsh/functions/saferm.zsh
Normal file
|
@ -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"
|
||||
|
Loading…
Add table
Reference in a new issue