transform: handle ./source.

This commit is contained in:
Jan Nieuwenhuizen 2018-11-17 19:23:51 +01:00
parent 9d1ed9ef57
commit 74454c2156
2 changed files with 8 additions and 0 deletions

View File

@ -245,6 +245,8 @@
(('compound compound) (transform compound))
(('compound compound ...) `(begin ,@(map transform compound)))
(('command (word (or "." "source")) file-name)
`(source ,(transform file-name)))
(('command word ... ('io-redirect ('io-here "<<" ('io-here-document string))))
`(pipeline (cut display ,string) (command ,@word)))
(('command word ... ('io-redirect filedes ... ('io-file ">" file-name)))

View File

@ -59,6 +59,7 @@
script-status
sequence
singlequotes
source
splice
split
substitution
@ -72,6 +73,11 @@
(('pipeline command) (pke 'background: `(pipeline+ #f ,command)))
(_ term)))
(define (source file-name)
(let* ((string (with-input-from-file file-name read-string))
(ast (parse-string string)))
(run ast)))
(define (command . args)
(define (exec command)
(cond ((procedure? command) command)