[Pkg-zsh-devel] Bug#875460: Fwd: `rm *` count is incorrect with `setopt GLOB_DOTS`

Bart Schaefer schaefer at brasslantern.com
Tue Apr 17 01:27:54 BST 2018


The below patch (with mangled whitespace corrected) should be in the
zsh 5.5.1 release.

---------- Forwarded message ----------
From: Bart Schaefer <schaefer at brasslantern.com>
Date: Fri, Apr 13, 2018 at 6:48 PM
Subject: Re: `rm *` count is incorrect with `setopt GLOB_DOTS`
To: zsh-workers at plast.id.au
Cc: "zsh-workers at zsh.org" <zsh-workers at zsh.org>


On Fri, Apr 13, 2018 at 5:23 PM,  <zsh-workers at 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;



More information about the Pkg-zsh-devel mailing list