extract progressbar code into an inline module
exit with non-zero status on error