This commit includes following fixes for a few shell scripts:
1. Follow the best practice of quoting variables everywhere unless they
are used in places where word-splitting and globbing can never happen.
2. Replace `command` with $(command) because the latter is easier to use
and read.
3. Don't use "$@" in places expecting a string because it is an array
of strings instead of a single string.