Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
which -- check if a command is available on the working environment
(defun which (command)
(handler-case
(let* ((result (with-output-to-string (s)
(uiop:run-program `("which" ,command)
:output s
:error-output *error-output*)))
(newline-pos
(position-if (lambda (char)
(or (char= char #\Newline)
(char= char #\Return)))
result)))
(if newline-pos
(subseq result 0 newline-pos)
result))
(uiop:subprocess-error ()
nil)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.