bash的出口不工作的只有一个变量 [英] bash export not working for only one variable
问题描述
有时候当我在bash出口它不给一个错误,但它并没有设置环境变量无论是。这就是我的意思是:
Occasionally when I export in bash it doesn't give an error but it doesn't set the environment variable either. Here's what I mean:
本作品:
bash-3.2$ export DYLD=$ABC_HOME
bash-3.2$ env | grep DYLD
DYLD=/Users/my_username/abc_home
但是,当我继续下去,这些不:
But when I continue, these don't:
bash-3.2$ export DYLD_LIBRARY=$ABC_HOME
bash-3.2$ env | grep DYLD
DYLD=/Users/my_username/abc_home
bash-3.2$ export DYLD_L=$ABC_HOME
bash-3.2$ env | grep DYLD
DYLD=/Users/my_username/abc_home
bash-3.2$ export DYLD_=$ABC_HOME
bash-3.2$ env | grep DYLD
DYLD=/Users/my_username/abc_home
任何想法,我可以看看如何解决这个问题?
Any idea what I could look at to fix this?
FWIW,按预期工作等用下划线出口,但这似乎开始失败一次,我在添加下划线。
FWIW, other exports with underscores work as expected, but this seems to start failing once I add the underscore in.
推荐答案
这似乎是一个OS X的保护(在埃尔卡皮坦增加可能)是$ P $被出口到生成的进程pvents这些(潜在的危险)的环境变量
This appears to be an OS X protection (added in El Capitan possibly) that prevents these (potentially dangerous) environment variables from being exported to spawned processes.
在苹果开发者论坛这个线程讨论这一些。
的官方文档<一个href=\"https://developer.apple.com/library/ios/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html#//apple_ref/doc/uid/TP40016462-CH3-SW1\">here还对此进行简要:
The official documentation here also documents this briefly:
由系统完整性保护,限制处理产卵儿童进程,如通过启动辅助过程中捆绑与 NSTask
或调用 EXEC( 2)
命令,将重置子进程的马赫特殊端口。任何动态连接器( dyld的
)的环境变量,如 DYLD_LIBRARY_PATH
,正在启动保护程序时清除。
Spawning children processes of processes restricted by System Integrity Protection, such as by launching a helper process in a bundle with
NSTask
or calling theexec(2)
command, resets the Mach special ports of that child process. Any dynamic linker (dyld
) environment variables, such asDYLD_LIBRARY_PATH
, are purged when launching protected processes.
这篇关于bash的出口不工作的只有一个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!