Bash read into array is not working

Bug #1760358 reported by Simon Tideswell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
New
Undecided
Unassigned

Bug Description

This issue is found in the Bionic Beaver (Ubuntu 18) beta.

How it should work (e.g. on Xenial)
-----------------------------------

$ read -a simon <<< $( ls -1 /usr )
$ echo ${#simon[@]}
9
$ echo ${simon[@]}
bin games include lib local sbin share src var

How it works (wrongly) on Bionic
--------------------------------
$ read -a simon <<< $( ls -1 /usr )
$ echo ${#simon[@]}
1
$ echo ${simon[@]}
bin

Release
-------
Description: Ubuntu Bionic Beaver (development branch)
Release: 18.04

Package Version
---------------
Installed: 4.4.18-1ubuntu1

Revision history for this message
Simon Tideswell (stideswell) wrote :

Hello

This still affects Bionic final release version: Ubuntu 18.04.1 LTS, bash 4.4.19(1).

Using bash's array capabilities in this way is extremely useful and being unable to use it makes bash scripting much harder work. I'm surprised such a serious issue remains unfixed some 4 months after Bionic was released! I'm sure this would be affecting all sorts of sysadmin scripts in the wild.

Simon

Revision history for this message
Simon Tideswell (stideswell) wrote :

Ah!!! Actually, this does work,

$ simon=( $( ls -1 /usr ) )
$ echo ${#simon[@]}
8
$ echo ${simon[@]}
bin games include lib local sbin share src

This will still cause scripts in the wild to break. But at least there's a workaround.

Simon

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.