From 46a7ab67e6cf428bc46fa821c4d6ea987fa6d723 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 Dec 2025 05:52:39 +0800 Subject: [PATCH 1/7] fix: wrap dashes and arguments in single quotes --- src/powershell.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell.ts b/src/powershell.ts index 002d314..ee2fac5 100644 --- a/src/powershell.ts +++ b/src/powershell.ts @@ -71,7 +71,7 @@ export function generate(name: string, exec: string): string { # Split the command at the first space to separate the program and arguments. $Program, $Arguments = $Command.Split(" ", 2) - $RequestComp = "& ${exec} complete -- $Arguments" + $RequestComp = "& ${exec} complete '--' '$Arguments'" __${name}_debug "RequestComp: $RequestComp" # we cannot use $WordToComplete because it From ab512b14d14c1be625d88578b7a3090096c72baa Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 Dec 2025 05:56:54 +0800 Subject: [PATCH 2/7] chore: add changeset for patch on @bomb.sh/tab --- .changeset/mean-stingrays-begin.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/mean-stingrays-begin.md diff --git a/.changeset/mean-stingrays-begin.md b/.changeset/mean-stingrays-begin.md new file mode 100644 index 0000000..8bba781 --- /dev/null +++ b/.changeset/mean-stingrays-begin.md @@ -0,0 +1,5 @@ +--- +"@bomb.sh/tab": patch +--- + +fix: wrap dashes and arguments in single quotes From f5f0c364035994a2e30aef219e138ed02e4ac92b Mon Sep 17 00:00:00 2001 From: so1ve Date: Tue, 16 Dec 2025 20:25:41 +0800 Subject: [PATCH 3/7] test: fix test --- tests/shell.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/shell.test.ts b/tests/shell.test.ts index b65c4ec..b61ff8f 100644 --- a/tests/shell.test.ts +++ b/tests/shell.test.ts @@ -162,7 +162,9 @@ describe('shell completion generators', () => { expect(script).toContain(`[scriptblock]$__${name}CompleterBlock =`); // Check that the script uses the provided exec path - expect(script).toContain(`$RequestComp = "& ${exec} complete --`); + expect(script).toContain( + `$RequestComp = "& ${exec} complete '--' '$Arguments'` + ); // Check that the script handles directives expect(script).toContain( From 1d78304a6727f3075f77028bf9e28d993683daa2 Mon Sep 17 00:00:00 2001 From: so1ve Date: Wed, 17 Dec 2025 05:29:13 +0800 Subject: [PATCH 4/7] update fix --- src/powershell.ts | 5 ++++- tests/shell.test.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/powershell.ts b/src/powershell.ts index ee2fac5..1a555a5 100644 --- a/src/powershell.ts +++ b/src/powershell.ts @@ -71,7 +71,10 @@ export function generate(name: string, exec: string): string { # Split the command at the first space to separate the program and arguments. $Program, $Arguments = $Command.Split(" ", 2) - $RequestComp = "& ${exec} complete '--' '$Arguments'" + $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' ' + __${name}_debug "QuotedArgs: $QuotedArgs" + + $RequestComp = "& ${exec} complete '--' $QuotedArgs" __${name}_debug "RequestComp: $RequestComp" # we cannot use $WordToComplete because it diff --git a/tests/shell.test.ts b/tests/shell.test.ts index b61ff8f..807fde9 100644 --- a/tests/shell.test.ts +++ b/tests/shell.test.ts @@ -163,7 +163,7 @@ describe('shell completion generators', () => { // Check that the script uses the provided exec path expect(script).toContain( - `$RequestComp = "& ${exec} complete '--' '$Arguments'` + `$RequestComp = "& ${exec} complete '--' $QuotedArgs"` ); // Check that the script handles directives From 3cfe75d32adf73654869a241e9d8e2ad9cca8a77 Mon Sep 17 00:00:00 2001 From: AmirSa12 Date: Sun, 21 Dec 2025 17:39:51 +0330 Subject: [PATCH 5/7] fix: consistency between version since all artgs are single-qouted --- src/powershell.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/powershell.ts b/src/powershell.ts index 1a555a5..54e5af6 100644 --- a/src/powershell.ts +++ b/src/powershell.ts @@ -103,10 +103,10 @@ export function generate(name: string, exec: string): string { if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and - $PSNativeCommandArgumentPassing -eq 'Legacy')) { - $RequestComp="$RequestComp" + ' \`"\`"' + $PSNativeCommandArgumentPassing -eq 'Legacy')) { + $RequestComp="$RequestComp" + " ''" } else { - $RequestComp = "$RequestComp" + ' ""' + $RequestComp = "$RequestComp" + " ''" } } From f8aa8545b43e871c82037bc9ff406cfd1bde6d8a Mon Sep 17 00:00:00 2001 From: AmirSa12 Date: Sun, 21 Dec 2025 17:59:57 +0330 Subject: [PATCH 6/7] Revert "fix: consistency between version since all artgs are single-qouted" This reverts commit 3cfe75d32adf73654869a241e9d8e2ad9cca8a77. --- src/powershell.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/powershell.ts b/src/powershell.ts index 54e5af6..1a555a5 100644 --- a/src/powershell.ts +++ b/src/powershell.ts @@ -103,10 +103,10 @@ export function generate(name: string, exec: string): string { if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and - $PSNativeCommandArgumentPassing -eq 'Legacy')) { - $RequestComp="$RequestComp" + " ''" + $PSNativeCommandArgumentPassing -eq 'Legacy')) { + $RequestComp="$RequestComp" + ' \`"\`"' } else { - $RequestComp = "$RequestComp" + " ''" + $RequestComp = "$RequestComp" + ' ""' } } From a5e81681fb4405835ae1a94ec999241eab9a85ee Mon Sep 17 00:00:00 2001 From: AmirSa12 Date: Sun, 21 Dec 2025 18:13:55 +0330 Subject: [PATCH 7/7] prettier --- .changeset/mean-stingrays-begin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/mean-stingrays-begin.md b/.changeset/mean-stingrays-begin.md index 8bba781..63bf43d 100644 --- a/.changeset/mean-stingrays-begin.md +++ b/.changeset/mean-stingrays-begin.md @@ -1,5 +1,5 @@ --- -"@bomb.sh/tab": patch +'@bomb.sh/tab': patch --- fix: wrap dashes and arguments in single quotes