ifthen WIP
This commit is contained in:
parent
c201b080d0
commit
a5c35947a9
2
anguish
2
anguish
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/guile-2.2 \
|
||||
-e main -s
|
||||
--debug -e main -s
|
||||
!#
|
||||
;; workaround:
|
||||
;; -e (@ (sh anguish) main) -s
|
||||
|
|
|
@ -97,6 +97,9 @@ copyleft.
|
|||
(define (transform ast)
|
||||
(match ast
|
||||
(('script command 'separator) (transform command))
|
||||
(('if-clause "if" (expression "then" consequent "fi")) `(if ,(transform expression) ,(transform consequent)))
|
||||
(('if-clause "if" expression "then" consequent "else" alternative "fi") `(if ,(transform expression) ,(transform consequent) ,(transform alternative)))
|
||||
(('compound-list command ('separator 'break)) (transform command))
|
||||
(('pipeline command) (transform command))
|
||||
(('pipeline command piped-commands) (cons 'pipeline (cons (transform command) (transform piped-commands))))
|
||||
(('simple-command ('word s)) (list (transform s)))
|
||||
|
@ -121,7 +124,9 @@ copyleft.
|
|||
((builtin cmd))
|
||||
(if (and (pair? cmd) (eq? 'pipeline (car cmd)))
|
||||
(sh:pipeline (cdr cmd))
|
||||
(apply system* cmd)))))
|
||||
(if (eq? 'if (car cmd))
|
||||
(pretty-print cmd)
|
||||
(apply system* cmd))))))
|
||||
|
||||
(define (prompt)
|
||||
(let* ((esc (string #\033))
|
||||
|
|
|
@ -1 +1 @@
|
|||
if ls * | grep foo; then echo ok; fi
|
||||
if test -e TODO; then echo exists; fi
|
||||
|
|
Loading…
Reference in New Issue