I've got a Korn shell script which I'm trying to debug with the aid of the "-x" switch, and it works for a while (i.e. as the script executes) until a function is called, then the shell stops displaying the commands as it executes. When the function returns, the commands are displayed again.
How do I get it to display commands for the entire script?
Kevin
On 2014-01-03 15:19, Kevin McGregor wrote:
I've got a Korn shell script which I'm trying to debug with the aid of the "-x" switch, and it works for a while (i.e. as the script executes) until a function is called, then the shell stops displaying the commands as it executes. When the function returns, the commands are displayed again.
How do I get it to display commands for the entire script?
A quick Google search for "korn shell xtrace stops working within functions" came up with this page...
http://docstore.mik.ua/orelly/unix3/korn/ch09_01.htm
... wherein it states...
"When set at the global level, the xtrace option applies to the main script and to any POSIX-style functions (those created with the name () syntax). If the code you are trying to debug calls function-style functions that are defined elsewhere (e.g., in your .profile or environment file), you can trace through these in the same way with an option to the typeset command. Just enter the command typeset -ft functname, and the named function will be traced whenever it runs. Type typeset +ft functname to turn tracing off. You can also put set -o xtrace into the function body itself, which is good when the function is within the script being debugged."
This behaviour may be different in different implementations of ksh, however...
http://stackoverflow.com/questions/2273474/korn-shell-set-x-debug-flag-globa...