diff --git a/src/slash-bedrock/libexec/brl-which b/src/slash-bedrock/libexec/brl-which index 5e2cf2b38..83f2bf9ce 100755 --- a/src/slash-bedrock/libexec/brl-which +++ b/src/slash-bedrock/libexec/brl-which @@ -21,6 +21,7 @@ Options: ${color_sub} ${color_norm}guess type from identifier ${color_cmd}-c${color_norm}, ${color_cmd}--current ${color_norm}which ${color_term}stratum${color_norm} provides current process ${color_cmd}-b${color_norm}, ${color_cmd}--bin ${color_norm}which ${color_term}stratum${color_norm} provides a given binary in \$PATH + ${color_cmd}-a${color_norm}, ${color_cmd}--all ${color_norm}which ${color_term}strata${color_norm} provide a given binary in \$PATH ${color_cmd}-f${color_norm}, ${color_cmd}--file ${color_norm}which ${color_term}stratum${color_norm} provides a given file path ${color_cmd}-p${color_norm}, ${color_cmd}--pid ${color_norm}which ${color_term}stratum${color_norm} provides a given process ID ${color_cmd}-x${color_norm}, ${color_cmd}--xwindow ${color_norm}which ${color_term}stratum${color_norm} provides a given X11 window (requires xprop) @@ -67,6 +68,32 @@ which_bin() { done } +which_bin_all() ( + IFS=':' + while [ -n "${1:-}" ]; do + for strat_dir in /bedrock/strata/*; do + if [ ! -d "${strat_dir}" ] || [ -h "${strat_dir}" ]; then + continue + fi + + for dir in ${PATH}; do + case "${dir}" in + ''|'.'|/bedrock/*) + continue + ;; + esac + + if [ -e "${strat_dir}/${dir}/${1}" ]; then + which_file "${strat_dir}/${dir}/${1}" + break + fi + done + done + + shift + done +) + which_file() { while [ -n "${1:-}" ]; do if ! [ -e "${1}" ]; then @@ -146,6 +173,10 @@ case "${1:-}" in shift which_bin "${@}" ;; +"-a" | "--all") + shift + which_bin_all "${@}" + ;; "-f" | "--file") shift which_file "${@}"