commit:     42fe7eadad8c80836ace0de527e988383f63b7da
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 20 13:04:34 2020 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Feb 20 13:27:33 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=42fe7ead

einstalldocs: Fix test for DOCS being unset.

The current test does not exactly test for unset DOCS, because it also
evaluates as true if the variable has attributes. Such attributes can
be defined even for an unset variable.

Therefore test the output of declare -p for presence of an = sign
instead, which indicates that a value has been assigned to the
variable (bug 710076 comment #2).

PMS reference: Algorithm 12.4, line 7:
https://projects.gentoo.org/pms/7/pms.html#x1-135011r183

See also bash upstream discussion:
https://lists.gnu.org/archive/html/bug-bash/2020-02/msg00045.html

Closes: https://bugs.gentoo.org/710076
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 bin/phase-helpers.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 3deb28c68..9495465f9 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 if ___eapi_has_DESTTREE_INSDESTTREE; then
@@ -953,7 +953,7 @@ fi
 if ___eapi_has_einstalldocs; then
        einstalldocs() {
                (
-                       if ! declare -p DOCS &>/dev/null ; then
+                       if [[ $(declare -p DOCS 2>/dev/null) != *=* ]]; then
                                local d
                                for d in README* ChangeLog AUTHORS NEWS TODO 
CHANGES \
                                                THANKS BUGS FAQ CREDITS 
CHANGELOG ; do

Reply via email to