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=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13876 invoked from network); 1 Jul 2020 12:51:03 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 1 Jul 2020 12:51:03 -0000 Received: (qmail 22288 invoked by alias); 1 Jul 2020 12:50:56 -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: 46172 Received: (qmail 19318 invoked by uid 1010); 1 Jul 2020 12:50:56 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.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(66.111.4.26):SA:0(-2.6/5.0):. Processed in 3.806729 secs); 01 Jul 2020 12:50:56 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrtddvgdehkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkjghfofggtgfgsehtqhdttdertdejnecuhfhrohhmpeffrghnihgv lhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenuc ggtffrrghtthgvrhhnpefhtdetfeehveeutdehuddtieefgeettedtjedtffehudeiieej leetteekudetheenucfkphepjeelrddujeeirdefledrieelnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhshhgr hhgrfhdrnhgrmhgv X-ME-Proxy: Date: Wed, 1 Jul 2020 12:50:10 +0000 From: Daniel Shahaf To: Mikael Magnusson Cc: Jonas =?UTF-8?B?QnLDpHV0aWdhbQ==?= , zsh-workers@zsh.org Subject: Re: [Bug] incorrect warning when I type rm /* Message-ID: <20200701125010.093a9755@tarpaulin.shahaf.local2> In-Reply-To: References: <7438d554-ae4d-01c9-84c1-993227efd6f4@braeutigamj.de> <20200701110025.38f498d5@tarpaulin.shahaf.local2> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Mikael Magnusson wrote on Wed, 01 Jul 2020 13:33 +0200: > On 7/1/20, Daniel Shahaf wrote: > > Jonas Br=C3=A4utigam wrote on Wed, 01 Jul 2020 12:02 +0200: =20 > >> 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 =20 > > > > 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). =20 >=20 > zpty_start and variants as in W02jobs, X02zlevi and others? Thanks for the pointer. I'll look when I have time, but if anyone can beat me to it, please do. Cheers, Daniel