Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm having a problem. I have set an environment variable in /etc/environment using BOOST_LIBRARYDIR="/usr/local/lib/boost/release".

echo $BOOST_LIBRARYDIR correctly echoes the value to the terminal. However, if I execute echo $BOOST_LIBRARYDIR in a script using ./test.sh it shows the env variable as empty. As I understand it, it should be set also for child processes?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

If you want an environment variable to be passed to children you must export it. To verify if it is exported use the env command. The safest way to do this is as follows.

BOOST_LIBRARYDIR="/usr/local/lib/boost/release"; export BOOST_LIBRARYDIR

Newer shells like bash and ksh accept the simpler form.

export BOOST_LIBRARYDIR ="/usr/local/lib/boost/release"
share|improve this answer
add comment

Since /etc/environment seems to be sourced from /etc/init/gdm.conf, I think you can substitute your line with

export BOOST_LIBRARYDIR="/usr/local/lib/boost/release"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.