Skip to content

fix(interpreter): reset OPTIND between bash script invocations#478

Merged
chaliy merged 2 commits intomainfrom
claude/fix-397-Y2nIj
Mar 2, 2026
Merged

fix(interpreter): reset OPTIND between bash script invocations#478
chaliy merged 2 commits intomainfrom
claude/fix-397-Y2nIj

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Mar 2, 2026

Summary

  • Save/restore OPTIND and _OPTCHAR_IDX around execute_shell calls
  • Prevents getopts state from leaking between script invocations
  • Matches real bash behavior where each bash script.sh starts fresh

Closes #397

@chaliy chaliy force-pushed the claude/fix-397-Y2nIj branch from eb8c15c to 0372109 Compare March 2, 2026 18:24
claude added 2 commits March 2, 2026 18:50
OPTIND was persisting in interpreter variables across execute_shell
calls, causing getopts to skip all options on subsequent script runs.
Now save/restore OPTIND and _OPTCHAR_IDX around script execution,
matching real bash behavior where each `bash script.sh` starts fresh.

Closes #397
@chaliy chaliy force-pushed the claude/fix-397-Y2nIj branch from 5b9dcc5 to 919a729 Compare March 2, 2026 18:50
@chaliy chaliy merged commit fc51ce0 into main Mar 2, 2026
17 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.

fix(builtins): getopts while loop doesn't iterate

2 participants