diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-02-26 12:56:07 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-02-26 12:57:21 -0700 |
commit | fe59d66670d820d1b6c2a74f3ed80d16133f4098 (patch) | |
tree | 09c2136976c38e57eeab524e175ecbc7bae30427 /src/connection.lisp | |
parent | 7701dbe4326a4983ada8ab81cf6d71d23f551ec7 (diff) | |
download | consfigurator-fe59d66670d820d1b6c2a74f3ed80d16133f4098.tar.gz |
make it easy just to get the exit code out of RUN and MRUN
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection.lisp')
-rw-r--r-- | src/connection.lisp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/connection.lisp b/src/connection.lisp index d09ed16..b9809e7 100644 --- a/src/connection.lisp +++ b/src/connection.lisp @@ -166,10 +166,10 @@ the root Lisp's machine. For example, using rsync(1) over SSH.")) :exit-code exit)))) (defmacro %process-run-args (&body forms) - `(let (cmd input may-fail env) + `(let (cmd input may-fail for-exit env) (loop for arg = (pop args) do (case arg - (:for-exit (setq may-fail t)) + (:for-exit (setq may-fail t for-exit t)) (:may-fail (setq may-fail t)) (:input (setq input (pop args))) (:env (setq env (pop args))) @@ -209,7 +209,8 @@ Keyword arguments accepted: variable names and values, use env(1) to set these variables when running the command. -Returns command's stdout, stderr and exit code." +Returns command's stdout, stderr and exit code, unless :FOR-EXIT, in which +case return only the exit code." (%process-run-args (with-remote-temporary-file (stdout) (setq cmd (format nil "( ~A ) >~A" cmd stdout)) @@ -217,7 +218,7 @@ Returns command's stdout, stderr and exit code." (connection-run *connection* cmd input) (let ((out (readfile stdout))) (if (or may-fail (= exit 0)) - (values out err exit) + (if for-exit exit (values out err exit)) (error 'run-failed :cmd cmd :stdout out :stderr err :exit-code exit))))))) @@ -237,7 +238,7 @@ start with RUN." (multiple-value-bind (out exit) (connection-run *connection* cmd input) (if (or may-fail (= exit 0)) - (values out exit) + (if for-exit exit (values out exit)) (error 'run-failed :cmd cmd :stdout out @@ -248,7 +249,7 @@ start with RUN." (lines (apply #'run args))) (defun test (&rest args) - (= 0 (nth-value 2 (apply #'run :for-exit "test" args)))) + (= 0 (apply #'run :for-exit "test" args))) (defun readfile (&rest args) (apply #'connection-readfile *connection* args)) |