eval and execute: Automatically skips over empty commands (those that parse command interprets as empty lists)

This commit is contained in:
Sekulum Forka 2021-05-12 22:19:26 +02:00
parent 69a96bda1b
commit fb7b46fca6
1 changed files with 4 additions and 0 deletions

View File

@ -248,6 +248,8 @@ proc execute(cmd: string): int =
let strm=cmd.newStringStream
while not strm.atEnd:
let parsed = strm.readCommand.parseCommand
if parsed == @[]:
continue
let progname = parsed[0]
let args = parsed[1..parsed.high]
if progname in builtins:
@ -264,6 +266,8 @@ proc eval(cmd: string): string =
let strm=cmd.newStringStream
while not strm.atEnd():
let parsed = strm.readCommand.parseCommand
if parsed == @[]:
continue
let progname=parsed[0]
let args = parsed[1..parsed.high]
if progname in builtins: