> How is the program like 'ls' going to see a variable that is an array when originally it was a string delimited with ':'?
There are two things here: the command 'ls' that you type on your shell and the executable named 'ls' located in "/bin/ls" (or wherever) which can list directories.
Most shells, when encounter a command X (say, 'ls') they see their 'context' to see if 'X' is defined. If yes, they will execute it. If not, they will assume that the X is an executable and try to execute it.
That's what happening here.
Yes, that I get. I was asking how is the translation from shell to inside of a program happen. On linux, I presume it's done via getenv(3), which means that it can only support strings. The post below says that it simply joins on a ':'. Is that safe for all or even most cases (except obviously PATH, which is delimited by ':')?
There are two things here: the command 'ls' that you type on your shell and the executable named 'ls' located in "/bin/ls" (or wherever) which can list directories. Most shells, when encounter a command X (say, 'ls') they see their 'context' to see if 'X' is defined. If yes, they will execute it. If not, they will assume that the X is an executable and try to execute it. That's what happening here.
Perhaps the following silly script helps?
HTH