Return codes in trap handlers in ksh

From: Owen Berry (owen.berry_at_gmail.com)
Date: 02/24/05


Date: 24 Feb 2005 14:31:57 -0800

Hi there,

Take a look at this sample code:

#!/bin/ksh
trap "signal_exit EXIT $?" EXIT
function signal_exit {
        echo "$?"
        echo "$@"
}
exit 5

On FC2 Linux with pdksh I get:

$ ./test.ksh
5
EXIT 0

On AIX 5.2 with standard ksh I get:

$ ./test.ksh
0
EXIT 0

In other words, in pdksh the return code that the script is exiting
with is available in $? and in ksh on AIX it's not.

Besides the differences, can anyone tell me how to get hold of that
return code in AIX ksh? I need it so that I can report it in a status
file.

Thanks!
Owen



Relevant Pages