bug-bash
[Top][All Lists]
Advanced

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

Re: bug attached


From: Chet Ramey
Subject: Re: bug attached
Date: Wed, 30 Aug 2023 10:58:03 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0

On 8/30/23 8:40 AM, queency3 jones wrote:

> Bash Version: 5.0
> Patch Level: 3
> Release Status: release
>
> Description:
>
> function sub { aa=8;return_value=$aa; }
> function sub { aa=8; }
>
> function main { aa=3;sub;aa=$(($aa+1));printf "$aa\n"; }
>
>
> calling main will print 9 instead of 4

What behavior do you expect and why? The bash behavior is correct, since
you have no local variables and all functions share the global variable
`aa' and its value.

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




reply via email to

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