Open
Conversation
There was a problem hiding this comment.
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; |
Owner
|
Thanks @kevingosse for the PR. I will prepare and include it in the next release soon. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When running
term39 --shell pwsh, a warning is displayed:This PR updates the shell lookup logic to search PATH, and on Windows to automatically append
.exeor.cmdto the executable name.