From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5542 invoked from network); 1 Jul 2020 11:34:08 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 1 Jul 2020 11:34:08 -0000 Received: (qmail 24875 invoked by alias); 1 Jul 2020 11:33:58 -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: Sender: zsh-workers@zsh.org X-Seq: 46171 Received: (qmail 9661 invoked by uid 1010); 1 Jul 2020 11:33:58 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f66.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25857. spamassassin: 3.4.4. Clear:RC:0(209.85.166.66):SA:0(-2.0/5.0):. Processed in 1.413193 secs); 01 Jul 2020 11:33:58 -0000 X-Envelope-From: mikachu@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.66 as permitted sender) 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:content-transfer-encoding; bh=yNHL686ooaOj6Dp7rE6FBodlw6T5ifXvld/H8R/h+LI=; b=KVLrk5TNQgyw4huIA9QMXROI1NLTYK+fjCBjbM2XE2Uy6lGZCT/3eHoR1clYdwIjX7 LiIGhMyOMNBLa4YXGckq6iSKjdT5yWKVXdn5EValmSmXjs24JnoLlmFKrjpyOoEwMGyW AOeSDrAjoxzccOY6jJ0NLXwaqrYWd+yNMwQXDlzavRmEwHS+hQh60wSMj20tKVUviZwO 2f7sMciv6maFOYpz9Pi8vIFszt99qsObBk+CvENpUqjvXEB/BDWNTqmjcvKTR9nfllaC 5O6C4rb1GKp9q++3+oc4RX62hpj2vL50DmlZcSUxPm9ilaLrMzOs/Obm3HlSrF7g7CNv lTzQ== X-Gm-Message-State: AOAM530ScSXgbHEuFkqrFv8qa9qu1ywdwR2Jh2SRyufbNmqxdyGoOP4h DUhC/cvkO9wH1Kzjp5oTDOS4M2PI2iQ0RgP5svBTuQ== X-Google-Smtp-Source: ABdhPJz6ZxRML79ZbHaQbRxkIfaAok2jqLER78wNks7dveCIfCLhuKJ85bfWrF3HMXrqBnEcFp7BXd30IO/4JGZbqCo= X-Received: by 2002:a6b:5b14:: with SMTP id v20mr1828705ioh.182.1593603203035; Wed, 01 Jul 2020 04:33:23 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20200701110025.38f498d5@tarpaulin.shahaf.local2> References: <7438d554-ae4d-01c9-84c1-993227efd6f4@braeutigamj.de> <20200701110025.38f498d5@tarpaulin.shahaf.local2> From: Mikael Magnusson Date: Wed, 1 Jul 2020 13:33:22 +0200 Message-ID: Subject: Re: [Bug] incorrect warning when I type rm /* To: Daniel Shahaf Cc: =?UTF-8?Q?Jonas_Br=C3=A4utigam?= , zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 7/1/20, Daniel Shahaf wrote: > Jonas Br=C3=A4utigam wrote on Wed, 01 Jul 2020 12:02 +0200: >> Hello, >> >> these days I wrote a command wrong. Instead of >> >> "$ rm ./*" <- deleting in the current directory >> >> I wrote: >> >> "$ rm /*" <- deleting in the root path "/" >> >> zsh warn me with: >> >> "zsh: sure you want to delete all 4 files in /home/[user]/Downloads >> [yn]?" >> >> After I typed "y", it tried to delete the files in "/". >> >> So the correct warning should be: >> >> "zsh: sure you want to delete all X files in / [yn]?" >> >> >> I use debian 10.4 with no "rm"-specifiy plugin. >> >> >> Whatch out If you try it! :D > > Thanks; it's a path arithmetic edge case: > > diff --git a/Src/exec.c b/Src/exec.c > index 045b5d2b9..7120a2c34 100644 > --- a/Src/exec.c > +++ b/Src/exec.c > @@ -3401,7 +3401,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, > int rmall; > > s[l - 2] =3D 0; > - rmall =3D checkrmall(s); > + rmall =3D checkrmall(l =3D=3D 2 ? "/" : s); > s[l - 2] =3D t; > > if (!rmall) { > > The "Is the dir empty?" logic likewise operated on $PWD rather than /, > so if someone runs =C2=ABrm /*=C2=BB as root in an empty directory, the > RM_STAR_SILENT confirmation prompt would not appear at all. > > I haven't figured out how to write a test for this (short of using > expect(1) or so). zpty_start and variants as in W02jobs, X02zlevi and others? --=20 Mikael Magnusson