From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3478 invoked from network); 2 Oct 2003 02:36:49 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 2 Oct 2003 02:36:49 -0000 Received: (qmail 18404 invoked by alias); 2 Oct 2003 02:36:42 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19163 Received: (qmail 18393 invoked from network); 2 Oct 2003 02:36:41 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 2 Oct 2003 02:36:41 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.3.58.249] by sunsite.dk (MessageWall 1.0.8) with SMTP; 2 Oct 2003 2:36:41 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h922adD22047 for zsh-workers@sunsite.dk; Wed, 1 Oct 2003 19:36:39 -0700 From: Bart Schaefer Message-Id: <1031002023639.ZM22046@candle.brasslantern.com> Date: Thu, 2 Oct 2003 02:36:39 +0000 In-Reply-To: <20031001221753.GA23189@DervishD> Comments: In reply to DervishD "Emulating 'locate'" (Oct 2, 12:17am) References: <20031001221753.GA23189@DervishD> X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh Subject: Re: Emulating 'locate' MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii [We should just go off and have our own little mailing list.] On Oct 2, 12:17am, DervishD wrote: } } Well, I suppose that slashes must be } matched explicitly (that is what ** is for...) No, that is what **/ is for. Each **/ (but not /**) triplet is replaced by zero or more levels of hierarchy. It's the trailing slash that makes ** magical; without it ** is just like *. Actually to be entirely accurate, not _every_ **/ triplit is so replaced; the **/ has to be the only thing in one level of hierarchy, i.e., it can't be foo**/ either. } Let do 'locate ir2'. The list of output files is the same as } 'locate ir3' (well, it outputs a couple of dirs more). But if I do } 'print -l /**/*ir2*/**' I only get '/dir1/dir2/dir3' :((( In fact, } adding more ** doesn't work: 'print /**/*ir2*/**/**' just outputs } '/dir1/dir2/ /dir1/dir2/dir3/ /dir1/dir2/dir3' That last should have done almost what you wanted, except the final * is redundant. I suspect you really did print /**/*ir2*/*/** ^^^ Note only one star here when you meant print /**/*ir2*/**/* But that's still not sufficient, because it requires that *ir2* be only an intervening directory and not the last file or directory in the path. For that you have to use brace expansion, because you can't mix **/ and any other form of alternation: print -l /**/*ir2*{,/**/*} So "locate" would be e.g. locate() { print -l /**/*${^*}*{,/**/*} } (You really ought to be sending these questions to -users, not -workers.) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net