Print each line as it is read
Print every script line as the shell reads it, before expansion, with set -v. Pair it with set -x to see the source line and the expanded command.
A trace shows the commands after variables are filled in, and sometimes what you need is the line as written.
set -v
name=world
echo "hello $name"
set +v
echo done
echo ---
set -vx
echo "hello $name"
set +vxname=world
echo "hello $name"
hello world
set +v
done
---
echo "hello $name"
+ echo 'hello world'
hello world
set +vx
+ set +vxset -v is the verbose option. It prints each line of input exactly as read, with the variables still unexpanded, before the shell runs it. set -x prints the command after expansion. Used together, the second block shows the source line and then the traced command with the value filled in, which makes it clear which part of a line produced a surprising result. Both are in the set builtin documentation. The line that turns verbose mode off is shown because it is read before it runs.
Verbose output goes to standard error and prints lines in the order they are read, so a function body appears when it is defined and not when it is called. It prints comments and blank lines too. Running bash -v script.sh applies it to the whole file, which is long for any real script.