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    c...@case.edu    http://tiswww.cwru.edu/~chet/


Reply via email to