Hi,
I was looking at how different projects on quicklisp use uiop:run-program and I came across this snippet in weblocks-utils:
(with-directory
*assets-package-dir*
(let ((ret (car (last (multiple-value-list (uiop:run-program '("bash" "get.sh") :output nil))))))
(unless (zerop ret)
(error "Error occured during installing assets package \"~A\" please execute it manually~%cd ~A~%bash get.sh" url-or-file *assets-package-dir*))))
I wanted to point out that:
:output nil is the default
- the return-code is always the third value returned (and uiop currently makes no guarantee that there will never be a fourth value) so instead of
(car (last (multiple-value-list (uiop:run-program)))) you might want to use (nth-value 2 (uiop:run-program))
run-program accepts a :directory argument so that you don't need to use with-directory
- unless you pass
:ignore-error-status t, run-program will treat a non-zero return code as an error on its own already so that you do not need to call (error) manually yourself (or if you do, you might want to pass :ignore-error-status t to get just one error rather than two.
Hi,
I was looking at how different projects on quicklisp use
uiop:run-programand I came across this snippet in weblocks-utils:(with-directory *assets-package-dir* (let ((ret (car (last (multiple-value-list (uiop:run-program '("bash" "get.sh") :output nil)))))) (unless (zerop ret) (error "Error occured during installing assets package \"~A\" please execute it manually~%cd ~A~%bash get.sh" url-or-file *assets-package-dir*))))I wanted to point out that:
:output nilis the default(car (last (multiple-value-list (uiop:run-program))))you might want to use(nth-value 2 (uiop:run-program))run-programaccepts a:directoryargument so that you don't need to usewith-directory:ignore-error-status t,run-programwill treat a non-zero return code as an error on its own already so that you do not need to call(error)manually yourself (or if you do, you might want to pass:ignore-error-status tto get just one error rather than two.