implement shift.
This commit is contained in:
parent
2f5de56cfd
commit
7f6b88c43b
1
check.sh
1
check.sh
|
@ -17,6 +17,7 @@ tests='
|
|||
01-script-backslash-twice
|
||||
01-script-$0
|
||||
01-script-$@
|
||||
01-script-shift
|
||||
|
||||
03-echo
|
||||
03-echo-doublequotes
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
jobs-command
|
||||
pwd-command
|
||||
set-command
|
||||
shift-command
|
||||
))
|
||||
|
||||
(define (PATH-search-path program)
|
||||
|
@ -118,6 +119,12 @@
|
|||
(apply set-command (map (cut string-append set <>) (cdr lst)))))
|
||||
((h ...) (last (map set-command args)))))
|
||||
|
||||
(define (shift-command . args)
|
||||
(lambda _
|
||||
(match args
|
||||
(() (when (pair? (cdr (%command-line)))
|
||||
(%command-line (cons (car (%command-line)) (cddr (%command-line)))))))))
|
||||
|
||||
(define (eval-command . args)
|
||||
(lambda _
|
||||
(match args
|
||||
|
@ -379,6 +386,7 @@ Options:
|
|||
("jobs" . ,jobs-command)
|
||||
("pwd" . ,pwd-command)
|
||||
("set" . ,set-command)
|
||||
("shift" . ,shift-command)
|
||||
("test" . ,test-command)
|
||||
("type" . ,type-command)
|
||||
("[" . ,bracket-command)
|
||||
|
|
|
@ -283,5 +283,7 @@
|
|||
|
||||
(('word 'delim) '(word ""))
|
||||
|
||||
(('pipeline ('command ('word "shift"))) '(shift))
|
||||
|
||||
((h t ...) (map transform o))
|
||||
(_ o)))
|
||||
|
|
|
@ -426,3 +426,6 @@
|
|||
|
||||
(define (test . o) ;; TODO replace with implementation in scheme
|
||||
(command (cons "test" o)))
|
||||
|
||||
(define (shift . o)
|
||||
(apply (shift-command) o))
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
echo $@
|
||||
shift
|
||||
echo $@
|
||||
shift
|
||||
echo $@
|
||||
shift
|
||||
echo $@
|
||||
shift
|
||||
echo $@
|
|
@ -0,0 +1,5 @@
|
|||
-s --long file0 file1
|
||||
--long file0 file1
|
||||
file0 file1
|
||||
file1
|
||||
|
Loading…
Reference in New Issue