-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stylecheck script fails on MacOS #13492
Comments
Eh, so it looks like this has been broken on OSX for a long time now; OSX uses FreeBSD grep, whereas Linux used GNU grep, and even though they claim The easiest solution would be to require a Or, we can simply let it sit broken until we move to |
I have something that I think works, but still need to test it: diff --git a/scripts/check_style.sh b/scripts/check_style.sh
index d1ad6bb9e..dbfbecd85 100755
--- a/scripts/check_style.sh
+++ b/scripts/check_style.sh
@@ -4,6 +4,12 @@ set -eu
ERROR_LOG="$(mktemp -t check_style_XXXXXX.log)"
+if [ "$(uname)" == "Darwin" ]; then
+ grepCommand=ggrep
+else
+ grepCommand=grep
+fi
+
EXCLUDE_FILES=(
"libsolutil/picosha2.h"
"test/cmdlineTests/strict_asm_only_cr/input.yul"
@@ -24,7 +30,7 @@ REPO_ROOT="$(dirname "$0")"/..
cd "$REPO_ROOT" || exit 1
WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" |
- grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE\|${EXCLUDE_FILES_JOINED}" || true
+ ${grepCommand} -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE\|${EXCLUDE_FILES_JOINED}" || true
)
if [[ "$WHITESPACE" != "" ]]
@@ -37,13 +43,13 @@ fi
function preparedGrep
{
- git grep -nIE "$1" -- '*.h' '*.cpp' | grep -v "${EXCLUDE_FILES_JOINED}"
+ git grep -nIE "$1" -- '*.h' '*.cpp' | ${grepCommand} -v "${EXCLUDE_FILES_JOINED}"
return $?
}
FORMATERROR=$(
(
- preparedGrep "#include \"" | grep -E -v -e "license.h" -e "BuildInfo.h" # Use include with <> characters
+ preparedGrep "#include \"" | ${grepCommand} -E -v -e "license.h" -e "BuildInfo.h" # Use include with <> characters
preparedGrep "\<(if|for|while|switch)\(" # no space after "if", "for", "while" or "switch"
preparedGrep "\<for\>\s*\([^=]*\>\s:\s.*\)" # no space before range based for-loop
preparedGrep "\<if\>\s*\(.*\)\s*\{\s*$" # "{\n" on same line as "if"
@@ -51,12 +57,12 @@ FORMATERROR=$(
preparedGrep "[,\(<]\s*const " # const on left side of type
preparedGrep "^\s*(static)?\s*const " # const on left side of type (beginning of line)
preparedGrep "^ [^*]|[^*] | [^*]" # uses spaces for indentation or mixes spaces and tabs
- preparedGrep "[a-zA-Z0-9_]\s*[&][a-zA-Z_]" | grep -E -v "return [&]" # right-aligned reference ampersand (needs to exclude return)
+ preparedGrep "[a-zA-Z0-9_]\s*[&][a-zA-Z_]" | ${grepCommand} -E -v "return [&]" # right-aligned reference ampersand (needs to exclude return)
# right-aligned reference pointer star (needs to exclude return and comments)
- preparedGrep "[a-zA-Z0-9_]\s*[*][a-zA-Z_]" | grep -E -v -e "return [*]" -e "^* [*]" -e "^*//.*"
+ preparedGrep "[a-zA-Z0-9_]\s*[*][a-zA-Z_]" | ${grepCommand} -E -v -e "return [*]" -e "^* [*]" -e "^*//.*"
# unqualified move check, i.e. make sure that std::move() is used instead of move()
- preparedGrep "move\(.+\)" | grep -v "std::move" | grep -E "[^a-z]move"
-) | grep -E -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" || true
+ preparedGrep "move\(.+\)" | ${grepCommand} -v "std::move" | ${grepCommand} -E "[^a-z]move"
+) | ${grepCommand} -E -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" || true
)
if [[ "$FORMATERROR" != "" ]] Although I get some warnings when I try to run it now, need to check if they're relevant:
|
- Install GNU grep on macOS with `brew install grep` - Use GNU grep with -E option - The following errors fixed. ``` $scripts/check_style.sh ggrep: warning: stray \ before / ggrep: warning: stray \ before / ggrep: warning: * at start of expression ggrep: warning: * at start of expression ```
- Install GNU grep on macOS with `brew install grep` - Use GNU grep with -E option - The following errors fixed. ``` $scripts/check_style.sh ggrep: warning: stray \ before / ggrep: warning: stray \ before / ggrep: warning: * at start of expression ggrep: warning: * at start of expression ```
- Install GNU grep on macOS with brew install grep - Use GNU grep with -E option - The following errors fixed. ``` $scripts/check_style.sh ggrep: warning: stray \ before / ggrep: warning: stray \ before / ggrep: warning: * at start of expression ggrep: warning: * at start of expression ``` Fixes [Stylecheck script fails on MacOS ethereum#13492](ethereum#13492)
- Install GNU grep on macOS with brew install grep - Use GNU grep with -E option - The following errors fixed. ``` $scripts/check_style.sh ggrep: warning: stray \ before / ggrep: warning: stray \ before / ggrep: warning: * at start of expression ggrep: warning: * at start of expression ``` Fixes [Stylecheck script fails on MacOS ethereum#13492](ethereum#13492)
PR at #14348 |
- Install GNU grep on macOS with brew install grep - Use GNU grep with -E option - The following errors fixed. ``` $scripts/check_style.sh ggrep: warning: stray \ before / ggrep: warning: stray \ before / ggrep: warning: * at start of expression ggrep: warning: * at start of expression ``` Fixes [Stylecheck script fails on MacOS ethereum#13492](ethereum#13492)
- Install GNU grep on macOS with brew install grep - Use GNU grep with -E option - The following errors fixed. ``` $scripts/check_style.sh ggrep: warning: stray \ before / ggrep: warning: stray \ before / ggrep: warning: * at start of expression ggrep: warning: * at start of expression ``` Fixes [Stylecheck script fails on MacOS ethereum#13492](ethereum#13492)
- Install GNU grep on macOS with brew install grep - Use GNU grep with -E option - The following errors fixed. ``` $scripts/check_style.sh ggrep: warning: stray \ before / ggrep: warning: stray \ before / ggrep: warning: * at start of expression ggrep: warning: * at start of expression ``` Fixes [Stylecheck script fails on MacOS ethereum#13492](ethereum#13492)
scripts/check_style.sh
does not work on MacOS:The text was updated successfully, but these errors were encountered: