Improve regex pattern to handle whitespace in environment variable parsing

Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-08-01 13:33:51 +00:00
parent 34e7cb0c16
commit 77955c95a7
1 changed files with 2 additions and 1 deletions

View File

@ -112,7 +112,8 @@ export class CommandLineAutoApprover extends Disposable {
// For bash/sh/bourne shell and unknown shells (fallback to bourne shell syntax)
// Handle environment variable assignments like: VAR=value VAR2=value command
const envVarPattern = /^([A-Za-z_][A-Za-z0-9_]*=(?:[^\s'"]|'[^']*'|"[^"]*")*\s+)+/;
// This regex matches one or more environment variable assignments at the start
const envVarPattern = /^(\s*[A-Za-z_][A-Za-z0-9_]*=(?:[^\s'"]|'[^']*'|"[^"]*")*\s+)+/;
const match = trimmedCommand.match(envVarPattern);
if (match) {