Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/System.Management.Automation/engine/CommandProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,9 @@ private void Init(IScriptCommandInfo scriptCommandInfo)
InitCommon();

// If the script has been dotted, throw an error if it's from a different language mode.
if (!this.UseLocalScope)
// Unless it was a script loaded through -File, in which case the danger of dotting other
// language modes (getting internal functions in the user's state) isn't a danger.
if (!this.UseLocalScope && !scriptCmdlet.ShouldRethrowExitException)
{
ValidateCompatibleLanguageMode(scriptCommandInfo.ScriptBlock, _context, Command.MyInvocation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,8 @@ internal sealed class PSScriptCmdlet : PSCmdlet, IDynamicParameters, IDisposable
private bool _exitWasCalled;
private bool _anyClauseExecuted;

internal bool ShouldRethrowExitException => _rethrowExitException;

public PSScriptCmdlet(ScriptBlock scriptBlock, bool useNewScope, bool fromScriptFile, ExecutionContext context)
{
_scriptBlock = scriptBlock;
Expand Down
Loading