source: trunk/third/tcsh/tcsh.man @ 12041

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