5.3-alpha: value substitutions remove unrelated REPLY when its REPLY is
From:
Koichi Murase
Subject:
5.3-alpha: value substitutions remove unrelated REPLY when its REPLY is removed
Date:
Sun, 28 Apr 2024 06:43:06 +0900
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.
--
Koichi