From 6660fbbdea9e96b2e4939fb5600e6243eb9924f7 Mon Sep 17 00:00:00 2001 From: Pysis Date: Thu, 18 Apr 2024 20:11:52 -0400 Subject: [PATCH 1/2] Fix crash with stack trace when sending the Ctrl+C control code `ETX` to quit the application. --- LiteDB.Shell/Shell/InputCommand.cs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/LiteDB.Shell/Shell/InputCommand.cs b/LiteDB.Shell/Shell/InputCommand.cs index c68d74846..7e9d41087 100644 --- a/LiteDB.Shell/Shell/InputCommand.cs +++ b/LiteDB.Shell/Shell/InputCommand.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; @@ -24,19 +24,28 @@ public string ReadCommand() Console.ForegroundColor = ConsoleColor.White; Console.Write("> "); - var cmd = this.ReadLine().Trim(); + var cmd = this.ReadLine(); + + if (cmd == null) + { + this.AutoExit = true ; + this.Running = false; + return ""; + } + + cmd = cmd.Trim(); // single line only for shell commands if (ShellProgram.GetCommand(cmd) == null) { while (!cmd.EndsWith(";")) { - Console.ForegroundColor = ConsoleColor.White; - Console.Write("| "); + Console.ForegroundColor = ConsoleColor.White; + Console.Write("| "); - var line = this.ReadLine(); - cmd += Environment.NewLine + line; - } + var line = this.ReadLine(); + cmd += Environment.NewLine + line; + } } cmd = cmd.Trim(); From 4212782b5ea5043b1dbaed813a5f42f90ea81a89 Mon Sep 17 00:00:00 2001 From: Jonas Kamsker <11245306+JKamsker@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:45:55 +0200 Subject: [PATCH 2/2] Fix spacing --- LiteDB.Shell/Shell/InputCommand.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/LiteDB.Shell/Shell/InputCommand.cs b/LiteDB.Shell/Shell/InputCommand.cs index 7e9d41087..3f807bb6e 100644 --- a/LiteDB.Shell/Shell/InputCommand.cs +++ b/LiteDB.Shell/Shell/InputCommand.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; namespace LiteDB.Shell { @@ -28,9 +27,9 @@ public string ReadCommand() if (cmd == null) { - this.AutoExit = true ; - this.Running = false; - return ""; + this.AutoExit = true; + this.Running = false; + return ""; } cmd = cmd.Trim(); @@ -40,12 +39,12 @@ public string ReadCommand() { while (!cmd.EndsWith(";")) { - Console.ForegroundColor = ConsoleColor.White; - Console.Write("| "); + Console.ForegroundColor = ConsoleColor.White; + Console.Write("| "); - var line = this.ReadLine(); - cmd += Environment.NewLine + line; - } + var line = this.ReadLine(); + cmd += Environment.NewLine + line; + } } cmd = cmd.Trim();