X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=os.lisp;h=589eac4b74e89a2ef798ce01030315a3770a87b9;hp=f7e600ffb3bd20b08e81fa986391f4400bd29d5a;hb=8513c6f273613b0ceb2b48c07da6a0b1803c32a5;hpb=5093ad6645375d1d9259097ea5c9122e5592be2f diff --git a/os.lisp b/os.lisp index f7e600f..589eac4 100644 --- a/os.lisp +++ b/os.lisp @@ -7,16 +7,16 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Jul 2003 ;;;; -;;;; $Id: os.lisp,v 1.1 2003/07/23 22:08:21 kevin Exp $ +;;;; $Id$ ;;;; ;;;; ************************************************************************* (in-package #:kmrcl) -(defun run-shell-command (control-string &rest args) +(defun command-output (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)" +returns (VALUES string-output error-output exit-status)" (let ((command (apply #'format nil control-string args))) #+sbcl (sb-impl::process-exit-code @@ -32,13 +32,57 @@ returns (VALUES string-output exit-code)" (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)) + (multiple-value-bind (output error status) + (excl.osi:command-output command) + (values output error status)) + + #+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") + + )) + +(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 output-string pid)" + (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 + (excl:run-shell-command command :input nil :output nil + :wait t) + #+lispworks (system:call-system-showing-output command