diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.lisp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib.lisp b/src/lib.lisp index ec65d13..d1b8db6 100644 --- a/src/lib.lisp +++ b/src/lib.lisp @@ -63,13 +63,20 @@ (when (uiop:file-exists-p (last-search-file)) (nth n (uiop:read-file-form (last-search-file))))) -(defun command-on-system (cmd) - ) +(defun executable-on-system-p (name) + "A hack that heuristically determins whether or not an executable +with the provided name is on the system. It is not perfect. It +consults the environment PATH, and looks for the command in any of +the directories that appear in the value of that variable." + #+(unix) + (loop for path in (str:split ":" (uiop:getenv "PATH")) + for directory = (cons :absolute + (cdr (str:split "/" path))) + thereis (uiop:file-exists-p + (make-pathname :name name :directory directory)))) (defun tags-from-oneliner (oneliner) - (loop for cmd? in (ppcre:split " +" oneliner) - when (command-on-system cmd?) - collect cmd?)) + (remove-if-not #'executable-on-system-p (ppcre:split " +" oneliner))) (defun prompt (prompt &key (out-stream *standard-output*) (in-stream *standard-input*)) (princ prompt out-stream) |