Print all commands in a bash function
I am trying to debug a bash function.
Is it possible to print all the commands executed by a bash function? I know that it is possible to print all the commands by a bash script by changing
#!/bin/bashto
#!/bin/bash -xHow do I get the same effect for a bash function?
Thank you.
1 Answer
You need to edit the function to add and remove tracing, eg:-
FuncName()
{ set -x ;# Enable tracing on entry ... (function code) ... set +x ;# Disable tracing on exit
} 2