views:

142

answers:

2

I'm a Linux user that just recently got a mac. I'm trying to set up my IDE and found out that Macs don't use .bashrc / .bash_profile / etc. for GUI apps. So, if you have a GUI app that needs an environment variable, you're apparently supposed to do it in /etc/launchd.conf

The thing is, this file uses csh style setenv syntax ("setenv key value" instead of "export key='value'") so now that I have a variable that has a space in it, I don't know what to do. Nothing is working. This is what I've tried to test it:

setenv MAVEN_OPTS "-Xms512m -Xmx1024m"
setenv MAVEN_OPTS1 '-Xms512m -Xmx1024m'
setenv MAVEN_OPTS2 (-Xms512m -Xmx1024m)
setenv MAVEN_OPTS3=(-Xms512m -Xmx1024m)
setenv MAVEN_OPTS4 -Xms512m -Xmx1024m
setenv MAVEN_OPTS5 -Xms512m
setenv MAVEN_OPTS6 "$MAVEN_OPTS5 -Xmx1024"
setenv MAVEN_OPTS7 $MAVEN_OPTS5 -Xmx1024
setenv MAVEN_OPTS8 /just/checking
setenv MAVEN_OPTS9="-Xms512m -Xmx1024m"
setenv MAVEN_OPTS10='-Xms512m -Xmx1024m'
setenv MAVEN_OPTS11='-Xms512m\ -Xmx1024m'
setenv MAVEN_OPTS12 '-Xms512m\ -Xmx1024m'
setenv MAVEN_OPTS13 "-Xms512m\ -Xmx1024m"
setenv MAVEN_OPTS14 -Xms512m\ -Xmx1024m

After a reboot only var #5 and #8 survive. (The ones with no spaces.) None of the rest are in my environment.

A: 
$ setenv ABC a\ B
$ echo $ABC
a B

seems to do the trick.

Brian Agnew
It does work in a c-shell, I know, but for some reason doesn't work when inside /etc/launchd.conf. I don't get it. In fact, in a real c-shell several of the above work: the MAVEN_OPTS declaration works, as well as #s 1,6,12,13, and 14.
Gabriel
+1  A: 

It does not work as in a c-shell because /etc/launchd.conf is nothing but a sequence of special commands for launchctl. See the launchctl man page for a reference on what works in /etc/launchd.conf

Sadly, this still won't help you to solve this problem, but I hope it will clarify the context a little. To me this problem is a shortcoming in Apple's launchctl/launchd tools. I have a hard time working around it myself.