mainThe GNU Bourne-Again SHell - Support: sr #110799, Length of named array variables...

 
 

sr #110799: Length of named array variables are zero.

Submitter:  None
Submitted:  Sat 10 Dec 2022 07:41:55 AM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  4 - Important Status:  Done
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 12 Dec 2022 10:25:13 PM UTC, comment #2: 

Thanks for the report. The issue is with namerefs whose values are non-identifiers but valid length expressions.

Chet Ramey <chet>
Group administrator
Sat 10 Dec 2022 08:02:56 AM UTC, comment #1: 

Oh, this is also reproducible on:
5.1.12(1)-release (aarch-unknown-linux-android) from Termux.

Cheers,
Brendon

Anonymous
Sat 10 Dec 2022 07:41:55 AM UTC, original submission:  

In 5.2.2(1)-release (x86_64-pc-linux-gnu), the following produces an incorrect behavior:

declare -a array=(foo)
declare -n name=array[0]
echo ${name}  # foo
echo ${#name} # 0

Per section 3.5.3: Shell Parameter Expansion, of the manual:

  • ${#name} should expand to the length in characters of the expanded value of name.
  • ${name} expands to foo, which is three characters long.
  • But on my end, ${#name} expands to 0.

I'm not sure whether I'm missing something, or that this is actually incorrect.
Other expansions such as substring works correctly.

Anonymous

 

(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 None (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
    2022-12-12 chet StatusNone Done

    Back to the top

    Powered by Savane 3.13-ee12.
    Corresponding source code