6 ms·
Great idea! Also terrifying :) Given how often I accidentally commit the wrong text in vscode, I shudder to think of the damage I could do with this on my shell
by monkellipse 3y ago
Great idea! Also terrifying :) Given how often I accidentally commit the wrong text in vscode, I shudder to think of the damage I could do with this on my shell, hah! What safety measures are there/could there be?
- biellls 3y agoA simple approach might be that if the resulting exit code is not 0 it won't be used to complete in the future.
- Eavolution 3y agoThat'd have the problem of tools like grep returning nothing, having an exit code of 1, but being a perfectly valid thing to suggest in the future.
- starttoaster 3y agoWhen you're writing, building, and executing code, I would not expect a 0 exit code every time.
- KRAKRISMOTT 3y agoThe fish approach
- owlstuffing 3y agoGenerally, a destructive shell command prompts for approval. But I suppose overfumbly fingers could still cause grief. Type/command aware tooling is a night and day difference.
- mksybr 3y agoGenerally? Do you have examples in mind? The ones I think of are destroy first and ask questions only if told to do so: mv cp rm redirection tee
- owlstuffing 3y agoYeah, you’re right. I was thinking of overly destructive commands eg. reformat etc.
- tombert 3y agoI feel like I've trashed millions of files I shouldn't have with `rm` and trying to be clever with regular expressions.
- doubled112 3y agoI've done this enough times I use `ls` first, then `rm`
- tombert 3y agoYeah, I generally will use `find . -name "<my pattern"` nowadays, just so I can see all the potentially recursive files as well, and then when I'm 100% sure that what I'm doing is good, I will pipe that into xargs or parallel. My point was that I don't feel like Unix really stops you from doing destructive scary stuff. It seems like it's perfectly happy to let you break your machine.
- doubled112 3y agoExactly, which is why we check for ourselves instead of expecting it to hold our hand. Unixy tools tend do what you tell them, nothing more and nothing less. No confirmations, no output if successful, no progress bars, etc. That's a feature in my mind, but I can see how it is easy to have your day ruined if you're expecting it to ask you again.
- tombert 3y agoI mostly agree, but sometimes I wish that `rm` would have default to "confirm before destroying", and add a flag like `-y` to not prompt, more or less like how `apt` works on Ubuntu.
- doubled112 3y agoThat's actually a way better experience than no confirmation and confirming each item individually.
- graypegg 3y agoI don't know how painful it would be, but I think I could adapt to a short delay of maybe 50-100ms where the shell won't respond to Return presses, only after accepting a completion. Just long enough ideally to make me re-read what I entered.