3 ms·
I write bash scripts almost solely for web hosting automation. I don't write a lot but when I need something, I spend a few hours making it. And when I'm done,
by geocrasher 4y ago
I write bash scripts almost solely for web hosting automation. I don't write a lot but when I need something, I spend a few hours making it. And when I'm done, I document it, because it's quite likely that in several months (or years?) I won't remember where I found that snippet of code, or what that function does, or how many bats ears and tree knots I had to boil to get that regex to work, or even what he regex does. So, I put comments throughout. It also saves my coworkers time when they're trying to figure out the script.
So yeah, leave comments! They don't have to be long. I leave comments like
# at this point we know $daemon is dead, so remove socket and kill any stray processes, and restart
#IP is validated as being a proper IP, now lets make sure it's not on the server itself. You're welcome, Scott.
So simple, but explains what was going on in my head when I wrote it.