mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Ensure running powershell within PowerShell starts instance of currently running PowerShell (#4481)
Modify PATH env var at startup so that $PSHOME is in front
This commit is contained in:
@@ -134,6 +134,14 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
#endif
|
||||
|
||||
// put PSHOME in front of PATH so that calling `powershell` within `powershell` always starts the same running version
|
||||
string path = Environment.GetEnvironmentVariable("PATH");
|
||||
string pshome = Utils.DefaultPowerShellAppBase;
|
||||
if (!path.Contains(pshome))
|
||||
{
|
||||
Environment.SetEnvironmentVariable("PATH", pshome + Path.PathSeparator + path);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string profileDir;
|
||||
|
||||
@@ -486,6 +486,12 @@ foo
|
||||
bash -c "unset HOME;$powershell -c '1+1'" | Should BeExactly 2
|
||||
}
|
||||
}
|
||||
|
||||
Context "PATH environment variable" {
|
||||
It "`$PSHOME should be in front so that powershell.exe starts current running PowerShell" {
|
||||
powershell -v | Should Match $psversiontable.GitCommitId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Console host api tests" -Tag CI {
|
||||
|
||||
Reference in New Issue
Block a user