diff src/main/kotlin/name/blackcap/passman/Main.kt @ 23:af86b8e0b88c

Clean up exit output.
author David Barts <n5jrn@me.com>
date Tue, 02 Jul 2024 18:18:29 -0700
parents 07406c4af4a5
children 2188b2f13326
line wrap: on
line diff
--- a/src/main/kotlin/name/blackcap/passman/Main.kt	Tue Jul 02 17:34:52 2024 -0700
+++ b/src/main/kotlin/name/blackcap/passman/Main.kt	Tue Jul 02 18:18:29 2024 -0700
@@ -49,7 +49,11 @@
     val QUIT = setOf<String>("exit", "quit")
     var lastStatus = 0
     while (true) {
-        val rawLine = System.console()?.readLine("passman> ") ?: break
+        val rawLine = System.console()?.readLine("passman> ")
+        if (rawLine == null) {
+            println()  // ensure shell prompt comes out on a line of its own
+            break
+        }
         val s = Shplitter()
         s.feed(rawLine)
         if (!s.complete) {
@@ -82,7 +86,6 @@
             lastStatus = 1
         }
     }
-    println()  // ensure shell prompt comes out on a line of its own
     exitProcess(lastStatus)
 }