Skip to content

Conversation

@adam-singer
Copy link
Contributor

command as a command-line script fails to get the parameters applied on $@ due to bazel escaping command in run_shell

If command is a string, then it is executed as if by sh -c <command> "" <arguments> -- that is, the elements in arguments are made available to the command as $1, $2 (or %1, %2 if using Windows batch), etc. If arguments contains any [actions.args()](https://bazel.build/rules/lib/builtins/actions#args) objects, their contents are appended one by one to the command line, so $i can refer to individual strings within an Args object. Note that if an Args object of unknown size is passed as part of arguments, then the strings will be at unknown indices; in this case the $@ shell substitution (retrieve all arguments) may be useful.

When sh -c is used the following arguments forwarded to the shell script will be ignored if other commands / variables follow. This causes arguments not to be forwarded to ty.

Example:

$ cat s.sh
#!/bin/sh
echo "ls start"
L=.

ls $@ $L && echo "ls done"

-----

# sh -c won't forward /tmp/

$ sh -c ./s.sh /tmp/
ls start
s.sh
ls done

-----

# invoking direct does forward

$ ./s.sh /tmp/
ls start
.:
s.sh

/tmp/:
logs

ls done

Changes are visible to end-users: no

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Adam Singer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@adam-singer adam-singer marked this pull request as ready for review February 9, 2026 22:32
@aspect-workflows
Copy link

aspect-workflows bot commented Feb 9, 2026

Bazel 7 (Test)

All tests were cache hits

6 tests (100.0%) were fully cached saving 2s.


Bazel 8 (Test)

All tests were cache hits

6 tests (100.0%) were fully cached saving 2s.


Bazel 9 (Test)

All tests were cache hits

6 tests (100.0%) were fully cached saving 2s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants