2018-07-17 16:20:06 +01:00
|
|
|
;;; 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)
|
|
|
|
#:use-module (geesh built-ins echo)
|
|
|
|
#:export (search-built-ins
|
|
|
|
search-special-built-ins))
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;;
|
|
|
|
;;; This module provides built-in searching functions.
|
|
|
|
;;;
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(define (undefined env . args)
|
|
|
|
(throw 'undefined-built-in))
|
|
|
|
|
|
|
|
;; Special built-ins take precedence over any other command.
|
|
|
|
(define *special-built-ins*
|
|
|
|
`(("." . ,undefined)
|
|
|
|
(":" . ,undefined)
|
2018-11-21 15:59:19 +00:00
|
|
|
("break" . ,(@@ (geesh built-ins break) main))
|
|
|
|
("continue" . ,(@@ (geesh built-ins continue) main))
|
2018-07-17 16:20:06 +01:00
|
|
|
("eval" . ,undefined)
|
|
|
|
("exec" . ,undefined)
|
|
|
|
("exit" . ,undefined)
|
2018-11-21 18:27:50 +00:00
|
|
|
("export" . ,(@@ (geesh built-ins export) main))
|
2018-11-21 18:34:30 +00:00
|
|
|
("readonly" . ,(@@ (geesh built-ins readonly) main))
|
2018-07-17 16:20:06 +01:00
|
|
|
("return" . ,undefined)
|
|
|
|
("set" . ,undefined)
|
|
|
|
("shift" . ,undefined)
|
|
|
|
("times" . ,undefined)
|
|
|
|
("trap" . ,undefined)
|
2018-11-16 02:05:12 +00:00
|
|
|
("unset" . ,(@@ (geesh built-ins unset) main))))
|
2018-07-17 16:20:06 +01:00
|
|
|
|
|
|
|
;; Regular built-ins take precendence over utilities in the search
|
|
|
|
;; path, but not over functions.
|
|
|
|
(define *built-ins*
|
|
|
|
`( ;; POSIX-specified built-ins.
|
|
|
|
("alias" . ,undefined)
|
|
|
|
("bg" . ,undefined)
|
|
|
|
("cd" . ,undefined)
|
|
|
|
("command" . ,undefined)
|
2018-10-17 00:39:20 +01:00
|
|
|
("false" . ,(@@ (geesh built-ins false) main))
|
2018-07-17 16:20:06 +01:00
|
|
|
("fc" . ,undefined)
|
|
|
|
("fg" . ,undefined)
|
|
|
|
("getopts" . ,undefined)
|
|
|
|
("hash" . ,undefined)
|
|
|
|
("jobs" . ,undefined)
|
|
|
|
("kill" . ,undefined)
|
|
|
|
("newgrp" . ,undefined)
|
|
|
|
("pwd" . ,undefined)
|
2018-10-16 23:15:05 +01:00
|
|
|
("read" . ,(@@ (geesh built-ins read) main))
|
2018-11-21 16:39:06 +00:00
|
|
|
("true" . ,(@@ (geesh built-ins true) main))
|
2018-07-17 16:20:06 +01:00
|
|
|
("umask" . ,undefined)
|
|
|
|
("unalias" . ,undefined)
|
|
|
|
("wait" . ,undefined)
|
|
|
|
;; Other built-ins.
|
|
|
|
("echo" . ,echo)))
|
|
|
|
|
|
|
|
(define (search-special-built-ins name)
|
|
|
|
(assoc-ref *special-built-ins* name))
|
|
|
|
|
|
|
|
(define (search-built-ins name)
|
|
|
|
(assoc-ref *built-ins* name))
|