Enable failglob in global scope to catch unintended globbing attempts including unescaped special uses of '*'. --- bin/eapi.sh | 4 ++++ bin/ebuild.sh | 11 +++++++++++ 2 files changed, 15 insertions(+)
diff --git a/bin/eapi.sh b/bin/eapi.sh index 6e78750..fa57999 100644 --- a/bin/eapi.sh +++ b/bin/eapi.sh @@ -160,6 +160,10 @@ ___eapi_unpack_is_case_sensitive() { # OTHERS +___eapi_enables_failglob_in_global_scope() { + [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]] +} + ___eapi_enables_globstar() { [[ ${1-${EAPI}} =~ ^(4-python|5-progress)$ ]] } diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 232bf44..3965acf 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -563,6 +563,13 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then # we make a backup copy for QA checks. __INHERITED_QA_CACHE=$INHERITED + # Catch failed globbing attempts in case ebuild writer forgot to + # escape '*' or likes. + # Note: this needs to be done before unsetting EAPI. + if ___eapi_enables_failglob_in_global_scope; then + shopt -s failglob + fi + # *DEPEND and IUSE will be set during the sourcing of the ebuild. # In order to ensure correct interaction between ebuilds and # eclasses, they need to be unset before this process of @@ -579,6 +586,10 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then set +x fi + if ___eapi_enables_failglob_in_global_scope; then + shopt -u failglob + fi + if [[ "${EBUILD_PHASE}" != "depend" ]] ; then RESTRICT=${PORTAGE_RESTRICT} [[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \ -- 2.1.3