From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5311 invoked by alias); 14 Apr 2018 01:48:29 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42636 Received: (qmail 7824 invoked by uid 1010); 14 Apr 2018 01:48:29 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf0-f44.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.215.44):SA:0(-1.9/5.0):. Processed in 2.146738 secs); 14 Apr 2018 01:48:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIMWL_WL_MED,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oN5Lqd2Du8PA0aTo9YCo2aD8DfhKxO3JDIvSvjuGhK8=; b=obb/A3T/uNL34p2hLDLCKjxXZwQEg4EvRjXnXUIxk4QU+qIEi572EidMWNyQ3WgvOh Q5mD6oB20e/Fk8ZgvpobFR/tRPpthEa9oswMnX6jYN/WKPvFyF7NBZq6Jwk2dbWNMGXL 4dRI3UCwQz3LLCVbxGg+NqTYyyGvkC5QCsy9tjSaAHZNBH4dz0QXZ8VsG+Ihp9JePPPE Eh+Nf9poGUh6p4sbx+S96IIWVA6z6gR30Bl3Jl7fJNr0oZSzYzxmHR87O3BfcXn4QMWS VsTIztKxfKLeT/47FENT4J/FhsllkyKr8t9ZgBptB4+YsGhe/H8gbP5Bdxba4ZN3uz/1 aAxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oN5Lqd2Du8PA0aTo9YCo2aD8DfhKxO3JDIvSvjuGhK8=; b=tLxjRdi54lDjTl55WDTe0XYtXHDaHNZJxFJP69U6GTn5UJ6xND/I3ds/BqfEwXZ8yr cwdPSBGPXofgQFM4Zif7I3F32w5WnCwtUBkUkf2G8+rYOncMCk0/9tqIiimFCpPrkv25 QJJTYEQmFx4M/vKhhMmW81C0+yxU+mWPRvKmyttTr7zwAdqzHj8Jqeof4Nq1HaBOuTBO 513y/QFQVkv1ueUMo5JaDdWIHfUqSV9oFK/uUejnqjx5Pl5Vp76OdfjeIJmtSc0iEFOb WUMCpBEnoQv91tBk3Iv+zAMfdJydfg4hd2Wvs4FgfQ3/I0HgGBmJ8bLbJpsvXWmo5O6D EkIw== X-Gm-Message-State: ALQs6tAON5l9fIrBFGWYUZvEjs4oNij85RfyaklsqJLSKevqPyOWG7Wj wSj97zabOIe306vXY5WudUBXgUVadpxxZuN5Y9XVxDMA X-Google-Smtp-Source: AIpwx4+f87Xg6MMUCLa/6JZY+/PyWXkdNd8WrlP4YeetUXpjceaOXeQwBvKOAIrd/G/ENGrqZBu5NLwOnLlNauW9oLE= X-Received: by 10.46.48.15 with SMTP id w15mr4488388ljw.79.1523670503118; Fri, 13 Apr 2018 18:48:23 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20180414002342.oon7lfuxt6msti7i@message.id> References: <20180414002342.oon7lfuxt6msti7i@message.id> From: Bart Schaefer Date: Fri, 13 Apr 2018 18:48:22 -0700 Message-ID: Subject: Re: `rm *` count is incorrect with `setopt GLOB_DOTS` To: zsh-workers@plast.id.au Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" On Fri, Apr 13, 2018 at 5:23 PM, 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 . - */ - while (zreaddir(rmd, ignoredots)) { + char *fname; + + while ((fname = zreaddir(rmd, 1))) { + if (ignoredots && *fname == '.') + continue; count++; if (count > max_count) break;