.bazelrc does not tokenize according to the Bourne shell as claimed
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the problem / feature request:
`.bazelrc` appears to be parsed with Python syntax, not Bourne shell syntax.
### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
- `.bazelrc`: `build --copt='-DTEST="a\\nc"'`
- `WORKSPACE`: `workspace(name = "bazeltest")`
- `BUILD.bazel`: `cc_test(name = "main", srcs = ["main.cc"])`
- `main.cc`: `#include ` `int main() { printf("%s\n", TEST); return 0; }`
- `bazel run //:main`
I expect to see `a\nc` as `g++ '-DTEST="a\\nc"' main.cc -o main.exe && ./main.exe` would produce, but instead I see `ac`.
### What operating system are you running Bazel on?
Windows
### What's the output of `bazel info release`?
release 3.2.0
### Have you found anything relevant by searching the web?
The documentation [says](https://docs.bazel.build/versions/1.1.0/guide.html#bazelrc-syntax-and-semantics)
> Like all UNIX “rc” files, the `.bazelrc` file is a text file with a line-based grammar. Empty lines and lines starting with `#` (comments) are ignored. Each line contains a sequence of words, which are tokenized according to the same rules as the Bourne shell.
but this appears to be incorrect as shown above, and I'm not sure what the intended behavior is.
Contributor guide
Research direction
Start with the minimal `.bazelrc` example and the linked Bazelrc syntax documentation, then run `bazel run //:main` on Windows to reproduce the difference in escaped newline handling. Trace the `.bazelrc` tokenization entry point and compare its behavior with the documented Bourne-shell rules; done means the intended behavior is established and the implementation or documentation is consistent with it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100