cb0709e07d53c9d4f0f7e0be85d356aa598eb9b5
[dragonfly.git] / contrib / tcsh-6 / tcsh.man
1 .\" Copyright (c) 1980, 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\" 
28 .\" Style notes for the tcsh man page:
29 .\" 
30 .\" - Tags in lists are bold, except in the FILES section where they are
31 .\"   italic.
32 .\" 
33 .\" - References are bold for section headings and environment and shell
34 .\"   variables and italic for commands (externals, builtins, aliases, and
35 .\"   editor commands) and arguments to commands.
36 .\" 
37 .\" - Be careful with the .B and .I macros: they handle only a limited number
38 .\"   of words. Work around this with \fB and \fI, but only if absolutely
39 .\"   necessary, because tcsh.man2html uses .B/.I to find name anchors.
40 .\" 
41 .\" - Indent in multiples of 4, usually 8.
42 .\" 
43 .\" - Use `', not '' or "", except of course in shell syntax examples.
44 .\"   '' at the beginning of a line will vanish!
45 .\" 
46 .\" - Use \-, not -.
47 .\" 
48 .\" - Include the tilde when naming dot files. `~/.login', not `.login'.
49 .\" 
50 .\" - Refer to external commands in man page format, e.g., `csh(1)'. However,
51 .\"   tcsh is `tcsh', not `tcsh(1)', because this is the tcsh man page (and
52 .\"   see the next note anyway).
53 .\" 
54 .\" - Say `the shell', not `tcsh', unless distinguishing between tcsh and csh.
55 .\" 
56 .\" - Say `shell variable'/`environment variable' instead of `variable'
57 .\"   and `builtin command'/`editor command' instead of `builtin' or `command'
58 .\"   unless the distinction is absolutely clear from context.
59 .\" 
60 .\" - Use the simple present tense. `The shell uses', not `The shell will use'.
61 .\" 
62 .\" - IMPORTANT: Cross-reference as much as possible. Commands, variables,
63 .\"   etc. in the reference section should be mentioned in the appropriate
64 .\"   descriptive section, or at least in the reference-section description
65 .\"   of another command (or whatever) which is mentioned in a description
66 .\"   section. Remember to note OS-specific things in "OS variant support",
67 .\"   new features in NEW FEATURES and referenced external commands in SEE
68 .\"   ALSO.
69 .\" 
70 .\" - tcsh.man2html depends heavily on the specific nroff commands used in the
71 .\"   man page when the script was written. Please stick closely to the style
72 .\"   used here if you can. In particular, please don't use nroff commands
73 .\"   which aren't already used herein.
74 .\" 
75 .TH TCSH 1 "14 February 2012" "Astron 6.18.01"
76 .SH NAME
77 tcsh \- C shell with file name completion and command line editing
78 .SH SYNOPSIS
79 .B tcsh \fR[\fB\-bcdefFimnqstvVxX\fR] [\fB\-Dname\fR[\fB=value\fR]] [arg ...]
80 .br
81 .B tcsh \-l
82 .SH DESCRIPTION
83 \fItcsh\fR is an enhanced but completely compatible version of the Berkeley
84 UNIX C shell, \fIcsh\fR(1).
85 It is a command language interpreter usable both as an interactive login
86 shell and a shell script command processor.
87 It includes a command-line editor (see \fBThe command-line editor\fR),
88 programmable word completion (see \fBCompletion and listing\fR),
89 spelling correction (see \fBSpelling correction\fR),
90 a history mechanism (see \fBHistory substitution\fR),
91 job control (see \fBJobs\fR)
92 and a C-like syntax.
93 The \fBNEW FEATURES\fR section describes major enhancements of \fItcsh\fR
94 over \fIcsh\fR(1).
95 Throughout this manual, features of
96 \fItcsh\fR not found in most \fIcsh\fR(1) implementations
97 (specifically, the 4.4BSD \fIcsh\fR)
98 are labeled with `(+)', and features which are present in \fIcsh\fR(1)
99 but not usually documented are labeled with `(u)'.
100 .SS "Argument list processing"
101 If the first argument (argument 0) to the shell is `\-' then it is a
102 login shell.  A login shell can be also specified by invoking the shell with
103 the \fB\-l\fR flag as the only argument.
104 .PP
105 The rest of the flag arguments are interpreted as follows:
106 .TP 4
107 .B \-b
108 Forces a ``break'' from option processing, causing any
109 further shell arguments to be treated as non-option arguments.  The remaining
110 arguments will not be interpreted as shell options.  This may be used to pass
111 options to a shell script without confusion or possible subterfuge.  The shell
112 will not run a set-user ID script without this option.
113 .TP 4
114 .B \-c
115 Commands are read from the following argument (which must be present, and
116 must be a single argument),
117 stored in the \fBcommand\fR shell variable for reference, and executed.
118 Any remaining arguments are placed in the \fBargv\fR shell variable.
119 .TP 4
120 .B \-d
121 The shell loads the directory stack from \fI~/.cshdirs\fR as described under
122 \fBStartup and shutdown\fR, whether or not it is a login shell. (+)
123 .TP 4
124 .B \-D\fIname\fR[=\fIvalue\fR]
125 Sets the environment variable \fIname\fR to \fIvalue\fR. (Domain/OS only) (+)
126 .TP 4
127 .B \-e
128 The shell exits if any invoked command terminates abnormally or
129 yields a non-zero exit status.
130 .TP 4
131 .B \-f
132 The shell does not load any resource or startup files, or perform any 
133 command hashing, and thus starts faster.
134 .TP 4
135 .B \-F
136 The shell uses \fIfork\fR(2) instead of \fIvfork\fR(2) to spawn processes. (+)
137 .TP 4
138 .B \-i
139 The shell is interactive and prompts for its top-level input, even if
140 it appears to not be a terminal.  Shells are interactive without this option if
141 their inputs and outputs are terminals.
142 .TP 4
143 .B \-l
144 The shell is a login shell.  Applicable only if \fB\-l\fR is the only
145 flag specified.
146 .TP 4
147 .B \-m
148 The shell loads \fI~/.tcshrc\fR even if it does not belong to the effective
149 user.  Newer versions of \fIsu\fR(1) can pass \fB\-m\fR to the shell. (+)
150 .TP 4
151 .B \-n
152 The shell parses commands but does not execute them.
153 This aids in debugging shell scripts.
154 .TP 4
155 .B \-q
156 The shell accepts SIGQUIT (see \fBSignal handling\fR) and behaves when
157 it is used under a debugger.  Job control is disabled. (u)
158 .TP 4
159 .B \-s
160 Command input is taken from the standard input.
161 .TP 4
162 .B \-t
163 The shell reads and executes a single line of input.  A `\\' may be used to
164 escape the newline at the end of this line and continue onto another line.
165 .TP 4
166 .B \-v
167 Sets the \fBverbose\fR shell variable, so that
168 command input is echoed after history substitution.
169 .TP 4
170 .B \-x
171 Sets the \fBecho\fR shell variable, so that commands are echoed
172 immediately before execution.
173 .TP 4
174 .B \-V
175 Sets the \fBverbose\fR shell variable even before executing \fI~/.tcshrc\fR.
176 .TP 4
177 .B \-X
178 Is to \fB\-x\fR as \fB\-V\fR is to \fB\-v\fR.
179 .TP 4
180 .B \-\-help
181 Print a help message on the standard output and exit. (+)
182 .TP 4
183 .B \-\-version
184 Print the version/platform/compilation options on the standard output and exit.
185 This information is also contained in the \fBversion\fR shell variable. (+)
186 .PP
187 After processing of flag arguments, if arguments remain but none of the
188 \fB\-c\fR, \fB\-i\fR, \fB\-s\fR, or \fB\-t\fR options were given, the first
189 argument is taken as the name of a file of commands, or ``script'', to
190 be executed.  The shell opens this file and saves its name for possible
191 resubstitution by `$0'.  Because many systems use either the standard
192 version 6 or version 7 shells whose shell scripts are not compatible
193 with this shell, the shell uses such a `standard' shell to execute a script
194 whose first character is not a `#', i.e., that does not start with a
195 comment.
196 .PP
197 Remaining arguments are placed in the \fBargv\fR shell variable.
198 .SS "Startup and shutdown"
199 A login shell begins by executing commands from the system files
200 \fI/etc/csh.cshrc\fR and \fI/etc/csh.login\fR.
201 It then executes commands from files in the user's \fBhome\fR directory:
202 first \fI~/.tcshrc\fR (+)
203 or, if \fI~/.tcshrc\fR is not found, \fI~/.cshrc\fR,
204 then \fI~/.history\fR (or the value of the \fBhistfile\fR shell variable),
205 then \fI~/.login\fR,
206 and finally \fI~/.cshdirs\fR (or the value of the \fBdirsfile\fR shell variable) (+).
207 The shell may read \fI/etc/csh.login\fR before instead of after
208 \fI/etc/csh.cshrc\fR, and \fI~/.login\fR before instead of after
209 \fI~/.tcshrc\fR or \fI~/.cshrc\fR and \fI~/.history\fR, if so compiled;
210 see the \fBversion\fR shell variable. (+)
211 .PP
212 Non-login shells read only \fI/etc/csh.cshrc\fR and \fI~/.tcshrc\fR
213 or \fI~/.cshrc\fR on startup.
214 .PP
215 For examples of startup files, please consult
216 \fIhttp://tcshrc.sourceforge.net\fR.
217 .PP
218 Commands like \fIstty\fR(1) and \fItset\fR(1),
219 which need be run only once per login, usually go in one's \fI~/.login\fR file.
220 Users who need to use the same set of files with both \fIcsh\fR(1) and
221 \fItcsh\fR can have only a \fI~/.cshrc\fR which checks for the existence of the
222 \fBtcsh\fR shell variable (q.v.) before using \fItcsh\fR-specific commands,
223 or can have both a \fI~/.cshrc\fR and a \fI~/.tcshrc\fR which \fIsource\fRs
224 (see the builtin command) \fI~/.cshrc\fR.
225 The rest of this manual uses `\fI~/.tcshrc\fR' to mean `\fI~/.tcshrc\fR or,
226 if \fI~/.tcshrc\fR is not found, \fI~/.cshrc\fR'.
227 .PP
228 In the normal case, the shell begins reading commands from the terminal,
229 prompting with `> '.  (Processing of arguments and the use of the shell to
230 process files containing command scripts are described later.)
231 The shell repeatedly reads a line of command input, breaks it into words,
232 places it on the command history list, parses it and executes each command
233 in the line.
234 .PP
235 One can log out by typing `^D' on an empty line, `logout' or `login' or
236 via the shell's autologout mechanism (see the \fBautologout\fR shell variable).
237 When a login shell terminates it sets the \fBlogout\fR shell variable to
238 `normal' or `automatic' as appropriate, then
239 executes commands from the files
240 \fI/etc/csh.logout\fR and \fI~/.logout\fR.  The shell may drop DTR on logout
241 if so compiled; see the \fBversion\fR shell variable.
242 .PP
243 The names of the system login and logout files vary from system to system for
244 compatibility with different \fIcsh\fR(1) variants; see \fBFILES\fR.
245 .SS Editing
246 We first describe \fBThe command-line editor\fR.
247 The \fBCompletion and listing\fR and \fBSpelling correction\fR sections
248 describe two sets of functionality that are implemented as editor commands
249 but which deserve their own treatment.
250 Finally, \fBEditor commands\fR lists and describes
251 the editor commands specific to the shell and their default bindings.
252 .SS "The command-line editor (+)"
253 Command-line input can be edited using key sequences much like those used in
254 GNU Emacs or \fIvi\fR(1).
255 The editor is active only when the \fBedit\fR shell variable is set, which
256 it is by default in interactive shells.
257 The \fIbindkey\fR builtin can display and change key bindings.
258 Emacs-style key bindings are used by default
259 (unless the shell was compiled otherwise; see the \fBversion\fR shell variable),
260 but \fIbindkey\fR can change the key bindings to \fIvi\fR-style bindings en masse.
261 .PP
262 The shell always binds the arrow keys (as defined in the \fBTERMCAP\fR
263 environment variable) to
264 .PP
265 .PD 0
266 .RS +4
267 .TP 8
268 down
269 \fIdown-history\fR
270 .TP 8
271 up
272 \fIup-history\fR
273 .TP 8
274 left
275 \fIbackward-char\fR
276 .TP 8
277 right
278 \fIforward-char\fR
279 .PD
280 .RE
281 .PP
282 unless doing so would alter another single-character binding.
283 One can set the arrow key escape sequences to the empty string with \fIsettc\fR
284 to prevent these bindings.
285 The ANSI/VT100 sequences for arrow keys are always bound.
286 .PP
287 Other key bindings are, for the most part, what Emacs and \fIvi\fR(1)
288 users would expect and can easily be displayed by \fIbindkey\fR, so there
289 is no need to list them here.  Likewise, \fIbindkey\fR can list the editor
290 commands with a short description of each.
291 .PP
292 Note that editor commands do not have the same notion of a ``word'' as does the
293 shell.  The editor delimits words with any non-alphanumeric characters not in
294 the shell variable \fBwordchars\fR, while the shell recognizes only whitespace
295 and some of the characters with special meanings to it, listed under
296 \fBLexical structure\fR.
297 .SS "Completion and listing (+)"
298 The shell is often able to complete words when given a unique abbreviation.
299 Type part of a word (for example `ls /usr/lost') and hit the tab key to
300 run the \fIcomplete-word\fR editor command.
301 The shell completes the filename `/usr/lost' to `/usr/lost+found/',
302 replacing the incomplete word with the complete word in the input buffer.
303 (Note the terminal `/'; completion adds a `/' to the
304 end of completed directories and a space to the end of other completed words,
305 to speed typing and provide a visual indicator of successful completion.
306 The \fBaddsuffix\fR shell variable can be unset to prevent this.)
307 If no match is found (perhaps `/usr/lost+found' doesn't exist),
308 the terminal bell rings.
309 If the word is already complete (perhaps there is a `/usr/lost' on your
310 system, or perhaps you were thinking too far ahead and typed the whole thing)
311 a `/' or space is added to the end if it isn't already there.
312 .PP
313 Completion works anywhere in the line, not at just the end; completed
314 text pushes the rest of the line to the right.  Completion in the middle of a word
315 often results in leftover characters to the right of the cursor that need
316 to be deleted.
317 .PP
318 Commands and variables can be completed in much the same way.
319 For example, typing `em[tab]' would complete `em' to
320 `emacs' if \fIemacs\fR were the only command on your system beginning with `em'.
321 Completion can find a command in any directory in \fBpath\fR or if
322 given a full pathname.
323 Typing `echo $ar[tab]' would complete `$ar' to `$argv'
324 if no other variable began with `ar'.
325 .PP
326 The shell parses the input buffer to determine whether the word you want to
327 complete should be completed as a filename, command or variable.
328 The first word in the buffer and the first word following
329 `;', `|', `|&', `&&' or `||' is considered to be a command.
330 A word beginning with `$' is considered to be a variable.
331 Anything else is a filename.  An empty line is `completed' as a filename.
332 .PP
333 You can list the possible completions of a word at any time by typing `^D'
334 to run the \fIdelete-char-or-list-or-eof\fR editor command.
335 The shell lists the possible completions using the \fIls\-F\fR builtin (q.v.)
336 and reprints the prompt and unfinished command line, for example:
337 .IP "" 4
338 > ls /usr/l[^D]
339 .br
340 lbin/       lib/        local/      lost+found/
341 .br
342 > ls /usr/l
343 .PP
344 If the \fBautolist\fR shell variable is set, the shell lists the remaining
345 choices (if any) whenever completion fails:
346 .IP "" 4
347 > set autolist
348 .br
349 > nm /usr/lib/libt[tab]
350 .br
351 libtermcap.a@ libtermlib.a@
352 .br
353 > nm /usr/lib/libterm
354 .PP
355 If \fBautolist\fR is set to `ambiguous', choices are listed only when
356 completion fails and adds no new characters to the word being completed.
357 .PP
358 A filename to be completed can contain variables, your own or others' home
359 directories abbreviated with `~' (see \fBFilename substitution\fR) and
360 directory stack entries abbreviated with `='
361 (see \fBDirectory stack substitution\fR).  For example,
362 .IP "" 4
363 > ls ~k[^D]
364 .br
365 kahn    kas     kellogg
366 .br
367 > ls ~ke[tab]
368 .br
369 > ls ~kellogg/
370 .PP
371 or
372 .IP "" 4
373 > set local = /usr/local
374 .br
375 > ls $lo[tab]
376 .br
377 > ls $local/[^D]
378 .br
379 bin/ etc/ lib/ man/ src/
380 .br
381 > ls $local/
382 .PP
383 Note that variables can also be expanded explicitly with the
384 \fIexpand-variables\fR editor command.
385 .PP
386 \fIdelete-char-or-list-or-eof\fR lists at only the end of the line;
387 in the middle of a line it deletes the character under the cursor and
388 on an empty line it logs one out or, if \fBignoreeof\fR is set, does nothing.
389 `M-^D', bound to the editor command \fIlist-choices\fR, lists completion
390 possibilities anywhere on a line, and \fIlist-choices\fR (or any one of the
391 related editor commands that do or don't delete, list and/or log out,
392 listed under \fIdelete-char-or-list-or-eof\fR) can be bound to `^D' with
393 the \fIbindkey\fR builtin command if so desired.
394 .PP
395 The \fIcomplete-word-fwd\fR and \fIcomplete-word-back\fR editor commands
396 (not bound to any keys by default) can be used to cycle up and down through
397 the list of possible completions, replacing the current word with the next or
398 previous word in the list.
399 .PP
400 The shell variable \fBfignore\fR can be set to a list of suffixes to be
401 ignored by completion.  Consider the following:
402 .IP "" 4
403 > ls
404 .br
405 Makefile        condiments.h~   main.o          side.c
406 .br
407 README          main.c          meal            side.o
408 .br
409 condiments.h    main.c~
410 .br
411 > set fignore = (.o \\~)
412 .br
413 > emacs ma[^D]
414 .br
415 main.c   main.c~  main.o
416 .br
417 > emacs ma[tab]
418 .br
419 > emacs main.c
420 .PP
421 `main.c~' and `main.o' are ignored by completion (but not listing),
422 because they end in suffixes in \fBfignore\fR.
423 Note that a `\\' was needed in front of `~' to prevent it from being
424 expanded to \fBhome\fR as described under \fBFilename substitution\fR.
425 \fBfignore\fR is ignored if only one completion is possible.
426 .PP
427 If the \fBcomplete\fR shell variable is set to `enhance', completion
428 1) ignores case and 2) considers periods, hyphens and underscores
429 (`.', `\-' and `_') to be word separators and hyphens and underscores to
430 be equivalent.  If you had the following files
431 .IP "" 4
432 comp.lang.c      comp.lang.perl   comp.std.c++
433 .br
434 comp.lang.c++    comp.std.c
435 .PP
436 and typed `mail \-f c.l.c[tab]', it would be completed to
437 `mail \-f comp.lang.c', and ^D would list `comp.lang.c' and `comp.lang.c++'.
438 `mail \-f c..c++[^D]' would list `comp.lang.c++' and `comp.std.c++'.  Typing
439 `rm a\-\-file[^D]' in the following directory
440 .IP "" 4
441 A_silly_file    a-hyphenated-file    another_silly_file
442 .PP
443 would list all three files, because case is ignored and hyphens and
444 underscores are equivalent.  Periods, however, are not equivalent to
445 hyphens or underscores.
446 .PP
447 If the \fBcomplete\fR shell variable is set to `Enhance', completion
448 ignores case and differences between a hyphen and an underscore word
449 separator only when the user types a lowercase character or a hyphen.
450 Entering an uppercase character or an underscore will not match the 
451 corresponding lowercase character or hyphen word separator.  
452 Typing `rm a\-\-file[^D]' in the directory of the previous example would 
453 still list all three files, but typing `rm A\-\-file' would match only 
454 `A_silly_file' and typing `rm a__file[^D]' would match just `A_silly_file' 
455 and `another_silly_file' because the user explicitly used an uppercase 
456 or an underscore character.  
457 .PP
458 Completion and listing are affected by several other shell variables:
459 \fBrecexact\fR can be set to complete on the shortest possible unique
460 match, even if more typing might result in a longer match:
461 .IP "" 4
462 > ls
463 .br
464 fodder   foo      food     foonly
465 .br
466 > set recexact
467 .br
468 > rm fo[tab]
469 .PP
470 just beeps, because `fo' could expand to `fod' or `foo', but if we type
471 another `o',
472 .IP "" 4
473 > rm foo[tab]
474 .br
475 > rm foo
476 .PP
477 the completion completes on `foo', even though `food' and `foonly'
478 also match.
479 \fBautoexpand\fR can be set to run the \fIexpand-history\fR editor command
480 before each completion attempt, \fBautocorrect\fR can be set to
481 spelling-correct the word to be completed (see \fBSpelling correction\fR)
482 before each completion attempt and \fBcorrect\fR can be set to complete
483 commands automatically after one hits `return'.
484 \fBmatchbeep\fR can be set to make completion beep or not beep in a variety
485 of situations, and \fBnobeep\fR can be set to never beep at all.
486 \fBnostat\fR can be set to a list of directories and/or patterns that
487 match directories to prevent the completion mechanism from \fIstat\fR(2)ing
488 those directories.
489 \fBlistmax\fR and \fBlistmaxrows\fR can be set to limit the number of items
490 and rows (respectively) that are listed without asking first.
491 \fBrecognize_only_executables\fR can be set to make the shell list only
492 executables when listing commands, but it is quite slow.
493 .PP
494 Finally, the \fIcomplete\fR builtin command can be used to tell the shell how
495 to complete words other than filenames, commands and variables.
496 Completion and listing do not work on glob-patterns (see \fBFilename substitution\fR),
497 but the \fIlist-glob\fR and \fIexpand-glob\fR editor commands perform
498 equivalent functions for glob-patterns.
499 .SS "Spelling correction (+)"
500 The shell can sometimes correct the spelling of filenames, commands and variable names
501 as well as completing and listing them.
502 .PP
503 Individual words can be spelling-corrected with the \fIspell-word\fR
504 editor command (usually bound to M-s and M-S)
505 and the entire input buffer with \fIspell-line\fR (usually bound to M-$).
506 The \fBcorrect\fR shell variable can be set to `cmd' to correct the
507 command name or `all' to correct the entire line each time return is typed,
508 and \fBautocorrect\fR can be set to correct the word to be completed
509 before each completion attempt.
510 .PP
511 When spelling correction is invoked in any of these ways and
512 the shell thinks that any part of the command line is misspelled,
513 it prompts with the corrected line:
514 .IP "" 4
515 > set correct = cmd
516 .br
517 > lz /usr/bin
518 .br
519 CORRECT>ls /usr/bin (y|n|e|a)?
520 .PP
521 One can answer `y' or space to execute the corrected line,
522 `e' to leave the uncorrected command in the input buffer,
523 `a' to abort the command as if `^C' had been hit, and
524 anything else to execute the original line unchanged.
525 .PP
526 Spelling correction recognizes user-defined completions (see the
527 \fIcomplete\fR builtin command).  If an input word in a position for
528 which a completion is defined resembles a word in the completion list,
529 spelling correction registers a misspelling and suggests the latter
530 word as a correction.  However, if the input word does not match any of
531 the possible completions for that position, spelling correction does
532 not register a misspelling.
533 .PP
534 Like completion, spelling correction works anywhere in the line,
535 pushing the rest of the line to the right and possibly leaving
536 extra characters to the right of the cursor.
537 .PP
538 Beware: spelling correction is not guaranteed to work the way one intends,
539 and is provided mostly as an experimental feature.
540 Suggestions and improvements are welcome.
541 .SS "Editor commands (+)"
542 `bindkey' lists key bindings and `bindkey \-l' lists and briefly describes
543 editor commands.
544 Only new or especially interesting editor commands are described here.
545 See \fIemacs\fR(1) and \fIvi\fR(1) for descriptions of each editor's
546 key bindings.
547 .PP
548 The character or characters to which each command is bound by default is
549 given in parentheses.  `^\fIcharacter\fR' means a control character and
550 `M-\fIcharacter\fR' a meta character, typed as escape-\fIcharacter\fR
551 on terminals without a meta key.  Case counts, but commands that are bound
552 to letters by default are bound to both lower- and uppercase letters for
553 convenience.
554 .TP 8
555 .B complete-word \fR(tab)
556 Completes a word as described under \fBCompletion and listing\fR.
557 .TP 8
558 .B complete-word-back \fR(not bound)
559 Like \fIcomplete-word-fwd\fR, but steps up from the end of the list.
560 .TP 8
561 .B complete-word-fwd \fR(not bound)
562 Replaces the current word with the first word in the list of possible
563 completions.  May be repeated to step down through the list.
564 At the end of the list, beeps and reverts to the incomplete word.
565 .TP 8
566 .B complete-word-raw \fR(^X-tab)
567 Like \fIcomplete-word\fR, but ignores user-defined completions.
568 .TP 8
569 .B copy-prev-word \fR(M-^_)
570 Copies the previous word in the current line into the input buffer.
571 See also \fIinsert-last-word\fR.
572 .TP 8
573 .B dabbrev-expand \fR(M-/)
574 Expands the current word to the most recent preceding one for which
575 the current is a leading substring, wrapping around the history list
576 (once) if necessary.
577 Repeating \fIdabbrev-expand\fR without any intervening typing
578 changes to the next previous word etc., skipping identical matches
579 much like \fIhistory-search-backward\fR does.
580 .TP 8
581 .B delete-char \fR(not bound)
582 Deletes the character under the cursor.
583 See also \fIdelete-char-or-list-or-eof\fR.
584 .TP 8
585 .B delete-char-or-eof \fR(not bound)
586 Does \fIdelete-char\fR if there is a character under the cursor
587 or \fIend-of-file\fR on an empty line.
588 See also \fIdelete-char-or-list-or-eof\fR.
589 .TP 8
590 .B delete-char-or-list \fR(not bound)
591 Does \fIdelete-char\fR if there is a character under the cursor
592 or \fIlist-choices\fR at the end of the line.
593 See also \fIdelete-char-or-list-or-eof\fR.
594 .TP 8
595 .B delete-char-or-list-or-eof \fR(^D)
596 Does \fIdelete-char\fR if there is a character under the cursor,
597 \fIlist-choices\fR at the end of the line
598 or \fIend-of-file\fR on an empty line.
599 See also those three commands, each of which does only a single action, and
600 \fIdelete-char-or-eof\fR, \fIdelete-char-or-list\fR and \fIlist-or-eof\fR,
601 each of which does a different two out of the three.
602 .TP 8
603 .B down-history \fR(down-arrow, ^N)
604 Like \fIup-history\fR, but steps down, stopping at the original input line.
605 .TP 8
606 .B end-of-file \fR(not bound)
607 Signals an end of file, causing the shell to exit unless the \fBignoreeof\fR
608 shell variable (q.v.) is set to prevent this.
609 See also \fIdelete-char-or-list-or-eof\fR.
610 .TP 8
611 .B expand-history \fR(M-space)
612 Expands history substitutions in the current word.
613 See \fBHistory substitution\fR.
614 See also \fImagic-space\fR, \fItoggle-literal-history\fR and
615 the \fBautoexpand\fR shell variable.
616 .TP 8
617 .B expand-glob \fR(^X-*)
618 Expands the glob-pattern to the left of the cursor.
619 See \fBFilename substitution\fR.
620 .TP 8
621 .B expand-line \fR(not bound)
622 Like \fIexpand-history\fR, but
623 expands history substitutions in each word in the input buffer.
624 .TP 8
625 .B expand-variables \fR(^X-$)
626 Expands the variable to the left of the cursor.
627 See \fBVariable substitution\fR.
628 .TP 8
629 .B history-search-backward \fR(M-p, M-P)
630 Searches backwards through the history list for a command beginning with
631 the current contents of the input buffer up to the cursor and copies it
632 into the input buffer.
633 The search string may be a glob-pattern (see \fBFilename substitution\fR)
634 containing `*', `?', `[]' or `{}'.
635 \fIup-history\fR and \fIdown-history\fR will proceed from the
636 appropriate point in the history list.
637 Emacs mode only.
638 See also \fIhistory-search-forward\fR and \fIi-search-back\fR.
639 .TP 8
640 .B history-search-forward \fR(M-n, M-N)
641 Like \fIhistory-search-backward\fR, but searches forward.
642 .TP 8
643 .B i-search-back \fR(not bound)
644 Searches backward like \fIhistory-search-backward\fR, copies the first match
645 into the input buffer with the cursor positioned at the end of the pattern,
646 and prompts with `bck: ' and the first match.  Additional characters may be
647 typed to extend the search, \fIi-search-back\fR may be typed to continue
648 searching with the same pattern, wrapping around the history list if
649 necessary, (\fIi-search-back\fR must be bound to a
650 single character for this to work) or one of the following special characters
651 may be typed:
652 .PP
653 .RS +8
654 .RS +4
655 .PD 0
656 .TP 8
657 ^W
658 Appends the rest of the word under the cursor to the search pattern.
659 .TP 8
660 delete (or any character bound to \fIbackward-delete-char\fR)
661 Undoes the effect of the last character typed and deletes a character
662 from the search pattern if appropriate.
663 .TP 8
664 ^G
665 If the previous search was successful, aborts the entire search.
666 If not, goes back to the last successful search.
667 .TP 8
668 escape
669 Ends the search, leaving the current line in the input buffer.
670 .RE
671 .PD
672 .PP
673 Any other character not bound to \fIself-insert-command\fR terminates the
674 search, leaving the current line in the input buffer, and
675 is then interpreted as normal input.  In particular, a carriage return
676 causes the current line to be executed.
677 Emacs mode only.
678 See also \fIi-search-fwd\fR and \fIhistory-search-backward\fR.
679 .RE
680 .TP 8
681 .B i-search-fwd \fR(not bound)
682 Like \fIi-search-back\fR, but searches forward.
683 .TP 8
684 .B insert-last-word \fR(M-_)
685 Inserts the last word of the previous input line (`!$') into the input buffer.
686 See also \fIcopy-prev-word\fR.
687 .TP 8
688 .B list-choices \fR(M-^D)
689 Lists completion possibilities as described under \fBCompletion and listing\fR.
690 See also \fIdelete-char-or-list-or-eof\fR and \fIlist-choices-raw\fR.
691 .TP 8
692 .B list-choices-raw \fR(^X-^D)
693 Like \fIlist-choices\fR, but ignores user-defined completions.
694 .TP 8
695 .B list-glob \fR(^X-g, ^X-G)
696 Lists (via the \fIls\-F\fR builtin) matches to the glob-pattern
697 (see \fBFilename substitution\fR) to the left of the cursor.
698 .TP 8
699 .B list-or-eof \fR(not bound)
700 Does \fIlist-choices\fR
701 or \fIend-of-file\fR on an empty line.
702 See also \fIdelete-char-or-list-or-eof\fR.
703 .TP 8
704 .B magic-space \fR(not bound)
705 Expands history substitutions in the current line,
706 like \fIexpand-history\fR, and inserts a space.
707 \fImagic-space\fR is designed to be bound to the space bar,
708 but is not bound by default.
709 .TP 8
710 .B normalize-command \fR(^X-?)
711 Searches for the current word in PATH and, if it is found, replaces it with
712 the full path to the executable.  Special characters are quoted.  Aliases are
713 expanded and quoted but commands within aliases are not.  This command is
714 useful with commands that take commands as arguments, e.g., `dbx' and `sh \-x'.
715 .TP 8
716 .B normalize-path \fR(^X-n, ^X-N)
717 Expands the current word as described under the `expand' setting
718 of the \fBsymlinks\fR shell variable.
719 .TP 8
720 .B overwrite-mode \fR(unbound)
721 Toggles between input and overwrite modes.
722 .TP 8
723 .B run-fg-editor \fR(M-^Z)
724 Saves the current input line and
725 looks for a stopped job with a name equal to the last component of the
726 file name part of the \fBEDITOR\fR or \fBVISUAL\fR environment variables,
727 or, if neither is set, `ed' or `vi'.
728 If such a job is found, it is restarted as if `fg %\fIjob\fR' had been
729 typed.  This is used to toggle back and forth between an editor and
730 the shell easily.  Some people bind this command to `^Z' so they
731 can do this even more easily.
732 .TP
733 .B run-help \fR(M-h, M-H)
734 Searches for documentation on the current command, using the same notion of
735 `current command' as the completion routines, and prints it.  There is no way
736 to use a pager; \fIrun-help\fR is designed for short help files.
737 If the special alias \fBhelpcommand\fR is defined, it is run with the
738 command name as a sole argument.  Else,
739 documentation should be in a file named \fIcommand\fR.help, \fIcommand\fR.1,
740 \fIcommand\fR.6, \fIcommand\fR.8 or \fIcommand\fR, which should be in one
741 of the directories listed in the \fBHPATH\fR environment variable.
742 If there is more than one help file only the first is printed.
743 .TP 8
744 .B self-insert-command \fR(text characters)
745 In insert mode (the default), inserts the typed character into the input line after the character under the cursor.
746 In overwrite mode, replaces the character under the cursor with the typed character.
747 The input mode is normally preserved between lines, but the
748 \fBinputmode\fR shell variable can be set to `insert' or `overwrite' to put the
749 editor in that mode at the beginning of each line.
750 See also \fIoverwrite-mode\fR.
751 .TP 8
752 .B sequence-lead-in \fR(arrow prefix, meta prefix, ^X)
753 Indicates that the following characters are part of a
754 multi-key sequence.  Binding a command to a multi-key sequence really creates
755 two bindings: the first character to \fIsequence-lead-in\fR and the
756 whole sequence to the command.  All sequences beginning with a character
757 bound to \fIsequence-lead-in\fR are effectively bound to \fIundefined-key\fR
758 unless bound to another command.
759 .TP 8
760 .B spell-line \fR(M-$)
761 Attempts to correct the spelling of each word in the input buffer, like
762 \fIspell-word\fR, but ignores words whose first character is one of
763 `\-', `!', `^' or `%', or which contain `\\', `*' or `?', to avoid problems
764 with switches, substitutions and the like.
765 See \fBSpelling correction\fR.
766 .TP 8
767 .B spell-word \fR(M-s, M-S)
768 Attempts to correct the spelling of the current word as described
769 under \fBSpelling correction\fR.
770 Checks each component of a word which appears to be a pathname.
771 .TP 8
772 .B toggle-literal-history \fR(M-r, M-R)
773 Expands or `unexpands' history substitutions in the input buffer.
774 See also \fIexpand-history\fR and the \fBautoexpand\fR shell variable.
775 .TP 8
776 .B undefined-key \fR(any unbound key)
777 Beeps.
778 .TP 8
779 .B up-history \fR(up-arrow, ^P)
780 Copies the previous entry in the history list into the input buffer.
781 If \fBhistlit\fR is set, uses the literal form of the entry.
782 May be repeated to step up through the history list, stopping at the top.
783 .TP 8
784 .B vi-search-back \fR(?)
785 Prompts with `?' for a search string (which may be a glob-pattern, as with
786 \fIhistory-search-backward\fR), searches for it and copies it into the
787 input buffer.  The bell rings if no match is found.
788 Hitting return ends the search and leaves the last match in the input
789 buffer.
790 Hitting escape ends the search and executes the match.
791 \fIvi\fR mode only.
792 .TP 8
793 .B vi-search-fwd \fR(/)
794 Like \fIvi-search-back\fR, but searches forward.
795 .TP 8
796 .B which-command \fR(M-?)
797 Does a \fIwhich\fR (see the description of the builtin command) on the
798 first word of the input buffer.
799 .TP 8
800 .B yank-pop \fR(M-y)
801 When executed immediately after a \fIyank\fR or another \fIyank-pop\fR,
802 replaces the yanked string with the next previous string from the
803 killring. This also has the effect of rotating the killring, such that
804 this string will be considered the most recently killed by a later
805 \fIyank\fR command. Repeating \fIyank-pop\fR will cycle through the
806 killring any number of times.
807 .SS "Lexical structure"
808 The shell splits input lines into words at blanks and tabs.  The special
809 characters `&', `|', `;', `<', `>', `(', and `)' and the doubled characters
810 `&&', `||', `<<' and `>>' are always separate words, whether or not they are
811 surrounded by whitespace.
812 .PP
813 When the shell's input is not a terminal, the character `#' is taken to begin a
814 comment.  Each `#' and the rest of the input line on which it appears is
815 discarded before further parsing.
816 .PP
817 A special character (including a blank or tab) may be prevented from having
818 its special meaning, and possibly made part of another word, by preceding it
819 with a backslash (`\\') or enclosing it in single (`''), double (`"') or
820 backward (``') quotes.  When not otherwise quoted a newline preceded by a `\\'
821 is equivalent to a blank, but inside quotes this sequence results in a
822 newline.
823 .PP
824 Furthermore, all \fBSubstitutions\fR (see below) except \fBHistory substitution\fR
825 can be prevented by enclosing the strings (or parts of strings)
826 in which they appear with single quotes or by quoting the crucial character(s)
827 (e.g., `$' or ``' for \fBVariable substitution\fR or \fBCommand substitution\fR respectively)
828 with `\\'.  (\fBAlias substitution\fR is no exception: quoting in any way any
829 character of a word for which an \fIalias\fR has been defined prevents
830 substitution of the alias.  The usual way of quoting an alias is to precede it
831 with a backslash.) \fBHistory substitution\fR is prevented by
832 backslashes but not by single quotes.  Strings quoted with double or backward
833 quotes undergo \fBVariable substitution\fR and \fBCommand substitution\fR, but other
834 substitutions are prevented.
835 .PP
836 Text inside single or double quotes becomes a single word (or part of one).
837 Metacharacters in these strings, including blanks and tabs, do not form
838 separate words.  Only in one special case (see \fBCommand substitution\fR
839 below) can a double-quoted string yield parts of more than one word;
840 single-quoted strings never do.  Backward quotes are special: they signal
841 \fBCommand substitution\fR (q.v.), which may result in more than one word.
842 .PP
843 Quoting complex strings, particularly strings which themselves contain quoting
844 characters, can be confusing.  Remember that quotes need not be used as they are
845 in human writing!  It may be easier to quote not an entire string, but only
846 those parts of the string which need quoting, using different types of quoting
847 to do so if appropriate.
848 .PP
849 The \fBbackslash_quote\fR shell variable (q.v.) can be set to make backslashes
850 always quote `\\', `'', and `"'.  (+) This may make complex quoting tasks
851 easier, but it can cause syntax errors in \fIcsh\fR(1) scripts.
852 .SS Substitutions
853 We now describe the various transformations the shell performs on the input in
854 the order in which they occur.  We note in passing the data structures involved
855 and the commands and variables which affect them.  Remember that substitutions
856 can be prevented by quoting as described under \fBLexical structure\fR.
857 .SS "History substitution"
858 Each command, or ``event'', input from the terminal is saved in the history
859 list.  The previous command is always saved, and the \fBhistory\fR shell
860 variable can be set to a number to save that many commands.  The \fBhistdup\fR
861 shell variable can be set to not save duplicate events or consecutive duplicate
862 events.
863 .PP
864 Saved commands are numbered sequentially from 1 and stamped with the time.
865 It is not usually necessary to use event numbers, but the current event number
866 can be made part of the prompt by placing an `!' in the \fBprompt\fR shell variable.
867 .PP
868 The shell actually saves history in expanded and literal (unexpanded) forms.
869 If the \fBhistlit\fR shell variable is set, commands that display and store
870 history use the literal form.
871 .PP
872 The \fIhistory\fR builtin command can print, store in a file, restore
873 and clear the history list at any time,
874 and the \fBsavehist\fR and \fBhistfile\fR shell variables can be set to
875 store the history list automatically on logout and restore it on login.
876 .PP
877 History substitutions introduce words from the history list into the input
878 stream, making it easy to repeat commands, repeat arguments of a previous
879 command in the current command, or fix spelling mistakes in the previous
880 command with little typing and a high degree of confidence.
881 .PP
882 History substitutions begin with the character `!'.  They may begin anywhere in
883 the input stream, but they do not nest.  The `!' may be preceded by a `\\' to
884 prevent its special meaning; for convenience, a `!' is passed unchanged when it
885 is followed by a blank, tab, newline, `=' or `('.  History substitutions also
886 occur when an input line begins with `^'.  This special abbreviation will be
887 described later.  The characters used to signal history substitution (`!' and
888 `^') can be changed by setting the \fBhistchars\fR shell variable.  Any input
889 line which contains a history substitution is printed before it is executed.
890 .PP
891 A history substitution may have an ``event specification'', which indicates
892 the event from which words are to be taken, a ``word designator'',
893 which selects particular words from the chosen event, and/or a ``modifier'',
894 which manipulates the selected words.
895 .PP
896 An event specification can be
897 .PP
898 .PD 0
899 .RS +4
900 .TP 8
901 .I n
902 A number, referring to a particular event
903 .TP 8
904 \-\fIn\fR
905 An offset, referring to the event \fIn\fR before the current event
906 .TP 8
907 #
908 The current event.
909 This should be used carefully in \fIcsh\fR(1), where there is no check for
910 recursion.  \fItcsh\fR allows 10 levels of recursion.  (+)
911 .TP 8
912 !
913 The previous event (equivalent to `\-1')
914 .TP 8
915 .I s
916 The most recent event whose first word begins with the string \fIs\fR
917 .TP 8
918 ?\fIs\fR?
919 The most recent event which contains the string \fIs\fR.
920 The second `?' can be omitted if it is immediately followed by a newline.
921 .RE
922 .PD
923 .PP
924 For example, consider this bit of someone's history list:
925 .IP "" 4
926 \ 9  8:30    nroff \-man wumpus.man
927 .br
928 10  8:31    cp wumpus.man wumpus.man.old
929 .br
930 11  8:36    vi wumpus.man
931 .br
932 12  8:37    diff wumpus.man.old wumpus.man
933 .PP
934 The commands are shown with their event numbers and time stamps.
935 The current event, which we haven't typed in yet, is event 13.
936 `!11' and `!\-2' refer to event 11.
937 `!!' refers to the previous event, 12.  `!!' can be abbreviated `!' if it is
938 followed by `:' (`:' is described below).
939 `!n' refers to event 9, which begins with `n'.
940 `!?old?' also refers to event 12, which contains `old'.
941 Without word designators or modifiers history references simply expand to the
942 entire event, so we might type `!cp' to redo the copy command or `!!|more'
943 if the `diff' output scrolled off the top of the screen.
944 .PP
945 History references may be insulated from the surrounding text with braces if
946 necessary.  For example, `!vdoc' would look for a command beginning with
947 `vdoc', and, in this example, not find one, but `!{v}doc' would expand
948 unambiguously to `vi wumpus.mandoc'.
949 Even in braces, history substitutions do not nest.
950 .PP
951 (+) While \fIcsh\fR(1) expands, for example, `!3d' to event 3 with the
952 letter `d' appended to it, \fItcsh\fR expands it to the last event beginning
953 with `3d'; only completely numeric arguments are treated as event numbers.
954 This makes it possible to recall events beginning with numbers.
955 To expand `!3d' as in \fIcsh\fR(1) say `!{3}d'.
956 .PP
957 To select words from an event we can follow the event specification by a `:'
958 and a designator for the desired words.  The words of an input line are
959 numbered from 0, the first (usually command) word being 0, the second word
960 (first argument) being 1, etc.  The basic word designators are:
961 .PP
962 .PD 0
963 .RS +4
964 .TP 8
965 0
966 The first (command) word
967 .TP 8
968 .I n
969 The \fIn\fRth argument
970 .TP 8
971 ^
972 The first argument, equivalent to `1'
973 .TP 8
974 $
975 The last argument
976 .TP 8
977 %
978 The word matched by an ?\fIs\fR? search
979 .TP 8
980 .I x\-y
981 A range of words
982 .TP 8
983 .I \-y
984 Equivalent to \fI`0\-y'\fR
985 .TP 8
986 *
987 Equivalent to `^\-$', but returns nothing if the event contains only 1 word
988 .TP 8
989 .I x*
990 Equivalent to \fI`x\-$'\fR
991 .TP 8
992 .I x\-
993 Equivalent to \fI`x*'\fR, but omitting the last word (`$')
994 .PD
995 .RE
996 .PP
997 Selected words are inserted into the command line separated by single blanks.
998 For example, the `diff' command in the previous example might have been
999 typed as `diff !!:1.old !!:1' (using `:1' to select the first argument
1000 from the previous event) or `diff !\-2:2 !\-2:1' to select and swap the
1001 arguments from the `cp' command.  If we didn't care about the order of the
1002 `diff' we might have said `diff !\-2:1\-2' or simply `diff !\-2:*'.
1003 The `cp' command might have been written `cp wumpus.man !#:1.old', using `#'
1004 to refer to the current event.
1005 `!n:\- hurkle.man' would reuse the first two words from the `nroff' command
1006 to say `nroff \-man hurkle.man'.
1007 .PP
1008 The `:' separating the event specification from the word designator can be
1009 omitted if the argument selector begins with a `^', `$', `*', `%' or `\-'.
1010 For example, our `diff' command might have been `diff !!^.old !!^' or,
1011 equivalently, `diff !!$.old !!$'.  However, if `!!' is abbreviated `!',
1012 an argument selector beginning with `\-' will be interpreted as an event
1013 specification.
1014 .PP
1015 A history reference may have a word designator but no event specification.
1016 It then references the previous command.
1017 Continuing our `diff' example, we could have said simply `diff
1018 !^.old !^' or, to get the arguments in the opposite order, just `diff !*'.
1019 .PP
1020 The word or words in a history reference can be edited, or ``modified'',
1021 by following it with one or more modifiers, each preceded by a `:':
1022 .PP
1023 .PD 0
1024 .RS +4
1025 .TP 8
1026 h
1027 Remove a trailing pathname component, leaving the head.
1028 .TP 8
1029 t
1030 Remove all leading pathname components, leaving the tail.
1031 .TP 8
1032 r
1033 Remove a filename extension `.xxx', leaving the root name.
1034 .TP 8
1035 e
1036 Remove all but the extension.
1037 .TP 8
1038 u
1039 Uppercase the first lowercase letter.
1040 .TP 8
1041 l
1042 Lowercase the first uppercase letter.
1043 .TP 8
1044 s\fI/l/r/\fR
1045 Substitute \fIl\fR for \fIr\fR.
1046 \fIl\fR is simply a string like \fIr\fR, not a regular expression as in
1047 the eponymous \fIed\fR(1) command.
1048 Any character may be used as the delimiter in place of `/';
1049 a `\\' can be used to quote the delimiter inside \fIl\fR and \fIr\fR.
1050 The character `&' in the \fIr\fR is replaced by \fIl\fR; `\\' also quotes `&'.
1051 If \fIl\fR is empty (``''), the \fIl\fR from a previous substitution or the
1052 \fIs\fR from a previous search or event number in event specification is used.
1053 The trailing delimiter may be omitted if it is immediately followed by a newline.
1054 .TP 8
1055 &
1056 Repeat the previous substitution.
1057 .TP 8
1058 g
1059 Apply the following modifier once to each word.
1060 .TP 8
1061 a (+)
1062 Apply the following modifier as many times as possible to a single word.
1063 `a' and `g' can be used together to apply a modifier globally.
1064 With the `s' modifier, only the patterns contained in the original word are
1065 substituted, not patterns that contain any substitution result.
1066 .TP 8
1067 p
1068 Print the new command line but do not execute it.
1069 .TP 8
1070 q
1071 Quote the substituted words, preventing further substitutions.
1072 .TP 8
1073 x
1074 Like q, but break into words at blanks, tabs and newlines.
1075 .PD
1076 .RE
1077 .PP
1078 Modifiers are applied to only the first modifiable word (unless `g' is used).
1079 It is an error for no word to be modifiable.
1080 .PP
1081 For example, the `diff' command might have been written as `diff wumpus.man.old
1082 !#^:r', using `:r' to remove `.old' from the first argument on the same line
1083 (`!#^').  We could say `echo hello out there', then `echo !*:u' to capitalize
1084 `hello', `echo !*:au' to say it out loud, or `echo !*:agu' to really shout.
1085 We might follow `mail \-s "I forgot my password" rot' with `!:s/rot/root' to
1086 correct the spelling of `root' (but see \fBSpelling correction\fR for a
1087 different approach).
1088 .PP
1089 There is a special abbreviation for substitutions.
1090 `^', when it is the first character on an input line, is equivalent to `!:s^'.
1091 Thus we might have said `^rot^root' to make the spelling correction in the
1092 previous example.
1093 This is the only history substitution which does not explicitly begin with `!'.
1094 .PP
1095 (+) In \fIcsh\fR as such, only one modifier may be applied to each history
1096 or variable expansion.  In \fItcsh\fR, more than one may be used, for example
1097 .IP "" 4
1098 % mv wumpus.man /usr/man/man1/wumpus.1
1099 .br
1100 % man !$:t:r
1101 .br
1102 man wumpus
1103 .PP
1104 In \fIcsh\fR, the result would be `wumpus.1:r'.  A substitution followed by a
1105 colon may need to be insulated from it with braces:
1106 .IP "" 4
1107 > mv a.out /usr/games/wumpus
1108 .br
1109 > setenv PATH !$:h:$PATH
1110 .br
1111 Bad ! modifier: $.
1112 .br
1113 > setenv PATH !{\-2$:h}:$PATH
1114 .br
1115 setenv PATH /usr/games:/bin:/usr/bin:.
1116 .PP
1117 The first attempt would succeed in \fIcsh\fR but fails in \fItcsh\fR,
1118 because \fItcsh\fR expects another modifier after the second colon
1119 rather than `$'.
1120 .PP
1121 Finally, history can be accessed through the editor as well as through
1122 the substitutions just described.
1123 The \fIup-\fR and \fIdown-history\fR, \fIhistory-search-backward\fR and
1124 \fI-forward\fR, \fIi-search-back\fR and \fI-fwd\fR,
1125 \fIvi-search-back\fR and \fI-fwd\fR, \fIcopy-prev-word\fR
1126 and \fIinsert-last-word\fR editor commands search for
1127 events in the history list and copy them into the input buffer.
1128 The \fItoggle-literal-history\fR editor command switches between the
1129 expanded and literal forms of history lines in the input buffer.
1130 \fIexpand-history\fR and \fIexpand-line\fR expand history substitutions
1131 in the current word and in the entire input buffer respectively.
1132 .SS "Alias substitution"
1133 The shell maintains a list of aliases which can be set, unset and printed by
1134 the \fIalias\fR and \fIunalias\fR commands.  After a command line is parsed
1135 into simple commands (see \fBCommands\fR) the first word of each command,
1136 left-to-right, is checked to see if it has an alias.  If so, the first word is
1137 replaced by the alias.  If the alias contains a history reference, it undergoes
1138 \fBHistory substitution\fR (q.v.) as though the original command were the
1139 previous input line.  If the alias does not contain a history reference, the
1140 argument list is left untouched.
1141 .PP
1142 Thus if the alias for `ls' were `ls \-l' the command `ls /usr' would become `ls
1143 \-l /usr', the argument list here being undisturbed.  If the alias for `lookup'
1144 were `grep !^ /etc/passwd' then `lookup bill' would become `grep bill
1145 /etc/passwd'.  Aliases can be used to introduce parser metasyntax.  For
1146 example, `alias print 'pr \e!* | lpr'' defines a ``command'' (`print') which
1147 \fIpr\fR(1)s its arguments to the line printer.
1148 .PP
1149 Alias substitution is repeated until the first word of the command has no
1150 alias.  If an alias substitution does not change the first word (as in the
1151 previous example) it is flagged to prevent a loop.  Other loops are detected and
1152 cause an error.
1153 .PP
1154 Some aliases are referred to by the shell; see \fBSpecial aliases\fR.
1155 .SS "Variable substitution"
1156 The shell maintains a list of variables, each of which has as value a list of
1157 zero or more words.
1158 The values of shell variables can be displayed and changed with the
1159 \fIset\fR and \fIunset\fR commands.
1160 The system maintains its own list of ``environment'' variables.
1161 These can be displayed and changed with \fIprintenv\fR, \fIsetenv\fR and
1162 \fIunsetenv\fR.
1163 .PP
1164 (+) Variables may be made read-only with `set \-r' (q.v.).
1165 Read-only variables may not be modified or unset;
1166 attempting to do so will cause an error.
1167 Once made read-only, a variable cannot be made writable,
1168 so `set \-r' should be used with caution.
1169 Environment variables cannot be made read-only.
1170 .PP
1171 Some variables are set by the shell or referred to by it.
1172 For instance, the \fBargv\fR variable is an image of the shell's argument
1173 list, and words of this variable's value are referred to in special ways.
1174 Some of the variables referred to by the shell are toggles;
1175 the shell does not care what their value is, only whether they are set or not.
1176 For instance, the \fBverbose\fR variable is a toggle which causes command
1177 input to be echoed.  The \fB\-v\fR command line option sets this variable.
1178 \fBSpecial shell variables\fR lists all variables which are referred to by the shell.
1179 .PP
1180 Other operations treat variables numerically.  The `@' command permits numeric
1181 calculations to be performed and the result assigned to a variable.  Variable
1182 values are, however, always represented as (zero or more) strings.  For the
1183 purposes of numeric operations, the null string is considered to be zero, and
1184 the second and subsequent words of multi-word values are ignored.
1185 .PP
1186 After the input line is aliased and parsed, and before each command is
1187 executed, variable substitution is performed keyed by `$' characters.  This
1188 expansion can be prevented by preceding the `$' with a `\e' except within `"'s
1189 where it \fIalways\fR occurs, and within `''s where it \fInever\fR occurs.
1190 Strings quoted by ``' are interpreted later (see \fBCommand substitution\fR
1191 below) so `$' substitution does not occur there until later,
1192 if at all.  A `$' is passed unchanged if followed by a blank, tab, or
1193 end-of-line.
1194 .PP
1195 Input/output redirections are recognized before variable expansion, and are
1196 variable expanded separately.  Otherwise, the command name and entire argument
1197 list are expanded together.  It is thus possible for the first (command) word
1198 (to this point) to generate more than one word, the first of which becomes the
1199 command name, and the rest of which become arguments.
1200 .PP
1201 Unless enclosed in `"' or given the `:q' modifier the results of variable
1202 substitution may eventually be command and filename substituted.  Within `"', a
1203 variable whose value consists of multiple words expands to a (portion of a)
1204 single word, with the words of the variable's value separated by blanks.  When
1205 the `:q' modifier is applied to a substitution the variable will expand to
1206 multiple words with each word separated by a blank and quoted to prevent later
1207 command or filename substitution.
1208 .PP
1209 The following metasequences are provided for introducing variable values into
1210 the shell input.  Except as noted, it is an error to reference a variable which
1211 is not set.
1212 .PP
1213 .PD 0
1214 $\fIname\fR
1215 .TP 8
1216 ${\fIname\fR}
1217 Substitutes the words of the value of variable \fIname\fR, each separated
1218 by a blank.  Braces insulate \fIname\fR from following characters which would
1219 otherwise be part of it.  Shell variables have names consisting of
1220 letters and digits starting with a letter.  The underscore character is
1221 considered a letter.  If \fIname\fR is not a shell variable, but is set in the
1222 environment, then that value is returned (but some of the other forms
1223 given below are not available in this case).
1224 .PP
1225 $\fIname\fR[\fIselector\fR]
1226 .TP 8
1227 ${\fIname\fR[\fIselector\fR]}
1228 Substitutes only the selected words from the value of \fIname\fR.
1229 The \fIselector\fR is subjected to `$' substitution and may consist of
1230 a single number or two numbers separated by a `\-'.
1231 The first word of a variable's value is numbered `1'.
1232 If the first number of a range is omitted it defaults to `1'.
1233 If the last member of a range is omitted it defaults to `$#\fIname\fR'.
1234 The \fIselector\fR `*' selects all words.
1235 It is not an error for a range to be empty if the
1236 second argument is omitted or in range.
1237 .TP 8
1238 $0
1239 Substitutes the name of the file from which command input
1240 is being read.  An error occurs if the name is not known.
1241 .PP
1242 $\fInumber\fR
1243 .TP 8
1244 ${\fInumber\fR}
1245 Equivalent to `$argv[\fInumber\fR]'.
1246 .TP 8
1247 $*
1248 Equivalent to `$argv', which is equivalent to `$argv[*]'.
1249 .PD
1250 .PP
1251 The `:' modifiers described under \fBHistory substitution\fR, except for `:p',
1252 can be applied to the substitutions above.  More than one may be used.  (+)
1253 Braces may be needed to insulate a variable substitution from a literal colon
1254 just as with \fBHistory substitution\fR (q.v.); any modifiers must appear
1255 within the braces.
1256 .PP
1257 The following substitutions can not be modified with `:' modifiers.
1258 .PP
1259 .PD 0
1260 $?\fIname\fR
1261 .TP 8
1262 ${?\fIname\fR}
1263 Substitutes the string `1' if \fIname\fR is set, `0' if it is not.
1264 .TP 8
1265 $?0
1266 Substitutes `1' if the current input filename is known, `0' if it is not.
1267 Always `0' in interactive shells.
1268 .PP
1269 $#\fIname\fR
1270 .TP 8
1271 ${#\fIname\fR}
1272 Substitutes the number of words in \fIname\fR.
1273 .TP 8
1274 $#
1275 Equivalent to `$#argv'.  (+)
1276 .PP
1277 $%\fIname\fR
1278 .TP 8
1279 ${%\fIname\fR}
1280 Substitutes the number of characters in \fIname\fR.  (+)
1281 .PP
1282 $%\fInumber\fR
1283 .TP 8
1284 ${%\fInumber\fR}
1285 Substitutes the number of characters in $argv[\fInumber\fR].  (+)
1286 .TP 8
1287 $?
1288 Equivalent to `$status'.  (+)
1289 .TP 8
1290 $$
1291 Substitutes the (decimal) process number of the (parent) shell.
1292 .TP 8
1293 $!
1294 Substitutes the (decimal) process number of the last
1295 background process started by this shell.  (+)
1296 .TP 8
1297 $_
1298 Substitutes the command line of the last command executed.  (+)
1299 .TP 8
1300 $<
1301 Substitutes a line from the standard input, with no further interpretation
1302 thereafter.  It can be used to read from the keyboard in a shell script.
1303 (+) While \fIcsh\fR always quotes $<, as if it were equivalent to `$<:q',
1304 \fItcsh\fR does not.  Furthermore, when \fItcsh\fR is waiting for a line to be
1305 typed the user may type an interrupt to interrupt the sequence into
1306 which the line is to be substituted, but \fIcsh\fR does not allow this.
1307 .PD
1308 .PP
1309 The editor command \fIexpand-variables\fR, normally bound to `^X-$',
1310 can be used to interactively expand individual variables.
1311 .SS "Command, filename and directory stack substitution"
1312 The remaining substitutions are applied selectively to the arguments of builtin
1313 commands.  This means that portions of expressions which are not evaluated are
1314 not subjected to these expansions.  For commands which are not internal to the
1315 shell, the command name is substituted separately from the argument list.  This
1316 occurs very late, after input-output redirection is performed, and in a child
1317 of the main shell.
1318 .SS "Command substitution"
1319 Command substitution is indicated by a command enclosed in ``'.  The output
1320 from such a command is broken into separate words at blanks, tabs and newlines,
1321 and null words are discarded.  The output is variable and command substituted
1322 and put in place of the original string.
1323 .PP
1324 Command substitutions inside double
1325 quotes (`"') retain blanks and tabs; only newlines force new words.  The single
1326 final newline does not force a new word in any case.  It is thus possible for a
1327 command substitution to yield only part of a word, even if the command outputs
1328 a complete line.
1329 .PP
1330 By default, the shell since version 6.12 replaces all newline and carriage 
1331 return characters in the command by spaces.  If this is switched off by
1332 unsetting \fBcsubstnonl\fR, newlines separate commands as usual.
1333 .SS "Filename substitution"
1334 If a word contains any of the characters `*', `?', `[' or `{' or begins with
1335 the character `~' it is a candidate for filename substitution, also known as
1336 ``globbing''.  This word is then regarded as a pattern (``glob-pattern''), and
1337 replaced with an alphabetically sorted list of file names which match the
1338 pattern.
1339 .PP
1340 In matching filenames, the character `.' at the beginning of a filename or
1341 immediately following a `/', as well as the character `/' must be matched
1342 explicitly (unless either
1343 .B globdot
1344 or
1345 .B globstar
1346 or both are set(+)).  The character `*' matches any string of characters, 
1347 including the null string.  The character `?' matches any single character.  
1348 The sequence `[...]' matches any one of the characters enclosed.  
1349 Within `[...]', a pair of
1350 characters separated by `\-' matches any character lexically between the two.
1351 .PP
1352 (+) Some glob-patterns can be negated:
1353 The sequence `[^...]' matches any single character \fInot\fR specified by the
1354 characters and/or ranges of characters in the braces.
1355 .PP
1356 An entire glob-pattern can also be negated with `^':
1357 .IP "" 4
1358 > echo *
1359 .br
1360 bang crash crunch ouch
1361 .br
1362 > echo ^cr*
1363 .br
1364 bang ouch
1365 .PP
1366 Glob-patterns which do not use `?', `*', or `[]' or which use `{}' or `~'
1367 (below) are not negated correctly.
1368 .PP
1369 The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'.
1370 Left-to-right order is preserved: `/usr/source/s1/{oldls,ls}.c' expands
1371 to `/usr/source/s1/oldls.c /usr/source/s1/ls.c'.  The results of matches are
1372 sorted separately at a low level to preserve this order:
1373 `../{memo,*box}' might expand to `../memo ../box ../mbox'.
1374 (Note that `memo' was not sorted with the results of matching `*box'.)
1375 It is not an error when this construct expands to files which do not exist,
1376 but it is possible to get an error from a command to which the expanded list
1377 is passed.
1378 This construct may be nested.
1379 As a special case the words `{', `}' and `{}' are passed undisturbed.
1380 .PP
1381 The character `~' at the beginning of a filename refers to home directories.
1382 Standing alone, i.e., `~', it expands to the invoker's home directory as
1383 reflected in the value of the \fBhome\fR shell variable.  When followed by a
1384 name consisting of letters, digits and `\-' characters the shell searches for a
1385 user with that name and substitutes their home directory; thus `~ken' might
1386 expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'.  If the character
1387 `~' is followed by a character other than a letter or `/' or appears elsewhere
1388 than at the beginning of a word, it is left undisturbed.
1389 A command like `setenv MANPATH /usr/man:/usr/local/man:~/lib/man' does not,
1390 therefore, do home directory substitution as one might hope.
1391 .PP
1392 It is an error for a glob-pattern containing `*', `?', `[' or `~', with or
1393 without `^', not to match any files.  However, only one pattern in a list of
1394 glob-patterns must match a file (so that, e.g., `rm *.a *.c *.o' would fail
1395 only if there were no files in the current directory ending in `.a', `.c', or
1396 `.o'), and if the \fBnonomatch\fR shell variable is set a pattern (or list
1397 of patterns) which matches nothing is left unchanged rather than causing
1398 an error.
1399 .PP
1400 The \fBglobstar\fR shell variable can be set to allow `**' or `***' as 
1401 a file glob pattern that matches any string of characters including `/',
1402 recursively traversing any existing sub-directories.  For example, 
1403 `ls **.c' will list all the .c files in the current directory tree.
1404 If used by itself, it will match match zero or more sub-directories
1405 (e.g. `ls /usr/include/**/time.h' will list any file named `time.h'
1406 in the /usr/include directory tree; `ls /usr/include/**time.h' will match 
1407 any file in the /usr/include directory tree ending in `time.h'; and
1408 `ls /usr/include/**time**.h' will match any .h file with `time' either
1409 in a subdirectory name or in the filename itself).
1410 To prevent problems with recursion, the `**' glob-pattern will not 
1411 descend into a symbolic link containing a directory.  To override this,
1412 use `***' (+)
1413 .PP
1414 The \fBnoglob\fR shell variable can be set to prevent filename substitution,
1415 and the \fIexpand-glob\fR editor command, normally bound to `^X-*', can be
1416 used to interactively expand individual filename substitutions.
1417 .SS "Directory stack substitution (+)"
1418 The directory stack is a list of directories, numbered from zero, used by the
1419 \fIpushd\fR, \fIpopd\fR and \fIdirs\fR builtin commands (q.v.).
1420 \fIdirs\fR can print, store in a file, restore and clear the directory stack
1421 at any time, and the \fBsavedirs\fR and \fBdirsfile\fR shell variables can be set to
1422 store the directory stack automatically on logout and restore it on login.
1423 The \fBdirstack\fR shell variable can be examined to see the directory stack and
1424 set to put arbitrary directories into the directory stack.
1425 .PP
1426 The character `=' followed by one or more digits expands to an entry in
1427 the directory stack.  The special case `=\-' expands to the last directory in
1428 the stack.  For example,
1429 .IP "" 4
1430 > dirs \-v
1431 .br
1432 0       /usr/bin
1433 .br
1434 1       /usr/spool/uucp
1435 .br
1436 2       /usr/accts/sys
1437 .br
1438 > echo =1
1439 .br
1440 /usr/spool/uucp
1441 .br
1442 > echo =0/calendar
1443 .br
1444 /usr/bin/calendar
1445 .br
1446 > echo =\-
1447 .br
1448 /usr/accts/sys
1449 .PP
1450 The \fBnoglob\fR and \fBnonomatch\fR shell variables and the \fIexpand-glob\fR
1451 editor command apply to directory stack as well as filename substitutions.
1452 .SS "Other substitutions (+)"
1453 There are several more transformations involving filenames, not strictly
1454 related to the above but mentioned here for completeness.
1455 \fIAny\fR filename may be expanded to a full path when the
1456 \fBsymlinks\fR variable (q.v.) is set to `expand'.
1457 Quoting prevents this expansion, and
1458 the \fInormalize-path\fR editor command does it on demand.
1459 The \fInormalize-command\fR editor command expands commands in PATH into
1460 full paths on demand.
1461 Finally, \fIcd\fR and \fIpushd\fR interpret `\-' as the old working directory
1462 (equivalent to the shell variable \fBowd\fR).
1463 This is not a substitution at all, but an abbreviation recognized by only
1464 those commands.  Nonetheless, it too can be prevented by quoting.
1465 .SS Commands
1466 The next three sections describe how the shell executes commands and
1467 deals with their input and output.
1468 .SS Simple commands, pipelines and sequences
1469 A simple command is a sequence of words, the first of which specifies the
1470 command to be executed.  A series of simple commands joined by `|' characters
1471 forms a pipeline.  The output of each command in a pipeline is connected to the
1472 input of the next.
1473 .PP
1474 Simple commands and pipelines may be joined into sequences with `;', and will
1475 be executed sequentially.  Commands and pipelines can also be joined into
1476 sequences with `||' or `&&', indicating, as in the C language, that the second
1477 is to be executed only if the first fails or succeeds respectively.
1478 .PP
1479 A simple command, pipeline or sequence may be placed in parentheses, `()',
1480 to form a simple command, which may in turn be a component of a pipeline or
1481 sequence.  A command, pipeline or sequence can be executed
1482 without waiting for it to terminate by following it with an `&'.
1483 .SS "Builtin and non-builtin command execution"
1484 Builtin commands are executed within the shell.  If any component of a
1485 pipeline except the last is a builtin command, the pipeline is executed
1486 in a subshell.
1487 .PP
1488 Parenthesized commands are always executed in a subshell.
1489 .IP "" 4
1490 (cd; pwd); pwd
1491 .PP
1492 thus prints the \fBhome\fR directory, leaving you where you were
1493 (printing this after the home directory), while
1494 .IP "" 4
1495 cd; pwd
1496 .PP
1497 leaves you in the \fBhome\fR directory.  Parenthesized commands are most often
1498 used to prevent \fIcd\fR from affecting the current shell.
1499 .PP
1500 When a command to be executed is found not to be a builtin command the shell
1501 attempts to execute the command via \fIexecve\fR(2).  Each word in the variable
1502 \fBpath\fR names a directory in which the shell will look for the
1503 command.  If the shell is not given a \fB\-f\fR option, the shell
1504 hashes the names in these directories into an internal table so that it will
1505 try an \fIexecve\fR(2) in only a directory where there is a possibility that the
1506 command resides there.  This greatly speeds command location when a large
1507 number of directories are present in the search path. This hashing mechanism is
1508 not used:
1509 .TP 4
1510 .B 1.
1511 If hashing is turned explicitly off via \fIunhash\fR.
1512 .TP 4
1513 .B 2.
1514 If the shell was given a \fB\-f\fR argument.
1515 .TP 4
1516 .B 3.
1517 For each directory component of \fBpath\fR which does not begin with a `/'.
1518 .TP 4
1519 .B 4.
1520 If the command contains a `/'.
1521 .PP
1522 In the above four cases the shell concatenates each component of the path
1523 vector with the given command name to form a path name of a file which it
1524 then attempts to execute it. If execution is successful, the search stops.
1525 .PP
1526 If the file has execute permissions but is not an executable to the system
1527 (i.e., it is neither an executable binary nor a script that specifies its
1528 interpreter), then it is assumed to be a file containing shell commands and
1529 a new shell is spawned to read it.  The \fIshell\fR special alias may be set
1530 to specify an interpreter other than the shell itself.
1531 .PP
1532 On systems which do not understand the `#!' script interpreter convention
1533 the shell may be compiled to emulate it; see the \fBversion\fR shell
1534 variable.  If so, the shell checks the first line of the file to
1535 see if it is of the form `#!\fIinterpreter\fR \fIarg\fR ...'.  If it is,
1536 the shell starts \fIinterpreter\fR with the given \fIarg\fRs and feeds the
1537 file to it on standard input.
1538 .SS Input/output
1539 The standard input and standard output of a command may be redirected with the
1540 following syntax:
1541 .PP
1542 .PD 0
1543 .TP 8
1544 < \fIname
1545 Open file \fIname\fR (which is first variable, command and filename
1546 expanded) as the standard input.
1547 .TP 8
1548 << \fIword
1549 Read the shell input up to a line which is identical to \fIword\fR.  \fIword\fR
1550 is not subjected to variable, filename or command substitution, and each input
1551 line is compared to \fIword\fR before any substitutions are done on this input
1552 line.  Unless a quoting `\e', `"', `' or ``' appears in \fIword\fR variable and
1553 command substitution is performed on the intervening lines, allowing `\e' to
1554 quote `$', `\e' and ``'.  Commands which are substituted have all blanks, tabs,
1555 and newlines preserved, except for the final newline which is dropped.  The
1556 resultant text is placed in an anonymous temporary file which is given to the
1557 command as standard input.
1558 .PP
1559 > \fIname
1560 .br
1561 >! \fIname
1562 .br
1563 >& \fIname
1564 .TP 8
1565 >&! \fIname
1566 The file \fIname\fR is used as standard output.  If the file does not exist
1567 then it is created; if the file exists, it is truncated, its previous contents
1568 being lost.
1569 .RS +8
1570 .PD
1571 .PP
1572 If the shell variable \fBnoclobber\fR is set, then the file must not exist or be a
1573 character special file (e.g., a terminal or `/dev/null') or an error results.
1574 This helps prevent accidental destruction of files.  In this case the `!' forms
1575 can be used to suppress this check.
1576 .PP
1577 The forms involving `&' route the diagnostic output into the specified file as
1578 well as the standard output.  \fIname\fR is expanded in the same way as `<'
1579 input filenames are.
1580 .PD 0
1581 .RE
1582 .PP
1583 >> \fIname
1584 .br
1585 >>& \fIname
1586 .br
1587 >>! \fIname
1588 .TP 8
1589 >>&! \fIname
1590 Like `>', but appends output to the end of \fIname\fR.
1591 If the shell variable \fBnoclobber\fR is set, then it is an error for
1592 the file \fInot\fR to exist, unless one of the `!' forms is given.
1593 .PD
1594 .PP
1595 A command receives the environment in which the shell was invoked as modified
1596 by the input-output parameters and the presence of the command in a pipeline.
1597 Thus, unlike some previous shells, commands run from a file of shell commands
1598 have no access to the text of the commands by default; rather they receive the
1599 original standard input of the shell.  The `<<' mechanism should be used to
1600 present inline data.  This permits shell command scripts to function as
1601 components of pipelines and allows the shell to block read its input.  Note
1602 that the default standard input for a command run detached is \fInot\fR
1603 the empty file \fI/dev/null\fR, but the original standard input of the shell.
1604 If this is a terminal and if the process attempts to read from the terminal,
1605 then the process will block and the user will be notified (see \fBJobs\fR).
1606 .PP
1607 Diagnostic output may be directed through a pipe with the standard output.
1608 Simply use the form `|&' rather than just `|'.
1609 .PP
1610 The shell cannot presently redirect diagnostic output without also redirecting
1611 standard output, but `(\fIcommand\fR > \fIoutput-file\fR) >& \fIerror-file\fR'
1612 is often an acceptable workaround.  Either \fIoutput-file\fR or
1613 \fIerror-file\fR may be `/dev/tty' to send output to the terminal.
1614 .SS Features
1615 Having described how the shell accepts, parses and executes
1616 command lines, we now turn to a variety of its useful features.
1617 .SS "Control flow"
1618 The shell contains a number of commands which can be used to regulate the
1619 flow of control in command files (shell scripts) and (in limited but
1620 useful ways) from terminal input.  These commands all operate by forcing the
1621 shell to reread or skip in its input and, due to the implementation,
1622 restrict the placement of some of the commands.
1623 .PP
1624 The \fIforeach\fR, \fIswitch\fR, and \fIwhile\fR statements, as well as the
1625 \fIif-then-else\fR form of the \fIif\fR statement, require that the major
1626 keywords appear in a single simple command on an input line as shown below.
1627 .PP
1628 If the shell's input is not seekable, the shell buffers up input whenever
1629 a loop is being read and performs seeks in this internal buffer to
1630 accomplish the rereading implied by the loop.  (To the extent that this
1631 allows, backward \fIgoto\fRs will succeed on non-seekable inputs.)
1632 .SS Expressions
1633 The \fIif\fR, \fIwhile\fR and \fIexit\fR builtin commands
1634 use expressions with a common syntax.  The expressions can include any
1635 of the operators described in the next three sections.  Note that the \fI@\fR
1636 builtin command (q.v.) has its own separate syntax.
1637 .SS "Logical, arithmetical and comparison operators"
1638 These operators are similar to those of C and have the same precedence.
1639 They include
1640 .IP "" 4
1641 ||  &&  |  ^  &  ==  !=  =~  !~  <=  >=
1642 .br
1643 <  > <<  >>  +  \-  *  /  %  !  ~  (  )
1644 .PP
1645 Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<='
1646 `>=' `<' and `>', `<<' and `>>', `+' and `\-', `*' `/' and `%' being, in
1647 groups, at the same level.  The `==' `!=' `=~' and `!~' operators compare
1648 their arguments as strings; all others operate on numbers.  The operators
1649 `=~' and `!~' are like `!=' and `==' except that the right hand side is a
1650 glob-pattern (see \fBFilename substitution\fR) against which the left hand
1651 operand is matched.  This reduces the need for use of the \fIswitch\fR
1652 builtin command in shell scripts when all that is really needed is
1653 pattern matching.
1654 .PP
1655 Null or
1656 missing arguments are considered `0'.  The results of all expressions are
1657 strings, which represent decimal numbers.  It is important to note that
1658 no two components of an expression can appear in the same word; except
1659 when adjacent to components of expressions which are syntactically
1660 significant to the parser (`&' `|' `<' `>' `(' `)') they should be
1661 surrounded by spaces.
1662 .SS "Command exit status"
1663 Commands can be executed in expressions and their exit status
1664 returned by enclosing them in braces (`{}').  Remember that the braces should
1665 be separated from the words of the command by spaces.  Command executions
1666 succeed, returning true, i.e., `1', if the command exits with status 0,
1667 otherwise they fail, returning false, i.e., `0'.  If more detailed status
1668 information is required then the command should be executed outside of an
1669 expression and the \fBstatus\fR shell variable examined.
1670 .SS "File inquiry operators"
1671 Some of these operators perform true/false tests on files and related
1672 objects.  They are of the form \fB\-\fIop file\fR, where \fIop\fR is one of
1673 .PP
1674 .PD 0
1675 .RS +4
1676 .TP 4
1677 .B r
1678 Read access
1679 .TP 4
1680 .B w
1681 Write access
1682 .TP 4
1683 .B x
1684 Execute access
1685 .TP 4
1686 .B X
1687 Executable in the path or shell builtin, e.g., `\-X ls' and `\-X ls\-F' are
1688 generally true, but `\-X /bin/ls' is not (+)
1689 .TP 4
1690 .B e
1691 Existence
1692 .TP 4
1693 .B o
1694 Ownership
1695 .TP 4
1696 .B z
1697 Zero size
1698 .TP 4
1699 .B s
1700 Non-zero size (+)
1701 .TP 4
1702 .B f
1703 Plain file
1704 .TP 4
1705 .B d
1706 Directory
1707 .TP 4
1708 .B l
1709 Symbolic link (+) *
1710 .TP 4
1711 .B b
1712 Block special file (+)
1713 .TP 4
1714 .B c
1715 Character special file (+)
1716 .TP 4
1717 .B p
1718 Named pipe (fifo) (+) *
1719 .TP 4
1720 .B S
1721 Socket special file (+) *
1722 .TP 4
1723 .B u
1724 Set-user-ID bit is set (+)
1725 .TP 4
1726 .B g
1727 Set-group-ID bit is set (+)
1728 .TP 4
1729 .B k
1730 Sticky bit is set (+)
1731 .TP 4
1732 .B t
1733 \fIfile\fR (which must be a digit) is an open file descriptor
1734 for a terminal device (+)
1735 .TP 4
1736 .B R
1737 Has been migrated (Convex only) (+)
1738 .TP 4
1739 .B L
1740 Applies subsequent operators in a multiple-operator test to a symbolic link
1741 rather than to the file to which the link points (+) *
1742 .RE
1743 .PD
1744 .PP
1745 \fIfile\fR is command and filename expanded and then tested to
1746 see if it has the specified relationship to the real user.  If \fIfile\fR
1747 does not exist or is inaccessible or, for the operators indicated by `*',
1748 if the specified file type does not exist on the current system,
1749 then all enquiries return false, i.e., `0'.
1750 .PP
1751 These operators may be combined for conciseness: `\-\fIxy file\fR' is
1752 equivalent to `\-\fIx file\fR && \-\fIy file\fR'.  (+) For example, `\-fx' is true
1753 (returns `1') for plain executable files, but not for directories.
1754 .PP
1755 \fBL\fR may be used in a multiple-operator test to apply subsequent operators
1756 to a symbolic link rather than to the file to which the link points.
1757 For example, `\-lLo' is true for links owned by the invoking user.
1758 \fBLr\fR, \fBLw\fR and \fBLx\fR are always true for links and false for
1759 non-links.  \fBL\fR has a different meaning when it is the last operator
1760 in a multiple-operator test; see below.
1761 .PP
1762 It is possible but not useful, and sometimes misleading, to combine operators
1763 which expect \fIfile\fR to be a file with operators which do not
1764 (e.g., \fBX\fR and \fBt\fR).  Following \fBL\fR with a non-file operator
1765 can lead to particularly strange results.
1766 .PP
1767 Other operators return other information, i.e., not just `0' or `1'.  (+)
1768 They have the same format as before; \fIop\fR may be one of
1769 .PP
1770 .PD 0
1771 .RS +4
1772 .TP 8
1773 .B A
1774 Last file access time, as the number of seconds since the epoch
1775 .TP 8
1776 .B A:
1777 Like \fBA\fR, but in timestamp format, e.g., `Fri May 14 16:36:10 1993'
1778 .TP 8
1779 .B M
1780 Last file modification time
1781 .TP 8
1782 .B M:
1783 Like \fBM\fR, but in timestamp format
1784 .TP 8
1785 .B C
1786 Last inode modification time
1787 .TP 8
1788 .B C:
1789 Like \fBC\fR, but in timestamp format
1790 .TP 8
1791 .B D
1792 Device number
1793 .TP 8
1794 .B I
1795 Inode number
1796 .TP 8
1797 .B F
1798 Composite \fBf\fRile identifier, in the form \fIdevice\fR:\fIinode\fR
1799 .TP 8
1800 .B L
1801 The name of the file pointed to by a symbolic link
1802 .TP 8
1803 .B N
1804 Number of (hard) links
1805 .TP 8
1806 .B P
1807 Permissions, in octal, without leading zero
1808 .TP 8
1809 .B P:
1810 Like \fBP\fR, with leading zero
1811 .TP 8
1812 .B P\fImode
1813 Equivalent to `\-P \fIfile\fR & \fImode\fR', e.g., `\-P22 \fIfile\fR' returns
1814 `22' if \fIfile\fR is writable by group and other, `20' if by group only,
1815 and `0' if by neither
1816 .TP 8
1817 .B P\fImode\fB:
1818 Like \fBP\fImode\fR, with leading zero
1819 .TP 8
1820 .B U
1821 Numeric userid
1822 .TP 8
1823 .B U:
1824 Username, or the numeric userid if the username is unknown
1825 .TP 8
1826 .B G
1827 Numeric groupid
1828 .TP 8
1829 .B G:
1830 Groupname, or the numeric groupid if the groupname is unknown
1831 .TP 8
1832 .B Z
1833 Size, in bytes
1834 .RE
1835 .PD
1836 .PP
1837 Only one of these operators may appear in a multiple-operator test, and it
1838 must be the last.  Note that \fBL\fR has a different meaning at the end of and
1839 elsewhere in a multiple-operator test.  Because `0' is a valid return value
1840 for many of these operators, they do not return `0' when they fail: most
1841 return `\-1', and \fBF\fR returns `:'.
1842 .PP
1843 If the shell is compiled with POSIX defined (see the \fBversion\fR shell
1844 variable), the result of a file inquiry is based on the permission bits of
1845 the file and not on the result of the \fIaccess\fR(2) system call.
1846 For example, if one tests a file with \fB\-w\fR whose permissions would
1847 ordinarily allow writing but which is on a file system mounted read-only,
1848 the test will succeed in a POSIX shell but fail in a non-POSIX shell.
1849 .PP
1850 File inquiry operators can also be evaluated with the \fIfiletest\fR builtin
1851 command (q.v.) (+).
1852 .SS Jobs
1853 The shell associates a \fIjob\fR with each pipeline.  It keeps a table of
1854 current jobs, printed by the \fIjobs\fR command, and assigns them small integer
1855 numbers.  When a job is started asynchronously with `&', the shell prints a
1856 line which looks like
1857 .IP "" 4
1858 [1] 1234
1859 .PP
1860 indicating that the job which was started asynchronously was job number 1 and
1861 had one (top-level) process, whose process id was 1234.
1862 .PP
1863 If you are running a job and wish to do something else you may hit the suspend
1864 key (usually `^Z'),
1865 which sends a STOP signal to the current job.  The shell will then normally
1866 indicate that the job has been `Suspended' and print another prompt.
1867 If the \fBlistjobs\fR shell variable is set, all jobs will be listed
1868 like the \fIjobs\fR builtin command; if it is set to `long' the listing will
1869 be in long format, like `jobs \-l'.
1870 You can then manipulate the state of the suspended job.
1871 You can put it in the
1872 ``background'' with the \fIbg\fR command or run some other commands and
1873 eventually bring the job back into the ``foreground'' with \fIfg\fR.
1874 (See also the \fIrun-fg-editor\fR editor command.)
1875 A `^Z' takes effect immediately and is like an interrupt
1876 in that pending output and unread input are discarded when it is typed.
1877 The \fIwait\fR builtin command causes the shell to wait for all background
1878 jobs to complete.
1879 .PP
1880 The `^]' key sends a delayed suspend signal, which does not generate a STOP
1881 signal until a program attempts to \fIread\fR(2) it, to the current job.
1882 This can usefully be typed ahead when you have prepared some commands for a
1883 job which you wish to stop after it has read them.
1884 The `^Y' key performs this function in \fIcsh\fR(1); in \fItcsh\fR,
1885 `^Y' is an editing command.  (+)
1886 .PP
1887 A job being run in the background stops if it tries to read from the
1888 terminal.  Background jobs are normally allowed to produce output, but this can
1889 be disabled by giving the command `stty tostop'.  If you set this tty option,
1890 then background jobs will stop when they try to produce output like they do
1891 when they try to read input.
1892 .PP
1893 There are several ways to refer to jobs in the shell.  The character `%'
1894 introduces a job name.  If you wish to refer to job number 1, you can name it
1895 as `%1'.  Just naming a job brings it to the foreground; thus `%1' is a synonym
1896 for `fg %1', bringing job 1 back into the foreground.  Similarly, saying `%1 &'
1897 resumes job 1 in the background, just like `bg %1'.  A job can also be named
1898 by an unambiguous prefix of the string typed in to start it: `%ex' would
1899 normally restart a suspended \fIex\fR(1) job, if there were only one suspended
1900 job whose name began with the string `ex'.  It is also possible to say
1901 `%?\fIstring\fR' to specify a job whose text contains \fIstring\fR, if there
1902 is only one such job.
1903 .PP
1904 The shell maintains a notion of the current and previous jobs.  In output
1905 pertaining to jobs, the current job is marked with a `+' and the previous job
1906 with a `\-'.  The abbreviations `%+', `%', and (by analogy with the syntax of
1907 the \fIhistory\fR mechanism) `%%' all refer to the current job, and `%\-' refers
1908 to the previous job.
1909 .PP
1910 The job control mechanism requires that the \fIstty\fR(1) option `new' be set
1911 on some systems.  It is an artifact from a `new' implementation of the tty
1912 driver which allows generation of interrupt characters from the keyboard to
1913 tell jobs to stop.  See \fIstty\fR(1) and the \fIsetty\fR builtin command for
1914 details on setting options in the new tty driver.
1915 .SS "Status reporting"
1916 The shell learns immediately whenever a process changes state.  It normally
1917 informs you whenever a job becomes blocked so that no further progress is
1918 possible, but only right before it prints a prompt.  This is done so that it
1919 does not otherwise disturb your work.  If, however, you set the shell variable
1920 \fBnotify\fR, the shell will notify you immediately of changes of status in
1921 background jobs.  There is also a shell command \fInotify\fR which marks a
1922 single process so that its status changes will be immediately reported.  By
1923 default \fInotify\fR marks the current process; simply say `notify' after
1924 starting a background job to mark it.
1925 .PP
1926 When you try to leave the shell while jobs are stopped, you will be
1927 warned that `There are suspended jobs.' You may use the \fIjobs\fR command to
1928 see what they are.  If you do this or immediately try to exit again, the shell
1929 will not warn you a second time, and the suspended jobs will be terminated.
1930 .SS "Automatic, periodic and timed events (+)"
1931 There are various ways to run commands and take other actions automatically
1932 at various times in the ``life cycle'' of the shell.  They are summarized here,
1933 and described in detail under the appropriate \fBBuiltin commands\fR,
1934 \fBSpecial shell variables\fR and \fBSpecial aliases\fR.
1935 .PP
1936 The \fIsched\fR builtin command puts commands in a scheduled-event list,
1937 to be executed by the shell at a given time.
1938 .PP
1939 The \fIbeepcmd\fR, \fIcwdcmd\fR, \fIperiodic\fR, \fIprecmd\fR, \fIpostcmd\fR,
1940 and \fIjobcmd\fR
1941 \fBSpecial aliases\fR can be set, respectively, to execute commands when the shell wants
1942 to ring the bell, when the working directory changes, every \fBtperiod\fR
1943 minutes, before each prompt, before each command gets executed, after each
1944 command gets executed, and when a job is started or is brought into the
1945 foreground.
1946 .PP
1947 The \fBautologout\fR shell variable can be set to log out or lock the shell
1948 after a given number of minutes of inactivity.
1949 .PP
1950 The \fBmail\fR shell variable can be set to check for new mail periodically.
1951 .PP
1952 The \fBprintexitvalue\fR shell variable can be set to print the exit status
1953 of commands which exit with a status other than zero.
1954 .PP
1955 The \fBrmstar\fR shell variable can be set to ask the user, when `rm *' is
1956 typed, if that is really what was meant.
1957 .PP
1958 The \fBtime\fR shell variable can be set to execute the \fItime\fR builtin
1959 command after the completion of any process that takes more than a given
1960 number of CPU seconds.
1961 .PP
1962 The \fBwatch\fR and \fBwho\fR shell variables can be set to report when
1963 selected users log in or out, and the \fIlog\fR builtin command reports
1964 on those users at any time.
1965 .SS "Native Language System support (+)"
1966 The shell is eight bit clean
1967 (if so compiled; see the \fBversion\fR shell variable)
1968 and thus supports character sets needing this capability.
1969 NLS support differs depending on whether or not
1970 the shell was compiled to use the system's NLS (again, see \fBversion\fR).
1971 In either case, 7-bit ASCII is the default character code
1972 (e.g., the classification of which characters are printable) and sorting,
1973 and changing the \fBLANG\fR or \fBLC_CTYPE\fR environment variables
1974 causes a check for possible changes in these respects.
1975 .PP
1976 When using the system's NLS, the \fIsetlocale\fR(3) function is called
1977 to determine appropriate character code/classification and sorting
1978 (e.g., a 'en_CA.UTF-8' would yield "UTF-8" as a character code).
1979 This function typically examines the \fBLANG\fR and \fBLC_CTYPE\fR
1980 environment variables; refer to the system documentation for further details.
1981 When not using the system's NLS, the shell simulates it by assuming that the
1982 ISO 8859-1 character set is used
1983 whenever either of the \fBLANG\fR and \fBLC_CTYPE\fR variables are set, regardless of
1984 their values.  Sorting is not affected for the simulated NLS.
1985 .PP
1986 In addition, with both real and simulated NLS, all printable
1987 characters in the range \e200\-\e377, i.e., those that have
1988 M-\fIchar\fR bindings, are automatically rebound to \fIself-insert-command\fR.
1989 The corresponding binding for the escape-\fIchar\fR sequence, if any, is
1990 left alone.
1991 These characters are not rebound if the \fBNOREBIND\fR environment variable
1992 is set.  This may be useful for the simulated NLS or a primitive real NLS
1993 which assumes full ISO 8859-1.  Otherwise, all M-\fIchar\fR bindings in the
1994 range \e240\-\e377 are effectively undone.
1995 Explicitly rebinding the relevant keys with \fIbindkey\fR
1996 is of course still possible.
1997 .PP
1998 Unknown characters (i.e., those that are neither printable nor control
1999 characters) are printed in the format \ennn.
2000 If the tty is not in 8 bit mode, other 8 bit characters are printed by
2001 converting them to ASCII and using standout mode.  The shell
2002 never changes the 7/8 bit mode of the tty and tracks user-initiated
2003 changes of 7/8 bit mode.  NLS users (or, for that matter, those who want to
2004 use a meta key) may need to explicitly set
2005 the tty in 8 bit mode through the appropriate \fIstty\fR(1)
2006 command in, e.g., the \fI~/.login\fR file.
2007 .SS "OS variant support (+)"
2008 A number of new builtin commands are provided to support features in
2009 particular operating systems.  All are described in detail in the
2010 \fBBuiltin commands\fR section.
2011 .PP
2012 On systems that support TCF (aix-ibm370, aix-ps2),
2013 \fIgetspath\fR and \fIsetspath\fR get and set the system execution path,
2014 \fIgetxvers\fR and \fIsetxvers\fR get and set the experimental version prefix
2015 and \fImigrate\fR migrates processes between sites.  The \fIjobs\fR builtin
2016 prints the site on which each job is executing.
2017 .PP
2018 Under BS2000, \fIbs2cmd\fR executes commands of the underlying BS2000/OSD
2019 operating system.
2020 .PP
2021 Under Domain/OS, \fIinlib\fR adds shared libraries to the current environment,
2022 \fIrootnode\fR changes the rootnode and \fIver\fR changes the systype.
2023 .PP
2024 Under Mach, \fIsetpath\fR is equivalent to Mach's \fIsetpath\fR(1).
2025 .PP
2026 Under Masscomp/RTU and Harris CX/UX, \fIuniverse\fR sets the universe.
2027 .PP
2028 Under Harris CX/UX, \fIucb\fR or \fIatt\fR runs a command under the specified
2029 universe.
2030 .PP
2031 Under Convex/OS, \fIwarp\fR prints or sets the universe.
2032 .PP
2033 The \fBVENDOR\fR, \fBOSTYPE\fR and \fBMACHTYPE\fR environment variables
2034 indicate respectively the vendor, operating system and machine type
2035 (microprocessor class or machine model) of the
2036 system on which the shell thinks it is running.
2037 These are particularly useful when sharing one's home directory between several
2038 types of machines; one can, for example,
2039 .IP "" 4
2040 set path = (~/bin.$MACHTYPE /usr/ucb /bin /usr/bin .)
2041 .PP
2042 in one's \fI~/.login\fR and put executables compiled for each machine in the
2043 appropriate directory.
2044 .PP
2045 The \fBversion\fR shell
2046 variable indicates what options were chosen when the shell was compiled.
2047 .PP
2048 Note also the \fInewgrp\fR builtin, the \fBafsuser\fR and
2049 \fBecho_style\fR shell variables and the system-dependent locations of
2050 the shell's input files (see \fBFILES\fR).
2051 .SS "Signal handling"
2052 Login shells ignore interrupts when reading the file \fI~/.logout\fR.
2053 The shell ignores quit signals unless started with \fB\-q\fR.
2054 Login shells catch the terminate signal, but non-login shells inherit the
2055 terminate behavior from their parents.
2056 Other signals have the values which the shell inherited from its parent.
2057 .PP
2058 In shell scripts, the shell's handling of interrupt and terminate signals
2059 can be controlled with \fIonintr\fR, and its handling of hangups can be
2060 controlled with \fIhup\fR and \fInohup\fR.
2061 .PP
2062 The shell exits on a hangup (see also the \fBlogout\fR shell variable).  By
2063 default, the shell's children do too, but the shell does not send them a
2064 hangup when it exits.  \fIhup\fR arranges for the shell to send a hangup to
2065 a child when it exits, and \fInohup\fR sets a child to ignore hangups.
2066 .SS "Terminal management (+)"
2067 The shell uses three different sets of terminal (``tty'') modes:
2068 `edit', used when editing, `quote', used when quoting literal characters,
2069 and `execute', used when executing commands.
2070 The shell holds some settings in each mode constant, so commands which leave
2071 the tty in a confused state do not interfere with the shell.
2072 The shell also matches changes in the speed and padding of the tty.
2073 The list of tty modes that are kept constant
2074 can be examined and modified with the \fIsetty\fR builtin.
2075 Note that although the editor uses CBREAK mode (or its equivalent),
2076 it takes typed-ahead characters anyway.
2077 .PP
2078 The \fIechotc\fR, \fIsettc\fR and \fItelltc\fR commands can be used to
2079 manipulate and debug terminal capabilities from the command line.
2080 .PP
2081 On systems that support SIGWINCH or SIGWINDOW, the shell
2082 adapts to window resizing automatically and adjusts the environment
2083 variables \fBLINES\fR and \fBCOLUMNS\fR if set.  If the environment
2084 variable \fBTERMCAP\fR contains li# and co# fields, the shell adjusts
2085 them to reflect the new window size.
2086 .SH REFERENCE
2087 The next sections of this manual describe all of the available
2088 \fBBuiltin commands\fR, \fBSpecial aliases\fR and
2089 \fBSpecial shell variables\fR.
2090 .SS "Builtin commands"
2091 .TP 8
2092 .B %\fIjob
2093 A synonym for the \fIfg\fR builtin command.
2094 .TP 8
2095 .B %\fIjob \fB&
2096 A synonym for the \fIbg\fR builtin command.
2097 .TP 8
2098 .B :
2099 Does nothing, successfully.
2100 .PP
2101 .B @
2102 .br
2103 .B @ \fIname\fB = \fIexpr
2104 .br
2105 .B @ \fIname\fR[\fIindex\fR]\fB = \fIexpr
2106 .br
2107 .B @ \fIname\fB++\fR|\fB--
2108 .PD 0
2109 .TP 8
2110 .B @ \fIname\fR[\fIindex\fR]\fB++\fR|\fB--
2111 The first form prints the values of all shell variables.
2112 .PD
2113 .RS +8
2114 .PP
2115 The second form assigns the value of \fIexpr\fR to \fIname\fR.
2116 The third form assigns the value of \fIexpr\fR to the \fIindex\fR'th
2117 component of \fIname\fR; both \fIname\fR and its \fIindex\fR'th component
2118 must already exist.
2119 .PP
2120 \fIexpr\fR may contain the operators `*', `+', etc., as in C.
2121 If \fIexpr\fR contains `<', `>', `&' or `' then at least that part of
2122 \fIexpr\fR must be placed within `()'.
2123 Note that the syntax of \fIexpr\fR has nothing to do with that described
2124 under \fBExpressions\fR.
2125 .PP
2126 The fourth and fifth forms increment (`++') or decrement (`\-\-') \fIname\fR
2127 or its \fIindex\fR'th component.
2128 .PP
2129 The space between `@' and \fIname\fR is required.  The spaces between
2130 \fIname\fR and `=' and between `=' and \fIexpr\fR are optional.  Components of
2131 \fIexpr\fR must be separated by spaces.
2132 .RE
2133 .PD
2134 .TP 8
2135 .B alias \fR[\fIname \fR[\fIwordlist\fR]]
2136 Without arguments, prints all aliases.
2137 With \fIname\fR, prints the alias for name.
2138 With \fIname\fR and \fIwordlist\fR, assigns
2139 \fIwordlist\fR as the alias of \fIname\fR.
2140 \fIwordlist\fR is command and filename substituted.
2141 \fIname\fR may not be `alias' or `unalias'.
2142 See also the \fIunalias\fR builtin command.
2143 .TP 8
2144 .B alloc
2145 Shows the amount of dynamic memory acquired, broken down into used and free
2146 memory.  With an argument shows the number of free and used blocks in each size
2147 category.  The categories start at size 8 and double at each step.  This
2148 command's output may vary across system types, because systems other than the VAX
2149 may use a different memory allocator.
2150 .TP 8
2151 .B bg \fR[\fB%\fIjob\fR ...]
2152 Puts the specified jobs (or, without arguments, the current job)
2153 into the background, continuing each if it is stopped.
2154 \fIjob\fR may be a number, a string, `', `%', `+' or `\-' as described
2155 under \fBJobs\fR.
2156 .PP
2157 .B bindkey \fR[\fB\-l\fR|\fB\-d\fR|\fB\-e\fR|\fB\-v\fR|\fB\-u\fR] (+)
2158 .br
2159 \fBbindkey \fR[\fB\-a\fR] [\fB\-b\fR] [\fB\-k\fR] [\fB\-r\fR] [\fB\-\-\fR] \fIkey \fR(+)
2160 .PD 0
2161 .TP 8
2162 \fBbindkey \fR[\fB\-a\fR] [\fB\-b\fR] [\fB\-k\fR] [\fB\-c\fR|\fB\-s\fR] [\fB\-\-\fR] \fIkey command \fR(+)
2163 .\" .B macro can't take too many words, so I used \fB in the previous tags
2164 Without options, the first form lists all bound keys and the editor command to which each is bound,
2165 the second form lists the editor command to which \fIkey\fR is bound and
2166 the third form binds the editor command \fIcommand\fR to \fIkey\fR.
2167 Options include:
2168 .PD
2169 .PP
2170 .PD 0
2171 .RS +8
2172 .TP 4
2173 .B \-l
2174 Lists all editor commands and a short description of each.
2175 .TP 4
2176 .B \-d
2177 Binds all keys to the standard bindings for the default editor.
2178 .TP 4
2179 .B \-e
2180 Binds all keys to the standard GNU Emacs-like bindings.
2181 .TP 4
2182 .B \-v
2183 Binds all keys to the standard \fIvi\fR(1)-like bindings.
2184 .TP 4
2185 .B \-a
2186 Lists or changes key-bindings in the alternative key map.
2187 This is the key map used in \fIvi\fR command mode.
2188 .TP 4
2189 .B \-b
2190 \fIkey\fR is interpreted as
2191 a control character written ^\fIcharacter\fR (e.g., `^A') or
2192 C-\fIcharacter\fR (e.g., `C-A'),
2193 a meta character written M-\fIcharacter\fR (e.g., `M-A'),
2194 a function key written F-\fIstring\fR (e.g., `F-string'),
2195 or an extended prefix key written X-\fIcharacter\fR (e.g., `X-A').
2196 .TP 4
2197 .B \-k
2198 \fIkey\fR is interpreted as a symbolic arrow key name, which may be one of
2199 `down', `up', `left' or `right'.
2200 .TP 4
2201 .B \-r
2202 Removes \fIkey\fR's binding.
2203 Be careful: `bindkey \-r' does \fInot\fR bind \fIkey\fR to
2204 \fIself-insert-command\fR (q.v.), it unbinds \fIkey\fR completely.
2205 .TP 4
2206 .B \-c
2207 \fIcommand\fR is interpreted as a builtin or external command instead of an
2208 editor command.
2209 .TP 4
2210 .B \-s
2211 \fIcommand\fR is taken as a literal string and treated as terminal input
2212 when \fIkey\fR is typed.  Bound keys in \fIcommand\fR are themselves
2213 reinterpreted, and this continues for ten levels of interpretation.
2214 .TP 4
2215 .B \-\-
2216 Forces a break from option processing, so the next word is taken as \fIkey\fR
2217 even if it begins with '\-'.
2218 .TP 4
2219 .B \-u \fR(or any invalid option)
2220 Prints a usage message.
2221 .PD
2222 .PP
2223 \fIkey\fR may be a single character or a string.
2224 If a command is bound to a string, the first character of the string is bound to
2225 \fIsequence-lead-in\fR and the entire string is bound to the command.
2226 .PP
2227 Control characters in \fIkey\fR can be literal (they can be typed by preceding
2228 them with the editor command \fIquoted-insert\fR, normally bound to `^V') or
2229 written caret-character style, e.g., `^A'.  Delete is written `^?'
2230 (caret-question mark).  \fIkey\fR and \fIcommand\fR can contain backslashed
2231 escape sequences (in the style of System V \fIecho\fR(1)) as follows:
2232 .RS +4
2233 .TP 8
2234 .PD 0
2235 .B \ea
2236 Bell
2237 .TP 8
2238 .B \eb
2239 Backspace
2240 .TP 8
2241 .B \ee
2242 Escape
2243 .TP 8
2244 .B \ef
2245 Form feed
2246 .TP 8
2247 .B \en
2248 Newline
2249 .TP 8
2250 .B \er
2251 Carriage return
2252 .TP 8
2253 .B \et
2254 Horizontal tab
2255 .TP 8
2256 .B \ev
2257 Vertical tab
2258 .TP 8
2259 .B \e\fInnn
2260 The ASCII character corresponding to the octal number \fInnn\fR
2261 .PD
2262 .RE
2263 .PP
2264 `\e' nullifies the special meaning of the following character, if it has
2265 any, notably `\\' and `^'.
2266 .RE
2267 .TP 8
2268 .B bs2cmd \fIbs2000-command\fR (+)
2269 Passes \fIbs2000-command\fR to the BS2000 command interpreter for
2270 execution. Only non-interactive commands can be executed, and it is
2271 not possible to execute any command that would overlay the image
2272 of the current process, like /EXECUTE or /CALL-PROCEDURE. (BS2000 only)
2273 .TP 8
2274 .B break
2275 Causes execution to resume after the \fIend\fR of the nearest
2276 enclosing \fIforeach\fR or \fIwhile\fR.  The remaining commands on the
2277 current line are executed.  Multi-level breaks are thus
2278 possible by writing them all on one line.
2279 .TP 8
2280 .B breaksw
2281 Causes a break from a \fIswitch\fR, resuming after the \fIendsw\fR.
2282 .TP 8
2283 .B builtins \fR(+)
2284 Prints the names of all builtin commands.
2285 .TP 8
2286 .B bye \fR(+)
2287 A synonym for the \fIlogout\fR builtin command.
2288 Available only if the shell was so compiled;
2289 see the \fBversion\fR shell variable.
2290 .TP 8
2291 .B case \fIlabel\fB:
2292 A label in a \fIswitch\fR statement as discussed below.
2293 .TP 8
2294 .B cd \fR[\fB\-p\fR] [\fB\-l\fR] [\fB\-n\fR|\fB\-v\fR] [\I--\fR] [\fIname\fR]
2295 If a directory \fIname\fR is given, changes the shell's working directory
2296 to \fIname\fR.  If not, changes to \fBhome\fR.
2297 If \fIname\fR is `\-' it is interpreted as the previous working directory
2298 (see \fBOther substitutions\fR).  (+)
2299 If \fIname\fR is not a subdirectory of the current directory
2300 (and does not begin with `/', `./' or `../'), each component of the variable
2301 \fBcdpath\fR is checked to see if it has a subdirectory \fIname\fR.  Finally, if
2302 all else fails but \fIname\fR is a shell variable whose value
2303 begins with `/', then this is tried to see if it is a directory.
2304 .RS +8
2305 .PP
2306 With \fB\-p\fR, prints the final directory stack, just like \fIdirs\fR.
2307 The \fB\-l\fR, \fB\-n\fR and \fB\-v\fR flags have the same effect on \fIcd\fR
2308 as on \fIdirs\fR, and they imply \fB\-p\fR.  (+)
2309 Using \fB\-\-\fR forces a break from option processing so the next word
2310 is taken as the directory \fIname\fR even if it begins with '\-'. (+)
2311 .PP
2312 See also the \fBimplicitcd\fR shell variable.
2313 .RE
2314 .TP 8
2315 .B chdir
2316 A synonym for the \fIcd\fR builtin command.
2317 .TP 8
2318 .B complete \fR[\fIcommand\fR [\fIword\fB/\fIpattern\fB/\fIlist\fR[\fB:\fIselect\fR]\fB/\fR[[\fIsuffix\fR]\fB/\fR] ...]] (+)
2319 Without arguments, lists all completions.
2320 With \fIcommand\fR, lists completions for \fIcommand\fR.
2321 With \fIcommand\fR and \fIword\fR etc., defines completions.
2322 .RS +8
2323 .PP
2324 \fIcommand\fR may be a full command name or a glob-pattern
2325 (see \fBFilename substitution\fR).  It can begin with `\-' to indicate that
2326 completion should be used only when \fIcommand\fR is ambiguous.
2327 .PP
2328 \fIword\fR specifies which word relative to the current word
2329 is to be completed, and may be one of the following:
2330 .PP
2331 .PD 0
2332 .RS +4
2333 .TP 4
2334 .B c
2335 Current-word completion.
2336 \fIpattern\fR is a glob-pattern which must match the beginning of the current word on
2337 the command line.  \fIpattern\fR is ignored when completing the current word.
2338 .TP 4
2339 .B C
2340 Like \fBc\fR, but includes \fIpattern\fR when completing the current word.
2341 .TP 4
2342 .B n
2343 Next-word completion.
2344 \fIpattern\fR is a glob-pattern which must match the beginning of the previous word on
2345 the command line.
2346 .TP 4
2347 .B N
2348 Like \fBn\fR, but must match the beginning of the word two before the current word.
2349 .TP 4
2350 .B p
2351 Position-dependent completion.
2352 \fIpattern\fR is a numeric range, with the same syntax used to index shell
2353 variables, which must include the current word.
2354 .PD
2355 .RE
2356 .PP
2357 \fIlist\fR, the list of possible completions, may be one of the following:
2358 .PP
2359 .PD 0
2360 .RS +4
2361 .TP 8
2362 .B a
2363 Aliases
2364 .TP 8
2365 .B b
2366 Bindings (editor commands)
2367 .TP 8
2368 .B c
2369 Commands (builtin or external commands)
2370 .TP 8
2371 .B C
2372 External commands which begin with the supplied path prefix
2373 .TP 8
2374 .B d
2375 Directories
2376 .TP 8
2377 .B D
2378 Directories which begin with the supplied path prefix
2379 .TP 8
2380 .B e
2381 Environment variables
2382 .TP 8
2383 .B f
2384 Filenames
2385 .TP 8
2386 .B F
2387 Filenames which begin with the supplied path prefix
2388 .TP 8
2389 .B g
2390 Groupnames
2391 .TP 8
2392 .B j
2393 Jobs
2394 .TP 8
2395 .B l
2396 Limits
2397 .TP 8
2398 .B n
2399 Nothing
2400 .TP 8
2401 .B s
2402 Shell variables
2403 .TP 8
2404 .B S
2405 Signals
2406 .TP 8
2407 .B t
2408 Plain (``text'') files
2409 .TP 8
2410 .B T
2411 Plain (``text'') files which begin with the supplied path prefix
2412 .TP 8
2413 .B v
2414 Any variables
2415 .TP 8
2416 .B u
2417 Usernames
2418 .TP 8
2419 .B x
2420 Like \fBn\fR, but prints \fIselect\fR when \fIlist-choices\fR is used.
2421 .TP 8
2422 .B X
2423 Completions
2424 .TP 8
2425 $\fIvar\fR
2426 Words from the variable \fIvar\fR
2427 .TP 8
2428 (...)
2429 Words from the given list
2430 .TP 8
2431 `...`
2432 Words from the output of command
2433 .PD
2434 .RE
2435 .PP
2436 \fIselect\fR is an optional glob-pattern.
2437 If given, words from only \fIlist\fR that match \fIselect\fR are considered
2438 and the \fBfignore\fR shell variable is ignored.
2439 The last three types of completion may not have a \fIselect\fR
2440 pattern, and \fBx\fR uses \fIselect\fR as an explanatory message when
2441 the \fIlist-choices\fR editor command is used.
2442 .PP
2443 \fIsuffix\fR is a single character to be appended to a successful
2444 completion.  If null, no character is appended.  If omitted (in which
2445 case the fourth delimiter can also be omitted), a slash is appended to
2446 directories and a space to other words.
2447 .PP
2448 \fIcommand\fR invoked from `...` version has additional environment
2449 variable set, the variable name is \%\fBCOMMAND_LINE\fR\% and
2450 contains (as its name indicates) contents of the current (already
2451 typed in) command line. One can examine and use contents of the
2452 \%\fBCOMMAND_LINE\fR\% variable in her custom script to build more
2453 sophisticated completions (see completion for svn(1) included in
2454 this package).
2455 .PP
2456 Now for some examples.  Some commands take only directories as arguments,
2457 so there's no point completing plain files.
2458 .IP "" 4
2459 > complete cd 'p/1/d/'
2460 .PP
2461 completes only the first word following `cd' (`p/1') with a directory.
2462 \fBp\fR-type completion can also be used to narrow down command completion:
2463 .IP "" 4
2464 > co[^D]
2465 .br
2466 complete compress
2467 .br
2468 > complete \-co* 'p/0/(compress)/'
2469 .br
2470 > co[^D]
2471 .br
2472 > compress
2473 .PP
2474 This completion completes commands (words in position 0, `p/0')
2475 which begin with `co' (thus matching `co*') to `compress' (the only
2476 word in the list).
2477 The leading `\-' indicates that this completion is to be used with only
2478 ambiguous commands.
2479 .IP "" 4
2480 > complete find 'n/\-user/u/'
2481 .PP
2482 is an example of \fBn\fR-type completion.  Any word following `find' and
2483 immediately following `\-user' is completed from the list of users.
2484 .IP "" 4
2485 > complete cc 'c/\-I/d/'
2486 .PP
2487 demonstrates \fBc\fR-type completion.  Any word following `cc' and beginning
2488 with `\-I' is completed as a directory.  `\-I' is not taken as part of the
2489 directory because we used lowercase \fBc\fR.
2490 .PP
2491 Different \fIlist\fRs are useful with different commands.
2492 .IP "" 4
2493 > complete alias 'p/1/a/'
2494 .br
2495 > complete man 'p/*/c/'
2496 .br
2497 > complete set 'p/1/s/'
2498 .br
2499 > complete true 'p/1/x:Truth has no options./'
2500 .PP
2501 These complete words following `alias' with aliases, `man' with commands,
2502 and `set' with shell variables.
2503 `true' doesn't have any options, so \fBx\fR does nothing when completion
2504 is attempted and prints `Truth has no options.' when completion choices are listed.
2505 .PP
2506 Note that the \fIman\fR example, and several other examples below, could
2507 just as well have used 'c/*' or 'n/*' as 'p/*'.
2508 .PP
2509 Words can be completed from a variable evaluated at completion time,
2510 .IP "" 4
2511 > complete ftp 'p/1/$hostnames/'
2512 .br
2513 > set hostnames = (rtfm.mit.edu tesla.ee.cornell.edu)
2514 .br
2515 > ftp [^D]
2516 .br
2517 rtfm.mit.edu tesla.ee.cornell.edu
2518 .br
2519 > ftp [^C]
2520 .br
2521 > set hostnames = (rtfm.mit.edu tesla.ee.cornell.edu uunet.uu.net)
2522 .br
2523 > ftp [^D]
2524 .br
2525 rtfm.mit.edu tesla.ee.cornell.edu uunet.uu.net
2526 .PP
2527 or from a command run at completion time:
2528 .IP "" 4
2529 > complete kill 'p/*/`ps | awk \\{print\\ \\$1\\}`/'
2530 .br
2531 > kill \-9 [^D]
2532 .br
2533 23113 23377 23380 23406 23429 23529 23530 PID
2534 .PP
2535 Note that the \fIcomplete\fR command does not itself quote its arguments,
2536 so the braces, space and `$' in `{print $1}' must be quoted explicitly.
2537 .PP
2538 One command can have multiple completions:
2539 .IP "" 4
2540 > complete dbx 'p/2/(core)/' 'p/*/c/'
2541 .PP
2542 completes the second argument to `dbx' with the word `core' and all other
2543 arguments with commands.  Note that the positional completion is specified
2544 before the next-word completion.
2545 Because completions are evaluated from left to right, if
2546 the next-word completion were specified first it would always match
2547 and the positional completion would never be executed.  This is a
2548 common mistake when defining a completion.
2549 .PP
2550 The \fIselect\fR pattern is useful when a command takes files with only
2551 particular forms as arguments.  For example,
2552 .IP "" 4
2553 > complete cc 'p/*/f:*.[cao]/'
2554 .PP
2555 completes `cc' arguments to files ending in only `.c', `.a', or `.o'.
2556 \fIselect\fR can also exclude files, using negation of a glob-pattern as
2557 described under \fBFilename substitution\fR.  One might use
2558 .IP "" 4
2559 > complete rm 'p/*/f:^*.{c,h,cc,C,tex,1,man,l,y}/'
2560 .PP
2561 to exclude precious source code from `rm' completion.  Of course, one
2562 could still type excluded names manually or override the completion
2563 mechanism using the \fIcomplete-word-raw\fR or \fIlist-choices-raw\fR
2564 editor commands (q.v.).
2565 .PP
2566 The `C', `D', `F' and `T' \fIlist\fRs are like `c', `d', `f' and `t'
2567 respectively, but they use the \fIselect\fR argument in a different way: to
2568 restrict completion to files beginning with a particular path prefix.  For
2569 example, the Elm mail program uses `=' as an abbreviation for one's mail
2570 directory.  One might use
2571 .IP "" 4
2572 > complete elm c@=@F:$HOME/Mail/@
2573 .PP
2574 to complete `elm \-f =' as if it were `elm \-f ~/Mail/'.  Note that we used `@'
2575 instead of `/' to avoid confusion with the \fIselect\fR argument, and we used
2576 `$HOME' instead of `~' because home directory substitution works at only the
2577 beginning of a word.
2578 .PP
2579 \fIsuffix\fR is used to add a nonstandard suffix
2580 (not space or `/' for directories) to completed words.
2581 .IP "" 4
2582 > complete finger 'c/*@/$hostnames/' 'p/1/u/@'
2583 .PP
2584 completes arguments to `finger' from the list of users, appends an `@',
2585 and then completes after the `@' from the `hostnames' variable.  Note
2586 again the order in which the completions are specified.
2587 .PP
2588 Finally, here's a complex example for inspiration:
2589 .IP "" 4
2590 > complete find \\
2591 .br
2592 \&'n/\-name/f/' 'n/\-newer/f/' 'n/\-{,n}cpio/f/' \e
2593 .br
2594 \&\'n/\-exec/c/' 'n/\-ok/c/' 'n/\-user/u/' \e
2595 .br
2596 \&'n/\-group/g/' 'n/\-fstype/(nfs 4.2)/' \e
2597 .br
2598 \&'n/\-type/(b c d f l p s)/' \e
2599 .br
2600 \'c/\-/(name newer cpio ncpio exec ok user \e
2601 .br
2602 group fstype type atime ctime depth inum \e
2603 .br
2604 ls mtime nogroup nouser perm print prune \e
2605 .br
2606 size xdev)/' \e
2607 .br
2608 \&'p/*/d/'
2609 .PP
2610 This completes words following `\-name', `\-newer', `\-cpio' or `ncpio'
2611 (note the pattern which matches both) to files,
2612 words following `\-exec' or `\-ok' to commands, words following `user'
2613 and `group' to users and groups respectively
2614 and words following `\-fstype' or `\-type' to members of the
2615 given lists.  It also completes the switches themselves from the given list
2616 (note the use of \fBc\fR-type completion)
2617 and completes anything not otherwise completed to a directory.  Whew.
2618 .PP
2619 Remember that programmed completions are ignored if the word being completed
2620 is a tilde substitution (beginning with `~') or a variable (beginning with `$').
2621 \fIcomplete\fR is an experimental feature, and the syntax may change
2622 in future versions of the shell.
2623 See also the \fIuncomplete\fR builtin command.
2624 .RE
2625 .TP 8
2626 .B continue
2627 Continues execution of the nearest enclosing \fIwhile\fR or \fIforeach\fR.
2628 The rest of the commands on the current line are executed.
2629 .TP 8
2630 .B default:
2631 Labels the default case in a \fIswitch\fR statement.
2632 It should come after all \fIcase\fR labels.
2633 .PP
2634 .B dirs \fR[\fB\-l\fR] [\fB\-n\fR|\fB\-v\fR]
2635 .br
2636 .B dirs \-S\fR|\fB\-L \fR[\fIfilename\fR] (+)
2637 .PD 0
2638 .TP 8
2639 .B dirs \-c \fR(+)
2640 The first form prints the directory stack.  The top of the stack is at the
2641 left and the first directory in the stack is the current directory.
2642 With \fB\-l\fR, `~' or `~\fIname\fP' in the output is expanded explicitly
2643 to \fBhome\fR or the pathname of the home directory for user \fIname\fP.  (+)
2644 With \fB\-n\fR, entries are wrapped before they reach the edge of the screen.  (+)
2645 With \fB\-v\fR, entries are printed one per line, preceded by their stack positions.  (+)
2646 If more than one of \fB\-n\fR or \fB\-v\fR is given, \fB\-v\fR takes precedence.
2647 \fB\-p\fR is accepted but does nothing.
2648 .PD
2649 .RS +8
2650 .PP
2651 With \fB\-S\fR, the second form saves the directory stack to \fIfilename\fR
2652 as a series of \fIcd\fR and \fIpushd\fR commands.
2653 With \fB\-L\fR, the shell sources \fIfilename\fR, which is presumably
2654 a directory stack file saved by the \fB\-S\fR option or the \fBsavedirs\fR
2655 mechanism.
2656 In either case, \fBdirsfile\fR is used if \fIfilename\fR is not given and
2657 \fI~/.cshdirs\fR is used if \fBdirsfile\fR is unset.
2658 .PP
2659 Note that login shells do the equivalent of `dirs \-L' on startup
2660 and, if \fBsavedirs\fR is set, `dirs \-S' before exiting.
2661 Because only \fI~/.tcshrc\fR is normally sourced before \fI~/.cshdirs\fR,
2662 \fBdirsfile\fR should be set in \fI~/.tcshrc\fR rather than \fI~/.login\fR.
2663 .PP
2664 The last form clears the directory stack.
2665 .RE
2666 .TP 8
2667 .B echo \fR[\fB\-n\fR] \fIword\fR ...
2668 Writes each \fIword\fR to the shell's standard
2669 output, separated by spaces and terminated with a newline.
2670 The \fBecho_style\fR shell variable may be set to emulate (or not) the flags and escape
2671 sequences of the BSD and/or System V versions of \fIecho\fR; see \fIecho\fR(1).
2672 .TP 8
2673 .B echotc \fR[\fB\-sv\fR] \fIarg\fR ... (+)
2674 Exercises the terminal capabilities (see \fItermcap\fR(5)) in \fIargs\fR.
2675 For example, 'echotc home' sends the cursor to the home position,
2676 \&'echotc cm 3 10' sends it to column 3 and row 10, and
2677 \&'echotc ts 0; echo "This is a test."; echotc fs' prints "This is a test."
2678 in the status line.
2679 .RS +8
2680 .PP
2681 If \fIarg\fR is 'baud', 'cols', 'lines', 'meta' or 'tabs', prints the
2682 value of that capability ("yes" or "no" indicating that the terminal does
2683 or does not have that capability).  One might use this to make the output
2684 from a shell script less verbose on slow terminals, or limit command
2685 output to the number of lines on the screen:
2686 .IP "" 4
2687 > set history=`echotc lines`
2688 .br
2689 > @ history\-\-
2690 .PP
2691 Termcap strings may contain wildcards which will not echo correctly.
2692 One should use double quotes when setting a shell variable to a terminal
2693 capability string, as in the following example that places the date in
2694 the status line:
2695 .IP "" 4
2696 > set tosl="`echotc ts 0`"
2697 .br
2698 > set frsl="`echotc fs`"
2699 .br
2700 > echo \-n "$tosl";date; echo \-n "$frsl"
2701 .PP
2702 With \fB\-s\fR, nonexistent capabilities return the empty string rather
2703 than causing an error.
2704 With \fB\-v\fR, messages are verbose.
2705 .RE
2706 .PP
2707 .B else
2708 .br
2709 .B end
2710 .br
2711 .B endif
2712 .PD 0
2713 .TP 8
2714 .B endsw
2715 See the description of the \fIforeach\fR, \fIif\fR, \fIswitch\fR, and
2716 \fIwhile\fR statements below.
2717 .PD
2718 .TP 8
2719 .B eval \fIarg\fR ...
2720 Treats the arguments as input to the
2721 shell and executes the resulting command(s) in the context
2722 of the current shell.  This is usually used to execute commands
2723 generated as the result of command or variable substitution,
2724 because parsing occurs before these substitutions.
2725 See \fItset\fR(1) for a sample use of \fIeval\fR.
2726 .TP 8
2727 .B exec \fIcommand\fR
2728 Executes the specified command in place of the current shell.
2729 .TP 8
2730 .B exit \fR[\fIexpr\fR]
2731 The shell exits either with the value of the specified \fIexpr\fR
2732 (an expression, as described under \fBExpressions\fR)
2733 or, without \fIexpr\fR, with the value 0.
2734 .TP 8
2735 .B fg \fR[\fB%\fIjob\fR ...]
2736 Brings the specified jobs (or, without arguments, the current job)
2737 into the foreground, continuing each if it is stopped.
2738 \fIjob\fR may be a number, a string, `', `%', `+' or `\-' as described
2739 under \fBJobs\fR.
2740 See also the \fIrun-fg-editor\fR editor command.
2741 .TP 8
2742 .B filetest \-\fIop file\fR ... (+)
2743 Applies \fIop\fR (which is a file inquiry operator as described under
2744 \fBFile inquiry operators\fR) to each \fIfile\fR and returns the results as a
2745 space-separated list.
2746 .PP
2747 .B foreach \fIname \fB(\fIwordlist\fB)
2748 .br
2749 \&...
2750 .PD 0
2751 .TP 8
2752 .B end
2753 Successively sets the variable \fIname\fR to each member of
2754 \fIwordlist\fR and executes the sequence of commands between this command
2755 and the matching \fIend\fR.  (Both \fIforeach\fR and \fIend\fR
2756 must appear alone on separate lines.)  The builtin command
2757 \fIcontinue\fR may be used to continue the loop prematurely and
2758 the builtin command \fIbreak\fR to terminate it prematurely.
2759 When this command is read from the terminal, the loop is read once
2760 prompting with `foreach? ' (or \fBprompt2\fR) before any statements in
2761 the loop are executed.  If you make a mistake typing in a
2762 loop at the terminal you can rub it out.
2763 .PD
2764 .TP 8
2765 .B getspath \fR(+)
2766 Prints the system execution path.  (TCF only)
2767 .TP 8
2768 .B getxvers \fR(+)
2769 Prints the experimental version prefix.  (TCF only)
2770 .TP 8
2771 .B glob \fIwordlist
2772 Like \fIecho\fR, but the `-n' parameter is not recognized and words are
2773 delimited by null characters in the output.  Useful for
2774 programs which wish to use the shell to filename expand a list of words.
2775 .TP 8
2776 .B goto \fIword
2777 \fIword\fR is filename and command-substituted to
2778 yield a string of the form `label'.  The shell rewinds its
2779 input as much as possible, searches for a line of the
2780 form `label:', possibly preceded by blanks or tabs, and
2781 continues execution after that line.
2782 .TP 8
2783 .B hashstat
2784 Prints a statistics line indicating how effective the
2785 internal hash table has been at locating commands (and avoiding
2786 \fIexec\fR's).  An \fIexec\fR is attempted for each component of the
2787 \fBpath\fR where the hash function indicates a possible hit, and
2788 in each component which does not begin with a `/'.
2789 .IP
2790 On machines without \fIvfork\fR(2), prints only the number and size of
2791 hash buckets.
2792 .PP
2793 .B history \fR[\fB\-hTr\fR] [\fIn\fR]
2794 .br
2795 .B history \-S\fR|\fB\-L|\fB\-M \fR[\fIfilename\fR] (+)
2796 .PD 0
2797 .TP 8
2798 .B history \-c \fR(+)
2799 The first form prints the history event list.
2800 If \fIn\fR is given only the \fIn\fR most recent events are printed or saved.
2801 With \fB\-h\fR, the history list is printed without leading numbers.  If
2802 \fB-T\fR is specified, timestamps are printed also in comment form.
2803 (This can be used to
2804 produce files suitable for loading with 'history \-L' or 'source \-h'.)
2805 With \fB\-r\fR, the order of printing is most recent
2806 first rather than oldest first.
2807 .PD
2808 .RS +8
2809 .PP
2810 With \fB\-S\fR, the second form saves the history list to \fIfilename\fR.
2811 If the first word of the \fBsavehist\fR shell variable is set to a
2812 number, at most that many lines are saved.  If the second word of
2813 \fBsavehist\fR is set to `merge', the history list is merged with the
2814 existing history file instead of replacing it (if there is one) and
2815 sorted by time stamp.  (+) Merging is intended for an environment like
2816 the X Window System
2817 with several shells in simultaneous use.  Currently it succeeds
2818 only when the shells quit nicely one after another.
2819 .PP
2820 With \fB\-L\fR, the shell appends \fIfilename\fR, which is presumably a
2821 history list saved by the \fB\-S\fR option or the \fBsavehist\fR mechanism,
2822 to the history list.
2823 \fB\-M\fR is like \fB\-L\fR, but the contents of \fIfilename\fR are merged
2824 into the history list and sorted by timestamp.
2825 In either case, \fBhistfile\fR is used if \fIfilename\fR is not given and
2826 \fI~/.history\fR is used if \fBhistfile\fR is unset.
2827 `history \-L' is exactly like 'source \-h' except that it does not require a
2828 filename.
2829 .PP
2830 Note that login shells do the equivalent of `history \-L' on startup
2831 and, if \fBsavehist\fR is set, `history \-S' before exiting.
2832 Because only \fI~/.tcshrc\fR is normally sourced before \fI~/.history\fR,
2833 \fBhistfile\fR should be set in \fI~/.tcshrc\fR rather than \fI~/.login\fR.
2834 .PP
2835 If \fBhistlit\fR is set, the first and second forms print and save the literal
2836 (unexpanded) form of the history list.
2837 .PP
2838 The last form clears the history list.
2839 .RE
2840 .TP 8
2841 .B hup \fR[\fIcommand\fR] \fR(+)
2842 With \fIcommand\fR, runs \fIcommand\fR such that it will exit on a hangup
2843 signal and arranges for the shell to send it a hangup signal when the shell
2844 exits.
2845 Note that commands may set their own response to hangups, overriding \fIhup\fR.
2846 Without an argument, causes the non-interactive shell only to
2847 exit on a hangup for the remainder of the script.
2848 See also \fBSignal handling\fR and the \fInohup\fR builtin command.
2849 .TP 8
2850 .B if (\fIexpr\fB) \fIcommand
2851 If \fIexpr\fR (an expression, as described under \fBExpressions\fR)
2852 evaluates true, then \fIcommand\fR is executed.
2853 Variable substitution on \fIcommand\fR happens early, at the same time it
2854 does for the rest of the \fIif\fR command.
2855 \fIcommand\fR must be a simple command, not an alias, a pipeline, a command list
2856 or a parenthesized command list, but it may have arguments.
2857 Input/output redirection occurs even if \fIexpr\fR is
2858 false and \fIcommand\fR is thus \fInot\fR executed; this is a bug.
2859 .PP
2860 .B if (\fIexpr\fB) then
2861 .br
2862 \&...
2863 .br
2864 .B else if (\fIexpr2\fB) then
2865 .br
2866 \&...
2867 .br
2868 .B else
2869 .br
2870 \&...
2871 .PD 0
2872 .TP 8
2873 .B endif
2874 If the specified \fIexpr\fR is true then the commands to the
2875 first \fIelse\fR are executed; otherwise if \fIexpr2\fR is true then
2876 the commands to the second \fIelse\fR are executed, etc.  Any
2877 number of \fIelse-if\fR pairs are possible; only one \fIendif\fR is
2878 needed.  The \fIelse\fR part is likewise optional.  (The words
2879 \fIelse\fR and \fIendif\fR must appear at the beginning of input lines;
2880 the \fIif\fR must appear alone on its input line or after an
2881 \fIelse\fR.)
2882 .PD
2883 .TP 8
2884 .B inlib \fIshared-library\fR ... (+)
2885 Adds each \fIshared-library\fR to the current environment.  There is no way
2886 to remove a shared library.  (Domain/OS only)
2887 .TP 8
2888 .B jobs \fR[\fB\-l\fR]
2889 Lists the active jobs.  With \fB\-l\fR, lists process
2890 IDs in addition to the normal information.  On TCF systems, prints
2891 the site on which each job is executing.
2892 .PP
2893 .PD 0
2894 .TP 8
2895 .B kill \fR[\fB\-s \fIsignal\fR] \fB%\fIjob\fR|\fIpid\fR ...
2896 .PD 0
2897 .TP 8
2898 .B kill \-l
2899 The first and second forms sends the specified \fIsignal\fR (or, if none
2900 is given, the TERM (terminate) signal) to the specified jobs or processes.
2901 \fIjob\fR may be a number, a string, `', `%', `+' or `\-' as described
2902 under \fBJobs\fR.
2903 Signals are either given by number or by name (as given in
2904 \fI/usr/include/signal.h\fR, stripped of the prefix `SIG').
2905 There is no default \fIjob\fR; saying just `kill' does not send a signal
2906 to the current job.  If the signal being sent is TERM (terminate)
2907 or HUP (hangup), then the job or process is sent a
2908 CONT (continue) signal as well.
2909 The third form lists the signal names.
2910 .PD
2911 .TP 8
2912 .B limit \fR[\fB\-h\fR] [\fIresource\fR [\fImaximum-use\fR]]
2913 Limits the consumption by the current process and each
2914 process it creates to not individually exceed \fImaximum-use\fR on
2915 the specified \fIresource\fR.  If no \fImaximum-use\fR is given, then
2916 the current limit is printed; if no \fIresource\fR is given, then
2917 all limitations are given.  If the \fB\-h\fR flag is given, the
2918 hard limits are used instead of the current limits.  The
2919 hard limits impose a ceiling on the values of the current
2920 limits.  Only the super-user may raise the hard limits, but
2921 a user may lower or raise the current limits within the legal range.
2922 .RS +8
2923 .PP
2924 Controllable resources currently include (if supported by the OS):
2925 .TP
2926 \fIcputime\fR
2927 the maximum number of cpu-seconds to be used by each process
2928 .TP
2929 \fIfilesize\fR
2930 the largest single file which can be created
2931 .TP
2932 \fIdatasize\fR
2933 the maximum growth of the data+stack region via sbrk(2) beyond
2934 the end of the program text
2935 .TP
2936 \fIstacksize\fR
2937 the maximum size of the automatically-extended stack region
2938 .TP
2939 \fIcoredumpsize\fR
2940 the size of the largest core dump that will be created
2941 .TP
2942 \fImemoryuse\fR
2943 the maximum amount of physical memory a process
2944 may have allocated to it at a given time
2945 .TP
2946 \fIvmemoryuse\fR
2947 the maximum amount of virtual memory a process
2948 may have allocated to it at a given time (address space)
2949 .TP
2950 \fIvmemoryuse\fR
2951 the maximum amount of virtual memory a process
2952 may have allocated to it at a given time
2953 .TP
2954 \fIheapsize\fR
2955 the maximum amount of memory a process
2956 may allocate per \fIbrk()\fR system call
2957 .TP
2958 \fIdescriptors\fR or \fIopenfiles\fR
2959 the maximum number of open files for this process
2960 .TP
2961 \fIconcurrency\fR
2962 the maximum number of threads for this process
2963 .TP
2964 \fImemorylocked\fR
2965 the maximum size which a process may lock into memory using mlock(2)
2966 .TP
2967 \fImaxproc\fR
2968 the maximum number of simultaneous processes for this user id
2969 .TP
2970 \fIsbsize\fR
2971 the maximum size of socket buffer usage for this user
2972 .TP
2973 \fIswapsize\fR
2974 the maximum amount of swap space reserved or used for this user
2975 .TP
2976 \fImaxlocks\fR
2977 the maximum number of locks for this user
2978 .TP
2979 \fImaxsignal\fR
2980 the maximum number of pending signals for this user
2981 .TP
2982 \fImaxmessage\fR
2983 the maximum number of bytes in POSIX mqueues for this user
2984 .TP
2985 \fImaxnice\fR
2986 the maximum nice priority the user is allowed to raise mapped from [19...-20]
2987 to [0...39] for this user
2988 .TP
2989 \fImaxrtprio\fR
2990 the maximum realtime priority for this user
2991 \fImaxrttime\fR
2992 the timeout for RT tasks in microseconds for this user.
2993 .PP
2994 \fImaximum-use\fR may be given as a (floating point or
2995 integer) number followed by a scale factor.  For all limits
2996 other than \fIcputime\fR the default scale is `k' or `kilobytes'
2997 (1024 bytes); a scale factor of `m' or `megabytes' or `g' or `gigabytes'
2998 may also be used.  For \fIcputime\fR the default scaling is `seconds',
2999 while `m' for minutes or `h' for hours, or a time of the
3000 form `mm:ss' giving minutes and seconds may be used.
3001 .PP
3002 If \fImaximum-use\fR  is `unlimited',
3003 then the limitation on the specified \fIresource\fR
3004 is removed (this is equivalent to the \fIunlimit\fR builtin command).
3005 .PP
3006 For both \fIresource\fR names and scale factors, unambiguous
3007 prefixes of the names suffice.
3008 .RE
3009 .TP 8
3010 .B log \fR(+)
3011 Prints the \fBwatch\fR shell variable and reports on each user indicated
3012 in \fBwatch\fR who is logged in, regardless of when they last logged in.
3013 See also \fIwatchlog\fR.
3014 .TP 8
3015 .B login
3016 Terminates a login shell, replacing it with an instance of
3017 \fI/bin/login\fR. This is one way to log off, included for
3018 compatibility with \fIsh\fR(1).
3019 .TP 8
3020 .B logout
3021 Terminates a login shell.  Especially useful if \fBignoreeof\fR is set.
3022 .TP 8
3023 .B ls\-F \fR[\-\fIswitch\fR ...] [\fIfile\fR ...] (+)
3024 Lists files like `ls \-F', but much faster.  It identifies each type of
3025 special file in the listing with a special character:
3026 .PP
3027 .RS +8
3028 .PD 0
3029 .TP 4
3030 /
3031 Directory
3032 .TP 4
3033 *
3034 Executable
3035 .TP 4
3036 #
3037 Block device
3038 .TP 4
3039 %
3040 Character device
3041 .TP 4
3042 |
3043 Named pipe (systems with named pipes only)
3044 .TP 4
3045 =
3046 Socket (systems with sockets only)
3047 .TP 4
3048 @
3049 Symbolic link (systems with symbolic links only)
3050 .TP 4
3051 +
3052 Hidden directory (AIX only) or context dependent (HP/UX only)
3053 .TP 4
3054 :
3055 Network special (HP/UX only)
3056 .PD
3057 .PP
3058 If the \fBlistlinks\fR shell variable is set, symbolic links are identified
3059 in more detail (on only systems that have them, of course):
3060 .PP
3061 .PD 0
3062 .TP 4
3063 @
3064 Symbolic link to a non-directory
3065 .TP 4
3066 >
3067 Symbolic link to a directory
3068 .TP 4
3069 &
3070 Symbolic link to nowhere
3071 .PD
3072 .PP
3073 \fBlistlinks\fR also slows down \fIls\-F\fR and causes partitions holding
3074 files pointed to by symbolic links to be mounted.
3075 .PP
3076 If the \fBlistflags\fR shell variable is set to `x', `a' or `A', or any
3077 combination thereof (e.g., `xA'), they are used as flags to \fIls\-F\fR,
3078 making it act like `ls \-xF', `ls \-Fa', `ls \-FA' or a combination
3079 (e.g., `ls \-FxA').
3080 On machines where `ls \-C' is not the default, \fIls\-F\fR acts like `ls \-CF',
3081 unless \fBlistflags\fR contains an `x', in which case it acts like `ls \-xF'.
3082 \fIls\-F\fR passes its arguments to \fIls\fR(1) if it is given any switches,
3083 so `alias ls ls\-F' generally does the right thing.
3084 .PP
3085 The \fBls\-F\fR builtin can list files using different colors depending on the
3086 filetype or extension.  See the \fBcolor\fR shell variable and the
3087 \fBLS_COLORS\fR environment variable.
3088 .RE
3089 .PP
3090 .B migrate \fR[\fB\-\fIsite\fR] \fIpid\fR|\fB%\fIjobid\fR ... (+)
3091 .PD 0
3092 .TP 8
3093 .B migrate \-\fIsite\fR (+)
3094 The first form migrates the process or job to the site specified or the
3095 default site determined by the system path.
3096 The second form is equivalent to `migrate \-\fIsite\fR $$': it migrates the
3097 current process to the specified site.  Migrating the shell
3098 itself can cause unexpected behavior, because the shell
3099 does not like to lose its tty.  (TCF only)
3100 .PD
3101 .TP 8
3102 .B newgrp \fR[\fB\-\fR] \fI[group]\fR (+)
3103 Equivalent to `exec newgrp'; see \fInewgrp\fR(1).
3104 Available only if the shell was so compiled;
3105 see the \fBversion\fR shell variable.
3106 .TP 8
3107 .B nice \fR[\fB+\fInumber\fR] [\fIcommand\fR]
3108 Sets the scheduling priority for the shell to \fInumber\fR, or, without
3109 \fInumber\fR, to 4.  With \fIcommand\fR, runs \fIcommand\fR at the appropriate
3110 priority.
3111 The greater the \fInumber\fR, the less cpu
3112 the process gets.  The super-user may specify negative
3113 priority by using `nice \-number ...'.  Command is always
3114 executed in a sub-shell, and the restrictions placed on
3115 commands in simple \fIif\fR statements apply.
3116 .TP 8
3117 .B nohup \fR[\fIcommand\fR]
3118 With \fIcommand\fR, runs \fIcommand\fR such that it will ignore hangup signals.
3119 Note that commands may set their own response to hangups, overriding \fInohup\fR.
3120 Without an argument, causes the non-interactive shell only to
3121 ignore hangups for the remainder of the script.
3122 See also \fBSignal handling\fR and the \fIhup\fR builtin command.
3123 .TP 8
3124 .B notify \fR[\fB%\fIjob\fR ...]
3125 Causes the shell to notify the user asynchronously when the status of any
3126 of the specified jobs (or, without %\fIjob\fR, the current job) changes,
3127 instead of waiting until the next prompt as is usual.
3128 \fIjob\fR may be a number, a string, `', `%', `+' or `\-' as described
3129 under \fBJobs\fR.
3130 See also the \fBnotify\fR shell variable.
3131 .TP 8
3132 .B onintr \fR[\fB\-\fR|\fIlabel\fR]
3133 Controls the action of the shell on interrupts.  Without arguments,
3134 restores the default action of the shell on interrupts,
3135 which is to terminate shell scripts or to return to the
3136 terminal command input level.
3137 With `\-', causes all interrupts to be ignored.
3138 With \fIlabel\fR, causes the shell to execute a `goto \fIlabel\fR'
3139 when an interrupt is received or a child process terminates because it was
3140 interrupted.
3141 .IP "" 8
3142 \fIonintr\fR is ignored if the shell is running detached and in system
3143 startup files (see \fBFILES\fR), where interrupts are disabled anyway.
3144 .TP 8
3145 .B popd \fR[\fB\-p\fR] [\fB\-l\fR] [\fB\-n\fR|\fB\-v\fR] \fR[\fB+\fIn\fR]
3146 Without arguments, pops the directory stack and returns to the new top directory.
3147 With a number `+\fIn\fR', discards the \fIn\fR'th entry in the stack.
3148 .IP "" 8
3149 Finally, all forms of \fIpopd\fR print the final directory stack,
3150 just like \fIdirs\fR.  The \fBpushdsilent\fR shell variable can be set to
3151 prevent this and the \fB\-p\fR flag can be given to override \fBpushdsilent\fR.
3152 The \fB\-l\fR, \fB\-n\fR and \fB\-v\fR flags have the same effect on \fIpopd\fR
3153 as on \fIdirs\fR.  (+)
3154 .TP 8
3155 .B printenv \fR[\fIname\fR] (+)
3156 Prints the names and values of all environment variables or,
3157 with \fIname\fR, the value of the environment variable \fIname\fR.
3158 .TP 8
3159 .B pushd \fR[\fB\-p\fR] [\fB\-l\fR] [\fB\-n\fR|\fB\-v\fR] [\fIname\fR|\fB+\fIn\fR]
3160 Without arguments, exchanges the top two elements of the directory stack.
3161 If \fBpushdtohome\fR is set, \fIpushd\fR without arguments does `pushd ~',
3162 like \fIcd\fR.  (+)
3163 With \fIname\fR, pushes the current working directory onto the directory
3164 stack and changes to \fIname\fR.
3165 If \fIname\fR is `\-' it is interpreted as the previous working directory
3166 (see \fBFilename substitution\fR).  (+)
3167 If \fBdunique\fR is set, \fIpushd\fR removes any instances of \fIname\fR
3168 from the stack before pushing it onto the stack.  (+)
3169 With a number `+\fIn\fR', rotates the \fIn\fRth element of the
3170 directory stack around to be the top element and changes to it.
3171 If \fBdextract\fR is set, however, `pushd +\fIn\fR' extracts the \fIn\fRth
3172 directory, pushes it onto the top of the stack and changes to it.  (+)
3173 .IP "" 8
3174 Finally, all forms of \fIpushd\fR print the final directory stack,
3175 just like \fIdirs\fR.  The \fBpushdsilent\fR shell variable can be set to
3176 prevent this and the \fB\-p\fR flag can be given to override \fBpushdsilent\fR.
3177 The \fB\-l\fR, \fB\-n\fR and \fB\-v\fR flags have the same effect on \fIpushd\fR
3178 as on \fIdirs\fR.  (+)
3179 .TP 8
3180 .B rehash
3181 Causes the internal hash table of the contents of the
3182 directories in the \fBpath\fR variable to be recomputed.  This is
3183 needed if the \fBautorehash\fR shell variable is not set and new
3184 commands are added to directories in \fBpath\fR while you are logged
3185 in.  With \fBautorehash\fR, a new command will be found
3186 automatically, except in the special case where another command of
3187 the same name which is located in a different directory already
3188 exists in the hash table.  Also flushes the cache of home directories
3189 built by tilde expansion.
3190 .TP 8
3191 .B repeat \fIcount command
3192 The specified \fIcommand\fR,
3193 which is subject to the same restrictions as the \fIcommand\fR
3194 in the one line \fIif\fR statement above, is executed \fIcount\fR times.
3195 I/O redirections occur exactly once, even if \fIcount\fR is 0.
3196 .TP 8
3197 .B rootnode //\fInodename \fR(+)
3198 Changes the rootnode to //\fInodename\fR, so that `/' will be interpreted
3199 as `//\fInodename\fR'.  (Domain/OS only)
3200 .PP
3201 .B sched \fR(+)
3202 .br
3203 .B sched \fR[\fB+\fR]\fIhh:mm command\fR \fR(+)
3204 .PD 0
3205 .TP 8
3206 .B sched \-\fIn\fR (+)
3207 The first form prints the scheduled-event list.
3208 The \fBsched\fR shell variable may be set to define the format in which
3209 the scheduled-event list is printed.
3210 The second form adds \fIcommand\fR to the scheduled-event list.
3211 For example,
3212 .PD
3213 .RS +8
3214 .IP "" 4
3215 > sched 11:00 echo It\\'s eleven o\\'clock.
3216 .PP
3217 causes the shell to echo `It's eleven o'clock.' at 11 AM.
3218 The time may be in 12-hour AM/PM format
3219 .IP "" 4
3220 > sched 5pm set prompt='[%h] It\\'s after 5; go home: >'
3221 .PP
3222 or may be relative to the current time:
3223 .IP "" 4
3224 > sched +2:15 /usr/lib/uucp/uucico \-r1 \-sother
3225 .PP
3226 A relative time specification may not use AM/PM format.
3227 The third form removes item \fIn\fR from the event list:
3228 .IP "" 4
3229 > sched
3230 .br
3231      1  Wed Apr  4 15:42  /usr/lib/uucp/uucico \-r1 \-sother
3232 .br
3233      2  Wed Apr  4 17:00  set prompt=[%h] It's after 5; go home: >
3234 .br
3235 > sched \-2
3236 .br
3237 > sched
3238 .br
3239      1  Wed Apr  4 15:42  /usr/lib/uucp/uucico \-r1 \-sother
3240 .PP
3241 A command in the scheduled-event list is executed just before the first
3242 prompt is printed after the time when the command is scheduled.
3243 It is possible to miss the exact time when the command is to be run, but
3244 an overdue command will execute at the next prompt.
3245 A command which comes due while the shell
3246 is waiting for user input is executed immediately.
3247 However, normal operation of an already-running command will not
3248 be interrupted so that a scheduled-event list element may be run.
3249 .PP
3250 This mechanism is similar to, but not the same as, the \fIat\fR(1)
3251 command on some Unix systems.
3252 Its major disadvantage is that it may not run a command at exactly the
3253 specified time.
3254 Its major advantage is that because \fIsched\fR runs directly from
3255 the shell, it has access to shell variables and other structures.
3256 This provides a mechanism for changing one's working environment
3257 based on the time of day.
3258 .RE
3259 .PP
3260 .B set
3261 .br
3262 .B set \fIname\fR ...
3263 .br
3264 .B set \fIname\fR\fB=\fIword\fR ...
3265 .br
3266 .B set [\-r] [\-f|\-l] \fIname\fR\fB=(\fIwordlist\fB)\fR ... (+)
3267 .br
3268 .B set \fIname[index]\fR\fB=\fIword\fR ...
3269 .br
3270 .B set \-r \fR(+)
3271 .br
3272 .B set \-r \fIname\fR ... (+)
3273 .PD 0
3274 .TP 8
3275 .B set \-r \fIname\fR\fB=\fIword\fR ... (+)
3276 The first form of the command prints the value of all shell variables.
3277 Variables which contain more than a single word print as a
3278 parenthesized word list.
3279 The second form sets \fIname\fR to the null string.
3280 The third form sets \fIname\fR to the single \fIword\fR.
3281 The fourth form sets \fIname\fR to the list of words in
3282 \fIwordlist\fR.  In all cases the value is command and filename expanded.
3283 If \fB\-r\fR is specified, the value is set read-only.  If \fB\-f\fR or
3284 \fB\-l\fR are specified, set only unique words keeping their order.
3285 \fB\-f\fR prefers the first occurrence of a word, and \fB\-l\fR the last.
3286 The fifth form sets the \fIindex\fR'th component of \fIname\fR to \fIword\fR;
3287 this component must already exist.
3288 The sixth form lists only the names of all shell variables that are read-only.
3289 The seventh form makes \fIname\fR read-only, whether or not it has a value.
3290 The eighth form is the same as the third form, but
3291 make \fIname\fR read-only at the same time.
3292 .PD
3293 .IP "" 8
3294 These arguments can be repeated to set and/or make read-only multiple variables
3295 in a single set command.  Note, however, that variable expansion
3296 happens for all arguments before any setting occurs.  Note also that `=' can
3297 be adjacent to both \fIname\fR and \fIword\fR or separated from both by
3298 whitespace, but cannot be adjacent to only one or the other.
3299 See also the \fIunset\fR builtin command.
3300 .TP 8
3301 .B setenv \fR[\fIname \fR[\fIvalue\fR]]
3302 Without arguments, prints the names and values of all environment variables.
3303 Given \fIname\fR, sets the environment variable \fIname\fR to \fIvalue\fR
3304 or, without \fIvalue\fR, to the null string.
3305 .TP 8
3306 .B setpath \fIpath \fR(+)
3307 Equivalent to \fIsetpath\fR(1).  (Mach only)
3308 .TP 8
3309 .B setspath\fR LOCAL|\fIsite\fR|\fIcpu\fR ...  (+)
3310 Sets the system execution path.  (TCF only)
3311 .TP 8
3312 .B settc \fIcap value \fR(+)
3313 Tells the shell to believe that the terminal capability \fIcap\fR
3314 (as defined in \fItermcap\fR(5)) has the value \fIvalue\fR.
3315 No sanity checking is done.
3316 Concept terminal users may have to `settc xn no' to get proper
3317 wrapping at the rightmost column.
3318 .TP 8
3319 .B setty \fR[\fB\-d\fR|\fB\-q\fR|\fB\-x\fR] [\fB\-a\fR] [[\fB+\fR|\fB\-\fR]\fImode\fR] (+)
3320 Controls which tty modes (see \fBTerminal management\fR)
3321 the shell does not allow to change.
3322 \fB\-d\fR, \fB\-q\fR or \fB\-x\fR tells \fIsetty\fR to act
3323 on the `edit', `quote' or `execute' set of tty modes respectively; without
3324 \fB\-d\fR, \fB\-q\fR or \fB\-x\fR, `execute' is used.
3325 .IP "" 8
3326 Without other arguments, \fIsetty\fR lists the modes in the chosen set
3327 which are fixed on (`+mode') or off (`\-mode').
3328 The available modes, and thus the display, vary from system to system.
3329 With \fB\-a\fR, lists all tty modes in the chosen set
3330 whether or not they are fixed.
3331 With \fB+\fImode\fR, \fB\-\fImode\fR or \fImode\fR, fixes \fImode\fR on or off
3332 or removes control from \fImode\fR in the chosen set.
3333 For example, `setty +echok echoe' fixes `echok' mode on and allows commands
3334 to turn `echoe' mode on or off, both when the shell is executing commands.
3335 .TP 8
3336 .B setxvers\fR [\fIstring\fR] (+)
3337 Set the experimental version prefix to \fIstring\fR, or removes it
3338 if \fIstring\fR is omitted.  (TCF only)
3339 .TP 8
3340 .B shift \fR[\fIvariable\fR]
3341 Without arguments, discards \fBargv\fR[1] and shifts the members of
3342 \fBargv\fR to the left.  It is an error for \fBargv\fR not to be set or to have
3343 less than one word as value.  With \fIvariable\fR, performs the
3344 same function on \fIvariable\fR.
3345 .TP 8
3346 .B source \fR[\fB\-h\fR] \fIname\fR [\fIargs\fR ...]
3347 The shell reads and executes commands from \fIname\fR.
3348 The commands are not placed on the history list.
3349 If any \fIargs\fR are given, they are placed in \fBargv\fR.  (+)
3350 \fIsource\fR commands may be nested;
3351 if they are nested too deeply the shell may run out of file descriptors.
3352 An error in a \fIsource\fR at any level terminates all nested
3353 \fIsource\fR commands.
3354 With \fB\-h\fR, commands are placed on the history list instead of being
3355 executed, much like `history \-L'.
3356 .TP 8
3357 .B stop \fB%\fIjob\fR|\fIpid\fR ...
3358 Stops the specified jobs or processes which are executing in the background.
3359 \fIjob\fR may be a number, a string, `', `%', `+' or `\-' as described
3360 under \fBJobs\fR.
3361 There is no default \fIjob\fR; saying just `stop' does not stop
3362 the current job.
3363 .TP 8
3364 .B suspend
3365 Causes the shell to stop in its tracks, much as if it had
3366 been sent a stop signal with \fB^Z\fR.  This is most often used to
3367 stop shells started by \fIsu\fR(1).
3368 .PP
3369 .B switch (\fIstring\fB)
3370 .br
3371 .B case \fIstr1\fB:
3372 .PD 0
3373 .IP "" 4
3374 \&...
3375 .br
3376 .B breaksw
3377 .PP
3378 \&...
3379 .PP
3380 .B default:
3381 .IP "" 4
3382 \&...
3383 .br
3384 .B breaksw
3385 .TP 8
3386 .B endsw
3387 Each case label is successively matched, against the
3388 specified \fIstring\fR which is first command and filename expanded.
3389 The file metacharacters `*', `?' and `[...]'  may be used
3390 in the case labels, which are variable expanded.  If none
3391 of the labels match before a `default' label is found, then
3392 the execution begins after the default label.  Each case
3393 label and the default label must appear at the beginning of
3394 a line.  The command \fIbreaksw\fR causes execution to continue
3395 after the \fIendsw\fR.  Otherwise control may fall through case
3396 labels and default labels as in C.  If no label matches and
3397 there is no default, execution continues after the \fIendsw\fR.
3398 .PD
3399 .TP 8
3400 .B telltc \fR(+)
3401 Lists the values of all terminal capabilities (see \fItermcap\fR(5)).
3402 .TP 8
3403 .B termname \fR[\fIterminal type\fR] \fR(+)
3404 Tests if \fIterminal type\fR (or the current value of \fBTERM\fR if no
3405 \fIterminal type\fR is given) has an entry in the hosts termcap(5) or
3406 terminfo(5) database. Prints the terminal type to stdout and returns 0
3407 if an entry is present otherwise returns 1.
3408 .TP 8
3409 .B time \fR[\fIcommand\fR]
3410 Executes \fIcommand\fR (which must be a simple command, not an alias,
3411 a pipeline, a command list or a parenthesized command list)
3412 and prints a time summary as described under the \fBtime\fR variable.
3413 If necessary, an extra shell is created to print the time statistic when
3414 the command completes.
3415 Without \fIcommand\fR, prints a time summary for the current shell and its
3416 children.
3417 .TP 8
3418 .B umask \fR[\fIvalue\fR]
3419 Sets the file creation mask to \fIvalue\fR, which is given in octal.
3420 Common values for the mask are
3421 002, giving all access to the group and read and execute access to others, and
3422 022, giving read and execute access to the group and others.
3423 Without \fIvalue\fR, prints the current file creation mask.
3424 .TP 8
3425 .B unalias \fIpattern\fR
3426 .br
3427 Removes all aliases whose names match \fIpattern\fR.
3428 `unalias *' thus removes all aliases.
3429 It is not an error for nothing to be \fIunalias\fRed.
3430 .TP 8
3431 .B uncomplete \fIpattern\fR (+)
3432 Removes all completions whose names match \fIpattern\fR.
3433 `uncomplete *' thus removes all completions.
3434 It is not an error for nothing to be \fIuncomplete\fRd.
3435 .TP 8
3436 .B unhash
3437 Disables use of the internal hash table to speed location of
3438 executed programs.
3439 .TP 8
3440 .B universe \fIuniverse\fR (+)
3441 Sets the universe to \fIuniverse\fR.  (Masscomp/RTU only)
3442 .TP 8
3443 .B unlimit \fR[\fB\-hf\fR] [\fIresource\fR]
3444 Removes the limitation on \fIresource\fR or, if no \fIresource\fR is
3445 specified, all \fIresource\fR limitations.
3446 With \fB\-h\fR, the corresponding hard limits are removed.
3447 Only the super-user may do this.
3448 Note that \fBunlimit\fR may not exit successful, since most systems
3449 do not allow \fIdescriptors\fR to be unlimited.
3450 With \fB\-f\fR errors are ignored.
3451 .TP 8
3452 .B unset \fIpattern
3453 Removes all variables whose names match \fIpattern\fR, unless they are read-only.
3454 `unset *' thus removes all variables unless they are read-only;
3455 this is a bad idea.
3456 It is not an error for nothing to be \fIunset\fR.
3457 .TP 8
3458 .B unsetenv \fIpattern
3459 Removes all environment variables whose names match \fIpattern\fR.
3460 `unsetenv *' thus removes all environment variables;
3461 this is a bad idea.
3462 It is not an error for nothing to be \fIunsetenv\fRed.
3463 .TP 8
3464 .B ver \fR[\fIsystype\fR [\fIcommand\fR]] (+)
3465 Without arguments, prints \fBSYSTYPE\fR.  With \fIsystype\fR, sets \fBSYSTYPE\fR
3466 to \fIsystype\fR.  With \fIsystype\fR and \fIcommand\fR, executes \fIcommand\fR
3467 under \fIsystype\fR.  \fIsystype\fR may be `bsd4.3' or `sys5.3'.
3468 (Domain/OS only)
3469 .TP 8
3470 .B wait
3471 The shell waits for all background jobs.  If the shell is interactive, an
3472 interrupt will disrupt the wait and cause the shell to print the names and job
3473 numbers of all outstanding jobs.
3474 .TP 8
3475 .B warp \fIuniverse\fR (+)
3476 Sets the universe to \fIuniverse\fR.  (Convex/OS only)
3477 .TP 8
3478 .B watchlog \fR(+)
3479 An alternate name for the \fIlog\fR builtin command (q.v.).
3480 Available only if the shell was so compiled;
3481 see the \fBversion\fR shell variable.
3482 .TP 8
3483 .B where \fIcommand\fR (+)
3484 Reports all known instances of \fIcommand\fR, including aliases, builtins and
3485 executables in \fBpath\fR.
3486 .TP 8
3487 .B which\fR \fIcommand\fR (+)
3488 Displays the command that will be executed by the shell after substitutions,
3489 \fBpath\fR searching, etc.
3490 The builtin command is just like \fIwhich\fR(1), but it correctly reports
3491 \fItcsh\fR aliases and builtins and is 10 to 100 times faster.
3492 See also the \fIwhich-command\fR editor command.
3493 .PP
3494 .B while (\fIexpr\fB)\fR
3495 .br
3496 \&...
3497 .PD 0
3498 .TP 8
3499 .B end
3500 Executes the commands between the \fIwhile\fR and the matching \fIend\fR
3501 while \fIexpr\fR (an expression, as described under \fBExpressions\fR)
3502 evaluates non-zero.
3503 \fIwhile\fR and \fIend\fR must appear alone on their input lines.
3504 \fIbreak\fR and \fIcontinue\fR may be used to terminate or continue the
3505 loop prematurely.
3506 If the input is a terminal, the user is prompted the first time
3507 through the loop as with \fIforeach\fR.
3508 .PD
3509 .SS "Special aliases (+)"
3510 If set, each of these aliases executes automatically at the indicated time.
3511 They are all initially undefined.
3512 .TP 8
3513 .B beepcmd
3514 Runs when the shell wants to ring the terminal bell.
3515 .TP 8
3516 .B cwdcmd
3517 Runs after every change of working directory.  For example, if the user is
3518 working on an X window system using \fIxterm\fR(1) and a re-parenting window
3519 manager that supports title bars such as \fItwm\fR(1) and does
3520 .RS +8
3521 .IP "" 4
3522 > alias cwdcmd  'echo \-n "^[]2;${HOST}:$cwd ^G"'
3523 .PP
3524 then the shell will change the title of the running \fIxterm\fR(1)
3525 to be the name of the host, a colon, and the full current working directory.
3526 A fancier way to do that is
3527 .IP "" 4
3528 > alias cwdcmd 'echo \-n "^[]2;${HOST}:$cwd^G^[]1;${HOST}^G"'
3529 .PP
3530 This will put the hostname and working directory on the title bar but
3531 only the hostname in the icon manager menu.
3532 .PP
3533 Note that putting a \fIcd\fR, \fIpushd\fR or \fIpopd\fR in \fIcwdcmd\fR
3534 may cause an infinite loop.  It is the author's opinion that anyone doing
3535 so will get what they deserve.
3536 .RE
3537 .TP 8
3538 .B jobcmd
3539 Runs before each command gets executed, or when the command changes state.
3540 This is similar to \fIpostcmd\fR, but it does not print builtins.
3541 .RS +8
3542 .IP "" 4
3543 > alias jobcmd  'echo \-n "^[]2\e;\e!#:q^G"'
3544 .PP
3545 then executing \fIvi foo.c\fR will put the command string in the xterm title bar.
3546 .RE
3547 .TP 8
3548 .B helpcommand
3549 Invoked by the \fBrun-help\fR editor command.  The command name for which help
3550 is sought is passed as sole argument.
3551 For example, if one does
3552 .RS +8
3553 .IP "" 4
3554 > alias helpcommand '\e!:1 --help'
3555 .PP
3556 then the help display of the command itself will be invoked, using the GNU
3557 help calling convention.
3558 Currently there is no easy way to account for various calling conventions (e.g.,
3559 the customary Unix `-h'), except by using a table of many commands.
3560 .RE
3561 .TP 8
3562 .B periodic
3563 Runs every \fBtperiod\fR minutes.  This provides a convenient means for
3564 checking on common but infrequent changes such as new mail.  For example,
3565 if one does
3566 .RS +8
3567 .IP "" 4
3568 > set tperiod = 30
3569 .br
3570 > alias periodic checknews
3571 .PP
3572 then the \fIchecknews\fR(1) program runs every 30 minutes.
3573 If \fIperiodic\fR is set but \fBtperiod\fR is unset or set to 0,
3574 \fIperiodic\fR behaves like \fIprecmd\fR.
3575 .RE
3576 .TP 8
3577 .B precmd
3578 Runs just before each prompt is printed.  For example, if one does
3579 .RS +8
3580 .IP "" 4
3581 > alias precmd date
3582 .PP
3583 then \fIdate\fR(1) runs just before the shell prompts for each command.
3584 There are no limits on what \fIprecmd\fR can be set to do, but discretion
3585 should be used.
3586 .RE
3587 .TP 8
3588 .B postcmd
3589 Runs before each command gets executed.
3590 .RS +8
3591 .IP "" 4
3592 > alias postcmd  'echo \-n "^[]2\e;\e!#:q^G"'
3593 .PP
3594 then executing \fIvi foo.c\fR will put the command string in the xterm title bar.
3595 .RE
3596 .TP 8
3597 .B shell
3598 Specifies the interpreter for executable scripts which do not themselves
3599 specify an interpreter.  The first word should be a full path name to the
3600 desired interpreter (e.g., `/bin/csh' or `/usr/local/bin/tcsh').
3601 .SS "Special shell variables"
3602 The variables described in this section have special meaning to the shell.
3603 .PP
3604 The shell sets \fBaddsuffix\fR, \fBargv\fR, \fBautologout\fR, \fBcsubstnonl\fR, \fBcommand\fR, \fBecho_style\fR,
3605 \fBedit\fR, \fBgid\fR, \fBgroup\fR, \fBhome\fR, \fBloginsh\fR, \fBoid\fR, \fBpath\fR,
3606 \fBprompt\fR, \fBprompt2\fR, \fBprompt3\fR, \fBshell\fR, \fBshlvl\fR,
3607 \fBtcsh\fR, \fBterm\fR, \fBtty\fR, \fBuid\fR, \fBuser\fR and \fBversion\fR at
3608 startup; they do not change thereafter unless changed by the user.  The shell
3609 updates \fBcwd\fR, \fBdirstack\fR, \fBowd\fR and \fBstatus\fR when necessary,
3610 and sets \fBlogout\fR on logout.
3611 .PP
3612 The shell synchronizes \fBgroup\fR, \fBhome\fR, \fBpath\fR, \fBshlvl\fR,
3613 \fBterm\fR and \fBuser\fR with the environment variables of the same names:
3614 whenever the environment variable changes the shell changes the corresponding
3615 shell variable to match (unless the shell variable is read-only) and vice
3616 versa.  Note that although \fBcwd\fR and \fBPWD\fR have identical meanings, they
3617 are not synchronized in this manner, and that the shell automatically
3618 interconverts the different formats of \fBpath\fR and \fBPATH\fR.
3619 .TP 8
3620 .B addsuffix \fR(+)
3621 If set, filename completion adds `/' to the end of directories and a space
3622 to the end of normal files when they are matched exactly.
3623 Set by default.
3624 .TP 8
3625 .B afsuser \fR(+)
3626 If set, \fBautologout\fR's autolock feature uses its value instead of
3627 the local username for kerberos authentication.
3628 .TP 8
3629 .B ampm \fR(+)
3630 If set, all times are shown in 12-hour AM/PM format.
3631 .TP 8
3632 .B argv
3633 The arguments to the shell.  Positional parameters are taken from \fBargv\fR,
3634 i.e., `$1' is replaced by `$argv[1]', etc.
3635 Set by default, but usually empty in interactive shells.
3636 .TP 8
3637 .B autocorrect \fR(+)
3638 If set, the \fIspell-word\fR editor command is invoked automatically before
3639 each completion attempt.
3640 .TP 8
3641 .B autoexpand \fR(+)
3642 If set, the \fIexpand-history\fR editor command is invoked automatically
3643 before each completion attempt. If this is set to \fIonlyhistory\fR, then
3644 only history will be expanded and a second completion will expand filenames.
3645 .TP 8
3646 .B autolist \fR(+)
3647 If set, possibilities are listed after an ambiguous completion.
3648 If set to `ambiguous', possibilities are listed only when no new
3649 characters are added by completion.
3650 .TP 8
3651 .B autologout \fR(+)
3652 The first word is the number of minutes of inactivity before automatic
3653 logout.  The optional second word is the number of minutes of inactivity
3654 before automatic locking.
3655 When the shell automatically logs out, it prints `auto-logout', sets the
3656 variable \fBlogout\fR to `automatic' and exits.
3657 When the shell automatically locks, the user is required to enter his password
3658 to continue working.  Five incorrect attempts result in automatic logout.
3659 Set to `60' (automatic logout after 60 minutes, and no locking) by default
3660 in login and superuser shells, but not if the shell thinks it is running
3661 under a window system (i.e., the \fBDISPLAY\fR environment variable is set),
3662 the tty is a pseudo-tty (pty) or the shell was not so compiled (see the
3663 \fBversion\fR shell variable).
3664 See also the \fBafsuser\fR and \fBlogout\fR shell variables.
3665 .TP 8
3666 .B autorehash \fR(+)
3667 If set, the internal hash table of the contents of the directories in the
3668 \fBpath\fR variable will be recomputed if a command is not found in the hash
3669 table.  In addition, the list of available commands will be rebuilt for each
3670 command completion or spelling correction attempt if set to `complete' or
3671 `correct' respectively; if set to `always', this will be done for both
3672 cases.
3673 .TP 8
3674 .B backslash_quote \fR(+)
3675 If set, backslashes (`\\') always quote `\\', `'', and `"'.  This may make
3676 complex quoting tasks easier, but it can cause syntax errors in \fIcsh\fR(1)
3677 scripts.
3678 .TP 8
3679 .B catalog
3680 The file name of the message catalog.
3681 If set, tcsh use `tcsh.${catalog}' as a message catalog instead of
3682 default `tcsh'.
3683 .TP 8
3684 .B cdpath
3685 A list of directories in which \fIcd\fR should search for
3686 subdirectories if they aren't found in the current directory.
3687 .TP 8
3688 .B color
3689 If set, it enables color display for the builtin \fBls\-F\fR and it passes
3690 \fB\-\-color=auto\fR to \fBls\fR.  Alternatively, it can be set to only
3691 \fBls\-F\fR or only \fBls\fR to enable color to only one command.  Setting
3692 it to nothing is equivalent to setting it to \fB(ls\-F ls)\fR.
3693 .TP 8
3694 .B colorcat
3695 If set, it enables color escape sequence for NLS message files.
3696 And display colorful NLS messages.
3697 .TP 8
3698 .B command \fR(+)
3699 If set, the command which was passed to the shell with the \fB-c\fR flag (q.v.).
3700 .TP 8
3701 .B compat_expr \fR(+)
3702 If set, the shell will evaluate expressions right to left, like the original
3703 \fIcsh\fR.
3704 .TP 8
3705 .B complete \fR(+)
3706 If set to `igncase', the completion becomes case insensitive.
3707 If set to `enhance', completion ignores case and considers
3708 hyphens and underscores to be equivalent; it will also treat
3709 periods, hyphens and underscores (`.', `\-' and `_') as word
3710 separators.
3711 If set to `Enhance', completion matches uppercase and underscore
3712 characters explicitly and matches lowercase and hyphens in a
3713 case-insensivite manner; it will treat periods, hypens and underscores
3714 as word separators.
3715 .TP 8
3716 .B continue \fR(+)
3717 If set to a list of commands, the shell will continue the listed
3718 commands, instead of starting a new one.
3719 .TP 8
3720 .B continue_args \fR(+)
3721 Same as continue, but the shell will execute:
3722 .RS +8
3723 .IP "" 4
3724 echo `pwd` $argv > ~/.<cmd>_pause; %<cmd>
3725 .RE
3726 .TP 8
3727 .B correct \fR(+)
3728 If set to `cmd', commands are automatically spelling-corrected.
3729 If set to `complete', commands are automatically completed.
3730 If set to `all', the entire command line is corrected.
3731 .TP 8
3732 .B csubstnonl \fR(+)
3733 If set, newlines and carriage returns in command substitution are
3734 replaced by spaces.  Set by default.
3735 .TP 8
3736 .B cwd
3737 The full pathname of the current directory.
3738 See also the \fBdirstack\fR and \fBowd\fR shell variables.
3739 .TP 8
3740 .B dextract \fR(+)
3741 If set, `pushd +\fIn\fR' extracts the \fIn\fRth directory from the directory
3742 stack rather than rotating it to the top.
3743 .TP 8
3744 .B dirsfile \fR(+)
3745 The default location in which `dirs \-S' and `dirs \-L' look for
3746 a history file.  If unset, \fI~/.cshdirs\fR is used.
3747 Because only \fI~/.tcshrc\fR is normally sourced before \fI~/.cshdirs\fR,
3748 \fBdirsfile\fR should be set in \fI~/.tcshrc\fR rather than \fI~/.login\fR.
3749 .TP 8
3750 .B dirstack \fR(+)
3751 An array of all the directories on the directory stack.
3752 `$dirstack[1]' is the current working directory, `$dirstack[2]'
3753 the first directory on the stack, etc.
3754 Note that the current working directory is `$dirstack[1]' but `=0' in
3755 directory stack substitutions, etc.
3756 One can change the stack arbitrarily by setting \fBdirstack\fR,
3757 but the first element (the current working directory) is always correct.
3758 See also the \fBcwd\fR and \fBowd\fR shell variables.
3759 .TP 8
3760 .B dspmbyte \fR(+)
3761 Has an effect iff 'dspm' is listed as part of the \fBversion\fR shell variable.
3762 If set to `euc', it enables display and editing EUC-kanji(Japanese) code.
3763 If set to `sjis', it enables display and editing Shift-JIS(Japanese) code.
3764 If set to `big5', it enables display and editing Big5(Chinese) code.
3765 If set to `utf8', it enables display and editing Utf8(Unicode) code.
3766 If set to the following format, it enables display and editing of original
3767 multi-byte code format:
3768 .RS +8
3769 .IP "" 4
3770 > set dspmbyte = 0000....(256 bytes)....0000
3771 .PP
3772 The table requires \fBjust\fR 256 bytes.  Each character of 256 characters
3773 corresponds (from left to right) to the ASCII codes 0x00, 0x01, ... 0xff.  Each
3774 character
3775 .\" (position in this table?)
3776 is set to number 0,1,2 and 3.  Each number has the following meaning:
3777 .br
3778   0 ... not used for multi-byte characters.
3779 .br
3780   1 ... used for the first byte of a multi-byte character.
3781 .br
3782   2 ... used for the second byte of a multi-byte character.
3783 .br
3784   3 ... used for both the first byte and second byte of a multi-byte character.
3785 .\" SHK: I tried my best to get the following to be grammatically correct.
3786 .\" However, I still don't understand what's going on here.  In the
3787 .\" following example, there are three bytes, but the text seems to refer to
3788 .\" each nybble as a character.  What's going on here?  It this 3-byte code
3789 .\" in the table?  The text above seems to imply that there are 256
3790 .\" characters/bytes in the table.  If I get some more info on this (perhaps
3791 .\" a complete example), I could fix the text to be grammatically correct.
3792 .\" (steve.kelem@xilinx.com 1999/09/13)
3793 .PP
3794   Example:
3795 .br
3796 If set to `001322', the first character (means 0x00 of the ASCII code) and
3797 second character (means 0x01 of ASCII code) are set to `0'.  Then, it is not
3798 used for multi-byte characters.  The 3rd character (0x02) is set to '1',
3799 indicating that it is used for the first byte of a multi-byte character.
3800 The 4th character(0x03) is set '3'.  It is used for both the first byte and
3801 the second byte of a multi-byte character.  The 5th and 6th characters
3802 (0x04,0x05) are set to '2', indicating that they are used for the second
3803 byte of a multi-byte character.
3804 .PP
3805 The GNU fileutils version of ls cannot display multi-byte
3806 filenames without the -N ( --literal ) option.   If you are using
3807 this version, set the second word of dspmbyte to "ls".  If not, for
3808 example, "ls-F -l" cannot display multi-byte filenames.
3809 .PP
3810   Note:
3811 .br
3812 This variable can only be used if KANJI and DSPMBYTE has been defined at
3813 compile time.
3814 .RE
3815 .TP 8
3816 .B dunique \fR(+)
3817 If set, \fIpushd\fR removes any instances of \fIname\fR
3818 from the stack before pushing it onto the stack.
3819 .TP 8
3820 .B echo
3821 If set, each command with its arguments is echoed just before it is
3822 executed.  For non-builtin commands all expansions occur before
3823 echoing.  Builtin commands are echoed before command and filename
3824 substitution, because these substitutions are then done selectively.
3825 Set by the \fB\-x\fR command line option.
3826 .TP 8
3827 .B echo_style \fR(+)
3828 The style of the \fIecho\fR builtin.  May be set to
3829 .PP
3830 .RS +8
3831 .PD 0
3832 .TP 8
3833 bsd
3834 Don't echo a newline if the first argument is `\-n'.
3835 .TP 8
3836 sysv
3837 Recognize backslashed escape sequences in echo strings.
3838 .TP 8
3839 both
3840 Recognize both the `\-n' flag and backslashed escape sequences; the default.
3841 .TP 8
3842 none
3843 Recognize neither.
3844 .PD
3845 .PP
3846 Set by default to the local system default.  The BSD and System V
3847 options are described in the \fIecho\fR(1) man pages on the appropriate
3848 systems.
3849 .RE
3850 .TP 8
3851 .B edit \fR(+)
3852 If set, the command-line editor is used.  Set by default in interactive
3853 shells.
3854 .TP 8
3855 .B ellipsis \fR(+)
3856 If set, the `%c'/`%.' and `%C' prompt sequences (see the \fBprompt\fR
3857 shell variable) indicate skipped directories with an ellipsis (`...')
3858 instead of `/<skipped>'.
3859 .TP 8
3860 .B euid \fR(+)
3861 The user's effective user ID.
3862 .TP 8
3863 .B euser \fR(+)
3864 The first matching passwd entry name corresponding to the effective user ID.
3865 .TP 8
3866 .B fignore \fR(+)
3867 Lists file name suffixes to be ignored by completion.
3868 .TP 8
3869 .B filec
3870 In \fItcsh\fR, completion is always used and this variable is ignored
3871 by default. If 
3872 .B edit
3873 is unset, then the traditional \fIcsh\fR completion is used.
3874 If set in \fIcsh\fR, filename completion is used.
3875 .TP 8
3876 .B gid \fR(+)
3877 The user's real group ID.
3878 .TP 8
3879 .B globdot \fR(+)
3880 If set, wild-card glob patterns will match files and directories beginning
3881 with `.' except for `.' and `..'
3882 .TP 8
3883 .B globstar \fR(+)
3884 If set, the `**' and `***' file glob patterns will match any string of 
3885 characters including `/' traversing any existing sub-directories.  (e.g. 
3886 `ls **.c' will list all the .c files in the current directory tree).
3887 If used by itself, it will match match zero or more sub-directories
3888 (e.g. `ls /usr/include/**/time.h' will list any file named `time.h'
3889 in the /usr/include directory tree; whereas `ls /usr/include/**time.h'
3890 will match any file in the /usr/include directory tree ending in `time.h').
3891 To prevent problems with recursion, the `**' glob-pattern will not 
3892 descend into a symbolic link containing a directory.  To override this,
3893 use `***'
3894 .TP 8
3895 .B group \fR(+)
3896 The user's group name.
3897 .TP 8
3898 .B highlight
3899 If set, the incremental search match (in \fIi-search-back\fR and
3900 \fIi-search-fwd\fR) and the region between the mark and the cursor are
3901 highlighted in reverse video.
3902 .IP "" 8
3903 Highlighting requires more frequent terminal writes, which introduces extra
3904 overhead. If you care about terminal performance, you may want to leave this
3905 unset.
3906 .TP 8
3907 .B histchars
3908 A string value determining the characters used in \fBHistory
3909 substitution\fR (q.v.).  The first character of its value is used as
3910 the history substitution character, replacing the default character
3911 `!'.  The second character of its value replaces the character `^' in
3912 quick substitutions.
3913 .TP 8
3914 .B histdup \fR(+)
3915 Controls handling of duplicate entries in the history list.  If set to
3916 `all' only unique history events are entered in the history list.  If
3917 set to `prev' and the last history event is the same as the current
3918 command, then the current command is not entered in the history.  If
3919 set to `erase' and the same event is found in the history list, that
3920 old event gets erased and the current one gets inserted.  Note that the
3921 `prev' and `all' options renumber history events so there are no gaps.
3922 .TP 8
3923 .B histfile \fR(+)
3924 The default location in which `history \-S' and `history \-L' look for
3925 a history file.  If unset, \fI~/.history\fR is used.  \fBhistfile\fR is
3926 useful when sharing the same home directory between different machines,
3927 or when saving separate histories on different terminals.  Because only
3928 \fI~/.tcshrc\fR is normally sourced before \fI~/.history\fR,
3929 \fBhistfile\fR should be set in \fI~/.tcshrc\fR rather than
3930 \fI~/.login\fR.
3931 .TP 8
3932 .B histlit \fR(+)
3933 If set, builtin and editor commands and the \fBsavehist\fR mechanism
3934 use the literal (unexpanded) form of lines in the history list.  See
3935 also the \fItoggle-literal-history\fR editor command.
3936 .TP 8
3937 .B history
3938 The first word indicates the number of history events to save.  The
3939 optional second word (+) indicates the format in which history is
3940 printed; if not given, `%h\\t%T\\t%R\\n' is used.  The format sequences
3941 are described below under \fBprompt\fR; note the variable meaning of
3942 `%R'.  Set to `100' by default.
3943 .TP 8
3944 .B home
3945 Initialized to the home directory of the invoker.  The filename
3946 expansion of `\fI~\fR' refers to this variable.
3947 .TP 8
3948 .B ignoreeof
3949 If set to the empty string or `0' and the input device is a terminal,
3950 the \fIend-of-file\fR command (usually generated by the user by typing
3951 `^D' on an empty line) causes the shell to print `Use "exit" to leave
3952 tcsh.' instead of exiting.  This prevents the shell from accidentally
3953 being killed.  Historically this setting exited after 26 successive
3954 EOF's to avoid infinite loops.  If set to a number \fIn\fR, the shell
3955 ignores \fIn - 1\fR consecutive \fIend-of-file\fRs and exits on the
3956 \fIn\fRth.  (+) If unset, `1' is used, i.e., the shell exits on a
3957 single `^D'.
3958 .TP 8
3959 .B implicitcd \fR(+)
3960 If set, the shell treats a directory name typed as a command as though
3961 it were a request to change to that directory.  If set to \fIverbose\fR,
3962 the change of directory is echoed to the standard output.  This behavior
3963 is inhibited in non-interactive shell scripts, or for command strings
3964 with more than one word.  Changing directory takes precedence over
3965 executing a like-named command, but it is done after alias
3966 substitutions.  Tilde and variable expansions work as expected.
3967 .TP 8
3968 .B inputmode \fR(+)
3969 If set to `insert' or `overwrite', puts the editor into that input mode
3970 at the beginning of each line.
3971 .TP 8
3972 .B killdup \fR(+)
3973 Controls handling of duplicate entries in the kill ring.  If set to
3974 `all' only unique strings are entered in the kill ring.  If set to
3975 `prev' and the last killed string is the same as the current killed
3976 string, then the current string is not entered in the ring.  If set
3977 to `erase' and the same string is found in the kill ring, the old
3978 string is erased and the current one is inserted.
3979 .TP 8
3980 .B killring \fR(+)
3981 Indicates the number of killed strings to keep in memory.  Set to `30'
3982 by default.  If unset or set to less than `2', the shell will only
3983 keep the most recently killed string.
3984 Strings are put in the killring by the editor commands that delete
3985 (kill) strings of text, e.g. \fIbackward-delete-word\fR,
3986 \fIkill-line\fR, etc, as well as the \fIcopy-region-as-kill\fR command.
3987 The \fIyank\fR editor command will yank the most recently killed string
3988 into the command-line, while \fIyank-pop\fR (see \fBEditor commands\fR)
3989 can be used to yank earlier killed strings.
3990 .TP 8
3991 .B listflags \fR(+)
3992 If set to `x', `a' or `A', or any combination thereof (e.g., `xA'), they
3993 are used as flags to \fIls\-F\fR, making it act like `ls \-xF', `ls
3994 \-Fa', `ls \-FA' or a combination (e.g., `ls \-FxA'): `a' shows all
3995 files (even if they start with a `.'), `A' shows all files but `.' and
3996 `..', and `x' sorts across instead of down.  If the second word of
3997 \fBlistflags\fR is set, it is used as the path to `ls(1)'.
3998 .TP 8
3999 .B listjobs \fR(+)
4000 If set, all jobs are listed when a job is suspended.  If set to `long',
4001 the listing is in long format.
4002 .TP 8
4003 .B listlinks \fR(+)
4004 If set, the \fIls\-F\fR builtin command shows the type of file to which
4005 each symbolic link points.
4006 .TP 8
4007 .B listmax \fR(+)
4008 The maximum number of items which the \fIlist-choices\fR editor command
4009 will list without asking first.
4010 .TP 8
4011 .B listmaxrows \fR(+)
4012 The maximum number of rows of items which the \fIlist-choices\fR editor
4013 command will list without asking first.
4014 .TP 8
4015 .B loginsh \fR(+)
4016 Set by the shell if it is a login shell.  Setting or unsetting it
4017 within a shell has no effect.  See also \fBshlvl\fR.
4018 .TP 8
4019 .B logout \fR(+)
4020 Set by the shell to `normal' before a normal logout, `automatic' before
4021 an automatic logout, and `hangup' if the shell was killed by a hangup
4022 signal (see \fBSignal handling\fR).  See also the \fBautologout\fR
4023 shell variable.
4024 .TP 8
4025 .B mail
4026 A list of files and directories to check for incoming mail, optionally
4027 preceded by a numeric word.  Before each prompt, if 10 minutes have
4028 passed since the last check, the shell checks each file and says `You
4029 have new mail.' (or, if \fBmail\fR contains multiple files, `You have
4030 new mail in \fIname\fR.') if the filesize is greater than zero in size
4031 and has a modification time greater than its access time.
4032 .PP
4033 .RS +8
4034 .PD
4035 .PP
4036 If you are in a login shell, then no mail file is reported unless it has
4037 been modified after the time the shell has started up, to prevent
4038 redundant notifications.  Most login programs will tell you whether or not
4039 you have mail when you log in.
4040 .PP
4041 If a file specified in \fBmail\fR is a directory, the shell will count each
4042 file within that directory as a separate message, and will report `You have
4043 \fIn\fR mails.' or `You have \fIn\fR mails in \fIname\fR.' as appropriate.
4044 This functionality is provided primarily for those systems which store mail
4045 in this manner, such as the Andrew Mail System.
4046 .PP
4047 If the first word of \fBmail\fR is numeric it is taken as a different mail
4048 checking interval, in seconds.
4049 .PP
4050 Under very rare circumstances, the shell may report `You have mail.' instead
4051 of `You have new mail.'
4052 .RE
4053 .TP 8
4054 .B matchbeep \fR(+)
4055 If set to `never', completion never beeps.
4056 If set to `nomatch', it beeps only when there is no match.
4057 If set to `ambiguous', it beeps when there are multiple matches.
4058 If set to `notunique', it beeps when there is one exact and other longer matches.
4059 If unset, `ambiguous' is used.
4060 .TP 8
4061 .B nobeep \fR(+)
4062 If set, beeping is completely disabled.
4063 See also \fBvisiblebell\fR.
4064 .TP 8
4065 .B noclobber
4066 If set, restrictions are placed on output redirection to insure that files
4067 are not accidentally destroyed and that `>>' redirections refer to existing
4068 files, as described in the \fBInput/output\fR section.
4069 .TP 8
4070 .B noding
4071 If set, disable the printing of `DING!' in the \fBprompt\fR time
4072 specifiers at the change of hour.
4073 .TP 8
4074 .B noglob
4075 If set, \fBFilename substitution\fR and \fBDirectory stack substitution\fR
4076 (q.v.) are inhibited.  This is most useful in shell scripts which do not deal
4077 with filenames, or after a list of filenames has been obtained and further
4078 expansions are not desirable.
4079 .TP 8
4080 .B nokanji \fR(+)
4081 If set and the shell supports Kanji (see the \fBversion\fR shell variable),
4082 it is disabled so that the meta key can be used.
4083 .TP 8
4084 .B nonomatch
4085 If set, a \fBFilename substitution\fR or \fBDirectory stack substitution\fR
4086 (q.v.) which does not match any
4087 existing files is left untouched rather than causing an error.
4088 It is still an error for the substitution to be
4089 malformed, e.g., `echo [' still gives an error.
4090 .TP 8
4091 .B nostat \fR(+)
4092 A list of directories (or glob-patterns which match directories; see
4093 \fBFilename substitution\fR) that should not be \fIstat\fR(2)ed during a
4094 completion operation.  This is usually used to exclude directories which
4095 take too much time to \fIstat\fR(2), for example \fI/afs\fR.
4096 .TP 8
4097 .B notify
4098 If set, the shell announces job completions asynchronously.
4099 The default is to present job completions just before printing a prompt.
4100 .TP 8
4101 .B oid \fR(+)
4102 The user's real organization ID.  (Domain/OS only)
4103 .TP 8
4104 .B owd \fR(+)
4105 The old working directory, equivalent to the `\-' used by \fIcd\fR and \fIpushd\fR.
4106 See also the \fBcwd\fR and \fBdirstack\fR shell variables.
4107 .TP 8
4108 .B padhour
4109 If set, enable the printing of padding '0' for hours, in 24 and 12 hour
4110 formats.  E.G.: 07:45:42 vs. 7:45:42.
4111 .TP 8
4112 .B parseoctal
4113 To retain compatibily with older versions numeric variables starting with
4114 0 are not interpreted as octal. Setting this variable enables proper octal
4115 parsing.
4116 .TP 8
4117 .B path
4118 A list of directories in which to look for executable commands.
4119 A null word specifies the current directory.
4120 If there is no \fBpath\fR variable then only full path names will execute.
4121 \fBpath\fR is set by the shell at startup from the \fBPATH\fR environment
4122 variable or, if \fBPATH\fR does not exist, to a system-dependent default
4123 something like `(/usr/local/bin /usr/bsd /bin /usr/bin .)'.
4124 The shell may put `.' first or last in \fBpath\fR or omit it entirely
4125 depending on how it was compiled; see the \fBversion\fR shell variable.
4126 A shell which is given neither the \fB\-c\fR nor the \fB\-t\fR option
4127 hashes the contents of the directories in \fBpath\fR after
4128 reading \fI~/.tcshrc\fR and each time \fBpath\fR is reset.
4129 If one adds a new command to a directory in \fBpath\fR while the shell
4130 is active, one may need to do a \fIrehash\fR for the shell to find it.
4131 .TP 8
4132 .B printexitvalue \fR(+)
4133 If set and an interactive program exits with a non-zero status, the shell
4134 prints `Exit \fBstatus\fR'.
4135 .TP 8
4136 .B prompt
4137 The string which is printed before reading each command from the terminal.
4138 \fBprompt\fR may include any of the following formatting sequences (+), which
4139 are replaced by the given information:
4140 .PP
4141 .RS +8
4142 .PD 0
4143 .TP 4
4144 %/
4145 The current working directory.
4146 .TP 4
4147 %~
4148 The current working directory, but with one's home directory
4149 represented by `~' and other users' home directories represented by
4150 `~user' as per \fBFilename substitution\fR.  `~user' substitution
4151 happens only if the shell has already used `~\fIuser\fR' in a pathname
4152 in the current session.
4153 .TP 4
4154 %c[[0]\fIn\fR], %.[[0]\fIn\fR]
4155 The trailing component of the current working directory, or \fIn\fR
4156 trailing components if a digit \fIn\fR is given.
4157 If \fIn\fR begins with `0', the number of skipped components precede
4158 the trailing component(s) in the format `/<\fIskipped\fR>trailing'.
4159 If the \fBellipsis\fR shell variable is set, skipped components
4160 are represented by an ellipsis so the whole becomes `...trailing'.
4161 `~' substitution is done as in `%~' above, but the `~' component
4162 is ignored when counting trailing components.
4163 .TP 4
4164 %C
4165 Like %c, but without `~' substitution.
4166 .TP 4
4167 %h, %!, !
4168 The current history event number.
4169 .TP 4
4170 %M
4171 The full hostname.
4172 .TP 4
4173 %m
4174 The hostname up to the first `.'.
4175 .TP 4
4176 %S (%s)
4177 Start (stop) standout mode.
4178 .TP 4
4179 %B (%b)
4180 Start (stop) boldfacing mode.
4181 .TP 4
4182 %U (%u)
4183 Start (stop) underline mode.
4184 .TP 4
4185 %t, %@
4186 The time of day in 12-hour AM/PM format.
4187 .TP 4
4188 %T
4189 Like `%t', but in 24-hour format (but see the \fBampm\fR shell variable).
4190 .TP 4
4191 %p
4192 The `precise' time of day in 12-hour AM/PM format, with seconds.
4193 .TP 4
4194 %P
4195 Like `%p', but in 24-hour format (but see the \fBampm\fR shell variable).
4196 .TP 4
4197 \e\fIc\fR
4198 \fIc\fR is parsed as in \fIbindkey\fR.
4199 .TP 4
4200 ^\fIc\fR
4201 \fIc\fR is parsed as in \fIbindkey\fR.
4202 .TP 4
4203 %%
4204 A single `%'.
4205 .TP 4
4206 %n
4207 The user name.
4208 .TP 4
4209 %N
4210 The effective user name.
4211 .TP 4
4212 %j
4213 The number of jobs.
4214 .TP 4
4215 %d
4216 The weekday in `Day' format.
4217 .TP 4
4218 %D
4219 The day in `dd' format.
4220 .TP 4
4221 %w
4222 The month in `Mon' format.
4223 .TP 4
4224 %W
4225 The month in `mm' format.
4226 .TP 4
4227 %y
4228 The year in `yy' format.
4229 .TP 4
4230 %Y
4231 The year in `yyyy' format.
4232 .TP 4
4233 %l
4234 The shell's tty.
4235 .TP 4
4236 %L
4237 Clears from the end of the prompt to end of the display or the end of the line.
4238 .TP 4
4239 %$
4240 Expands the shell or environment variable name immediately after the `$'.
4241 .TP 4
4242 %#
4243 `>' (or the first character of the \fBpromptchars\fR shell variable)
4244 for normal users, `#' (or the second character of \fBpromptchars\fR)
4245 for the superuser.
4246 .TP 4
4247 %{\fIstring\fR%}
4248 Includes \fIstring\fR as a literal escape sequence.
4249 It should be used only to change terminal attributes and
4250 should not move the cursor location.  This
4251 cannot be the last sequence in \fBprompt\fR.
4252 .TP 4
4253 %?
4254 The return code of the command executed just before the prompt.
4255 .TP 4
4256 %R
4257 In \fBprompt2\fR, the status of the parser.
4258 In \fBprompt3\fR, the corrected string.
4259 In \fBhistory\fR, the history string.
4260 .PD
4261 .PP
4262 `%B', `%S', `%U' and `%{\fIstring\fR%}' are available in only
4263 eight-bit-clean shells; see the \fBversion\fR shell variable.
4264 .PP
4265 The bold, standout and underline sequences are often used to distinguish a
4266 superuser shell.  For example,
4267 .IP "" 4
4268 > set prompt = "%m [%h] %B[%@]%b [%/] you rang? "
4269 .br
4270 tut [37] \fB[2:54pm]\fR [/usr/accts/sys] you rang? _
4271 .PP
4272 If `%t', `%@', `%T', `%p', or `%P' is used, and \fBnoding\fR is not set,
4273 then print `DING!' on the change of hour (i.e, `:00' minutes) instead of
4274 the actual time.
4275 .PP
4276 Set by default to `%# ' in interactive shells.
4277 .RE
4278 .TP 8
4279 .B prompt2 \fR(+)
4280 The string with which to prompt in \fIwhile\fR and \fIforeach\fR loops and
4281 after lines ending in `\\'.
4282 The same format sequences may be used as in \fBprompt\fR (q.v.);
4283 note the variable meaning of `%R'.
4284 Set by default to `%R? ' in interactive shells.
4285 .TP 8
4286 .B prompt3 \fR(+)
4287 The string with which to prompt when confirming automatic spelling correction.
4288 The same format sequences may be used as in \fBprompt\fR (q.v.);
4289 note the variable meaning of `%R'.
4290 Set by default to `CORRECT>%R (y|n|e|a)? ' in interactive shells.
4291 .TP 8
4292 .B promptchars \fR(+)
4293 If set (to a two-character string), the `%#' formatting sequence in the
4294 \fBprompt\fR shell variable is replaced with the first character for
4295 normal users and the second character for the superuser.
4296 .TP 8
4297 .B pushdtohome \fR(+)
4298 If set, \fIpushd\fR without arguments does `pushd ~', like \fIcd\fR.
4299 .TP 8
4300 .B pushdsilent \fR(+)
4301 If set, \fIpushd\fR and \fIpopd\fR do not print the directory stack.
4302 .TP 8
4303 .B recexact \fR(+)
4304 If set, completion completes on an exact match even if a longer match is
4305 possible.
4306 .TP 8
4307 .B recognize_only_executables \fR(+)
4308 If set, command listing displays only files in the path that are
4309 executable.  Slow.
4310 .TP 8
4311 .B rmstar \fR(+)
4312 If set, the user is prompted before `rm *' is executed.
4313 .TP 8
4314 .B rprompt \fR(+)
4315 The string to print on the right-hand side of the screen (after
4316 the command input) when the prompt is being displayed on the left.
4317 It recognizes the same formatting characters as \fBprompt\fR.
4318 It will automatically disappear and reappear as necessary, to ensure that
4319 command input isn't obscured, and will appear only if the prompt,
4320 command input, and itself will fit together on the first line.
4321 If \fBedit\fR isn't set, then \fBrprompt\fR will be printed after
4322 the prompt and before the command input.
4323 .TP 8
4324 .B savedirs \fR(+)
4325 If set, the shell does `dirs \-S' before exiting.
4326 If the first word is set to a number, at most that many directory stack
4327 entries are saved.
4328 .TP 8
4329 .B savehist
4330 If set, the shell does `history \-S' before exiting.
4331 If the first word is set to a number, at most that many lines are saved.
4332 (The number must be less than or equal to \fBhistory\fR.)
4333 If the second word is set to `merge', the history list is merged with
4334 the existing history file instead of replacing it (if there is one) and
4335 sorted by time stamp and the most recent events are retained.  (+)
4336 .TP 8
4337 .B sched \fR(+)
4338 The format in which the \fIsched\fR builtin command prints scheduled events;
4339 if not given, `%h\\t%T\\t%R\\n' is used.
4340 The format sequences are described above under \fBprompt\fR;
4341 note the variable meaning of `%R'.
4342 .TP 8
4343 .B shell
4344 The file in which the shell resides.  This is used in forking
4345 shells to interpret files which have execute bits set, but
4346 which are not executable by the system.  (See the description
4347 of \fBBuiltin and non-builtin command execution\fR.)  Initialized to the
4348 (system-dependent) home of the shell.
4349 .TP 8
4350 .B shlvl \fR(+)
4351 The number of nested shells.
4352 Reset to 1 in login shells.
4353 See also \fBloginsh\fR.
4354 .TP 8
4355 .B status
4356 The status returned by the last command, unless the variable
4357 .B anyerror
4358 is set, and any error in a pipeline or a backquote expansion will be
4359 propagated (this is the default
4360 .B csh
4361 behavior, and the current
4362 .B tcsh
4363 default). If it terminated
4364 abnormally, then 0200 is added to the status.  Builtin commands
4365 which fail return exit status `1', all other builtin commands
4366 return status `0'.
4367 .TP 8
4368 .B symlinks \fR(+)
4369 Can be set to several different values to control symbolic link (`symlink')
4370 resolution:
4371 .RS +8
4372 .PP
4373 If set to `chase', whenever the current directory changes to a directory
4374 containing a symbolic link, it is expanded to the real name of the directory
4375 to which the link points.  This does not work for the user's home directory;
4376 this is a bug.
4377 .PP
4378 If set to `ignore', the shell tries to construct a current directory
4379 relative to the current directory before the link was crossed.
4380 This means that \fIcd\fRing through a symbolic link and then `cd ..'ing
4381 returns one to the original directory.  This affects only builtin commands
4382 and filename completion.
4383 .PP
4384 If set to `expand', the shell tries to fix symbolic links by actually expanding
4385 arguments which look like path names.  This affects any command, not just
4386 builtins.  Unfortunately, this does not work for hard-to-recognize filenames,
4387 such as those embedded in command options.  Expansion may be prevented by
4388 quoting.  While this setting is usually the most convenient, it is sometimes
4389 misleading and sometimes confusing when it fails to recognize an argument
4390 which should be expanded.  A compromise is to use `ignore' and use the
4391 editor command \fInormalize-path\fR (bound by default to ^X-n) when necessary.
4392 .PP
4393 Some examples are in order.  First, let's set up some play directories:
4394 .IP "" 4
4395 > cd /tmp
4396 .br
4397 > mkdir from from/src to
4398 .br
4399 > ln \-s from/src to/dst
4400 .PP
4401 Here's the behavior with \fBsymlinks\fR unset,
4402 .IP "" 4
4403 > cd /tmp/to/dst; echo $cwd
4404 .br
4405 /tmp/to/dst
4406 .br
4407 > cd ..; echo $cwd
4408 .br
4409 /tmp/from
4410 .PP
4411 here's the behavior with \fBsymlinks\fR set to `chase',
4412 .IP "" 4
4413 > cd /tmp/to/dst; echo $cwd
4414 .br
4415 /tmp/from/src
4416 .br
4417 > cd ..; echo $cwd
4418 .br
4419 /tmp/from
4420 .PP
4421 here's the behavior with \fBsymlinks\fR set to `ignore',
4422 .IP "" 4
4423 > cd /tmp/to/dst; echo $cwd
4424 .br
4425 /tmp/to/dst
4426 .br
4427 > cd ..; echo $cwd
4428 .br
4429 /tmp/to
4430 .PP
4431 and here's the behavior with \fBsymlinks\fR set to `expand'.
4432 .IP "" 4
4433 > cd /tmp/to/dst; echo $cwd
4434 .br
4435 /tmp/to/dst
4436 .br
4437 > cd ..; echo $cwd
4438 .br
4439 /tmp/to
4440 .br
4441 > cd /tmp/to/dst; echo $cwd
4442 .br
4443 /tmp/to/dst
4444 .br
4445 > cd ".."; echo $cwd
4446 .br
4447 /tmp/from
4448 .br
4449 > /bin/echo ..
4450 .br
4451 /tmp/to
4452 .br
4453 > /bin/echo ".."
4454 .br
4455 \&..
4456 .PP
4457 Note that `expand' expansion 1) works just like `ignore' for builtins
4458 like \fIcd\fR, 2) is prevented by quoting, and 3) happens before
4459 filenames are passed to non-builtin commands.
4460 .RE
4461 .TP 8
4462 .B tcsh \fR(+)
4463 The version number of the shell in the format `R.VV.PP',
4464 where `R' is the major release number, `VV' the current version
4465 and `PP' the patchlevel.
4466 .TP 8
4467 .B term
4468 The terminal type.  Usually set in \fI~/.login\fR as described under
4469 \fBStartup and shutdown\fR.
4470 .TP 8
4471 .B time
4472 If set to a number, then the \fItime\fR builtin (q.v.) executes automatically
4473 after each command which takes more than that many CPU seconds.
4474 If there is a second word, it is used as a format string for the output
4475 of the \fItime\fR builtin.  (u) The following sequences may be used in the
4476 format string:
4477 .PP
4478 .RS +8
4479 .PD 0
4480 .TP 4
4481 %U
4482 The time the process spent in user mode in cpu seconds.
4483 .TP 4
4484 %S
4485 The time the process spent in kernel mode in cpu seconds.
4486 .TP 4
4487 %E
4488 The elapsed (wall clock) time in seconds.
4489 .TP 4
4490 %P
4491 The CPU percentage computed as (%U + %S) / %E.
4492 .TP 4
4493 %W
4494 Number of times the process was swapped.
4495 .TP 4
4496 %X
4497 The average amount in (shared) text space used in Kbytes.
4498 .TP 4
4499 %D
4500 The average amount in (unshared) data/stack space used in Kbytes.
4501 .TP 4
4502 %K
4503 The total space used (%X + %D) in Kbytes.
4504 .TP 4
4505 %M
4506 The maximum memory the process had in use at any time in Kbytes.
4507 .TP 4
4508 %F
4509 The number of major page faults (page needed to be brought from disk).
4510 .TP 4
4511 %R
4512 The number of minor page faults.
4513 .TP 4
4514 %I
4515 The number of input operations.
4516 .TP 4
4517 %O
4518 The number of output operations.
4519 .TP 4
4520 %r
4521 The number of socket messages received.
4522 .TP 4
4523 %s
4524 The number of socket messages sent.
4525 .TP 4
4526 %k
4527 The number of signals received.
4528 .TP 4
4529 %w
4530 The number of voluntary context switches (waits).
4531 .TP 4
4532 %c
4533 The number of involuntary context switches.
4534 .PD
4535 .PP
4536 Only the first four sequences are supported on systems without BSD resource
4537 limit functions.
4538 The default time format is `%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww' for
4539 systems that support resource usage reporting and `%Uu %Ss %E %P' for
4540 systems that do not.
4541 .PP
4542 Under Sequent's DYNIX/ptx, %X, %D, %K, %r and %s are not
4543 available, but the following additional sequences are:
4544 .PP
4545 .PD 0
4546 .TP 4
4547 %Y
4548 The number of system calls performed.
4549 .TP 4
4550 %Z
4551 The number of pages which are zero-filled on demand.
4552 .TP 4
4553 %i
4554 The number of times a process's resident set size was increased by the kernel.
4555 .TP 4
4556 %d
4557 The number of times a process's resident set size was decreased by the kernel.
4558 .TP 4
4559 %l
4560 The number of read system calls performed.
4561 .TP 4
4562 %m
4563 The number of write system calls performed.
4564 .TP 4
4565 %p
4566 The number of reads from raw disk devices.
4567 .TP 4
4568 %q
4569 The number of writes to raw disk devices.
4570 .PD
4571 .PP
4572 and the default time format is `%Uu %Ss %E %P %I+%Oio %Fpf+%Ww'.
4573 Note that the CPU percentage can be higher than 100% on multi-processors.
4574 .RE
4575 .TP 8
4576 .B tperiod \fR(+)
4577 The period, in minutes, between executions of the \fIperiodic\fR special alias.
4578 .TP 8
4579 .B tty \fR(+)
4580 The name of the tty, or empty if not attached to one.
4581 .TP 8
4582 .B uid \fR(+)
4583 The user's real user ID.
4584 .TP 8
4585 .B user
4586 The user's login name.
4587 .TP 8
4588 .B verbose
4589 If set, causes the words of each
4590 command to be printed, after history substitution (if any).
4591 Set by the \fB\-v\fR command line option.
4592 .TP 8
4593 .B version \fR(+)
4594 The version ID stamp.  It contains the shell's version number (see \fBtcsh\fR),
4595 origin, release date, vendor, operating system and machine (see \fBVENDOR\fR,
4596 \fBOSTYPE\fR and \fBMACHTYPE\fR) and a comma-separated
4597 list of options which were set at compile time.
4598 Options which are set by default in the distribution are noted.
4599 .PP
4600 .RS +8
4601 .PD 0
4602 .TP 6
4603 8b
4604 The shell is eight bit clean; default
4605 .TP 6
4606 7b
4607 The shell is not eight bit clean
4608 .TP 6
4609 wide
4610 The shell is multibyte encoding clean (like UTF-8)
4611 .TP 6
4612 nls
4613 The system's NLS is used; default for systems with NLS
4614 .TP 6
4615 lf
4616 Login shells execute \fI/etc/csh.login\fR before instead of after
4617 \fI/etc/csh.cshrc\fR and \fI~/.login\fR before instead of after
4618 \fI~/.tcshrc\fR and \fI~/.history\fR.
4619 .TP 6
4620 dl
4621 `.' is put last in \fBpath\fR for security; default
4622 .TP 6
4623 nd
4624 `.' is omitted from \fBpath\fR for security
4625 .TP 6
4626 vi
4627 \fIvi\fR-style editing is the default rather than \fIemacs\fR
4628 .TP 6
4629 dtr
4630 Login shells drop DTR when exiting
4631 .TP 6
4632 bye
4633 \fIbye\fR is a synonym for \fIlogout\fR and \fIlog\fR
4634 is an alternate name for \fIwatchlog\fR
4635 .TP 6
4636 al
4637 \fBautologout\fR is enabled; default
4638 .TP 6
4639 kan
4640 Kanji is used if appropriate according to locale settings,
4641 unless the \fBnokanji\fR shell variable is set
4642 .TP 6
4643 sm
4644 The system's \fImalloc\fR(3) is used
4645 .TP 6
4646 hb
4647 The `#!<program> <args>' convention is emulated when executing shell scripts
4648 .TP 6
4649 ng
4650 The \fInewgrp\fR builtin is available
4651 .TP 6
4652 rh
4653 The shell attempts to set the \fBREMOTEHOST\fR environment variable
4654 .TP 6
4655 afs
4656 The shell verifies your password with the kerberos server if local
4657 authentication fails.  The \fBafsuser\fR shell variable or the
4658 \fBAFSUSER\fR environment variable override your local username if set.
4659 .PD
4660 .PP
4661 An administrator may enter additional strings to indicate differences
4662 in the local version.
4663 .RE
4664 .TP 8
4665 .B visiblebell \fR(+)
4666 If set, a screen flash is used rather than the audible bell.
4667 See also \fBnobeep\fR.
4668 .TP 8
4669 .B watch \fR(+)
4670 A list of user/terminal pairs to watch for logins and logouts.
4671 If either the user is `any' all terminals are watched for the given user
4672 and vice versa.
4673 Setting \fBwatch\fR to `(any any)' watches all users and terminals.
4674 For example,
4675 .RS +8
4676 .IP "" 4
4677 set watch = (george ttyd1 any console $user any)
4678 .PP
4679 reports activity of the user `george' on ttyd1, any user on the console, and
4680 oneself (or a trespasser) on any terminal.
4681 .PP
4682 Logins and logouts are checked every 10 minutes by default, but the first
4683 word of \fBwatch\fR can be set to a number to check every so many minutes.
4684 For example,
4685 .IP "" 4
4686 set watch = (1 any any)
4687 .PP
4688 reports any login/logout once every minute.  For the impatient, the \fIlog\fR
4689 builtin command triggers a \fBwatch\fR report at any time.  All current logins
4690 are reported (as with the \fIlog\fR builtin) when \fBwatch\fR is first set.
4691 .PP
4692 The \fBwho\fR shell variable controls the format of \fBwatch\fR reports.
4693 .RE
4694 .TP 8
4695 .B who \fR(+)
4696 The format string for \fBwatch\fR messages.  The following sequences
4697 are replaced by the given information:
4698 .PP
4699 .RS +8
4700 .PD 0
4701 .TP 4
4702 %n
4703 The name of the user who logged in/out.
4704 .TP 4
4705 %a
4706 The observed action, i.e., `logged on', `logged off' or `replaced \fIolduser\fR on'.
4707 .TP 4
4708 %l
4709 The terminal (tty) on which the user logged in/out.
4710 .TP 4
4711 %M
4712 The full hostname of the remote host, or `local' if the login/logout was
4713 from the local host.
4714 .TP 4
4715 %m
4716 The hostname of the remote host up to the first `.'.
4717 The full name is printed if it is an IP address or an X Window System display.
4718 .PD
4719 .PP
4720 %M and %m are available on only systems that store the remote hostname in
4721 \fI/etc/utmp\fR.
4722 If unset, `%n has %a %l from %m.' is used, or `%n has %a %l.' on systems
4723 which don't store the remote hostname.
4724 .RE
4725 .TP 8
4726 .B wordchars \fR(+)
4727 A list of non-alphanumeric characters to be considered part of a word by the
4728 \fIforward-word\fR, \fIbackward-word\fR etc., editor commands.
4729 If unset, `*?_\-.[]~=' is used.
4730 .SH ENVIRONMENT
4731 .TP 8
4732 .B AFSUSER \fR(+)
4733 Equivalent to the \fBafsuser\fR shell variable.
4734 .TP 8
4735 .B COLUMNS
4736 The number of columns in the terminal.  See \fBTerminal management\fR.
4737 .TP 8
4738 .B DISPLAY
4739 Used by X Window System (see \fIX\fR(1)).
4740 If set, the shell does not set \fBautologout\fR (q.v.).
4741 .TP 8
4742 .B EDITOR
4743 The pathname to a default editor.
4744 See also the \fBVISUAL\fR environment variable
4745 and the \fIrun-fg-editor\fR editor command.
4746 .TP 8
4747 .B GROUP \fR(+)
4748 Equivalent to the \fBgroup\fR shell variable.
4749 .TP 8
4750 .B HOME
4751 Equivalent to the \fBhome\fR shell variable.
4752 .TP 8
4753 .B HOST \fR(+)
4754 Initialized to the name of the machine on which the shell
4755 is running, as determined by the \fIgethostname\fR(2) system call.
4756 .TP 8
4757 .B HOSTTYPE \fR(+)
4758 Initialized to the type of machine on which the shell
4759 is running, as determined at compile time.  This variable is obsolete and
4760 will be removed in a future version.
4761 .TP 8
4762 .B HPATH \fR(+)
4763 A colon-separated list of directories in which the \fIrun-help\fR editor
4764 command looks for command documentation.
4765 .TP 8
4766 .B LANG
4767 Gives the preferred character environment.
4768 See \fBNative Language System support\fR.
4769 .TP 8
4770 .B LC_CTYPE
4771 If set, only ctype character handling is changed.
4772 See \fBNative Language System support\fR.
4773 .TP 8
4774 .B LINES
4775 The number of lines in the terminal.  See \fBTerminal management\fR.
4776 .TP 8
4777 .B LS_COLORS
4778 The format of this variable is reminiscent of the \fBtermcap(5)\fR
4779 file format; a colon-separated list of expressions of the form
4780 "\fIxx=string\fR", where "\fIxx\fR" is a two-character variable name.  The
4781 variables with their associated defaults are:
4782 .PP
4783 .RS +8
4784 .RS +4
4785 .PD 0
4786 .TP 12
4787 no      0
4788 Normal (non-filename) text
4789 .TP 12
4790 fi      0
4791 Regular file
4792 .TP 12
4793 di      01;34
4794 Directory
4795 .TP 12
4796 ln      01;36
4797 Symbolic link
4798 .TP 12
4799 pi      33
4800 Named pipe (FIFO)
4801 .TP 12
4802 so      01;35
4803 Socket
4804 .TP 12
4805 do      01;35
4806 Door
4807 .TP 12
4808 bd      01;33
4809 Block device
4810 .TP 12
4811 cd      01;32
4812 Character device
4813 .TP 12
4814 ex      01;32
4815 Executable file
4816 .TP 12
4817 mi      (none)
4818 Missing file (defaults to fi)
4819 .TP 12
4820 or      (none)
4821 Orphaned symbolic link (defaults to ln)
4822 .TP 12
4823 lc      ^[[
4824 Left code
4825 .TP 12
4826 rc      m
4827 Right code
4828 .TP 12
4829 ec      (none)
4830 End code (replaces lc+no+rc)
4831 .PD
4832 .RE
4833 .PP
4834 You need to include only the variables you want to change from
4835 the default.
4836 .PP
4837 File names can also be colorized based on filename extension.
4838 This is specified in the \fBLS_COLORS\fR variable using the syntax
4839 \fB"*ext=string"\fR.  For example, using ISO 6429 codes, to color
4840 all C\-language source files blue you would specify \fB"*.c=34"\fR.
4841 This would color all files ending in \fB.c\fR in blue (34) color.
4842 .PP
4843 Control characters can be written either in C\-style\-escaped
4844 notation, or in stty\-like ^\-notation.  The C\-style notation
4845 adds \fB^[\fR for Escape, \fB\_\fR for a normal space character,
4846 and \fB?\fR for Delete.  In addition, the \fB^[\fR escape character
4847 can be used to override the default interpretation of \fB^[\fR,
4848 \fB^\fR, \fB:\fR and \fB=\fR.
4849 .PP
4850 Each file will be written as \fB<lc>\fR \fB<color-code>\fR
4851 \fB<rc>\fR \fB<filename>\fR \fB<ec>\fR.  If the \fB<ec>\fR
4852 code is undefined, the sequence \fB<lc>\fR \fB<no>
4853 \fB<rc>\fR will be used instead.  This is generally more convenient
4854 to use, but less general.  The left, right and end codes are
4855 provided so you don't have to type common parts over and over
4856 again and to support weird terminals; you will generally not
4857 need to change them at all unless your terminal does not use
4858 ISO 6429 color sequences but a different system.
4859 .PP
4860 If your terminal does use ISO 6429 color codes, you can
4861 compose the type codes (i.e., all except the \fBlc\fR, \fBrc\fR,
4862 and \fBec\fR codes) from numerical commands separated by semicolons.  The
4863 most common commands are:
4864 .PP
4865 .RS +8
4866 .PD 0
4867 .TP 4
4868 0
4869 to restore default color
4870 .TP 4
4871 1
4872 for brighter colors
4873 .TP 4
4874 4
4875 for underlined text
4876 .TP 4
4877 5
4878 for flashing text
4879 .TP 4
4880 30
4881 for black foreground
4882 .TP 4
4883 31
4884 for red foreground
4885 .TP 4
4886 32
4887 for green foreground
4888 .TP 4
4889 33
4890 for yellow (or brown) foreground
4891 .TP 4
4892 34
4893 for blue foreground
4894 .TP 4
4895 35
4896 for purple foreground
4897 .TP 4
4898 36
4899 for cyan foreground
4900 .TP 4
4901 37
4902 for white (or gray) foreground
4903 .TP 4
4904 40
4905 for black background
4906 .TP 4
4907 41
4908 for red background
4909 .TP 4
4910 42
4911 for green background
4912 .TP 4
4913 43
4914 for yellow (or brown) background
4915 .TP 4
4916 44
4917 for blue background
4918 .TP 4
4919 45
4920 for purple background
4921 .TP 4
4922 46
4923 for cyan background
4924 .TP 4
4925 47
4926 for white (or gray) background
4927 .PD
4928 .RE
4929 .PP
4930 Not all commands will work on all systems or display devices.
4931 .PP
4932 A few terminal programs do not recognize the default end code
4933 properly.  If all text gets colorized after you do a directory
4934 listing, try changing the \fBno\fR and \fBfi\fR codes from 0 to the
4935 numerical codes for your standard fore- and background colors.
4936 .RE
4937 .TP 8
4938 .B MACHTYPE \fR(+)
4939 The machine type (microprocessor class or machine model), as determined at compile time.
4940 .TP 8
4941 .B NOREBIND \fR(+)
4942 If set, printable characters are not rebound to \fIself-insert-command\fR.
4943 See \fBNative Language System support\fR.
4944 .TP 8
4945 .B OSTYPE \fR(+)
4946 The operating system, as determined at compile time.
4947 .TP 8
4948 .B PATH
4949 A colon-separated list of directories in which to look for executables.
4950 Equivalent to the \fBpath\fR shell variable, but in a different format.
4951 .TP 8
4952 .B PWD \fR(+)
4953 Equivalent to the \fBcwd\fR shell variable, but not synchronized to it;
4954 updated only after an actual directory change.
4955 .TP 8
4956 .B REMOTEHOST \fR(+)
4957 The host from which the user has logged in remotely, if this is the case and
4958 the shell is able to determine it.  Set only if the shell was so compiled;
4959 see the \fBversion\fR shell variable.
4960 .TP 8
4961 .B SHLVL \fR(+)
4962 Equivalent to the \fBshlvl\fR shell variable.
4963 .TP 8
4964 .B SYSTYPE \fR(+)
4965 The current system type.  (Domain/OS only)
4966 .TP 8
4967 .B TERM
4968 Equivalent to the \fBterm\fR shell variable.
4969 .TP 8
4970 .B TERMCAP
4971 The terminal capability string.  See \fBTerminal management\fR.
4972 .TP 8
4973 .B USER
4974 Equivalent to the \fBuser\fR shell variable.
4975 .TP 8
4976 .B VENDOR \fR(+)
4977 The vendor, as determined at compile time.
4978 .TP 8
4979 .B VISUAL
4980 The pathname to a default full-screen editor.
4981 See also the \fBEDITOR\fR environment variable
4982 and the \fIrun-fg-editor\fR editor command.
4983 .SH FILES
4984 .PD 0
4985 .TP 16
4986 .I /etc/csh.cshrc
4987 Read first by every shell.
4988 ConvexOS, Stellix and Intel use \fI/etc/cshrc\fR and
4989 NeXTs use \fI/etc/cshrc.std\fR.
4990 A/UX, AMIX, Cray and IRIX have no equivalent in \fIcsh\fR(1),
4991 but read this file in \fItcsh\fR anyway.
4992 Solaris 2.x does not have it either, but \fItcsh\fR reads \fI/etc/.cshrc\fR.  (+)
4993 .TP 16
4994 .I /etc/csh.login
4995 Read by login shells after \fI/etc/csh.cshrc\fR.
4996 ConvexOS, Stellix and Intel use \fI/etc/login\fR,
4997 NeXTs use \fI/etc/login.std\fR, Solaris 2.x uses \fI/etc/.login\fR and
4998 A/UX, AMIX, Cray and IRIX use \fI/etc/cshrc\fR.
4999 .TP 16
5000 .I ~/.tcshrc \fR(+)
5001 Read by every shell after \fI/etc/csh.cshrc\fR or its equivalent.
5002 .TP 16
5003 .I ~/.cshrc
5004 Read by every shell, if \fI~/.tcshrc\fR doesn't exist,
5005 after \fI/etc/csh.cshrc\fR or its equivalent.
5006 This manual uses `\fI~/.tcshrc\fR' to mean `\fI~/.tcshrc\fR or,
5007 if \fI~/.tcshrc\fR is not found, \fI~/.cshrc\fR'.
5008 .TP 16
5009 .I ~/.history
5010 Read by login shells after \fI~/.tcshrc\fR
5011 if \fBsavehist\fR is set, but see also \fBhistfile\fR.
5012 .TP 16
5013 .I ~/.login
5014 Read by login shells after \fI~/.tcshrc\fR or \fI~/.history\fR.
5015 The shell may be compiled to read \fI~/.login\fR before instead of after
5016 \fI~/.tcshrc\fR and \fI~/.history\fR; see the \fBversion\fR shell variable.
5017 .TP 16
5018 .I ~/.cshdirs \fR(+)
5019 Read by login shells after \fI~/.login\fR
5020 if \fBsavedirs\fR is set, but see also \fBdirsfile\fR.
5021 .TP 16
5022 .I /etc/csh.logout
5023 Read by login shells at logout.
5024 ConvexOS, Stellix and Intel use \fI/etc/logout\fR and
5025 NeXTs use \fI/etc/logout.std\fR.
5026 A/UX, AMIX, Cray and IRIX have no equivalent in \fIcsh\fR(1),
5027 but read this file in \fItcsh\fR anyway.
5028 Solaris 2.x does not have it either, but \fItcsh\fR reads \fI/etc/.logout\fR.  (+)
5029 .TP 16
5030 .I ~/.logout
5031 Read by login shells at logout after \fI/etc/csh.logout\fR or its equivalent.
5032 .TP 16
5033 .I /bin/sh
5034 Used to interpret shell scripts not starting with a `#'.
5035 .TP 16
5036 .I /tmp/sh*
5037 Temporary file for `<<'.
5038 .TP 16
5039 .I /etc/passwd
5040 Source of home directories for `~name' substitutions.
5041 .PD
5042 .PP
5043 The order in which startup files are read may differ if the shell was so
5044 compiled; see \fBStartup and shutdown\fR and the \fBversion\fR shell variable.
5045 .SH "NEW FEATURES (+)"
5046 This manual describes \fItcsh\fR as a single entity,
5047 but experienced \fIcsh\fR(1) users will want to pay special attention to
5048 \fItcsh\fR's new features.
5049 .PP
5050 A command-line editor, which supports GNU Emacs or \fIvi\fR(1)-style
5051 key bindings.  See \fBThe command-line editor\fR and \fBEditor commands\fR.
5052 .PP
5053 Programmable, interactive word completion and listing.
5054 See \fBCompletion and listing\fR and the \fIcomplete\fR and \fIuncomplete\fR
5055 builtin commands.
5056 .PP
5057 \fBSpelling correction\fR (q.v.) of filenames, commands and variables.
5058 .PP
5059 \fBEditor commands\fR (q.v.) which perform other useful functions in the middle of
5060 typed commands, including documentation lookup (\fIrun-help\fR),
5061 quick editor restarting (\fIrun-fg-editor\fR) and
5062 command resolution (\fIwhich-command\fR).
5063 .PP
5064 An enhanced history mechanism.  Events in the history list are time-stamped.
5065 See also the \fIhistory\fR command and its associated shell variables,
5066 the previously undocumented `#' event specifier and new modifiers
5067 under \fBHistory substitution\fR,
5068 the \fI*-history\fR, \fIhistory-search-*\fR, \fIi-search-*\fR, \fIvi-search-*\fR and
5069 \fItoggle-literal-history\fR editor commands
5070 and the \fBhistlit\fR shell variable.
5071 .PP
5072 Enhanced directory parsing and directory stack handling.
5073 See the \fIcd\fR, \fIpushd\fR, \fIpopd\fR and \fIdirs\fR commands and their associated
5074 shell variables, the description of \fBDirectory stack substitution\fR,
5075 the \fBdirstack\fR, \fBowd\fR and \fBsymlinks\fR shell variables and
5076 the \fInormalize-command\fR and \fInormalize-path\fR editor commands.
5077 .PP
5078 Negation in glob-patterns.  See \fBFilename substitution\fR.
5079 .PP
5080 New \fBFile inquiry operators\fR (q.v.) and a \fIfiletest\fR
5081 builtin which uses them.
5082 .PP
5083 A variety of \fBAutomatic, periodic and timed events\fR (q.v.) including
5084 scheduled events, special aliases, automatic logout and terminal locking,
5085 command timing and watching for logins and logouts.
5086 .PP
5087 Support for the Native Language System
5088 (see \fBNative Language System support\fR),
5089 OS variant features
5090 (see \fBOS variant support\fR and the \fBecho_style\fR shell variable)
5091 and system-dependent file locations (see \fBFILES\fR).
5092 .PP
5093 Extensive terminal-management capabilities.  See \fBTerminal management\fR.
5094 .PP
5095 New builtin commands including \fIbuiltins\fR, \fIhup\fR, \fIls\-F\fR,
5096 \fInewgrp\fR, \fIprintenv\fR, \fIwhich\fR and \fIwhere\fR (q.v.).
5097 .PP
5098 New variables that make useful information easily available to the shell.
5099 See the \fBgid\fR, \fBloginsh\fR, \fBoid\fR, \fBshlvl\fR, \fBtcsh\fR,
5100 \fBtty\fR, \fBuid\fR and \fBversion\fR shell variables and the \fBHOST\fR,
5101 \fBREMOTEHOST\fR, \fBVENDOR\fR, \fBOSTYPE\fR and \fBMACHTYPE\fR environment
5102 variables.
5103 .PP
5104 A new syntax for including useful information in the prompt string
5105 (see \fBprompt\fR),
5106 and special prompts for loops and spelling correction
5107 (see \fBprompt2\fR and \fBprompt3\fR).
5108 .PP
5109 Read-only variables.  See \fBVariable substitution\fR.
5110 .SH BUGS
5111 When a suspended command is restarted, the shell prints the directory
5112 it started in if this is different from the current directory.  This can
5113 be misleading (i.e., wrong) as the job may have changed directories internally.
5114 .PP
5115 Shell builtin functions are not stoppable/restartable.  Command sequences
5116 of the form `a ; b ; c' are also not handled gracefully when stopping is
5117 attempted.  If you suspend `b', the shell will then immediately execute
5118 `c'.  This is especially noticeable if this expansion results from an
5119 \fIalias\fR.  It suffices to place the sequence of commands in ()'s to force it
5120 to a subshell, i.e., `( a ; b ; c )'.
5121 .PP
5122 Control over tty output after processes are started is primitive; perhaps
5123 this will inspire someone to work on a good virtual terminal interface.
5124 In a virtual terminal interface much more interesting things could be
5125 done with output control.
5126 .PP
5127 Alias substitution is most often used to clumsily simulate shell procedures;
5128 shell procedures should be provided rather than aliases.
5129 .PP
5130 Control structures should be parsed rather than being recognized as
5131 built-in commands.  This would allow control commands to be placed anywhere,
5132 to be combined with `|', and to be used with `&' and `;' metasyntax.
5133 .PP
5134 \fIforeach\fR doesn't ignore here documents when looking for its \fIend\fR.
5135 .PP
5136 It should be possible to use the `:' modifiers on the output of command
5137 substitutions.
5138 .PP
5139 The screen update for lines longer than the screen width is very poor
5140 if the terminal cannot move the cursor up (i.e., terminal type `dumb').
5141 .PP
5142 \fBHPATH\fR and \fBNOREBIND\fR don't need to be environment variables.
5143 .PP
5144 Glob-patterns which do not use `?', `*' or `[]' or which use `{}' or `~'
5145 are not negated correctly.
5146 .PP
5147 The single-command form of \fIif\fR does output redirection even if
5148 the expression is false and the command is not executed.
5149 .PP
5150 \fIls\-F\fR includes file identification characters when sorting filenames
5151 and does not handle control characters in filenames well.  It cannot be
5152 interrupted.
5153 .PP
5154 Command substitution supports multiple commands and conditions, but not
5155 cycles or backward \fIgoto\fRs.
5156 .PP
5157 Report bugs at http://bugs.gw.com/, preferably with fixes.  If you want to
5158 help maintain and test tcsh, send mail to tcsh-request@mx.gw.com with the
5159 text `subscribe tcsh' on a line by itself in the body.
5160 .SH THE T IN TCSH
5161 In 1964, DEC produced the PDP-6.  The PDP-10 was a later re-implementation.  It
5162 was re-christened the DECsystem-10 in 1970 or so when DEC brought out the
5163 second model, the KI10.
5164 .PP
5165 TENEX was created at Bolt, Beranek & Newman (a Cambridge, Massachusetts
5166 think tank) in
5167 1972 as an experiment in demand-paged virtual memory operating systems.  They
5168 built a new pager for the DEC PDP-10 and created the OS to go with it.  It was
5169 extremely successful in academia.
5170 .PP
5171 In 1975, DEC brought out a new model of the PDP-10, the KL10; they intended to
5172 have only a version of TENEX, which they had licensed from BBN, for the new
5173 box.  They called their version TOPS-20 (their capitalization is trademarked).
5174 A lot of TOPS-10 users (`The OPerating System for PDP-10') objected; thus DEC
5175 found themselves supporting two incompatible systems on the same hardware--but
5176 then there were 6 on the PDP-11!
5177 .PP
5178 TENEX, and TOPS-20 to version 3, had command completion
5179 via a user-code-level subroutine library called ULTCMD.  With version 3, DEC
5180 moved all that capability and more into the monitor (`kernel' for you Unix
5181 types), accessed by the COMND% JSYS (`Jump to SYStem' instruction, the
5182 supervisor call mechanism [are my IBM roots also showing?]).
5183 .PP
5184 The creator of tcsh was impressed by this feature and several others of TENEX
5185 and TOPS-20, and created a version of csh which mimicked them.
5186 .SH LIMITATIONS
5187 The system limits argument lists to ARG_MAX characters.
5188 .PP
5189 The number of arguments to a command which involves filename expansion is
5190 limited to 1/6th the number of characters allowed in an argument list.
5191 .PP
5192 Command substitutions may substitute no more characters than are allowed in
5193 an argument list.
5194 .PP
5195 To detect looping, the shell restricts the number of \fIalias\fR
5196 substitutions on a single line to 20.
5197 .SH "SEE ALSO"
5198 csh(1), emacs(1), ls(1), newgrp(1), sh(1), setpath(1), stty(1), su(1),
5199 tset(1), vi(1), x(1), access(2), execve(2), fork(2), killpg(2),
5200 pipe(2), setrlimit(2), sigvec(2), stat(2), umask(2), vfork(2), wait(2),
5201 malloc(3), setlocale(3), tty(4), a.out(5), termcap(5), environ(7),
5202 termio(7), Introduction to the C Shell
5203 .SH VERSION
5204 This manual documents tcsh 6.18.01 (Astron) 2012-02-14.
5205 .SH AUTHORS
5206 .PD 0
5207 .TP 2
5208 William Joy
5209 Original author of \fIcsh\fR(1)
5210 .TP 2
5211 J.E. Kulp, IIASA, Laxenburg, Austria
5212 Job control and directory stack features
5213 .TP 2
5214 Ken Greer, HP Labs, 1981
5215 File name completion
5216 .TP 2
5217 Mike Ellis, Fairchild, 1983
5218 Command name recognition/completion
5219 .TP 2
5220 Paul Placeway, Ohio State CIS Dept., 1983-1993
5221 Command line editor, prompt routines, new glob syntax and numerous fixes
5222 and speedups
5223 .TP 2
5224 Karl Kleinpaste, CCI 1983-4
5225 Special aliases, directory stack extraction stuff, login/logout watch,
5226 scheduled events, and the idea of the new prompt format
5227 .TP 2
5228 Rayan Zachariassen, University of Toronto, 1984
5229 \fIls\-F\fR and \fIwhich\fR builtins and numerous bug fixes, modifications
5230 and speedups
5231 .TP 2
5232 Chris Kingsley, Caltech
5233 Fast storage allocator routines
5234 .TP 2
5235 Chris Grevstad, TRW, 1987
5236 Incorporated 4.3BSD \fIcsh\fR into \fItcsh\fR
5237 .TP 2
5238 Christos S. Zoulas, Cornell U. EE Dept., 1987-94
5239 Ports to HPUX, SVR2 and SVR3, a SysV version of getwd.c, SHORT_STRINGS support
5240 and a new version of sh.glob.c
5241 .TP 2
5242 James J Dempsey, BBN, and Paul Placeway, OSU, 1988
5243 A/UX port
5244 .TP 2
5245 Daniel Long, NNSC, 1988
5246 \fBwordchars\fR
5247 .TP 2
5248 Patrick Wolfe, Kuck and Associates, Inc., 1988
5249 \fIvi\fR mode cleanup
5250 .TP 2
5251 David C Lawrence, Rensselaer Polytechnic Institute, 1989
5252 \fBautolist\fR and ambiguous completion listing
5253 .TP 2
5254 Alec Wolman, DEC, 1989
5255 Newlines in the prompt
5256 .TP 2
5257 Matt Landau, BBN, 1989
5258 \fI~/.tcshrc\fR
5259 .TP 2
5260 Ray Moody, Purdue Physics, 1989
5261 Magic space bar history expansion
5262 .TP 2
5263 Mordechai ????, Intel, 1989
5264 printprompt() fixes and additions
5265 .TP 2
5266 Kazuhiro Honda, Dept. of Computer Science, Keio University, 1989
5267 Automatic spelling correction and \fBprompt3\fR
5268 .TP 2
5269 Per Hedeland, Ellemtel, Sweden, 1990-
5270 Various bugfixes, improvements and manual updates
5271 .TP 2
5272 Hans J. Albertsson (Sun Sweden)
5273 \fBampm\fR, \fIsettc\fR and \fItelltc\fR
5274 .TP 2
5275 Michael Bloom
5276 Interrupt handling fixes
5277 .TP 2
5278 Michael Fine, Digital Equipment Corp
5279 Extended key support
5280 .TP 2
5281 Eric Schnoebelen, Convex, 1990
5282 Convex support, lots of \fIcsh\fR bug fixes,
5283 save and restore of directory stack
5284 .TP 2
5285 Ron Flax, Apple, 1990
5286 A/UX 2.0 (re)port
5287 .TP 2
5288 Dan Oscarsson, LTH Sweden, 1990
5289 NLS support and simulated NLS support for non NLS sites, fixes
5290 .TP 2
5291 Johan Widen, SICS Sweden, 1990
5292 \fBshlvl\fR, Mach support, \fIcorrect-line\fR, 8-bit printing
5293 .TP 2
5294 Matt Day, Sanyo Icon, 1990
5295 POSIX termio support, SysV limit fixes
5296 .TP 2
5297 Jaap Vermeulen, Sequent, 1990-91
5298 Vi mode fixes, expand-line, window change fixes, Symmetry port
5299 .TP 2
5300 Martin Boyer, Institut de recherche d'Hydro-Quebec, 1991
5301 \fBautolist\fR beeping options, modified the history search to search for
5302 the whole string from the beginning of the line to the cursor.
5303 .TP 2
5304 Scott Krotz, Motorola, 1991
5305 Minix port
5306 .TP 2
5307 David Dawes, Sydney U. Australia, Physics Dept., 1991
5308 SVR4 job control fixes
5309 .TP 2
5310 Jose Sousa, Interactive Systems Corp., 1991
5311 Extended \fIvi\fR fixes and \fIvi\fR delete command
5312 .TP 2
5313 Marc Horowitz, MIT, 1991
5314 ANSIfication fixes, new exec hashing code, imake fixes, \fIwhere\fR
5315 .TP 2
5316 Bruce Sterling Woodcock, sterling@netcom.com, 1991-1995
5317 ETA and Pyramid port, Makefile and lint fixes, \fBignoreeof\fR=n addition, and
5318 various other portability changes and bug fixes
5319 .TP 2
5320 Jeff Fink, 1992
5321 \fIcomplete-word-fwd\fR and \fIcomplete-word-back\fR
5322 .TP 2
5323 Harry C. Pulley, 1992
5324 Coherent port
5325 .TP 2
5326 Andy Phillips, Mullard Space Science Lab U.K., 1992
5327 VMS-POSIX port
5328 .TP 2
5329 Beto Appleton, IBM Corp., 1992
5330 Walking process group fixes, \fIcsh\fR bug fixes,
5331 POSIX file tests, POSIX SIGHUP
5332 .TP 2
5333 Scott Bolte, Cray Computer Corp., 1992
5334 CSOS port
5335 .TP 2
5336 Kaveh R. Ghazi, Rutgers University, 1992
5337 Tek, m88k, Titan and Masscomp ports and fixes.  Added autoconf support.
5338 .TP 2
5339 Mark Linderman, Cornell University, 1992
5340 OS/2 port
5341 .TP 2
5342 Mika Liljeberg, liljeber@kruuna.Helsinki.FI, 1992
5343 Linux port
5344 .TP 2
5345 Tim P. Starrin, NASA Langley Research Center Operations, 1993
5346 Read-only variables
5347 .TP 2
5348 Dave Schweisguth, Yale University, 1993-4
5349 New man page and tcsh.man2html
5350 .TP 2
5351 Larry Schwimmer, Stanford University, 1993
5352 AFS and HESIOD patches
5353 .TP 2
5354 Luke Mewburn, RMIT University, 1994-6
5355 Enhanced directory printing in prompt,
5356 added \fBellipsis\fR and \fBrprompt\fR.
5357 .TP 2
5358 Edward Hutchins, Silicon Graphics Inc., 1996
5359 Added implicit cd.
5360 .TP 2
5361 Martin Kraemer, 1997
5362 Ported to Siemens Nixdorf EBCDIC machine
5363 .TP 2
5364 Amol Deshpande, Microsoft, 1997
5365 Ported to WIN32 (Windows/95 and Windows/NT); wrote all the missing library
5366 and message catalog code to interface to Windows.
5367 .TP 2
5368 Taga Nayuta, 1998
5369 Color ls additions.
5370 .PD
5371 .PP
5372 .SH "THANKS TO"
5373 Bryan Dunlap, Clayton Elwell, Karl Kleinpaste, Bob Manson, Steve Romig,
5374 Diana Smetters, Bob Sutterfield, Mark Verber, Elizabeth Zwicky and all
5375 the other people at Ohio State for suggestions and encouragement
5376 .PP
5377 All the people on the net, for putting up with,
5378 reporting bugs in, and suggesting new additions to each and every version
5379 .PP
5380 Richard M. Alderson III, for writing the `T in tcsh' section