diff --git a/scripts/Common/Scripts/Config.ps1 b/scripts/Common/Scripts/Config.ps1 index 34f56f1f..f846506b 100644 --- a/scripts/Common/Scripts/Config.ps1 +++ b/scripts/Common/Scripts/Config.ps1 @@ -30,21 +30,30 @@ $null = New-Module { [string] $Path ) - $job = Start-Job { - $env:Value = Resolve-Path $Using:Path; - $env:WSLENV = "Value/p"; - $result = wsl -- bash -c 'echo "$Value"'; - wsl -e printf "%q" "$result"; - }; + $completed = $false; - $result = Receive-Job -Wait $job; + 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``"; - } - if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) { - Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``"; + 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; } $result;