shell_script: moved common stuff into functions.sh