From 1ae4cab3e5270fc094ae17bf128fdb3fb5dff39d Mon Sep 17 00:00:00 2001 From: serhiizghama Date: Thu, 14 May 2026 03:08:22 +0700 Subject: [PATCH] fix(terminal): skip -l login flag for csh and tcsh csh and tcsh do not accept -l as a flag, causing every terminal command to fail with 'Unknown option: -l' when $SHELL points to one of them. Detect the shell name and only pass -l when the shell is known to support it. csh and tcsh automatically source their rc files on every invocation, so login shell behavior is preserved. Fixes #12378 --- .../tools/implementations/runTerminalCommand.ts | 6 +++++- extensions/cli/src/tools/runTerminalCommand.ts | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) 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): {