Wednesday, October 14, 2009

When Stupid Attacks (.bat file edition)

I'd just like to point out that today I spent about 3 hours trying to write a Windows batch file to do some string replacement. This script is only for developers and development machines. The same script took me seriously less than 5 minutes for Linux. Why so hard on Windows? Because their scripting environment sucks.

But, I stuck it out. I wrote a long and scary script that tried to take into account empty lines, commented lines, and lines that actually stores the properties that I wanted to write. I got something that worked 'mostly', and thought about spending even more time on it when I finally stopped being stupid and decided that I should be using the Windows port of sed. It was one of those times that I just wasn't thinking clearly in my haste to write some code. Just a friendly reminder - if it's hard and feels like a hack, it's probably the wrong thing to do, and there's probably something smarter to do - sometimes you just have to take a step back to do it.
blog comments powered by Disqus