Add the 'read' utility

* geesh/built-ins/read.scm: New file.
* Makefile.am: Add it.
* geesh/built-ins.scm (*built-ins*): Define 'read'.
This commit is contained in:
Timothy Sample 2018-10-16 18:15:05 -04:00
parent 2db7833d61
commit 339f59d639
3 changed files with 33 additions and 1 deletions

View File

@ -38,6 +38,7 @@ test-list: ; @echo $(TESTS)
MODULES = \
geesh/built-ins/echo.scm \
geesh/built-ins/read.scm \
geesh/built-ins.scm \
geesh/environment.scm \
geesh/eval.scm \

View File

@ -65,7 +65,7 @@
("kill" . ,undefined)
("newgrp" . ,undefined)
("pwd" . ,undefined)
("read" . ,undefined)
("read" . ,(@@ (geesh built-ins read) main))
("true" . ,undefined)
("umask" . ,undefined)
("unalias" . ,undefined)

31
geesh/built-ins/read.scm Normal file
View File

@ -0,0 +1,31 @@
;;; The Geesh Shell Interpreter
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with Geesh. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins read)
#:use-module (geesh environment)
#:use-module (ice-9 rdelim))
;;; Commentary:
;;;
;;; The 'read' utility.
;;;
;;; Code:
(define (main env . args)
(set-var! env (car args) (read-line (current-input-port)))
0)