From bf1f3ba7b12de948734cd7536b8435f17b3d324b Mon Sep 17 00:00:00 2001 From: MickLesk <47820557+MickLesk@users.noreply.github.com> Date: Fri, 23 Oct 2026 10:21:02 +0200 Subject: [PATCH] Report a failure inside a subshell once set -E hands the ERR trap to $(...) and ( ), so the subshell reported the error, log tail included, and the calling shell reported it again. A trap that fires in a subshell now only exits with the code; explicit error_handler calls still report. --- core/error_handler.func | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/error_handler.func b/core/error_handler.func index fc06edd..a79a367 100644 --- a/core/error_handler.func +++ b/core/error_handler.func @@ -676,6 +676,13 @@ error_handler() { [[ "$exit_code" -eq 0 ]] && return 0 + # set -E hands the ERR trap (which passes no arguments) to $(...) and ( ) too. + # The calling shell fails on the same error and reports it, so reporting here + # as well printed it twice. + if ((BASH_SUBSHELL > 0 && $# == 0)); then + exit "$exit_code" + fi + # Telemetry reads these for the "where" FAILED_COMMAND="$command" FAILED_LINE="$line_number"