aboutsummaryrefslogtreecommitdiffstats
path: root/filter.sh
diff options
context:
space:
mode:
Diffstat (limited to 'filter.sh')
-rwxr-xr-xfilter.sh26
1 files changed, 16 insertions, 10 deletions
diff --git a/filter.sh b/filter.sh
index 0ecea90..8ff38f2 100755
--- a/filter.sh
+++ b/filter.sh
@@ -12,19 +12,25 @@
GREP_ARG="$1"
FILE_GREP_ARG="$2"
-PROG="$3"
-shift 3
-
-GREP_PROG="cat"
-FILE_GREP_PROG="cat"
+BUILDROOT="$3"
+PROG="$4"
+shift 4
# use ' ' to signify no arg as rpm filter empty strings from
# command line :(
-[ "$GREP_ARG" = ' ' ] || GREP_PROG="grep -v $GREP_ARG"
-[ "$FILE_GREP_ARG" = ' ' ] || FILE_GREP_PROG="grep -v $FILE_GREP_ARG"
-
-$FILE_GREP_PROG | $PROG "$@" | $GREP_PROG
-
+if [ "$FILE_GREP_ARG" != ' ' ]; then
+ # get rid of double and trailing slashes
+ BUILDROOT="$(echo "$BUILDROOT" | perl -pe 's,/+,/,g;s,/$,,')"
+ perl -pe "s,^$BUILDROOT,," | grep -v "$FILE_GREP_ARG" | perl -pe "s,^,$BUILDROOT,"
+else
+ cat
+fi | \
+$PROG "$@" | \
+if [ "$GREP_ARG" != ' ' ]; then
+ grep -v "$GREP_ARG"
+else
+ cat
+fi
exit 0
# filter.sh ends here