about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-10-18 12:55:47 +0200
committerbptato <nincsnevem662@gmail.com>2023-10-18 12:55:47 +0200
commit1b15372501435f006be218105726a0c49dd23771 (patch)
treeb89d2b2a58a87725fa42f69c2dd2f9d4111b8833
parent305906b7439fa71b73a0330026057e21042288d6 (diff)
downloadchawan-1b15372501435f006be218105726a0c49dd23771.tar.gz
Fix crash on `cha -'
-rw-r--r--src/main.nim8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main.nim b/src/main.nim
index ef2ffb08..86066c28 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -130,12 +130,14 @@ while i < params.len:
   const NeedsNextParam = {'T', 'I', 'O', 'c', 'o', 'r'}
 
   if param[0] == '-':
-    if param[1] != '-':
-      # If param.len is 0, we just interpret param as a single dash `-',
-      # which is ignored.
+    if param.len == 1:
+      # If param == "-", i.e. it is a single dash, then ignore it.
       # (Some programs use single-dash to read from stdin, but we do that
       # automatically when stdin is not a tty. So ignoring it entirely
       # is probably for the best.)
+      inc i
+      continue
+    if param[1] != '-':
       for j in 1 ..< param.len:
         if j != param.high and param[j] in NeedsNextParam:
           # expecting next parameter, but not the last char...