Put all the bagit args together in an array and passed that to executeOrRun instead.  All the string munging was to ensure that we passed a space-separated list of parameters as the command.  I suspect this used to directly run bagit, then needed some extra processing and this script was trying to emulate the old behavior.