Skip to content
Merged
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
12 changes: 9 additions & 3 deletions src/features/execution/execUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
export function quoteStringIfNecessary(arg: string): string {
if (arg.indexOf(' ') >= 0 && !(arg.startsWith('"') && arg.endsWith('"'))) {
return `"${arg}"`;
// Always return if already quoted to avoid double-quoting
if (arg.startsWith('"') && arg.endsWith('"')) {
return arg;
}
return arg;

// Quote if contains common shell special characters that are problematic across multiple shells
// Includes: space, &, |, <, >, ;, ', ", `, (, ), [, ], {, }, $
const needsQuoting = /[\s&|<>;'"`()\[\]{}$]/.test(arg);

return needsQuoting ? `"${arg}"` : arg;
}

export function quoteArgs(args: string[]): string[] {
Expand Down
Loading