sm-commit AT lists.ibiblio.org
Subject: Source Mage code commit list
List archive
[SM-Commit] GIT changes to devel-stage-root sorcery by David Brown (82e7eba14478633bc22afecb4bc6be49226830be)
- From: David Brown <scm AT mail.sourcemage.org>
- To: sm-commit AT lists.ibiblio.org
- Subject: [SM-Commit] GIT changes to devel-stage-root sorcery by David Brown (82e7eba14478633bc22afecb4bc6be49226830be)
- Date: Tue, 28 Nov 2006 23:49:46 -0600
GIT changes to devel-stage-root sorcery by David Brown <dmlb2000 AT gmail.com>:
var/lib/sorcery/modules/libsorcery | 57
++++++++++++++++++++++++++++++-------
1 files changed, 47 insertions(+), 10 deletions(-)
New commits:
commit 82e7eba14478633bc22afecb4bc6be49226830be
Author: David Brown <dmlb2000 AT gmail.com>
Commit: David Brown <dmlb2000 AT gmail.com>
Okay implemented the !filter syntax in both filter() and filter_in()
functions
diff --git a/var/lib/sorcery/modules/libsorcery
b/var/lib/sorcery/modules/libsorcery
index 12ec692..7422b0c 100755
--- a/var/lib/sorcery/modules/libsorcery
+++ b/var/lib/sorcery/modules/libsorcery
@@ -492,7 +492,7 @@ function symlinks() {
##
#---------------------------------------------------------------------
function filter() {
- local thing RID_LIST
+ local thing RID_LIST NOT_RID_LIST
local files each invert
for each in $@; do
test -f $each && files="$files $each"
@@ -500,11 +500,35 @@ function filter() {
if [[ $files ]] ; then
RID_LIST=$(
- cat $files | while read thing; do
- echo -n "$thing\|"
- done
+ cat $files |
+ grep -v '^!' | while read thing; do
+ echo -n "${thing}\|"
+ done
echo -n /dev/null)
- grep -v "$RID_LIST"
+ NOT_RID_LIST=$(
+ cat $files |
+ grep '^!' | while read thing; do
+ echo -n "${thing/\!/}\|"
+ done
+ echo -n /dev/null)
+ (
+ # Okay to explain the code
+ # exec 3> is opening up the 3 file descriptor for this shell and
+ # pointing all input to that file descriptor to the stdin of the
+ # subshell with grep
+ # similarly with exec 4> line
+ # the tee line is taking the stdin from this subshell and sending
+ # it to the two file descriptors 3 and 4
+ # the filter_tmp_file is used so the output going to fds 3 & 4
+ # won't over-write each other
+
+ # And to explain the reasoning
+ # the grep -v command removes both the RID and NOT_RID lists
+ exec 3> >(grep -v "$NOT_RID_LIST\|$RID_LIST")
+ exec 4> >(grep "$NOT_RID_LIST" > $TMP_DIR/filter_tmp_file)
+ tee -a /proc/self/fd/3 1>&4
+ cat $TMP_DIR/filter_tmp_file
+ )
else
cat
fi
@@ -522,7 +546,7 @@ function filter() {
##
#---------------------------------------------------------------------
function filter_in() {
- local thing RID_LIST
+ local thing RID_LIST NOT_RID_LIST
local files each
for each in $@; do
test -f $each && files="$files $each"
@@ -530,11 +554,24 @@ function filter_in() {
if [[ $files ]] ; then
RID_LIST=$(
- cat $files | while read thing; do
- echo -n "$thing\|"
- done
+ cat $files |
+ grep -v '^!' | while read thing; do
+ echo -n "${thing}\|"
+ done
+ echo -n /dev/null)
+ NOT_RID_LIST=$(
+ cat $files |
+ grep '^!' | while read thing; do
+ echo -n "${thing/\!/}\|"
+ done
echo -n /dev/null)
- grep "$RID_LIST"
+ if [[ $NOT_RID_LIST ]]
+ then
+ grep "$RID_LIST" |
+ grep -v "$NOT_RID_LIST"
+ else
+ grep "$RID_LIST"
+ fi
else
cat
fi
- [SM-Commit] GIT changes to devel-stage-root sorcery by David Brown (82e7eba14478633bc22afecb4bc6be49226830be), David Brown, 11/29/2006
Archive powered by MHonArc 2.6.24.