mirror of
https://github.com/status-im/nim-confutils.git
synced 2025-03-02 12:50:31 +00:00
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:
parent
7f17285d4e
commit
d0d6fb45b2
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user