Skip to content

Commit 77955c9

Browse files
CopilotTyriar
andcommitted
Improve regex pattern to handle whitespace in environment variable parsing
Co-authored-by: Tyriar <[email protected]>
1 parent 34e7cb0 commit 77955c9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandLineAutoApprover.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export class CommandLineAutoApprover extends Disposable {
112112

113113
// For bash/sh/bourne shell and unknown shells (fallback to bourne shell syntax)
114114
// Handle environment variable assignments like: VAR=value VAR2=value command
115-
const envVarPattern = /^([A-Za-z_][A-Za-z0-9_]*=(?:[^\s'"]|'[^']*'|"[^"]*")*\s+)+/;
115+
// This regex matches one or more environment variable assignments at the start
116+
const envVarPattern = /^(\s*[A-Za-z_][A-Za-z0-9_]*=(?:[^\s'"]|'[^']*'|"[^"]*")*\s+)+/;
116117
const match = trimmedCommand.match(envVarPattern);
117118

118119
if (match) {

0 commit comments

Comments
 (0)