Fix reading multi-line quoted here-documents

* geesh/lexer.scm (get-quoted-here-doc): Use the correct line-reading
procedure when looping.
* tests/lexer.scm: Add test.
This commit is contained in:
Timothy Sample 2018-07-17 21:59:09 -04:00
parent 48ee11a6fb
commit 8b945a77a9
2 changed files with 5 additions and 1 deletions

View File

@ -561,7 +561,7 @@ marks the end of the here-document."
(let ((line* (string-trim-right line #\newline)))
(if (string=? line* end)
`(<sh-quote> ,(string-concatenate-reverse acc))
(loop (get-line port) (cons line acc)))))))
(loop (read-line port 'concat) (cons line acc)))))))
(define (get-unquoted-here-doc end port)
"Get an unquoted here-document string from @var{port}, where

View File

@ -299,6 +299,10 @@
'(HERE-DOC (0 . 7) (<sh-quote> "$x\n"))
(get-here-doc* "eof" "$x\neof" #:quoted? #t))
(test-equal "Lexes a multi-line quoted here-document"
'(HERE-DOC (0 . 8) (<sh-quote> "a\nb\n"))
(get-here-doc* "eof" "a\nb\neof" #:quoted? #t))
(test-equal "Lexes a here-document with tab trimming"
'(HERE-DOC (0 . 15) (<sh-quote> "foo\nbar\n"))
(get-here-doc* "eof" "\tfoo\n\tbar\n\teof" #:trim-tabs? #t))