From 339f59d6399eb25ae19362689875bcddb39c40ce Mon Sep 17 00:00:00 2001 From: Timothy Sample Date: Tue, 16 Oct 2018 18:15:05 -0400 Subject: [PATCH] Add the 'read' utility * geesh/built-ins/read.scm: New file. * Makefile.am: Add it. * geesh/built-ins.scm (*built-ins*): Define 'read'. --- Makefile.am | 1 + geesh/built-ins.scm | 2 +- geesh/built-ins/read.scm | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 geesh/built-ins/read.scm diff --git a/Makefile.am b/Makefile.am index c1ada04..3c9d052 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/geesh/built-ins.scm b/geesh/built-ins.scm index a33f951..9f4fce3 100644 --- a/geesh/built-ins.scm +++ b/geesh/built-ins.scm @@ -65,7 +65,7 @@ ("kill" . ,undefined) ("newgrp" . ,undefined) ("pwd" . ,undefined) - ("read" . ,undefined) + ("read" . ,(@@ (geesh built-ins read) main)) ("true" . ,undefined) ("umask" . ,undefined) ("unalias" . ,undefined) diff --git a/geesh/built-ins/read.scm b/geesh/built-ins/read.scm new file mode 100644 index 0000000..65692a3 --- /dev/null +++ b/geesh/built-ins/read.scm @@ -0,0 +1,31 @@ +;;; The Geesh Shell Interpreter +;;; Copyright 2018 Timothy Sample +;;; +;;; 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 . + +(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)