[SM-Commit] GIT changes to master sorcery by David Brown (5f7655a0e94c0069a087c44018b7a654ce098856)

David Brown scm at mail.sourcemage.org
Sun Dec 17 15:57:26 EST 2006


GIT changes to master sorcery by David Brown <dmlb2000 at gmail.com>:

 ChangeLog                          |    3 +
 var/lib/sorcery/modules/libsorcery |   60 ++++++++++++++++++++++++-------------
 2 files changed, 43 insertions(+), 20 deletions(-)

New commits:
commit 5f7655a0e94c0069a087c44018b7a654ce098856
Author: David Brown <dmlb2000 at gmail.com>
Commit: David Brown <dmlb2000 at gmail.com>

    filter/filter_in removed /dev/null entry from both rid and not rid list and added extra checking for possable empty lists

diff --git a/ChangeLog b/ChangeLog
index 734abfa..390c65a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2006-12-17 David Brown <dmlb2000 at gmail.com>
+	* libsorcery: filter/filter_in removed /dev/null entry from both functions
+
 2006-12-03 Andrew Stitt <astitt at sourcemage.org>
 	* build_api/common: gather_docs delineates between files and
 	  directories. Now *rc matches config files, but not directories
diff --git a/var/lib/sorcery/modules/libsorcery b/var/lib/sorcery/modules/libsorcery
index 705eca2..7f56c0f 100755
--- a/var/lib/sorcery/modules/libsorcery
+++ b/var/lib/sorcery/modules/libsorcery
@@ -503,24 +503,36 @@ function filter() {
       cat $files   |
       grep -v '^!' | while read thing; do
                        echo -n "${thing}\|"
-                     done
-      echo -n /dev/null)
+                     done)
     NOT_RID_LIST=$(
       cat $files   |
       grep '^!'    | while read thing; do
                        echo -n "${thing/\!/}\|"
-                     done
-      echo -n /dev/null)
+                     done)
+    RID_LIST=${RID_LIST%\\|}
+	NOT_RID_LIST=${NOT_RID_LIST%\\|}
+	echo "R:$RID_LIST" >&2
+	echo "NR:$NOT_RID_LIST" >&2
 
     local TMP_SSF=$(make_safe_dir)
     local FILE=$TMP_SSF/ssf
 
-    cat > $FILE
-    {
-      grep -v "$NOT_RID_LIST\|$RID_LIST" $FILE
-      grep "$NOT_RID_LIST" $FILE
-    }
-    rm $FILE 2>/dev/null
+	if [[ $RID_LIST ]]
+	then
+	  if [[ $NOT_RID_LIST ]]
+	  then
+        cat > $FILE
+        {
+          grep -v "$NOT_RID_LIST\|$RID_LIST" $FILE
+          grep "$NOT_RID_LIST" $FILE
+        }
+        rm $FILE 2>/dev/null
+      else
+        grep -v "$RID_LIST"
+      fi
+	else
+      cat
+    fi
   else
     cat
   fi
@@ -549,20 +561,28 @@ function filter_in() {
       cat $files   | 
       grep -v '^!' | while read thing; do
                        echo -n "${thing}\|"
-                     done
-      echo -n /dev/null)
+                     done)
     NOT_RID_LIST=$(
       cat $files   | 
       grep '^!'    | while read thing; do
                        echo -n "${thing/\!/}\|"
-                     done
-      echo -n /dev/null)
-    if [[ $NOT_RID_LIST ]]
-    then
-      grep "$RID_LIST" |
-      grep -v "$NOT_RID_LIST"
-    else
-      grep "$RID_LIST"
+                     done)
+	RID_LIST=${RID_LIST%\\|}
+	NOT_RID_LIST=${NOT_RID_LIST%\\|}
+	echo "R:$RID_LIST" >&2
+	echo "NR:$NOT_RID_LIST" >&2
+	if [[ $RID_LIST ]]
+	then
+      if [[ $NOT_RID_LIST ]]
+      then
+        grep "$RID_LIST" |
+        grep -v "$NOT_RID_LIST"
+      else
+        grep "$RID_LIST"
+      fi
+	else
+	  # grep '' outputs everything in this case we want nothing
+      cat > /dev/null
     fi
   else
     cat



More information about the SM-Commit mailing list