commit: 7ff579ccb92b2f2512933a41e9a0a204b0601201
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat May 31 15:06:12 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun 1 21:42:02 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7ff579cc
phase-helpers.sh: refactor the einstalldocs() function
Declare the entire function as a compound command of the ( … ) form,
which induces a subshell.
Rename the d variable to f, since it is being employed with the
expectation that its value will be the pathname of a regular file.
Use the -v test operator to determine whether the DOCS variable is set.
This feature was introduced by bash-4.2.
Refrain from using the ___is_indexed_array_var() function to determine
whether variables are indexed array variables. Instead, use the
${param <AT> a} form of expansion. This feature was introduced by bash-4.4.
Reduce the use of the && control operator so as to clarify the overall
flow control.
In the course of testing for a scalar variable, test not only that the
variable isn't an indexed array variable, but also that it isn't an
associative array.
Suppress SC2086 warnings where word splitting is being wilfully performed.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/phase-helpers.sh | 48 ++++++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index bd97a7e044..b07bb42b3c 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -949,31 +949,31 @@ if ___eapi_has_get_libdir; then
fi
if ___eapi_has_einstalldocs; then
- einstalldocs() {
- (
- 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
- [[ -f ${d} && -s ${d} ]] && docinto /
&& dodoc "${d}"
- done
- elif ___is_indexed_array_var DOCS ; then
- [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc
-r "${DOCS[@]}"
- else
- [[ ${DOCS} ]] && docinto / && dodoc -r ${DOCS}
- fi
- )
+ einstalldocs() (
+ local f
+
+ if [[ ! -v DOCS ]]; then
+ for f in README* ChangeLog AUTHORS NEWS TODO CHANGES \
+ THANKS BUGS FAQ CREDITS CHANGELOG
+ do
+ if [[ -f ${f} && -s ${f} ]]; then
+ docinto / && dodoc "${f}"
+ fi
+ done
+ elif [[ ${DOCS@a} == *a* ]] && (( ${#DOCS[@]} )); then
+ docinto / && dodoc -r "${DOCS[@]}"
+ elif [[ ${DOCS@a} != *[aA]* && ${DOCS} ]]; then
+ # shellcheck disable=2086
+ docinto / && dodoc -r ${DOCS}
+ fi
- (
- if ___is_indexed_array_var HTML_DOCS ; then
- [[ ${#HTML_DOCS[@]} -gt 0 ]] && \
- docinto html && dodoc -r
"${HTML_DOCS[@]}"
- else
- [[ ${HTML_DOCS} ]] && \
- docinto html && dodoc -r ${HTML_DOCS}
- fi
- )
- }
+ if [[ ${HTML_DOCS@a} == *a* ]] && (( ${#HTML_DOCS[@]} )); then
+ docinto html && dodoc -r "${HTML_DOCS[@]}"
+ elif [[ ${HTML_DOCS@a} != *[aA]* && ${HTML_DOCS} ]]; then
+ # shellcheck disable=2086
+ docinto html && dodoc -r ${HTML_DOCS}
+ fi
+ )
fi
if ___eapi_has_eapply; then