On Wed, Jan 07, 2026 at 10:15:55 +0800, 王伟 wrote:
>     local all_var_info=${ local;}
>     declare -p all_var_info

> test_case6 ret----------
> declare -- all_var_info=""

The man page says:

       This  type of command substitution superficially resembles executing an
       unnamed shell function: local variables are created  as  when  a  shell
       function  is  executing,  and the return builtin forces command to com-
       plete; however, the rest of the execution  environment,  including  the
       positional parameters, is shared with the caller.

Since bash provides no way to print the local variables of your caller,
the curly-brace command substitution is simply not what you want here.
Continue using $( ) instead, since that does what you need.  (Or write
local's output to a temp file and read it back in.  That also works.)

Reply via email to