Skip to content

fix(bake): restore command-position detection on the Git Bash bake path (closes #9) - #13

Merged
ShortArrow merged 1 commit into
developfrom
fix/issue-9-cygwin-command-position
Jun 1, 2026
Merged

fix(bake): restore command-position detection on the Git Bash bake path (closes #9)#13
ShortArrow merged 1 commit into
developfrom
fix/issue-9-cygwin-command-position

Conversation

@ShortArrow

Copy link
Copy Markdown
Owner

Summary

  • Bug (Restore command-position detection on the Git Bash bake path (0.1.19) #9): 0.1.17 carved out command-position detection from the Git Bash bake-mode dispatcher so the Ctrl+C fix (Git Bash: bind -x line buffer not cleared by Ctrl+C after expansion #7) could ship as a focused release. As a result, on Git Bash any trailing token matching an abbreviation expanded regardless of context — echo gst<Space> expanded gst even though the user clearly wanted it as an argument to echo. Linux / WSL exec path has always honoured is_command_position, so the trade-off was Git-Bash-only.
  • Fix: bake dispatcher now reproduces domain::hook::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 defers to the same operator check. The bake path produces the byte-equivalent buffer rewrite as the exec path for every input.
  • Same PR tidy: __runex_cyg_expand prefix 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

  • 5 new unit tests in bash_static_dispatcher::tests pin the generated helper structure
  • 5 new Linux PTY tests in bash_cygwin_bake_pty.rs for argument position (no expand) and each command-position prefix
  • 4 new Windows-local smokes in bash_gitbash_smoke.rs across Git Bash + MSYS2 (+ Cygwin if installed)
  • 1 new exec-path PTY test in bash_pty_integration.rs mirrors the bake counterpart so parity is visible in one diff
  • 694 cargo tests pass on Windows local
  • 734 cargo tests pass on WSL Arch Linux
  • Manual verify on real Git Bash with 0.1.19:
  • CI: GitHub Actions Linux / Windows / macOS on this PR

Critical files

  • runex/src/app/bash_static_dispatcher.rs__runex_cyg_is_command_position helper + __runex_cyg_expand check + substring prefix + module docstring update + 5 unit tests
  • runex/tests/bash_cygwin_bake_pty.rs — 0.1.17 trade-off pin deleted + 5 new e2e tests
  • runex/tests/bash_gitbash_smoke.rs — 4 new Windows-local smokes
  • runex/tests/bash_pty_integration.rs — 1 new exec parity test
  • docs/setup.md / docs/setup.ja.md — trade-off item 7 removed
  • CHANGELOG.md — 0.1.19 entry under Fixed / Internal / Tests / Docs
  • runex/Cargo.toml — 0.1.18 → 0.1.19

Closes #9.

…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.
@ShortArrow
ShortArrow merged commit 2b9ad39 into develop Jun 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant