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))
|
vals))
|
||||||
acc)))
|
acc)))
|
||||||
(((? string? h) . t)
|
(((? 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)
|
(define (wedge-apart qword)
|
||||||
(match qword
|
(match qword
|
||||||
|
@ -168,7 +170,9 @@ string, the separator is derived from @var{ifs} using
|
||||||
(let ((sep (argument-separator ifs)))
|
(let ((sep (argument-separator ifs)))
|
||||||
(loop t (cons (string-join vals sep) acc))))
|
(loop t (cons (string-join vals sep) acc))))
|
||||||
(((? string? h) . t)
|
(((? 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)
|
(define (qword->pattern qword ifs)
|
||||||
(let loop ((qword (normalize-word qword)) (acc '()))
|
(let loop ((qword (normalize-word qword)) (acc '()))
|
||||||
|
|
|
@ -77,6 +77,10 @@
|
||||||
'("foo")
|
'("foo")
|
||||||
(expand-word '("f" ("oo"))))
|
(expand-word '("f" ("oo"))))
|
||||||
|
|
||||||
|
(test-equal "Handles nested lists for string output"
|
||||||
|
"foo"
|
||||||
|
(expand-word '("f" ("oo")) #:output 'string))
|
||||||
|
|
||||||
|
|
||||||
;;; Quotes.
|
;;; Quotes.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue