Next: program executing, Previous: program testing, Up: program [Contents][Index]
The simpler way to test the availability of a program is to look for it just before it is used.
After a call to mbfl_program_split_path()
: this array is filled with the components of the
PATH
variable.
If the number of pairs in the global array mbfl_split_PATH
is zero: split the current value
of PATH into its components by splitting the string using the colon character :
as
separator; store the result in the global array mbfl_split_PATH
; finally return true.
If the number of pairs in the global array mbfl_split_PATH
is not zero: do nothing and return
false.
We can print the contents of the array with:
local -i i for ((i=0; i < ${#mbfl_split_PATH[@]}; ++i)) do echo "${mbfl_split_PATH[$i]}" done
To force a resplit, just reset the array to the empty state with:
mbfl_split_PATH=()
Search for a program in the standard search path. Print the full pathname of the program found, or an empty string if nothing is found. If an executable file is found: return true; otherwise return false.
The search path is the one in the environment variable ENV as found by
mbfl_program_split_path()
. The contained directories are searched in the order in which they
appear in PATH
. There are rules:
mbfl_file_is_absolute()
): only that
absolute pathname is verified as executable file. PATH is ignored.
The _var
function variant will store the result in the variable _RV rather than print
it.
Next: program executing, Previous: program testing, Up: program [Contents][Index]