install.sh: Handle redirects properly

Also strips some bashisms

Fixes #415
Merge pull request #416 from npm/curlsh

install.sh: Handle redirects properly