fix(terminal): also set MSYS2_ARG_CONV_EXCL for MSYS2/Cygwin bash fallback
MSYS_NO_PATHCONV is honored by Git for Windows bash only. _find_bash's final shutil.which fallback can return MSYS2-proper or Cygwin bash, which ignore it and honor MSYS2_ARG_CONV_EXCL instead. Set both so argv path conversion stays disabled regardless of which bash flavor spawns. Also subsumes the cmd /c mangling in #56147.
This commit is contained in:
parent
51c01062d4
commit
a2d49de801
2 changed files with 25 additions and 0 deletions
|
|
@ -260,6 +260,23 @@ class TestWindowsMsysPathconvDefaults:
|
|||
run_env = _make_run_env({"MSYS_NO_PATHCONV": "0"})
|
||||
assert run_env.get("MSYS_NO_PATHCONV") == "0"
|
||||
|
||||
def test_msys2_arg_conv_excl_set_on_windows(self, monkeypatch):
|
||||
# MSYS2-proper / Cygwin bash ignore MSYS_NO_PATHCONV; they honor
|
||||
# MSYS2_ARG_CONV_EXCL. Both must be set on every env builder.
|
||||
monkeypatch.setattr(local_mod, "_IS_WINDOWS", True)
|
||||
assert _make_run_env({}).get("MSYS2_ARG_CONV_EXCL") == "*"
|
||||
assert _sanitize_subprocess_env({}).get("MSYS2_ARG_CONV_EXCL") == "*"
|
||||
assert hermes_subprocess_env().get("MSYS2_ARG_CONV_EXCL") == "*"
|
||||
|
||||
def test_msys2_arg_conv_excl_not_set_on_posix(self, monkeypatch):
|
||||
monkeypatch.setattr(local_mod, "_IS_WINDOWS", False)
|
||||
assert "MSYS2_ARG_CONV_EXCL" not in _make_run_env({})
|
||||
|
||||
def test_msys2_arg_conv_excl_respects_user_override(self, monkeypatch):
|
||||
monkeypatch.setattr(local_mod, "_IS_WINDOWS", True)
|
||||
run_env = _make_run_env({"MSYS2_ARG_CONV_EXCL": "/custom"})
|
||||
assert run_env.get("MSYS2_ARG_CONV_EXCL") == "/custom"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Command wrapping — native Windows cwd must be Git Bash-friendly for cd
|
||||
|
|
|
|||
|
|
@ -759,10 +759,18 @@ def _apply_windows_msys_bash_env_defaults(env: dict) -> None:
|
|||
runs terminal commands through bash on Windows, so set the standard MSYS
|
||||
opt-out by default. Users who need conversion can override in their env.
|
||||
Refs #56700.
|
||||
|
||||
``MSYS_NO_PATHCONV`` is honored by Git for Windows bash only. MSYS2-proper
|
||||
and Cygwin bash (which ``_find_bash`` can still return via the final
|
||||
``shutil.which`` fallback) ignore it and honor ``MSYS2_ARG_CONV_EXCL``
|
||||
instead, so set both. ``*`` disables all argv conversion — the semantic
|
||||
equivalent of ``MSYS_NO_PATHCONV=1``. Also fixes ``cmd /c`` mangling
|
||||
(#56147).
|
||||
"""
|
||||
if not _IS_WINDOWS:
|
||||
return
|
||||
env.setdefault("MSYS_NO_PATHCONV", "1")
|
||||
env.setdefault("MSYS2_ARG_CONV_EXCL", "*")
|
||||
|
||||
|
||||
def _path_env_key(run_env: dict) -> str | None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue