-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Preference variables generally take effect in the scope in which they're defined, which appears not be the case for $ErrorView, which only honors it in an ancestral scope:
Steps to reproduce
& { Set-Variable -Scope 0 VerbosePreference Continue; Write-Verbose 'I will display.' }
& { Set-Variable -Scope 0 ErrorView CategoryView; Get-Item /NoSuchItem }
& { Set-Variable -Scope 1 ErrorView CategoryView; Get-Item /NoSuchItem }Note: To re-run the test, start a new session, because the last command sets $ErrorView in the global scope.
Expected behavior
I will display.
ObjectNotFound: (/NoSuchItem:String) [Get-Item], ItemNotFoundException
ObjectNotFound: (/NoSuchItem:String) [Get-Item], ItemNotFoundExceptionActual behavior
I will display.
Get-Item : Cannot find path '/NoSuchItem' because it does not exist.
At line:1 char:54
+ ... t-Variable -Scope 0 ErrorView CategorizedView; Get-Item /NoSuchItem }
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (/NoSuchItem:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
ObjectNotFound: (/NoSuchItem:String) [Get-Item], ItemNotFoundExceptionSetting $ErrorView in the same scope as the failing Get-Item command didn't take effect - contrast this with the $VerbosePreference variable.
Environment data
PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64metablaster and rkeithhill
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime