diff --git a/core/tools/implementations/runTerminalCommand.ts b/core/tools/implementations/runTerminalCommand.ts index 8f6201bd12c..6facf101f53 100644 --- a/core/tools/implementations/runTerminalCommand.ts +++ b/core/tools/implementations/runTerminalCommand.ts @@ -32,7 +32,11 @@ function getShellCommand(command: string): { shell: string; args: string[] } { } else { // Unix/macOS: Use login shell to source .bashrc/.zshrc etc. const userShell = process.env.SHELL || "/bin/bash"; - return { shell: userShell, args: ["-l", "-c", command] }; + // csh and tcsh do not accept -l as a flag, so skip the login flag for them. + const shellName = userShell.split("/").pop() || ""; + const loginArgs = + shellName === "csh" || shellName === "tcsh" ? [] : ["-l"]; + return { shell: userShell, args: [...loginArgs, "-c", command] }; } } diff --git a/extensions/cli/src/tools/runTerminalCommand.ts b/extensions/cli/src/tools/runTerminalCommand.ts index 6b640c6a1c3..92b5a59a1be 100644 --- a/extensions/cli/src/tools/runTerminalCommand.ts +++ b/extensions/cli/src/tools/runTerminalCommand.ts @@ -77,13 +77,26 @@ function getShellCommand(command: string): { shell: string; args: string[] } { const wslShell = process.env.SHELL || "/bin/bash"; return { shell: wslShell, - args: ["-l", "-c", command], + args: [...getLoginShellArgs(wslShell), "-c", command], }; } // Unix/macOS: Use login shell to source .bashrc/.zshrc etc. const userShell = process.env.SHELL || "/bin/bash"; - return { shell: userShell, args: ["-l", "-c", command] }; + return { + shell: userShell, + args: [...getLoginShellArgs(userShell), "-c", command], + }; +} + +// csh and tcsh do not accept -l as a flag, so skip the login flag for them. +// They automatically source ~/.cshrc / ~/.tcshrc on every invocation anyway. +function getLoginShellArgs(shellPath: string): string[] { + const shellName = shellPath.split("/").pop() || ""; + if (shellName === "csh" || shellName === "tcsh") { + return []; + } + return ["-l"]; } export function runCommandInBackground(command: string): {