[SM-Commit] GIT changes to master sorcery by Jaka Kranjc (c8132c9c543107ffe89fdf7acbde9c297c10f1a9)

Jaka Kranjc scm at sourcemage.org
Thu Dec 30 11:37:07 EST 2010


GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx at sourcemage.org>:

 ChangeLog                       |    2 ++
 var/lib/sorcery/modules/libmisc |   10 ++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

New commits:
commit c8132c9c543107ffe89fdf7acbde9c297c10f1a9
Author: Jaka Kranjc <lynxlynxlynx at sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx at sourcemage.org>

    remove_files_and_dirs: optimised the empty dir removal a bit
    much room for further improvement left

commit e53fd9adf691393eb5f8f4e157118dab13898200
Author: Jaka Kranjc <lynxlynxlynx at sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx at sourcemage.org>

    libmisc: fixed remove_files_and_dirs not removing some dirs #15804

diff --git a/ChangeLog b/ChangeLog
index 2245826..807a470 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
 	* libtablet: store the grimoire name in the tablet, part of #8370
 	  fixed the section name fetching in tablet_set_spell
 	* gaze: versions show the correct grimoire when using cast -g #15745
+	* libmisc: fixed remove_files_and_dirs not removing some dirs #15804
+	  and optimised the empty dir removal a bit
 
 2010-10-19 Bor Kraljič <pyrobor at ver.si>
 	* libsummon: moved sanity check of source to right after download (#15886)
diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index 3b83465..4cc16d9 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -1115,13 +1115,19 @@ function misc_is_function()  {
 #---------------------------------------------------------------------
 function remove_files_and_dirs() {
     cat $1 | while read file; do
-      test -d $file || rm -f $file
+      if [[ ! -d $file ]]; then
+        rm -f $file
+      else
+        # also try to remove empty dirs, as
+        # the leaves are not taken care of by the next block #15804
+        rmdir $file &>/dev/null
+      fi
     done
 
     # remove possibly empty directories, rmdir WILL have error output
     # because some directories wont be empty for one of many reasons,
     # this is OKAY
-    cat $1|get_dirnames|while read dir; do
+    cat $1|get_dirnames|sort -u|while read dir; do
       until [[ $dir == ${2:-/} ]] ; do
         rmdir $dir &>/dev/null || break
         smgl_dirname "$dir" dir



More information about the SM-Commit mailing list