On Fri, Mar 07, 2014 at 11:38:21AM -0800, Eduardo A. Bustamante López wrote: > WARNING: the codes given below cause the shell to enter an infinite > loop. > > > Both: > dualbus@debian:~$ bash -Tc 'f(){ :; }; trap return RETURN; f' > ^C > > and: > dualbus@debian:~$ bash -c 'f(){ trap return RETURN; }; f' > ^C > > Cause the function call to recurse infinitely. I would understand if
By the way, I forgot to add the reason why I found this. POSIX states the following: | EXIT STATUS | | The value of the special parameter '?' shall be set to n, an unsigned | decimal integer, or to the exit status of the last command executed | if n is not specified. If the value of n is greater than 255, the | results are undefined. When return is executed in a trap action, the | last command is considered to be the command that executed | immediately preceding the trap action. Reference: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_24 The interesting bit is 'when return is executed in a trap action, ...'. So I wanted to test that, and the easiest way I thought I could verify if that matched, was to execute return in a RETURN trap. It's worth noting that using --posix does not affect the outcome. -- Eduardo Alan Bustamante López