commit 48b1a06bdba2debb4f1c7a0b5c6d32b77f3f9905
parent ca90a372f4b0738eaf586ed027984bfc2791a02b
Author: Tomas Hlavaty <tom@logand.com>
Date: Wed, 28 Aug 2013 23:20:59 +0200
port rw.os to ecl
Diffstat:
M | os.lisp | | | 33 | ++++++++++++++++++++++++--------- |
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/os.lisp b/os.lisp
@@ -34,13 +34,17 @@
(error (format nil "~a error ~d: ~a ~s" cmd code reason args)))))
(defun run-command (cmd args &optional error-plist)
- #-(or cmu sbcl clisp openmcl)
+ #-(or cmu sbcl clisp openmcl ecl)
(error "TODO port RW.OS:RUN-COMMAND")
(let ((p
#+cmu(ext:run-program cmd args)
#+sbcl(sb-ext:run-program cmd args :search t)
#+clisp(ext:run-program cmd :arguments args)
- #+openmcl(ccl:run-program cmd args)))
+ #+openmcl(ccl:run-program cmd args)
+ #+ecl (nth-value 2 (ext:run-program cmd args
+ :input nil
+ :output nil
+ :error nil))))
(when p
(unwind-protect
(let ((code #+cmu(ext:process-exit-code p)
@@ -49,7 +53,8 @@
#+openmcl(multiple-value-bind (a b)
(ccl:external-process-status p)
(declare (ignore a))
- b)))
+ b)
+ #+ecl(ext::external-process-%code p)))
(if (eq 0 code)
t
(throw-error cmd args code error-plist)))
@@ -58,16 +63,22 @@
#+openmcl(flet ((finish (x) (when x (close x))))
(finish (ccl:external-process-output-stream p))
(finish (ccl:external-process-input-stream p))
- (finish (ccl:external-process-error-stream p)))))))
+ (finish (ccl:external-process-error-stream p)))
+ ;; TODO ecl?
+ ))))
(defun call-with-program-output (cmd args error-plist fn)
- #-(or cmu sbcl clisp openmcl)
+ #-(or cmu sbcl clisp openmcl ecl)
(error "TODO port RW.OS::CALL-WITH-PROGRAM-OUTPUT")
(let ((p
#+cmu(ext:run-program cmd args :output :stream)
#+sbcl(sb-ext:run-program cmd args :output :stream :search t)
#+clisp(ext:run-program cmd :arguments args :output :stream)
- #+openmcl(ccl:run-program cmd args :output :stream)))
+ #+openmcl(ccl:run-program cmd args :output :stream)
+ #+ecl (nth-value 2 (ext:run-program cmd args
+ :input nil
+ :output :stream
+ :error nil))))
(when p
(unwind-protect
(let ((code #+cmu(ext:process-exit-code p)
@@ -76,20 +87,24 @@
#+openmcl(multiple-value-bind (a b)
(ccl:external-process-status p)
(declare (ignore a))
- b)))
+ b)
+ #+ecl(ext::external-process-%code p)))
(if (eq 0 code)
(funcall fn
#+cmu(ext:process-output p)
#+sbcl(sb-ext:process-output p)
#+clisp p
- #+openmcl(ccl:external-process-output-stream p))
+ #+openmcl(ccl:external-process-output-stream p)
+ #+ecl(ext:external-process-output p))
(throw-error cmd args code error-plist)))
#+cmu(ext:process-close p)
#+sbcl(sb-ext:process-close p)
#+openmcl(flet ((finish (x) (when x (close x))))
(finish (ccl:external-process-output-stream p))
(finish (ccl:external-process-input-stream p))
- (finish (ccl:external-process-error-stream p)))))))
+ (finish (ccl:external-process-error-stream p)))
+ ;; TODO ecl?
+ ))))
(defmacro with-program-output ((var cmd args &optional error-plist) &body body)
`(call-with-program-output ,cmd ,args ,error-plist (lambda (,var) ,@body)))