Index: scripts/brp-nobuildrootpath
===================================================================
RCS file: /v/rpm/cvs/rpm/scripts/brp-nobuildrootpath,v
retrieving revision 1.2
retrieving revision 1.4
diff -u -r1.2 -r1.4
--- scripts/brp-nobuildrootpath	25 May 2007 18:34:16 -0000	1.2
+++ scripts/brp-nobuildrootpath	29 Jul 2008 20:49:30 -0000	1.4
@@ -1,17 +1,21 @@
 #!/bin/sh
-
+#
+# A fixed version of this file that doesn't bomb out
+# when failing to match. Also removed the case statement
+# as it's simpler to just let 'find' do everything in one pass.
+#
+#
 # If using normal root, avoid changing anything.
 if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
     exit 0
 fi
-
+#
 # Remove occurences of $RPM_BUILD_ROOT from *.la and *.pc files.
-for f in `find $RPM_BUILD_ROOT -type f` ; do
-    case "$f" in
-    *.la|*.pc)
-	grep "${RPM_BUILD_ROOT}\/" "$f" 2>&1 > /dev/null && \
-	sed -e "s|${RPM_BUILD_ROOT}/|/|g" "$f" 2>/dev/null > "$f.out" && \
-	mv "$f.out" "$f"
-	;;
-    esac
+#
+for f in `find $RPM_BUILD_ROOT -type f -name \*.pc -o -name \*.la` ; do
+    # -c to count the occurances, only proceed if >= 1
+    if [ "`grep -c "${RPM_BUILD_ROOT}\/" "$f"`" -ge 1 ]; then
+        sed -e "s|${RPM_BUILD_ROOT}/|/|g" "$f" > "$f.out" && \
+        mv -f "$f.out" "$f"
+    fi
 done