Quote:
Originally Posted by microbet
What do you do about that? Detect operating system version or w/e is relevant and send an alert and not run the script whenever it's not what you allow? I mean, I'm sure that could be good, but do you do it in practice?
I don't know and certainly am not trying to present myself as anything other than a novice, but I've had to review a lot of code lately and here's the main things I notice people do that really sucks for me to try to maintain:
- Using a lot of external software dependencies, I avoid these unless absolutely necessary and stick to common commands that don't change much between unix based systems. For instance I never use find because its implementation and parameters change too much between mac/centOS for instance. I also don't use host or any of its associated commands for similar reasons. Stuff like that.
- Hardcoding file paths, or using a lot of relative file paths. This is the worst offense to me. I try to use absolute file paths for everything and to use locations where I know things will always be and keep it as simple/readable as possible. I see a lot of scripts that bounce between directories 40 times and you read it and you're like "where the **** am i right now?"
- Doing stuff that depends on output being formatted a certain way. Grepping output to determine some thing - I really hate this but sometimes it's unavoidable.
- hacky stuff like modifying source files with sed. **** that ****, just don't do it, there's almost always a better way.
- Piping 5+ things together to do some thing, completely unreadable and usually avoidable.
just a few things off the top of my head.