From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14311 invoked from network); 4 Feb 2003 05:16:44 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 4 Feb 2003 05:16:44 -0000 Received: (qmail 14017 invoked by alias); 4 Feb 2003 05:16:23 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5869 Received: (qmail 14010 invoked from network); 4 Feb 2003 05:16:23 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 4 Feb 2003 05:16:23 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.46.181.248] by sunsite.dk (MessageWall 1.0.8) with SMTP; 4 Feb 2003 5:16:22 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h145GO315384 for zsh-users@sunsite.dk; Mon, 3 Feb 2003 21:16:24 -0800 From: "Bart Schaefer" Message-Id: <1030204051624.ZM15383@candle.brasslantern.com> Date: Tue, 4 Feb 2003 05:16:23 +0000 In-Reply-To: <20030204032905.15019.qmail@web12308.mail.yahoo.com> Comments: In reply to Le Wang "Re: check for existence without full globbing" (Feb 3, 10:29pm) References: <20030204032905.15019.qmail@web12308.mail.yahoo.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh users list Subject: Re: check for existence without full globbing MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Feb 3, 10:29pm, Le Wang wrote: } } I need to get a list of directories that have .java files in them. Here is } the snipplet: } } for i ( $sourcePath ) { } for j ( $i/**/*(-/) ) { The (-) qualifier there probably doesn't do what you think. **/ won't descend through symlinks, so **/*(-/) will not descend beyond the first symlink in any path. Hence you'll only find the .java files that are directly within the symlinked directories, not those in any subdirs of the symlinked directories, if you see what I mean. If you can be sure the symlinks don't cycle, you can use ***/ instead. } setopt localoptions } setopt nullglob } unsetopt globsubst } tempArr=( $j/*.java ) } } if (( $#tempArr >= 1 )); then } temp=${j#$i/} } temp=${temp//\\//.} } packages=( $packages $temp ) } fi } } } } } } It was taking quite a while to glob through all the .java files. I'll bet it's taking much longer to do the ${j#$/} ${temp//\\//.} stuff, plus packages=( $packages $temp ), in a loop, than to do the globbing. And you should almost never put setopt/unsetopt commands inside a loop body, because they don't revert at the end of the loop (only at the end of a shell function), so all you're doing every time around is resetting something that's already set. Try this and see if it's faster: typeset -U packages packages=( ${~~^sourcePath}/./**/*(N-/) ) packages=( ${~~^packages}/**/*.java(N:h) ) packages=( ${${~~packages##*/./}:gs,/,.} ) The double tildes in ${~~...} turn off globsubst for that expansion, and the N turns on nullglob, so you don't have to mess around with setopt. -- 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