You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(interpreter): replace groupStdin string with StdinCursor class
Replaces the `groupStdin?: string` snapshot pattern in IOState with a
`StdinCursor` object that tracks a position index into the original
content. The cursor is shared by reference across commands in the same
while-loop body, so any command that consumes stdin advances the
position in-place without needing explicit snapshot/restore gymnastics.
Key changes:
- New `StdinCursor` class with `remaining`, `advance(n)`, `readAll()`
- `read` and `mapfile` builtins call `advance` / `readAll` on the cursor
- `file-reader.ts` calls `ctx.stdinCursor?.readAll()` so cat, grep,
head, awk, sed etc. inside while loops all advance position correctly
- `pipeline-execution.ts` simplified: save ref before pipeline, null it
for non-first commands, restore after — the shared object carries
any position advancement made by the first command
- `executeGroup`, `executeSubshell`, `executeUserScript`, `eval` all
install a fresh cursor only when they have their own stdin source;
otherwise they share the outer cursor
- `Bash.ts` constructs a StdinCursor from the top-level stdin option
instead of passing a raw string
Fixes the case where `cat | tr` (or any file-reader-based command) was
used as the first command in a while-loop pipeline body and failed to
advance the loop's stdin position.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyEbpGVknBW94w6XpvP462
0 commit comments