-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-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
This came up when experimenting with @lzybkr's workaround for #7530. In short, I'm using the ScriptBlock (not just its string representation) from one runspace in another so that file position information is correctly reported when an error is encountered.
Steps to reproduce
$scriptblock = {
"a in dot-invoked scriptblock: $a"
}
$powershell = [powershell]::Create().
AddScript({
"a in outer scriptblock: $a"
. $args[0]
}).
AddArgument($scriptblock)
$initialSessionState = [initialsessionstate]::CreateDefault()
$initialSessionState.Variables.Add(
[System.Management.Automation.Runspaces.SessionStateVariableEntry]::new(
'a',
1,
''
)
)
$runspace = [runspacefactory]::CreateRunspace($initialSessionState)
$runspace.Open()
$powershell.Runspace = $runspace
$powershell.Invoke()Expected behavior
a in outer scriptblock: 1
a in dot-invoked scriptblock: 1
Actual behavior
a in outer scriptblock: 1
a in dot-invoked scriptblock:
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.4
PSEdition Core
GitCommitId 6.1.0-preview.4
OS Microsoft Windows 6.3.9600
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Metadata
Metadata
Assignees
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-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