-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Milestone
Description
- Create a script with the following code:
function foo
{
[CmdletBinding()]
param()
process
{
try
{
Write-Error 'boo'
}
finally { }
}
}
function bar
{
foo -ErrorAction Ignore
}- Dot-source that script to import the function definitions.
- Call the "bar" function.
Expected result:
Nothing (no output; no error--bar is calling foo with "-ErrorAction Ignore").
Actual result:
I get an error, and it's not even the one written by foo:
Write-Error : The value Ignore is not supported for an ActionPreference variable. The provided value should be used only as a value for a preference
parameter, and has been replaced by the default value. For more information, see the Help topic, "about_Preference_Variables."
At E:\temp\ps_ea_ignore_2.ps1:11 char:13
- Write-Error 'boo'
- ~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [Write-Error], NotSupportedException
- FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.WriteErrorCommand
Dan Thompson:
In addition to being annoying for straight-up calling advanced functions (you can't use "-ErrorAction Ignore" with them), this also hampers meta-programming (you can't do "& $someCmd -ErrorAction Ignore", because you might not know if $someCmd is an advanced function or not).
amervitz, mklement0, alx9r, kborowinski, BTMike and 7 more
Metadata
Metadata
Assignees
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime