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

Closed
opened 2026-02-16 17:39:49 -05:00 by yindo · 4 comments
Owner

Originally created by @ayatofrench on GitHub (Dec 7, 2025).

Originally assigned to: @ayatofrench on GitHub.

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

Originally created by @ayatofrench on GitHub (Dec 7, 2025). Originally assigned to: @ayatofrench on GitHub. ### 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: ```ts 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
yindo added the opentuibugnix labels 2026-02-16 17:39:49 -05:00
yindo closed this issue 2026-02-16 17:39:49 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 7, 2025):

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] commented on GitHub (Dec 7, 2025): 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.
Author
Owner

@hsachdeva9 commented on GitHub (Dec 7, 2025):

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

@hsachdeva9 commented on GitHub (Dec 7, 2025): hey @ayatofrench, I would like to work on this issue, Could you please assign it to me?
Author
Owner

@rekram1-node commented on GitHub (Dec 7, 2025):

@ayatofrench sure thing!

@rekram1-node commented on GitHub (Dec 7, 2025): @ayatofrench sure thing!
Author
Owner

@rekram1-node commented on GitHub (Dec 7, 2025):

@hsachdeva9 ayato already volunteered

@rekram1-node commented on GitHub (Dec 7, 2025): @hsachdeva9 ayato already volunteered
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3372