summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/expn.yo3
-rw-r--r--Src/glob.c24
3 files changed, 32 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 7cbde83b4..9de5f73de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-04-01  Peter Stephenson  <pws@pwstephenson.fsnet.co.uk>
+
+	* 19717: Doc/Zsh/expn.y, Src/glob.c: use F glob qualifier
+	for `full' (non-empty) directories.
+
 2004-03-31  Bart Schaefer  <schaefer@zsh.org>
 
 	* unposted: Functions/Misc/zrecompile: change "mv" to "mv -f"
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index f61cb7aa8..118040b00 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -1630,6 +1630,9 @@ startitem()
 item(tt(/))(
 directories
 )
+item(tt(F))(
+`full' (i.e. non-empty) directories
+)
 item(tt(.))(
 plain files
 )
diff --git a/Src/glob.c b/Src/glob.c
index 857afc5fd..c0d23aa00 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1322,6 +1322,9 @@ zglob(LinkList list, LinkNode np, int nountok)
 		    func = qualmodeflags;
 		    data = qgetmodespec(&s);
 		    break;
+		case 'F':
+		    func = qualnonemptydir;
+		    break;
 		case 'M':
 		    /* Mark directories with a / */
 		    if ((gf_markdirs = !(sense & 1)))
@@ -2799,3 +2802,24 @@ qualsheval(char *name, struct stat *buf, off_t days, char *str)
     }
     return 0;
 }
+
+/**/
+static int
+qualnonemptydir(char *name, struct stat *buf, off_t days, char *str)
+{
+    DIR *dirh = opendir(name);
+    struct dirent *de;
+
+    if (dirh == NULL)
+	return 0;
+
+    while ((de = readdir(dirh))) {
+	if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
+	    closedir(dirh);
+	    return 1;
+	}
+    }
+
+    closedir(dirh);
+    return 0;
+}