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 2172 invoked from network); 1 Jul 2020 11:01:20 -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:01:20 -0000 Received: (qmail 5885 invoked by alias); 1 Jul 2020 11:01:14 -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: 46170 Received: (qmail 2181 invoked by uid 1010); 1 Jul 2020 11:01:14 -0000 X-Qmail-Scanner-Diagnostics: from out4-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.28):SA:0(-2.6/5.0):. Processed in 5.411741 secs); 01 Jul 2020 11:01:14 -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: gggruggvucftvghtrhhoucdtuddrgeduiedrtddvgdefiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkjghfofggtgfgsehtqhdttdertdejnecuhfhrohhmpeffrghnihgv lhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenuc ggtffrrghtthgvrhhnpefhtdetfeehveeutdehuddtieefgeettedtjedtffehudeiieej leetteekudetheenucfkphepjeelrddujeeirdefledrieelnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhshhgr hhgrfhdrnhgrmhgv X-ME-Proxy: Date: Wed, 1 Jul 2020 11:00:25 +0000 From: Daniel Shahaf To: Jonas =?UTF-8?B?QnLDpHV0aWdhbQ==?= Cc: zsh-workers@zsh.org Subject: Re: [Bug] incorrect warning when I type rm /* Message-ID: <20200701110025.38f498d5@tarpaulin.shahaf.local2> In-Reply-To: <7438d554-ae4d-01c9-84c1-993227efd6f4@braeutigamj.de> References: <7438d554-ae4d-01c9-84c1-993227efd6f4@braeutigamj.de> 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 Jonas Br=C3=A4utigam wrote on Wed, 01 Jul 2020 12:02 +0200: > Hello, >=20 > these days I wrote a command wrong. Instead of >=20 > "$ rm ./*" <- deleting=C2=A0 in the current directory >=20 > I wrote: >=20 > "$ rm /*" <- deleting in the root path "/" >=20 > zsh warn me with: >=20 > "zsh: sure you want to delete all 4 files in /home/[user]/Downloads [yn]?" >=20 > After I typed "y", it tried to delete the files in "/". >=20 > So the correct warning should be: >=20 > "zsh: sure you want to delete all X files in / [yn]?" >=20 >=20 > I use debian 10.4 with no "rm"-specifiy plugin. >=20 >=20 > 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; =20 s[l - 2] =3D 0; - rmall =3D checkrmall(s); + rmall =3D checkrmall(l =3D=3D 2 ? "/" : s); s[l - 2] =3D t; =20 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). Cheers, Daniel