Skip to content

Commit fdee73b

Browse files
authored
powershell: escape variable with curly brackets (#1960)
This fixes an issue with program names that include a dot, in our case `podman.exe`. This was caused by the change in commit 6ba7ebb. Fixes #1853 Signed-off-by: Paul Holzinger <[email protected]>
1 parent 988bd76 commit fdee73b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

powershell_completions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ filter __%[1]s_escapeStringWithSpecialChars {
4747
`+" $_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|\"|`|\\||<|>|&','`$&'"+`
4848
}
4949
50-
[scriptblock]$__%[2]sCompleterBlock = {
50+
[scriptblock]${__%[2]sCompleterBlock} = {
5151
param(
5252
$WordToComplete,
5353
$CommandAst,
@@ -122,7 +122,7 @@ filter __%[1]s_escapeStringWithSpecialChars {
122122
123123
__%[1]s_debug "Calling $RequestComp"
124124
# First disable ActiveHelp which is not supported for Powershell
125-
$env:%[10]s=0
125+
${env:%[10]s}=0
126126
127127
#call the command store the output in $out and redirect stderr and stdout to null
128128
# $Out is an array contains each line per element
@@ -279,7 +279,7 @@ filter __%[1]s_escapeStringWithSpecialChars {
279279
}
280280
}
281281
282-
Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock $__%[2]sCompleterBlock
282+
Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock ${__%[2]sCompleterBlock}
283283
`, name, nameForVar, compCmd,
284284
ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
285285
ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs, ShellCompDirectiveKeepOrder, activeHelpEnvVar(name)))

powershell_completions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ func TestPwshCompletionNoActiveHelp(t *testing.T) {
2929

3030
// check that active help is being disabled
3131
activeHelpVar := activeHelpEnvVar(c.Name())
32-
check(t, output, fmt.Sprintf("%s=0", activeHelpVar))
32+
check(t, output, fmt.Sprintf("${env:%s}=0", activeHelpVar))
3333
}

0 commit comments

Comments
 (0)