Skip to content

Comments

Use -ErrorAction Ignore instead of SilentlyContinue with Get-Command in build.psm1#8832

Merged
anmenaga merged 1 commit intoPowerShell:masterfrom
SteveL-MSFT:build-erroraction-ignore
Feb 6, 2019
Merged

Use -ErrorAction Ignore instead of SilentlyContinue with Get-Command in build.psm1#8832
anmenaga merged 1 commit intoPowerShell:masterfrom
SteveL-MSFT:build-erroraction-ignore

Conversation

@SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Feb 5, 2019

PR Summary

Change use of SilentlyContinue with Get-Command to Ignore.

PR Context

We are using Get-Command foo -ErrorAction SilentlyContinue to test if a command exists and handle it accordingly. However, SilentlyContinue still puts the ErrorRecord into $Error which (currently) results in the CommandNotFoundSuggestion to show after the script finishes (if that experimental feature is enabledZ). The correct thing is to use Ignore since we are handling this case and not have the ErrorRecord show up in $Error

PR Checklist

…using it as equivalent to `Test-Command` and don't

want the error to be put into `$Error`
@anmenaga anmenaga merged commit 53ad397 into PowerShell:master Feb 6, 2019
@anmenaga anmenaga added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Feb 6, 2019
@SteveL-MSFT SteveL-MSFT deleted the build-erroraction-ignore branch June 6, 2020 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants