diff options
author | Mike Gilbert <floppym@gentoo.org> | 2022-07-11 15:48:48 -0400 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2022-07-12 00:01:04 +0100 |
commit | 50ac4e2e3401be2410a01f7d5d7923672b57798f (patch) | |
tree | 079f9ca965c15c424b849c8a9183496104c70f39 /bin/isolated-functions.sh | |
parent | news: fix isRelevant check (diff) | |
download | portage-50ac4e2e3401be2410a01f7d5d7923672b57798f.tar.gz portage-50ac4e2e3401be2410a01f7d5d7923672b57798f.tar.bz2 portage-50ac4e2e3401be2410a01f7d5d7923672b57798f.zip |
Allow nested ebegin calls using a count variable
At the start of each phase, the count is set to 0.
The count is incremented each time ebegin is called.
If the count is equal to 0 when eend is called, a warning is output.
Otherwise, the count is decremented by 1.
At the end of each phase, if the count is greater than 0, a warning is
output.
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Closes: https://github.com/gentoo/portage/pull/854
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'bin/isolated-functions.sh')
-rw-r--r-- | bin/isolated-functions.sh | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index dea0d7f49..55c38fbb0 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -339,10 +339,7 @@ ebegin() { [[ ${RC_ENDCOL} == "yes" ]] && echo >&2 LAST_E_LEN=$(( 3 + ${#RC_INDENTATION} + ${#msg} )) LAST_E_CMD="ebegin" - if [[ -v EBEGIN_EEND ]] ; then - eqawarn "QA Notice: ebegin called, but missing call to eend (phase: ${EBUILD_PHASE})" - fi - EBEGIN_EEND=1 + let ++__EBEGIN_EEND_COUNT return 0 } @@ -371,10 +368,9 @@ __eend() { eend() { [[ -n $1 ]] || eqawarn "QA Notice: eend called without first argument" - if [[ -v EBEGIN_EEND ]] ; then - unset EBEGIN_EEND - else - eqawarn "QA Notice: eend called without preceding ebegin (phase: ${EBUILD_PHASE})" + if (( --__EBEGIN_EEND_COUNT < 0 )); then + __EBEGIN_EEND_COUNT=0 + eqawarn "QA Notice: eend called without preceding ebegin in ${FUNCNAME[1]}" fi local retval=${1:-0} shift |