Hi all, I'm writing a wrapper for rm, which does not let the file/directory be removed, if there's a .dirinfo file in the directory containing "NoDelete".
(feel free to ask what that's all about.) This is what I have: xrm () { for path in $@; do if [[ $path == -* || $path == --* ]]; then local RMO+="$path" else basedir=$(echo "$path" | sed -e "s/$(basename path)//g") if [[ -e "$path"/.dirinfo && $(grep NoDelete "$path"/.dirinfo 2>/dev/null) != "" ]]; then echo "can not delete delete $path, it's protected" elif [[ -e ${basedir}/.dirinfo && $(grep NoDelete "$basedir"/.dirinfo 2>/dev/null) != "" ]]; then echo "can not delete delete $path, it's protected" else $(which rm) $RM_OPTS $RMO "$path" fi fi done } Now, I wanted to ask, if there's a more elegant/better way to implement this. Chris