]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
testing: Improve replacing IP addresses in test files
authorTobias Brunner <tobias@strongswan.org>
Mon, 2 Dec 2024 18:07:51 +0000 (19:07 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Dec 2024 07:43:45 +0000 (08:43 +0100)
There are a lot of files without patterns and running them all through
sed is quite slow.  Using grep first makes this quicker (about 0.5s per
test).  Ignoring PEM files is also helpful.

testing/scripts/function.sh

index 5fbc98293bf38d215ded69e105970584c0c513ac..c162044e511872cf51e362e79ec45cc118e7ff93 100755 (executable)
@@ -194,10 +194,6 @@ function searchandreplace {
        # search and replace in each found file the
        # given string
        #
-
-       for eachfoundfile in `find $DESTDIR -type f`
-       do
-               sed -i -e "s/$SEARCHSTRING/$REPLACESTRING/g" "$eachfoundfile"
-       done
-
+       grep -rlZ --exclude='*.pem' "$SEARCHSTRING" $DESTDIR | \
+               xargs -0 -I@ sed -i -e "s/$SEARCHSTRING/$REPLACESTRING/g" @
 }