Make sure the function does not break execution under set -e and bugfix for command options