quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH 04/39] BSD compatibility: rmdir


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 04/39] BSD compatibility: rmdir
Date: Sat, 19 Mar 2011 10:52:34 +0100
User-agent: quilt/0.48-17.1

Use rmdir -p instead of open-coding it. The more complex code was
maybe needed to properly handle symbolic links, but we know that
there won't be symbolic links in the backup directory, so the extra
complexity isn't needed.

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

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -117,14 +117,7 @@ process_file() {
                        $ECHO "Removing $file"
                        if [ -z "$OPT_KEEP_BACKUP" ]; then
                                rm "$backup"
-                               while [ -d "${backup%/*}" ] && ! [ -L 
"${backup%/*}" ]
-                               do
-                                       backup="${backup%/*}"
-                                       rmdir --ignore-fail-on-non-empty 
"$backup" 2>/dev/null
-                                       if [ -d "$backup" ]; then
-                                               break
-                                       fi
-                               done
+                               rmdir -p "${backup%/*}" 2> /dev/null || true
                        fi
                else
                        $ECHO "Restoring $file"
@@ -142,14 +135,7 @@ process_file() {
 
                        if [ -z "$OPT_KEEP_BACKUP" ]; then
                                rm "$backup"
-                               while [ -d "${backup%/*}" ] && ! [ -L 
"${backup%/*}" ]
-                               do
-                                       backup="${backup%/*}"
-                                       rmdir --ignore-fail-on-non-empty 
"$backup" 2>/dev/null
-                                       if [ -d "$backup" ]; then
-                                               break
-                                       fi
-                               done
+                               rmdir -p "${backup%/*}" 2> /dev/null || true
                        fi
                        if [ -n "$OPT_TOUCH" ]; then
                                touch "$file"
@@ -159,14 +145,7 @@ process_file() {
                if [ -e "$backup" ]; then
                        rm "$backup"
                fi
-               while [ -d "${backup%/*}" ] && ! [ -L "${backup%/*}" ]
-               do
-                       backup="${backup%/*}"
-                       rmdir --ignore-fail-on-non-empty "$backup" 2>/dev/null
-                       if [ -d "$backup" ]; then
-                               break
-                       fi
-               done
+               rmdir -p "${backup%/*}" 2> /dev/null || true
        elif [ -z "$OPT_WHAT" ]; then
                if [ -e "$file" ] && [ -n "$OPT_NOLINKS" ]; then
                        ensure_nolinks "$file"




reply via email to

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