bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: local variable escapes into trap


From: Chet Ramey
Subject: Re: local variable escapes into trap
Date: Tue, 29 Dec 2009 11:35:56 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0

On 12/29/09 4:19 AM, Akim Demaille wrote:
> Hi!
> 
> On the following script, the local variable $name of bar() hides the
> global $name when entering the trap.  I have observed that with several
> versions of Bash, including
> 
>> GNU bash, version 4.0.33(1)-release (i486-pc-linux-gnu)

I believe that bash is correct.  When the `exit' builtin is invoked, and
the trap is executed, the shell is still executing in the function's
context.  There was no `return', and running exit or a trap does not
implicitly call it.

> FWIW, Zsh and Dash behave as I expected.

FWIW, ksh93 behaves like bash.

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]