8000 Automatic $? variable (success indicator) is reset to $true when a command is enclosed in parentheses - make $? only reflect command status, not expression status · Issue #3359 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

8000
Skip to content
Automatic $? variable (success indicator) is reset to $true when a command is enclosed in parentheses - make $? only reflect command status, not expression status #3359
@mklement0

Description

@mklement0

Not sure if this behavior is by design; if so, it would help to understand the rationale.

Steps to reproduce

Get-Item -EA SilentlyContinue NoSuchItem; $?  # Failure is reflected in $? being $False
(Get-Item -EA SilentlyContinue NoSuchItem); $? #  Using (...) resets $? to $True 

Expected behavior

False
False

Actual behavior

False
True

Environment data

PowerShell Core v6.0.0-alpha (v6.0.0-alpha.17) on Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Maintainers-Documentationspecific to documentation in this repoIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Languageparser, language semantics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0