mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Import PSReadLine change to throw when redirected
A similar change was made to the Source Depot fork of PSReadLine, and the behavior is depended on in the ConsoleHost. The host always attempts to load PSReadLine, because a future version of PSReadLine will support redirected input/output, and until then, PSReadLine must throw so that the host correctly falls back to Console.ReadLine().
This commit is contained in:
@@ -258,6 +258,14 @@ namespace Microsoft.PowerShell
|
||||
public static string ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
|
||||
{
|
||||
var console = _singleton._console;
|
||||
|
||||
// If either stdin or stdout is redirected, PSReadline doesn't really work, so throw
|
||||
// and let PowerShell call Console.ReadLine or do whatever else it decides to do.
|
||||
if (Console.IsInputRedirected || Console.IsOutputRedirected)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
#if CORECLR
|
||||
_singleton._prePSReadlineControlCMode = Console.TreatControlCAsInput;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user