From: Matthias Urlichs Date: Wed, 13 Jul 2005 20:07:24 GMT Subject: Re: [RFC PATCH] cogito --- don't overwrite metadata files in place (breaks CoW use) Message-ID: <20050713200724.GN9915@kiste.smurf.noris.de> In-Reply-To: <20050713185339.GA9260@taniwha.stupidest.org> Hi, Chris Wedgwood: > How about the following? > Ummm... > local NLINK=`readlink "$DEST"` > > if [ ! -e "$NLINK" ] ; then You lose if the link is relative and the symlink is not in the current directory. You also lose on systems where the empty filename is synonymous with the current directory. You'd need to do something along the lines of if [ -n "$NLINK" ] ; then case "$NLINK" in /*) ;; *) NLINK="$(dirname "$DEST")/$NLINK" ;; esac fi first. > # dangling link, just poke as-is > echo "$1" > "$DEST" You should remove "DEST first. Otherwise, under Linux, you'll magically create the file the symlink points to, which may not be what you want to do. -- Matthias Urlichs | {M:U} IT Design @ m-u-it.de | smurf@smurf.noris.de Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de - - Custom does often reason overrule And only serves for reason to the fool. -- John Wilmot, Earl of Rochester