* 'rm foo * bar' and answering 'n' runs 'rm foo bar' @ 2017-11-29 17:19 ` Daniel Shahaf 2017-11-30 9:41 ` Peter Stephenson 0 siblings, 1 reply; 2+ messages in thread From: Daniel Shahaf @ 2017-11-29 17:19 UTC (permalink / raw) To: zsh-workers [-- Attachment #1: Type: text/plain, Size: 688 bytes --] 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 [-- Attachment #2: 13148-rebased.patch --] [-- Type: text/x-diff, Size: 795 bytes --] 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) { ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: 'rm foo * bar' and answering 'n' runs 'rm foo bar' 2017-11-29 17:19 ` 'rm foo * bar' and answering 'n' runs 'rm foo bar' Daniel Shahaf @ 2017-11-30 9:41 ` Peter Stephenson 0 siblings, 0 replies; 2+ messages in thread From: Peter Stephenson @ 2017-11-30 9:41 UTC (permalink / raw) To: zsh-workers On Wed, 29 Nov 2017 17:19:33 +0000 Daniel Shahaf <d.s@daniel.shahaf.name> wrote: > 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). That seems reasonable --- it's hard to think of a negative consequence. pws ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-30 14:29 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20171129172023epcas2p2ad06101e98ecb0ffc5f52b45b8dd8af0@epcas2p2.samsung.com> 2017-11-29 17:19 ` 'rm foo * bar' and answering 'n' runs 'rm foo bar' Daniel Shahaf 2017-11-30 9:41 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).