Skip to content

Commit 8b4e835

Browse files
committed
fix: don't put environment variables in a module.
1 parent 03a9f95 commit 8b4e835

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/shell/powershell.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ type pwsh struct{}
3030
var Pwsh Shell = pwsh{}
3131

3232
const hook = `
33+
34+
# All environment variables must be set in global scope
35+
# DO NOT PUT IN MODULE
3336
{{.EnvContent}}
3437
38+
$env:__VFOX_PID = $pid;
39+
3540
# remove any existing dynamic module of vfox
3641
if ($null -ne (Get-Module -Name "version-fox")) {
3742
Remove-Module -Name "version-fox" -Force
@@ -45,7 +50,6 @@ New-Module -Name "version-fox" -ScriptBlock {
4550
#>
4651
& '{{.SelfPath}}' env --cleanup 2>$null | Out-Null;
4752
48-
$env:__VFOX_PID = $pid;
4953
$originalPrompt = $function:prompt;
5054
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [Text.UTF8Encoding]::UTF8;
5155
@@ -70,7 +74,6 @@ New-Module -Name "version-fox" -ScriptBlock {
7074
# perform cleanup on removal so a new initialization in current session works
7175
$ExecutionContext.SessionState.Module.OnRemove += {
7276
$function:prompt = $originalPrompt
73-
Remove-Item -Path Env:__VFOX_PID
7477
Unregister-Event -SubscriptionId $subscription.Id
7578
}
7679
} | Import-Module -Global

0 commit comments

Comments
 (0)