More quotes to improve Zsh compatibility

This commit changes most of the occurrences of
  x=$(cmd)
into
  x="$(cmd)"

When cmd is returning multiple words or lines Zsh interprets
them as an array. Putting those quotes ensures we get a single
string with spaces inside.
Merge pull request #193 from np/zshcompat

Zshcompat: More quotes to improve Zsh compatibility