From 22a5bf92f86587917f8f1a285e0843301ec1f050 Mon Sep 17 00:00:00 2001 From: Antoine Tollenaere Date: Wed, 17 Jul 2024 13:02:45 +0200 Subject: [PATCH 1/2] vet: fix option order when invoking grep vet.sh is currently calling `grep -ev expr`. This is being interpreted as "grep pattern 'v' in file 'expr'", instead of the intended "invert grep for pattern 'expr' in standard input". As a result: - Most likely we see a line as follows on standard output: ``` + noret_grep '(SA4000)' /tmp/tmp.xKUnikWsnw + grep '(SA4000)' /tmp/tmp.xKUnikWsnw + not grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)' + grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)' + [[ 1 == 1 ]] grep: crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000): No such file or directory ``` and the process continues without error, but doesn't do what we want it to do. - Occasionally, this causes a broken pipe on the first grep which results in an error: ``` + noret_grep '(SA4000)' /tmp/tmp.BmSCFYnqgE + grep '(SA4000)' /tmp/tmp.BmSCFYnqgE + not grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)' + grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)' grep: crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000): No such file or directory grep: write error: Broken pipe + [[ 2 == 1 ]] ``` --- scripts/vet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/vet.sh b/scripts/vet.sh index a2849f68f4d0..ab44f99682f3 100755 --- a/scripts/vet.sh +++ b/scripts/vet.sh @@ -121,7 +121,7 @@ XXXXX PleaseIgnoreUnused' # Ignore a false positive when operands have side affectes. # TODO(https://github.com/dominikh/go-tools/issues/54): Remove this once the issue is fixed in staticcheck. - noret_grep "(SA4000)" "${SC_OUT}" | not grep -ev "crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000)" + noret_grep "(SA4000)" "${SC_OUT}" | not grep -v -e "crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000)" # Only ignore the following deprecated types/fields/functions and exclude # generated code. From 43f42b271782a193beb0d25e05cdbe2369226ae1 Mon Sep 17 00:00:00 2001 From: Antoine Tollenaere Date: Wed, 17 Jul 2024 13:25:55 +0200 Subject: [PATCH 2/2] Avoid the use of \d which is not supported in basic regexes --- scripts/vet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/vet.sh b/scripts/vet.sh index ab44f99682f3..9db7b9ea35cb 100755 --- a/scripts/vet.sh +++ b/scripts/vet.sh @@ -121,7 +121,7 @@ XXXXX PleaseIgnoreUnused' # Ignore a false positive when operands have side affectes. # TODO(https://github.com/dominikh/go-tools/issues/54): Remove this once the issue is fixed in staticcheck. - noret_grep "(SA4000)" "${SC_OUT}" | not grep -v -e "crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000)" + noret_grep "(SA4000)" "${SC_OUT}" | not grep -v -e "crl.go:[0-9]\+:[0-9]\+: identical expressions on the left and right side of the '||' operator (SA4000)" # Only ignore the following deprecated types/fields/functions and exclude # generated code.