From 0f1d141905e6648b661d570b5062c25f74360cfe Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Mon, 30 Jan 2023 14:41:03 -0800 Subject: [PATCH] Use PCRE git grep to work around macOS git bug. Git 2.39 on macOS contains a buggy `grep` implementation which, among other things, fails to interpret the metasequence `\s` in extended regex mode as space characters and instead interprets it as the literal `s` character. To avoid this issue, this commit now uses `-P` instead of `-E` when calling `git grep`, forcing use of PCRE instead. --- scripts/test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/test.sh b/scripts/test.sh index a4a82aaa..bb21d184 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -34,7 +34,7 @@ function check_versions_match() { function check_style() { # Ensure there are no tabs in any file. local tab=$(printf '\t') - local matches=$(git grep -E -I -n "${tab}" "${PROJECT_ROOT}" | grep -v 'LICENSE') + local matches=$(git grep -PIn "${tab}" "${PROJECT_ROOT}" | grep -v 'LICENSE') if ! [ -z "${matches}" ]; then echo "Tab characters were found in the following:" echo "${matches}" @@ -43,7 +43,7 @@ function check_style() { # Ensure non-comment lines are under 100 characters. local n=100 - local matches=$(git grep -P -I -n "(?=^..{$n,}$)(?!^\s*\/\/[\/!].*$).*" '*.rs') + local matches=$(git grep -PIn "(?=^..{$n,}$)(?!^\s*\/\/[\/!].*$).*" '*.rs') if ! [ -z "${matches}" ]; then echo "Lines longer than $n characters were found in the following:" echo "${matches}" @@ -51,7 +51,7 @@ function check_style() { fi # Ensure there's no trailing whitespace. - local matches=$(git grep -E -I -n "\s+$" "${PROJECT_ROOT}" | grep -v -F '.stderr:') + local matches=$(git grep -PIn "\s+$" "${PROJECT_ROOT}" | grep -v -F '.stderr:') if ! [ -z "${matches}" ]; then echo "Trailing whitespace was found in the following:" echo "${matches}"