fix(bake): restore command-position detection on the Git Bash bake path (closes #9) - #13
Merged
Merged
Conversation
…th (closes #9) 0.1.17 introduced the bake-mode dispatcher to fix the cygwin signal loss after `bind -x` (#7), but as a carved-out interim trade-off the bake path expanded any trailing token that matched an abbreviation regardless of whether the prefix was a command position. The Linux / WSL exec path has always honoured `domain::hook::is_command_position`; on Git Bash the same input rewrote the buffer to a fully expanded form. Concretely, `echo gst<Space>` would expand `gst` on Git Bash even though the user clearly wanted `gst` as an argument to `echo`. The bake dispatcher now reproduces `is_command_position` in pure bash via `__runex_cyg_is_command_position`: a `case` over the four pipeline operators (`&&`, `||`, `|`, `;`) plus a trailing-`sudo` recursion that itself defers to the same operator check. The bake path produces the byte-equivalent buffer rewrite as the exec path for every input — `gst<Space>` still expands at line start, `sudo gst<Space>` still expands via the recursion, and `echo gst<Space>` now stops expanding as it should. Same PR also switches the `__runex_cyg_expand` prefix computation from `${left%$token}` to a substring slice. The old form treated the token as a `%` glob pattern, so a token containing `?` / `*` / `[` would strip an unintended portion of the left side. The new substring form is byte-faithful regardless of token contents. Tests: - 5 new unit tests in `bash_static_dispatcher::tests` pin the generated helper structure (helper present, every pipeline-op pattern present, sudo word check present, check runs before lookup, substring prefix replaces the glob). - 5 new Linux PTY tests in `bash_cygwin_bake_pty.rs` for argument position (no expand) and each command-position prefix (`sudo`, `|`, `&&`, `;`). The 0.1.17 trade-off pin (`cygwin_bake_expands_even_when_token_is_not_in_command_position`) is replaced by a positive `cygwin_bake_skips_expansion_after_echo`. - 4 new Windows-local smokes in `bash_gitbash_smoke.rs` drive `__runex_expand` with `READLINE_LINE` directly on every cygwin- family bash installed (Git Bash, MSYS2, optionally upstream Cygwin). - 1 new exec-path PTY test (`bash_pty_integration::space_does_not_expand_after_echo_argument_position`) mirrors the bake-path counterpart so the parity is visible in a single diff. - Manual verify on real Git Bash with 0.1.19: `echo gst<Space>` no longer expands; `sudo gst<Space>` still does; `gst<Space>` still does; Ctrl+C after expansion still works (no #7 regression). Docs: - `docs/setup.md` / `docs/setup.ja.md` troubleshooting item 7 ("Git Bash 0.1.17 interim trade-off") removed. - Module docstring at the top of `bash_static_dispatcher.rs` swaps the trade-off section for a parity note that maps each Rust branch to its bash counterpart. Bump version 0.1.18 → 0.1.19 + Cargo.lock + CHANGELOG.
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
echo gst<Space>expandedgsteven though the user clearly wanted it as an argument toecho. Linux / WSL exec path has always honouredis_command_position, so the trade-off was Git-Bash-only.domain::hook::is_command_positionin pure bash via__runex_cyg_is_command_position— acaseover the four pipeline operators (&&,||,|,;) plus a trailing-sudorecursion that defers to the same operator check. The bake path produces the byte-equivalent buffer rewrite as the exec path for every input.__runex_cyg_expandprefix computation switches from${left%$token}(which treated the token as a%glob pattern) to a substring slice. The new form is byte-faithful regardless of whether the token contains?/*/[.Test plan
bash_static_dispatcher::testspin the generated helper structurebash_cygwin_bake_pty.rsfor argument position (no expand) and each command-position prefixbash_gitbash_smoke.rsacross Git Bash + MSYS2 (+ Cygwin if installed)bash_pty_integration.rsmirrors the bake counterpart so parity is visible in one diffgst<Space>still expands at line start ✓sudo gst<Space>still expands via sudo recursion ✓echo gst<Space>now self-inserts (= no expand) ✓ ← issue Restore command-position detection on the Git Bash bake path (0.1.19) #9 coreCritical files
runex/src/app/bash_static_dispatcher.rs—__runex_cyg_is_command_positionhelper +__runex_cyg_expandcheck + substring prefix + module docstring update + 5 unit testsrunex/tests/bash_cygwin_bake_pty.rs— 0.1.17 trade-off pin deleted + 5 new e2e testsrunex/tests/bash_gitbash_smoke.rs— 4 new Windows-local smokesrunex/tests/bash_pty_integration.rs— 1 new exec parity testdocs/setup.md/docs/setup.ja.md— trade-off item 7 removedCHANGELOG.md— 0.1.19 entry under Fixed / Internal / Tests / Docsrunex/Cargo.toml— 0.1.18 → 0.1.19Closes #9.