From 9cdfa9cd293105ad41345d5dd2af71e7dd10d656 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Mon, 12 Apr 2021 04:00:03 +0700 Subject: all: check and return an error if start index is out of range --- script.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'script.go') diff --git a/script.go b/script.go index 10c09a9..df669bd 100644 --- a/script.go +++ b/script.go @@ -68,6 +68,8 @@ func parseScript(env *environment, content []byte) (s *script, err error) { } stmts := bytes.Split(buf.Bytes(), []byte{'\n'}) + // Add empty line at the beginning to make the start index start from + // 1, not 0. stmts = append([][]byte{{}}, stmts...) s = &script{ -- cgit v1.3-5-g45d5