From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14028 invoked from network); 28 Aug 2001 20:21:00 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 Aug 2001 20:21:00 -0000 Received: (qmail 28572 invoked by alias); 28 Aug 2001 20:20:52 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15720 Received: (qmail 28550 invoked from network); 28 Aug 2001 20:20:50 -0000 To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: Re: Zsh Guide chapter 5 (substitutions) In-reply-to: "Bart Schaefer"'s message of "Tue, 21 Aug 2001 16:38:43 -0000." <1010821163843.ZM21870@candle.brasslantern.com> Date: Tue, 28 Aug 2001 22:25:54 +0100 From: Peter Stephenson Message-Id: <20010828212559.367FA1427E@pwstephenson.fsnet.co.uk> Bart Schaefer wrote: > And that's all, except that I'm left puzzling over this: > > The other tricky point is the use of double quotes in the eval. That > means that if the second argument has a double quote in it, the shell > will get very confused. > > This refers to: > > eval "f2=\"$result\"" > > I'm left wondering whether > > f2=${(e)result} > > wouldn't be equivalent and avoid the need for the double quotes? Well, hmm. Yeah. Fixed some other things, too. Index: Functions/Misc/zmv =================================================================== RCS file: /cvsroot/zsh/zsh/Functions/Misc/zmv,v retrieving revision 1.8 diff -u -r1.8 zmv --- Functions/Misc/zmv 2001/04/02 13:04:05 1.8 +++ Functions/Misc/zmv 2001/08/28 20:19:20 @@ -103,10 +103,6 @@ # are now turned off by default. To force the use of glob qualifiers, # give the flag -Q. # -# The second argument is re-evaluated in order to expand the parameters, -# so quoting may be a bit haphazard. In particular, a double quote -# will need an extra level of quoting. -# # The pattern is always treated as an extendedglob pattern. This # can also be interpreted as a feature. # @@ -130,7 +126,7 @@ print -P "%N: unrecognized option: -$OPTARG" >&2 return 1 fi - eval "opt_$opt=${OPTARG:--$opt}" + eval "opt_$opt=${(q)OPTARG:--$opt}" done (( OPTIND > 1 )) && shift $(( OPTIND - 1 )) @@ -153,6 +149,7 @@ pat=$1 repl=$2 +shift 2 if [[ -z $action ]]; then # We can't necessarily get the name of the function directly, because @@ -229,9 +226,9 @@ fi [[ -e $f && $f = (#b)${~pat} ]] || continue set -- "$match[@]" - eval g=\"$repl\" + g=${(e)repl} if [[ -z $g ]]; then - errs=($errs "$f expanded to empty string") + errs=($errs "\`$f' expanded to an empty string") elif [[ $f = $g ]]; then # don't cause error: more useful just to skip # errs=($errs "$f not altered by substitution") @@ -255,7 +252,7 @@ for f in $files; do [[ -z $to[$f] ]] && continue exec=($action ${=opt_o} $opt_s -- $f $to[$f]) - [[ -n $opt_i$opt_n$opt_v ]] && print -- $exec + [[ -n $opt_i$opt_n$opt_v ]] && print -r -- ${(q)exec} if [[ -n $opt_i ]]; then read -q 'opt?Execute? ' || continue fi -- Peter Stephenson Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk