Skip to content

Commit d98c8e6

Browse files
authored
Merge branch 'main' into copilot/fix-3b6de93e-8dce-49f5-8cd1-5f79d0da7ad8
2 parents 0973218 + b1eac38 commit d98c8e6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/features/execution/execUtils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
export function quoteStringIfNecessary(arg: string): string {
2-
if (arg.indexOf(' ') >= 0 && !(arg.startsWith('"') && arg.endsWith('"'))) {
3-
return `"${arg}"`;
2+
// Always return if already quoted to avoid double-quoting
3+
if (arg.startsWith('"') && arg.endsWith('"')) {
4+
return arg;
45
}
5-
return arg;
6+
7+
// Quote if contains common shell special characters that are problematic across multiple shells
8+
// Includes: space, &, |, <, >, ;, ', ", `, (, ), [, ], {, }, $
9+
const needsQuoting = /[\s&|<>;'"`()\[\]{}$]/.test(arg);
10+
11+
return needsQuoting ? `"${arg}"` : arg;
612
}
713

814
export function quoteArgs(args: string[]): string[] {

src/features/terminal/terminalEnvVarInjector.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ export class TerminalEnvVarInjector implements Disposable {
110110
await this.injectEnvironmentVariablesForWorkspace(workspaceFolder);
111111
} else {
112112
// No provided workspace - update all workspaces
113-
this.envVarCollection.clear();
114113

115114
const workspaceFolders = workspace.workspaceFolders;
116115
if (!workspaceFolders || workspaceFolders.length === 0) {
@@ -140,7 +139,6 @@ export class TerminalEnvVarInjector implements Disposable {
140139

141140
// use scoped environment variable collection
142141
const envVarScope = this.getEnvironmentVariableCollectionScoped({ workspaceFolder });
143-
envVarScope.clear(); // Clear existing variables for this workspace
144142

145143
// Check if env file injection is enabled
146144
const config = getConfiguration('python', workspaceUri);

0 commit comments

Comments
 (0)