From 9415c5193e350812523160b2708bd0c78315af2c Mon Sep 17 00:00:00 2001 From: sammyette <38820196+TorchedSammy@users.noreply.github.com> Date: Sun, 16 May 2021 15:50:49 -0400 Subject: [PATCH] feat(wip): check if lua input is incomplete --- shell.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shell.go b/shell.go index a88a455..fed3e25 100644 --- a/shell.go +++ b/shell.go @@ -8,6 +8,7 @@ import ( "github.com/bobappleyard/readline" "github.com/yuin/gopher-lua" + "github.com/yuin/gopher-lua/parse" "layeh.com/gopher-luar" "mvdan.cc/sh/v3/interp" "mvdan.cc/sh/v3/syntax" @@ -31,6 +32,11 @@ func RunInput(input string) { fn, err := l.LoadString(cmdString) if err != nil && noexecute { fmt.Println(err) + if lerr, ok := err.(*lua.ApiError); ok { + if perr, ok := lerr.Cause.(*parse.Error); ok { + print(perr.Pos.Line == parse.EOF) + } + } return } // And if there's no syntax errors and -n isnt provided, run