setenv&的奇怪行为OS X Yosemite中的getenv [英] Strange behaviour for setenv & getenv in OS X Yosemite
问题描述
设置环境变量时
launchctl setenv FOO test
我可以通过以下方式获取值
I can fetch the value by
launchctl getenv FOO
这使我返回测试",但很简单
which returns me 'test', but a simple
echo $FOO
不替代,结果为空.在同一终端以及新终端中.
doesn't substitute, the result is empty. In same terminal as well as in new terminal.
背景:优胜美地10.10不再支持/etc/launchd.conf进行系统范围的设置,因此
Background: Yosemite 10.10 doesn't support /etc/launchd.conf anymore for system wide settings, so Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra? looks pretty promising, but I need the access to the env vars via $VARNAME
, which doesn't work in my case.
推荐答案
As I wrote in section Issues / problems here in order your env variables were correctly taken by applications after system reboot you will need:
- 两个都登录两次:登录=>注销=>登录
- 或关闭&手动重新打开应用程序,应在其中使用env变量
- 或不要使用重新登录时重新打开窗口"功能.
发生这种情况是由于Apple拒绝对已加载的服务进行显式排序,因此在处理重新打开队列"的同时注册了env变量.
This happens due to Apple denies explicit ordering of loaded services, so env variables are registered in parallel with processing of the "reopen queue".
这篇关于setenv&的奇怪行为OS X Yosemite中的getenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!