catch exceptions in splitCompletionLine (#77)

We currently return `@[]` in `splitCompletionLine` when there is
unexpected or unsupported input via environment variables, but let
exceptions during parsing propagate to the caller. Catching those
exceptions allows the caller to use same behaviour regardless of
the nature of unexpected input (either through env, or parsing).
Currently, callers don't seem to be aware of the exceptions, so
going with the behaviour used for environment errors of returning `@[]`.
This commit is contained in:
Etan Kissling 2023-06-13 10:36:33 +02:00 committed by GitHub
parent 7f17285d4e
commit d0d6fb45b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,12 +133,15 @@ proc splitCompletionLine*(): seq[string] =
# Split the resulting string
var l: ShellLexer
l.open(strm)
while true:
let token = l.getTok()
if token.isNone():
break
result.add(token.get())
try:
l.open(strm)
while true:
let token = l.getTok()
if token.isNone():
break
result.add(token.get())
except IOError, OSError:
return @[]
proc shellQuote*(word: string): string =
if len(word) == 0: