Stop double-wrapping --run_under commandlines with bash

On non-windows platforms, `--run_under='cd /tmp &&' -- //foo:bar` would
become `/bin/bash -c '/bin/bash -c \'cd /tmp && /foo/bar\''`, now it's just
`/bin/bash -c 'cd /tmp && /foo/bar'`. This is a lot cleaner and less confusing
when it comes to trying to interpret or do anything novel with the command line.

The double-wrapping seems to have existed because that's the way the code
evolved, not necessity. See unknown commit for when the unconditional outer
/bin/bash was added.

This wound up being a lot more invasive than I had originally hoped, but I
think the restructuring is for the better. While all of the divergent ways of
doing things across and within linux and windows remain, at least they're
consolidated and better documented via tests.

RunCommandLine is moved to a builder to consolidate duplicate updates of args,
pretty args, and args-without-residue. Command-line production is implemented
via a new formatter interface, with a linux (aka non-windows) and windows
implementation.

Includes what I think is drive-by fix for the run executable not being escaped
with --run_under. That is, while I think the previous behavior was probably
functional, if we had thought about it I think we'd want to escape.

There are some bug-for-bug ports of existing issues, notably windows escaping
bugs. I tried to create github issues and linked TODOs for these.

There's probably more cleanup that can be done, but given the invasiveness I
tried to keep things focused.

PiperOrigin-RevId: 624974102
Change-Id: I973d473eb5afb2fd76a5d98cc624c236396af7fa
4 files changed
tree: c2fcde538abd158b09dc666d63ebf555125f6238
  1. .bazelci/
  2. .github/
  3. examples/
  4. scripts/
  5. site/
  6. src/
  7. third_party/
  8. tools/
  9. .bazelrc
  10. .bazelversion
  11. .gitattributes
  12. .gitignore
  13. AUTHORS
  14. bazel_downloader.cfg
  15. BUILD
  16. CHANGELOG.md
  17. CODE_OF_CONDUCT.md
  18. CODEOWNERS
  19. combine_distfiles.py
  20. combine_distfiles_to_tar.sh
  21. compile.sh
  22. CONTRIBUTING.md
  23. CONTRIBUTORS
  24. distdir.bzl
  25. extensions.bzl
  26. LICENSE
  27. maven_install.json
  28. MODULE.bazel
  29. MODULE.bazel.lock
  30. rbe_extension.bzl
  31. README.md
  32. repositories.bzl
  33. requirements.txt
  34. SECURITY.md
  35. WORKSPACE
  36. WORKSPACE.bzlmod
  37. workspace_deps.bzl
README.md

Bazel

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Reporting a Vulnerability

To report a security issue, please email security@bazel.build with a description of the issue, the steps you took to create the issue, affected versions, and, if known, mitigations for the issue. Our vulnerability management team will respond within 3 working days of your email. If the issue is confirmed as a vulnerability, we will open a Security Advisory. This project follows a 90 day disclosure timeline.

Contributing to Bazel

See CONTRIBUTING.md

Build status