parse [ .. ] into plain command. fixes 10-if-bracket-false, 100-bracket-file.

This commit is contained in:
Jan Nieuwenhuizen 2018-12-01 10:15:33 +01:00
parent 6cf9cf7d0f
commit d5c94e75dd
2 changed files with 7 additions and 6 deletions

View File

@ -115,9 +115,8 @@
until-clause <-- until-keyword compound do-group
test <-- ltest sp+ (word sp+)+ rtest#
ltest < '['
rtest < ']'
test <- '[' sp+ test-args sp+ ']'#
test-args <-- (sp* word)+
literal <- !reserved (escaped / !allowed .)+
escaped <- escape [ \"$]
@ -285,5 +284,8 @@
(('pipeline ('command ('word "shift"))) '(shift))
(('command ('word "[" ('test-args test-args ...) "]"))
`(command (word "[") ,@(map transform test-args) (word "]")))
((h t ...) (map transform o))
(_ o)))

View File

@ -96,6 +96,8 @@
escape-builtin?))
(lambda _ (status:exit-val (apply system* command))))))
(else (lambda () #t))))
(when (> %debug-level 1)
(format (current-error-port) "command: ~s\n" args))
(match args
(((or "." "source") file-name)
(let* ((string (with-input-from-file file-name read-string))
@ -424,8 +426,5 @@
(define (regex-sep o)
o)
(define (test . o) ;; TODO replace with implementation in scheme
(command (cons "test" o)))
(define (shift . o)
(apply (shift-command) o))