Skip to content

Commit 1d78304

Browse files
committed
update fix
1 parent f5f0c36 commit 1d78304

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/powershell.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export function generate(name: string, exec: string): string {
7171
# Split the command at the first space to separate the program and arguments.
7272
$Program, $Arguments = $Command.Split(" ", 2)
7373
74-
$RequestComp = "& ${exec} complete '--' '$Arguments'"
74+
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
75+
__${name}_debug "QuotedArgs: $QuotedArgs"
76+
77+
$RequestComp = "& ${exec} complete '--' $QuotedArgs"
7578
__${name}_debug "RequestComp: $RequestComp"
7679
7780
# we cannot use $WordToComplete because it

tests/shell.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ describe('shell completion generators', () => {
163163

164164
// Check that the script uses the provided exec path
165165
expect(script).toContain(
166-
`$RequestComp = "& ${exec} complete '--' '$Arguments'`
166+
`$RequestComp = "& ${exec} complete '--' $QuotedArgs"`
167167
);
168168

169169
// Check that the script handles directives

0 commit comments

Comments
 (0)