zsh-workers
 help / color / mirror / code / Atom feed
* `rm *` count is incorrect with `setopt GLOB_DOTS`
@ 2018-04-14  0:23 zsh-workers
  2018-04-14  1:48 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: zsh-workers @ 2018-04-14  0:23 UTC (permalink / raw)
  To: zsh-workers

Hello,

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.

$ zsh -f
% cd $(mktemp -d)
% touch foo bar
% rm *
zsh: sure you want to delete all 2 files in /tmp/tmp.cLNHQwcBW1 [yn]? n
% setopt GLOB_DOTS
% rm *
zsh: sure you want to delete all 4 files in /tmp/tmp.cLNHQwcBW1 [yn]?

I'm testing with zsh 5.5 on Arch Linux. I also reverted back to zsh 
5.3.1, and this issue was still present. However, I get the feeling that 
this issue wasn't around since that long ago, so the source of the 
problem could be something else (apologies in advance if it is).

Cheers.

P.S. I'm not subscribed to the mailing list, so please reply to this 
email address.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: `rm *` count is incorrect with `setopt GLOB_DOTS`
  2018-04-14  0:23 `rm *` count is incorrect with `setopt GLOB_DOTS` zsh-workers
@ 2018-04-14  1:48 ` Bart Schaefer
  2018-04-14 10:20   ` zsh-workers
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2018-04-14  1:48 UTC (permalink / raw)
  To: zsh-workers; +Cc: zsh-workers

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: `rm *` count is incorrect with `setopt GLOB_DOTS`
  2018-04-14  1:48 ` Bart Schaefer
@ 2018-04-14 10:20   ` zsh-workers
  0 siblings, 0 replies; 3+ messages in thread
From: zsh-workers @ 2018-04-14 10:20 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On Fri, Apr 13, 2018 at 06:48:22PM -0700, Bart Schaefer wrote:
> Apologies if this gets line-folded badly:

Ah okay. Thank you, that fixed it. I actually did find the url you 
quoted, which is obviously a similar problem. However, the zsh issue 
tracker is… difficult to navigate, so I presumed that this had been 
fixed a few versions ago. Apologies for the noise, and thank you for the 
reply!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-14 10:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-14  0:23 `rm *` count is incorrect with `setopt GLOB_DOTS` zsh-workers
2018-04-14  1:48 ` Bart Schaefer
2018-04-14 10:20   ` zsh-workers

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).