From 2a8ec66d2fdb3fdcf95786aed32d33f3dd0a1601 Mon Sep 17 00:00:00 2001 From: Zoran Dzelajlija Date: Sun, 20 Mar 2005 22:42:07 +0000 Subject: [PATCH] r6: cp_check_and_sed() hendla datoteke sa ' ' u imenu. cp_mail() prazan red viska u mailu. --- functions.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 -- 1.7.10.4