bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

asking for a better way to implement this


From: Christopher Roy Bratusek
Subject: asking for a better way to implement this
Date: Sun, 26 Sep 2010 18:15:57 +0200

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]