Skip to content

Commit 14475e2

Browse files
committed
Merge #12097: [scripts] lint-whitespace: use perl instead of grep -P
40b17f5 [scripts] lint-whitespace: use perl instead of grep -P (Sjors Provoost) Pull request description: MacOS does not support `grep -P` out of the box. This change makes it easier for developers to check for whitespace problems locally. Based on [this](https://stackoverflow.com/a/16658690) and [this](https://serverfault.com/a/504387) Stack Exchange answer. Tested with: ```sh export TRAVIS_COMMIT_RANGE='fe78c9a...62e0453' contrib/devtools/lint-whitespace.sh This diff appears to have added new lines with tab characters instead of spaces. The following changes were suspected: diff --git a/src/test/bignum_tests.cpp b/src/test/bignum_tests.cpp @@ -0,0 +1,110 @@ + num.setint64(n); ``` Tree-SHA512: 37c342a0ca2580289cf326a278a051a7c21ba918d6b2143fd9987f159fab85f1de3d770fcf532a642cd5d1957afc8595678128196e102dc473924758f133db7f
2 parents 9fb3898 + 40b17f5 commit 14475e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

contrib/devtools/lint-whitespace.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if showdiff | grep -E -q '^\+.*\s+$'; then
5959
fi
6060

6161
# Check if tab characters were found in the diff.
62-
if showcodediff | grep -P -q '^\+.*\t'; then
62+
if showcodediff | perl -nle '$MATCH++ if m{^\+.*\t}; END{exit 1 unless $MATCH>0}' > /dev/null; then
6363
echo "This diff appears to have added new lines with tab characters instead of spaces."
6464
echo "The following changes were suspected:"
6565
FILENAME=""
@@ -81,7 +81,7 @@ if showcodediff | grep -P -q '^\+.*\t'; then
8181
fi
8282
echo "$line"
8383
fi
84-
done < <(showcodediff | grep -P '^(diff --git |@@|\+.*\t)')
84+
done < <(showcodediff | perl -nle 'print if m{^(diff --git |@@|\+.*\t)}')
8585
RET=1
8686
fi
8787

0 commit comments

Comments
 (0)