bug-bash
[Top][All Lists]
Advanced

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

Empty strings disappear from array splice


From: marc . coiffier
Subject: Empty strings disappear from array splice
Date: Mon, 19 Jan 2015 15:22:36 -0800 (PST)
User-agent: G2/1.0

Hello all,

(This bug was found on a fresh Debian wheezy install)

Here is the minimal code sample to reproduce the bug (present in version 4.2, 
corrected in 4.3 as far as I can tell) :

  arr1=( "" "" )
  arr2=( "${arr1[@]:1}" )
  if [ ${#arr2[@]} -eq 1 ]; then
    echo OK
  else
    echo Not OK
  fi

On the buggy Bash version, the second affectation creates an empty array 
whereas we expect it to create an array of one empty string.

Oddly enough, the bug is absent from some older Bash versions (3.0 correctly 
reported an array of one element, for instance). 

Thank you for your time,


reply via email to

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