If I have HTTP_PROXY defined in default my environment (by ~/.bash_profile), how can I unset the variable from a script?

I know that I can do unset HTTP_PROXY from the command line, but if I try to put this command in a script and run it, HTTP_PROXY is still defined. If I load the script using bash or source, it is still defined.

  • 3
    Could you post an example script? – Jeremy Kerr Mar 2 '11 at 14:09

When you run a script it will be executed in a separate child process which cannot affect the environment variables in the parent process (i.e. your interactive shell). However if you use the "source" command it will read lines from the script file and execute them in the current shell, so that should work.

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.