Documentation
¶
Overview ¶
Package winpsenv prepares the environment for Windows PowerShell child processes.
When sailwright is started from PowerShell 7 (pwsh), for example from the default shell of GitHub Actions Windows runners, child processes inherit pwsh's PSModulePath. Windows PowerShell 5.1 then loads incompatible PowerShell 7 core modules: Microsoft.PowerShell.Security fails to load and the Cert: drive is missing, among other breakage. pwsh applies a similar mitigation (removing its own module paths) when it starts powershell.exe directly; this package does the same for processes sailwright starts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandEnv ¶
CommandEnv returns the environment for a child process started with executable, or nil to inherit the current environment unchanged. extraEnv is appended last so it overrides inherited values.
func IsWindowsPowerShell ¶
IsWindowsPowerShell reports whether executable names Windows PowerShell (powershell or powershell.exe, optionally with a directory), as opposed to PowerShell 7 (pwsh).
func Sanitize ¶
Sanitize returns environ with PowerShell 7 module directories removed from PSModulePath when executable is Windows PowerShell, plus the removed entries. For any other executable, or when nothing is removed, environ is returned unchanged. If PSModulePath only held PowerShell 7 entries, the variable is dropped so Windows PowerShell computes its default.
Types ¶
This section is empty.