diff options
author | Colin Okay <okay@toyful.space> | 2022-02-20 08:54:51 -0600 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-02-20 08:54:51 -0600 |
commit | b66a719737205635ec57203b46ae9759d99baed6 (patch) | |
tree | ca0ea8dda08db74ca575c88c96b1979839d8547f /src | |
parent | 2c49e526105cd04d4b76bc204929ee8b8a9f6c6b (diff) |
added tags-from-oneliner function
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) |