From f7c1dd6e725e8b4d7efff37826c93a78f5494acd Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 29 Oct 2018 21:13:41 +0100 Subject: [PATCH] Make readline optional. * gash/readline.scm: New file. * build-aux/build-guile.sh: Compile it. * gash/gash.scm: Use it as fallback. --- build-aux/build-guile.sh | 1 + gash/gash.scm | 6 +++++- gash/readline.scm | 41 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 gash/readline.scm diff --git a/build-aux/build-guile.sh b/build-aux/build-guile.sh index b11e9f6..e3b6327 100755 --- a/build-aux/build-guile.sh +++ b/build-aux/build-guile.sh @@ -53,6 +53,7 @@ gash/job.scm gash/lzw.scm gash/peg.scm gash/pipe.scm +gash/readline.scm gash/script.scm gash/ustar.scm gash/util.scm diff --git a/gash/gash.scm b/gash/gash.scm index 346e3ac..eea1972 100644 --- a/gash/gash.scm +++ b/gash/gash.scm @@ -9,7 +9,6 @@ #:use-module (ice-9 local-eval) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) - #:use-module (ice-9 readline) #:use-module (ice-9 pretty-print) #:use-module (ice-9 receive) #:use-module (ice-9 regex) @@ -30,6 +29,11 @@ parse parse-string)) +(catch #t + (lambda _ (use-modules (ice-9 readline))) + (lambda (key . args) + (use-modules (gash readline)))) + (define %debug-level 0) ; 1 informational, 2 verbose, 3 peg tracing (define %prefer-builtins? #f) ; use builtin, even if COMMAND is available in PATH? (define %geesh-parser? #f) ; use Geesh parser [EXPERIMENTAL] diff --git a/gash/readline.scm b/gash/readline.scm new file mode 100644 index 0000000..3b4d960 --- /dev/null +++ b/gash/readline.scm @@ -0,0 +1,41 @@ +;;; Gash -- Guile As SHell +;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen +;;; +;;; This file is part of Gash. +;;; +;;; Gash 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. +;;; +;;; Gash 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 Gash. If not, see . + +;;; Commentary: + +;;; This is a fallback module for the bootstrap guile where (ice-9 +;;; readline) is not available. + +;;; Code: + +(define-module (gash readline) + #:use-module (ice-9 rdelim) + #:export (add-history + clear-history + read-history + readline + with-readline-completion-function + write-history)) + +(define (add-history x) #t) +(define (clear-history) #t) +(define (read-history x) #t) +(define (readline prompt) (display prompt) (read-line)) +(define (with-readline-completion-function completion thunk) (thunk)) +(define (write-history x) #t) +