Up Next Previous

Startup and shutdown --- 啟動與關閉 tcsh

開始登入時, 作業系統先會去讀取 /etc/csh.cshrc and /etc/csh.login. 並執行裡頭的命令. 然後, 再依序讀取並執行使用者 個人目錄下的:
  1. ~/.tcshrc (+) 若不存在 ~/.tcshrc 則讀取 ~/.cshrc
  2. ~/.history (or the value of the histfile shell variable),
  3. ~/.login
  4. ~/.cshdirs (or the value of the dirsfile shell variable) (+).
The shell may read /etc/csh.login before instead of after /etc/csh.cshrc, and ~/.login before instead of after ~/.tcshrc or ~/.cshrc and ~/.history, if so compiled; see the version shell variable. (+)

Non-login shells read only /etc/csh.cshrc and ~/.tcshrc or ~/.cshrc on startup.

Commands like stty(1) and tset(1), which need be run only once per login, usually go in one's ~/.login file. Users who need to use the same set of files with both csh(1) and tcsh can have only a ~/.cshrc which checks for the existence of the tcsh shell variable (q.v.) before using tcsh-specific commands, or can have both a ~/.cshrc and a ~/.tcshrc which sources (see the builtin command) ~/.cshrc. The rest of this manual uses `~/.tcshrc' to mean `~/.tcshrc or, if ~/.tcshrc is not found, ~/.cshrc'.

In the normal case, the shell begins reading commands from the terminal, prompting with `> '. (Processing of arguments and the use of the shell to process files containing command scripts are described later.) The shell repeatedly reads a line of command input, breaks it into words, places it on the command history list, parses it and executes each command in the line.

One can log out by typing `^D' on an empty line, `logout' or `login' or via the shell's autologout mechanism (see the autologout shell variable). When a login shell terminates it sets the logout shell variable to `normal' or `automatic' as appropriate, then executes commands from the files /etc/csh.logout and ~/.logout. The shell may drop DTR on logout if so compiled; see the version shell variable.

The names of the system login and logout files vary from system to system for compatibility with different csh(1) variants; see FILES.

Up Next Previous