From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: question about glob qualifier format (#qx)
Date: Sat, 21 Sep 2013 01:30:28 -0700 [thread overview]
Message-ID: <130921013028.ZM17637@torch.brasslantern.com> (raw)
In-Reply-To: <20130920233930.GB4501@localhost.localdomain>
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@)
<list of symlinks>
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.
prev parent reply other threads:[~2013-09-21 8:30 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
2013-09-21 8:30 ` Bart Schaefer [this message]
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=130921013028.ZM17637@torch.brasslantern.com \
--to=schaefer@brasslantern.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).