]> Savannah Git Hosting - gnulib.git/commitdiff
configmake: Bypass the unusable 'echo' command of some shells.
authorBruno Haible <bruno@clisp.org>
Sun, 18 Jun 2023 20:37:32 +0000 (22:37 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 18 Jun 2023 20:48:35 +0000 (22:48 +0200)
Reported by Brian Inglis <Brian.Inglis@Shaw.ca> in
<https://lists.gnu.org/archive/html/bug-gettext/2023-06/msg00054.html>.

* m4/build-to-host.m4 (gl_BUILD_TO_HOST): Use 'printf' instead of
'echo', because the "dash" shell has a SystemV compatible 'echo'
command. Also, be sure to remove trailing CRs.

ChangeLog
m4/build-to-host.m4

index f4b9116d4243d126f0ef9b3cf225d45d2710d0a4..15d375bbb6ba3fbe017280e2da6d4618dc059385 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-06-18  Bruno Haible  <bruno@clisp.org>
+
+       configmake: Bypass the unusable 'echo' command of some shells.
+       Reported by Brian Inglis <Brian.Inglis@Shaw.ca> in
+       <https://lists.gnu.org/archive/html/bug-gettext/2023-06/msg00054.html>.
+       * m4/build-to-host.m4 (gl_BUILD_TO_HOST): Use 'printf' instead of
+       'echo', because the "dash" shell has a SystemV compatible 'echo'
+       command. Also, be sure to remove trailing CRs.
+
 2023-06-18  Paul Eggert  <eggert@cs.ucla.edu>
 
        update-copyright tests: fix to match behavior
index e3c72877f0274c7e9207a72a47be3b4524b35747..8964ee84a4bfb46f4602883a82b2ec687bb031e4 100644 (file)
@@ -1,4 +1,4 @@
-# build-to-host.m4 serial 1
+# build-to-host.m4 serial 2
 dnl Copyright (C) 2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -47,12 +47,12 @@ AC_DEFUN([gl_BUILD_TO_HOST],
       ;;
   esac
   dnl Convert it to C string syntax.
-  [$1]_c=`echo "$gl_final_[$1]" | sed -e "$gl_sed_double_backslashes" -e "$gl_sed_escape_doublequotes"`
+  [$1]_c=`printf '%s\n' "$gl_final_[$1]" | sed -e "$gl_sed_double_backslashes" -e "$gl_sed_escape_doublequotes" | tr -d "$gl_tr_cr"`
   [$1]_c='"'"$[$1]_c"'"'
   AC_SUBST([$1_c])
 
   dnl Define somedir_c_make.
-  [$1]_c_make=`echo "$[$1]_c" | sed -e "$gl_sed_escape_for_make_1" -e "$gl_sed_escape_for_make_2"`
+  [$1]_c_make=`printf '%s\n' "$[$1]_c" | sed -e "$gl_sed_escape_for_make_1" -e "$gl_sed_escape_for_make_2" | tr -d "$gl_tr_cr"`
   dnl Use the substituted somedir variable, when possible, so that the user
   dnl may adjust somedir a posteriori when there are no special characters.
   if test "$[$1]_c_make" = '\"'"${gl_final_[$1]}"'\"'; then
@@ -70,4 +70,10 @@ changequote(,)dnl
   gl_sed_escape_for_make_1="s,\\([ \"&'();<>\\\\\`|]\\),\\\\\\1,g"
 changequote([,])dnl
   gl_sed_escape_for_make_2='s,\$,\\$$,g'
+  dnl Find out how to remove carriage returns from output. Solaris /usr/ucb/tr
+  dnl does not understand '\r'.
+  case `echo r | tr -d '\r'` in
+    '') gl_tr_cr='\015' ;;
+    *)  gl_tr_cr='\r' ;;
+  esac
 ])