I couldn't find a way to set an environmental variable with dot (.).

For example:

export mule.home=/Users/chandra/mule/
export {mule.home}=/Users/chandra/mule/
export $mule.home=/Users/chandra/mule/

all throw an error indicating it's not a valid identifier, like:

-bash: export: `.home=/Users': not a valid identifier

Setting mule_home works but not mule.home. Any ideas, suggestions?

  • could you try mule\.home? – Kinjal Dixit Oct 30 '12 at 6:29
  • Doesn't work "restart"... but thanks for the suggestion. – bschandramohan Oct 30 '12 at 8:36

That is because a name with a dot—and you can believe your shell here—is not a valid identifier. From man bash:

name A word consisting only of alphanumeric characters and underscores, and beginning with an alphabetic character or an underscore. Also referred to as an identifier.

The dot is not an alphanumeric character and it's not an underscore either. You can create something like:

env mule.home=/Users/chandra/mule/

But you won't really be able to read this, as far as I know. Also, bash should prevent you from even creating those identifiers in the first place.

My suggestion would be to create the environment variable with an underscore instead, and possibly use UPPERCASE words, as it's common practice.

Or use another shell that supports dots in environment variables, for example csh and tcsh.

| improve this answer | |
  • Thanks slhck. we are setting it as part of some builds - don't have control of changing . to _. Will find out how it's being used and get back. – bschandramohan Oct 30 '12 at 8:39
  • 1
    In the case of env, since that's an external command bash doesn't have a say whether it's valid or not. – glenn jackman Oct 30 '12 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.