diff options
-rw-r--r-- | src/php.eselect.in | 70 |
1 files changed, 24 insertions, 46 deletions
diff --git a/src/php.eselect.in b/src/php.eselect.in index a377116..9a1d628 100644 --- a/src/php.eselect.in +++ b/src/php.eselect.in @@ -249,69 +249,47 @@ check_module() { ## Actual actions -list_apache2() { - local targets - local a - targets=( $(find_sapi_targets apache2) ) - a=$(get_sapi_active_target apache2) +# Perform the "list" action for the given SAPI. +# +# INPUT: +# +# The SAPI name. +# +# OUTPUT: +# +# A numbered and decorated list of targets for the given SAPI. +# +list_sapi() { + local sapi="${1}" + local targets=( $(find_sapi_targets "${sapi}") ) + local active=$(get_sapi_active_target "${sapi}") + for (( i = 0; i < ${#targets[@]}; i++ )) ; do - if [[ $a == ${targets[i]} ]] ; then + if [[ $active == ${targets[i]} ]] ; then targets[i]=$(highlight_marker "${targets[i]}") fi done write_numbered_list -m "(none found)" "${targets[@]}" } +list_apache2() { + list_sapi apache2 +} + list_cli() { - local targets - local a - targets=( $(find_sapi_targets cli) ) - a=$(get_sapi_active_target cli) - for (( i = 0; i < ${#targets[@]}; i++ )) ; do - if [[ $a == ${targets[i]} ]] ; then - targets[i]=$(highlight_marker "${targets[i]}") - fi - done - write_numbered_list -m "(none found)" "${targets[@]}" + list_sapi cli } list_cgi() { - local targets - local a - targets=( $(find_sapi_targets cgi) ) - a=$(get_sapi_active_target cgi) - for (( i = 0; i < ${#targets[@]}; i++ )) ; do - if [[ $a == ${targets[i]} ]] ; then - targets[i]=$(highlight_marker "${targets[i]}") - fi - done - write_numbered_list -m "(none found)" "${targets[@]}" + list_sapi cgi } list_fpm() { - local targets - local a - targets=( $(find_sapi_targets fpm) ) - a=$(get_sapi_active_target fpm) - for (( i = 0; i < ${#targets[@]}; i++ )) ; do - if [[ $a == ${targets[i]} ]] ; then - targets[i]=$(highlight_marker "${targets[i]}") - fi - done - write_numbered_list -m "(none found)" "${targets[@]}" + list_sapi fpm } list_phpdbg() { - local targets - local a - targets=( $(find_sapi_targets dbg) ) - a=$(get_sapi_active_target dbg) - for (( i = 0; i < ${#targets[@]}; i++ )) ; do - if [[ $a == ${targets[i]} ]] ; then - targets[i]=$(highlight_marker "${targets[i]}") - fi - done - write_numbered_list -m "(none found)" "${targets[@]}" + list_sapi dbg } set_apache2() { |