Tighten shell validation in bash.ts to handle shells installed in non-standard paths
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
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.
hey @ayatofrench, I would like to work on this issue, Could you please assign it to me?
@ayatofrench sure thing!
@hsachdeva9 ayato already volunteered