diff --git a/python/private/runtime_env_toolchain_interpreter.sh b/python/private/runtime_env_toolchain_interpreter.sh index c78cfe1a9b..57d9838919 100755 --- a/python/private/runtime_env_toolchain_interpreter.sh +++ b/python/private/runtime_env_toolchain_interpreter.sh @@ -77,7 +77,7 @@ if [ -e "$self_dir/pyvenv.cfg" ] || [ -e "$self_dir/../pyvenv.cfg" ]; then # binary, not the actual one invoked. # NOTE: exec -a would be simpler, but isn't posix-compatible, and dash shell # (Ubuntu/debian default) doesn't support it; see #3009. - exec sh -c "$PYTHON_BIN \$@" "$venv_bin" "$@" + exec sh -c 'exec "$@"' "$venv_bin" "$PYTHON_BIN" "$@" else exec "$PYTHON_BIN" "$@" fi diff --git a/tests/runtime_env_toolchain/BUILD.bazel b/tests/runtime_env_toolchain/BUILD.bazel index f1bda251f9..fde7d83db8 100644 --- a/tests/runtime_env_toolchain/BUILD.bazel +++ b/tests/runtime_env_toolchain/BUILD.bazel @@ -44,6 +44,7 @@ py_reconfig_test( py_reconfig_test( name = "bootstrap_script_test", srcs = ["toolchain_runs_test.py"], + args = ["argument with spaces"], bootstrap_impl = "script", data = [ "//tests/support:current_build_settings", diff --git a/tests/runtime_env_toolchain/toolchain_runs_test.py b/tests/runtime_env_toolchain/toolchain_runs_test.py index 13b5775ff0..4036bc724c 100644 --- a/tests/runtime_env_toolchain/toolchain_runs_test.py +++ b/tests/runtime_env_toolchain/toolchain_runs_test.py @@ -26,6 +26,7 @@ def test_ran(self): ) if settings["bootstrap_impl"] == "script": + self.assertEqual(sys.argv[1:], ["argument with spaces"]) # Verify we're running in a venv self.assertNotEqual(sys.prefix, sys.base_prefix) # .venv/ occurs for a build-time venv.