Start to fix problems spotted by clang-analyzer.

Also, let's not spawn /bin/sh (moreover, with a fixed path) each time we want to
run a command.