2011-08-15, 17:15(+02), Francky Leyn: > Hello, > > if you have a variable, say VAR, > and you don't assign it a value, > and afterwards you test it, > what is the value of $VAR then? > > random, or an empty string? [...]
Upon startup, the shell makes one shell variable per environment variable whose name is compatible with shell variable names. So for instance, if bash receives "VAR=foo" in its environemt, $VAR will expand to foo. If it's passed "1=bar", $1 will not be affected, and it's the same for a few special variables of the shell. If passed "A+B=C" or "=D" for instance, that obviously won't be mapped to shell variables. Some shells do discard variables from the environment that can't be mapped to shell variables. That's not the case of bash. -- Stephane