diff options
author | Michael Orlitzky <mjo@gentoo.org> | 2016-01-22 13:54:59 -0500 |
---|---|---|
committer | Michael Orlitzky <mjo@gentoo.org> | 2016-01-22 13:54:59 -0500 |
commit | 56261aef608438c77df89aa5782cd9285d5f9d2f (patch) | |
tree | 9ab042907de422510b2fa08d2a5a303d2f0f033a | |
parent | Remove the word "automatically" from the cleanup description. (diff) | |
download | eselect-php-56261aef608438c77df89aa5782cd9285d5f9d2f.tar.gz eselect-php-56261aef608438c77df89aa5782cd9285d5f9d2f.tar.bz2 eselect-php-56261aef608438c77df89aa5782cd9285d5f9d2f.zip |
Document and fix the update functionality.
The update_sapi() function was not working due to a call to set_$sapi
that was never caught. Some of the logic in both do_update() and
update_sapi() was clarified, and the update_sapi() function was
documented. The "update" action and "cleanup" (which uses it) now work
as expected.
-rw-r--r-- | src/php.eselect.in.in | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/src/php.eselect.in.in b/src/php.eselect.in.in index a9c6efd..4e5e4b7 100644 --- a/src/php.eselect.in.in +++ b/src/php.eselect.in.in @@ -211,13 +211,32 @@ cleanup_sapi() { done } + +# Update the given SAPI to the latest valid target. +# +# The "latest" target is really just the last available one in the +# list for this SAPI. +# +# INPUT: +# +# The name of a SAPI. +# +# OUTPUT: +# +# An error code "1" is returned if there are no valid targets for the +# given SAPI. Otherwise, we return whatever comes back from set_sapi() +# update_sapi() { local sapi="${1}" - local target=$(find_sapi_targets "${sapi}" | tail -n 1) - local current=$(get_sapi_active_target "${sapi}") - [[ -z $target ]] && return 1 - [[ $current = $target ]] && return 1 - set_$sapi $target + local latest_target=$(find_sapi_targets "${sapi}" | tail -n 1) + + # No valid targets? + [[ -z "${latest_target}" ]] && return 1 + + # Proceed even if the current target is the latest one. This can + # fix issues where, for example, the "phpize" symlink is broken + # but "php" is fine and points to the latest target. + set_sapi "${sapi}" "${latest_target}" } @@ -551,7 +570,7 @@ describe_update() { } describe_update_parameters() { - echo "<module> [ifunset]" + echo "<module> [--if-unset]" } describe_update_options() { @@ -561,13 +580,18 @@ describe_update_options() { do_update() { local sapi="${1}" + local ifunset="${2}" + + # Input sanity check. check_module "${sapi}" - [[ -z ${2} || ( -z ${3} && ( ${2} == ifunset || ${2} == '--if-unset' ) ) ]] || \ - die -q "Usage error" - if [[ (${2} == ifunset || ${2} == '--if-unset') && -n $(get_sapi_active_target "${sapi}") ]]; - then - return + # Older versions listed the flag as "ifunset" insted of "--if-unset". + if [[ "${ifunset}" == "ifunset" || "${ifunset}" == "--if-unset" ]] ; then + if [[ -n $(get_sapi_active_target "${sapi}") ]] ; then + # There's already an active target for this SAPI, and the + # user asked us to leave it alone. So we leave it alone. + return + fi fi update_sapi "${sapi}" || echo "Nothing to update" |