summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2016-01-08 11:32:30 -0500
committerMichael Orlitzky <mjo@gentoo.org>2016-01-08 11:32:30 -0500
commite05ad5dc17a9501bf14e56652a42cf66a545e512 (patch)
treea35e306a32d50020f2200bed7ea2fe0239c26de7
parentFix call to resolv_target() in set_phpdbg(). (diff)
downloadeselect-php-e05ad5dc17a9501bf14e56652a42cf66a545e512.tar.gz
eselect-php-e05ad5dc17a9501bf14e56652a42cf66a545e512.tar.bz2
eselect-php-e05ad5dc17a9501bf14e56652a42cf66a545e512.zip
Document and clean up the resolv_target function.
-rw-r--r--src/php.eselect.in39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/php.eselect.in b/src/php.eselect.in
index d868082..72e6610 100644
--- a/src/php.eselect.in
+++ b/src/php.eselect.in
@@ -231,14 +231,41 @@ write_mod_php_conf() {
EOF
}
+
+# Resolve an index or target name for a given SAPI into the "display
+# name" of that target.
+#
+# INPUT:
+#
+# The first parameter is the name of a SAPI. The second parameter is
+# either a number (the index of a target), or a target name.
+#
+# OUTPUT:
+#
+# The "display name" of the given target for the given SAPI. For
+# example, if the first parameter is "cli" and the second parameter is
+# "1", then the output will be the display name of the first target
+# for the cli SAPI (e.g. "php5.6").
+#
+# If the index or target name is invalid (that is, does not correspond
+# to one of the valid targets for the given SAPI), then nothing is
+# output.
+#
resolv_target() {
- local targets=( $(find_sapi_targets $1) )
- if is_number $2; then
- if [[ $2 -le ${#targets[@]} && $2 -gt 0 ]] ; then
- echo "${targets[ $(( $2 - 1 )) ]}"
+ local sapi="${1}"
+ local target="${2}"
+
+ # $targets is an array of things like "php5.6" and "php7.0"
+ local targets=( $(find_sapi_targets "${sapi}") )
+
+ if is_number "${target}" ; then
+ if [[ $target -le ${#targets[@]} && $target -gt 0 ]] ; then
+ # $target looks like an index into the $targets array.
+ echo "${targets[ $(( $target - 1 )) ]}"
fi
- elif has $2 ${targets[@]}; then
- echo $2
+ elif has "${target}" ${targets[@]} ; then
+ # $target is the *name* of a valid target for this SAPI.
+ echo "${target}"
fi
}