Skip to content

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

@epipping

Description

@epipping

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions