Updated with feedback from shellcheck.