fix 01-script-$@.
This commit is contained in:
parent
1f0a7674d9
commit
73ecccef1e
1
check.sh
1
check.sh
|
@ -85,6 +85,7 @@ tests='
|
|||
30-substitution-assignment
|
||||
30-for-substitution
|
||||
30-substitution-assignment
|
||||
30-substitution-assignment-at
|
||||
30-substitution-redirect
|
||||
|
||||
40-eval
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-26)
|
||||
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (gash io)
|
||||
|
||||
#:export (
|
||||
|
@ -55,12 +56,13 @@
|
|||
(define %functions '())
|
||||
|
||||
(define* (assignment name #:optional value)
|
||||
(if value
|
||||
(set! %global-variables
|
||||
(assoc-set! %global-variables name value))
|
||||
(set! %global-variables
|
||||
(assoc-set! %global-variables name "")))
|
||||
#t)
|
||||
(let ((value (match value
|
||||
((? string?) value)
|
||||
(((? string?) ...) (apply string-append value))
|
||||
(#f ""))))
|
||||
(set! %global-variables
|
||||
(assoc-set! %global-variables name value))
|
||||
#t))
|
||||
|
||||
(define* (variable name #:optional (default ""))
|
||||
(cond ((string->number name)
|
||||
|
@ -69,7 +71,8 @@
|
|||
(if (< n (length (%command-line))) (list-ref (%command-line) n)
|
||||
"")))
|
||||
((equal? name "@")
|
||||
(string-join (cdr (%command-line))))
|
||||
(if (pair? (cdr (%command-line))) (cdr (%command-line))
|
||||
""))
|
||||
((equal? name "#")
|
||||
(number->string (length (cdr (%command-line)))))
|
||||
(else
|
||||
|
|
|
@ -104,6 +104,9 @@
|
|||
(ast (parse-string string)))
|
||||
(run ast)
|
||||
0))
|
||||
(((? string?) ..1) (exec (append-map glob args)))
|
||||
(((and (or (? string?)) c) ((and (? string?) a) ...))
|
||||
(exec (append-map glob (cons c a))))
|
||||
(_ (exec (append-map glob args)))))
|
||||
|
||||
(define (glob? pattern)
|
||||
|
@ -180,6 +183,7 @@
|
|||
(_ (list o))))
|
||||
(match o
|
||||
(((? string?) ...) (string-join (flatten o) ""))
|
||||
((((? string?) ...)) (flatten (car o)))
|
||||
(_ o)))
|
||||
|
||||
(define-syntax-rule (substitution commands)
|
||||
|
@ -417,8 +421,11 @@
|
|||
((h ... t) t)
|
||||
(_ o)))
|
||||
|
||||
(define (delim . o)
|
||||
(string-join o ""))
|
||||
(define (delim o . rest)
|
||||
(match rest
|
||||
(() o)
|
||||
(((? string?) ...) (string-append o (string-join rest "")))
|
||||
((((? string?) ...)) (string-append o (string-join (car rest) "")))))
|
||||
|
||||
(define (name o)
|
||||
o)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
cmdline=$(echo " $@")
|
||||
echo cmdline:$cmdline
|
|
@ -0,0 +1 @@
|
|||
cmdline: -s --long file0 file1
|
Loading…
Reference in New Issue