我正在尝试引入一个变量并将其添加到ubuntu 10.04中的全局路径中.根据
official docs,/ etc / environment是正确的地方.这是我的例子:
GRADLE_HOME=/etc/gradle-0.9-preview-3 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$GRADLE_HOME/bin"
GRADLE_HOME变量已添加到环境中,但它不会在PATH分配期间解释$GRADLE_HOME变量.硬编码很好.没什么大不了的,但我想知道是否支持变量替换,或者是否有更好的方法可以做到这一点?谢谢!
来自相关帖子的这个解释似乎提供了答案:
原文链接:https://www.f2er.com/ubuntu/348489.htmlBecause /etc/environment is not a shell script. It is the shell that does expansion of environment variables. The PAM module pam_env is what reads /etc/environment – and it treats it as a simple list of KEY=VAL pairs and sets up the environment accordingly. It has no language for doing variable expansion.