[Top][All Lists]

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

Re: Incorrect / Inconsistent behavior with nameref assignments in functi

From: Chet Ramey
Subject: Re: Incorrect / Inconsistent behavior with nameref assignments in functions
Date: Mon, 31 Aug 2020 11:21:06 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

On 8/28/20 4:56 AM, Binarus wrote:

> Bash Version: 4.4
> Patch Level: 12
> Release Status: release
> Description:
> ------------
> Under certain circumstances, assignments of namerefs to local variables
> in functions behaves in a way which makes namerefs completely useless.
> Furthermore, the behavior is not consistent.

There is an order of evaluation problem as explained later in the thread,
not specific to namerefs. It's fixed in bash-5.1.

The underlying issue is making `declare [options] foo=bar' expand the
argument like an assignment statement as POSIX specifies. This makes
`declare' more like a hybrid reserved word instead of a builtin. In some
cases, the options matter and affect how the argument gets expanded. You
end up having to do something like `declare [options] foo; foo=bar' to get
the expansion right, but that introduces several corner cases.

``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]