From 268d0ffa05d97eb9c836e790b9a4a25a9d1d49fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hauke=20G=C3=BCnther?= Date: Wed, 22 Jun 2022 22:15:27 +0200 Subject: Fix error when ghdl.exe is searched with Get-Command but not found Without adding `-ErrorAction Stop` the routine does not go into the catch case but continues to run with an undefined variable `$GHDLBinary`. --- scripts/vendors/shared.psm1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/vendors/shared.psm1 b/scripts/vendors/shared.psm1 index bc6f6f93c..51f492874 100644 --- a/scripts/vendors/shared.psm1 +++ b/scripts/vendors/shared.psm1 @@ -156,16 +156,19 @@ function Get-GHDLBinary { $GHDLBinary = $env:GHDL } else { try - { write-host "calling which ..." - $GHDLBinary = (Get-Command "ghdl.exe").Source } + { Write-host "Calling Get-Command ..." + $GHDLBinary = (Get-Command "ghdl.exe" -ErrorAction Stop).Source } catch - { Write-Host "Use adv. options '-GHDL' to set the GHDL executable." -ForegroundColor Red + { Write-Host "Cannot find ghdl.exe." -ForegroundColor Red + Write-Host "Use adv. options '-GHDL' to set the GHDL executable." -ForegroundColor Red Exit-CompileScript -1 } } if (-not (Test-Path $GHDLBinary -PathType Leaf)) - { Write-Host "Use adv. options '-GHDL' to set the GHDL executable." -ForegroundColor Red + { + Write-Host "$GHDLBinary is not a file." -ForegroundColor Red + Write-Host "Use adv. options '-GHDL' to set the GHDL executable." -ForegroundColor Red Exit-CompileScript -1 } -- cgit v1.2.3