fix transform
This commit is contained in:
parent
fcfabb096d
commit
d1c268cd6a
|
@ -22,7 +22,8 @@
|
||||||
((compose string-to-ast file-to-string) filename))
|
((compose string-to-ast file-to-string) filename))
|
||||||
|
|
||||||
(define (main args)
|
(define (main args)
|
||||||
(let* ((option-spec '((help (single-char #\h) (value #f))
|
(let* ((option-spec '((debug (single-char #\d) (value #f))
|
||||||
|
(help (single-char #\h) (value #f))
|
||||||
(parse (single-char #\p) (value #f))
|
(parse (single-char #\p) (value #f))
|
||||||
(version (single-char #\v) (value #f))))
|
(version (single-char #\v) (value #f))))
|
||||||
(options (getopt-long args option-spec
|
(options (getopt-long args option-spec
|
||||||
|
@ -34,8 +35,8 @@
|
||||||
(run (lambda (ast) (and ast
|
(run (lambda (ast) (and ast
|
||||||
(cond (parse?
|
(cond (parse?
|
||||||
(let ((ast- (transform ast)))
|
(let ((ast- (transform ast)))
|
||||||
(display ast) (newline)(newline)
|
(display "parsed : ") (display ast) (newline)(newline)
|
||||||
(display ast-) (newline)(newline)
|
(display "prepared: ") (display ast-) (newline)(newline)
|
||||||
#t))
|
#t))
|
||||||
(#t
|
(#t
|
||||||
(sh-exec ast)
|
(sh-exec ast)
|
||||||
|
@ -94,14 +95,14 @@ copyleft.
|
||||||
#f))
|
#f))
|
||||||
|
|
||||||
(define (transform ast)
|
(define (transform ast)
|
||||||
;(display 'TRANSFORM:) (display ast) (newline)
|
|
||||||
(match ast
|
(match ast
|
||||||
(('script command 'separator) (transform command))
|
(('script command 'separator) (transform command))
|
||||||
(('pipeline command) (transform command))
|
(('pipeline command) (transform command))
|
||||||
(('pipeline command piped-commands) (cons 'pipeline (cons (transform command) (transform piped-commands))))
|
(('pipeline command piped-commands) (cons 'pipeline (cons (transform command) (transform piped-commands))))
|
||||||
(('simple-command ('word s)) (list s))
|
(('simple-command ('word s)) (list (transform s)))
|
||||||
(('simple-command ('word s1) ('word s2)) (list s1 s2))
|
(('simple-command ('word s1) ('word s2)) (list (transform s1) (transform s2)))
|
||||||
(('simple-command ('word s1) (list ('word s2) ...)) (cons s1 s2))
|
(('simple-command ('word s1) (('word s2) ...)) (cons (transform s1) (map transform s2)))
|
||||||
|
(('literal s) s)
|
||||||
((('pipe _) command ...) (map transform command))
|
((('pipe _) command ...) (map transform command))
|
||||||
(((('pipe _) command) ...) (map transform command))
|
(((('pipe _) command) ...) (map transform command))
|
||||||
((_ o) (transform o))
|
((_ o) (transform o))
|
||||||
|
@ -109,6 +110,7 @@ copyleft.
|
||||||
|
|
||||||
(define (sh-exec ast)
|
(define (sh-exec ast)
|
||||||
(let ((cmd (transform ast)))
|
(let ((cmd (transform ast)))
|
||||||
|
;(display "executing: ")(display cmd) (newline)
|
||||||
(if (builtin cmd)
|
(if (builtin cmd)
|
||||||
((builtin cmd))
|
((builtin cmd))
|
||||||
(if (and (pair? cmd) (eq? 'pipeline (car cmd)))
|
(if (and (pair? cmd) (eq? 'pipeline (car cmd)))
|
||||||
|
|
Loading…
Reference in New Issue