diff --git a/src/shell_install/powershell.rs b/src/shell_install/powershell.rs index b3e70f88..b08a75ca 100644 --- a/src/shell_install/powershell.rs +++ b/src/shell_install/powershell.rs @@ -25,19 +25,21 @@ Function br { $args = $args -join ' ' $cmd_file = New-TemporaryFile - $process = Start-Process -FilePath 'broot.exe' ` - -ArgumentList "--outcmd $($cmd_file.FullName) $args" ` - -NoNewWindow -PassThru -WorkingDirectory $PWD + try { + $process = Start-Process -FilePath 'broot.exe' ` + -ArgumentList "--outcmd $($cmd_file.FullName) $args" ` + -NoNewWindow -PassThru -WorkingDirectory $PWD - Wait-Process -InputObject $process #Faster than Start-Process -Wait - If ($process.ExitCode -eq 0) { - $cmd = Get-Content $cmd_file - Remove-Item $cmd_file - If ($cmd -ne $null) { Invoke-Expression -Command $cmd } - } Else { + Wait-Process -InputObject $process #Faster than Start-Process -Wait + If ($process.ExitCode -eq 0) { + $cmd = Get-Content $cmd_file + If ($cmd -ne $null) { Invoke-Expression -Command $cmd } + } Else { + Write-Host "`n" # Newline to tidy up broot unexpected termination + Write-Error "broot.exe exited with error code $($process.ExitCode)" + } + } finally { Remove-Item $cmd_file - Write-Host "`n" # Newline to tidy up broot unexpected termination - Write-Error "broot.exe exited with error code $($process.ExitCode)" } } "#;