/etc/environment, variables aren't expanded

Cameron Hutchison lists at xdna.net
Sat May 17 02:47:26 UTC 2008


TomasN <nechtom at gmail.com> writes:

>Hi. Why the environment variables in /etc/environment aren't expaned?

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.

>JAVA_HOME="/opt/jdk1.6.0_06"
>JDK_HOME="$JAVA_HOME"
>JRE_HOME="$JDK_HOME/jre"
>PATH="$JDK_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

>... in /etc/profile each variable in quotes is expanded.

/etc/profile is a shell script, and as such it has access to the full
facilities of the shell.

I personally think /etc/environment is rather useless for the reasons
you've just found. It is too simplistic to just have KEY=VAL lines is a
lot of cases.

Just use /etc/profile instead of /etc/environment. That's what I do.

.




More information about the ubuntu-users mailing list