1 |
Enable failglob in global scope to catch unintended globbing attempts |
2 |
including unescaped special uses of '*'. |
3 |
--- |
4 |
bin/eapi.sh | 4 ++++ |
5 |
bin/ebuild.sh | 11 +++++++++++ |
6 |
2 files changed, 15 insertions(+) |
7 |
|
8 |
diff --git a/bin/eapi.sh b/bin/eapi.sh |
9 |
index 6e78750..fa57999 100644 |
10 |
--- a/bin/eapi.sh |
11 |
+++ b/bin/eapi.sh |
12 |
@@ -160,6 +160,10 @@ ___eapi_unpack_is_case_sensitive() { |
13 |
|
14 |
# OTHERS |
15 |
|
16 |
+___eapi_enables_failglob_in_global_scope() { |
17 |
+ [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]] |
18 |
+} |
19 |
+ |
20 |
___eapi_enables_globstar() { |
21 |
[[ ${1-${EAPI}} =~ ^(4-python|5-progress)$ ]] |
22 |
} |
23 |
diff --git a/bin/ebuild.sh b/bin/ebuild.sh |
24 |
index be044e0..167ea4c 100755 |
25 |
--- a/bin/ebuild.sh |
26 |
+++ b/bin/ebuild.sh |
27 |
@@ -533,6 +533,13 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then |
28 |
# we make a backup copy for QA checks. |
29 |
__INHERITED_QA_CACHE=$INHERITED |
30 |
|
31 |
+ # Catch failed globbing attempts in case ebuild writer forgot to |
32 |
+ # escape '*' or likes. |
33 |
+ # Note: this needs to be done before unsetting EAPI. |
34 |
+ if ___eapi_enables_failglob_in_global_scope; then |
35 |
+ shopt -s failglob |
36 |
+ fi |
37 |
+ |
38 |
# *DEPEND and IUSE will be set during the sourcing of the ebuild. |
39 |
# In order to ensure correct interaction between ebuilds and |
40 |
# eclasses, they need to be unset before this process of |
41 |
@@ -549,6 +556,10 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then |
42 |
set +x |
43 |
fi |
44 |
|
45 |
+ if ___eapi_enables_failglob_in_global_scope; then |
46 |
+ shopt -u failglob |
47 |
+ fi |
48 |
+ |
49 |
if [[ "${EBUILD_PHASE}" != "depend" ]] ; then |
50 |
RESTRICT=${PORTAGE_RESTRICT} |
51 |
[[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \ |
52 |
-- |
53 |
2.0.4 |