From c01bc8e8ea99252f4249434e432896c8f2ae1199 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Mon, 8 Mar 2021 22:36:50 -0500 Subject: [PATCH] Fix DX_COMMAND_OUTPUT backslash-newline on heirloom-sh. It seems that heirloom-sh (and presumably Solaris /bin/sh) read just silently eats backslash-newlines, and escaping the backslash does nothing useful, the shell just eats both backslashes and the newline. Attempt to avoid this problem by appending a magic string to troublesome lines, and stripping it after reading. This will obviously fail if the input _actually_ has this sequence but hopefully that will not be an issue in practice. --- m4/cmdout.m4 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/m4/cmdout.m4 b/m4/cmdout.m4 index 90aa13e..c91aca1 100644 --- a/m4/cmdout.m4 +++ b/m4/cmdout.m4 @@ -22,12 +22,19 @@ AC_DEFUN_ONCE([_DX_COMMAND_OUTPUT_SETUP], [m4_divert_push([INIT_PREPARE])dnl dx_fn_cmdout_collect_output () { AS_UNSET([$][1]) # Double up backslashes as they will be stripped by read. - sed 's/\\/\\\\/g' conftest.do0 >conftest.do1 || return + # Heirloom sh read apparently just eats backslashes at EOL, so we compromise + # by adding a marker that can be stripped out afterwards. + _dx_eol='@%eol@%' + sed -e 's/\\/\\\\/g' -e 's/\\$/\\'"$_dx_eol/" conftest.do0 >conftest.do1 || + return exec 3