Prevent unnecessary errors during WSL execution
This commit is contained in:
parent
31e3c51f97
commit
18abc9e499
1 changed files with 24 additions and 21 deletions
|
@ -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;
|
||||
$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 ((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;
|
||||
}
|
||||
|
||||
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;
|
||||
$result;
|
||||
};
|
||||
}
|
||||
|
||||
<#
|
||||
|
|
Loading…
Reference in a new issue