setenv变量在launchd.conf中有空格? [英] setenv variable with spaces in launchd.conf?
问题描述
我是Linux用户,最近刚购买了Mac.我试图设置我的IDE,发现Mac对于GUI应用程序不使用.bashrc/.bash_profile/等.因此,如果您有一个需要环境变量的GUI应用程序,则显然应该在/etc/launchd.conf
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
问题是,此文件使用csh样式setenv语法("setenv键值"而不是"export键='值'"),所以现在我有了一个带有空格的变量,我不知道该怎么办.什么都没用.这是我尝试测试的内容:
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
重新启动后,只有变量#5和#8幸存. (那些没有空格.)其余的都不在我的环境中.
After a reboot only var #5 and #8 survive. (The ones with no spaces.) None of the rest are in my environment.
推荐答案
尝试使用launchd(创建plist/Library/LaunchDaemons/java.props.plist):
Try using launchd instead (create plist /Library/LaunchDaemons/java.props.plist):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>java.props</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>setenv</string>
<string>JAVA_OPTS</string>
<string>-Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
</dict>
</plist>
这将运行一次并设置您的环境.希望对您有所帮助.
This will run once and set your environment up. Hope it'll help.
这篇关于setenv变量在launchd.conf中有空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!