On Wed, Nov 09, 2005 at 01:56:01PM +0000, Gerrit Pape wrote:
>
> > All other POSIX shells behave like that.
> > 
> > http://www.opengroup.org/onlinepubs/009695399/utilities/return.html
> > 
> > It is definitely a bug to me. I've not tested it, but I had had

Actually, it's not as simple as that.  The specification above also
says that return when called inside a trap without arguments should
set the exit status to the last command outside the trap, but in
reality we have:

$ bash -o posix -c 'trap ":; return" USR1; a() { (exit 2); (kill -s USR1 $$; 
exit 2); (exit 2); }; a; echo $?'
0
$ ksh -c 'trap ":; return" USR1; a() { (exit 2); (kill -s USR1 $$; exit 2); 
(exit 2); }; a; echo $?'
0
$ dash -c 'trap ":; return" USR1; a() { (exit 2); (kill -s USR1 $$; exit 2); 
(exit 2); }; a; echo $?'
2
$

However, dash only gets it right by accident since its trap handler
always restores the last exit status even if the return statement
inside the trap had an argument.

The same logic is used in dash's loop construct.

I'll have to think about this a bit more.

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to