Is it just a convention or all environment variables have to be uppercase?

Question

Is it just a convention or all environment variables have to be uppercase?

Answer

There is a general consensus on how to write environment variables or shell variables which is all uppercase with underscores if needed multiple words. This will help us and the computer to differentiate between them and other variables, for example, Google’s styleguide states:

All caps, separated with underscores, declared at the top of the file.

Constants and anything exported to the environment should be capitalized

Now, this is not something written in stone and some other companies and teams have their own terms and flexibility around the subject, so I recommend that at least to start with, it would be good practice to keep our environment variables in all caps and with underscores, then as we are more comfortable, adjust to what feels more comfortable for us, and whatever guide the teams we work with maintain.

18 Likes