Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my /etc/launchd.conf file, I added these lines in an effort to figure out exactly how to create globally scoped environment variables whose values contain whitespace.

setenv foo1 123456
setenv foo2 "123456"
setenv foo3 123\ 456
setenv foo4 "123\ 456"
setenv foo5 "123 456"
setenv foo6 "123\\ 456"
setenv foo7 '123456'
setenv foo8 '123 456'
setenv foo9 '123\ 456'
setenv foo10 '123\\ 456'

To see what stuck and what the results were, I ran set | grep foo. The result:


I'm out of ideas. Is this even possible? If so, what's the syntax?

share|improve this question
Here's a similar question on StackOverflow. – Emil Feb 9 '13 at 12:42
Thanks. I got it working for one environment variable, but I don't know how to get multiple environment variables created in the same plist file, so I'm trying a number of things to get that working at the moment. – Steve Taylor Feb 9 '13 at 12:57
I had two environment variables to create, so I ended up creating them in two separate plist files. It's an extremely verbose replacement for something so simple that Apple took away from us in Mountain Lion. – Steve Taylor Feb 9 '13 at 13:21

Use export instead of setenv.

export foo1=123456
export foo2="123456"   # foo2 should now have the same value as foo1   
export foo3=123\ 456
export foo4="123 456"  # foo4 should now have the same value as foo3
share|improve this answer
This does not work. The export command (which doesn't accept any arguments) simply exports the entire environment as a series of commands, appropriate for passing to a shell. For example: SHELL="/bin/bash"; export SHELL; – L S Oct 29 '13 at 19:38
As seen in your example, export only exports the variable named, not the entire environment. – Joe Block Feb 17 '14 at 2:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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