Fix some shell idiosyncrasies.

Follows all warnings detected by shellcheck.net (thanks @lucasdicioccio
for the tip).