Skip to content
Myr

Add support for PowerShell 7.2+ (#1916)

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

PowerShell 7.2 has changed the way arguments are passed to executables. This was originally an experimental feature in 7.2, but as of 7.3 it is built-in. A simple "" is now sufficient for passing empty arguments, no back-tick escaping is required. Fixes #1849

authored by Oldřich Jedlička · committed by GitHub · parent 3daa4b9 · Browse files · 1 file+11 added−2 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: Oldřich Jedlička <oldium.pro@gmail.com>
  • Co-authored-by: Oldřich Jedlička <oldrich.jedlicka@rohlik.cz>

Diff stats

1 file+11 added−2 removed

  • other:+11 added−2 removed

1 file+11 added−2 removed

modified:powershell_completions.go+11 added-2 removed
105 unmodified lines
106 if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {107 # If the last parameter is complete (there is a space following it)108 # We add an extra empty parameter so we can indicate this to the go method.109 __%[1]s_debug "Adding extra empty parameter"110`+" # We need to use `\"`\" to pass an empty argument a \"\" or '' does not work!!!"+`111`+" $RequestComp=\"$RequestComp\" + ' `\"`\"'"+`110 # PowerShell 7.2+ changed the way how the arguments are passed to executables,111 # so for pre-7.2 or when Legacy argument passing is enabled we need to use112`+" # `\"`\" to pass an empty argument, a \"\" or '' does not work!!!"+`113 if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or114 ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or115 (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and116 $PSNativeCommandArgumentPassing -eq 'Legacy')) {117`+" $RequestComp=\"$RequestComp\" + ' `\"`\"'"+`118 } else {119 $RequestComp="$RequestComp" + ' ""'120 }121 }122123 __%[1]s_debug "Calling $RequestComp"124 # First disable ActiveHelp which is not supported for Powershell
201 unmodified lines