From a92d2d84c01b01882133ea508c043ea11de07271 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 10 Jan 2005 17:31:07 +0000 Subject: 20661: *(+func) = *(e:func:) --- ChangeLog | 5 +++++ Doc/Zsh/expn.yo | 16 +++++++++++++++- Src/glob.c | 31 ++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 896948344..961b34fe1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-01-10 Peter Stephenson + + * 20661: Doc/Zsh/expn.yo, Src/glob.c: allow (+func) as shorthand + for (e:func:) in glob qualifier. + 2005-01-10 Oliver Kiddle * 20662: Completion/X/Command/_nedit: update for nedit 5.5 diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 5d05601d5..eb9909cfc 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -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) diff --git a/Src/glob.c b/Src/glob.c index 5519e0e02..c1f2fc0dc 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -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 (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) { - zerr("missing end of string", NULL, 0); + 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; } -- cgit 1.4.1