]> git.draconx.ca Git - dxcommon.git/commitdiff
DX_RUN_LOG: Work around DJGPP subshell bug.
authorNick Bowler <nbowler@draconx.ca>
Fri, 23 Feb 2024 01:26:02 +0000 (20:26 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 23 Feb 2024 01:31:59 +0000 (20:31 -0500)
On DJGPP bash, running set -x in a subshell also affects the parent
shell environment.  Inadvertently turning on traces for the whole
rest of the configure run is not desirable, so work around the
problem by manually turning the traces back off when this happens.

m4/base.m4

index c14ba68d21fcdf15ffb74e930ee8e0d51680e087..4dc0d146520ddc86b1ddf8c2f354b8da39eb007a 100644 (file)
@@ -1,10 +1,10 @@
-dnl Copyright © 2012, 2014, 2021, 2023 Nick Bowler
-dnl
-dnl Basic macros for dxcommon.
-dnl
-dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
-dnl This is free software: you are free to do what the fuck you want to.
-dnl There is NO WARRANTY, to the extent permitted by law.
+# Copyright © 2012, 2014, 2021, 2023-2024 Nick Bowler
+#
+# Basic macros for dxcommon.
+#
+# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+# This is free software: you are free to do what the fuck you want to.
+# There is NO WARRANTY, to the extent permitted by law.
 
 AC_PREREQ([2.64])
 
@@ -68,14 +68,20 @@ dnl
 dnl This macro expands to the dxcommon base directory, as a quoted string.
 AC_DEFUN([DX_BASEDIR], [m4_ignore(DX_INIT())m4_defn([_DX_BASEDIR])])
 
-dnl DX_RUN_LOG(command)
-dnl
-dnl Run a command, logging all of the command, its output, and overall
-dnl exit status to config.log.  The expansion of this macro is a single
-dnl complex shell command suitable for use in shell conditionals.
-AC_DEFUN([DX_RUN_LOG], [{ (set -x; $1;) >&AS_MESSAGE_LOG_FD 2>&1
-  dx_status=$?; AS_ECHO(["\$? = $dx_status"]) >&AS_MESSAGE_LOG_FD 2>&1
-  test $dx_status = 0; }])
+# DX_RUN_LOG(command)
+#
+# Run a command, logging all of the command, its output, and overall
+# exit status to config.log.  The expansion of this macro is a single
+# complex shell command suitable for use in shell conditionals.
+AC_DEFUN([DX_RUN_LOG],
+[{ _dx_shopt=$-
+( set -x
+$1
+) >&AS_MESSAGE_LOG_FD 2>&1
+_dx_status=$?
+test x"$-" = x"$_dx_shopt" || set +x # work around DJGPP subshell bug
+AS_ECHO(["\$? = $_dx_status"]) >&AS_MESSAGE_LOG_FD
+test $_dx_status = 0; } 2>/dev/null])
 
 # DX_PATCH_MACRO([macro-name], [regexp], [replacement])
 #