From: Han Pingtian <hanpt@linux.vnet.ibm.com>
To: zsh-users@zsh.org
Subject: Re: question about glob qualifier format (#qx)
Date: Sat, 21 Sep 2013 07:39:30 +0800 [thread overview]
Message-ID: <20130920233930.GB4501@localhost.localdomain> (raw)
In-Reply-To: <20130920123830.30111071@pwslap01u.europe.root.pri>
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@linux.vnet.ibm.com> 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.
next prev parent reply other threads:[~2013-09-20 23:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-20 11:11 Han Pingtian
2013-09-20 11:38 ` Peter Stephenson
2013-09-20 23:39 ` Han Pingtian [this message]
2013-09-21 8:30 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130920233930.GB4501@localhost.localdomain \
--to=hanpt@linux.vnet.ibm.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).