> 1) I don't have access to systems that are old or weird enough to check > if the performance penalty will happen often. What do you think? > > 2) If ksh had a way to print without interpreting escapes *and dashes*, > I'd be glad to add it; do you know one?
I thought of one after lunch: "print -r -- FOO". This way we can print without forking on bash, zsh, ksh, ash/dash. So here is a resubmission of patch 6/6. Paolo
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index e3627b0..28f50cd 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -92,8 +92,13 @@ fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh -# In case there is no working printf in the path -eval "$lt_func_ECHO" +# A function that is used when printf is not a builtin. +func_fallback_echo () +{ + cat <<_LTECHO_EOF +$1 +_LTECHO_EOF +} # NLS nuisances: We save the old values to restore during execute mode. # Only set LANG and LC_ALL to C if already set. @@ -2340,16 +2345,18 @@ if test \"\$libtool_install_magic\" = \"$magic\"; then else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then - file=\"\$0\" - # Make sure echo works." + file=\"\$0\"" - qlt_cmd_ECHO=`$ECHO "X$lt_cmd_ECHO" | $Xsed -e "$sed_quote_subst"` - qlt_func_ECHO=`$ECHO "X$lt_func_ECHO" | $Xsed -e "$sed_quote_subst"` qECHO=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"` - $ECHO "\ - lt_cmd_ECHO=\"$qlt_cmd_ECHO\" - lt_func_ECHO=\"$qlt_func_ECHO\" - eval \"\$lt_func_ECHO\" + $ECHO "\ + +# A function that is used when printf is not a builtin. +func_fallback_echo () +{ + cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF +} ECHO=\"$qECHO\" fi\ diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index 4c4aa0b..b221749 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -526,7 +526,13 @@ LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' -eval "\$lt_func_ECHO" +# Used when printf is not a builtin. +func_fallback_echo () +{ + cat <<_LTECHO_EOF +\$[]1 +_LTECHO_EOF +} # Quote evaled strings. for var in lt_decl_all_varnames([[ \ @@ -1069,74 +1075,37 @@ m4_define([_LT_SHELL_INIT], ])])# _LT_SHELL_INIT -# _LT_DETECT_ECHO_BACKSLASH -# ----------------------------- -# Find a working printf (either a program or a shell builtin) -# that can be used to print values without interpreting backslashes -# or strings with a leading `-'. -m4_defun([_LT_DETECT_ECHO_BACKSLASH], + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Find how we can fake an echo command that does not interpret backslash. +# In particular, with Autoconf 2.60 or later we add some code to the start +# of the generated configure script which will find a shell with a builtin +# printf (which we can use as an echo command). +m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO -AC_MSG_CHECKING([for a working printf]) +AC_MSG_CHECKING([how to print strings]) if test "X`printf %s $ECHO`" = "X$ECHO"; then ECHO='printf %s\n' - else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR - for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH - do - IFS=$as_save_IFS - test "x$as_dir" = x && continue - test -f "$as_dir/printf" || test -f "$as_dir/printf.exe" || continue - test "X`$as_dir/printf %s $ECHO`" = "X$ECHO" && - { ECHO=$as_dir/printf' %s\n' ; break; } - done - case "$ECHO" in - */printf*) ;; - *) - lt_cmd_ECHO="printf %s\\\\n \"\$[]1\"" - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR - for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH - do - IFS=$as_save_IFS - test "x$as_dir" = x && continue - for as_base in sh bash ksh zsh sh5; do - as_shell=$as_dir/$as_base - test -f "$as_shell" || test -f "$as_shell.exe" || continue - lt_func_ECHO='func_do_echo () { '$as_shell' -c "$lt_cmd_ECHO" x "$[]1";}' - (lt_out=`$as_shell -c " - PATH=/tmp/nonexistent; export PATH; - FPATH=/tmp/nonexistent; export FPATH; - printf %s \"\\$[]1\"" lt_echo "$ECHO"` - test "X$lt_out" = "X$ECHO") && - { eval "$lt_func_ECHO"; ECHO=func_do_echo; break 2; } - done - done - esac + # Used when printf is not a builtin. + func_fallback_echo () + { + cat <<_LTECHO_EOF +$[]1 +_LTECHO_EOF + } + ECHO='func_fallback_echo' fi case "$ECHO" in - printf*) AC_MSG_RESULT([shell builtin]) ;; - */printf*) AC_MSG_RESULT([$as_dir/printf]) ;; - func_do_echo) AC_MSG_RESULT([$as_shell builtin]) ;; - *) AC_MSG_RESULT([not found]) - AC_MSG_ERROR([cannot find a working printf]) ;; + printf*) AC_MSG_RESULT([printf]) ;; + *) AC_MSG_RESULT([cat]) ;; esac -_LT_DECL([], [lt_cmd_ECHO], [1], [Used if there is no working printf in the path]) -_LT_DECL([], [lt_func_ECHO], [1], [Used if there is no working printf in the path]) -]) - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Add some code to the start of the generated configure script which -# will find a printf which doesn't interpret backslashes, and -# which we can use as an echo command. If possible, find a builtin. -m4_defun([_LT_PROG_ECHO_BACKSLASH], -[m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DETECT_ECHO_BACKSLASH])dnl m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'