[Top][All Lists]
[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
- [Quilt-dev] [PATCH 06/39] backup-files: Drop suffix option, (continued)
- [Quilt-dev] [PATCH 06/39] backup-files: Drop suffix option, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 28/39] backup-files: Separate lists for empty and non-empty files, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 10/39] backup-files: Speed up ensure_nolinks, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 35/39] backup-files: Inline restore_fast, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 20/39] backup-files: Batch mass restore, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 31/39] backup-files: New function for copy, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 37/39] backup-files: Drop support for backup removal, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 08/39] backup-files: Drop variable progname, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 04/39] BSD compatibility: rmdir, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 32/39] backup-files: Separate function copy_many, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 39/39] backup-files: Skip echo-only loops in silent mode,
Jean Delvare <=
- [Quilt-dev] [PATCH 34/39] backup-files: Clarify command line options, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 38/39] backup-files: Keep /dev/null opened, Jean Delvare, 2011/03/19