News for hackers. Stuff that matters.
Re:Times I've Messed Up as a Developer by seanwilson on Tuesday October 10, 2017 @12:26PM (#15443066)
This is why I do a "mv" to "tmp" instead of using "rm" when I can. Having special messages or colours to differentiate between production and other environments is a great idea as well. Generally if I'm about to do something on production, I'll close everything else to do with other environments as it's just too easy to slip up.
Re:Times I've Messed Up as a Developer by 3131s on Tuesday October 10, 2017 @01:39PM (#15443743)
You can also alias "rm -i" or "rm -I" to "rm" to avert major catastrophes.

From man rm:

-i prompt before every removal

-I prompt once before removing more than three files, or when removing recursively; less intrusive than -i, while still giving protection against most mistakes

Re:Times I've Messed Up as a Developer by nisse72 on Tuesday October 10, 2017 @03:14PM (#15444527)
This alias seems to be set by default in many linux distributions these days (and has been that way for many years now).

The problem is that you get used to this crutch and rely on it, until one day you're logged in someplace without the alias and end up deleting something you shouldn't.

I'm not a fan and normally disable it. Instead, I prefer to be very careful and deliberate when using rm, especially with any wildcards, making sure I'm in the right directory and that the pattern matches what I expect it to.

Re:Times I've Messed Up as a Developer by nucleardog on Wednesday October 11, 2017 @01:05PM (#15451280)
I'll probably get shit on for admitting it, but I generally keep rm aliased to `rm -rf`. Recursive, force.

It forces me to be careful and deliberate. There's never a safe option or a backstop. I treat rm like a gun - always assume it's loaded and going to murder whatever I point it at without hesitation. If I'm not 100% sure about what I'm about to delete or how a wildcard will expand, then I echo it first.

I messed up once, about 15 years ago now. Lost a few personal files. Haven't screwed up since.

Re:Times I've Messed Up as a Developer by chias on Tuesday October 10, 2017 @05:14PM (#15445361)
> This alias seems to be set by default in many linux distributions these days (and has been that way for many years now)

Which Linux distributions do this? I have not seen this alias set by default on any distribution that I've used recently (Gentoo, Linux Mint, Debian, Ubuntu, Crunchbang, Arch).

Re:Times I've Messed Up as a Developer by nisse72 on Tuesday October 10, 2017 @06:56PM (#15445990)
I stand corrected, it doesn't seem to be the case anymore.

I can find old rpms and deb files with rm aliased in /etc/skel/.bashrc or /etc/skel/profile/aliases.sh, but the most recent I found is in a bash 3.2 package, so this practice seems to have stopped quite a few years ago.

Re:Times I've Messed Up as a Developer by woliveirajr on Tuesday October 10, 2017 @03:36PM (#15444708)
An then use 'yes' to avoid all those key pressing :)
Re:Times I've Messed Up as a Developer by inertial on Wednesday October 11, 2017 @12:42AM (#15447338)
There's trash-cli that moves files to "trash". Alias "rm" to display an error message to avoid accidental deletions.

https://github.com/sindresorhus/trash-cli

Re:Times I've Messed Up as a Developer by woodrowbarlow on Tuesday October 10, 2017 @03:04PM (#15444427)
my go-to .bashrc hashes the hostname into a color and prints the prompt in that color. it has saved me from making a dumb mistake a few times.
Re:Times I've Messed Up as a Developer by shocks on Tuesday October 10, 2017 @03:38PM (#15444732)
Production prompts are red.

Staging prompts are yellow.

Development prompts are green.

Re:Times I've Messed Up as a Developer by woodrowbarlow on Tuesday October 10, 2017 @03:43PM (#15444777)
yeah, that'd be great. but our staging units (i don't deal with production units) come and go so often that keeping a list of hostnames became unrealistic.
Re:Times I've Messed Up as a Developer by khedoros1 on Tuesday October 10, 2017 @03:58PM (#15444873)
Is there something in your dev process that would actually require you to implement it with a list of hostnames, rather than just putting the "staging" version of .bashrc onto the staging machines, and the "dev" version onto dev machines?
Re:Times I've Messed Up as a Developer by aidos on Tuesday October 10, 2017 @06:19PM (#15445797)
Mine is exactly the same :-)
Re:Times I've Messed Up as a Developer by tacone on Tuesday October 10, 2017 @03:20PM (#15444574)
Could you post the code somewhere?
Re:Times I've Messed Up as a Developer by woodrowbarlow on Tuesday October 10, 2017 @03:39PM (#15444736)
sure, although my technique is a bit kuldgy.

https://gist.github.com/woodrowbarlow/52b02ab27d0f8088891c3d...

look at `get_hash_color`.