Get rid of some bash-ism and do stuff ourselves.