[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cygwin Package mingw64-x86_64-gettext 0.22 mingw sh ==dash
From: |
Bruno Haible |
Subject: |
Re: Cygwin Package mingw64-x86_64-gettext 0.22 mingw sh ==dash |
Date: |
Sun, 18 Jun 2023 22:49:11 +0200 |
Hello Brian,
Brian Inglis wrote in
<https://lists.gnu.org/archive/html/bug-gettext/2023-06/msg00054.html>:
> Building Cygwin Package mingw gettext 0.22 got a problem running configure
> with
> sh == dash, in latest gettext 0.22 gettext-runtime/intl/configure and
> elsewhere
> handling localedir converting to localedir_c/localedir_c_make all containing
> Windows paths, especially under Cygwin, as you will see, demonstrated in the
> attached script and log, explained in the attached patch for configure.
>
> Under sh == dash echo \0## \b \t \n \v \f \c are escapes,
> also \c as in \cygwin in Windows path suppresses output as EoL,
> so Windows paths containing \c as in \cygwin are truncated:
Argh. Solaris 10 /bin/sh may soon be dead, but shells that are compatible to
it will apparently be around forever ;-(
Thanks for the analysis!
> use printf "%s" "$gl" instead of echo "$gl"!
It should better be printf '%s\n' since the output is piped into 'sed',
and we can't be sure how 'sed' handled input lines that are not newline-
terminated [1].
And then, just in case the shell is running in native Windows, we need to
remove the CR byte before the final newline. For this I took the trick from
gnulib/tests/test-exclude*.sh.
> I have not yet found where this transformation is generated from (some m4?),
> so
> any pointers would help.
> Other workarounds may be needed under other shells, depending on echo escapes
> and printf availability, perhaps a $gl_safe_echo or $SAFE_ECHO?
The printf command was not universally available before 2000-2005, but nowadays
it is. So, we can use 'printf %s\n' instead of 'echo' unconditionally.
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.
diff --git a/m4/build-to-host.m4 b/m4/build-to-host.m4
index e3c72877f0..8964ee84a4 100644
--- a/m4/build-to-host.m4
+++ b/m4/build-to-host.m4
@@ -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 @@ AC_DEFUN([gl_BUILD_TO_HOST_INIT]
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
])
[1] https://lists.gnu.org/archive/html/bug-gnulib/2023-06/msg00084.html