From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27436 invoked from network); 2 Apr 1999 10:44:44 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 2 Apr 1999 10:44:44 -0000 Received: (qmail 11051 invoked by alias); 2 Apr 1999 10:44:28 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6001 Received: (qmail 11031 invoked from network); 2 Apr 1999 10:44:21 -0000 From: "Bart Schaefer" Message-Id: <990402023951.ZM769@candle.brasslantern.com> Date: Fri, 2 Apr 1999 02:39:51 -0800 In-Reply-To: <002e01be7c48$968d8860$21c9ca95@mowp.siemens.ru> Comments: In reply to "Andrej Borsenkow" "bar='#pat'; ${foo/$bar/...} problem" (Apr 1, 6:04pm) References: <002e01be7c48$968d8860$21c9ca95@mowp.siemens.ru> X-Mailer: Z-Mail (4.0b.820 20aug96) To: "ZSH workers mailing list" Subject: Re: bar='#pat'; ${foo/$bar/...} problem MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 1, 6:04pm, Andrej Borsenkow wrote: } Subject: bar='#pat'; ${foo/$bar/...} problem } } It seems to be impossible to specify `#' (and probably `%') as part of the } replaced pattern: What you mean here is, specify left-anchored or right-anchored patterns, right? In that case, the # or % is not "part of the pattern", it's part of the ${...} syntax. The rest is just a glob pattern and doesn't have any built-in notion of "anchored." So really there are three: ${foo/pat/rep} pat --> rep, anywhere in foo ${foo/#pat/rep} pat --> rep, at left of foo ${foo/%pat/rep} pat --> rep, at right of foo Once you get that, it's easy to see that what you're attempting is the same as if you did % bar=('/#xx' '/zz'} % print ${foo$bar[1]$bar[2]} which you obviously wouldn't expect to work (I hope). Now, you might argue that the implementation of /# and /% should be as if # and % are extensions of the glob syntax, and in fact that is how it appears to be implemented in bash: $ foo=xxya $ bar='#xx' $ echo ${foo/$bar/zz} zzya In the meantime, though, you need an eval step of some kind: % foo=(xxya xxyb) % bar=('#xx' 'zz') % eval print '${foo/'"$bar[1]"'/$bar[2]}' (Did I get to be article 6000? :-) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com