Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

From the lfs doc:

The exec env -i.../bin/bash command in the .bash_profile replaces the running shell with a new one with a completely empty environment, except for the HOME, TERM, and PS1 variables. This ensures that no unwanted and potentially hazardous environment variables from the host system leak into the build environment. The technique used here achieves the goal of ensuring a clean environment.

What case will cause that problem?

Is there any simple example?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

There are plenty of variables which will change how the shell behaves, what programs are executed or can hook into new programs. Examples for some of the more problematic environment variables are CDPATH, LD_LIBRARY_PATH, LD_PRELOAD, PATH.

By resetting the environment you can ensure a clean and sane build environment without the need to take care/reset all kind of environment variables.

share|improve this answer
    
What you mean 'hook into new programs like CDPATH, LD_LIBRARY_PATH, LD_PRELOAD, PATH'? Thank you~ –  sam Jul 25 '12 at 16:20
    
@sam as i said environment variables can control many things, like which shared libraries are loaded or which program gets executed if you are using an unqualified command etc. i'll rephrase that sentence –  Ulrich Dangel Jul 25 '12 at 16:24
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.