On 3/7/14, 2:38 PM, 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
> this is labeled as a feature, rather than a bug (in the sense that
> the user shouldn't be putting return inside a return trap :), so one
> can safely assume that if they did it, it's because they wanted the
> infinite recursion).

This isn't intended; the a `return' from a return trap should behave like
`exit' in an exit trap and not run the trap recursively.  There is code
in there that's intended to do that; the longjmp that the return builtin
executes defeats those mechanisms.  I will figure out a solution and put
it out as a future patch.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to