How to export dot separated environment variables

bash, macos, unix

Solution

As others have said, bash doesn't allow it so you'll have to use your favourite scripting language to do it. For example, in Perl:

perl -e '$ENV{"property.name"} = "property.value"; system "bash"'

This will fire up a subshell bash with the `property.name` environment variable set, but you still can't access that environment variable from bash (although your program will be able to see it).

Edit: @MarkEdgar commented that the env command will work too:

 env 'property.name=property.value' bash # start a subshell, or
 env 'property.name=property.value' command arg1 arg2 ...   # Run your command

As usual, you only require quotes if you need to protect special characters from the shell or want to include spaces in the property name or value.

Problem

Execution of ``` user@EWD-MacBook-Pro:~$ export property.name=property.value ``` Gives me ``` -bash: export: `property.name=property.value': not a valid identifier ``` Is it possible to have system properties with dot inside? If so how do that?

Original source