diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2004-04-01 18:33:05 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2004-04-01 18:33:05 +0000 |
commit | fda060370fe0f6abe71be309c71ee7658adfc647 (patch) | |
tree | ce0606288081e9ea16bf4d5138962a19654c2a81 | |
parent | 1f03c7a78412984bd7153c996be2a9c530893bf2 (diff) | |
download | zsh-fda060370fe0f6abe71be309c71ee7658adfc647.tar.gz zsh-fda060370fe0f6abe71be309c71ee7658adfc647.tar.xz zsh-fda060370fe0f6abe71be309c71ee7658adfc647.zip |
19717: (F) glob qualifier for full directories
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Doc/Zsh/expn.yo | 3 | ||||
-rw-r--r-- | Src/glob.c | 24 |
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; +} |