Permalink
Browse files

Added the function TRIVIAL-SHELL:EXIT

  • Loading branch information...
lokedhs committed Sep 3, 2012
1 parent c8d98b4 commit 1e47e4e33a406a3a2d5b08cba7f92625a398a52b
Showing with 38 additions and 5 deletions.
  1. +2 −0 dev/allegro.lisp
  2. +3 −0 dev/clisp.lisp
  3. +4 −1 dev/cmucl.lisp
  4. +3 −0 dev/digitool.lisp
  5. +4 −1 dev/ecl.lisp
  6. +4 −1 dev/lispworks.lisp
  7. +4 −1 dev/openmcl.lisp
  8. +1 −0 dev/package.lisp
  9. +4 −1 dev/sbcl.lisp
  10. +9 −0 dev/shell.lisp
View
@@ -32,3 +32,5 @@
(defun %get-env-var (name)
(sys:getenv name))
+(defun %exit (code)
+ (excl:exit code))
View
@@ -14,3 +14,6 @@
(defun %get-env-var (name)
(ext:getenv name))
+
+(defun %exit (code)
+ (ext:exit code))
View
@@ -21,4 +21,7 @@
(defun %get-env-var (name)
(cdr (assoc (intern (substitute #\_ #\- name)
:keyword)
- ext:*environment-list*)))
+ ext:*environment-list*)))
+
+(defun %exit (code)
+ (ext:quit code))
View
@@ -4,3 +4,6 @@
(when input
(error "This version of trivial-shell does not support the input parameter."))
(ccl:do-shell-script command))
+
+(defun %exit (code)
+ (error 'unsupported-function-error :function 'exit))
View
@@ -7,4 +7,7 @@
(error 'unsupported-function-error :function 'os-process-id))
(defun %get-env-var (name)
- (ext:getenv name))
+ (ext:getenv name))
+
+(defun %exit (code)
+ (ext:exit code))
View
@@ -19,4 +19,7 @@
(error 'unsupported-function-error :function 'os-process-id))
(defun %get-env-var (name)
- (lw:environment-variable name))
+ (lw:environment-variable name))
+
+(defun %exit (code)
+ (lw:quit :status code))
View
@@ -30,4 +30,7 @@
(error 'unsupported-function-error :function 'os-process-id))
(defun %get-env-var (name)
- (ccl::getenv name))
+ (ccl::getenv name))
+
+(defun %exit (code)
+ (ccl:quit code))
View
@@ -7,6 +7,7 @@
#:shell-command
#:with-timeout
#:get-env-var
+ #:exit
#:*bourne-compatible-shell*
#:*shell-search-paths*
View
@@ -84,4 +84,7 @@
(error 'unsupported-function-error :function 'os-process-id))
(defun %get-env-var (name)
- (sb-ext:posix-getenv name))
+ (sb-ext:posix-getenv name))
+
+(defun %exit (code)
+ (sb-ext:exit :code code))
View
@@ -69,3 +69,12 @@ may be used to find a shell to use in executing `command`."
(defun get-env-var (name)
"Return the value of the environment variable `name`."
(%get-env-var name))
+
+(defun exit (&optional (code :success))
+ "Exit the process. CODE is either a numeric exit code, or the special values :SUCCESS
+or :FAILURE, which maps to the appropriate exit codes for the operating system."
+ ;; Currently, :SUCCESS always maps to 0 and :FAILURE maps to 1
+ (%exit (cond ((eq code :success) 0)
+ ((eq code :failure) 1)
+ ((integerp code) code)
+ (t (error "Illegal exit code: ~s (should be an integer or the values :SUCCESS or :FAILURE)" code)))))

0 comments on commit 1e47e4e

Please sign in to comment.