skx / marionette

Something like puppet, for the localhost only.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow testing for an executable on the users's PATH

skx opened this issue · comments

Looking at #72 I see the following code:

let download="/usr/bin/curl" if exists(/usr/bin/curl)
let download="/usr/bin/wget" if exists(/usr/bin/wget)

This is obviously not portable (to windows), but the intent is merely to allow:

shell{ command => "${download} ..

So the key result should be that we can find a binary named curl or wget on the path. We don't need to consider the specific path. So we should instead write:

let download="curl"   if on_path(curl)
let download="wget" if on_path(wget)

i.e. A new conditional that returns "true" if the named binary is somewhere on the users' path. It will take care of windows with .exe/.com/.bat suffixes too.