20661: *(+func) = *(e:func:)

This commit is contained in:
Peter Stephenson 2005-01-10 17:31:07 +00:00
parent 9040271492
commit a92d2d84c0
3 changed files with 46 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2005-01-10 Peter Stephenson <pws@csr.com>
* 20661: Doc/Zsh/expn.yo, Src/glob.c: allow (+func) as shorthand
for (e:func:) in glob qualifier.
2005-01-10 Oliver Kiddle <opk@zsh.org>
* 20662: Completion/X/Command/_nedit: update for nedit 5.5

View File

@ -1739,7 +1739,8 @@ the owner and the other members of the group have at least write
permission, and for which other users don't have read or execute
permission.
)
item(tt(e)var(string))(
xitem(tt(e)var(string))
item(tt(PLUS())var(cmd))(
The var(string) will be executed as shell code. The filename will be
included in the list if and only if the code returns a zero status (usually
the status of the last command). The first character after the `tt(e)'
@ -1762,6 +1763,19 @@ For example, suppose a directory contains a single file `tt(lonely)'. Then
the expression `tt(*(e:'reply=(${REPLY}{1,2})':))' will cause the words
`tt(lonely1 lonely2)' to be inserted into the command line. Note the
quotation marks.
The form tt(PLUS())var(cmd) has the same effect, but no delimiters appear
around var(cmd). Instead, var(cmd) is taken as the longest sequence of
characters following the tt(PLUS()) that are alphanumeric or underscore.
Typically var(cmd) will be the name of a shell function that contains the
appropriate test. For example,
example(nt() { [[ $REPLY -nt $NTREF ]] }
NTREF=reffile
ls -l *(+nt))
lists all files in the directory that have been modified more recently than
tt(reffile).
)
item(tt(d)var(dev))(
files on the device var(dev)

View File

@ -1426,22 +1426,43 @@ zglob(LinkList list, LinkNode np, int nountok)
s++;
break;
}
case '+':
case 'e':
{
char sav, *tt = get_strarg(s);
char sav, *tt;
int plus;
if (!*tt) {
zerr("missing end of string", NULL, 0);
if (s[-1] == '+') {
plus = 0;
tt = s;
while (iident(*tt))
tt++;
if (tt == s)
{
zerr("missing identifier after `+'", NULL, 0);
tt = NULL;
}
} else {
plus = 1;
tt = get_strarg(s);
if (!*tt)
{
zerr("missing end of string", NULL, 0);
tt = NULL;
}
}
if (tt == NULL) {
data = 0;
} else {
sav = *tt;
*tt = '\0';
func = qualsheval;
sdata = dupstring(s + 1);
sdata = dupstring(s + plus);
untokenize(sdata);
*tt = sav;
if (sav)
s = tt + 1;
s = tt + plus;
else
s = tt;
}