If I run
bash -x myscript.sh
I get debug output.
But if I have a function in myscript.sh , the function code is immune to -x. It writes for output only the name of the function.
How to get debug output for functions in bash scripts?
Update:
After ztank1013's answer, I just realized that I used ksh, not bash. Bash seems to have enabled the functrace function on my system by default (thanks bash -o-logist)
I am satisfied, but for the community I keep the question open to ksh.
For the script:
#!/bin/ksh a=2 testering(){ a=3 if [ $a -eq 3 ]; then echo lili fi } if [ $a -eq 2 ]; then echo mimi fi testering exit
ksh -x ./testdebug.sh :
+ a=2 + [ 2 -eq 2 ] + echo mimi mimi + testering lili + exit
So for ksh, what's the trick?
(If there is no answer, the "correct" will go to bash -o-logist.)
Florin ghita
source share