fix builtins
This commit is contained in:
parent
f171f79ec9
commit
9856ad7619
|
@ -68,7 +68,6 @@ the GNU Public License, see COPYING for the copyleft.
|
|||
(define global-variables '())
|
||||
|
||||
(define (main args)
|
||||
(setenv "PATH" "/bin:/usr/bin:/sbin:/usr/sbin:.")
|
||||
(map (lambda (key-value)
|
||||
(let* ((key-value (string-split key-value #\=))
|
||||
(key (car key-value))
|
||||
|
@ -174,15 +173,16 @@ the GNU Public License, see COPYING for the copyleft.
|
|||
(_ ast)))
|
||||
|
||||
(define (builtin ast)
|
||||
;;(stdout "builtin: " ast "\n")
|
||||
(match ast
|
||||
(('append ('glob "cd") arg) `(apply chdir ,arg))
|
||||
(('append ('glob "fg") ('glob arg)) `(fg ,(string->number arg)))
|
||||
(('append ('glob "bg") ('glob arg)) `(bg ,(string->number arg)))
|
||||
(('append ('glob "echo") args ...) `(stdout (string-join ,@args " ")))
|
||||
(('glob "echo") `(stdout))
|
||||
(('glob "fg") `(fg 1))
|
||||
(('glob "bg") `(bg 1))
|
||||
(('glob "jobs") `(jobs))
|
||||
((('append ('glob "cd") arg)) `(apply chdir ,arg))
|
||||
((('append ('glob "fg") ('glob arg))) `(fg ,(string->number arg)))
|
||||
((('append ('glob "bg") ('glob arg))) `(bg ,(string->number arg)))
|
||||
((('append ('glob "echo") args ...)) `(stdout (string-join ,@args " ")))
|
||||
((('glob "echo")) `(stdout))
|
||||
((('glob "fg")) `(fg 1))
|
||||
((('glob "bg")) `(bg 1))
|
||||
((('glob "jobs")) `(jobs))
|
||||
(('for-each rest ...) ast)
|
||||
(('if rest ...) ast)
|
||||
(#t #t)
|
||||
|
@ -238,10 +238,7 @@ the GNU Public License, see COPYING for the copyleft.
|
|||
(define (sh-exec ast)
|
||||
(define (exec cmd)
|
||||
(local-eval cmd (the-environment)))
|
||||
(let* (;;(print (format (current-error-port) "parsed: ~s\n" ast))
|
||||
(ast (transform ast))
|
||||
;;(print (format (current-error-port) "transformed: ~s\n" ast))
|
||||
)
|
||||
(let ((ast (transform ast)))
|
||||
(match ast
|
||||
('script #t) ;; skip
|
||||
(_ (begin (map exec ast) #t)))))
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
(string-join (map (compose string-join process-command) (reverse (job-processes job))) " | "))
|
||||
|
||||
(define (display-job job)
|
||||
(stdout "[" (job-id job) "] " (status->state (job-status job)) "\t\t"
|
||||
(stdout "[" (job-id job) "] " (map status->state (job-status job)) "\t\t"
|
||||
(job-command job)))
|
||||
|
||||
(define (jobs)
|
||||
|
@ -55,7 +55,7 @@
|
|||
(reverse job-table)))
|
||||
|
||||
(define (job-status job)
|
||||
(process-status (last (job-processes job))))
|
||||
(map process-status (job-processes job)))
|
||||
|
||||
(define (job-update job pid status)
|
||||
(unless (= 0 pid)
|
||||
|
@ -122,7 +122,7 @@
|
|||
(unless (job-completed? job)
|
||||
(newline) (display-job job))
|
||||
(reap-jobs)
|
||||
(job-status job))
|
||||
(last (job-status job)))
|
||||
|
||||
(define (fg index)
|
||||
(let ((job (job-index index)))
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
(define (exec* command) ;; list of strings
|
||||
(catch #t (lambda () (apply execlp (cons (car command) command)))
|
||||
(lambda (key . args) (display (string-append (caaddr args) "\n"))
|
||||
(lambda (key . args) (format (current-error-port) "~a\n" (caaddr args))
|
||||
(exit #f))))
|
||||
|
||||
(define (setup-process fg? job)
|
||||
|
|
Loading…
Reference in New Issue