mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-23 04:52:42 -08:00
run-program: don't handle nil stream in unixsys
Valid values are either :stream or stream object, prepare null earlier.
This commit is contained in:
parent
7a76c928f3
commit
43c19eafe2
2 changed files with 30 additions and 42 deletions
|
|
@ -318,12 +318,6 @@ create_descriptor(cl_object stream, cl_object direction,
|
|||
if (*parent < 0)
|
||||
printf("open_osfhandle failed\n");
|
||||
}
|
||||
else if (Null(stream)) {
|
||||
if (direction == @':input')
|
||||
*child = open("nul", O_RDONLY);
|
||||
else
|
||||
*child = open("nul", O_WRONLY);
|
||||
}
|
||||
else if (!Null(cl_streamp(stream))) {
|
||||
HANDLE stream_handle = ecl_stream_to_HANDLE
|
||||
(stream, direction != @':input');
|
||||
|
|
@ -357,12 +351,6 @@ create_descriptor(cl_object stream, cl_object direction,
|
|||
*child = fd[1];
|
||||
}
|
||||
}
|
||||
else if (Null(stream)) {
|
||||
if (direction == @':input')
|
||||
*child = open("/dev/null", O_RDONLY);
|
||||
else
|
||||
*child = open("/dev/null", O_WRONLY);
|
||||
}
|
||||
else if (!Null(cl_streamp(stream))) {
|
||||
*child = ecl_stream_to_handle
|
||||
(stream, direction != @':input');
|
||||
|
|
|
|||
|
|
@ -143,36 +143,36 @@
|
|||
(unless (ext:get-signal-handler ext:+sigchld+)
|
||||
(ext:set-signal-handler ext:+sigchld+ #'sigchld-handler))
|
||||
|
||||
(flet ((process-stream (which default &rest args)
|
||||
(cond ((eql which t) default)
|
||||
((or (stringp which) (pathnamep which))
|
||||
(apply #'open which :external-format external-format args))
|
||||
;; this three cases are handled in create_descriptor (for now)
|
||||
((eql which nil) which)
|
||||
((eql which :stream) which)
|
||||
((streamp which) which)
|
||||
;; signal error as early as possible
|
||||
(T (error "Invalid ~S argument to EXT:RUN-PROGRAM" which))))
|
||||
|
||||
(prepare-args (args)
|
||||
#-windows
|
||||
(mapcar #'si:copy-to-simple-base-string args)
|
||||
#+windows
|
||||
(si:copy-to-simple-base-string
|
||||
(with-output-to-string (str)
|
||||
(loop for (arg . rest) on args
|
||||
do (if (and escape-arguments
|
||||
(find-if (lambda (c)
|
||||
(find c '(#\Space #\Tab #\")))
|
||||
arg))
|
||||
(escape-arg arg str)
|
||||
(princ arg str))
|
||||
(when rest
|
||||
(write-char #\Space str))))))
|
||||
(null-stream (direction)
|
||||
(open #-windows "/dev/null"
|
||||
#+windows "nul"
|
||||
:direction direction)))
|
||||
(labels ((process-stream (which default &rest args)
|
||||
(cond ((eql which t)
|
||||
default)
|
||||
((or (stringp which) (pathnamep which))
|
||||
(apply #'open which :external-format external-format args))
|
||||
((eql which nil)
|
||||
(null-stream (getf args :direction)))
|
||||
((or (eql which :stream) (streamp which))
|
||||
which)
|
||||
;; signal error as early as possible
|
||||
(T (error "Invalid ~S argument to EXT:RUN-PROGRAM" which))))
|
||||
(prepare-args (args)
|
||||
#-windows
|
||||
(mapcar #'si:copy-to-simple-base-string args)
|
||||
#+windows
|
||||
(si:copy-to-simple-base-string
|
||||
(with-output-to-string (str)
|
||||
(loop for (arg . rest) on args
|
||||
do (if (and escape-arguments
|
||||
(find-if (lambda (c)
|
||||
(find c '(#\Space #\Tab #\")))
|
||||
arg))
|
||||
(escape-arg arg str)
|
||||
(princ arg str))
|
||||
(when rest
|
||||
(write-char #\Space str))))))
|
||||
(null-stream (direction)
|
||||
(open #-windows "/dev/null"
|
||||
#+windows "nul"
|
||||
:direction direction)))
|
||||
|
||||
(setf input (process-stream input *standard-input*
|
||||
:direction :input
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue