Skip to content

feat(adapters): Bash/Zsh native-location and POSIX-safe sh adapters (#16) - #19

Merged
joncrangle merged 3 commits into
masterfrom
feat/shell-native-adapters-16
Sep 9, 2026
Merged

joncrangle merged 3 commits into
masterfrom
feat/shell-native-adapters-16

Conversation

@joncrangle

Copy link
Copy Markdown
Owner

Closes #16.

Why

Replace the shared shell wrapper with separate strategies tailored to each runtime's capabilities:

  • Bash and Zsh use native caller metadata instead of synthetic per-line tracking or source rewriting.
  • POSIX sh uses an isolated POSIX-safe compatibility adapter without Bash/Zsh extensions.

What

  • Bash adapter (lua/itchy/adapters/bash.lua): Native caller-location instrumentation via BASH_LINENO[0] in a managed launcher; unchanged user source sourced in-place; framed records emitted to an adapter-private event file side-channel; preserves redirections, pipelines, and printf -v.
  • Zsh adapter (lua/itchy/adapters/zsh.lua): Native caller-location instrumentation via funcfiletrace[1] from zsh/parameter; preserves builtins, redirections, and pipelines.
  • POSIX sh adapter (lua/itchy/adapters/sh.lua): Dedicated POSIX-safe compatibility adapter; conservative source transformation limited to actual echo/printf commands; line count preserved 1:1; native stderr diagnostics mapped back through header line offset.
  • Shared shell machinery (lua/itchy/adapters/shell_common.lua): Private event file record decoding, stream folding to deduplicate delegated builtin output, native stderr diagnostic parsing, launcher templating, and runtime.args preservation.
  • Cleanup: Deleted obsolete shared wrapper lua/itchy/wrappers/shell.lua, updated lua/itchy/wrappers/init.lua, and removed shell-specific diagnostic parsing from lua/itchy/adapters/legacy.lua.
  • Tests: Comprehensive test suites for Bash, Zsh, and POSIX sh (covering echo, printf, functions, control flow, redirections, pipelines, command/builtin, printf -v, syntax errors, command-not-found, visual selections, POSIX safety regex gate, and custom runtime.args preservation).

Verification

  • Tests
  • Manual Check

Full test suite: 219 cases, 0 fails.

)

- Implement dedicated native caller-location adapter for Bash using BASH_LINENO
- Implement dedicated native caller-location adapter for Zsh using funcfiletrace
- Implement isolated POSIX-safe compatibility adapter for sh with minimal rewriting
- Use adapter-private event file side-channel for framed records to keep redirections and pipelines unpolluted
- Preserve runtime.args across shell adapters while filtering out inline -c
- Remove obsolete shared shell wrapper and legacy shell error parsing
- Add full test coverage across bash, zsh, and sh adapters
@joncrangle
joncrangle merged commit d07e238 into master Sep 9, 2026
4 checks passed
@joncrangle
joncrangle deleted the feat/shell-native-adapters-16 branch September 9, 2026 22:24
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.

Implement native Bash/Zsh adapters and a POSIX-safe sh compatibility path

1 participant