diff --git a/tests/tools/test_self_repo_guard.py b/tests/tools/test_self_repo_guard.py index d2738ecc90..c0f9ae9dc0 100644 --- a/tests/tools/test_self_repo_guard.py +++ b/tests/tools/test_self_repo_guard.py @@ -84,6 +84,9 @@ class TestBlocksMutationsInSourceRepo: "bash -lc 'git switch main'", "bash -o pipefail -c 'git checkout main'", "bash +O extglob -c 'git checkout main'", + "zsh -yc 'git checkout main'", + "dash -Vc 'git checkout main'", + "ksh -Gc 'git checkout main'", ], ) def test_wrappers_and_nested_shells(self, repo, command): diff --git a/tools/self_repo_guard.py b/tools/self_repo_guard.py index 6d3f4b4c81..218367adff 100644 --- a/tools/self_repo_guard.py +++ b/tools/self_repo_guard.py @@ -331,14 +331,26 @@ def _cd_target(executable: str, args: list[str], cwd: Path) -> Path | None: def _shell_script_arg(args: list[str]) -> str | None: """Return the script string owned by a shell's ``-c``, if present. - Delegates to approval.py's ``_bash_exec_payload``, which parses bash's - real option grammar (``-O/-o`` consume the next argument, short-option - bundles, ``--init-file``/``--rcfile``). A naive "leading option containing - 'c'" scan fails open on ``bash -o pipefail -c '