diff --git a/ariadne/k8s/exec.py b/ariadne/k8s/exec.py index ade0003..4ef3f96 100644 --- a/ariadne/k8s/exec.py +++ b/ariadne/k8s/exec.py @@ -59,8 +59,8 @@ def _build_command(command: list[str] | str, env: dict[str, str] | None) -> list else: cmd_str = shlex.join(command) if env: - prefix = " ".join(f"{key}={shlex.quote(value)}" for key, value in env.items()) - cmd_str = f"{prefix} {cmd_str}" + exports = "; ".join(f"export {key}={shlex.quote(value)}" for key, value in env.items()) + cmd_str = f"{exports}; {cmd_str}" return ["/bin/sh", "-c", cmd_str] diff --git a/tests/test_k8s_exec.py b/tests/test_k8s_exec.py index c295ebf..dc678be 100644 --- a/tests/test_k8s_exec.py +++ b/tests/test_k8s_exec.py @@ -60,7 +60,7 @@ class HangingStream(DummyStream): def test_build_command_wraps_env() -> None: cmd = _build_command(["echo", "hello"], {"FOO": "bar"}) assert cmd[0] == "/bin/sh" - assert "FOO=bar" in cmd[2] + assert "export FOO=bar" in cmd[2] def test_exec_returns_output(monkeypatch) -> None: