bash export not working for only one variable

前端 未结 2 1308
清歌不尽
清歌不尽 2020-12-04 02:44

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:

This works:

ba         


        
相关标签:
2条回答
  • 2020-12-04 03:15

    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.

    This thread on the Apple Developer Forums discuss this some.

    The official documentation here also documents this briefly:

    Spawning children processes of processes restricted by System Integrity Protection, such as by launching a helper process in a bundle with NSTask or calling the exec(2) command, resets the Mach special ports of that child process. Any dynamic linker (dyld) environment variables, such as DYLD_LIBRARY_PATH, are purged when launching protected processes.

    0 讨论(0)
  • 2020-12-04 03:29

    Try this :

    oldifs=$IFS
    IFS=$'\n'
    export DYLD_LIBRARY=$ABC_HOME
    env | grep DYLD
    IFS=$oldifs
    
    0 讨论(0)
提交回复
热议问题