Remove (almost) all references to Geesh.

gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.

Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
This commit is contained in:
Timothy Sample 2019-02-14 19:55:07 -05:00
parent f387269c0b
commit 1bd92e2893
53 changed files with 728 additions and 906 deletions

View File

@ -15,9 +15,3 @@ or
bash -e test/42-sh-export.sh
./pre-inst-env gash -e test/42-sh-export.sh
To use Geesh, assuming you have built it in ../geesh, do something like
GUILE_LOAD_PATH=../geesh:$GUILE_LOAD_PATH
GUILE_LOAD_COMPILED_PATH=../geesh:$GUILE_LOAD_COMPILED_PATH
./pre-inst-env gash --geesh -dd -p -c 'cat < README > bla'

View File

@ -10,7 +10,6 @@ Building and Installing Gash
guix environment -l guix.scm
*** Other GNU/Linux
- [[https://gitlab.com/samplet/geesh][geesh]], 0.1-rc is known to work.
- GNU Guile, version 2.2.3 or is known to work.
- GNU make, version 4.2 known to work.
- SH, /bin/sh, GNU Bash 4.3 is known to work.

View File

@ -53,14 +53,43 @@ dist-hook:
echo $(VERSION) > $(distdir)/.tarball-version
MODULES = \
gash/built-ins/break.scm \
gash/built-ins/cd.scm \
gash/built-ins/colon.scm \
gash/built-ins/command.scm \
gash/built-ins/continue.scm \
gash/built-ins/dot.scm \
gash/built-ins/echo.scm \
gash/built-ins/eval.scm \
gash/built-ins/exec.scm \
gash/built-ins/exit.scm \
gash/built-ins/export.scm \
gash/built-ins/false.scm \
gash/built-ins/pwd.scm \
gash/built-ins/read.scm \
gash/built-ins/readonly.scm \
gash/built-ins/return.scm \
gash/built-ins/set.scm \
gash/built-ins/shift.scm \
gash/built-ins/trap.scm \
gash/built-ins/true.scm \
gash/built-ins/type.scm \
gash/built-ins/umask.scm \
gash/built-ins/unset.scm \
gash/built-ins/utils.scm \
gash/built-ins.scm \
gash/builtins.scm \
gash/config.scm \
gash/environment.scm \
gash/eval.scm \
gash/gash.scm \
gash/geesh.scm \
gash/grammar.scm \
gash/io.scm \
gash/job.scm \
gash/lexer.scm \
gash/parser.scm \
gash/pattern.scm \
gash/peg.scm \
gash/peg/cache.scm \
gash/peg/codegen.scm \
@ -69,42 +98,12 @@ MODULES = \
gash/peg/using-parsers.scm \
gash/pipe.scm \
gash/readline.scm \
gash/repl.scm \
gash/script.scm \
gash/shell-utils.scm \
gash/shell.scm \
gash/util.scm \
geesh/built-ins/break.scm \
geesh/built-ins/cd.scm \
geesh/built-ins/colon.scm \
geesh/built-ins/command.scm \
geesh/built-ins/continue.scm \
geesh/built-ins/dot.scm \
geesh/built-ins/echo.scm \
geesh/built-ins/eval.scm \
geesh/built-ins/exec.scm \
geesh/built-ins/exit.scm \
geesh/built-ins/export.scm \
geesh/built-ins/false.scm \
geesh/built-ins/pwd.scm \
geesh/built-ins/read.scm \
geesh/built-ins/readonly.scm \
geesh/built-ins/return.scm \
geesh/built-ins/set.scm \
geesh/built-ins/shift.scm \
geesh/built-ins/trap.scm \
geesh/built-ins/true.scm \
geesh/built-ins/type.scm \
geesh/built-ins/umask.scm \
geesh/built-ins/unset.scm \
geesh/built-ins/utils.scm \
geesh/built-ins.scm \
geesh/environment.scm \
geesh/eval.scm \
geesh/lexer.scm \
geesh/parser.scm \
geesh/pattern.scm \
geesh/repl.scm \
geesh/shell.scm \
geesh/word.scm
gash/word.scm
bin_SCRIPTS = \
scripts/gash

View File

@ -1,6 +1,6 @@
AC_INIT([Geesh],
AC_INIT([Gash],
m4_esyscmd([build-aux/git-version-gen .tarball-version]))
AC_CONFIG_SRCDIR([geesh])
AC_CONFIG_SRCDIR([gash])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([color-tests silent-rules -Wall -Werror foreign])
AM_SILENT_RULES([yes])

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins)
#:use-module (geesh built-ins echo)
(define-module (gash built-ins)
#:use-module (gash built-ins echo)
#:export (search-built-ins
search-special-built-ins))
@ -32,21 +32,21 @@
;; Special built-ins take precedence over any other command.
(define *special-built-ins*
`(("." . ,(@@ (geesh built-ins dot) main))
(":" . ,(@@ (geesh built-ins colon) main))
("break" . ,(@@ (geesh built-ins break) main))
("continue" . ,(@@ (geesh built-ins continue) main))
("eval" . ,(@@ (geesh built-ins eval) main))
("exec" . ,(@@ (geesh built-ins exec) main))
("exit" . ,(@@ (geesh built-ins exit) main))
("export" . ,(@@ (geesh built-ins export) main))
("readonly" . ,(@@ (geesh built-ins readonly) main))
("return" . ,(@@ (geesh built-ins return) main))
("set" . ,(@@ (geesh built-ins set) main))
("shift" . ,(@@ (geesh built-ins shift) main))
`(("." . ,(@@ (gash built-ins dot) main))
(":" . ,(@@ (gash built-ins colon) main))
("break" . ,(@@ (gash built-ins break) main))
("continue" . ,(@@ (gash built-ins continue) main))
("eval" . ,(@@ (gash built-ins eval) main))
("exec" . ,(@@ (gash built-ins exec) main))
("exit" . ,(@@ (gash built-ins exit) main))
("export" . ,(@@ (gash built-ins export) main))
("readonly" . ,(@@ (gash built-ins readonly) main))
("return" . ,(@@ (gash built-ins return) main))
("set" . ,(@@ (gash built-ins set) main))
("shift" . ,(@@ (gash built-ins shift) main))
("times" . ,undefined)
("trap" . ,(@@ (geesh built-ins trap) main))
("unset" . ,(@@ (geesh built-ins unset) main))))
("trap" . ,(@@ (gash built-ins trap) main))
("unset" . ,(@@ (gash built-ins unset) main))))
;; Regular built-ins take precendence over utilities in the search
;; path, but not over functions.
@ -54,9 +54,9 @@
`( ;; POSIX-specified built-ins.
("alias" . ,undefined)
("bg" . ,undefined)
("cd" . ,(@@ (geesh built-ins cd) main))
("command" . ,(@@ (geesh built-ins command) main))
("false" . ,(@@ (geesh built-ins false) main))
("cd" . ,(@@ (gash built-ins cd) main))
("command" . ,(@@ (gash built-ins command) main))
("false" . ,(@@ (gash built-ins false) main))
("fc" . ,undefined)
("fg" . ,undefined)
("getopts" . ,undefined)
@ -64,11 +64,11 @@
("jobs" . ,undefined)
("kill" . ,undefined)
("newgrp" . ,undefined)
("pwd" . ,(@@ (geesh built-ins pwd) main))
("read" . ,(@@ (geesh built-ins read) main))
("true" . ,(@@ (geesh built-ins true) main))
("type" . ,(@@ (geesh built-ins type) main))
("umask" . ,(@@ (geesh built-ins umask) main))
("pwd" . ,(@@ (gash built-ins pwd) main))
("read" . ,(@@ (gash built-ins read) main))
("true" . ,(@@ (gash built-ins true) main))
("type" . ,(@@ (gash built-ins type) main))
("umask" . ,(@@ (gash built-ins umask) main))
("unalias" . ,undefined)
("wait" . ,undefined)
;; Other built-ins.

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins break)
#:use-module (geesh environment))
(define-module (gash built-ins break)
#:use-module (gash environment))
;;; Commentary:
;;;

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins cd)
#:use-module (geesh environment)
(define-module (gash built-ins cd)
#:use-module (gash environment)
#:use-module (ice-9 match))
;;; Commentary:
@ -26,7 +26,7 @@
;;;
;;; Code:
(define pwd (@@ (geesh built-ins pwd) main))
(define pwd (@@ (gash built-ins pwd) main))
(define (directory? path)
"Check if @var{path} refers to a directory."

View File

@ -1,22 +1,22 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins colon))
(define-module (gash built-ins colon))
;;; Commentary:
;;;

View File

@ -17,10 +17,10 @@
;;; You should have received a copy of the GNU General Public License
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins command)
(define-module (gash built-ins command)
#:use-module (ice-9 getopt-long)
#:use-module (gash config)
#:use-module (geesh built-ins utils))
#:use-module (gash built-ins utils)
#:use-module (gash config))
;;; Commentary:
;;;
@ -80,4 +80,4 @@ Options:
(else (let* ((command (car files))
(built-in? command)
(args-string (string-join args)))
((@@ (geesh built-ins eval) main) args-string))))))))
((@@ (gash built-ins eval) main) args-string))))))))

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins continue)
#:use-module (geesh environment))
(define-module (gash built-ins continue)
#:use-module (gash environment))
;;; Commentary:
;;;

View File

@ -1,25 +1,25 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins dot)
#:use-module (geesh built-ins utils)
#:use-module (geesh environment)
#:use-module (geesh parser)
(define-module (gash built-ins dot)
#:use-module (gash built-ins utils)
#:use-module (gash environment)
#:use-module (gash parser)
#:use-module (ice-9 match))
;;; Commentary:

View File

@ -1,22 +1,22 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins echo)
(define-module (gash built-ins echo)
#:export (echo))
;;; Commentary:

View File

@ -1,25 +1,25 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins eval)
#:use-module (geesh built-ins utils)
#:use-module (geesh environment)
#:use-module (geesh parser)
(define-module (gash built-ins eval)
#:use-module (gash built-ins utils)
#:use-module (gash environment)
#:use-module (gash parser)
#:use-module (ice-9 match))
;;; Commentary:

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins exec)
#:use-module (geesh environment)
(define-module (gash built-ins exec)
#:use-module (gash environment)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1))

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins exit)
#:use-module (geesh environment))
(define-module (gash built-ins exit)
#:use-module (gash environment))
;;; Commentary:
;;;

View File

@ -1,24 +1,24 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins export)
#:use-module (geesh built-ins utils)
#:use-module (geesh environment)
(define-module (gash built-ins export)
#:use-module (gash built-ins utils)
#:use-module (gash environment)
#:use-module (ice-9 match))
;;; Commentary:

View File

@ -1,22 +1,22 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins false))
(define-module (gash built-ins false))
;;; Commentary:
;;;

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins pwd)
#:use-module (geesh environment)
(define-module (gash built-ins pwd)
#:use-module (gash environment)
#:use-module (ice-9 match))
;;; Commentary:

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins read)
#:use-module (geesh environment)
(define-module (gash built-ins read)
#:use-module (gash environment)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim))

View File

@ -1,24 +1,24 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins readonly)
#:use-module (geesh built-ins utils)
#:use-module (geesh environment)
(define-module (gash built-ins readonly)
#:use-module (gash built-ins utils)
#:use-module (gash environment)
#:use-module (ice-9 match))
;;; Commentary:

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins return)
#:use-module (geesh environment))
(define-module (gash built-ins return)
#:use-module (gash environment))
;;; Commentary:
;;;

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins set)
#:use-module (geesh environment)
(define-module (gash built-ins set)
#:use-module (gash environment)
#:use-module (ice-9 match))
;;; Commentary:

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins shift)
#:use-module (geesh environment)
(define-module (gash built-ins shift)
#:use-module (gash environment)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1))

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins trap)
#:use-module (geesh environment)
(define-module (gash built-ins trap)
#:use-module (gash environment)
#:use-module (ice-9 match))
;;; Commentary:
@ -26,7 +26,7 @@
;;;
;;; Code:
(define sh:eval (@@ (geesh built-ins eval) main))
(define sh:eval (@@ (gash built-ins eval) main))
(define (action->handler action)
(let ((n (string->number action)))

View File

@ -1,22 +1,22 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins true))
(define-module (gash built-ins true))
;;; Commentary:
;;;

View File

@ -17,10 +17,10 @@
;;; You should have received a copy of the GNU General Public License
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins type)
(define-module (gash built-ins type)
#:use-module (ice-9 getopt-long)
#:use-module (gash config)
#:use-module (geesh built-ins utils))
#:use-module (gash built-ins utils)
#:use-module (gash config))
;;; Commentary:
;;;

View File

@ -1,22 +1,22 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins umask)
(define-module (gash built-ins umask)
#:use-module (ice-9 match))
;;; Commentary:

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins unset)
#:use-module (geesh environment)
(define-module (gash built-ins unset)
#:use-module (gash environment)
#:use-module (ice-9 match))
;;; Commentary:

View File

@ -1,22 +1,22 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018, 2019 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh built-ins utils)
(define-module (gash built-ins utils)
#:use-module (ice-9 match)
#:export (get-evaluator
built-in?
@ -32,16 +32,16 @@
;; built-ins. This is a bit of trickery to avoid a module dependency
;; loop.
(define (get-evaluator)
(module-ref (resolve-interface '(geesh eval)) 'eval-sh))
(module-ref (resolve-interface '(gash eval)) 'eval-sh))
;; Similar to 'get-evaluator', we avoid a dependency loop by looking
;; up functions dynamically.
(define (built-in? name)
(let ((search-special-built-ins
(module-ref (resolve-interface '(geesh built-ins))
(module-ref (resolve-interface '(gash built-ins))
'search-special-built-ins))
(search-built-ins
(module-ref (resolve-interface '(geesh built-ins))
(module-ref (resolve-interface '(gash built-ins))
'search-built-ins)))
(or (search-special-built-ins name)
(search-built-ins name))))

View File

@ -1,107 +1,407 @@
;;; Gash --- Guile As SHell
;;; Copyright © 2018 R.E.W. van Beusekom <rutger.van.beusekom@gmail.com>
;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; 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 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.
;;; 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 <http://www.gnu.org/licenses/>.
(define-module (gash environment)
#:use-module (ice-9 hash-table)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (get-status
set-status!
get-root-pid
getvar
setvar!
unsetvar!
exported?
set-exported!
read-only?
set-read-only!
with-variables
get-environ
with-environ
getfun
defun!
unsetfun!
with-arguments
getopt
setopt!
*option-names*
*option-letters*
call-with-continue
sh:continue
call-with-break
sh:break
call-with-return
sh:return
set-atexit!
sh:exit
*fd-count*
fd->current-port))
#:use-module (ice-9 match)
#:use-module (gash io)
;;; Commentary:
;;;
;;; This module contains functions to inspect and manipulate the
;;; environment of the Shell language.
;;;
;;; Code:
#:export (
%command-line
%functions
%global-variables
assignment
function
set-shell-opt!
shell-opt?
variable
variable-and
variable-or
))
;;; Status and PID.
(define %command-line (make-parameter (command-line)))
(define *status* 0)
;; FIXME: export/env vs set
(define %global-variables
(map identity ;; FIXME: make mutable
`(,(cons "SHELL" (car (command-line)))
,(cons "SHELLOPTS" "")
,(cons "PIPESTATUS" "([0]=\"0\"")
,(cons "?" "0")
,@(map (lambda (key-value)
(let* ((key-value (string-split key-value #\=))
(key (car key-value))
(value (cadr key-value)))
(cons key value)))
(environ)))))
(define (get-status)
"Return the current status."
*status*)
(define %functions '())
(define (set-status! n)
"Set the current status."
(set! *status* n))
(define* (assignment name #:optional value)
(let ((value (match value
((? string?) value)
(((? string?) ...) (apply string-append value))
(#f ""))))
(set! %global-variables
(assoc-set! %global-variables name value))
#t))
(define *root-pid* (getpid))
(define* (variable name #:optional (default ""))
(cond ((string->number name)
=>
(lambda (n)
(if (< n (length (%command-line))) (list-ref (%command-line) n)
"")))
((equal? name "@")
(if (pair? (cdr (%command-line))) (cdr (%command-line))
""))
((equal? name "#")
(number->string (length (cdr (%command-line)))))
(else
(or (assoc-ref %global-variables name)
(if (shell-opt? "nounset") (begin
;; TODO: throw/error
(format (current-error-port) "gash: ~a: unbound variable\n" name)
#f)
default)))))
(define (get-root-pid)
*root-pid*)
(define (variable-or name . default)
(variable name (apply string-append default)))
;;; Variables.
(define (variable-and name . default)
(let ((value (variable name #f)))
(if value (apply string-append default) "")))
(define (environ->alist env)
"Convert @var{environ} (a value of the type returned by
@code{environ}) to an alist."
(define (string-split-1 str char_pred)
(and=> (string-index str char_pred)
(lambda (index)
`(,(substring str 0 index) . ,(substring str (1+ index))))))
(filter-map (cut string-split-1 <> #\=) env))
(define (set-shell-opt! name set?)
(let* ((shell-opts (variable "SHELLOPTS"))
(options (if (string-null? shell-opts) '()
(string-split shell-opts #\:)))
(new-options (if set? (delete-duplicates (sort (cons name options) string<))
(filter (negate (cut equal? <> name)) options)))
(new-shell-opts (string-join new-options ":")))
(assignment "SHELLOPTS" new-shell-opts)))
(define (initial-pwd env)
(let* ((pwd (assoc-ref env "PWD"))
(pwd-p (false-if-exception (canonicalize-path pwd))))
(if (and pwd
(string-prefix? "/" pwd)
pwd-p
(string=? pwd-p (getcwd))
(not (any (lambda (component)
(member component '("." "..")))
(string-split pwd #\/))))
pwd
(getcwd))))
(define (shell-opt? name)
(member name (string-split (assoc-ref %global-variables "SHELLOPTS") #\:)))
(define (initial-variables)
(let ((env (environ->alist (environ))))
(alist->hash-table
(map (match-lambda
((name . value) `(,name . ,(vector value #t #f))))
(append `(("PWD" . ,(initial-pwd env)))
env)))))
(define (function name body)
(set! %functions
(assoc-set! %functions name body)))
(define *variables* (initial-variables))
(define (exported? name)
"Check if the variable @var{name} has been exported."
(match (hash-ref *variables* name)
(#(_ exported? _) exported?)
(_ #f)))
(define* (set-exported! name #:optional value)
"Export the variable @var{name}. If the optional parameter
@var{value} is provided, update the variable's value as well."
(match (hash-ref *variables* name)
((? vector? vec)
(vector-set! vec 1 #t)
(when value
(vector-set! vec 0 value)))
(v (hash-set! *variables* name (vector (or value v) #t #f)))))
(define (read-only? name)
"Check if the variable @var{name} has been marked read-only."
(match (hash-ref *variables* name)
(#(_ _ read-only?) read-only?)
(_ #f)))
(define* (set-read-only! name #:optional value)
"Mark the variable @var{name} as read-only. If the optional
parameter @var{value} is provided, update the variable's value as
well."
(match (hash-ref *variables* name)
((? vector? vec)
(vector-set! vec 2 #t)
(when value
(vector-set! vec 0 value)))
(v (hash-set! *variables* name (vector (or value v) #f #t)))))
(define* (getvar name #:optional dflt)
"Return the value of the variable @var{name}. If it does not exist
and @var{dflt} is provided, return @var{dflt}. Otherwise, return
@code{#f}."
(match (hash-ref *variables* name dflt)
(#(value _ _) (or value dflt))
(value value)))
(define (setvar! name value)
"Set the variable @var{name} to @var{value}. If @var{value} is
@code{#f}, the variable will be removed from the set of current
variables. If @var{name} has been marked read-only, an exception will
be thrown."
(match (hash-ref *variables* name)
((? vector? vec)
(when (vector-ref vec 2)
(scm-error
'shell-error "setvar!"
"Attempted to assign the read-only only variable \"~A\"."
`(,name)
'(variable-assignment-error)))
(if value
(vector-set! vec 0 value)
(hash-remove! *variables* name)))
(_ (if value
(hash-set! *variables* name value)
(hash-remove! *variables* name)))))
(define (unsetvar! name)
"Remove the variable @var{name} from the set of current variables."
(setvar! name #f))
(define (with-variables variables thunk)
"Call @var{thunk} in a dynamic extent in which the set of current
variables contains only @var{variables}. The previous set of current
variables is unaffected by any changes made from within the dynamic
extent of @var{thunk}."
(let ((outside-variables #f)
(inside-variables (alist->hash-table variables)))
(dynamic-wind
(lambda ()
(set! outside-variables *variables*)
(set! *variables* inside-variables))
thunk
(lambda ()
(set! inside-variables *variables*)
(set! outside-variables *variables*)))))
(define* (get-environ #:optional (bindings '()))
"Return a value that represents the set of current variables is
suitable for passing to @code{environ}. If @var{bindings} is set,
consider them as part of the set of current variables."
(let ((exported (hash-fold (lambda (name v acc)
(match v
(#(value #t _)
(cons `(,name . ,value) acc))
(_ acc)))
'()
*variables*)))
(map (match-lambda
((name . value) (string-append name "=" value)))
(delete-duplicates!
(append bindings exported)
(lambda (x y)
(string=? (car x) (car y)))))))
(define (with-environ env thunk)
"Call @var{thunk} in a dynamic extent in which the environment (the
regular @code{getenv}/@code{setenv} one -- not the Gash one) has been
set to @var{env} (a value suitable for passing to @code{environ}."
(let ((outside-env #f)
(inside-env env))
(dynamic-wind
(lambda ()
(set! outside-env (environ))
(environ inside-env))
thunk
(lambda ()
(set! inside-env (environ))
(environ outside-env)))))
;;; Functions.
(define *functions* (make-hash-table))
(define (getfun name)
"Return the function @var{name}. If it does not exist, return
@code{#f}."
(hash-ref *functions* name))
(define (defun! name proc)
"Define the function @var{name} to be @var{proc} (a procedure that
takes a variable number of arguments)."
(hash-set! *functions* name proc))
(define (unsetfun! name)
"Remove the function @var{name} from the set of current functions."
(hash-remove! *functions* name))
;;; Arguments.
(define (with-arguments args thunk)
"Call @var{thunk} in a dynamic extent in which the current arguments
list (as obtained by calling @code{program-arguments}) is set to
@var{args}. The previous arguments list is unaffected by any changes
made from within the dynamic extent of @var{thunk}."
(let ((outside-args #f)
(inside-args args))
(dynamic-wind
(lambda ()
(set! outside-args (program-arguments))
(set-program-arguments inside-args))
thunk
(lambda ()
(set! inside-args (program-arguments))
(set-program-arguments outside-args)))))
;;; Options.
(define *options*
(map (cut cons <> #f)
'(allexport
errexit
ignoreeof
monitor
noclobber
noglob
noexec
nolog
notify
nounset
verbose
vi
xtrace)))
(define (getopt name)
"Get the value of the option named @var{name}."
(match (assq name *options*)
((_ . value) value)))
(define (setopt! name value)
"Set the value of the option named @var{name} to @var{value}."
(match (assq name *options*)
((? pair? p) (set-cdr! p value))))
(define *option-names*
(map car *options*))
(define *option-letters*
'((#\a . allexport)
(#\e . errexit)
(#\m . monitor)
(#\C . noclobber)
(#\f . noglob)
(#\n . noexec)
(#\b . notify)
(#\u . nounset)
(#\v . verbose)
(#\x . xtrace)))
;;; Prompts
(define *continue-tag* (make-prompt-tag))
(define (call-with-continue thunk)
"Call @var{thunk} in such a way that a call to @code{continue} will
exit the dynamic extent of @var{thunk}."
(call-with-prompt *continue-tag*
thunk
(lambda (cont n)
(when (> n 0)
(false-if-exception
(abort-to-prompt *continue-tag* (1- n)))))))
(define* (sh:continue #:optional (n 0))
"Exit to the closest invocation of @code{call-with-continue}. If
@var{n} is set, exit to the @math{n + 1}th closest invocation."
(abort-to-prompt *continue-tag* n))
(define *break-tag* (make-prompt-tag))
(define (call-with-break thunk)
"Call @var{thunk} in such a way that a call to @code{break} will
exit the dynamic extent of @var{thunk}."
(call-with-prompt *break-tag*
thunk
(lambda (cont n)
(when (> n 0)
(false-if-exception
(abort-to-prompt *break-tag* (1- n)))))))
(define* (sh:break #:optional (n 0))
"Exit to the closest invocation of @code{call-with-break}. If
@var{n} is set, exit to the @math{n + 1}th closest invocation."
(abort-to-prompt *break-tag* n))
(define *return-tag* (make-prompt-tag))
(define (call-with-return thunk)
"Call @var{thunk} in such a way that a call to @code{return} will
exit the dynamic extent of @var{thunk}."
(call-with-prompt *return-tag*
thunk
(lambda (cont status)
(set-status! status))))
(define* (sh:return #:optional (status (get-status)))
"Exit to the closest invocation of @code{call-with-return} setting
status to @var{status}. If @var{status} is not set, keep the current
status."
(abort-to-prompt *return-tag* status))
(define *atexit* #f)
(define *exiting?* #f)
(define (set-atexit! handler)
(set! *atexit* handler))
(define* (sh:exit #:optional status)
(if (and (not *exiting?*) (thunk? *atexit*))
(begin
(set! *exiting?* #t)
(*atexit*)
(exit (or status (get-status))))
(exit (or status (get-status)))))
;;; Files.
(define *fd-count* 10)
(define current-3-port (make-parameter #f))
(define current-4-port (make-parameter #f))
(define current-5-port (make-parameter #f))
(define current-6-port (make-parameter #f))
(define current-7-port (make-parameter #f))
(define current-8-port (make-parameter #f))
(define current-9-port (make-parameter #f))
(define fd->current-port
(let ((cps (vector current-input-port
current-output-port
current-error-port
current-3-port
current-4-port
current-5-port
current-6-port
current-7-port
current-8-port
current-9-port)))
(lambda (fd)
"Return the current port (e.g. @code{current-input-port})
corresponding to the the Shell file descriptor @var{fd}. The value of
@var{fd} must be a nonnegative integer less than @code{*fd-count*}."
(vector-ref cps fd))))

View File

@ -1,25 +1,25 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh eval)
#:use-module (geesh environment)
#:use-module (geesh shell)
#:use-module (geesh word)
(define-module (gash eval)
#:use-module (gash environment)
#:use-module (gash shell)
#:use-module (gash word)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)

View File

@ -21,10 +21,10 @@
#:use-module (gash script)
#:use-module (gash util)
#:use-module (geesh environment)
#:use-module (geesh eval)
#:use-module (geesh parser)
#:use-module (geesh repl)
#:use-module (gash environment)
#:use-module (gash eval)
#:use-module (gash parser)
#:use-module (gash repl)
#:export (main
%debug-level

View File

@ -31,7 +31,7 @@
))
(catch #t
(lambda _ (use-modules (geesh parser)))
(lambda _ (use-modules (gash parser)))
(lambda (key . args)
#t))

View File

@ -1,22 +1,22 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2017, 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh lexer)
(define-module (gash lexer)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 receive)

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh parser)
#:use-module (geesh lexer)
(define-module (gash parser)
#:use-module (gash lexer)
#:use-module (ice-9 match)
#:use-module (ice-9 textual-ports)
#:use-module (srfi srfi-1)

View File

@ -1,4 +1,4 @@
(define-module (geesh pattern)
(define-module (gash pattern)
#:use-module (ice-9 match)
#:use-module (ice-9 receive)
#:use-module (srfi srfi-1)

View File

@ -1,25 +1,25 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2017, 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh repl)
#:use-module (geesh environment)
#:use-module (geesh eval)
#:use-module (geesh parser)
(define-module (gash repl)
#:use-module (gash environment)
#:use-module (gash eval)
#:use-module (gash parser)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
#:export (run-repl))

View File

@ -1,7 +1,7 @@
(define-module (geesh shell)
#:use-module (geesh built-ins)
#:use-module (geesh environment)
#:use-module (geesh pattern)
(define-module (gash shell)
#:use-module (gash built-ins)
#:use-module (gash environment)
#:use-module (gash pattern)
#:use-module (ice-9 match)
#:use-module (ice-9 textual-ports)
#:use-module (srfi srfi-1)

View File

@ -1,24 +1,24 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (geesh word)
#:use-module (geesh environment)
#:use-module (geesh pattern)
(define-module (gash word)
#:use-module (gash environment)
#:use-module (gash pattern)
#:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)

View File

@ -1,407 +0,0 @@
;;; 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 environment)
#:use-module (ice-9 hash-table)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (get-status
set-status!
get-root-pid
getvar
setvar!
unsetvar!
exported?
set-exported!
read-only?
set-read-only!
with-variables
get-environ
with-environ
getfun
defun!
unsetfun!
with-arguments
getopt
setopt!
*option-names*
*option-letters*
call-with-continue
sh:continue
call-with-break
sh:break
call-with-return
sh:return
set-atexit!
sh:exit
*fd-count*
fd->current-port))
;;; Commentary:
;;;
;;; This module contains functions to inspect and manipulate the
;;; environment of the Shell language.
;;;
;;; Code:
;;; Status and PID.
(define *status* 0)
(define (get-status)
"Return the current status."
*status*)
(define (set-status! n)
"Set the current status."
(set! *status* n))
(define *root-pid* (getpid))
(define (get-root-pid)
*root-pid*)
;;; Variables.
(define (environ->alist env)
"Convert @var{environ} (a value of the type returned by
@code{environ}) to an alist."
(define (string-split-1 str char_pred)
(and=> (string-index str char_pred)
(lambda (index)
`(,(substring str 0 index) . ,(substring str (1+ index))))))
(filter-map (cut string-split-1 <> #\=) env))
(define (initial-pwd env)
(let* ((pwd (assoc-ref env "PWD"))
(pwd-p (false-if-exception (canonicalize-path pwd))))
(if (and pwd
(string-prefix? "/" pwd)
pwd-p
(string=? pwd-p (getcwd))
(not (any (lambda (component)
(member component '("." "..")))
(string-split pwd #\/))))
pwd
(getcwd))))
(define (initial-variables)
(let ((env (environ->alist (environ))))
(alist->hash-table
(map (match-lambda
((name . value) `(,name . ,(vector value #t #f))))
(append `(("PWD" . ,(initial-pwd env)))
env)))))
(define *variables* (initial-variables))
(define (exported? name)
"Check if the variable @var{name} has been exported."
(match (hash-ref *variables* name)
(#(_ exported? _) exported?)
(_ #f)))
(define* (set-exported! name #:optional value)
"Export the variable @var{name}. If the optional parameter
@var{value} is provided, update the variable's value as well."
(match (hash-ref *variables* name)
((? vector? vec)
(vector-set! vec 1 #t)
(when value
(vector-set! vec 0 value)))
(v (hash-set! *variables* name (vector (or value v) #t #f)))))
(define (read-only? name)
"Check if the variable @var{name} has been marked read-only."
(match (hash-ref *variables* name)
(#(_ _ read-only?) read-only?)
(_ #f)))
(define* (set-read-only! name #:optional value)
"Mark the variable @var{name} as read-only. If the optional
parameter @var{value} is provided, update the variable's value as
well."
(match (hash-ref *variables* name)
((? vector? vec)
(vector-set! vec 2 #t)
(when value
(vector-set! vec 0 value)))
(v (hash-set! *variables* name (vector (or value v) #f #t)))))
(define* (getvar name #:optional dflt)
"Return the value of the variable @var{name}. If it does not exist
and @var{dflt} is provided, return @var{dflt}. Otherwise, return
@code{#f}."
(match (hash-ref *variables* name dflt)
(#(value _ _) (or value dflt))
(value value)))
(define (setvar! name value)
"Set the variable @var{name} to @var{value}. If @var{value} is
@code{#f}, the variable will be removed from the set of current
variables. If @var{name} has been marked read-only, an exception will
be thrown."
(match (hash-ref *variables* name)
((? vector? vec)
(when (vector-ref vec 2)
(scm-error
'shell-error "setvar!"
"Attempted to assign the read-only only variable \"~A\"."
`(,name)
'(variable-assignment-error)))
(if value
(vector-set! vec 0 value)
(hash-remove! *variables* name)))
(_ (if value
(hash-set! *variables* name value)
(hash-remove! *variables* name)))))
(define (unsetvar! name)
"Remove the variable @var{name} from the set of current variables."
(setvar! name #f))
(define (with-variables variables thunk)
"Call @var{thunk} in a dynamic extent in which the set of current
variables contains only @var{variables}. The previous set of current
variables is unaffected by any changes made from within the dynamic
extent of @var{thunk}."
(let ((outside-variables #f)
(inside-variables (alist->hash-table variables)))
(dynamic-wind
(lambda ()
(set! outside-variables *variables*)
(set! *variables* inside-variables))
thunk
(lambda ()
(set! inside-variables *variables*)
(set! outside-variables *variables*)))))
(define* (get-environ #:optional (bindings '()))
"Return a value that represents the set of current variables is
suitable for passing to @code{environ}. If @var{bindings} is set,
consider them as part of the set of current variables."
(let ((exported (hash-fold (lambda (name v acc)
(match v
(#(value #t _)
(cons `(,name . ,value) acc))
(_ acc)))
'()
*variables*)))
(map (match-lambda
((name . value) (string-append name "=" value)))
(delete-duplicates!
(append bindings exported)
(lambda (x y)
(string=? (car x) (car y)))))))
(define (with-environ env thunk)
"Call @var{thunk} in a dynamic extent in which the environment (the
regular @code{getenv}/@code{setenv} one -- not the Geesh one) has been
set to @var{env} (a value suitable for passing to @code{environ}."
(let ((outside-env #f)
(inside-env env))
(dynamic-wind
(lambda ()
(set! outside-env (environ))
(environ inside-env))
thunk
(lambda ()
(set! inside-env (environ))
(environ outside-env)))))
;;; Functions.
(define *functions* (make-hash-table))
(define (getfun name)
"Return the function @var{name}. If it does not exist, return
@code{#f}."
(hash-ref *functions* name))
(define (defun! name proc)
"Define the function @var{name} to be @var{proc} (a procedure that
takes a variable number of arguments)."
(hash-set! *functions* name proc))
(define (unsetfun! name)
"Remove the function @var{name} from the set of current functions."
(hash-remove! *functions* name))
;;; Arguments.
(define (with-arguments args thunk)
"Call @var{thunk} in a dynamic extent in which the current arguments
list (as obtained by calling @code{program-arguments}) is set to
@var{args}. The previous arguments list is unaffected by any changes
made from within the dynamic extent of @var{thunk}."
(let ((outside-args #f)
(inside-args args))
(dynamic-wind
(lambda ()
(set! outside-args (program-arguments))
(set-program-arguments inside-args))
thunk
(lambda ()
(set! inside-args (program-arguments))
(set-program-arguments outside-args)))))
;;; Options.
(define *options*
(map (cut cons <> #f)
'(allexport
errexit
ignoreeof
monitor
noclobber
noglob
noexec
nolog
notify
nounset
verbose
vi
xtrace)))
(define (getopt name)
"Get the value of the option named @var{name}."
(match (assq name *options*)
((_ . value) value)))
(define (setopt! name value)
"Set the value of the option named @var{name} to @var{value}."
(match (assq name *options*)
((? pair? p) (set-cdr! p value))))
(define *option-names*
(map car *options*))
(define *option-letters*
'((#\a . allexport)
(#\e . errexit)
(#\m . monitor)
(#\C . noclobber)
(#\f . noglob)
(#\n . noexec)
(#\b . notify)
(#\u . nounset)
(#\v . verbose)
(#\x . xtrace)))
;;; Prompts
(define *continue-tag* (make-prompt-tag))
(define (call-with-continue thunk)
"Call @var{thunk} in such a way that a call to @code{continue} will
exit the dynamic extent of @var{thunk}."
(call-with-prompt *continue-tag*
thunk
(lambda (cont n)
(when (> n 0)
(false-if-exception
(abort-to-prompt *continue-tag* (1- n)))))))
(define* (sh:continue #:optional (n 0))
"Exit to the closest invocation of @code{call-with-continue}. If
@var{n} is set, exit to the @math{n + 1}th closest invocation."
(abort-to-prompt *continue-tag* n))
(define *break-tag* (make-prompt-tag))
(define (call-with-break thunk)
"Call @var{thunk} in such a way that a call to @code{break} will
exit the dynamic extent of @var{thunk}."
(call-with-prompt *break-tag*
thunk
(lambda (cont n)
(when (> n 0)
(false-if-exception
(abort-to-prompt *break-tag* (1- n)))))))
(define* (sh:break #:optional (n 0))
"Exit to the closest invocation of @code{call-with-break}. If
@var{n} is set, exit to the @math{n + 1}th closest invocation."
(abort-to-prompt *break-tag* n))
(define *return-tag* (make-prompt-tag))
(define (call-with-return thunk)
"Call @var{thunk} in such a way that a call to @code{return} will
exit the dynamic extent of @var{thunk}."
(call-with-prompt *return-tag*
thunk
(lambda (cont status)
(set-status! status))))
(define* (sh:return #:optional (status (get-status)))
"Exit to the closest invocation of @code{call-with-return} setting
status to @var{status}. If @var{status} is not set, keep the current
status."
(abort-to-prompt *return-tag* status))
(define *atexit* #f)
(define *exiting?* #f)
(define (set-atexit! handler)
(set! *atexit* handler))
(define* (sh:exit #:optional status)
(if (and (not *exiting?*) (thunk? *atexit*))
(begin
(set! *exiting?* #t)
(*atexit*)
(exit (or status (get-status))))
(exit (or status (get-status)))))
;;; Files.
(define *fd-count* 10)
(define current-3-port (make-parameter #f))
(define current-4-port (make-parameter #f))
(define current-5-port (make-parameter #f))
(define current-6-port (make-parameter #f))
(define current-7-port (make-parameter #f))
(define current-8-port (make-parameter #f))
(define current-9-port (make-parameter #f))
(define fd->current-port
(let ((cps (vector current-input-port
current-output-port
current-error-port
current-3-port
current-4-port
current-5-port
current-6-port
current-7-port
current-8-port
current-9-port)))
(lambda (fd)
"Return the current port (e.g. @code{current-input-port})
corresponding to the the Shell file descriptor @var{fd}. The value of
@var{fd} must be a nonnegative integer less than @code{*fd-count*}."
(vector-ref cps fd))))

View File

@ -35,7 +35,7 @@
(member relative paths)))))
(package
(name "geesh")
(name "gash")
(version *version*)
(source (local-file *srcdir* #:recursive? #t #:select? (make-select)))
(build-system gnu-build-system)
@ -52,8 +52,8 @@
(add-before 'configure 'bootstrap
(lambda _
(zero? (system* "sh" "bootstrap")))))))
(home-page "https://gitlab.com/samplet/geesh")
(home-page "https://gitlab.com/samplet/gash")
(synopsis "POSIX-compatible shell written in Guile Scheme")
(description "Geesh is a POSIX-compatible shell written in Guile
(description "Gash is a POSIX-compatible shell written in Guile
Scheme. It is designed to be capable of bootstrapping Bash.")
(license license:gpl3+))

View File

@ -1,63 +0,0 @@
#!@GUILE@ --no-auto-compile
-*- scheme -*-
!#
;;; The Geesh Shell Interpreter
;;; Copyright 2017 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/>.
(add-to-load-path "@MODDIR@")
(set! %load-compiled-path (cons "@GODIR@" %load-compiled-path))
(use-modules (geesh repl)
(ice-9 getopt-long))
(define options-spec
'((command (single-char #\c) (value #t))
(stdin (single-char #\s))))
(let* ((options (getopt-long (program-arguments) options-spec
#:stop-at-first-non-option #t))
(command (option-ref options 'command #f))
(stdin (option-ref options 'stdin #f))
(args (option-ref options '() '())))
(cond
((and command stdin)
(format (current-error-port)
"~a: Invalid options.~%"
(car (program-arguments)))
(exit EXIT_FAILURE))
(command
(if (null? args)
(set-program-arguments (list (car (program-arguments))))
(set-program-arguments args))
(call-with-input-string command
(lambda (port)
(exit (run-repl port)))))
(stdin
(set-program-arguments (cons (car (program-arguments)) args))
(exit (run-repl)))
(else
(cond
((null? args)
(set-program-arguments (list (car (program-arguments))))
(exit (run-repl)))
(else
(set-program-arguments args)
(call-with-input-file (car args)
(lambda (port)
(exit (run-repl port)))))))))

View File

@ -5,22 +5,22 @@
(guix utils)
(ice-9 match))
(define geesh
(define gash
(load (string-append (current-source-directory) "/../../guix.scm")))
(define geesh-with-links
(define gash-with-links
(package
(inherit geesh)
(inherit gash)
(arguments
(substitute-keyword-arguments (package-arguments geesh)
(substitute-keyword-arguments (package-arguments gash)
((#:phases phases '%standard-phases)
`(modify-phases ,phases
(add-after 'install 'link-bash
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(symlink (string-append out "/bin/geesh")
(symlink (string-append out "/bin/gash")
(string-append out "/bin/sh"))
(symlink (string-append out "/bin/geesh")
(symlink (string-append out "/bin/gash")
(string-append out "/bin/bash")))))))))))
(define bash-without-bash
@ -28,7 +28,7 @@
(bag
(inherit bash-bag)
(build-inputs
`(("bash" ,geesh-with-links)
`(("bash" ,gash-with-links)
,@(filter (match-lambda
((name . _)
(not (member name '("bash")))))

View File

@ -7,12 +7,12 @@ oil: oil-link
cp -R -H oil-link "$@"
chmod -R u+w "$@"
oil/bin/geesh: oil
oil/bin/gash: oil
echo "#!/bin/sh" > "$@"
echo "$(abs_top_builddir)/pre-inst-env geesh "'"$$@"' >> "$@"
echo "$(abs_top_builddir)/pre-inst-env gash "'"$$@"' >> "$@"
chmod a+x "$@"
check: oil/bin/geesh ;
check: oil/bin/gash ;
TEST_EXTENSIONS = .sh
SH_LOG_COMPILER = ./check-spec

View File

@ -1,7 +1,7 @@
#!/bin/sh
cd oil
export OSH_LIST=bin/geesh
export OSH_LIST=bin/gash
test_name=$(basename "$1")
test_name=${test_name%.sh}

View File

@ -109,7 +109,7 @@
("errexit and time { }")
;; Follow Dash on this one.
("errexit with (( ))"
("N-I dash" "N-I dash/geesh"))
("N-I dash" "N-I dash/gash"))
;; These next two are due to a difference
;; between the Oil shell and every other shell.
;; Oil thinks that setting the errexit option in
@ -125,10 +125,10 @@
("Tilde expansion within for loop")
;; This is beyond POSIX.
("Brace Expansion within Array"
("N-I dash" "N-I dash/geesh"))
("N-I dash" "N-I dash/gash"))
;; We match Bash here.
("for loop with invalid identifier"
("OK bash" "OK bash/geesh"))
("OK bash" "OK bash/gash"))
;; For these next two, we do not have arithmetic
;; substitution, but we can use 'expr' instead.
("while in pipe"
@ -138,9 +138,9 @@
("spec/quote.test.sh"
(;; We match KornShell on these two tests.
("Unterminated single quote"
("OK mksh" "OK mksh/geesh"))
("OK mksh" "OK mksh/gash"))
("Unterminated double quote"
("OK mksh" "OK mksh/geesh"))
("OK mksh" "OK mksh/gash"))
;; The rest of these are well beyond POSIX.
("$''")
("$'' with quotes")
@ -165,26 +165,26 @@
("spec/var-sub.test.sh"
(;; We match Bash here.
("Bad var sub"
("OK bash" "OK bash/geesh"))
("OK bash" "OK bash/gash"))
;; This test expects 'ls' to be at '/bin/ls',
;; which isn't the case on GuixSD.
("Braced block inside ${}"
("which ls" "guile -c '(display \"/bin/ls\")'"))
;; We match KornShell here.
("Here doc with bad \"$@\" delimiter"
("OK mksh" "OK mksh/geesh"))))
("OK mksh" "OK mksh/gash"))))
("spec/redirect.test.sh"
(;; We match Bash and Dash here, just not Oil.
("Redirect in assignment is invalid"
("OK bash" "OK bash/geesh"))
("OK bash" "OK bash/gash"))
;; Again, we match Dash here (though not Bash).
("Redirect in assignment"
("OK dash" "OK dash/geesh"))
("OK dash" "OK dash/gash"))
;; This test requires arithmetic substitutions.
("Redirect in function body is evaluated multiple times")
;; We match KornShell here.
("Prefix redirect for loop -- not allowed"
("OK mksh" "OK mksh/geesh"))
("OK mksh" "OK mksh/gash"))
;; We do not support named file descriptors
;; (they are not in POSIX).
("Named file descriptor")

View File

@ -1,20 +1,20 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2017 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (tests unit automake)
#:use-module (srfi srfi-64))

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2017, 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (test-lexer)
#:use-module (geesh lexer)
#:use-module (gash lexer)
#:use-module (ice-9 match)
#:use-module (srfi srfi-64)
#:use-module (system base lalr)

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (test-parser)
#:use-module (geesh parser)
#:use-module (gash parser)
#:use-module (srfi srfi-64)
#:use-module (tests unit automake))

View File

@ -1,23 +1,23 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (test-pattern)
#:use-module (geesh pattern)
#:use-module (gash pattern)
#:use-module (srfi srfi-64)
#:use-module (tests unit automake))

View File

@ -1,24 +1,24 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (test-shell)
#:use-module (geesh environment)
#:use-module (geesh shell)
#:use-module (gash environment)
#:use-module (gash shell)
#:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:use-module (ice-9 textual-ports)

View File

@ -1,24 +1,24 @@
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2018 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (test-word)
#:use-module (geesh environment)
#:use-module (geesh word)
#:use-module (gash environment)
#:use-module (gash word)
#:use-module (srfi srfi-64)
#:use-module (tests unit automake))

View File

@ -2,23 +2,23 @@
-*- scheme -*-
!#
;;; The Geesh Shell Interpreter
;;; Gash -- Guile As SHell
;;; Copyright 2017 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Geesh.
;;; This file is part of Gash.
;;;
;;; Geesh is free software: you can redistribute it and/or modify
;;; 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.
;;;
;;; Geesh is distributed in the hope that it will be useful,
;;; 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 Geesh. If not, see <http://www.gnu.org/licenses/>.
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(use-modules (ice-9 popen)
(ice-9 receive)