-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
vet: fix option order when invoking grep #7421
vet: fix option order when invoking grep #7421
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7421 +/- ##
==========================================
- Coverage 81.50% 81.32% -0.19%
==========================================
Files 350 350
Lines 26846 26846
==========================================
- Hits 21882 21832 -50
- Misses 3778 3810 +32
- Partials 1186 1204 +18 |
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 ]] ```
1b2bae6
to
22a5bf9
Compare
@@ -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:[0-9]\+:[0-9]\+: identical expressions on the left and right side of the '||' operator (SA4000)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting errors with \d because it didn't match the lines, I think this is because GNU grep doesn't support \d by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI I pinged this bug in the TODO. It'd be nice to be able to just delete this stuff instead.
Maybe we can simplify this to just not grep -v "crl.go:"
? I don't think the rest of it helps.
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:and the process continues without error, but doesn't do what we want it to do.
RELEASE NOTES: none