Ubuntu – Can you use variables when editing /etc/environment in ubuntu 10.04

environment-variablesUbuntuubuntu-10.04

I'm trying to introduce a variable and add it to the global path in ubuntu 10.04. According to the official docs, /etc/environment is the right place. Here's what my example looks like:

GRADLE_HOME=/etc/gradle-0.9-preview-3
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$GRADLE_HOME/bin"

The GRADLE_HOME variable is added to the environment, but it's not interpreting the $GRADLE_HOME variable during the PATH assignment. Hard-coding it works fine. Not a big deal, but I'd like to know if variable substitution is supported, or if there's a better way to do this? Thanks!

Best Answer

This explanation from a related post appears to provide the answer:

Because /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.