-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Resolution-By DesignThe reported behavior is by design.The reported behavior is by design.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
It can be useful to run functions (vs. scripts) in the current scope. @Jaykul's Get-ParameterValues is an example
At the moment, it appears that a dot sourced function does not actually run in the current scope. Apologies if I'm using the wrong phrasing, the example should clarify things:
Steps to reproduce
function Test-MyInvocationParam {
[cmdletbinding()]
param($Invocation = $MyInvocation)
$Invocation
}
function Test-Bug {
[cmdletbinding()]
param($a=1)
. Test-MyInvocationParam
}
(Test-Bug).MyCommand.NameExpected behavior
Test-Bug
Actual behavior
Test-MyInvocationParam
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.7
OS Darwin 16.7.0 Darwin Kernel Version 16.7.0: Th...
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Metadata
Metadata
Assignees
Labels
Resolution-By DesignThe reported behavior is by design.The reported behavior is by design.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime