summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2012-02-01 18:08:49 +0100
committerJean Delvare <jdelvare@suse.de>2012-02-01 18:08:49 +0100
commitf94d39d031ab6975bf506ffc03ab4bfe5be03584 (patch)
tree3cf5b22614a07f98f28a5470a01e041a8c0e0163
parent73949d4f08b168116f30c9be0f1e282957e1a816 (diff)
downloadquilt-f94d39d031ab6975bf506ffc03ab4bfe5be03584.tar.gz
backup-files: Avoid negations
In if/else constructs, always start with the positive case, to avoid a negation. Signed-off-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Raphael Hertzog <hertzog@debian.org>
-rw-r--r--quilt/scripts/backup-files.in26
1 files changed, 13 insertions, 13 deletions
diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in
index 4e59de5..db4c008 100644
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -67,10 +67,7 @@ backup() {
dir=$(dirname "$backup")
[ -d "$dir" ] || mkdir -p "$dir"
- if [ ! -e "$file" ]; then
- $ECHO "New file $file"
- : > "$backup"
- else
+ if [ -e "$file" ]; then
$ECHO "Copying $file"
if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = 1 ]; then
cp -p "$file" "$backup"
@@ -80,6 +77,9 @@ backup() {
ensure_nolinks "$file"
fi
fi
+ else
+ $ECHO "New file $file"
+ : > "$backup"
fi
}
@@ -91,15 +91,15 @@ restore_fast()
local file=$1
local backup=$OPT_PREFIX$file
- if [ ! -s "$backup" ]; then
- $ECHO "Removing $file"
- else
+ if [ -s "$backup" ]; then
$ECHO "Restoring $file"
if [ -n "$OPT_NOLINKS" ]; then
cp -p "$backup" "$file"
else
ln "$backup" "$file" 2> /dev/null || cp -p "$backup" "$file"
fi
+ else
+ $ECHO "Removing $file"
fi
}
@@ -111,12 +111,7 @@ restore()
if [ ! -e "$backup" ]; then
return 1
fi
- if [ ! -s "$backup" ]; then
- $ECHO "Removing $file"
- if [ -e "$file" ]; then
- rm "$file"
- fi
- else
+ if [ -s "$backup" ]; then
$ECHO "Restoring $file"
if [ -e "$file" ]; then
rm "$file"
@@ -132,6 +127,11 @@ restore()
if [ -n "$OPT_TOUCH" ]; then
touch "$file"
fi
+ else
+ $ECHO "Removing $file"
+ if [ -e "$file" ]; then
+ rm "$file"
+ fi
fi
if [ -z "$OPT_KEEP_BACKUP" ]; then