The C shell reads its .cshrc, .login, and .logout setup files . Only will read the .login and .logout files. Back when csh was designed, this restriction worked fine. The shell that started as you logged in was flagged as a login shell, and it read all three files. You started other shells (shell escapes, shell scripts, etc.) from that login shell, and they would read only .cshrc.
Now, UNIX has interactive shells started by window systems (like all your setup commands in .cshrc isn't good because all read it... you definitely don't want to run terminal-setting commands like tset during shell escapes!), remote shells (like ), and other shells that might need some things set from the .login or .logout files. Depending on how these shells are invoked, these might not be login shells - so they might read only .cshrc. How can you handle that? Putting
To handle problems at login time, put almost all of your setup commands in .cshrc instead of .login. After the "login-only" commands have been read from .cshrc, set the ENV_SETas a flag. (There's nothing special about this name. You can pick any name you want.)
The shell will copy the "flag" variable to subshells and the .cshrc can test for it - if the variable exists, the login-only commands are skipped. That'll keep the commands from being read again in a shell escape.
Here are parts of a .cshrc that show the idea:
...Normal .cshrc stuff... if ($?prompt && ! $?ENV_SET) then # Do commands that used to go in .login file: setenv EDITOR /usr/ucb/vi tset ... setenv ENV_SET done endif
You should put a comment in the .login file to explain what you've done.
The .logout file should probably be read only once - when your last ("top-level") shell exits. If your top-level shell isn't a login shell, you can make it read .logout anyway. Here's how. First, along with the previous fixes to your .cshrc file, add an alias that will read your .logout file when you use the exit command. Also set theto force you to use the exit command when you log out. Now the chunk of your .cshrc will look like:
if ($?prompt && ! $?ENV_SET) then ... # Make all top-level interactive shells read .logout file: set ignoreeof alias exit 'source ~/.logout; ""exit' ... endif