Commit d9d1a48f authored by Francois-Rene Rideau's avatar Francois-Rene Rideau
Browse files

Simplify run-program on ECL

Undo some ugly workaround from 3d8764fc now that ECL fixed bug 149:
https://gitlab.com/embeddable-common-lisp/ecl/issues/149
parent 6b71a134
...@@ -386,15 +386,7 @@ argument to pass to the internal RUN-PROGRAM" ...@@ -386,15 +386,7 @@ argument to pass to the internal RUN-PROGRAM"
(etypecase specifier (etypecase specifier
(null (or #+(or allegro lispworks) (null-device-pathname))) (null (or #+(or allegro lispworks) (null-device-pathname)))
(string (parse-native-namestring specifier)) (string (parse-native-namestring specifier))
(pathname (pathname specifier)
#-ecl specifier
#+ecl (let ((s (apply 'open specifier :direction
(ecase role
((:input)
'(:input :if-does-not-exist :error))
((:output :error-output)
'(:output :if-does-not-exist :create :if-exists :rename-and-delete))))))
(values s s)))
(stream specifier) (stream specifier)
((eql :stream) :stream) ((eql :stream) :stream)
((eql :interactive) ((eql :interactive)
...@@ -417,12 +409,6 @@ argument to pass to the internal RUN-PROGRAM" ...@@ -417,12 +409,6 @@ argument to pass to the internal RUN-PROGRAM"
(integer raw-exit-code) ; negative: signal (integer raw-exit-code) ; negative: signal
(t -1))) (t -1)))
(defun call-with-open-streams (streams thunk)
(unwind-protect (funcall thunk) (dolist (s streams) (ignore-errors (close s)))))
(defmacro with-open-streams ((streams) &body body)
`(call-with-closing ,streams #'(lambda () ,@body)))
(defun %run-program (command (defun %run-program (command
&rest keys &rest keys
&key input (if-input-does-not-exist :error) &key input (if-input-does-not-exist :error)
...@@ -443,28 +429,19 @@ It returns a process-info plist with possible keys: ...@@ -443,28 +429,19 @@ It returns a process-info plist with possible keys:
#-(or allegro clasp clisp clozure cmu ecl (and lispworks os-unix) mkcl sbcl scl) #-(or allegro clasp clisp clozure cmu ecl (and lispworks os-unix) mkcl sbcl scl)
(progn command keys directory (progn command keys directory
(error "run-program not available")) (error "run-program not available"))
#+(or allegro clisp clozure cmu ecl (and lispworks os-unix) mkcl sbcl scl) #+(or allegro clasp clisp clozure cmu ecl (and lispworks os-unix) mkcl sbcl scl)
(nest (let* ((%command (%normalize-command command))
(let ((%command (%normalize-command command)) (%input (%normalize-io-specifier input :input))
#+ecl (close-me '()))) (%output (%normalize-io-specifier output :output))
(multiple-value-bind (%input #+ecl i-close) (%error-output (%normalize-io-specifier error-output :error-output))
(%normalize-io-specifier input :input) (interactive (%interactivep input output error-output))
#+ecl (when i-close (push i-close close-me))) (process*
(multiple-value-bind (%output #+ecl o-close)
(%normalize-io-specifier output :output)
#+ecl (when o-close (push o-close close-me)))
(multiple-value-bind (%error-output #+ecl e-close)
(%normalize-io-specifier error-output :error-output)
#+ecl (when e-close (push e-close close-me)))
#+(and allegro os-windows) (let ((interactive (%interactivep input output error-output))))
(let ((process*
(nest (nest
#+clisp (progn #+clisp (progn
;; clisp cannot redirect stderr, so check we don't. ;; clisp cannot redirect stderr, so check we don't.
;; Also, since we now always return a code, we cannot use this code path ;; Also, since we now always return a code, we cannot use this code path
;; if any of the input, output or error-output is :stream. ;; if any of the input, output or error-output is :stream.
(assert (eq %error-output :terminal))) (assert (eq %error-output :terminal)))
#+ecl (with-open-streams (close-me))
#-(or allegro mkcl sbcl) (with-current-directory (directory)) #-(or allegro mkcl sbcl) (with-current-directory (directory))
#+(or allegro clasp clisp ecl lispworks mkcl) (multiple-value-list) #+(or allegro clasp clisp ecl lispworks mkcl) (multiple-value-list)
(apply (apply
...@@ -501,7 +478,7 @@ It returns a process-info plist with possible keys: ...@@ -501,7 +478,7 @@ It returns a process-info plist with possible keys:
#+mkcl `(:directory ,(native-namestring directory)) #+mkcl `(:directory ,(native-namestring directory))
#-sbcl keys #-sbcl keys
#+sbcl (if directory keys (remove-plist-key :directory keys)))))) #+sbcl (if directory keys (remove-plist-key :directory keys))))))
(process-info-r ()))) (process-info-r ()))
(flet ((prop (key value) (push key process-info-r) (push value process-info-r))) (flet ((prop (key value) (push key process-info-r) (push value process-info-r)))
#+allegro #+allegro
(cond (cond
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment