cancel
Showing results for 
Search instead for 
Did you mean: 

debug in a script function

SOLVED
Go to solution
lawrenzo_1
Super Advisor

debug in a script function

Hi All,

I want to execute a script with ksh -x <script> so I can see the output of the commands however I would like to display what is happening with the functions of the script ....

does anyone know the syntax?

Thanks

Chris
hello
4 REPLIES
likid0
Honored Contributor

Re: debug in a script function

put a set -x inside the function.

MI_FUNC () {
set -x
echo "lol"
}
Windows?, no thanks
lawrenzo_1
Super Advisor

Re: debug in a script function

the problem I have with that is the function is a check function ie


Check_Func () {

[[ $? -ne 0 ]] && alert

}

if I put the set -x in then $? always = 0

:-(

Thanks all the same.
hello
James R. Ferguson
Acclaimed Contributor
Solution

Re: debug in a script function

Hi Chris:

> if I put the set -x in then $? always = 0

So do this:

Check_Func () {
typeset RC=$?
set -x
echo "I saw RC=${RC}"
...
}

Regards!

...JRF...

lawrenzo_1
Super Advisor

Re: debug in a script function

ah yes I suppose there is always that !

Thanks James

Chris
hello