X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=os.lisp;fp=os.lisp;h=f7e600ffb3bd20b08e81fa986391f4400bd29d5a;hp=0000000000000000000000000000000000000000;hb=5093ad6645375d1d9259097ea5c9122e5592be2f;hpb=cf4d25858f4969025835e23008818d94c6e23208 diff --git a/os.lisp b/os.lisp new file mode 100644 index 0000000..f7e600f --- /dev/null +++ b/os.lisp @@ -0,0 +1,61 @@ +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: os.lisp +;;;; Purpose: Operating System utilities +;;;; Programmer: Kevin M. Rosenberg +;;;; Date Started: Jul 2003 +;;;; +;;;; $Id: os.lisp,v 1.1 2003/07/23 22:08:21 kevin Exp $ +;;;; +;;;; ************************************************************************* + +(in-package #:kmrcl) + +(defun run-shell-command (control-string &rest args) + "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and +synchronously execute the result using a Bourne-compatible shell, +returns (VALUES string-output exit-code)" + (let ((command (apply #'format nil control-string args))) + #+sbcl + (sb-impl::process-exit-code + (sb-ext:run-program + "/bin/sh" + (list "-c" command) + :input nil :output nil)) + + #+(or cmu scl) + (ext:process-exit-code + (ext:run-program + "/bin/sh" + (list "-c" command) + :input nil :output nil)) + + #+allegro + (multiple-value-bind (output dummy exit) + (excl:run-shell-command command :input nil :output :stream + :wait nil) + (declare (ignore dummy)) + (values output exit)) + + #+lispworks + (system:call-system-showing-output + command + :shell-type "/bin/sh" + :output-stream output) + + #+clisp ;XXX not exactly *verbose-out*, I know + (ext:run-shell-command command :output :terminal :wait t) + + #+openmcl + (nth-value 1 + (ccl:external-process-status + (ccl:run-program "/bin/sh" (list "-c" command) + :input nil :output nil + :wait t))) + + #-(or openmcl clisp lispworks allegro scl cmu sbcl) + (error "RUN-SHELL-PROGRAM not implemented for this Lisp") + + ))