declare -A on RHEL 5

1

I am using an associative array on my RHEL 6 servers and I just tested the script on a RHEL 5 server and apparently -A is not supported for the declare command on RHEL 5:

declare -A var
-bash: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...

Is there any work around for this? Is there any way that I can update only the declare command or only the bash shell to that which RHEL 6 is using?

bash versions are: rhel5 - bash-3.2-24.el5 rhel6 - bash-4.1.2-9.el6_2.x86_64

jjno91

Posted 2014-07-10T21:05:31.377

Reputation: 313

It wouldn't hurt to mention the Bash versions you're using (hint: rpm -q bash). – Cristian Ciupitu – 2014-07-10T21:10:50.483

@CristianCiupitu added – jjno91 – 2014-07-10T21:14:04.137

Then Create associative array in bash 3, perhaps?

– Cristian Ciupitu – 2014-07-10T21:15:38.883

1You could just compile whatever version of bash you need on RHEL 5; it should be pretty straightforward. – jjlin – 2014-07-10T22:42:21.043

No answers