Fix die so that dump_trace is not called when the main script is a
helper binary. This prevents the following error message when a helper
dies automatically in EAPI 4:
isolated-functions.sh: line 61: p -= : syntax error: operand expected (error token is "-= ")
eerror "ERROR: $CATEGORY/$PF failed:"
eerror " ${*:-(no error message)}"
eerror
- # This part is useless when called by the die helper.
- if [[ ${BASH_SOURCE[1]##*/} != die ]] ; then
+ # dump_trace is useless when the main script is a helper binary
+ local main_index
+ (( main_index = ${#BASH_SOURCE[@]} - 1 ))
+ if has ${BASH_SOURCE[$main_index]##*/} ebuild.sh misc-functions.sh ; then
dump_trace 2 ${filespacing} ${linespacing}
eerror " $(printf "%${filespacing}s" "${BASH_SOURCE[1]##*/}"), line $(printf "%${linespacing}s" "${BASH_LINENO[0]}"): Called die"
eerror "The specific snippet of code:"