Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

rfc patch, abort rm instead of only removing the * from the cmdline



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



Messages sorted by: Reverse Date, Date, Thread, Author