Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uiop:run-program :directory and :ignore-error-status #4

Open
epipping opened this issue Nov 6, 2016 · 1 comment
Open

uiop:run-program :directory and :ignore-error-status #4

epipping opened this issue Nov 6, 2016 · 1 comment

Comments

@epipping
Copy link

epipping commented Nov 6, 2016

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.
@html
Copy link
Collaborator

html commented Nov 11, 2016

thanks, it needs time for testing so I don't guarantee that I'll fix that soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants