From d1c268cd6a23c963876180f82bfe42c474254836 Mon Sep 17 00:00:00 2001 From: Rutger van Beusekom Date: Mon, 19 Sep 2016 12:37:38 +0200 Subject: [PATCH] fix transform --- sh/anguish.scm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sh/anguish.scm b/sh/anguish.scm index eb0416d..95873f5 100644 --- a/sh/anguish.scm +++ b/sh/anguish.scm @@ -22,7 +22,8 @@ ((compose string-to-ast file-to-string) filename)) (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)) (version (single-char #\v) (value #f)))) (options (getopt-long args option-spec @@ -34,8 +35,8 @@ (run (lambda (ast) (and ast (cond (parse? (let ((ast- (transform ast))) - (display ast) (newline)(newline) - (display ast-) (newline)(newline) + (display "parsed : ") (display ast) (newline)(newline) + (display "prepared: ") (display ast-) (newline)(newline) #t)) (#t (sh-exec ast) @@ -94,14 +95,14 @@ copyleft. #f)) (define (transform ast) - ;(display 'TRANSFORM:) (display ast) (newline) (match ast (('script command 'separator) (transform command)) (('pipeline command) (transform command)) (('pipeline command piped-commands) (cons 'pipeline (cons (transform command) (transform piped-commands)))) - (('simple-command ('word s)) (list s)) - (('simple-command ('word s1) ('word s2)) (list s1 s2)) - (('simple-command ('word s1) (list ('word s2) ...)) (cons s1 s2)) + (('simple-command ('word s)) (list (transform s))) + (('simple-command ('word s1) ('word s2)) (list (transform s1) (transform 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)) ((_ o) (transform o)) @@ -109,6 +110,7 @@ copyleft. (define (sh-exec ast) (let ((cmd (transform ast))) + ;(display "executing: ")(display cmd) (newline) (if (builtin cmd) ((builtin cmd)) (if (and (pair? cmd) (eq? 'pipeline (car cmd)))