diff options
author | Ross Konsolebox <konsolebox@gmail.com> | 2018-08-01 14:40:59 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2019-05-19 17:04:12 -0700 |
commit | 5473a2695aa3fb3a7cdee889fe8c861fcb274277 (patch) | |
tree | 442edcbaf39076c29542eaa8ba1eb9e5d5d3981b /bin | |
parent | _safe_loop: call global_event_loop() directly (diff) | |
download | portage-5473a2695aa3fb3a7cdee889fe8c861fcb274277.tar.gz portage-5473a2695aa3fb3a7cdee889fe8c861fcb274277.tar.bz2 portage-5473a2695aa3fb3a7cdee889fe8c861fcb274277.zip |
Add bash ___is_indexed_array_var function (bug 662468)
Closes: https://bugs.gentoo.org/662468
Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'bin')
-rw-r--r-- | bin/isolated-functions.sh | 10 | ||||
-rw-r--r-- | bin/phase-helpers.sh | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 22a6dbb0f..e4e769a04 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -593,4 +593,14 @@ __eqatag() { ) >> "${T}"/qa.log } +if [[ BASH_VERSINFO -gt 4 || (BASH_VERSINFO -eq 4 && BASH_VERSINFO[1] -ge 4) ]] ; then + ___is_indexed_array_var() { + [[ ${!1@a} == *a* ]] + } +else + ___is_indexed_array_var() { + [[ $(declare -p "$1" 2>/dev/null) == 'declare -a'* ]] + } +fi + true diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 64a82b4b7..02633125f 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -853,7 +853,7 @@ __eapi4_src_install() { THANKS BUGS FAQ CREDITS CHANGELOG ; do [[ -s "${d}" ]] && dodoc "${d}" done - elif [[ $(declare -p DOCS) == "declare -a "* ]] ; then + elif ___is_indexed_array_var DOCS ; then dodoc "${DOCS[@]}" else dodoc ${DOCS} @@ -861,7 +861,7 @@ __eapi4_src_install() { } __eapi6_src_prepare() { - if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then + if ___is_indexed_array_var PATCHES ; then [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}" elif [[ -n ${PATCHES} ]]; then eapply ${PATCHES} @@ -996,7 +996,7 @@ if ___eapi_has_einstalldocs; then THANKS BUGS FAQ CREDITS CHANGELOG ; do [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}" done - elif [[ $(declare -p DOCS) == "declare -a"* ]] ; then + elif ___is_indexed_array_var DOCS ; then [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}" else [[ ${DOCS} ]] && docinto / && dodoc -r ${DOCS} @@ -1004,7 +1004,7 @@ if ___eapi_has_einstalldocs; then ) ( - if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]] ; then + if ___is_indexed_array_var HTML_DOCS ; then [[ ${#HTML_DOCS[@]} -gt 0 ]] && \ docinto html && dodoc -r "${HTML_DOCS[@]}" else |