Intel XENIX 286 Programmers Guide (86) - Tenox.tc
Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc
CHAPTER 8 csh : C SHEll The C shell program, csh, is a command language interpreter for XENIX system users. The C shell, like the standard XENIX shell sh, is an interface between you and XENIX commands and programs. It translates command lines typed at a terminal into corresponding system actions, gives you access to information such as your login name, home directory, and mailbox, and supports the construction of shell procedures for automating system tasks. This chapter explains how to use the C shell. It also explains the syntax and function of C shell commands and features and shows how to use these features to create shell procedures. The C shell is fully described in the entry csh in Appendix B, "Programming Commands." Invoking the C Shell You can invoke the C shell from another shell by typing the csh command csh at the standard shell's command line. You can also direct the system to invoke the C shell for you when you log in. If you have given the C shell as your login shell in your /etc/passwd file entry, the system automatically starts the C shell when you log in. After the system starts the C shell, the shell searches your home directory for the command files .cshrc and .login. If the shell finds the files, it executes the commands contained in them and then displays the C shell prompt, normally a percent sign (%}. The .cshrc file typically contains commands to be executed each time you start a C shell, and the .login file contains the commands to be executed each time you log into the system. The following is an example of a typical .login file: set ignoreeof set mail = (lusr/spool/mail/bill) set time = 15 set history = 10 mail This file contains several set commands. The set command is executed directly by the C shell; there is no corresponding XENIX program for this command. In the example, set is used to set the C-shell variable ignoreeof, which shields the C shell from logging out if CONTROL-D is pressed. Instead of CONTROL-D, the logout command is used to log out of the system. Setting the mail variable in the example causes the C shell to notify you if you receive any mail in the specified mailbox. 8-1
csh: C Shell XENIX Programming The C shell variable time is set to 15, causing the C shell to automatically print statistics lines for commands that execute for at least 15 seconds of CPU time. The variable history is set to 10, indicating that the C shell will remember the last 10 commands typed in its history list (described later). Finally, the XENIX mail program is invoked. When the C shell finishes processing the .login file, it begins reading commands from the terminal, prompting for each with % When you log out (by giving the logout command) the C shell prints logout and executes commands from the file .logout if it exists in your home directory. After that, the C shell term inates and XENIX logs you off the system. Using Shell Variab les The C shell maintains a set of variables. For example, in the above discussion, the variables history and time had the values 10 and 15. Each C shell variable has as its value an array of zero or more strings. C shell variables may be assigned values by the set command, which has several forms, the most useful of which is set name = value C shell variables can be used to store values to be used later in commands through a substitution mechanism. The C shell variables most commonly referenced are, however, those that the C shell itself refers to. By changing the values of these variables you can directly affect the behavior of the C shell. One of the most important variables is path, which contains a list of directory names. When you type a command name at your terminal, the C shell examines each named directory in turn until it finds an executable file with a name that corresponds to the name you typed. The set command with no arguments displays the values of all variables currently defined in the C shell. The following example shows typical default values: argv () home /usr/bill path (. /bin /usr/bin) prompt % shell /bi n/csh status 0 This output indicates that the variable path begins with the current directory indicated by dot (.), then /bin, and last /usr/bin. Your own local commands may be in the current directory. Normal XENIX commands reside in /bin and /usr/bin. 8-2
- Page 104 and 105: XENIX Programming adb: Program Debu
- Page 106 and 107: XENIX Programming adb: Program Debu
- Page 108 and 109: XENIX Programming adb: Program Debu
- Page 110 and 111: XENIX Programming adb: Program Debu
- Page 112 and 113: XENIX Programming adb: Program Debu
- Page 114 and 115: XENIX Programming adb: Program Debu
- Page 116 and 117: XENIX Programming int fcnt,gcnt,hcn
- Page 118 and 119: XENIX Programming adb: Program Debu
- Page 120 and 121: XENIX Programming adb: Program Debu
- Page 122 and 123: XENIX Programming adb: Program Debu
- Page 124 and 125: XENIX Programming adb: Program Debu
- Page 126 and 127: XENIX Programming adb: Program Debu
- Page 128: XENIX Programming adb: Program Debu
- Page 131 and 132: as: A sse m bier XENIX Programming
- Page 133 and 134: as: Assembler XENIX Programming The
- Page 135 and 136: as: Assembler XENIX Programming Key
- Page 137 and 138: as: Assembler The combination rules
- Page 139 and 140: as: Assembler XENIX Programming Ins
- Page 141 and 142: as: Assembler Initial Value Directi
- Page 143 and 144: as: Assembler XENIX Programming int
- Page 145 and 146: as: A sse m bier sub subb test test
- Page 147 and 148: as: Assembler XENIX Programming lnt
- Page 149 and 150: as: Assembler XENIX Programming lnt
- Page 151 and 152: as: Assembler XENIX Programming Imm
- Page 153 and 154: as: A sse m bier XENIX Programming
- Page 158 and 159: XENIX Programming csh: C Shell Some
- Page 160 and 161: XENIX Programm ing *w 32 * q % !c -
- Page 162 and 163: XENIX Programming csh: C Shell the
- Page 164 and 165: XENIX Programming csh: C Shell Usin
- Page 166 and 167: XENIX Programming csh: C Shell Usin
- Page 168 and 169: XENIX Programming csh: C Shell The
- Page 170 and 171: XENIX Programming csh: C Shell Note
- Page 172 and 173: XENIX Programming switch ( string c
- Page 174 and 175: XENIX Programming csh: C Shell Star
- Page 176 and 177: XENIX Programming csh: C Shell Spec
- Page 178 and 179: CHAPTER 9 lex : LEXICAL ANA LYZER G
- Page 180 and 181: XENIX Programming lex: Lexical Anal
- Page 182 and 183: XENIX Programming lex: Lexical Anal
- Page 184 and 185: XENIX Programming lex: Lexical Anal
- Page 186 and 187: XENIX Programming lex: Lexical Anal
- Page 188 and 189: XENIX Programming lex: Lexical Anal
- Page 190 and 191: XENIX Programming lex: Lexical Anal
- Page 192 and 193: XENIX Programm ing lex: Lexical Ana
- Page 194 and 195: XENIX Programming Specifying Source
- Page 196 and 197: XENIX Programming lex: Lexical Anal
- Page 198 and 199: XENIX Programming lex: Lexical Anal
- Page 200 and 201: XENIX Programming The definitions s
- Page 202 and 203: CHAPTER 10 yacc: COMPILER-COMPILER
- Page 204 and 205: XENIX Programming yacc: Compiler-Co
CHAPTER 8<br />
csh : C SHEll<br />
The C shell program, csh, is a command language interpreter for <strong>XENIX</strong> system users.<br />
The C shell, like the standard <strong>XENIX</strong> shell sh, is an interface between you and <strong>XENIX</strong><br />
commands and programs. It translates command lines typed at a terminal into<br />
corresponding system actions, gives you access to information such as your login name,<br />
home directory, and mailbox, and supports the construction of shell procedures for<br />
automating system tasks.<br />
This chapter explains how to use the C shell. It also explains the syntax and function of<br />
C shell commands and features and shows how to use these features to create shell<br />
procedures. The C shell is fully described in the entry csh in Appendix B, "Programming<br />
Commands."<br />
Invoking the C Shell<br />
You can invoke the C shell from another shell by typing the csh command<br />
csh<br />
at the standard shell's command line. You can also direct the system to invoke the C<br />
shell for you when you log in. If you have given the C shell as your login shell in your<br />
/e<strong>tc</strong>/passwd file entry, the system automatically starts the C shell when you log in.<br />
After the system starts the C shell, the shell searches your home directory for the<br />
command files .cshrc and .login. If the shell finds the files, it executes the commands<br />
contained in them and then displays the C shell prompt, normally a percent sign (%}.<br />
The .cshrc file typically contains commands to be executed each time you start a C<br />
shell, and the .login file contains the commands to be executed each time you log into<br />
the system. The following is an example of a typical .login file:<br />
set ignoreeof<br />
set mail = (lusr/spool/mail/bill)<br />
set time = 15<br />
set history = 10<br />
mail<br />
This file contains several set commands. The set command is executed directly by the<br />
C shell; there is no corresponding <strong>XENIX</strong> program for this command. In the example,<br />
set is used to set the C-shell variable ignoreeof, which shields the C shell from logging<br />
out if CONTROL-D is pressed. Instead of CONTROL-D, the logout command is used to<br />
log out of the system. Setting the mail variable in the example causes the C shell to<br />
notify you if you receive any mail in the specified mailbox.<br />
8-1