Skip to content

Commit 5331396

Browse files
authored
Added enhanced checking of interactive environments (#231)
1 parent 1013696 commit 5331396

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sharprompt/Drivers/DefaultConsoleDriver.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using System.Runtime.InteropServices;
34

45
using Sharprompt.Internal;
@@ -32,7 +33,14 @@ public DefaultConsoleDriver()
3233
{
3334
_previousTreatControlCAsInput = Console.TreatControlCAsInput;
3435

35-
Console.TreatControlCAsInput = true;
36+
try
37+
{
38+
Console.TreatControlCAsInput = true;
39+
}
40+
catch (IOException)
41+
{
42+
throw new InvalidOperationException(Resource.Message_NotSupportedEnvironment);
43+
}
3644
}
3745

3846
private readonly bool _previousTreatControlCAsInput;

0 commit comments

Comments
 (0)