From: "Michael Orlitzky" <mjo@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/eselect-php:master commit in: src/
Date: Sun, 20 Dec 2015 00:17:38 +0000 (UTC) [thread overview]
Message-ID: <1450567780.b363dda0a3d3bdab2874b3f12c64c9fc8beeef4c.mjo@gentoo> (raw)
commit: b363dda0a3d3bdab2874b3f12c64c9fc8beeef4c
Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 19 23:29:40 2015 +0000
Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Sat Dec 19 23:29:40 2015 +0000
URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=b363dda0
Factor our the active SAPI target getter functions.
We had five functions doing essentially the same thing:
1. get_active_cli()
2. get_active_cgi()
3. get_active_fpm()
4. get_active_phpdbg()
5. get_active_apache2()
Now that we have the sapi_active_link_path() function taking a SAPI
name as an argument, these have been refactored. One new function
get_sapi_active_target() takes a SAPI name as an argument and returns
the name of the active target (using sapi_active_link_path).
src/php.eselect.in | 62 +++++++++++++++---------------------------------------
1 file changed, 17 insertions(+), 45 deletions(-)
diff --git a/src/php.eselect.in b/src/php.eselect.in
index 6c1f803..fff7784 100644
--- a/src/php.eselect.in
+++ b/src/php.eselect.in
@@ -195,33 +195,6 @@ find_targets_phpdbg() {
done | @SORT@ | @UNIQ@
}
-get_active_cli() {
- # See get_active_apache2() for an explanation of the sed call.
- local target=$(canonicalise "$(sapi_active_link_path cli)")
- local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php:\1:p"
- [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
-}
-
-get_active_cgi() {
- # See get_active_apache2() for an explanation of the sed call.
- local target=$(canonicalise "$(sapi_active_link_path cgi)")
- local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-cgi:\1:p"
- [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
-}
-
-get_active_fpm() {
- # See get_active_apache2() for an explanation of the sed call.
- local target=$(canonicalise "$(sapi_active_link_path fpm)")
- local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/php-fpm:\1:p"
- [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
-}
-
-get_active_phpdbg() {
- # See get_active_apache2() for an explanation of the sed call.
- local target=$(canonicalise "$(sapi_active_link_path dbg)")
- local ver="s:.*/usr/.*/\(php[0-9]\.[0-9][0-9]*\)/bin/phpdbg:\1:p"
- [[ -a "${target}" ]] && echo "${target}" | @SED@ -ne "${ver}"
-}
# Find the active (selected) version of the apache2 module. Used to
# decorate the output of the `eselect php list apache2` command.
@@ -235,21 +208,20 @@ get_active_phpdbg() {
# The "display name" of the active apache2 module. For example,
# "php5.6" or "php7.0".
#
-get_active_apache2() {
- local active_symlink target ver
-
- # The symlink to our active module.
- active_symlink="$(sapi_active_link_path apache2)"
-
- # This sed expression finds the "display name" of the PHP version
- # corresponding to a copy of libphp. For example, it parses the
- # string "php5.6" out of "/usr/lib64/php5.6/apache2/libphp5.so".
- ver="s:.*/usr/.*/\(php[0-9]\.[0-9]\)/apache2/libphp[57].so:\1:p"
+get_sapi_active_target() {
+ local sapi="${1}"
+ local active_symlink=$(sapi_active_link_path "${sapi}")
if [[ -L "${active_symlink}" ]] ; then
- target=$(canonicalise "${active_symlink}")
- if [[ -a "${target}" ]] ; then
- echo "${target}" | @SED@ -ne "${ver}"
+ local active_file=$(canonicalise "${active_symlink}")
+ if [[ -a "${active_file}" ]] ; then
+ # This sed command (regular expression) finds a target name
+ # contained in a filesystem path. For example, it parses
+ # "php5.6" from "/usr/lib64/php5.6/apache2/libphp5.so".
+ # The curly braces are an attempt to avoid '+' which is
+ # a GNU extension.
+ local sed_cmd='s:.*/\(php[0-9]\.[0-9]\{1,\}\)/.*:\1:p'
+ echo "${active_file}" | @SED@ -ne "${sed_cmd}"
fi
fi
}
@@ -305,7 +277,7 @@ list_apache2() {
local targets
local a
targets=( $(find_targets_apache2) )
- a=$(get_active_apache2)
+ a=$(get_sapi_active_target apache2)
for (( i = 0; i < ${#targets[@]}; i++ )) ; do
if [[ $a == ${targets[i]} ]] ; then
targets[i]=$(highlight_marker "${targets[i]}")
@@ -318,7 +290,7 @@ list_cli() {
local targets
local a
targets=( $(find_targets_cli) )
- a=$(get_active_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]}")
@@ -331,7 +303,7 @@ list_cgi() {
local targets
local a
targets=( $(find_targets_cgi) )
- a=$(get_active_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]}")
@@ -344,7 +316,7 @@ list_fpm() {
local targets
local a
targets=( $(find_targets_fpm) )
- a=$(get_active_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]}")
@@ -357,7 +329,7 @@ list_phpdbg() {
local targets
local a
targets=( $(find_targets_phpdbg) )
- a=$(get_active_phpdbg)
+ a=$(get_sapi_active_target dbg)
for (( i = 0; i < ${#targets[@]}; i++ )) ; do
if [[ $a == ${targets[i]} ]] ; then
targets[i]=$(highlight_marker "${targets[i]}")
next reply other threads:[~2015-12-20 0:17 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-20 0:17 Michael Orlitzky [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-12-08 2:24 [gentoo-commits] proj/eselect-php:master commit in: src/ Brian Evans
2020-03-01 12:59 Michael Orlitzky
2020-02-29 22:16 Michael Orlitzky
2020-02-29 22:16 Michael Orlitzky
2020-02-29 22:16 Michael Orlitzky
2020-02-29 22:16 Michael Orlitzky
2020-02-12 22:30 Michael Orlitzky
2018-04-12 2:24 Michael Orlitzky
2016-01-22 20:53 Michael Orlitzky
2016-01-22 19:42 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 19:14 Michael Orlitzky
2016-01-22 3:15 Michael Orlitzky
2016-01-22 3:15 Michael Orlitzky
2016-01-22 3:15 Michael Orlitzky
2016-01-22 3:15 Michael Orlitzky
2016-01-20 14:42 Michael Orlitzky
2016-01-09 17:20 Michael Orlitzky
2016-01-09 17:20 Michael Orlitzky
2016-01-09 2:24 Michael Orlitzky
2016-01-09 2:24 Michael Orlitzky
2016-01-09 2:24 Michael Orlitzky
2016-01-09 2:24 Michael Orlitzky
2016-01-09 2:24 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2016-01-08 21:50 Michael Orlitzky
2015-12-20 0:17 Michael Orlitzky
2015-12-20 0:17 Michael Orlitzky
2015-12-20 0:17 Michael Orlitzky
2015-12-20 0:17 Michael Orlitzky
2015-12-20 0:17 Michael Orlitzky
2015-12-20 0:17 Michael Orlitzky
2015-12-20 0:17 Michael Orlitzky
2015-12-20 0:17 Michael Orlitzky
2015-12-18 2:27 Brian Evans
2015-12-11 0:40 Michael Orlitzky
2015-12-11 0:40 Michael Orlitzky
2015-12-11 0:40 Michael Orlitzky
2015-12-11 0:40 Michael Orlitzky
2015-12-11 0:40 Michael Orlitzky
2015-12-11 0:40 Michael Orlitzky
2015-12-11 0:40 Michael Orlitzky
2015-12-11 0:40 Michael Orlitzky
2015-12-11 0:40 Michael Orlitzky
2015-12-11 0:40 Michael Orlitzky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450567780.b363dda0a3d3bdab2874b3f12c64c9fc8beeef4c.mjo@gentoo \
--to=mjo@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox