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

'rm foo * bar' and answering 'n' runs 'rm foo bar'



As the subject says:

$ zsh -f
% cd $(mktemp -d)
% touch foo bar baz
% rm foo * bar 
zsh: sure you want to delete all 3 files in /tmp/tmp.e9ZNT40K4y [yn]? n
% ls
baz
%

This is counter-intuitive: users expect 'n' to abort the command
entirely.

It was brought up nine years ago:

Thread starts: http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=13141
Stéphane's patch: http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=13148
Review: http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=13149
Review: http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=13150

So...  Shall we commit users/13148?

Mikael had a rebased version available, I've attached it (with
permission).

Cheers,

Daniel
diff --git a/Src/exec.c b/Src/exec.c
index bd64a2d28..3ac488a81 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3249,19 +3249,24 @@ execcmd_exec(Estate state, Execcmd_params eparams,
 
 	    next = nextnode(node);
 	    if (s[0] == Star && !s[1]) {
-		if (!checkrmall(pwd))
-		    uremnode(args, node);
+		if (!checkrmall(pwd)) {
+		    errflag |= ERRFLAG_ERROR;
+		    break;
+		}
 	    } else if (l >= 2 && s[l - 2] == '/' && s[l - 1] == Star) {
 		char t = s[l - 2];
+		int rmall;
 
 		s[l - 2] = 0;
-		if (!checkrmall(*s ? s : "/"))
-		    uremnode(args, node);
+		rmall = checkrmall(s);
 		s[l - 2] = t;
+
+		if (!rmall) {
+		    errflag |= ERRFLAG_ERROR;
+		    break;
+		}
 	    }
 	}
-	if (!nextnode(firstnode(args)))
-	    errflag |= ERRFLAG_ERROR;
     }
 
     if (type == WC_FUNCDEF) {


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