summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2020-02-15 10:56:55 +0100
committerUlrich Müller <ulm@gentoo.org>2020-02-15 10:56:55 +0100
commit0d4ffd51d3dc86782dae2db9fe632f45af7eec87 (patch)
tree6667fce4b63d22908165162b11c214139612c7be /ebuild-functions.tex
parentUpdate copyright years. (diff)
downloadpms-0d4ffd51d3dc86782dae2db9fe632f45af7eec87.tar.gz
pms-0d4ffd51d3dc86782dae2db9fe632f45af7eec87.tar.bz2
pms-0d4ffd51d3dc86782dae2db9fe632f45af7eec87.zip
ebuild-functions.tex: Update array detection code.
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>
Diffstat (limited to 'ebuild-functions.tex')
-rw-r--r--ebuild-functions.tex8
1 files 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}