Have a look at this. I hope it's helpful.
In reply to Re: Interpret $? variable by mtmcc in thread Interpret $? variable by rbala