Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [Patch] No warnings for `rm /*`
- X-seq: zsh-workers 38350
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [Patch] No warnings for `rm /*`
- Date: Tue, 26 Apr 2016 10:36:24 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=bBMzpgMV0KepqG+v0tTRJkxs955rT8e4trjIDA5n2hE=; b=DHo611qy4aK9ApdS29PAyXHDwi5lGx1V0mYUf2Y/xN30PkEPC54Wb6takadr7ZGgP9 SreIGWHbg8rJ6z3puFj/gH3qqf/54Aba+rfrdNFRaREoHetv1xwkQJAScltdcjUyD+xP LerlsdOPTtFoWf/z++wBeQhBrUONJxXl1mWvBCYnCJNTiPTvuTGeGhlu7aCrsbDempFQ bz/sAdfwO2kb28YpnGehiIFyQwbBAjccfCXYGkiX+Ujl0hBDKTs+oTECXwf/c2q3iK0O kf44lyvYauO0RDju/IocTJDqppm1QQLtL5PtxVxUcMKVPLJ8JuZFj5TePuaP/xYtDErK +aXQ==
- In-reply-to: <CAN3Cs_H0Uz8c7Du53UfvoRcob5zcU8KkNeqHn6vVGaguxNHK9A@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAN3Cs_H0Uz8c7Du53UfvoRcob5zcU8KkNeqHn6vVGaguxNHK9A@mail.gmail.com>
On Apr 26, 10:31am, Glenn Smith wrote:
} Subject: [Patch] No warnings for `rm /*`
}
} I discovered that zsh warns in every case except `rm /*`.
Thanks. I think the following simpler patch does the same.
diff --git a/Src/exec.c b/Src/exec.c
index 50eff72..2dcd5bc 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2902,11 +2902,11 @@ execcmd(Estate state, int input, int output, int how, int last1)
if (s[0] == Star && !s[1]) {
if (!checkrmall(pwd))
uremnode(args, node);
- } else if (l > 2 && s[l - 2] == '/' && s[l - 1] == Star) {
+ } else if (l >= 2 && s[l - 2] == '/' && s[l - 1] == Star) {
char t = s[l - 2];
s[l - 2] = 0;
- if (!checkrmall(s))
+ if (!checkrmall(*s ? s : "/"))
uremnode(args, node);
s[l - 2] = t;
}
As an aside:
% rm /nonexistentdir/*
zsh: sure you want to delete all the files in /nonexistentdir [yn]?
Seems like we could detect when opendir() fails with ENOENT and skip
the prompt, but maybe there are cases of race condition (directory is
created after I type "rm ..." but before /bin/rm is executed?) where
the default answer of "y" would be incorrect.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author