r8183: docbook functions
[kmrcl.git] / os.lisp
diff --git a/os.lisp b/os.lisp
index 9b193ab0119dbd81ca3f2c6696076464a63548d5..b31d4bad074778e58d27548677d4457511e2a281 100644 (file)
--- a/os.lisp
+++ b/os.lisp
 
 (in-package #:kmrcl)
 
+(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 error-output exit-status)"
+  (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 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 string-output exit-code)"
+returns (VALUES output-string pid)"
   (let ((command (apply #'format nil control-string args)))
     #+sbcl
     (sb-impl::process-exit-code
@@ -32,13 +78,14 @@ returns (VALUES string-output exit-code)"
       (list  "-c" command)
       :input nil :output nil))
     
+    
     #+allegro
-    (multiple-value-bind (output dummy exit)
+    (multiple-value-bind (output dummy pid)
        (excl:run-shell-command command :input nil :output :stream
                                :wait nil)
       (declare (ignore dummy))
-      (values output exit))
-    
+      (values output pid))
+
     #+lispworks
     (system:call-system-showing-output
      command