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:
parent
16ba8ca016
commit
7a0f4fbae2
|
@ -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 '()))
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue