16 Aug 01:45
rfc patch, abort rm instead of only removing the * from the cmdline
From: Mikael Magnusson <mikachu <at> gmail.com>
Subject: rfc patch, abort rm instead of only removing the * from the cmdline
Newsgroups: gmane.comp.shells.zsh.user
Date: 2008-08-15 23:49:08 GMT
Expires: This article expires on 2008-08-30
Subject: rfc patch, abort rm instead of only removing the * from the cmdline
Newsgroups: gmane.comp.shells.zsh.user
Date: 2008-08-15 23:49:08 GMT
Expires: This article expires on 2008-08-30
It surprised me that this isn't already what happens, what do others think?
Imagine for example the typo
% rm -rf * /tmp
Before, even if you said no to the prompt, it will remove all your
files in /tmp.
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2515,13 +2515,13 @@ execcmd(Estate state, int input, int output,
int how, int last1)
next = nextnode(node);
if (s[0] == Star && !s[1]) {
if (!checkrmall(pwd))
- uremnode(args, node);
+ return;
} else if (l > 2 && s[l - 2] == '/' && s[l - 1] == Star) {
char t = s[l - 2];
s[l - 2] = 0;
if (!checkrmall(s))
- uremnode(args, node);
+ return;
s[l - 2] = t;
}
}
--
--
Mikael Magnusson
(Continue reading)
RSS Feed