quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH 11/39] backup-files: Prefix must be a directory


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 11/39] backup-files: Prefix must be a directory
Date: Sat, 19 Mar 2011 10:52:41 +0100
User-agent: quilt/0.48-17.1

Enforce the fact that the prefix must be a directory. This is what
quilt does, and enforcing it allows some code clean-ups.

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

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -135,22 +135,6 @@ process_file() {
        fi
 }
 
-walk() {
-       local path="$1"
-       if [ ! -f "$path" ]; then
-               return 0
-       fi
-
-       if [ "${path#$OPT_PREFIX}" == "$path" ]
-       then
-               # prefix does not match
-               return 0
-       fi
-       path="${path#$OPT_PREFIX}"
-
-       process_file "$path"
-}
-
 
 ECHO=echo
 declare -a FILELIST
@@ -192,6 +176,11 @@ if [ -z "$OPT_PREFIX" ]; then
        exit 1
 fi
 
+if [ "${OPT_PREFIX:(-1)}" != / ]; then
+       echo "Prefix must be a directory" >&2
+       exit 1
+fi
+
 if [ -n "$OPT_FILE" ]; then
        cat "$OPT_FILE" \
        | while read nextfile; do
@@ -204,9 +193,7 @@ while [ $I -lt address@hidden ]; do
 
        case "${FILELIST[$I]}" in
        -)
-               path="${OPT_PREFIX%/*}"
-
-               find "$path" -mindepth 1 \( -type f -o -type d \) -print 
2>/dev/null \
+               find "$OPT_PREFIX" -mindepth 1 \( -type f -o -type d \) -print 
2>/dev/null \
                | while read
                do
                        if [ -d "$REPLY" ]
@@ -217,7 +204,7 @@ while [ $I -lt address@hidden ]; do
                                        exit 1
                                fi
                        else
-                               walk "$REPLY"
+                               process_file "${REPLY#$OPT_PREFIX}"
                        fi
                done
                if [ $? != 0 ]; then




reply via email to

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