The below patch (with mangled whitespace corrected) should be in the zsh 5.5.1 release.
---------- Forwarded message ---------- From: Bart Schaefer <schae...@brasslantern.com> Date: Fri, Apr 13, 2018 at 6:48 PM Subject: Re: `rm *` count is incorrect with `setopt GLOB_DOTS` To: zsh-work...@plast.id.au Cc: "zsh-work...@zsh.org" <zsh-work...@zsh.org> On Fri, Apr 13, 2018 at 5:23 PM, <zsh-work...@plast.id.au> wrote: > > When I run `rm *`, zsh asks if I "want to delete all x files", where x > is the number of files to be deleted. However, with `setopt GOB_DOTS`, > this number appears to be two more than the actual number of files. It's counting "." and ".." because, well, they begin with a dot. It's actually wrong any time the directory contains files beginning with ".", it's just LESS wrong when GLOB_DOTS. Apologies if this gets line-folded badly: diff --git a/Src/utils.c b/Src/utils.c index 180693d..2a006b4 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -2775,10 +2775,11 @@ checkrmall(char *s) const int max_count = 100; if ((rmd = opendir(unmeta(s)))) { int ignoredots = !isset(GLOBDOTS); - /* ### TODO: Passing ignoredots here is wrong. See workers/41672 - aka <https://bugs.debian.org/875460>. - */ - while (zreaddir(rmd, ignoredots)) { + char *fname; + + while ((fname = zreaddir(rmd, 1))) { + if (ignoredots && *fname == '.') + continue; count++; if (count > max_count) break;