How to determine if command is available #438
-
Does clink provide a convenient Lua function to determine if a command is available, i.e. is on PATH? Something like e.g. |
Beta Was this translation helpful? Give feedback.
Answered by
chrisant996
Feb 28, 2023
Replies: 1 comment 11 replies
-
No, but it's easy to do it yourself. Loop over |
Beta Was this translation helpful? Give feedback.
11 replies
Answer selected by
sebthom
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No, but it's easy to do it yourself.
Loop over
ipairs(string.explode(os.getenv("path"), ";"))
and useos.isfile(path.join(dir_from_path, name_to_find)
. If the inputname_to_find
doesn't include an extension, then you'll want to also loop over either a list of predefined extensions oripairs(string.explode(os.getenv("pathext"), ";"))
and tryos.isfile(name_to_find .. each_ext_from_list)
.