X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=functions.sh;h=5bb7ae6b1277107c9ceaa6d60eadd22a2dc3e4ce;hb=491a93c69b438d7fcbf3980185558dee614781ea;hp=13429de23af7daf9c51750f64147f7a22d98fa3f;hpb=d79bdabfd15b6324adc9549290b89178bed98908;p=carnet-tools-cn.git diff --git a/functions.sh b/functions.sh index 13429de..5bb7ae6 100644 --- a/functions.sh +++ b/functions.sh @@ -163,10 +163,8 @@ cp_check_and_sed() { 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 @@ -220,3 +218,20 @@ ${CP_NOTICE}----------" 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 " 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" +}