From b85d6289553158e86249448e210243ed7ba5741d Mon Sep 17 00:00:00 2001 From: Marius Gerbershagen Date: Fri, 7 Feb 2020 21:35:44 +0100 Subject: [PATCH] run-program: fix handling of nil argument to :if-output-exists, :if-input-does-not-exist According to the documentation, we were supposed to return nil, but instead we signaled a bogus error like :INPUT argument to RUN-PROGRAM does not have a file handle: # --- src/lsp/process.lsp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/lsp/process.lsp b/src/lsp/process.lsp index a66706b2f..2b80b163a 100644 --- a/src/lsp/process.lsp +++ b/src/lsp/process.lsp @@ -158,7 +158,20 @@ (open #-windows "/dev/null" #+windows "nul" :direction direction - :if-exists :overwrite))) + :if-exists :overwrite)) + (verify-stream (stream stream-type) + (case stream + ((nil) + (when (null (case stream-type + (:input if-input-does-not-exist) + (:output if-output-exists) + (:error if-error-exists))) + (return-from run-program nil)) + (null-stream (if (eql stream-type :input) + :output + :input))) + (:virtual-stream :stream) + (otherwise stream)))) (let ((progname (si:copy-to-simple-base-string command)) (args (prepare-args (cons command argv))) (process (make-external-process)) @@ -177,18 +190,9 @@ (multiple-value-setq (pid parent-write parent-read parent-error) (si:spawn-subprocess progname args environ - (case process-input - ((nil) (null-stream :output)) - (:virtual-stream :stream) - (otherwise process-input)) - (case process-output - ((nil) (null-stream :input)) - (:virtual-stream :stream) - (otherwise process-output)) - (case process-error - ((nil) (null-stream :input)) - (:virtual-stream :stream) - (otherwise process-error)))) + (verify-stream process-input :input) + (verify-stream process-output :output) + (verify-stream process-error :error))) (let ((stream-write (when (plusp parent-write)