6

For example, I would like to use the following environment variable name and value in a Linux environment

myDN=OU=MY_OU,DC=MYDC,DC=local

Is the above allowed in a Linux environment?

Jorge Bucaran
  • 5,588
  • 2
  • 30
  • 48
TinMan
  • 105
  • 2
  • 8
  • Yes, environment variable values can contain any character except the null byte. There are restrictions on variable names, but not values. – Barmar Dec 12 '16 at 21:42
  • Are you having a problem with that environment variable? If so, post the code so we can help you solve it. – Barmar Dec 12 '16 at 21:43
  • Thank you Barmar. I have a Linux development environment in which I can test this. However, I'm sharing that environment with several others on my team, and I didn't want to disrupt their work in case the equals sign did not work for my environment variable value. You have answered my question; if you post it as an answer, I will mark it as the correct answer. – TinMan Dec 12 '16 at 22:05
  • How would setting an environment variable in your login affect your colleagues? – Barmar Dec 12 '16 at 22:06
  • The value here corresponds to a configurable pertaining to an LDAP connection. – TinMan Dec 12 '16 at 22:12
  • So? You can set environment variables directly in the shell, you don't have to modify LDAP. – Barmar Dec 12 '16 at 22:15
  • Sorry, I'm not following you. I'm not modifying LDAP. – TinMan Dec 13 '16 at 02:54
  • Then I'm not following you. What were you trying to avoid doing that would affect the rest of your team. – Barmar Dec 13 '16 at 03:13

1 Answers1

17

Environment variables can contain any character except \0, since the null byte is the C string terminator character. When parsing the environment, the first = in each environment variable separates the name from the value, but additional = characters have no impact.

barmar@dev:~$ export myDN=OU=MY_OU,DC=MYDC,DC=local
barmar@dev:~$ echo $myDN
OU=MY_OU,DC=MYDC,DC=local
Barmar
  • 741,623
  • 53
  • 500
  • 612