Execute profile commands with out-default

So functions called in profile can write to the screen without any
workarounds.
This commit is contained in:
Andrew Schwartzmeyer
2016-01-15 15:39:42 -08:00
parent 62de9f2645
commit 08c7d801f8
+27 -2
View File
@@ -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