public inbox for gentoo-pms@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* [gentoo-pms] [PATCH] ebuild-functions.tex: Update array detection code.
@ 2020-02-15 10:14 99% Ulrich Müller
  0 siblings, 0 replies; 1+ results
From: Ulrich Müller @ 2020-02-15 10:14 UTC (permalink / raw
  To: gentoo-pms

[-- Attachment #1: Type: text/plain, Size: 1913 bytes --]

Remove the space after "declare -a" for matching "declare -p" output.
With the update of the bash version to 4.2 in EAPI 6, variables can
have other attributes in addition, which would make the test fail.
For example, see https://bugs.gentoo.org/444832#c7. The implementation
in Portage already omits the space.

Replace grep by functionally equivalent code in bash. This is how the
test is implemented in package managers, and follows the principle
that external programs should not be called unnecessarily.

Redirect stderr for "declare -p", because it outputs an error message
if the PATCHES variable is not defined.

Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
 ebuild-functions.tex | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ebuild-functions.tex b/ebuild-functions.tex
index 33c003a..4a13db6 100644
--- a/ebuild-functions.tex
+++ b/ebuild-functions.tex
@@ -133,7 +133,7 @@ as:
 \caption{\t{src_prepare}, format~6}
 \begin{verbatim}
 src_prepare() {
-    if declare -p PATCHES | grep -q "^declare -a "; then
+    if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
         [[ -n ${PATCHES[@]} ]] && eapply "${PATCHES[@]}"
     else
         [[ -n ${PATCHES} ]] && eapply ${PATCHES}
@@ -325,13 +325,13 @@ src_install() {
         emake DESTDIR="${D}" install
     fi
 
-    if ! declare -p DOCS >/dev/null 2>&1 ; then
+    if ! declare -p DOCS >/dev/null 2>&1; then
         local d
         for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \
-                THANKS BUGS FAQ CREDITS CHANGELOG ; do
+                THANKS BUGS FAQ CREDITS CHANGELOG; do
             [[ -s "${d}" ]] && dodoc "${d}"
         done
-    elif declare -p DOCS | grep -q "^declare -a " ; then
+    elif [[ $(declare -p DOCS) == "declare -a"* ]]; then
         dodoc "${DOCS[@]}"
     else
         dodoc ${DOCS}
-- 
2.25.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply related	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-02-15 10:14 99% [gentoo-pms] [PATCH] ebuild-functions.tex: Update array detection code Ulrich Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox