mainThe GNU Bourne-Again SHell - Support: sr #110538, Consecutive 0x01 bytes lost during...

 
 

sr #110538: Consecutive 0x01 bytes lost during expansion to local array variable

Submitter:  None
Submitted:  Sat 11 Sep 2021 12:30:37 AM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal 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
   

Sat 18 Sep 2021 09:14:00 PM UTC, comment #2: 

There is a fix in the devel branch tagged for bash-5.2.

Chet Ramey <chet>
Group administrator
Wed 15 Sep 2021 08:55:30 PM UTC, comment #1: 

Yes, this is a problem with this form of compound assignment, since the assignment appears as an argument to a builtin command and undergoes another `round' of expansion. This ends up removing the 0x01 characters bash uses for internal quoting.

An easy workaround, while I look at the issue, is to use

local -a foo
foo=( "${var[@]}" )

Chet Ramey <chet>
Group administrator
Sat 11 Sep 2021 12:30:37 AM UTC, original submission:  

test.sh:

#!/bin/bash

print_value() {
    local -a foo=("${var[@]}");
    echo -n "$foo" | xxd -p
}

var=($'\x01\x01\x01\x01\x01\x01');
print_value


Expected output: 010101010101

Actual output: 010101


$ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


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.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-09-18 chet StatusIn Progress Done
    2021-09-15 chet StatusNone In Progress

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code