Remove all bashisms from build.sh

Most changes are straightforward, like replacing unnecessary [[ with [.
The only significant change was to the detection of Python’s version
number : the previous approach used regexes and string indexes, which
is rather fragile. We now use sys.version_info.{major, minor} instead.

This was done as a preparation for [issue 1290 on YCM](https://github.com/Valloric/YouCompleteMe/issues/1290).

I signed the CLA.