Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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:

foo1=123456
foo2='"123456"'
foo7=''\''123456'\'''

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

share|improve this question
2  
Here's a similar question on StackOverflow. –  Emil Feb 9 '13 at 12:42
1  
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
1  
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

1 Answer 1

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 at 2:08

Your Answer

 
discard

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.