From 94642d4cc219397729f9468793f5981795e152a8 Mon Sep 17 00:00:00 2001 From: doggeddog Date: Thu, 31 Oct 2019 22:31:46 +0800 Subject: [PATCH 1/2] support multiline while quote is unclosed --- ishell.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ishell.go b/ishell.go index f440095..129cbbd 100644 --- a/ishell.go +++ b/ishell.go @@ -344,7 +344,7 @@ func (s *Shell) readMultiLinesFunc(f func(string) bool) (string, error) { var line string line, err = s.readLine() fmt.Fprint(&lines, line) - if !f(line) || err != nil { + if (!f(line) || err != nil) && isQuoteClosed(lines.String()) { break } fmt.Fprintln(&lines) @@ -718,3 +718,11 @@ func getPosition() (int, int, error) { return col, row, nil } + +func isQuoteClosed(lines string) bool { + _, err := shlex.Split(lines) + if err != nil && err.Error() == "EOF found when expecting closing quote." { + return false + } + return true +} \ No newline at end of file From 7b120bd946fa6bb97a806130f020172f1b4e0139 Mon Sep 17 00:00:00 2001 From: doggeddog Date: Thu, 31 Oct 2019 22:44:53 +0800 Subject: [PATCH 2/2] support multiline while quote is unclosed --- ishell.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ishell.go b/ishell.go index 129cbbd..d8f3524 100644 --- a/ishell.go +++ b/ishell.go @@ -725,4 +725,4 @@ func isQuoteClosed(lines string) bool { return false } return true -} \ No newline at end of file +}