Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/tools/implementations/runTerminalCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] };
}
}

Expand Down
17 changes: 15 additions & 2 deletions extensions/cli/src/tools/runTerminalCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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): {
Expand Down
Loading