Экспортировать переменные или установить их в .profile?

267
davidjhp

Я устанавливаю Apache Maven 3.1 на Ubuntu Desktop 10.04.

На странице установки http://maven.apache.org/download.cgi#Installation в разделе «Операционные системы на основе Unix» указывается экспорт нескольких переменных:

export M2_HOME=/home/hduser/workspace/apache-maven-3.1.0 export M2=$M2_HOME/bin export PATH=$M2:$PATH 

Когда я выйду из системы, а позже войду, я потеряю эти переменные. Так не имеет ли смысла устанавливать эти переменные в .profile, чтобы при последующем входе в систему эти переменные все равно были установлены? Почему на странице инструкции не указано, что, или они ожидают, что у меня будет здравый смысл сделать это самостоятельно?

0

1 ответ на вопрос

1
LawrenceC

export just makes the variables survive when another shell is called. A typical situation where another shell is called is when you invoke a script.

You'll definitely want to copy all those export statements in your .profile so that not only are they there when you login, but also exist in any subshells you may spawn through executing scripts and such.

I'd say this is a basic Unix thing.

Look at your current .profile - you'll likely already see an export PATH= statement in it.

Похожие вопросы