From 846bd9b0029b05cde906206c2713ccbb976f0fc3 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Tue, 3 Feb 2026 22:54:28 +0100 Subject: [PATCH] support/br2-external: remove leftover trap The trap was initially introduced in c5fa9308ea4e (core/br2-external: properly report unexpected errors), in 2017, to catch all unexpected errors, back when a single file was generated, and errors emitted to stderr. Since commit d027cd75d098 (core: generate all br2-external files in one go), in 2019 the single output file 'ofile' is no longer created, as multiple output files were then introduced, while messages for *expected errors* were redirected to a Makefile variable assignment emitted on stdout, at which point the script just exits (in error); expected failures only occur in do_validate(). Unexpected errors can only occur on failure to create, or write to, output files, either '.br2-external.mk' in do_validate() or do_mk(), or any of the kconfig fragments in do_kconfig(). Cause for failure to create those can only be a no-space-left-on-device condition, as they are created in a directory that was just created by the script earlier in main(), and thus has the necessary mode; failure to create that directory is now caught explicitly. A trap on ERR is not called when the shell exits explicitly with a call to 'exit', thus, only failures to create or write to output file would be caught. In that case, we are better off not trying to write to those files anyway: failure to create the file would already be reported by the shell on stderr, while disk-full would not allow to store the output anyway... In any case, the script exits in error, which is going to be caught by the caller, which will terminate. So, drop the trap altogether. As a side effect, that squelches a shellcheck error. Signed-off-by: Yann E. MORIN Signed-off-by: Romain Naour (cherry picked from commit 244e4283a918d775c3dff17b03a532658c0f7f4a) Signed-off-by: Thomas Perale --- support/scripts/br2-external | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/support/scripts/br2-external b/support/scripts/br2-external index 8aea479d20..6d4fc1a791 100755 --- a/support/scripts/br2-external +++ b/support/scripts/br2-external @@ -30,10 +30,10 @@ main() { error "no output directory specified (-d)\n" fi - # Trap any unexpected error to generate a meaningful error message - trap "error 'unexpected error while generating ${ofile}\n'" ERR + if ! mkdir -p "${outputdir}"; then + error "Cannot create output directory '%s'\n" "${outputdir}" + fi - mkdir -p "${outputdir}" do_validate "${outputdir}" ${@//:/ } do_mk "${outputdir}" do_kconfig "${outputdir}"