From: Zoran Dzelajlija Date: Sun, 20 Mar 2005 22:42:07 +0000 (+0000) Subject: r6: cp_check_and_sed() hendla datoteke sa ' ' u imenu. X-Git-Tag: debian/3.0.0~99 X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=carnet-tools-cn.git;a=commitdiff_plain;h=2a8ec66d2fdb3fdcf95786aed32d33f3dd0a1601 r6: cp_check_and_sed() hendla datoteke sa ' ' u imenu. cp_mail() prazan red viska u mailu. --- diff --git a/functions.sh b/functions.sh index 2f14b52..495409d 100644 --- a/functions.sh +++ b/functions.sh @@ -107,6 +107,11 @@ cp_backup_conffile() { } # by jelly, Tue, 15 Mar 2005 14:04:21 +0100 +# A sed wrapper, to use instead of perl -pi -e +# - relatively safe in-place s///g +# - takes care of symlinks and ownership +# returns true if changed, false if nothing happened +# cp_check_and_sed() { [ "$CP_SCRIPT_DEBUG" ] && set -vx local s sedcmd ret i @@ -115,15 +120,15 @@ cp_check_and_sed() { sedcmd="$1" shift ret=2 - for i in $* + for i in "$@" do [ -e "$i" ] || continue egrep -q "$s" "$i" || continue [ -h "$i" ] && i=$(readlink -f "$i") sed "$sedcmd" "$i" > "$i.dpkg-tmp" - chown --reference "$i" "$i.dpkg-tmp" - chmod --reference "$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" else rm "$i.dpkg-tmp" @@ -172,8 +177,7 @@ For your convenience, a partial output of the last $pkg installation is included below. ---------- -$CP_NOTICE -----------" +${CP_NOTICE}----------" echo "$CP_NOTICE" | /usr/sbin/sendmail -t & sleep 1