diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-08 13:15:23 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-08 13:15:23 -0700 |
commit | d3185fda78ecf915ce7ea3ae8d60441f3c89af1b (patch) | |
tree | 4a9e0b345402d50655b296809e5dd48fccf4f8ec /src/connection.lisp | |
parent | 56d5dfa83fd100c4f6c143785411a4fc0c247753 (diff) | |
download | consfigurator-d3185fda78ecf915ce7ea3ae8d60441f3c89af1b.tar.gz |
RUN/MRUN: export each environment variable individually
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection.lisp')
-rw-r--r-- | src/connection.lisp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/connection.lisp b/src/connection.lisp index 3f5a4f6..605667d 100644 --- a/src/connection.lisp +++ b/src/connection.lisp @@ -291,13 +291,20 @@ the working directory of the Lisp process using UIOP:WITH-CURRENT-DIRECTORY." finally (nreversef cmd)) (setq cmd (if (cdr cmd) (escape-sh-command cmd) (car cmd))) (loop while env - collect (format nil "~A=~A" (symbol-name (pop env)) (pop env)) + collect (format nil "~A=~A" + (symbol-name (pop env)) (escape-sh-token (pop env))) into accum finally (when accum - (setq cmd (format nil "env ~{~A~^ ~} ~A" - (mapcar #'escape-sh-token accum) - cmd)))) + ;; We take this approach of exporting individual variables + ;; rather than just prepending `FOO=bar BAR=baz` so that if CMD + ;; contains $FOO it will get expanded. We used to use env(1) + ;; but that means CMD cannot contain shell builtins which do + ;; not have an equivalent on PATH, such as 'cd'. This approach + ;; does mean that implementations of CONNECTION-RUN will need + ;; to start a fresh 'sh -c' for each command run, but that's + ;; desirable to ensure any variables set by CMD are reset. + (setq cmd (format nil "~{export ~A;~^ ~} ~A" accum cmd)))) (setq cmd (format nil "cd ~A; ~A" (escape-sh-token (unix-namestring (pwd))) cmd)) ,@forms)) |