libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: fix dollar handling in func_quote_for_expand [libtool--devo--1.0--p


From: Gary V. Vaughan
Subject: FYI: fix dollar handling in func_quote_for_expand [libtool--devo--1.0--patch-265]
Date: Wed, 20 Oct 2004 21:45:46 +0100 (BST)
User-agent: mailnotify/0.5

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Applied to HEAD.

  * looking for address@hidden/libtool--devo--1.0--patch-264 to compare with
  * comparing to address@hidden/libtool--devo--1.0--patch-264
  M  ChangeLog
  M  config/general.m4sh
  
  * modified files
  
  Index: Changelog
  from  Gary V. Vaughan  <address@hidden>
  
        * config/general.m4sh (sed_double_backslash): New sed expression
        to escape \$ properly in combination with double_quote_subst.
        (func_quote_for_eval): Four space indent margin for functions!
        (func_quote_for_expand): Use $sed_double_backslash.
        (func_show_eval): New function that echos an escaped but variable
        expanded command, and then evaluates it.
  
        * config/general.m4sh (sed_quote_subst): Ditto.
  --- orig/config/general.m4sh
  +++ mod/config/general.m4sh
  @@ -94,6 +94,13 @@
   # Same as above, but do not quote variable references.
   double_quote_subst='s/\([["`\\]]\)/\\\1/g'
   
  +# Save mangling of backslash escaped dollars by the above.  Running this
  +# substitution after double_quote_subst notices and corrects expansion
  +# of already escaped meta-chars.  \$x -> double_quote_subst -> \\$x,
  +# which doesn't protect $x from expansion.  To correct this we do:
  +# \\$x -> sed_double_backslash -> \\\$x, properly protecting $x.
  +sed_double_backslash='s/\([[^\\]]\)\\\\$/\1\\\\\\$/g'
  +
   # test EBCDIC or ASCII
   case `$ECHO A|tr A '\301'` in
    A) # EBCDIC based system
  @@ -256,20 +263,20 @@
   # Aesthetically quote ARG to be evaled later.
   func_quote_for_eval ()
   {
  -  my_arg=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"`
  +    my_arg=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"`
   
  -  case $my_arg in
  -    # 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.
  -    *[[\@<:@\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \        ]]*|*@:>@*|"")
  -      my_arg="\"$my_arg\""
  -      ;;
  -  esac
  +    case $my_arg in
  +      # 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.
  +      *[[\@<:@\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \      ]]*|*@:>@*|"")
  +        my_arg="\"$my_arg\""
  +        ;;
  +    esac
   
  -  func_quote_for_eval_result="$my_arg"
  +    func_quote_for_eval_result="$my_arg"
   }
   
   
  @@ -278,17 +285,36 @@
   # but do not quote variable references.
   func_quote_for_expand ()
   {
  -  my_arg=`$ECHO "X$1" | $Xsed -e "$double_quote_subst"`
  +    my_arg=`$ECHO "X$1" | $Xsed \
  +        -e "$double_quote_subst" -e "$sed_double_backslash"`
  +
  +    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"
  +}
  +
   
  -  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_show_eval cmd [fail_exp]
  +# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
  +# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
  +# is given, then evaluate it.
  +func_show_eval ()
  +{
  +    my_cmd="$1"
  +    my_fail_exp="${2-:}"
  +
  +    ${opt_silent-false} || {
  +      func_quote_for_expand "$my_cmd"
  +      eval "func_echo $func_quote_for_expand_result"
  +    }
   
  -  func_quote_for_expand_result="$my_arg"
  +    ${opt_dry_run-false} || eval "$my_cmd" || eval "$my_fail_exp"
   }
  
  
  
- -- 
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook
_________________________________________________________
This patch notification generated by tlaapply version 0.8
http://tkd.kicks-ass.net/arch/address@hidden/cvs-utils--tla--1.0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFBds54FRMICSmD1gYRAmCnAJoDnbBlPElZGMqba0WOa1a/LMSmiACgkYxb
00mUoJDnm1BBkXSHaP8kqNs=
=SX5O
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]