Change in behaviour of declare/local from bash 4.2 to 4.3 -


i've updated system , got new bash version. since i've encountered nasty behaviour of bash scripts, managed track down new behaviour of bash's declare / local commands.

considering following minimal working example:

#!/bin/bash  function printarray1 () {   local -a arr=("${!1}")   echo "${arr[@]}" # printing complete array   echo "${arr[9]}" # check if recognized integer indexed array }  function printarray2 () {   local arr=("${!1}")   echo "${arr[@]}" # printing complete array   echo "${arr[9]}" # check if recognized integer indexed array }  arr=("01" "02" "03" "04" "05" "06" "07" "08" "09" "10") echo "declaration indexed array:" printarray1 arr[@] echo "undefined declaration:" printarray2 arr[@] 

on gnu bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu) results in

declaration indexed array: 01 02 03 04 05 06 07 08 09 10 10 undefined declaration: 01 02 03 04 05 06 07 08 09 10 10 

while newer gnu bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) version returns

declaration indexed array:  undefined declaration: 01 02 03 04 05 06 07 08 09 10 10 

note behaviour same when use "declare" instead of "local".

i not find change of declare options in bash 4.3. (help declare) equal in both versions relevant information. i've stumbled upon claim "all variables can used arrays without explicit definition." (see why "declare -f" , "declare -a" needed in bash scripts?).

can explain behaviour? new feature? or bug? has passing of arrays functions been restricted? me it's pretty scary when bash behaviour changes version version.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -