Porting to work on zsh in addition to bash. Some of the unfn logic is broken, as are the regexp matches; but otherwise most of it seems ok.