If you are speaking of a problem it would be helpful if you'd exactly specify the conditions you expect; and why. A reference to bash behaviour seems not to be an appropriate measure.
The question is, what do you expect as a possible range of exit codes, and in what way do you want to do the signalling of exit codes and/or signals. If, in your applications context, you don't have exit codes >128 then just subtract 128, as in (( rc >= 128 )) && (( rc -= 128 )) return $rc but then you wouldn't be able to distinguish signals from exit status. ________________________________ > From: [email protected] > Date: Mon, 2 Jul 2012 11:01:59 +0800 > Subject: [ast-users] [ksh93] How to return $? from a function when $? > 256 > To: [email protected]; [email protected] > CC: > > For example, following code is very common in scripts: > > ### CODE BEGIN ### > function debug > { > return > } > > function runcmd > { > typeset cmd=$1 > typeset rc > > debug "+++ $cmd" > eval "$cmd" > rc=$? > if (( rc )); then > debug "+++ $cmd failed with $rc" > else > debug "+++ $cmd succeeded" > fi > > return $rc > } > > runcmd '/usr/bin/sleep 15' > echo $? > ### CODE END ### > > The problem is when the command is killed by a signal, we cannot return > the correct $? (> 256) from the runcmd() function. Bash does not has > this problem since $? is equal to 128+signal when a command is killed. > > _______________________________________________ ast-users mailing list > [email protected] > https://mailman.research.att.com/mailman/listinfo/ast-users _______________________________________________ ast-users mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-users
