New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make 'rm -rf foo/' be a bit harder #14749
fix: make 'rm -rf foo/' be a bit harder #14749
Conversation
// if not back out vim#14742 // then make it be a bit harder to make mistake to rm all // // also seems recover its original logic of 'all' argument Signed-off-by: shane.xb.qian <shane.qian@foxmail.com>
@@ -11454,24 +11454,29 @@ fun! s:NetrwLocalRmFile(path,fname,all) | |||
|
|||
else | |||
" attempt to remove directory | |||
let rmfile= substitute(rmfile,'[\/]$','','e') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave the directory indicator. That is actually useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was there before this PR and #14742
i guess it was remained there for judging if it was a dir or not, i just kept it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this was not touched by #14742
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, so i didnot plan to touch it either.
// please notice that if/else
if !all | ||
echohl Statement | ||
call inputsave() | ||
let ok= input("Confirm *recursive* deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") | ||
" make it be a bit harder to make mistake by inputting upper case | ||
let ok= input("Confirm *recursive* deletion of directory<".rmfile."> ","[{Y(ES)},n(o),A(LL),q(uit)] ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you are unexpectedly changing the key-bindings. This will break peoples habits. I don't think this is appreciated by long-time users. (besides, it actually looks funny, that some keys need to be upper-cased and others not).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, i am not against just back out the #14742, then kept the appreciated long-time users' habits, or you had better idea not to so easy or high possibility to make mistake to rm all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What mistake, there is still a confirmation dialog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- lower case is easy to mis-type, like a 'hit-enter' happened.
- it was designed to: if 'all=1' then no 'confirm', else req a confirm, and confirm to only delete('rm', 'd') not 'rf'.
Okay, let's step back a bit for now. What problem are you trying to solve? I usually don't use netrw, but I just tried: Conversely, when I go back to commit d3952e8 (so before #14742) was merged, it errored out for a non-empty directory, even if I explicitly confirmed to delete. Which I do not find particular helpful. |
there 2 rm operation in netrw actually, one is 'local', another is 'remote', there some cfg about 'rm' for 'remote', but 'local' was designed to only delete('rmfile', 'd') not 'rf', |
Here you go again with the gatekeeping... |
i think it meant to make 'rm all' be harder, so if you'd like to keep #14742 , then wish you accept this enhance (and fix) too. |
Correct. But #14742 only changed the Sorry, I think the new behaviour makes a bit more sense to me. |
funny boy |
default for 'remote' is 'rmdir' which would not rm non-empty dir.
it changed:
|
This was not changed. It was like that before already.
This seems to happen when either:
|
i meant after #14742 when you mis-typed 'D' then lower case is easier to make mistake which compared to upper case you had to press 'shift' first, a.k.a 'SAFE'.
yes, seems those 2 places for now, but please note: " s:NetrwLocalRmFile: remove file fname given the path {{{2
" Give confirmation prompt unless all==1
fun! s:NetrwLocalRmFile(path,fname,all) when all == 1, it was designed to 'no confirm', in the future some places may call this fun too, supposed it is Not ok to rm all directly. |
endif | ||
let rmfile= substitute(rmfile,'[\/]$','','e') | ||
|
||
if all || ok =~# 'y\%[es]' || ok == "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also please note: i removed this ok == ""
though not sure when it would happen (or mostly it would not happen), but it scared me if i just pressed 'enter' somehow.
You already have to type capital
May be, or may be not. We don't have a netrw maintainer and I don't expect this to change soon. I think this needs to be taken care of, when new functions start calling it. But that is not something to worry about currently. Okay, let's close it then. I think we have verified that the current new version is fine and there is no issue. Sorry, I am not convinced that this change is a good one. |
ncdu is a gui-like diaglog for deletion, is it same?
um, i supposed we should not wait a knew problem to happen, there perhaps no regret to recover files once rm all.
anyway, if you were not like this PR, i can maintain this local hack to myself, no problem. |
It's a tui application. Like Vim is a tui application.
Let me repeat: There is currently not a known problem. |
it is gui-like diaglog, not a cli inputing yes/no/all/quit in vim, so to ncdu, users knew what he is doing, and mostly impossible to feedkey.
i think i had repeated many times:
|
There is some research that making deletes harder is not always the right idea. I appreciate that the confirmation makes it harder for my cat to accidentally delete files, but extra roadblocks (given the requirement to shift-d already) are probably not necessary. Clarifying the interface of a public function (even one not intended for public use) may be worthwhile. |
I'd still call it TUI and it requires to confirm :)
I repeat one more time:
|
gui-like, -like, or ok, if you like, it is popup window in tui.. um.. the point was not the like, vs/but how it interactive.
it was not having to change but the #14742 break the game (yes, this is a repeat too).
i cofirmed there now seems 2 functions called |
let's just agree to disagree here and let's not waste more time here. :) Thanks all. |
ok, fine, to pass-by vim users, if you scared the mis-typed 'D' |
// if not back out #14742
// then make it be a bit harder to make mistake to rm all
//
// also seems recover its original logic of 'all' argument