update scrips for consistency with modern conventions

* downcase variables which do not belong in the environment
* quote __all__ expansions appropriately 
* replace variables that relied on unquoted expansions for wordsplitting with properly quoted arrays
* replace backticks with $() notation for command substitutions
* save subshells and fork/execs to external utils wherever possible (optimizations)
* define functions with a more reliable & portable syntax (the function keyword implies some unexpected behaviours)
* replace '[[ ]]' tests with '(( ))' tests for integer operations
* use 2-space indent to decrease the excessive whitespace and line-length caused by 8-space tabs

All changes were made with the goal of preferring consistency and correctness over implementation simplicity in mind. I admit that I may have made some mistakes, but i quadruple checked these files to be as certain of their consistency as possible. My apologies if i still forgot some quotes.

I understand that this is a fairly monolithic pull request, and makes a lot of changes. `make test` runs cleanly on my system with bash 4.2.45(2)-release & zsh 5.0.2. I wanted to submit this as a series of smaller pull requests, but the fact is that the files are too interdependent to make this feasible. If the tests pass on your build system, I hope you'll understand the necessity to lump these changes all together rather than submitting something on the order of ~8 separate pull requests.

I merged my final working version directly into your latest commit, and it went smoothly. This should work the same for you.

If there are any questions, comments, or complaints then feel free to bug me at any time. 95% of these changes are as simple as adding double-quotes around expansions, changing the indentation, and switching to the more appropriate/portable style of function definition so there is overall very little to actively review.

Thanks for your work on chruby!