Is there any practical difference in debugging using bash -x scriptname.sh
or using set -x
inside the script and then calling it?
In my personal experience I always use bash -x
because that way I don't have to change the script so it's less invasive.
Is there a scenario where bash -x
would not fit and just set -x
would work?
I came up with these questions because I always see people suggesting set -x
when trying to help others to debug and I was wondering why not bash -x scriptname.sh
. Is there a technical limitation?
PS: I'm not asking about what the commands do, but I'm asking "how" they do and if one is better than the other.
About what they do: