The main purpose is to determine whether a command exists in PATH
.
Some of the following methods also support determine the existence
of function
s. The comparison focuses on speed, not support coverage.
❯ export TIMEFMT=$'%U user %S system %P cpu %*E total'
❯ time (for i ({1..100}) if (($+commands[tree])); then echo 1 &>/dev/null; fi)