Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 9db478a

Browse files
author
Max Schaefer
committed
Fix escaping in Makefile targets.
Previously, invoking `make autoformat` would run a command of this form: ```sh ... | grep \\.go$ | ... ``` Note that the `$` is not escaped. This probably wasn't intended, even though it happens to work anyway, since the shell doesn't try to expand lone `$`s. More problematically, invoking `make check-formatting` would run a command of this form: ```sh ... | grep \\.go| ... ``` Note that the `$` is gone, so it matches `.go` anywhere in the file name. In particular, it matches `ql/test/library-tests/semmle/go/frameworks/Protobuf/vendor/google.golang.org/protobuf/LICENSE`, which I think is responsible for the somewhat mysterious "expected 'package', found Copyright" errors we've been seeing from CI. This PR fixes both targets to run ```sh ... | grep '\.go$' | ... ``` Because of the single quotes we only need a single backslash, and the `$` gets left alone.
1 parent 88c740b commit 9db478a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ DATAFLOW_BRANCH=master
3131

3232
autoformat:
3333
find ql/src -name "*.ql" -or -name "*.qll" | xargs codeql query format -qq -i
34-
git ls-files | grep \\.go$$ | grep -v ^vendor/ | xargs grep -L "//\s*autoformat-ignore" | xargs gofmt -w
34+
git ls-files | grep '\.go$$' | grep -v ^vendor/ | xargs grep -L "//\s*autoformat-ignore" | xargs gofmt -w
3535

3636
check-formatting:
3737
find ql/src -name "*.ql" -or -name "*.qll" | xargs codeql query format --check-only
38-
test -z "$$(git ls-files | grep \\.go$ | grep -v ^vendor/ | xargs grep -L "//\s*autoformat-ignore" | xargs gofmt -l)"
38+
test -z "$$(git ls-files | grep '\.go$$' | grep -v ^vendor/ | xargs grep -L "//\s*autoformat-ignore" | xargs gofmt -l)"
3939

4040
tools: $(addsuffix $(EXE),$(addprefix tools/bin/,$(BINARIES))) tools/tokenizer.jar
4141

0 commit comments

Comments
 (0)