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
|
[string] $Path
|
||||||
)
|
)
|
||||||
|
|
||||||
$completed = $false;
|
& {
|
||||||
|
$ErrorActionPreference = 'Continue';
|
||||||
|
$completed = $false;
|
||||||
|
|
||||||
while (-not $completed) {
|
while (-not $completed) {
|
||||||
$job = Start-Job {
|
$job = Start-Job {
|
||||||
$env:Value = Resolve-Path $Using:Path;
|
$env:Value = Resolve-Path $Using:Path;
|
||||||
$env:WSLENV = "Value/p";
|
$env:WSLENV = "Value/p";
|
||||||
$result = wsl -- bash -c 'echo "$Value"';
|
$result = wsl -- bash -c 'echo "$Value"';
|
||||||
wsl -e printf "%q" "$result";
|
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)) {
|
if ((Split-Path -Leaf $Path) -ne (Split-Path -Leaf $result)) {
|
||||||
Write-Error "The result of the path conversion of ``$Path`` was unexpected: ``$result``";
|
Write-Error "The result of the path conversion of ``$Path`` was unexpected: ``$result``";
|
||||||
continue;
|
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)) {
|
$result;
|
||||||
Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``";
|
};
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$completed = $true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
|
Loading…
Reference in a new issue