Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: question about glob qualifier format (#qx)

On Fri, Sep 20, 2013 at 12:38:30PM +0100, Peter Stephenson wrote:
> On Fri, 20 Sep 2013 19:11:10 +0800
> Han Pingtian <hanpt@xxxxxxxxxxxxxxxxxx> wrote:
> > I'm confused about the usage of glob qualifier format "(#qx)". The man
> > page says:
> > 
> >        				......    Also, as the syntax  is  unambiguous,
> >        the  expression  will  be  treated  as glob qualifiers just as long any
> >        parentheses contained within it are balanced; appearance of `|', `(' or
> >        `~'  does  not  negate the effect. 
> > 
> > But looks like if I put them in parentheses, it will not take effect any more:
> > 
> > 	
> > 	$ ls
> > 	1.c  2.h  a  b  slink
> > 	$ echo *((#q/))
> > 	1.c 2.h a b slink
> > 
> > So I'd like to know how to comprehend the manpage here? Thanks in
> > advance!
> Because of the ambiguity between glob qualifiers without the #q and
> parenthesised groups, the shell guesses which is which.  An expression
> containing "|" makes it guess that it's a parenthesised group rather
> than a set of glob qualifiers.  However, if the *first* open parenthesis
> (there's no reason to double them) is followed by #q (and EXTENDED_GLOB
> is set), it knows for sure that this is a glob qualifier, so it doesn't
> need to do any guessing.
> This is there as an additional help; you don't need to change your
> normal use of glob qualifiers just because you've signalled them
> explicitly with #q.  (#q/) works fine.
> pws

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/))

we must write it as :

    $ echo *(#q@) *(#q/)

I cannot see any difference between '(#qx)' format and 'bare glob
qualifier' format on being disabled by '|', '('. Please advise. Thanks.

Messages sorted by: Reverse Date, Date, Thread, Author