From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20666 invoked by alias); 21 Sep 2013 08:30:17 -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: 17989 Received: (qmail 24248 invoked from network); 21 Sep 2013 08:30:11 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130921013028.ZM17637@torch.brasslantern.com> Date: Sat, 21 Sep 2013 01:30:28 -0700 In-reply-to: <20130920233930.GB4501@localhost.localdomain> Comments: In reply to Han Pingtian "Re: question about glob qualifier format (#qx)" (Sep 21, 7:39am) References: <20130920111110.GA4501@localhost.localdomain> <20130920123830.30111071@pwslap01u.europe.root.pri> <20130920233930.GB4501@localhost.localdomain> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: question about glob qualifier format (#qx) MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 21, 7:39am, Han Pingtian wrote: } } But I'm still confusing on the manpage :) } } If I want to list all symbolic links and directories in current } directory, this expression doesn't work: } } $ echo (*(#q@)|*(#q/)) A few lines above the excerpt you previously quoted from the manual, it says: If the option EXTENDED_GLOB is set, a different syntax for glob qualifiers is available, namely `(#qx)' where x is any of the same glob qualifiers used in the other format. The qualifiers must still appear at the end of the pattern. } I cannot see any difference between '(#qx)' format and 'bare glob } qualifier' format on being disabled by '|', '('. Please advise. The difference is with e.g. (.). With BARE_GLOB_QUAL, *(.) matches all plain files. With NO_BARE_GLOB_QUAL, *(.) matches files whose name ends in a dot, and *(#q.) is needed to match all plain files. } we must write it as : } } $ echo *(#q@) *(#q/) More than one of these lists can be combined, separated by commas. The whole list matches if at least one of the sublists matches (they are `or'ed, the qualifiers in the sublists are `and'ed). So: % echo *(#q@,/) *should* do what you want, but see below about potential bugs .... I accidentally encountered some odd behavior while confirming this. With NO_EXTENDED_GLOB, #q is not supposed to be available to introduce qualifiers. However % setopt NO_EXTENDED_GLOB % echo *(#q@) Whereas % echo *(#q/) zsh: unknown file attribute This is inconsistent, that is, sometimes (#q@) will also give "unknown" and (#q/) will work. The more I play with it the less consistently it behaves. *(#q@,/) may produce any of zsh: unknown file attribute zsh: bad pattern: *(#q@,/) or the intended list of files, depending on ... well, I can't tell what it depends on, possibly previous globs or what the current directory is, or how often EXTENDED_GLOB or BARE_GLOB_QUAL have been toggled on and off. In fact once I even got: % setopt CSH_NULL_GLOB % print -l *(#q@) *(#q/) zsh: bad pattern: *(#q/) (even when */ matches several directories, and *(/) matches them with BARE_GLOB_QUAL). So something about the parsing for #q may be wonky. All of this works very nicely when BARE_GLOB_QUAL is enabled, which it is by default, which is probably why nobody noticed before that #q is doing strange things.