Skip to content
Snippets Groups Projects
Commit d36a06ec authored by Francois-Rene Rideau's avatar Francois-Rene Rideau
Browse files

2.0.2: further refine and document ON-ERROR behavior:

return what it returns when CALL-FUNCTION'ed with the condition,
except for NIL (continue) and T (signal error).
parent 9984a223
No related branches found
No related tags found
No related merge requests found
......@@ -96,9 +96,10 @@ RUN CMD &KEY ON-ERROR TIME SHOW HOST OUTPUT
a PROCESS-SPEC object already parsed,
or a string to be passed to a Unix shell.
ON-ERROR specifies behavior in case the command doesn't successfully exit
with exit code 0, as per FARE-UTILS's ERROR-BEHAVIOR provided with
(if a function, invoke it, if a string, issue an error with it,
otherwise return it as is).
with exit code 0. NIL means continue and return the error code;
T (default) means signal the error (same as :ON-ERROR 'SIGNAL);
any other value is called as by UIOP:CALL-FUNCTION with the condition as argument,
and if it returns, its return values are returned by RUN.
TIME is a boolean which if true causes the execution to be timed as per TIME.
SHOW is a boolean which if true causes a message to be sent
to the *TRACE-OUTPUT* before execution.
......
......@@ -2,7 +2,7 @@
(defsystem "inferior-shell"
:description "spawn local or remote processes and shell pipes"
:version "2.0.1"
:version "2.0.2"
:defsystem-depends-on (:asdf #-asdf3 "uiop")
:depends-on ((:version #+asdf3 "asdf" #-asdf3 "uiop" "3.0.3") ; input and error-output redirection
#+sbcl "sb-posix"
......
......@@ -52,19 +52,19 @@
(apply 'run-process-spec (funcall host spec) :host nil keys))))
(defun run/nil (cmd &rest keys
&key time show host
(on-error 'signal)
&key time show host (on-error t)
&allow-other-keys)
"run command CMD"
(labels ((process-time ()
(if time (time (process-command)) (process-command)))
(process-command ()
(handler-bind
((subprocess-error #'(lambda (c) (call-function on-error c))))
(apply 'run-process-spec cmd :ignore-error-status nil :host host keys))))
(when show
(format *trace-output* "; ~A~%" (print-process-spec cmd)))
(process-time)))
(when (eq on-error t) (setf on-error 'signal))
(when show
(format *trace-output* "; ~A~%" (print-process-spec cmd)))
(flet ((run-it ()
(handler-bind
((subprocess-error #'(lambda (c)
(if on-error (return-from run-it (call-function on-error c))
(continue c)))))
(apply 'run-process-spec cmd :ignore-error-status nil :host host keys))))
(if time (time (run-it)) (run-it))))
(defun run (cmd &rest keys
&key on-error time show host (output t op) (error-output t eop) &allow-other-keys)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment