Commit 7db45430 authored by Daniel Kochmański's avatar Daniel Kochmański

environ: accept empty list as nil environment

To inherit current process environemnt, user has to pass `:default' as
environ (what is a default value).
parent e7876023
......@@ -357,7 +357,6 @@ si_run_program_inner(cl_object command, cl_object argv, cl_object environ) {
cl_object pid, stream_read, exit_status;
command = si_copy_to_simple_base_string(command);
environ = cl_mapcar(2, @'si::copy-to-simple-base-string', environ);
#if defined(ECL_MS_WINDOWS_HOST)
argv = cl_format(4, ECL_NIL,
......@@ -397,7 +396,12 @@ si_spawn_subprocess(cl_object command, cl_object argv, cl_object environ,
int child_pid;
cl_object pid;
/* command = ecl_null_terminated_base_string(command); */
/* environ is either a list or `:default'. */
if (ECL_LISTP(environ)) {
environ = cl_mapcar(2, @'si::copy-to-simple-base-string', environ);
} else if (!ecl_eql(environ, @':default')) {
FEerror("Malformed :ENVIRON argument to EXT:RUN-PROGRAM.", 0);
}
#if defined(ECL_MS_WINDOWS_HOST)
{
......@@ -409,7 +413,7 @@ si_spawn_subprocess(cl_object command, cl_object argv, cl_object environ,
cl_object env_buffer;
char *env = NULL;
if (!Null(environ)) {
if (ECL_LISTP(environ)) {
env_buffer = from_list_to_execve_argument(environ, NULL);
env = env_buffer->base_string.self;
}
......@@ -505,7 +509,7 @@ si_spawn_subprocess(cl_object command, cl_object argv, cl_object environ,
argv_ptr[j] = arg->base_string.self;
}
}
if (!Null(environ)) {
if (ECL_LISTP(environ)) {
char **pstrings;
from_list_to_execve_argument(environ, &pstrings);
execve((char*)command->base_string.self, (char **)argv_ptr, pstrings);
......
......@@ -17,7 +17,7 @@
(defun run-and-collect (command args &optional file)
(handler-case
(let ((lines (collect-lines (si:run-program-inner command args nil))))
(let ((lines (collect-lines (si:run-program-inner command args :default))))
(cond ((null file)
lines)
((probe-file file)
......
......@@ -51,7 +51,7 @@
(program (car program)))
(with-current-directory
#-windows (multiple-value-bind (output-stream return-code)
(si:run-program-inner program args nil)
(si:run-program-inner program args :default)
(setf output (collect-lines output-stream)
result return-code))
#+windows (setf result (si:system (format nil "~A~{ ~A~}" program args)))))
......
......@@ -100,7 +100,7 @@
(output :stream)
(error :output)
(wait t)
(environ nil)
(environ :default)
(if-input-does-not-exist nil)
(if-output-exists :error)
(if-error-exists :error)
......@@ -146,7 +146,6 @@
(let ((progname (si:copy-to-simple-base-string command))
(args (prepare-args (cons command argv)))
(environ (mapcar #'si:copy-to-simple-base-string environ))
(process (make-external-process))
(process-input (process-stream input *standard-input*
:direction :input
......
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