mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Execute profile commands with out-default
So functions called in profile can write to the screen without any workarounds.
This commit is contained in:
@@ -176,8 +176,7 @@ namespace Microsoft.PowerShell.Linux.Host
|
||||
PSCommand[] profileCommands = HostUtilities.GetProfileCommands("PSL");
|
||||
foreach (PSCommand command in profileCommands)
|
||||
{
|
||||
this.currentPowerShell.Commands = command;
|
||||
this.currentPowerShell.Invoke();
|
||||
RunCommand(command);
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -225,6 +224,32 @@ namespace Microsoft.PowerShell.Linux.Host
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs individual commands
|
||||
/// </summary>
|
||||
/// <param name="command">command to run</param>
|
||||
internal void RunCommand(PSCommand command)
|
||||
{
|
||||
if (command == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
command.AddCommand("out-default");
|
||||
command.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
|
||||
|
||||
this.currentPowerShell.Commands = command;
|
||||
|
||||
try
|
||||
{
|
||||
this.currentPowerShell.Invoke();
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
this.ReportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A helper class that builds and executes a pipeline that writes
|
||||
/// to the default output path. Any exceptions that are thrown are
|
||||
|
||||
Reference in New Issue
Block a user