diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-08-29 14:43:13 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-08-31 15:55:26 -0700 |
commit | 23b3dc9d0323073792d5eb87760616be1debf728 (patch) | |
tree | e785ed990daa7b528db3bc7e034c492b5a93828d /src/connection.lisp | |
parent | 7682e6056c4f40c578e223fc49ea4f7d6c607c37 (diff) | |
download | consfigurator-23b3dc9d0323073792d5eb87760616be1debf728.tar.gz |
RUN: combine creating the temporary file with running the command
Should improve performance, especially when connection latency is high.
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection.lisp')
-rw-r--r-- | src/connection.lisp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/connection.lisp b/src/connection.lisp index 94ad848..efd86ad 100644 --- a/src/connection.lisp +++ b/src/connection.lisp @@ -449,20 +449,25 @@ Keyword arguments accepted: Returns command's stdout, stderr and exit code, unless :FOR-EXIT, in which case return only the exit code." (%process-run-args - (let* ((stdout (mktemp)) - (wrapped (format nil "( ~A ) >~A" cmd stdout))) + (let (stdout + (wrapped + (format + nil "tmpf=$(~A) && printf \"%s\\n\" \"$tmpf\" && (~A) >\"$tmpf\"" + (load-time-value (mkstemp-cmd) t) cmd))) (handler-bind ((serious-condition (lambda (c) (declare (ignore c)) - (connection-run - *connection* - (format nil "rm -f ~A" (escape-sh-token stdout)) - nil)))) + (when stdout + (connection-run + *connection* + (format nil "rm -f ~A" (escape-sh-token stdout)) + nil))))) (informat 4 "~&RUN ~A" (if (> *consfigurator-debug-level* 4) wrapped cmd)) (multiple-value-bind (err exit) (connection-run *connection* wrapped input) + (setq err (lines err) stdout (car err) err (unlines (cdr err))) (let ((out (connection-readfile-and-remove *connection* stdout))) (when inform (informat 1 "~& % ~A~%~{ ~A~%~}" |