* properly quote variables * consistent command susbtitution * condense conditionals to one line * better error handling thanks to zsw for teaching me some sh