egrep -q "$s" "$i" || continue
[ -h "$i" ] && i=$(readlink -f "$i")
sed "$sedcmd" "$i" > "$i.dpkg-tmp"
- if ! cmp -s "$i" "$i.dpkg-tmp"; then
- chown --reference "$i" "$i.dpkg-tmp"
- chmod --reference "$i" "$i.dpkg-tmp"
- mv "$i.dpkg-tmp" "$i"
+ if ! cmp -s "$i" "$i.dpkg-tmp" 2>&1 >/dev/null; then
+ cp_safe_file_replace "$i.dpkg-tmp" "$i"
else
rm "$i.dpkg-tmp"
fi
sleep 1
fi
}
+
+# by ddzeko, Mon, 21 Mar 2005 11:31:59 +0100
+cp_safe_file_replace () {
+ [ "$CP_SCRIPT_DEBUG" ] && set -vx
+ local new old
+ if [ -z "$2" ]; then
+ echo "Usage: cp_safe_file_replace <new-file> <target-file>" 1>&2
+ return 1
+ fi
+ new="$1"
+ old="$2"
+ if [ -e "$old" ]; then
+ chown --reference "$old" "$new"
+ chmod --reference "$old" "$new"
+ fi
+ mv "$new" "$old"
+}