aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2013-10-21 22:35:23 +0200
committerUlrich Müller <ulm@gentoo.org>2013-10-21 22:35:23 +0200
commita1de32ca76ee2dc24961f52b38c9c0f3cd51eb03 (patch)
tree4a6495b945e716292faea1666de720be9a9a7be6 /libs
parentAdd env_update to eselect-mode keywords. (diff)
downloadeselect-a1de32ca76ee2dc24961f52b38c9c0f3cd51eb03.tar.gz
eselect-a1de32ca76ee2dc24961f52b38c9c0f3cd51eb03.tar.bz2
eselect-a1de32ca76ee2dc24961f52b38c9c0f3cd51eb03.zip
Move es_find_module function to core library.
* bin/eselect.in (es_find_module): Move function to core library. * libs/core.bash.in (find_module): Rename and simplify.
Diffstat (limited to 'libs')
-rw-r--r--libs/core.bash.in15
1 files changed, 14 insertions, 1 deletions
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}"