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
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automatic $? variable (success indicator) is reset to $true when a command is enclosed in parentheses - make $? only reflect command status, not expression status #3359
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