Earlier quoted context omitted.
Over the years I've been steadily training myself to type "WHERE" earlier in the process, until I have finally settled on the obvious-in-hindsight solution: Always simply start with the WHERE clause. (Of course every effort not to be on the SQL shell of a production server in the first place should be taken, but sometimes you need a sledgehammer and nothing else will work.)
The habit I learned was: before running any DELETE or UPDATE statement, run a SELECT with the same WHERE. (e.g. if I meant to say DELETE FROM puppies WHERE cute = 0, first run SELECT FROM puppies WHERE cute = 0.) I find I remember to do that because of the direct benefit (getting a sneak preview of what I'm going to delete), but it also means I end up thinking twice about the WHERE statement, so I'm much less likely…
Ooops.
151–160 of 247 posts
Re: Ooops.
#152Earlier quoted context omitted.
I hate that feeling you get in the pit of your stomach after you realize what's happening. Same thing when you forget the WHERE on a DELETE FROM.
SQL is desperately in need of some updates. For starters, DELETE FROM should never be allowed without a WHERE clause. DBs should simply define that as malformed sql.
Re: Ooops.
#153Unix could really do with a command that you can wrap around this type of call. Either a sanity check on the path part or a safe rm alternative that contains it. I would gladly give up full rm access to know that I can safely (or safer-ly) delete in scripts. It could be something as simple as a file with paths on each line it - match one path or a path with a glob - and the script fails before destroying anything imp…
Re: Ooops.
#154Looks like someone never read the Unix Hater's Handbook. Another fun thing is rm + shell expansion. A file named * or / can cause extremely unintended deletions.
rm -- -r -f # removes files -r and -fRe: Ooops.
#155reminds me of http://thedailywtf.com/Articles/Bourne-Into-Oblivion.aspx
Re: Ooops.
#156Earlier quoted context omitted.
I hate that feeling you get in the pit of your stomach after you realize what's happening. Same thing when you forget the WHERE on a DELETE FROM.
SQL is desperately in need of some updates. For starters, DELETE FROM should never be allowed without a WHERE clause. DBs should simply define that as malformed sql.
Re: Ooops.
#157I learned a rather unusual trick to keep myself safe from unintended glob matches. It is not "fool"-proof, but it will probably dilute an unmitigated disaster into an incomplete disaster: Keep a file named -i in the sensitive directories. When glob picks it up, which should be fairly early, it will be treated like a command line argument. Has saved me on occasions. I also had a friend in school who used to, for whate…
I hate that feeling you get in the pit of your stomach after you realize what's happening. Same thing when you forget the WHERE on a DELETE FROM.
Re: Ooops.
#158Re: Ooops.
#159Earlier quoted context omitted.
Almost all of the desktop environments commonly used with Linux do have a trash bin.
If it wasn't obvious, "Why is `rm -rf` not connected to the recycle bin?" is implicit in my original question.
alias rmmmmmmmmmmmmmmmmmmmmmm='rm -i'
rm() { D="~/.Trash/`date +%s.%N`"; mkdir -p $D; mv "$@" $D; }Re: Ooops.
#160A decade ago, I worked on a DNA sequencer / aligner product. This produced easily 1GB+ raw data files, and they typically exploded by a factor of ten by the time you performed a bunch of cleaning, smoothing, filtering, etc on them. For several reasons, not least of which was a 4GB file size limit in fat32, this software had to use a directory as a pseudo file. I was working on some file saving logic. A customer had a…