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?


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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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