libtool-patches
[Top][All Lists]
Advanced

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

Re: eval $show when we $run eval


From: Gary V. Vaughan
Subject: Re: eval $show when we $run eval
Date: Wed, 13 Oct 2004 16:20:08 +0100
User-agent: Mozilla Thunderbird 0.8 (X11/20040913)

Hi Peter,

Peter O'Gorman wrote:
>>> Index: ChangeLog
>>> 2004-10-13  Peter O'Gorman  <address@hidden>
>>>
>>>     * config/ltmain.m4sh: Make sure that we $show what we will $run,
>>>     use eval $show if we do $run eval.
>>
>>
>>
>>> -      $show "$command"
>>> +      eval $show "$command"
>>
>>
>>
>> eval will strip the quotes, so that $show will run on the bare $command
>> expansion, which may contain chars special to the shell, e.g ;
>>
>> I think the changed lines should read (untested!):
>>
>>     eval \$show \"$command\"
>>
>> Hmmm.... maybe $command contains " marks too :-(  If that is a
>> possibility
>> then $command must be passed through func_quote_for_eval():
>>
>>     func_quote_for_eval "$command"
>>     eval \$show \"$func_quote_for_eval_result\"
> 
> 
> Oh no, I just committed it to both HEAD and branch-2-0. It did pass all
> it's tests, but I'll get around to making these modifications tomorrow.

Okay, thanks.

While you are in the region of the lines that can use it (on HEAD), I have
been playing around with the following function in another project:

# func_verbose_eval command [args] ...
func_verbose_eval ()
{
    # First, show what we are about to do
    func_verbose "$@"

    # Quote shell metachars
    eval_cmd=
    while test $# -gt 0; do
      my_arg="$1"
      shift

      case $my_arg in
        \'*\')
          eval_cmd="${eval_cmd:+$eval_cmd }$my_arg"
          ;;
        *[[\@<:@\~\#\^\&\*\(\)\{\}\|\<\>\?\'\ \ ]]*|*@:>@*|"")
          eval_cmd="${eval_cmd:+$eval_cmd }'$my_arg'"
          ;;
        *)
          eval_cmd="${eval_cmd:+$eval_cmd }$my_arg"
          ;;
      esac
    done

    # Finally evaluate the meta-char escaped command
    eval "$eval_cmd"
}


The idea is that the whole $show $run mess can be replaced by a single:

    func_verbose_eval "$command"

It works in my other project, though I'm not sure enough of the corner cases
to have started testing it in libtool yet.  If you feel inclined, please be
my guest.

Cheers,
        Gary.
-- 
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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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