summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/php.eselect.in.in')
-rw-r--r--src/php.eselect.in.in46
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"