Fixed current implementations to support bash errexit and nounset options