Skip to content
Myr

powershell: escape variable with curly brackets (#1960)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This fixes an issue with program names that include a dot, in our case `podman.exe`. This was caused by the change in commit 6ba7ebbc. Fixes #1853

authored by Paul Holzinger · committed by GitHub · parent 988bd76 · Browse files · 2 files+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: Paul Holzinger <pholzing@redhat.com>

Diff stats

2 files+4 added−4 removed

  • other:+4 added−4 removed

2 files+4 added−4 removed

modified:powershell_completions_test.go+1 added-1 removed
27 unmodified lines
28 output := buf.String()2930 // check that active help is being disabled31 activeHelpVar := activeHelpEnvVar(c.Name())32 check(t, output, fmt.Sprintf("%s=0", activeHelpVar))32 check(t, output, fmt.Sprintf("${env:%s}=0", activeHelpVar))33}
modified:powershell_completions.go+3 added-3 removed
45 unmodified lines
46filter __%[1]s_escapeStringWithSpecialChars {47`+" $_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|\"|`|\\||<|>|&','`$&'"+`48}4950[scriptblock]$__%[2]sCompleterBlock = {50[scriptblock]${__%[2]sCompleterBlock} = {51 param(52 $WordToComplete,53 $CommandAst,54 $CursorPosition
66 unmodified lines
121 }122123 __%[1]s_debug "Calling $RequestComp"124 # First disable ActiveHelp which is not supported for Powershell125 $env:%[10]s=0125 ${env:%[10]s}=0126127 #call the command store the output in $out and redirect stderr and stdout to null128 # $Out is an array contains each line per element129 Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
148 unmodified lines
278279 }280}281282Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock $__%[2]sCompleterBlock282Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock ${__%[2]sCompleterBlock}283`, name, nameForVar, compCmd,284 ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,285 ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs, ShellCompDirectiveKeepOrder, activeHelpEnvVar(name)))286}
39 unmodified lines