bugThe GNU Bourne-Again SHell - Bugs: bug #66455, declare -p [varname] does not...

 
 

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

Submitter:  Dominik Kummer <domson>
Submitted:  Mon 18 Nov 2024 12:39:22 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Need Info
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 19 Nov 2024 01:56:53 PM UTC, comment #2: 

I always start dialogs moderately without overloading the other too much. Hoping for a quick fix. But I really tried lots of approaches to make a global nameref variable from within a loadable builtin before arriving here, to boil the problem down to these few lines.

I will provide a full example as soon as possible. I just have to isolate the case.

kind regards

comment #1:

> Posting two isolated lines of C source code doesn't do much to demonstrate a problem.
>
> If you have something more substantial to reproduce it that I can use to test, possibly a loadable builtin that tries to create a variable and do something with it, I will look further.
>

Dominik Kummer <domson>
Mon 18 Nov 2024 07:13:30 PM UTC, comment #1: 

Posting two isolated lines of C source code doesn't do much to demonstrate a problem.

If you have something more substantial to reproduce it that I can use to test, possibly a loadable builtin that tries to create a variable and do something with it, I will look further.

Chet Ramey <chet>
Group administrator
Mon 18 Nov 2024 12:39:22 PM UTC, original submission:  

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);
      }
    }

Dominik Kummer <domson>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by domson (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-11-18 chet StatusNone Need Info

    Back to the top

    Powered by Savane 3.14-225a.
    Corresponding source code