Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [Bug] incorrect warning when I type rm /*
Jonas Bräutigam 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] = 0;
- rmall = checkrmall(s);
+ rmall = checkrmall(l == 2 ? "/" : s);
s[l - 2] = t;
if (!rmall) {
The "Is the dir empty?" logic likewise operated on $PWD rather than /,
so if someone runs «rm /*» 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author