GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use `-ErrorAction Ignore` instead of `SilentlyContinue` with `Get-Command` in build.psm1 by SteveL-MSFT · Pull Request #8832 · PowerShell/PowerShell

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Feb 5, 2019 •
edited by adityapatwardhan
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] to your commit messages if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT
Use -ErrorAction Ignore instead of SilentlyContinue since we are …
3e34b48
…using it as equivalent to `Test-Command` and don't

want the error to be put into `$Error`
@SteveL-MSFT Steve Lee (SteveL-MSFT) assigned Andrew (anmenaga) Feb 5, 2019
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested a review from James Truher (JamesWTruher) February 5, 2019 16:57
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested review from Paul Higinbotham (PaulHigin), Travis Plunk (TravisEz13), Aditya Patwardhan (adityapatwardhan), Andrew (anmenaga) and Dongbo Wang (daxian-dbw) as code owners February 5, 2019 16:57
PaulHigin
Paul Higinbotham (PaulHigin) approved these changes Feb 5, 2019
View reviewed changes
adityapatwardhan
Aditya Patwardhan (adityapatwardhan) approved these changes Feb 5, 2019
View reviewed changes
iSazonov
Ilya (iSazonov) approved these changes Feb 5, 2019
View reviewed changes
TravisEz13
Travis Plunk (TravisEz13) approved these changes Feb 5, 2019
View reviewed changes
@anmenaga
Andrew (anmenaga) merged commit 53ad397 into PowerShell:master Feb 6, 2019
@anmenaga Andrew (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
Steve Lee (SteveL-MSFT) deleted the build-erroraction-ignore branch June 6, 2020 02:29
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SteveL-MSFT Andrew
Use -ErrorAction Ignore instead of SilentlyContinue with `Get-Com…
79a4fb9
…mand` in build.psm1 (PowerShell#8832)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@TravisEz13 Travis Plunk (TravisEz13) TravisEz13 approved these changes
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) adityapatwardhan approved these changes
@iSazonov Ilya (iSazonov) iSazonov approved these changes
@JamesWTruher James Truher (JamesWTruher) Awaiting requested review from JamesWTruher
@anmenaga Andrew (anmenaga) Awaiting requested review from anmenaga
@daxian-dbw Dongbo Wang (daxian-dbw) Awaiting requested review from daxian-dbw
+1 more reviewer
@PaulHigin Paul Higinbotham (PaulHigin) PaulHigin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@anmenaga Andrew (anmenaga)

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@SteveL-MSFT @TravisEz13 @adityapatwardhan @PaulHigin @iSazonov @anmenaga
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.