Skip to content

Commit 2322535

Browse files
authored
Refactor quoteStringIfNecessary to fix handling of single shell operators (#905)
fixes microsoft/vscode#269636
1 parent 7976ee7 commit 2322535

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/features/execution/execUtils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ export function quoteStringIfNecessary(arg: string): string {
44
return arg;
55
}
66

7+
// Don't quote single shell operators/special characters
8+
if (arg.length === 1 && /[&|<>;()[\]{}$]/.test(arg)) {
9+
return arg;
10+
}
11+
712
// Quote if contains common shell special characters that are problematic across multiple shells
813
// Includes: space, &, |, <, >, ;, ', ", `, (, ), [, ], {, }, $
914
const needsQuoting = /[\s&|<>;'"`()\[\]{}$]/.test(arg);

0 commit comments

Comments
 (0)