From: Noah Misch Date: Wed, 20 Oct 2004 08:41:34 +0000 (+0000) Subject: * m4/libtool.m4 (sed_quote_subst): Remove superfluous backslashes X-Git-Tag: release-1-9f~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ec16d174c78c81350b9f0d914b045254d409c85;p=thirdparty%2Flibtool.git * m4/libtool.m4 (sed_quote_subst): Remove superfluous backslashes from the match character set. (double_quote_subst): Ditto. * lib/general.m4sh (sed_quote_subst): Ditto. (double_quote_subst): New variable, copied from m4/libtool.m4. Much the same as sed_quote_subst, but variable references are not quoted. (func_quote_for_eval): Given any $foo; $bar and $foo must be identical after the following commands: func_quote_for_eval "$foo" eval "bar=$func_quote_for_eval_result" (func_quote_for_expand): In a similar vein to to func_quote_for_eval, except that variable expansions are not protected when quoting the command for subsequent display. * config/ltmain.m4sh: Factor away use of $sed_quote_subst now that it has been subsumed into func_quote_for_eval. (func_mode_link): Instead of `2004-10-14 Peter O'Gorman' below, use func_quote_for_expand so that ${wl} is expanded properly in the $show expression. --- diff --git a/ChangeLog b/ChangeLog index 8c9457eb0..b5a21fe5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2004-10-20 Noah Misch , + Gary V. Vaughan + + * m4/libtool.m4 (sed_quote_subst): Remove superfluous backslashes + from the match character set. + (double_quote_subst): Ditto. + * lib/general.m4sh (sed_quote_subst): Ditto. + (double_quote_subst): New variable, copied from + m4/libtool.m4. Much the same as sed_quote_subst, but variable + references are not quoted. + (func_quote_for_eval): Given any $foo; $bar and + $foo must be identical after the following commands: + func_quote_for_eval "$foo" + eval "bar=$func_quote_for_eval_result" + (func_quote_for_expand): In a similar vein to to func_quote_for_eval, + except that variable expansions are not protected when quoting the + command for subsequent display. + * config/ltmain.m4sh: Factor away use of $sed_quote_subst now that + it has been subsumed into func_quote_for_eval. + (func_mode_link): Instead of `2004-10-14 Peter O'Gorman' below, + use func_quote_for_expand so that ${wl} is expanded properly in + the $show expression. + 2004-10-16 Gary V. Vaughan * config/ltmain.m4sh (func_mode_finish): solaris-2.6 also has diff --git a/config/general.m4sh b/config/general.m4sh index 6ddc1655e..d03da0dbd 100644 --- a/config/general.m4sh +++ b/config/general.m4sh @@ -89,7 +89,11 @@ esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' -sed_quote_subst='s/\([[\\`\\"$\\\\]]\)/\\\1/g' +sed_quote_subst='s/\([[`"$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + # test EBCDIC or ASCII case `$ECHO A|tr A '\301'` in A) # EBCDIC based system @@ -252,10 +256,12 @@ func_mktempdir () # Aesthetically quote ARG to be evaled later. func_quote_for_eval () { - my_arg="$1" + my_arg=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` case $my_arg in - # Double-quote args containing other shell metacharacters. + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and and variable + # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[[\@<:@\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]]*|*@:>@*|"") @@ -265,3 +271,24 @@ func_quote_for_eval () func_quote_for_eval_result="$my_arg" } + + +# func_quote_for_expand arg +# Aesthetically quote ARG to be evaled later; same as above, +# but do not quote variable references. +func_quote_for_expand () +{ + my_arg=`$ECHO "X$1" | $Xsed -e "$double_quote_subst"` + + case $my_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting and command substitution for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[[\@<:@\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]]*|*@:>@*|"") + my_arg="\"$my_arg\"" + ;; + esac + + func_quote_for_expand_result="$my_arg" +} diff --git a/config/ltmain.m4sh b/config/ltmain.m4sh index ad778129c..4191b7fc5 100644 --- a/config/ltmain.m4sh +++ b/config/ltmain.m4sh @@ -1090,7 +1090,6 @@ func_mode_compile () esac # case $arg_mode # Aesthetically quote the previous argument. - lastarg=`$ECHO "X$lastarg" | $Xsed -e "$sed_quote_subst"` func_quote_for_eval "$lastarg" base_compile="$base_compile $func_quote_for_eval_result" done # for arg @@ -1511,8 +1510,8 @@ func_mode_execute () ;; esac # Quote arguments (to preserve shell metacharacters). - file=`$ECHO "X$file" | $Xsed -e "$sed_quote_subst"` - args="$args \"$file\"" + func_quote_for_eval "$file" + args="$args $func_quote_for_eval_result" done if test -z "$run"; then @@ -1637,8 +1636,7 @@ func_mode_install () # Allow the use of GNU shtool's install command. $ECHO "X$nonopt" | $Xsed | $GREP shtool > /dev/null; then # Aesthetically quote it. - arg=`$ECHO "X$nonopt" | $Xsed -e "$sed_quote_subst"` - func_quote_for_eval "$arg" + func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg="$1" shift @@ -1649,7 +1647,6 @@ func_mode_install () # The real first argument should be the name of the installation program. # Aesthetically quote it. - arg=`$ECHO "X$arg" | $Xsed -e "$sed_quote_subst"` func_quote_for_eval "$arg" install_prog="$install_prog$func_quote_for_eval_result" @@ -1693,7 +1690,6 @@ func_mode_install () esac # Aesthetically quote the argument. - arg=`$ECHO "X$arg" | $Xsed -e "$sed_quote_subst"` func_quote_for_eval "$arg" install_prog="$install_prog $func_quote_for_eval_result" done @@ -2199,7 +2195,7 @@ func_mode_link () arg="$1" shift qarg=`$ECHO "X$arg" | $Xsed -e "$sed_quote_subst"` - func_quote_for_eval "$qarg" + func_quote_for_eval "$arg" libtool_args="$libtool_args $func_quote_for_eval_result" # If the previous option needs an argument, assign it. @@ -2716,7 +2712,7 @@ func_mode_link () ;; -Wc,*) - args=`$ECHO "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` + args=`$ECHO "X$arg" | $Xsed -e 's/^-Wc,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do @@ -2730,7 +2726,7 @@ func_mode_link () ;; -Wl,*) - args=`$ECHO "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` + args=`$ECHO "X$arg" | $Xsed -e 's/^-Wl,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do @@ -2765,7 +2761,6 @@ func_mode_link () # -q* pass through compiler args for the IBM compiler # -m* pass through architecture-specific compiler args for GCC -64|-mips[[0-9]]|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*) - arg=`$ECHO "X$arg" | $Xsed -e "$sed_quote_subst"` func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" compile_command="$compile_command $arg" @@ -2776,7 +2771,6 @@ func_mode_link () # Some other compiler flag. -* | +*) - arg=`$ECHO "X$arg" | $Xsed -e "$sed_quote_subst"` func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; @@ -2910,7 +2904,6 @@ func_mode_link () *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. - arg=`$ECHO "X$arg" | $Xsed -e "$sed_quote_subst"` func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; @@ -5144,8 +5137,8 @@ EOF for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" - func_quote_for_eval "$cmd" - eval \$show \"$func_quote_for_eval_result\" + func_quote_for_expand "$cmd" + eval \$show "$func_quote_for_expand_result" $run eval "$cmd" || { lt_exit=$? @@ -5593,8 +5586,8 @@ EOF elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else - var_value=`$ECHO "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" @@ -6283,8 +6276,8 @@ fi\ elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else - var_value=`$ECHO "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. diff --git a/m4/libtool.m4 b/m4/libtool.m4 index ef2e1bc6c..17c00cb2b 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -135,10 +135,10 @@ esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='sed -e s/^X//' -[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. -[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] +double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string.