Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
'rm foo * bar' and answering 'n' runs 'rm foo bar'
- X-seq: zsh-workers 42060
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: 'rm foo * bar' and answering 'n' runs 'rm foo bar'
- Date: Wed, 29 Nov 2017 17:19:33 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=4aXGT22qkgVw+XgSvthsANXPsa5D4 HICihuLMC1xFYA=; b=YMDlyi41Tc4laTyOQ2WrRf4zs7W9u0A3zXDidm5HKs/YR q7cl4Y4WsRqJWzUYU0W+e7pH3z+3Uq1YqYF/6n8IjyuueyFU+C2LZhQTNHk8IpHb Qd94JHv6hgrFqAsT6+kSOayjpPdn2oIeUz5Z+B2L5nvU6PPBD/scCLYY3NAGDolp dwv1BJL/BUSvxwQsS6pw7GfAyHn2X7wIR9SgwYFFVs5RlOvFnpURRisLv0pqdtuu KsI9jvFqT/sSrmu0Jjf5djRXLtz0+GBXfx5GC0Yw4DE4CGARYyMetHOs4EI0iyKR zFriPTha2bw3nCZU5J9e8MRZZYDQWoz9UIQ36cROw==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=4aXGT22qkgVw+XgSvthsANXPsa5D4 HICihuLMC1xFYA=; b=dFdtXp+MLvvLgLJ25nzgnODQVsnmmyyrnt+y4cHDkkimr n5cNNqMShtksWVolnCVcgVX5Y08Hvw7ILvVVM+2XE6f4jX0uXvUvHUml6fcefuc9 PYyP/0EfX1WYv/JMwcuODlPG3x1FhyTagQ4bTVuaox3kwilrSY23hbRzGDS4F8O0 C2ljwPQNi3XUi2XrE6QfDhZ1UTVSuByVyUU9Ej+KDZEm7fF9frKrEwGPLigU7uHM k7IKQqJ1fTNc1R5nh5HNNvWbkUBzRj85Mq5yg8Aj7qWKwzzQHWDhWel8KsrPSZIk wqhhFt4mz5y/ZRrZDwYOoQzuiUuSkfrOTeynhdvUQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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