commit: 5473a2695aa3fb3a7cdee889fe8c861fcb274277 Author: Ross Konsolebox <konsolebox <AT> gmail <DOT> com> AuthorDate: Wed Aug 1 14:40:59 2018 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Mon May 20 00:04:12 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5473a269
Add bash ___is_indexed_array_var function (bug 662468) Closes: https://bugs.gentoo.org/662468 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> bin/isolated-functions.sh | 10 ++++++++++ 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
