I don't think it's the config() handling that is at question here Pat. It's the rm outside of it.
Code:
config() {
NEW="$1"
OLD="`dirname $NEW`/`basename $NEW .new`"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
config etc/mercurial/hgrc.d/hgk.rc.new
rm -f etc/mercurial/hgrc.d/hgk.rc.new
- If old doesn't exist move new to old
- else if new and old are the same remove new
- else leave it for the admin to sort out
- but then it gets deleted anyway outside of config(), so the admin will never get to see it.