Fixed wrong handling of `cwd` parameter when `expand` is set to false

When passing the `cwd` parameter to copy the target file list is built correctly but the actual copying fails, this patch fixes this.