Skip to content

Search shell in path#11

Open
kevingosse wants to merge 1 commit intoalejandroqh:mainfrom
kevingosse:path
Open

Search shell in path#11
kevingosse wants to merge 1 commit intoalejandroqh:mainfrom
kevingosse:path

Conversation

@kevingosse
Copy link

When running term39 --shell pwsh, a warning is displayed:

Warning: Shell 'pwsh' not found, using system default shell

This PR updates the shell lookup logic to search PATH, and on Windows to automatically append .exe or .cmd to the executable name.

Copilot AI review requested due to automatic review settings March 17, 2026 09:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves custom shell handling in the terminal emulator by resolving shell names via PATH (and common Windows extensions) so --shell pwsh works when only the executable name is provided.

Changes:

  • Added shell_exists() helper to check shell availability via direct path or PATH lookup.
  • Updated ShellConfig::validate() to accept shells found on PATH.
  • Updated TerminalEmulator::new() to use the same PATH-aware existence check before spawning a custom shell.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if name.contains('/') || name.contains('\\') {
return false;
}
if let Ok(path_var) = std::env::var("PATH") {
Comment on lines +23 to +52
/// Check if a shell can be found, either as a direct path or via PATH lookup
fn shell_exists(name: &str) -> bool {
let path = std::path::Path::new(name);
if path.exists() {
return true;
}
// Only search PATH for bare names (no directory separators)
if name.contains('/') || name.contains('\\') {
return false;
}
if let Ok(path_var) = std::env::var("PATH") {
for dir in std::env::split_paths(&path_var) {
if dir.join(name).exists() {
return true;
}
#[cfg(windows)]
{
if !name.contains('.') {
if dir.join(format!("{}.exe", name)).exists() {
return true;
}
if dir.join(format!("{}.cmd", name)).exists() {
return true;
}
}
}
}
}
false
}
Comment on lines +24 to +36
fn shell_exists(name: &str) -> bool {
let path = std::path::Path::new(name);
if path.exists() {
return true;
}
// Only search PATH for bare names (no directory separators)
if name.contains('/') || name.contains('\\') {
return false;
}
if let Ok(path_var) = std::env::var("PATH") {
for dir in std::env::split_paths(&path_var) {
if dir.join(name).exists() {
return true;
@alejandroqh
Copy link
Owner

Thanks @kevingosse for the PR. I will prepare and include it in the next release soon.

@alejandroqh alejandroqh self-assigned this Mar 17, 2026
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.

3 participants