bug-bash
[Top][All Lists]
Advanced

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

Re: 5.3-alpha: value substitutions remove unrelated REPLY when its REPLY


From: Chet Ramey
Subject: Re: 5.3-alpha: value substitutions remove unrelated REPLY when its REPLY is removed
Date: Mon, 29 Apr 2024 11:33:25 -0400
User-agent: Mozilla Thunderbird

On 4/27/24 5:43 PM, Koichi Murase wrote:
When REPLY that is prepared by a value substitution ${ <list>; } is
removed by <list>, the value substitution removes the previous-scope
REPLY, which is not prepared by the value substitution, after the
execution of <list>.

$ bash-5.3-alpha --norc
$ unlocal() { unset -v "$@"; }
$ f2() { unlocal "$1"; echo "f2:$1=${!1}"; }
$ f1() { local REPLY=1; a=${| f2 REPLY; }; echo "f1:REPLY=$REPLY"; }
$ f1
f2:REPLY=1
f1:REPLY=

Removing REPLY inside a value substitution is admittedly arguable.
Nevertheless, it is still more consistent for value substitutions to
remove only the REPLY they prepared, if present, and to avoid removing
unrelated REPLY.

Thanks for the report. I agree that valsubs should only unset an instance
of REPLY at the current function context.

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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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