diff --git a/Makefile.am b/Makefile.am index 1cb5027..7987881 100644 --- a/Makefile.am +++ b/Makefile.am @@ -75,7 +75,8 @@ SOURCES = \ gash/readline.scm \ gash/repl.scm \ gash/shell.scm \ - gash/word.scm + gash/word.scm \ + language/sh/spec.scm bin_SCRIPTS = \ scripts/gash diff --git a/doc/gash.texi b/doc/gash.texi index 3ff62db..eedaa1c 100644 --- a/doc/gash.texi +++ b/doc/gash.texi @@ -247,6 +247,22 @@ Print each command that is executed. @end table +@node Using Gash from the Guile REPL +@section Using Gash from the Guile REPL + +Gash defines a language specification that extends Guile, allowing you +to use shell syntax from the REPL. This is accomplished by using the +@code{language} REPL command: + +@example +scheme@atchar{}(guile-user)> ,language sh +Happy hacking with Guile as Shell! To switch back, type `,L scheme'. +sh@atchar{}(guile-user)> echo "Hello Gash!" +Hello Gash! +$1 = 0 +@end example + + @node Missing features @section Missing features diff --git a/language/sh/spec.scm b/language/sh/spec.scm new file mode 100644 index 0000000..894e368 --- /dev/null +++ b/language/sh/spec.scm @@ -0,0 +1,38 @@ +;;; Gash --- Guile As SHell +;;; Copyright © 2020 Stephen J. Scheck +;;; +;;; 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 . + +(define-module (language sh spec) + #:use-module (gash environment) + #:use-module (gash eval) + #:use-module (gash parser) + #:use-module (system base language) + #:export (sh)) + +;;; Commentary: +;;; +;;; This module contains the language spec definition that extends +;;; Guile allowing use of shell syntax from the REPL by invocation +;;; of the ,language meta-command. +;;; +;;; Code: + +(define-language sh + #:title "Guile as Shell" + #:reader (lambda (port env) (read-sh port)) + #:evaluator (lambda (x module) (eval-sh x) (get-status)) + #:printer write)