Skip to content

Fix: Add bash support#31

Merged
my-claude-utils merged 6 commits intomy-claude-utils:mainfrom
Biohazord:fix/add-bash-support
Mar 19, 2026
Merged

Fix: Add bash support#31
my-claude-utils merged 6 commits intomy-claude-utils:mainfrom
Biohazord:fix/add-bash-support

Conversation

@Biohazord
Copy link
Contributor

Description

Proposed fix for issue #29

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Chore (dependency updates, CI config, etc.)

Testing Checklist

  • Tested locally with npx clsh-dev (or npm run dev for development)
  • Lint passes (npm run lint)
  • Type checking passes (npm run typecheck)
  • Build succeeds (npm run build)
  • Tested on desktop browser
  • Tested on mobile browser (if UI change)

Adds bash as a supported shell type across agent and web packages.
Sessions exited immediately on systems without zsh because the shell was hardcoded. The server now detects available shells at startup (zsh > bash) and can be overridden with CLSH_SHELL env var. The client now defers shell selection to the server.

Closes my-claude-utils#29
@Biohazord Biohazord changed the title Fix/add bash support Fix: Add bash support Mar 18, 2026
}

const createSession = useCallback((): void => {
wsClient?.send({ type: 'session_create', shell: 'zsh' });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there is a plan to allow the user to select a shell, but this still functions as before.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is great!

Copy link
Owner

@my-claude-utils my-claude-utils left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice contribution — clean, well-scoped, and well-documented. Adding bash support + auto-detection is a great improvement for Linux users.

Two things to address before merging (one security, one nit):

  1. Command injection risk in shellExists() — see inline comment. Currently safe because callers validate first, but the function itself is unsafe by design. Since this is an open-source project, future contributors might call it without upstream validation.

  2. Missing trailing newline in .env.example — minor nit.

Everything else looks solid — types are consistent across frontend and backend, the DefaultableShell vs ShellType distinction is a good pattern, and making shell optional in session_create is the right call.

}

function shellExists(shell: string): boolean {
try {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security: command injection risk

execSync(\command -v ${shell}`)interpolatesshelldirectly into a shell command string. While the current callers validate againstDEFAULTABLE_SHELLSbefore calling this, the function itself accepts anystring, so a future contributor calling shellExists(userInput)` without validation would introduce command injection.

Defense in depth fix: pass shell as a positional argument instead of interpolating:

import { execFileSync } from 'node:child_process';

function shellExists(shell: string): boolean {
  try {
    execFileSync('sh', ['-c', 'command -v -- "$1"', '--', shell], { stdio: 'ignore' });
    return true;
  } catch {
    return false;
  }
}

This way the value of shell never gets interpreted by the shell, regardless of what's passed in. execFileSync doesn't spawn a shell for the outer call, and $1 passes the argument safely.

.env.example Outdated

# Optional: Default shell for new terminal sessions (auto-detected if not set)
# Valid values: bash, zsh
CLSH_SHELL= No newline at end of file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missing trailing newline. POSIX expects text files to end with \n.

@my-claude-utils my-claude-utils merged commit b86e0b3 into my-claude-utils:main Mar 19, 2026
2 checks passed
@my-claude-utils
Copy link
Owner

Thanks so much for this contribution @Biohazord! 🎉

Great work on the shell auto-detection and bash support. This makes clsh way more accessible for Linux users who don't have zsh installed. The DefaultableShell vs ShellType pattern is clean, and the config module is well-structured.

Merged and closing #29. Welcome aboard as a contributor!

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.

2 participants