In order to check if the file is executable by the owner, you can do this:
for dir in split(ENV["PATH"], @static is_windows() ? ";" : ":")
if isdir(dir) && exec in readdir(dir)
file = joinpath(dir, exec)
if isfile(file) && (uperm(file) & 0x01 > 0)
I also added the test that the file is a regular file, also directory are executable.
But maybe you want to determine if it’s executable by the current user? Note that
-x which doesn’t check if current user can run the program. For example, with both bash and dash, on my system:
$ [ -x /sbin/ifconfig ] && echo "Yes, we can" || echo "No, we can't"
Yes, we can
even if my user can’t run that program.