On Fri, Aug 17, 2012 at 03:19:56PM +0800, John Summerfield wrote: > In two cases I wish to pass an array in the environment, like so: > 14:28 john@Boomer$ STUFF[1]=one STUFFX=stuffx env | grep ^ST > STUFFX=stuffx > STUFF[1]=one
You are creating an environment variable called "STUFF[1]". This is an invalid environment variable name, but env(1) receives it and dutifully prints it out. However, Bash recognizes that it is an invalid name, and does not turn it into a usable shell variable. Some older versions of Bash would also strip such invalid variables from the environment before invoking child processes. Bash 4.2 leaves them in the environment because of complaints about build systems that were using them for some purpose. I don't know whether Bash 4.1 is one that stripped them or preserved them. In either case, you should not be writing programs that rely on invalid variable names.