Need help with trap

Hi

Our problem is knowing:

What is the "best" way of simulating a TRAP for ERR within a function, since we know this will not work directly with ksh93 and aix5. How can we save the error encountered in the function and then deal with it in the calling script?

Thanks!

How about echoing the error in the function?

function() {
   # some code
   echo $?   # $? contains the return value of the command
}

return_value=function
if [ $return_value -ne 0 ]; then
   # deal with error
fi

Thanx,

That helps but could be "messy" if function is complicated. We found that the original TRAP for ERR inside functions is actually fixed in later versions of AIX 5.

Also, If the function is dotted the TRAP for ERR will work in our version of AIX. Is it "normal" to dot functions?

Cheers

If you are struggling with a broken version of ksh you should upgrade to the version you know to be fixed. Your buggy ksh may have more bugs you have not yet discovered.

No.