[PR #3051] feat: Make shell more robust #10521

Closed
opened 2026-02-16 18:15:12 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3051

State: closed
Merged: Yes


I noticed a few things to improve in the current implementation of the shell
commands, so I went ahead and did it.

Changes

  • Replaced scripts map with structured invocations map for clearer
    per-shell configuration
  • Removed eval ${input.command} which is error-prone and not general
  • Untangled bash and zsh rc file sourcing; previously it was sourcing both files
    for either shell, which could cause unintended side-effects

Verification

Ran the following:

SHELL=fish opencode
SHELL=sh opencode
SHELL=bash opencode
SHELL=zsh opencode
SHELL=nu opencode
SHELL= opencode (shows an error notification in the TUI, same as the current production version)

and within those TUI instances running the following command:

!echo "$SHELL" (!echo ($env.SHELL) for nu): prints the correct value

Tried the following edge cases in a random sample of shells:

! (empty shell command)
!cat
!bash
!| cat

None of those block, and have identical behavior as the production version.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3051 **State:** closed **Merged:** Yes --- I noticed a few things to improve in the current implementation of the shell commands, so I went ahead and did it. ## Changes - Replaced scripts map with structured invocations map for clearer per-shell configuration - Removed `eval ${input.command}` which is error-prone and not general - Untangled bash and zsh rc file sourcing; previously it was sourcing both files for either shell, which could cause unintended side-effects ## Verification Ran the following: `SHELL=fish opencode` `SHELL=sh opencode` `SHELL=bash opencode` `SHELL=zsh opencode` `SHELL=nu opencode` `SHELL= opencode` (shows an error notification in the TUI, same as the current production version) and within those TUI instances running the following command: `!echo "$SHELL"` (`!echo ($env.SHELL)` for `nu`): prints the correct value Tried the following edge cases in a random sample of shells: `!` (empty shell command) `!cat` `!bash` `!| cat` None of those block, and have identical behavior as the production version.
yindo added the pull-request label 2026-02-16 18:15:12 -05:00
yindo closed this issue 2026-02-16 18:15:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10521