Better to immediately switch to Python (or anything else) once you have any non-trivial control flow in your bash script. Loops, non-trivial conditionals, and argument parsing are all easier in Python. Bash is for simple scripts that just chain commands.