From: Zack Weinberg Date: Tue, 27 May 2025 18:26:18 +0000 (-0400) Subject: Move more code out of shell traps into shell functions. X-Git-Tag: v2.72.90~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c777e326bd9674bc9f895544a7201e2dd915ffe;p=thirdparty%2Fautoconf.git Move more code out of shell traps into shell functions. Follow-up on 416b8f50c9bd4e38f9bc48b946505d2a18f6b1fd. * lib/autoconf/general.m4 (_AC_INIT_PREPARE): Emit function ac_exit_trap, move remaining code from the 'trap 0' command to ac_exit_trap. --- diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index e94f9b00a..900ba1e06 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1363,11 +1363,10 @@ ac_dump_debugging_info () } # When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? +# config.log. +ac_exit_trap () +{ + exit_status=$1 # Sanitize IFS. IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. @@ -1375,7 +1374,11 @@ trap 'exit_status=$? eval "rm -f $ac_clean_CONFIG_STATUS core *.core core.conftest.*" && rm -f -r conftest* confdefs* conf$[$]* $ac_clean_files && exit $exit_status -' 0 +} + +dnl To minimize quoting issues, put as little code as possible in traps. +dnl Do not start any trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'ac_exit_trap $?' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; AS_EXIT([1])' $ac_signal done