bug-bash
[Top][All Lists]
Advanced

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

[bug #66455] declare -p [varname] does not recognize nameref variables


From: Dominik Kummer
Subject: [bug #66455] declare -p [varname] does not recognize nameref variables
Date: Mon, 18 Nov 2024 07:39:31 -0500 (EST)

URL:
  <https://savannah.gnu.org/bugs/?66455>

                 Summary: declare -p [varname] does not recognize nameref
variables
                   Group: The GNU Bourne-Again SHell
               Submitter: domson
               Submitted: Mon 18 Nov 2024 01:39:22 PM CET
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Mon 18 Nov 2024 01:39:22 PM CET By: Dominik Kummer <domson>
When we do

    sh_var = bind_variable (varname, value, 0);
    VSETATTR(sh_var, att_nameref);

on a global scope, the variable is not recognized as nameref variable.

As a workaround we can use

    void var_convert_nameref(const SHELL_VAR *sh_var) {
      if (sh_var) {
        char *command = (char*)smalloc(PATH_MAX+1);
        snprintf(command, PATH_MAX, "declare -n %s", sh_var->name);
        evalstring(command, (char *)NULL, SEVAL_NOHIST);
      }
    }







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?66455>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature


reply via email to

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