quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH 39/39] backup-files: Skip echo-only loops in silent m


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 39/39] backup-files: Skip echo-only loops in silent mode
Date: Sat, 19 Mar 2011 10:53:09 +0100
User-agent: quilt/0.48-17.1

In silent mode, loops which do nothing but print messages turn into
no-ops. Skip them completely to save some time.

Signed-off-by: Jean Delvare <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
 quilt/scripts/backup-files.in |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -67,6 +67,17 @@ ensure_nolinks() {
        fi
 }
 
+notify_action()
+{
+       [ $ECHO != : ] || return 0
+       local action=$1 filename=$2
+
+       while read -d $'\0' -r
+       do
+               $ECHO "$action ${REPLY#./}"
+       done < "$filename"
+}
+
 backup() {
        local file=$1
        local backup=$OPT_PREFIX$file
@@ -140,11 +151,7 @@ restore_all()
 
        if [ -s "$EMPTY_FILES" ]; then
                xargs -0 rm -f < "$EMPTY_FILES"
-
-               while read -d $'\0' -r
-               do
-                       $ECHO "Removing ${REPLY#./}"
-               done < "$EMPTY_FILES"
+               notify_action Removing "$EMPTY_FILES"
        fi
 
        if [ -s "$NONEMPTY_FILES" ]; then
@@ -157,10 +164,7 @@ restore_all()
                    xargs -0 cp -l --parents --remove-destination \
                                --target-directory="$target_dir" \
                                < "$NONEMPTY_FILES" 2>&4); then
-                       while read -d $'\0' -r
-                       do
-                               $ECHO "Restoring ${REPLY#./}"
-                       done < "$NONEMPTY_FILES"
+                       notify_action Restoring "$NONEMPTY_FILES"
                else
                        (cd "$OPT_PREFIX" && find . -type d -print0) \
                        | xargs -0 mkdir -p
@@ -243,10 +247,7 @@ copy_many()
 
                if xargs -0 cp -p --parents --target-directory="$OPT_PREFIX" \
                   < "$NONEMPTY_FILES" 2>&4; then
-                       while read -d $'\0' -r
-                       do
-                               $ECHO "Copying $REPLY"
-                       done < "$NONEMPTY_FILES"
+                       notify_action Copying "$NONEMPTY_FILES"
                else
                        while read -d $'\0' -r
                        do




reply via email to

[Prev in Thread] Current Thread [Next in Thread]