Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: rfc patch, abort rm instead of only removing the * from the cmdline
- X-seq: zsh-users 13148
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>
- Subject: Re: rfc patch, abort rm instead of only removing the * from the cmdline
- Date: Sun, 17 Aug 2008 07:57:18 +0100
- Cc: Richard Hartmann <richih.mailinglist@xxxxxxxxx>, zsh-users <zsh-users@xxxxxxxxxx>
- In-reply-to: <237967ef0808161358y5deae840xe3bd399d01d198f@xxxxxxxxxxxxxx>
- Mail-followup-to: Mikael Magnusson <mikachu@xxxxxxxxx>, Richard Hartmann <richih.mailinglist@xxxxxxxxx>, zsh-users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <237967ef0808151649j1d14ce23s1acad02da98fdfdf@xxxxxxxxxxxxxx> <2d460de70808160858p5312805dlf1c9976a9b702a51@xxxxxxxxxxxxxx> <237967ef0808160902p4dbc6d73w6620f6c69471ea20@xxxxxxxxxxxxxx> <20080816205209.GA5176@xxxxxxxxxxxxxxx> <237967ef0808161358y5deae840xe3bd399d01d198f@xxxxxxxxxxxxxx>
On Sat, Aug 16, 2008 at 10:58:19PM +0200, Mikael Magnusson wrote:
[...]
> It looks like it does abort the command if the * is the _only_ argument...
> I couldn't check easily as I already have the patch applied :).
>
> % rm * --help
> zsh: sure you want to delete all the files in /home/mikachu/a [yn]? n
> Usage: rm [OPTION]... FILE...
> Remove (unlink) the FILE(s).
[...]
OK, I can reproduce it now. And I agree with you it wasn't quite
what I expected. But then, I think the fix should rather be
something like:
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.140
diff -p -u -r1.140 exec.c
--- Src/exec.c 13 Aug 2008 21:02:02 -0000 1.140
+++ Src/exec.c 17 Aug 2008 06:56:17 -0000
@@ -2547,19 +2547,24 @@ execcmd(Estate state, int input, int out
next = nextnode(node);
if (s[0] == Star && !s[1]) {
- if (!checkrmall(pwd))
- uremnode(args, node);
+ if (!checkrmall(pwd)) {
+ errflag = 1;
+ 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))
- uremnode(args, node);
+ rmall = checkrmall(s);
s[l - 2] = t;
+
+ if (!rmall) {
+ errflag = 1;
+ break;
+ }
}
}
- if (!nextnode(firstnode(args)))
- errflag = 1;
}
if (errflag) {
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author