(Solved) Ignoring Environment Variables when Starting a BASH Script
Hi all!
I'm doing some BASH script writing, and I'm trying to figure out a way to keep my script from inheriting any variables that the shell calling it had happened to EXPORT, working instead off of an environment that only includes the environment variables from the applicable config files (/etc/profile, ~/.bashrc, etc). Is there any way to do this? |
It's a bit of a dirty hack... but you could use:
Code:
for VAR in `env | cut -d= -f1`; do |
That should work, but you'll have to re-invoke /etc/profile and .bashrc and .bash_profile.
In fact you'd have to parse those files to just get env var defs and nothing else. :( If you really want control, decide which vars/vals you want and add those to the top of your script, overwriting previous defs. |
Thanks all. Here's what I finally went with.
Code:
env -i /bin/bash --login -i |
All times are GMT -5. The time now is 02:52 AM. |