opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Tighten shell validation in bash.ts to handle shells installed in non-standard paths

Open ayatofrench opened this issue 3 weeks ago • 4 comments

Description

Problem

The current shell detection logic in bash.ts contains a guard that returns the SHELL environment variable if it doesn't match a specific set of paths. When running in a Nix environment (or other shells installed by nix), the dynamically generated paths do not match the Set and are returned as valid.

Technical Detail

The check currently relies on an exact string match:


if (s) {
    if (!new Set(["/bin/fish", "/bin/nu", "/usr/bin/fish", "/usr/bin/nu"]).has(s)) {
       return s
    }
}

Proposed Solution

I recommend refactoring this guard to detect shells installed in non-standard paths (such as checking the base name of the path).

I’ve noticed other open PRs that add broader shell support, but I wanted to open this PR just in case such support might take some more time. I am happy to submit a PR with a fix.

OpenCode version

1.0.133

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

macOS

Terminal

Ghostty

ayatofrench avatar Dec 07 '25 07:12 ayatofrench

This issue might be a duplicate of existing issues. Please check:

  • #462: Add support for NixOS and/or Static linked binaries - addresses broader NixOS support concerns including shell path issues
  • #4968: Shell sessions losing $PATH value from parent shell - related shell environment variable/path handling in bash.ts
  • #4702: Add config to change shell for bash tool - related to shell configuration and detection

Feel free to ignore if none of these address your specific case.

github-actions[bot] avatar Dec 07 '25 07:12 github-actions[bot]

hey @ayatofrench, I would like to work on this issue, Could you please assign it to me?

hsachdeva9 avatar Dec 07 '25 07:12 hsachdeva9

@ayatofrench sure thing!

rekram1-node avatar Dec 07 '25 07:12 rekram1-node

@hsachdeva9 ayato already volunteered

rekram1-node avatar Dec 07 '25 07:12 rekram1-node