My OS: Ubuntu 18.04.5 LTS
I use tracing for troubleshooting a script. I've notice different behaviors in the tracing depending on how I set it up. I would like to understand why it behaves this way.
I normally activate tracing using set -x
in my script where I need the tracing to take place. However the Prompt String PS4 ("+ " by default) seems to "duplicate" itself.
If I active tracing in the shebang #! line, PS4 is only printed once.
Similarly, if I call bash
directly for running my script, and specifying -x
in the command line, PS4 is also only printed once.
Why is set -x
behaving differently in the first example ? I guess there is something fundamental about the shell which I am not getting here...