Since I started work at HP I became worrier and worrier in producing shell scripts easy to extend. I have modified hundrends of badly written scripts and worst designed in a couple of days which led our team, fortunately, to a non-big fiasco.
Anyway, all could have been nice if the original scripts were acomplished some principles related mainly to:
1) Bad handling of temporary files.
2) Embbeding big chunks of awk scripts.
3) less than 1% of lines of comments.
Surfing the web I found an interesting web about good shell scripting practice, take a look to it, for sure it will be useful some day.