aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rwxr-xr-xbin/eselect.in15
-rw-r--r--libs/core.bash.in15
3 files changed, 19 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index edb8af3..7436537 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-21 Ulrich Müller <ulm@gentoo.org>
+
+ * bin/eselect.in (es_find_module): Move function to core library.
+ * libs/core.bash.in (find_module): Rename and simplify.
+
2013-09-18 Ulrich Müller <ulm@gentoo.org>
* misc/eselect-mode.el (eselect-mode-keywords-package-manager):
diff --git a/bin/eselect.in b/bin/eselect.in
index ea632ce..e50fa8e 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -70,21 +70,6 @@ inherit manip output path-manipulation tests
# it, don't ask...
trap 'echo "exiting" >&2; exit 250' 15
-# es_find_module foo
-# Find and echo the filename of the foo module. If there's no foo module,
-# die.
-es_find_module() {
- local modname="$1" modpath="" modfile=""
- [[ -z ${modname} ]] && die "Usage: ${FUNCNAME} <module>"
- for modpath in "${ESELECT_MODULES_PATH[@]}"; do
- [[ -f ${modpath}/${modname}.eselect ]] && break
- done
-
- modfile="${modpath}/${modname}.eselect"
- [[ -r ${modfile} ]] || die -q "Can't load module ${modname}"
- echo ${modfile}
-}
-
# es_do_usage
# Display eselect usage
es_do_usage() {
diff --git a/libs/core.bash.in b/libs/core.bash.in
index 2a682ce..64dbede 100644
--- a/libs/core.bash.in
+++ b/libs/core.bash.in
@@ -65,6 +65,19 @@ die() {
exit 249
}
+# find_module module PRIVATE
+# Find module and echo its filename. Die if module doesn't exist.
+find_module() {
+ local modname=$1 modpath
+ for modpath in "${ESELECT_MODULES_PATH[@]}"; do
+ if [[ -f ${modpath}/${modname}.eselect ]]; then
+ echo "${modpath}/${modname}.eselect"
+ return
+ fi
+ done
+ die -q "Can't load module ${modname}"
+}
+
# do_action action args...
# Load and do 'action' with the specified args
do_action() {
@@ -78,7 +91,7 @@ do_action() {
[[ ${ESELECT_BINARY_NAME##*/} != "${ESELECT_PROGRAM_NAME}" ]] \
&& ESELECT_COMMAND="${ESELECT_BINARY_NAME##*/}"
- modfile=$( es_find_module "${action}" )
+ modfile=$(find_module "${action}")
(
source "$ESELECT_DEFAULT_ACTIONS" 2>/dev/null \
|| die "Couldn't source ${ESELECT_DEFAULT_ACTIONS}"