My script included a command rm -r ${base_dir}/${old_file} . While executing the script, due to an error, both the variables were not set. But since then, my bash scripts have always included set -o nounset .