From a1de32ca76ee2dc24961f52b38c9c0f3cd51eb03 Mon Sep 17 00:00:00 2001 From: Ulrich Müller Date: Mon, 21 Oct 2013 22:35:23 +0200 Subject: 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. --- libs/core.bash.in | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libs/core.bash.in') 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}" -- cgit v1.2.3-65-gdbad