Skip to content

Commit 40b17f5

Browse files
committed
[scripts] lint-whitespace: use perl instead of grep -P
MacOS does not support 'grep -P' out of the box. This change makes it easier for developers to check for whitespace problems locally.
1 parent 5691028 commit 40b17f5

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)