aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gmail.com>2015-11-21 15:29:51 -0500
committerTim Harder <radhermit@gmail.com>2015-11-21 15:29:51 -0500
commit2e31a6843166c6fa23bf02dfe846ef161db29f65 (patch)
treea8a62abce745f8f4a8b19dc3a97f320fa7c616c3
parentimport find_binary directly from snakeoil instead of pkgcore.spawn (diff)
downloadpkgcore-2e31a6843166c6fa23bf02dfe846ef161db29f65.tar.gz
pkgcore-2e31a6843166c6fa23bf02dfe846ef161db29f65.tar.bz2
pkgcore-2e31a6843166c6fa23bf02dfe846ef161db29f65.zip
bash: use compgen to get function lists
Simpler than use custom declare() methods.
-rw-r--r--bash/ebuild-env-utils.lib14
-rwxr-xr-xbash/generate_eapi_func_list.bash7
-rwxr-xr-xbash/generate_global_func_list.bash2
3 files changed, 3 insertions, 20 deletions
diff --git a/bash/ebuild-env-utils.lib b/bash/ebuild-env-utils.lib
index 6f5cae392..326435487 100644
--- a/bash/ebuild-env-utils.lib
+++ b/bash/ebuild-env-utils.lib
@@ -45,18 +45,6 @@ __escape_regex_array() {
eval $1='( "${__tmp_array[@]}" )'
} &> /dev/null
-__environ_list_funcs() {
- # Grab the vars /before/ adding our custom declare function, else it'll
- # show up in the list of functions.
- local __content=$(builtin declare -F)
- declare() {
- echo "$2"
- }
- eval "${__content}" || die "${FUNCNAME}: eval failed" >&2
- unset -f declare
- :
-}
-
__environ_list_vars() {
declare() {
local __ret=${2%%=*}
@@ -84,7 +72,7 @@ __environ_dump() {
# Punt any regex chars...
__escape_regex_array __func_filters
- __PKGCORE_TARGETS=( $(__environ_list_funcs | __regex_filter_input "${__func_filters[@]}" ) )
+ __PKGCORE_TARGETS=( $(compgen -A function | __regex_filter_input "${__func_filters[@]}" ) )
unset __func_filters
if [[ ${#__PKGCORE_TARGETS[@]} -ne 0 ]]; then
declare -f "${__PKGCORE_TARGETS[@]}" || die "failed outputting funcs ${__PKGCORE_TARGETS[@]}" >&2
diff --git a/bash/generate_eapi_func_list.bash b/bash/generate_eapi_func_list.bash
index 149d83b33..c851d6ec2 100755
--- a/bash/generate_eapi_func_list.bash
+++ b/bash/generate_eapi_func_list.bash
@@ -18,13 +18,8 @@ export PKGCORE_PYTHON_BINARY=/bin/true
source "${PKGCORE_BIN_PATH}/eapi/${EAPI}.lib" \
|| { echo "failed loading eapi/${EAPI}.lib" >&2; exit 1; }
-# grab function list *before* adding our custom declare function, otherwise
-# it'll show up in the list of functions
-__content=$(builtin declare -F)
-declare() { echo "$2"; }
-result=$(eval "${__content}") || { echo "generate EAPI func list eval failed" >&2; exit 1; }
+result=$(compgen -A function)
# Sorting order; put PMS functionality first, then our internals.
result=$(echo "${result}" | grep -v "^__"; echo "${result}" | grep "^__")
-unset -f declare
echo "${result}"
diff --git a/bash/generate_global_func_list.bash b/bash/generate_global_func_list.bash
index 493626fa0..d3d9780bc 100755
--- a/bash/generate_global_func_list.bash
+++ b/bash/generate_global_func_list.bash
@@ -64,7 +64,7 @@ unset -f __source_was_seen
unset -f source
# Sorting order; put PMS functionality first, then our internals.
-result=$(__environ_list_funcs | sort)
+result=$(compgen -A function | sort)
result=$(echo "${result}" | grep -v "^__"; echo "${result}" | grep "^__")
${DEBUG} && echo >&2