bash: modularize a bit