I wonder is there any program that can take a bash script as input and print out all bash commands it will run? A program that would unroll loops, expand environment variables and generally not perform any destructive action nor call any external binaries. It’s like a dry run of sorts.
Of course, if you narrow the problem scope you might be able to solve it. OP was talking about unrolling loops etc. which I interpreted as having the exact amount of times a loop is executed. AFAIK this would lead to a state explosion for nearly all non-trivial cases, and we already now that knowing if a program (incl. loops) terminates is not generally solvable.