Skip to content

Commit

Permalink
fix issue with listing dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Kvadratni committed Feb 6, 2025
1 parent 5a1883f commit 2fc5fd2
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions crates/goose-mcp/src/developer/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,11 @@ pub struct ShellConfig {
impl Default for ShellConfig {
fn default() -> Self {
if cfg!(windows) {
// Prefer PowerShell over cmd.exe for better functionality
if std::process::Command::new("powershell.exe")
.arg("-Command")
.arg("exit")
.output()
.is_ok()
{
Self {
executable: "powershell.exe".to_string(),
arg: "-Command".to_string(),
redirect_syntax: "2>&1".to_string(), // PowerShell supports Unix-style redirection
}
} else {
Self {
executable: "cmd.exe".to_string(),
arg: "/C".to_string(),
redirect_syntax: "2>&1".to_string(), // cmd.exe also supports this syntax
}
// Use cmd.exe for simpler command execution
Self {
executable: "cmd.exe".to_string(),
arg: "/C".to_string(),
redirect_syntax: "2>&1".to_string(), // cmd.exe also supports this syntax
}
} else {
Self {
Expand All @@ -45,13 +32,8 @@ pub fn get_shell_config() -> ShellConfig {

pub fn format_command_for_platform(command: &str) -> String {
let config = get_shell_config();
if cfg!(windows) && config.executable == "powershell.exe" {
// For Windows PowerShell, wrap the command in braces
format!("{{ {} }} {}", command, config.redirect_syntax)
} else {
// For cmd.exe and Unix shells, no braces needed
format!("{} {}", command, config.redirect_syntax)
}
// For all shells, no braces needed
format!("{} {}", command, config.redirect_syntax)
}

pub fn expand_path(path_str: &str) -> String {
Expand Down

0 comments on commit 2fc5fd2

Please sign in to comment.