Browse Source

Fixes #1815. Now returns false if WSL clipboard isn't supported.

BDisp 3 years ago
parent
commit
9b4400400f

+ 7 - 3
Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

@@ -821,7 +821,7 @@ namespace Terminal.Gui {
 
 
 				window = Curses.initscr ();
 				window = Curses.initscr ();
 			} catch (Exception e) {
 			} catch (Exception e) {
-				Console.WriteLine ("Curses failed to initialize, the exception is: " + e);
+				throw new Exception ($"Curses failed to initialize, the exception is: {e.Message}");
 			}
 			}
 
 
 			// Ensures that all procedures are performed at some previous closing.
 			// Ensures that all procedures are performed at some previous closing.
@@ -986,6 +986,9 @@ namespace Terminal.Gui {
 
 
 		public static bool Is_WSL_Platform ()
 		public static bool Is_WSL_Platform ()
 		{
 		{
+			if (new CursesClipboard ().IsSupported) {
+				return false;
+			}
 			var result = BashRunner.Run ("uname -a", runCurses: false);
 			var result = BashRunner.Run ("uname -a", runCurses: false);
 			if (result.Contains ("microsoft") && result.Contains ("WSL")) {
 			if (result.Contains ("microsoft") && result.Contains ("WSL")) {
 				return true;
 				return true;
@@ -1361,11 +1364,14 @@ namespace Terminal.Gui {
 						FileName = "bash",
 						FileName = "bash",
 						Arguments = arguments,
 						Arguments = arguments,
 						RedirectStandardInput = true,
 						RedirectStandardInput = true,
+						RedirectStandardError = true,
 						UseShellExecute = false,
 						UseShellExecute = false,
 						CreateNoWindow = false
 						CreateNoWindow = false
 					}
 					}
 				}) {
 				}) {
 					process.Start ();
 					process.Start ();
+					process.ErrorDataReceived += (sender, args) => { };
+					process.BeginErrorReadLine ();
 					process.StandardInput.Write (inputText);
 					process.StandardInput.Write (inputText);
 					process.StandardInput.Close ();
 					process.StandardInput.Close ();
 					process.WaitForExit ();
 					process.WaitForExit ();
@@ -1506,7 +1512,6 @@ namespace Terminal.Gui {
 				powershell.Start ();
 				powershell.Start ();
 				var result = powershell.StandardOutput.ReadToEnd ();
 				var result = powershell.StandardOutput.ReadToEnd ();
 				powershell.StandardOutput.Close ();
 				powershell.StandardOutput.Close ();
-				powershell.WaitForExit ();
 				if (!powershell.DoubleWaitForExit ()) {
 				if (!powershell.DoubleWaitForExit ()) {
 					var timeoutError = $@"Process timed out. Command line: bash {powershell.StartInfo.Arguments}.
 					var timeoutError = $@"Process timed out. Command line: bash {powershell.StartInfo.Arguments}.
 							Output: {powershell.StandardOutput.ReadToEnd ()}
 							Output: {powershell.StandardOutput.ReadToEnd ()}
@@ -1533,7 +1538,6 @@ namespace Terminal.Gui {
 				}
 				}
 			}) {
 			}) {
 				powershell.Start ();
 				powershell.Start ();
-				powershell.WaitForExit ();
 				if (!powershell.DoubleWaitForExit ()) {
 				if (!powershell.DoubleWaitForExit ()) {
 					var timeoutError = $@"Process timed out. Command line: bash {powershell.StartInfo.Arguments}.
 					var timeoutError = $@"Process timed out. Command line: bash {powershell.StartInfo.Arguments}.
 							Output: {powershell.StandardOutput.ReadToEnd ()}
 							Output: {powershell.StandardOutput.ReadToEnd ()}

+ 1 - 1
Terminal.Gui/ConsoleDrivers/CursesDriver/UnmanagedLibrary.cs

@@ -117,7 +117,7 @@ namespace Unix.Terminal {
 			}
 			}
 
 
 			if (this.handle == IntPtr.Zero) {
 			if (this.handle == IntPtr.Zero) {
-				throw new IOException (string.Format ("Error loading native library \"{0}\"", this.libraryPath));
+				throw new IOException ($"Error loading native library \"{string.Join (", ", libraryPathAlternatives)}\"");
 			}
 			}
 		}
 		}