Search code examples
tcsh

why are my environmental variables permanent?


This problem has been bothering me for awhile. Occasionally I would set up an environmental variable in my .tcshrc file. As soon as I don't need it any more, I would remove it from my .tcshrc file; however, for some reason the variable became permanent in my shell. I thought that everything in the .tcshrc file were not meant to be permanent once the settings are commented or removed. This specifically happened to a new PATH that I wanted to add. Now that I don't need it any more, removing it from the .tcshrc file does nothing.


Solution

  • Your .tcshrc is an executable script. You have to actually execute it for changes to it to have any effect. This typically occurs (automatically) when you start a new shell.

    Another issue you may be running into is that environment varibles ar inherited by child processes. If your .tcshrc adds to variables rather than overwriting them (which isn't an uncommon thing to do with PATH) then this may cause the behavior you're seeing. Your current shell process has the extra entry in the PATH, and even though the child shell isn't adding it to the PATH (due to your recent .tcshrc change) it's already there.