Is it possible to set an environment variable name containing a period in BASH?
I want to export several environment variables to a subprocess. As a result of circumstances outside my control, the names of the variables contain periods. In other words, I want to do something like this
> export foo.bar=123 bash: export: `foo.bar=123': not a valid identifier I've tried using quotes and backslashes. Is it just impossible to do this? Thanks |
Quote:
Quote:
|
I want to pass the variables to an external process launched from BASH. Is there any way to do this, other than using export?
Cheers. Quote:
|
As parameters?
Code:
./myprog "$foo" "$bar" "$whatever_else" |
The external process wants to receive the values as environment variables of the form foo.bar=123. I have no control over this.
I am just trying to find a way to invoke the external process from BASH. Maybe there is some other way to do it -- Perl perhaps? Cheers, Quote:
|
Quote:
No shell that I know of (including bash, the plain posix bourne shell -sh-, and all the csh variants) will allow that. I don't know anything about ksh though, so I won't speak about it. Are there any instructions that we can take at a look at or something? I really can't believe that the program has been done in such way because no shell that I know of can define identifiers which contains dots. Only A-Z,a-z,0-9 and _ are allowed, and the first character can't be a cypher. |
Quote:
Actually, csh and tcsh support dots in their variable names. Code:
[exussum:/] exussum% setenv A.B C.D |
environment variables names _themselves_ can contain any printable character except '='
http://www.opengroup.org/onlinepubs/...bd_chap08.html But various shells restrict the characters you can use. I have been bitten by this. See here, particularly catkin's suggestion: http://www.linuxquestions.org/questi...3/#post3915600 In C/C++ you would need to use setenv, e.g. setenv("X.X", "PQR", 1); and then fork() to launch your process that uses the variables. |
All times are GMT -5. The time now is 12:57 AM. |