diff --git a/scripts/Common/Scripts/Config.ps1 b/scripts/Common/Scripts/Config.ps1 index f846506b..c027e371 100644 --- a/scripts/Common/Scripts/Config.ps1 +++ b/scripts/Common/Scripts/Config.ps1 @@ -30,33 +30,36 @@ $null = New-Module { [string] $Path ) - $completed = $false; + & { + $ErrorActionPreference = 'Continue'; + $completed = $false; - while (-not $completed) { - $job = Start-Job { - $env:Value = Resolve-Path $Using:Path; - $env:WSLENV = "Value/p"; - $result = wsl -- bash -c 'echo "$Value"'; - wsl -e printf "%q" "$result"; - }; + while (-not $completed) { + $job = Start-Job { + $env:Value = Resolve-Path $Using:Path; + $env:WSLENV = "Value/p"; + $result = wsl -- bash -c 'echo "$Value"'; + wsl -e printf "%q" "$result"; + }; + + $result = Receive-Job -Wait $job; + + + if ((Split-Path -Leaf $Path) -ne (Split-Path -Leaf $result)) { + Write-Error "The result of the path conversion of ``$Path`` was unexpected: ``$result``"; + continue; + } + + if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) { + Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``"; + continue; + } - $result = Receive-Job -Wait $job; - - - if ((Split-Path -Leaf $Path) -ne (Split-Path -Leaf $result)) { - Write-Error "The result of the path conversion of ``$Path`` was unexpected: ``$result``"; - continue; - } - - if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) { - Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``"; - continue; + $completed = $true; } - $completed = $true; - } - - $result; + $result; + }; } <#