fix(pwsh): call convert-path before setting workingdirectory

Only for FileSystem psprovider
This commit is contained in:
lnu 2022-04-07 08:44:17 +02:00 committed by Jan De Dobbeleer
parent 39a272af76
commit a31d718fcb

View file

@ -1,5 +1,4 @@
function global:Start-Utf8Process
{
function global:Start-Utf8Process {
param(
[string] $FileName,
[string] $Arguments
@ -12,7 +11,9 @@ function global:Start-Utf8Process
$StartInfo.FileName = $filename
$StartInfo.Arguments = $Arguments
$StartInfo.UseShellExecute = $false
$StartInfo.WorkingDirectory = $PWD #when UseShellExecute=false, workingDirectory=""
if ($pwd.provider.name -eq "FileSystem") { #workingdirectory does not work with registry path
$StartInfo.WorkingDirectory = convert-path $pwd #when UseShellExecute=false, workingDirectory=""
}
$StartInfo.CreateNoWindow = $true
$_ = $Process.Start();
$_ = $Process.WaitForExit();
@ -192,7 +193,8 @@ function global:Enable-PoshTransientPrompt {
[Console]::OutputEncoding = [Text.Encoding]::UTF8
try {
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
} finally {
}
finally {
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
[Console]::OutputEncoding = $previousOutputEncoding
}