From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20932 invoked from network); 28 Mar 2004 20:13:48 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 28 Mar 2004 20:13:48 -0000 Received: (qmail 5270 invoked by alias); 28 Mar 2004 20:13:36 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7281 Received: (qmail 5190 invoked from network); 28 Mar 2004 20:13:36 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 28 Mar 2004 20:13:36 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 28 Mar 2004 20:13:36 -0000 Received: (qmail 10052 invoked from network); 28 Mar 2004 20:13:32 -0000 Received: from sccimhc02.asp.att.net (63.240.76.164) by a.mx.sunsite.dk with SMTP; 28 Mar 2004 20:13:30 -0000 Received: from louisville.edu (12-220-223-80.client.insightbb.com[12.220.223.80]) by sccimhc02.asp.att.net (sccimhc02) with SMTP id <20040328201302im200rp6m8e>; Sun, 28 Mar 2004 20:13:02 +0000 Date: Sun, 28 Mar 2004 15:13:00 -0500 Subject: Re: Globbing for Empty Directories? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v553) From: Aaron Davies To: zsh-users@sunsite.dk Content-Transfer-Encoding: 7bit In-Reply-To: <1040328192147.ZM26160@candle.brasslantern.com> Message-Id: <4F9C0127-80F4-11D8-AA68-000502631FBD@louisville.edu> X-Mailer: Apple Mail (2.553) X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: ** X-Spam-Status: No, hits=2.4 required=6.0 tests=FROM_ENDS_IN_NUMS, RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 2.4 On Sunday, March 28, 2004, at 02:21 PM, Bart Schaefer wrote: > On Mar 28, 2:00am, Aaron Davies wrote: > } > } Is there a way to get empty directories from a glob pattern? > > There's some discusson of this in the archives from a few months ago. > > It's not possible to tell if a directory is empty without actually > looking > for files in it. So the best you can do is something like this: > > isempty() { > reply=( $REPLY/*(DN) ) > (( $#reply )) && unset reply || reply=( $REPLY ) > } > > print /path/to/emptydirectory(/e{isempty}) > > The (/) is important, otherwise you need to test [[ -d $REPLY ]] in the > isempty function (because as-is it matches files as well as empty > dirs). > If you want to follow symlinks to empty directories you need: > > print /path/to/emptydirectory(-/e{isempty}) > > It's much easier to get only NON-empty directories: > > print /path/to/nonempty/*(DN[-1]:h) > > In this case, though, symlinks are always followed because of appending > "/*" to the directory name, and there's not much to be done about it. Thanks much. In that case, could I make this a feature request? -- __ __ / ) / ) /--/ __. __ ________ / / __. , __o _ _ / (_(_/|_/ (_(_) / / <_ /__/_(_/|_\/ <__