Handle nested lists when removing quotes.

* gash/word.scm (remove-quotes): Handle nested lists.
(split-fields) <wedge-apart-quote>: Likewise.
* tests/unit/word.scm: Add test.
This commit is contained in:
Timothy Sample 2019-10-10 13:32:40 -04:00
parent 16ba8ca016
commit 7a0f4fbae2
2 changed files with 10 additions and 2 deletions

View File

@ -112,7 +112,9 @@ in the string @var{ifs}."
vals))
acc)))
(((? string? h) . t)
(loop t (cons `(<sh-quote> ,h) acc))))))
(loop t (cons `(<sh-quote> ,h) acc)))
(((qwords ...) . t)
(loop t (append-reverse (wedge-apart-quote qwords) acc))))))
(define (wedge-apart qword)
(match qword
@ -168,7 +170,9 @@ string, the separator is derived from @var{ifs} using
(let ((sep (argument-separator ifs)))
(loop t (cons (string-join vals sep) acc))))
(((? string? h) . t)
(loop t (cons h acc))))))
(loop t (cons h acc)))
(((qwords ...) . t)
(loop t (cons (remove-quotes qwords ifs) acc))))))
(define (qword->pattern qword ifs)
(let loop ((qword (normalize-word qword)) (acc '()))

View File

@ -77,6 +77,10 @@
'("foo")
(expand-word '("f" ("oo"))))
(test-equal "Handles nested lists for string output"
"foo"
(expand-word '("f" ("oo")) #:output 'string))
;;; Quotes.