test: 04-word-at-word.
This commit is contained in:
parent
39761c0087
commit
d4f58ffa19
1
check.sh
1
check.sh
|
@ -32,6 +32,7 @@ tests='
|
||||||
04-echo-var
|
04-echo-var
|
||||||
04-echo-equal
|
04-echo-equal
|
||||||
04-echo-word-at
|
04-echo-word-at
|
||||||
|
04-echo-word-at-word
|
||||||
|
|
||||||
05-assignment
|
05-assignment
|
||||||
05-assignment-echo
|
05-assignment-echo
|
||||||
|
|
|
@ -80,6 +80,10 @@
|
||||||
(run ast)))
|
(run ast)))
|
||||||
|
|
||||||
(define (command . args)
|
(define (command . args)
|
||||||
|
(define (flatten o)
|
||||||
|
(match o
|
||||||
|
((h t ...) (append (flatten h) (append-map flatten t)))
|
||||||
|
(_ (list o))))
|
||||||
(define (exec command)
|
(define (exec command)
|
||||||
(cond ((procedure? command) command)
|
(cond ((procedure? command) command)
|
||||||
((assoc-ref %functions (car command))
|
((assoc-ref %functions (car command))
|
||||||
|
@ -98,16 +102,15 @@
|
||||||
(else (lambda () #t))))
|
(else (lambda () #t))))
|
||||||
(when (> %debug-level 1)
|
(when (> %debug-level 1)
|
||||||
(format (current-error-port) "command: ~s\n" args))
|
(format (current-error-port) "command: ~s\n" args))
|
||||||
(match args
|
(let ((args (flatten args)))
|
||||||
(((or "." "source") file-name)
|
(match args
|
||||||
(let* ((string (with-input-from-file file-name read-string))
|
(((or "." "source") file-name)
|
||||||
(ast (parse-string string)))
|
(let* ((string (with-input-from-file file-name read-string))
|
||||||
(run ast)
|
(ast (parse-string string)))
|
||||||
0))
|
(run ast)
|
||||||
(((? string?) ..1) (exec (append-map glob args)))
|
0))
|
||||||
(((and (or (? string?)) c) ... ((and (? string?) a) ...))
|
(((? string?) ..1) (exec (append-map glob args)))
|
||||||
(apply command (append c a)))
|
(_ (exec (append-map glob args))))))
|
||||||
(_ (exec (append-map glob args)))))
|
|
||||||
|
|
||||||
(define (glob? pattern)
|
(define (glob? pattern)
|
||||||
(and (string? pattern) (string-match "\\?|\\*" pattern)))
|
(and (string? pattern) (string-match "\\?|\\*" pattern)))
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
echo command $@ plus
|
|
@ -0,0 +1 @@
|
||||||
|
command -s --long file0 file1 plus
|
Loading…
Reference in New Issue