From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25540 invoked by alias); 26 Nov 2014 18:00:29 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19447 Received: (qmail 8078 invoked from network); 26 Nov 2014 18:00:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=nIvEjsXhj4BYhD5gOr726SDyrB9DCKWZXwx3KgeZ0lY=; b=PqcpatetxGMtnE7DMbtkonOcpPl6UdaMudsTYfhDasvLKrwTrK70LasscE9d7WXWE5 kQcR3QiHAssh44D+/av+mOjEdLWUhKde41OMwYFuvfda38MIGJsXhmj60JRCpmjjhVIV wndkIijHlq9odQ5zXjc3Lo1Xq900PnyLntkzZJk2APSFKxnrWvxdp/v2lHw6h43iTuAW 7q0FLJlUTaC/is744JgWDonrdMdwzJNRQ/z3DjIuZpMYx7HeVZK2P3YzojJ3jQq9gdHp Dkn71xcl1cvVOjB0UwvofW0j/SGgVv7nMh+3p1rPG5awsnShQWxZaT0tbtgBDNZH8i6H Jkkw== MIME-Version: 1.0 X-Received: by 10.50.67.113 with SMTP id m17mr4418257igt.4.1417024823433; Wed, 26 Nov 2014 10:00:23 -0800 (PST) In-Reply-To: References: Date: Wed, 26 Nov 2014 19:00:23 +0100 Message-ID: Subject: Re: Glob specifiers for intermediate path components From: Mikael Magnusson To: =?UTF-8?B?SsO2cmcgWmllZmxl?= Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Nov 26, 2014 at 6:32 PM, J=C3=B6rg Ziefle = wrote: > Suppose I have the following directory structure: > > $ mkdir a > $ touch a/1 > $ ln -s a b > $ ls -ld a b a/1 > drwxr-xr-x 3 jozi staff 102 Nov 26 18:27 a > -rw-r--r-- 1 jozi staff 0 Nov 26 18:27 a/1 > lrwxr-xr-x 1 jozi staff 1 Nov 26 18:27 b -> a > > Globbing for files within directories, I get the file within the > directory pointed by symlink b too: > > $ print -l */*(.) > a/1 > b/1 > > How can I restrict the globbing for the first directory level to > directories only, excluding symlinks to directories? The obvious > doesn't work: > > $ print -l *(/)/*(.) > zsh: bad pattern: *(/)/*(.) > > More generally, how can I specify glob qualifiers for intermediate > path components? In spirit: > > $ print -l a(...)/b(...)/c(...)/d(...)/e(...)/f(...) > > where (...) denotes glob qualifiers for the respective path components, o= r even: > > $ print -l {{a(...)/b(...)}/c(...)} You can't, as such. There are at least two workarounds I can think of. print -l a(/e:'REPLY=3D$REPLY/b(/)':) (this one quickly gets messy to nest) () { print -l $^@/b(/) } a(/) () { () { print -l $^@/c(/) } $^@/b(/) } a(/) You may need to add N in the glob quals here too, or intermediate directories with no children would produce a glob error. Note more specifically also that **/*(.) does not recurse through symlinks to directories, ***/*(.) would. --=20 Mikael Magnusson