Use '$?' as the return value of the REPL

* geesh/repl.scm (run-repl): Return the value of '$?' (converted to a
number).
This commit is contained in:
Timothy Sample 2018-10-16 19:58:15 -04:00
parent fb493cc5f4
commit 801e9c8012
1 changed files with 5 additions and 4 deletions

View File

@ -32,7 +32,8 @@
(define (run-repl)
(let loop ((env (make-environment (environ->alist (environ))))
(exp (read-sh (current-input-port))))
(unless (eof-object? exp)
(eval-sh env exp)
(loop env (read-sh (current-input-port)))))
#t)
(if (eof-object? exp)
(or (and=> (var-ref env "?") string->number) 0)
(begin
(eval-sh env exp)
(loop env (read-sh (current-input-port)))))))