summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2014-06-04 22:47:20 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2014-06-04 22:47:20 -0700
commit69378db3c53cea12d8c5f20380de5017e4e72611 (patch)
treeada7373380c4d7dc552c9ebc0cbe9cecc814aef2
parent9381bb6a2d3abd4a4c6871b5676f9fb04f42d921 (diff)
downloadzsh-69378db3c53cea12d8c5f20380de5017e4e72611.tar.gz
zsh-69378db3c53cea12d8c5f20380de5017e4e72611.zip
32708: glob qualifier (Y) implies (oN)
plus incidental patch to avoid adding a meaningless bitvalue to sort-order flags
-rw-r--r--ChangeLog7
-rw-r--r--Doc/Zsh/expn.yo7
-rw-r--r--Src/glob.c7
-rw-r--r--Test/D02glob.ztst2
4 files changed, 18 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f210d1d7..bbbec84a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-06-04 Barton E. Schaefer <schaefer@zsh.org>
+
+ * Daniel Shahaf: 32708: Doc/Zsh/expn.yo, Src/glob.c,
+ Test/D02glob.ztst: glob qualifier (Y) implies (oN), plus
+ incidental patch to avoid adding a meaningless bitvalue to
+ sort-order flags
+
2014-06-03 Barton E. Schaefer <schaefer@zsh.org>
* Daniel Shahaf: 32694: Completion/Zsh/Type/_globquals,
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 2f91fec9d..ff9f2b177 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -2568,10 +2568,12 @@ item(tt(Y)var(n))(
enables short-circuit mode: the pattern will expand to at most var(n)
filenames. If more than var(n) matches exist, only the first var(n)
matches in directory traversal order will be considered.
+
+Implies tt(oN) when no tt(o)var(c) qualifier is used.
)
item(tt(o)var(c))(
specifies how the names of the files should be sorted. If var(c) is
-tt(n) they are sorted by name (the default); if it is tt(L) they
+tt(n) they are sorted by name; if it is tt(L) they
are sorted depending on the size (length) of the files; if tt(l)
they are sorted by the number of links; if tt(a), tt(m), or tt(c)
they are sorted by the time of the last access, modification, or
@@ -2586,6 +2588,9 @@ so `tt(*(^-oL))' gives a list of all files sorted by file size in descending
order, following any symbolic links. Unless tt(oN) is used, multiple order
specifiers may occur to resolve ties.
+The default sorting is tt(n) (by name) unless the tt(Y) glob qualifier is used,
+in which case it is tt(N) (unsorted).
+
tt(oe) and tt(o+) are special cases; they are each followed by shell code,
delimited as for the tt(e) glob qualifier and the tt(+) glob qualifier
respectively (see above). The code is executed for each matched file with
diff --git a/Src/glob.c b/Src/glob.c
index c74a56053..c6cb3d2fc 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1619,9 +1619,10 @@ zglob(LinkList list, LinkNode np, int nountok)
restore_globstate(saved);
return;
}
+ if ((sense & 2) &&
+ (t & (GS_SIZE|GS_ATIME|GS_MTIME|GS_CTIME|GS_LINKS)))
+ t <<= GS_SHIFT; /* HERE: GS_EXEC? */
if (t != GS_EXEC) {
- if ((sense & 2) && !(t & (GS_NAME|GS_DEPTH)))
- t <<= GS_SHIFT; /* HERE: GS_EXEC? */
if (gf_sorts & t) {
zerr("doubled sort specifier");
restore_globstate(saved);
@@ -1779,7 +1780,7 @@ zglob(LinkList list, LinkNode np, int nountok)
return;
}
if (!gf_nsorts) {
- gf_sortlist[0].tp = gf_sorts = GS_NAME;
+ gf_sortlist[0].tp = gf_sorts = (shortcircuit ? GS_NONE : GS_NAME);
gf_nsorts = 1;
}
/* Initialise receptacle for matched files, *
diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index c00bbe339..358c93413 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -546,7 +546,7 @@
(){ print $#@ } glob.tmp/dir*(Y1)
(){ print $#@ } glob.tmp/file*(NY1)
(){ [[ "$*" == */dir?\ */dir? ]] && print Returns matching filenames } glob.tmp/dir*(Y2)
- (){ print "Limit is upper bound:" $@:t } glob.tmp/dir*(Y5)
+ (){ print "Limit is upper bound:" ${(o)@:t} } glob.tmp/dir*(Y5)
(){ print "Negated:" $@:t } glob.tmp/dir*(Y1^Y)
(){ print "Sorting:" $@:t } glob.tmp/dir*(Y4On)
(){ [[ $#@ -eq 1 ]] && print Globs before last path component } glob.tmp/dir?/subdir(NY1)