xref: /freebsd/contrib/tcsh/tcsh.man.new (revision d3d381b2b194b4d24853e92eecef55f262688d1a)
1.\" $tcsh: tcsh.man.new,v 1.5 2016/11/24 15:06:09 christos Exp $
2.\" From: tcsh: tcsh.man,v 3.266 2016/11/24 15:04:52 christos Exp
3.\" Copyright (c) 1980, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS `AS IS' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LESS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\" - Indent in multiples of 4, usually 8.
31.\"
32.\" - Use \` for literal back-quote (`).
33.\"
34.\" - Use \e for literal backslash (\).
35.\"
36.\" - Use \-, not -.
37.\"
38.\" - Include the tilde when naming dot files. .Pa ~/.login , not .Pa .login
39.\"
40.\" - Refer to external commands in man page format, e.g., .Xr csh 1
41.\" However, tcsh is .Nm , because this is the tcsh man page (and
42.\" see the next note anyway).
43.\"
44.\" - Say .Sq the shell , not .Sq tcsh ,
45.\" unless distinguishing between tcsh and csh.
46.\"
47.\" - Say .Sq shell variable / .Sq environment variable instead of
48.\" .Sq variable and .Sq builtin command / .Sq editor command instead of
49.\" .Sq builtin or .Sq command
50.\"   unless the distinction is absolutely clear from context.
51.\"
52.\" - Use the simple present tense.
53.\" .Sq The shell uses , not .Sq The shell will use
54.\"
55.\" - IMPORTANT: Cross-reference as much as possible. Commands, variables,
56.\"   etc. in the reference section should be mentioned in the appropriate
57.\"   descriptive section, or at least in the reference-section description
58.\"   of another command (or whatever) which is mentioned in a description
59.\"   section. Remember to note OS-specific things in "OS variant support",
60.\"   new features in NEW FEATURES and referenced external commands in SEE
61.\"   ALSO.
62.\"
63.\" - tcsh.man2html depends heavily on the specific nroff commands used in the
64.\"   man page when the script was written. Please stick closely to the style
65.\"   used here if you can. In particular, please don't use nroff commands
66.\"   which aren't already used herein.
67.\"
68.Dd November 24, 2016
69.Dt TCSH 1
70.Os Astron 6.20.00
71.Sh NAME
72.Nm tcsh
73.Nd C shell with file name completion and command line editing
74.Sh SYNOPSIS
75.Nm
76.Op Fl bcdefFimnqstvVxX
77.Op Fl Dname Ns Op =value
78.Op Ar arg ...
79.Nm
80.Fl l
81.Ek
82.Sh DESCRIPTION
83.Nm
84is an enhanced but completely compatible version of the Berkeley
85UNIX C shell,
86.Xr csh 1 .
87It is a command language interpreter usable both as an interactive login
88shell and a shell script command processor.
89It includes a command-line editor (see
90.Sx The command-line editor )
91programmable word completion (see
92.Sx Completion and listing )
93spelling correction (see
94.Sx Spelling correction ) ,
95a history mechanism (see
96.Sx History substitution ) ,
97job control (see
98.Sx Jobs )
99and a C-like syntax.
100The
101.Sx NEW FEATURES
102section describes major enhancements of
103.Nm
104over
105.Xr csh 1 .
106Throughout this manual, features of
107.Nm
108not found in most
109.Xr csh 1
110implementations
111(specifically, the 4.4BSD one)
112are labeled with
113.Sq (+) ,
114and features which are present in
115.Xr csh 1
116but not usually documented are labeled with
117.Sq (u) .
118.Bl -tag
119.Ss Argument list processing
120If the first argument (argument 0) to the shell is
121.Sq \-
122then it is a login shell.
123A login shell can be also specified by invoking the shell with
124the
125.Fl l
126flag as the only argument.
127.Pp
128The rest of the flag arguments are interpreted as follows:
129.Bl -tag -width indent
130.It Fl b
131Forces a
132.Dq break
133from option processing, causing any
134further shell arguments to be treated as non-option arguments.
135The remaining arguments will not be interpreted as shell options.
136This may be used to pass options to a shell script without confusion
137or possible subterfuge.
138The shell will not run a set-user ID script without this option.
139.It Fl c
140Commands are read from the following argument (which must be present, and
141must be a single argument),
142stored in the
143.Va command
144shell variable for reference, and executed.
145Any remaining arguments are placed in the
146.Va argv
147shell variable.
148.It Fl d
149The shell loads the directory stack from
150.Pa ~/.cshdirs
151as described under
152.Sx Startup and shutdown ,
153whether or not it is a login shell. (+)
154.It Fl Dname Ns Op =value
155Sets the environment variable
156.Va name
157.Dv value .
158(Domain/OS only) (+)
159.It Fl e
160The shell exits if any invoked command terminates abnormally or
161yields a non-zero exit status.
162.It Fl f
163The shell does not load any resource or startup files, or perform any
164command hashing, and thus starts faster.
165.It Fl F
166The shell uses
167.Xr fork 2
168instead of
169.Xr vfork 2
170to spawn processes. (+)
171.It Fl i
172The shell is interactive and prompts for its top-level input, even if
173it appears to not be a terminal.
174Shells are interactive without this option if
175their inputs and outputs are terminals.
176.It Fl l
177The shell is a login shell.
178Applicable only if
179.Fl l
180is the only
181flag specified.
182.It Fl m
183The shell loads
184.Pa ~/.tcshrc
185even if it does not belong to the effective user.
186Newer versions of
187.Xr su 1
188can pass
189.Fl m
190to the shell. (+)
191.It Fl n
192The shell parses commands but does not execute them.
193This aids in debugging shell scripts.
194.It Fl q
195The shell accepts SIGQUIT (see
196.Sx Signal handling )
197and behaves when it is used under a debugger.
198Job control is disabled. (u)
199.It Fl s
200Command input is taken from the standard input.
201.It Fl t
202The shell reads and executes a single line of input.
203A
204.Sq \e
205may be used to
206escape the newline at the end of this line and continue onto another line.
207.It Fl v
208Sets the
209.Va verbose
210shell variable, so that
211command input is echoed after history substitution.
212.It Fl x
213Sets the
214.Va echo
215shell variable, so that commands are echoed
216immediately before execution.
217.It Fl V
218Sets the
219.Va verbose
220shell variable even before executing
221.Pa ~/.tcshrc .
222.It Fl X
223Is to
224.Fl x
225as
226.Fl V
227is to
228.Fl v .
229.TP 4
230.It Fl \-help
231Print a help message on the standard output and exit. (+)
232.It Fl \-version
233Print the version/platform/compilation options on the standard output and exit.
234This information is also contained in the
235.Va version
236shell variable. (+)
237.El
238.Pp
239After processing of flag arguments, if arguments remain but none of the
240.Fl c ,
241.Fl i ,
242.Fl s ,
243or
244.Fl t
245options were given, the first argument is taken as the name of a file of
246commands, or
247.Dq script ,
248to be executed.
249The shell opens this file and saves its name for possible
250resubstitution by
251.Sq $0 .
252Because many systems use either the standard
253version 6 or version 7 shells whose shell scripts are not compatible
254with this shell, the shell uses such a
255.Sq standard
256shell to execute a script
257whose first character is not a
258.Sq # ,
259i.e., that does not start with a
260comment.
261.Pp
262Remaining arguments are placed in the
263.Va argv
264shell variable.
265.Ss Startup and shutdown
266A login shell begins by executing commands from the system files
267.Pa /etc/csh.cshrc
268and
269.Pa /etc/csh.login .
270It then executes commands from files in the user's
271.Pa home
272directory:
273first
274.Pa ~/.tcshrc (+)
275or, if
276.Pa ~/.tcshrc
277is not found,
278.Pa ~/.cshrc ,
279then
280.Pa ~/.history
281(or the value of the
282.Va histfile
283shell variable), then
284.Pa ~/.login ,
285and finally
286.Pa ~/.cshdirs
287(or the value of the
288.Va dirsfile
289shell variable) (+).
290The shell may read
291.Pa /etc/csh.login
292before instead of after
293.Pa /etc/csh.cshrc ,
294and
295.Pa ~/.login
296before instead of after
297.Pa ~/.tcshrc
298or
299.Pa ~/.cshrc
300and
301.Pa ~/.history ,
302if so compiled;
303see the
304.Va version
305shell variable. (+)
306.Pp
307Non-login shells read only
308.Pa /etc/csh.cshrc
309and
310.Pa ~/.tcshrc
311or
312.Pa ~/.cshrc
313on startup.
314.Pp
315For examples of startup files, please consult:
316.Lk http://tcshrc.sourceforge.net
317.Pp
318Commands like
319.Xr stty 1
320and
321.Xr tset 1 ,
322which need be run only once per login, usually go in one's
323.Pa ~/.login
324file.
325Users who need to use the same set of files with both
326.Xr csh 1
327and
328.Nm
329can have only a
330.Pa ~/.cshrc
331which checks for the existence of the
332.Va tcsh
333shell variable (q.v.) before using
334.Nm \-
335specific commands,
336or can have both a
337.Pa ~/.cshrc
338and a
339.Pa ~/.tcshrc
340which
341.Ic sources
342(see the builtin command)
343.Pa ~/.cshrc .
344The rest of this manual uses
345.Pa ~/.tcshrc
346to mean
347.Pa ~/.tcshrc
348or,
349if
350.Pa ~/.tcshrc
351is not found,
352.Pa ~/.cshrc .
353.Pp
354In the normal case, the shell begins reading commands from the terminal,
355prompting with
356.Sq >\~ .
357(Processing of arguments and the use of the shell to
358process files containing command scripts are described later.)
359The shell repeatedly reads a line of command input, breaks it into words,
360places it on the command history list, parses it and executes each command
361in the line.
362.Pp
363One can log out by typing
364.Sq ^D
365on an empty line,
366.Sq logout
367or
368.Sq login
369or
370via the shell's autologout mechanism (see the
371.Va autologout
372shell variable).
373When a login shell terminates it sets the
374.Va logout
375shell variable to
376.Sq normal
377or
378.Sq automatic
379as appropriate, then executes commands from the files
380.Pa /etc/csh.logout
381and
382.Pa ~/.logout .
383The shell may drop DTR on logout
384if so compiled; see the
385.Va version
386shell variable.
387.Pp
388The names of the system login and logout files vary from system to system for
389compatibility with different
390.Xr csh 1
391variants; see
392.Sx FILES .
393.Ss Editing
394We first describe
395.Sx The command-line editor"
396The
397.Sx Completion and listing
398and
399.Sx Spelling correction
400sections describe two sets of functionality that are implemented as editor
401commands but which deserve their own treatment.
402Finally,
403.Sx Editor commands
404lists and describes
405the editor commands specific to the shell and their default bindings.
406.It Sx The command-line editor (+)
407Command-line input can be edited using key sequences much like those used in
408.Xr emacs 1
409or
410.Xr vi 1 .
411The editor is active only when the
412.Va edit
413shell variable is set, which it is by default in interactive shells.
414The
415.Ic bindkey
416builtin can display and change key bindings.
417.Xr emacs 1
418style key bindings are used by default
419(unless the shell was compiled otherwise; see the
420.Va version
421shell variable),
422but
423.Ic bindkey
424can change the key bindings to
425.Xr vi 1
426style bindings en masse.
427.Pp
428The shell always binds the arrow keys (as defined in the
429.Va TERMCAP
430environment variable) to:
431.Pp
432.Bl -tag -width right -compact -offset indent
433.It down
434.Ic down-history
435.It up
436.Ic up-history
437.It left
438.Ic backward-char
439.It right
440.Ic forward-char
441.El
442.Pp
443unless doing so would alter another single-character binding.
444One can set the arrow key escape sequences to the empty string with
445.Va settc
446to prevent these bindings.
447The ANSI/VT100 sequences for arrow keys are always bound.
448.Pp
449Other key bindings are, for the most part, what
450.Xr emacs 1
451and
452.Xr vi 1
453users would expect and can easily be displayed by
454.Ic bindkey ,
455so there
456is no need to list them here.
457Likewise,
458.Ic bindkey
459can list the editor
460commands with a short description of each.
461Certain key bindings have different behavior depending if
462.Xr emacs 1
463or
464.Xr vi 1
465style bindings are being used; see
466.Va vimode
467for more information.
468.Pp
469Note that editor commands do not have the same notion of a
470.Dq word
471as does the shell.
472The editor delimits words with any non-alphanumeric characters not in
473the shell variable
474.Va wordchars ,
475while the shell recognizes only whitespace
476and some of the characters with special meanings to it, listed under
477.Sx Lexical structure .
478.Ss Completion and listing (+)
479The shell is often able to complete words when given a unique abbreviation.
480Type part of a word (for example
481.Ic ls
482.Pa /usr/lost )
483and hit the tab key to run the
484.Ic complete-word
485editor command.
486The shell completes the filename
487.Pa /usr/lost
488to
489.Pa /usr/lost+found/ ,
490replacing the incomplete word with the complete word in the input buffer.
491(Note the terminal
492.Sq / ;
493completion adds a
494.Sq /
495to the end of completed directories and a space to the end of other completed
496words, to speed typing and provide a visual indicator of successful completion.
497The
498.Va addsuffix
499shell variable can be unset to prevent this.)
500If no match is found (perhaps
501.Pa /usr/lost+found
502doesn't exist), the terminal bell rings.
503If the word is already complete (perhaps there is a
504.Pa /usr/lost
505on your
506system, or perhaps you were thinking too far ahead and typed the whole thing)
507a
508.Sq /
509or space is added to the end if it isn't already there.
510.Pp
511Completion works anywhere in the line, not at just the end; completed
512text pushes the rest of the line to the right.
513Completion in the middle of a word
514often results in leftover characters to the right of the cursor that need
515to be deleted.
516.Pp
517Commands and variables can be completed in much the same way.
518For example, typing
519.Sq em[tab]
520would complete
521.Sq em
522to
523.Sq emacs
524if
525.Pa emacs
526were the only command on your system beginning with
527.Sq em .
528Completion can find a command in any directory in
529.Pa path
530or if given a full pathname.
531Typing
532.Sq echo $ar[tab]
533would complete
534.Sq $ar
535to
536.Sq $argv
537if no other variable began with
538.Sq ar .
539.Pp
540The shell parses the input buffer to determine whether the word you want to
541complete should be completed as a filename, command or variable.
542The first word in the buffer and the first word following
543.Sq \&; ,
544.Sq | ,
545.Sq |& ,
546.Sq &&
547or
548.Sq ||
549is considered to be a command.
550A word beginning with
551.Sq $
552is considered to be a variable.
553Anything else is a filename.
554An empty line is
555.Sq completed
556as a filename.
557.Pp
558You can list the possible completions of a word at any time by typing
559.Sq ^D
560to run the
561.Ic delete-char-or-list-or-eof
562editor command.
563The shell lists the possible completions using the
564.Ic ls\-F
565builtin (q.v.)
566and reprints the prompt and unfinished command line, for example:
567.Bd -literal -offset indent
568> ls /usr/l[^D]
569lbin/       lib/        local/      lost+found/
570> ls /usr/l
571.Ed
572.Pp
573If the
574.Va autolist
575shell variable is set, the shell lists the remaining
576choices (if any) whenever completion fails:
577.Bd -literal -offset indent
578> set autolist
579> nm /usr/lib/libt[tab]
580libtermcap.a@ libtermlib.a@
581> nm /usr/lib/libterm
582.Ed
583.Pp
584If
585.Va autolist
586shell variable is set to
587.Sq ambiguous ,
588choices are listed only when
589completion fails and adds no new characters to the word being completed.
590.Pp
591A filename to be completed can contain variables, your own or others' home
592directories abbreviated with
593.Sq ~
594(see
595.Sx Filename substitution )
596and directory stack entries abbreviated with
597.Sq =
598(see
599.Sx Directory stack substitution ) .
600For example,
601.Bd -literal -offset indent
602> ls ~k[^D]
603kahn    kas     kellogg
604> ls ~ke[tab]
605> ls ~kellogg/
606.Ed
607or
608.Bd -literal -offset indent
609> set local = /usr/local
610> ls $lo[tab]
611> ls $local/[^D]
612bin/ etc/ lib/ man/ src/
613> ls $local/
614.Ed
615.Pp
616Note that variables can also be expanded explicitly with the
617.Ic expand-variables
618editor command.
619.Pp
620.Ic delete-char-or-list-or-eof
621lists at only the end of the line;
622in the middle of a line it deletes the character under the cursor and
623on an empty line it logs one out or, if then
624.Va ignoreeof
625variable is set, does nothing.
626.Sq M-^D ,
627bound to the editor command
628.Ic list-choices ,
629lists completion
630possibilities anywhere on a line, and
631.Ic list-choices
632(or any one of the
633related editor commands that do or don't delete, list and/or log out,
634listed under
635.Ic delete-char-or-list-or-eof )
636can be bound to
637.Sq ^D
638with the
639.Ic bindkey
640builtin command if so desired.
641.Pp
642The
643.Ic complete-word-fwd
644and
645.Ic complete-word-back
646editor commands
647(not bound to any keys by default) can be used to cycle up and down through
648the list of possible completions, replacing the current word with the next or
649previous word in the list.
650.Pp
651The shell variable
652.Va fignore
653can be set to a list of suffixes to be ignored by completion.
654Consider the following:
655.Bd -literal -offset indent
656> ls
657Makefile        condiments.h~   main.o          side.c
658README          main.c          meal            side.o
659condiments.h    main.c~
660> set fignore = (.o \e~)
661> emacs ma[^D]
662main.c   main.c~  main.o
663> emacs ma[tab]
664> emacs main.c
665.Ed
666.Pp
667.Sq main.c~
668and
669.Sq main.o
670are ignored by completion (but not listing),
671because they end in suffixes in
672.Va fignore .
673Note that a
674.Sq \e
675was needed in front of
676.Sq ~
677to prevent it from being expanded to
678.Va home
679as described under
680.Sx Filename substitution .
681.Va fignore
682is ignored if only one completion is possible.
683.Pp
684If the
685.Va complete
686shell variable is set to
687.Sq enhance ,
688completion
6891) ignores case and 2) considers periods, hyphens and underscores
690.Sq ( . ,
691.Sq \&-
692and
693.Sq _ )
694to be word separators and hyphens and underscores to be equivalent.
695If you had the following files
696.Bd -literal -offset indent
697comp.lang.c      comp.lang.perl   comp.std.c++
698comp.lang.c++    comp.std.c
699.Ed
700.Pp
701and typed
702.Sq mail \-f c.l.c[tab] ,
703it would be completed to
704.Sq mail \-f comp.lang.c ,
705and
706.Sq ^D
707would list
708.Sq comp.lang.c
709and
710.Sq comp.lang.c++ .
711.Sq mail \-f c..c++[^D]
712would list
713.Sq comp.lang.c++
714and
715.Sq comp.std.c++ .
716Typing
717.Sq rm a\-\-file[^D]
718in the following directory
719.Bd -literal -offset indent
720A_silly_file    a-hyphenated-file    another_silly_file
721.Ed
722.Pp
723would list all three files, because case is ignored and hyphens and
724underscores are equivalent.
725Periods, however, are not equivalent to
726hyphens or underscores.
727.Pp
728If the
729.Va complete
730shell variable is set to
731.Sq enhance ,
732completion
733ignores case and differences between a hyphen and an underscore word
734separator only when the user types a lowercase character or a hyphen.
735Entering an uppercase character or an underscore will not match the
736corresponding lowercase character or hyphen word separator.
737Typing
738.Sq rm a\-\-file[^D]
739in the directory of the previous example would
740still list all three files, but typing
741.Sq rm A\-\-file
742would match only
743.Sq A_silly_file
744and typing
745.Sq rm a__file[^D]
746would match just
747.Sq A_silly_file
748and
749.Sq another_silly_file
750because the user explicitly used an uppercase
751or an underscore character.
752.Pp
753Completion and listing are affected by several other shell variables:
754.Va recexact
755can be set to complete on the shortest possible unique
756match, even if more typing might result in a longer match:
757.Bd -literal -offset indent
758> ls
759fodder   foo      food     foonly
760> set recexact
761> rm fo[tab]
762.Ed
763.Pp
764just beeps, because
765.Sq fo
766could expand to
767.Sq fod
768or
769.Sq foo ,
770but if we type another
771.Sq o ,
772.Bd -literal -offset indent
773> rm foo[tab]
774> rm foo
775.Ed
776.Pp
777the completion completes on
778.Sq foo ,
779even though
780.Sq food
781and
782.Sq foonly
783also match.
784.Va autoexpand
785can be set to run the
786.Ic expand-history
787editor command
788before each completion attempt,
789.Va autocorrect
790can be set to
791spelling-correct the word to be completed (see
792.Sx Spelling correction )
793before each completion attempt and
794.Va correct
795can be set to complete commands automatically after one hits
796.Sq return .
797.Va matchbeep
798can be set to make completion beep or not beep in a variety
799of situations, and
800.Va nobeep
801can be set to never beep at all.
802.Va nostat
803can be set to a list of directories and/or patterns that
804match directories to prevent the completion mechanism from
805.Xr stat 2
806ing
807those directories.
808.Va listmax
809and
810.Va listmaxrows
811can be set to limit the number of items
812and rows (respectively) that are listed without asking first.
813.Va recognize_only_executables
814can be set to make the shell list only
815executables when listing commands, but it is quite slow.
816.Pp
817Finally, the
818.Ic complete
819builtin command can be used to tell the shell how
820to complete words other than filenames, commands and variables.
821Completion and listing do not work on glob-patterns (see
822.Sx Filename substitution ) ,
823but the
824.Ic list-glob
825and
826.Ic expand-glob
827editor commands perform
828equivalent functions for glob-patterns.
829.Ss Spelling correction (+)
830The shell can sometimes correct the spelling of filenames, commands and
831variable names as well as completing and listing them.
832.Pp
833Individual words can be spelling-corrected with the
834.Ic spell-word
835editor command (usually bound to M-s and M-S)
836and the entire input buffer with
837.Ic spell-line
838(usually bound to M-$).
839The
840.Va correct
841shell variable can be set to
842.Dv cmd
843to correct the command name or
844.Dv all
845to correct the entire line each time return is typed, and
846.Va autocorrect
847can be set to correct the word to be completed
848before each completion attempt.
849.Pp
850When spelling correction is invoked in any of these ways and
851the shell thinks that any part of the command line is misspelled,
852it prompts with the corrected line:
853.Bd -literal -offset indent
854> set correct = cmd
855> lz /usr/bin
856CORRECT>ls /usr/bin (y|n|e|a)?
857.Ed
858.Pp
859One can answer
860.Sq y
861or space to execute the corrected line,
862.Sq e
863to leave the uncorrected command in the input buffer,
864.Sq a
865to abort the command as if
866.Sq ^C
867had been hit, and
868anything else to execute the original line unchanged.
869.Pp
870Spelling correction recognizes user-defined completions (see the
871.Ic complete
872builtin command).
873If an input word in a position for
874which a completion is defined resembles a word in the completion list,
875spelling correction registers a misspelling and suggests the latter
876word as a correction.
877However, if the input word does not match any of
878the possible completions for that position, spelling correction does
879not register a misspelling.
880.Pp
881Like completion, spelling correction works anywhere in the line,
882pushing the rest of the line to the right and possibly leaving
883extra characters to the right of the cursor.
884.Ss Editor commands (+)
885.Ic bindkey
886lists key bindings and
887.Ic bindkey \-l
888lists and briefly describes editor commands.
889Only new or especially interesting editor commands are described here.
890See
891.Xr emacs 1
892and
893.Xr vi 1
894for descriptions of each editor's key bindings.
895.Pp
896The character or characters to which each command is bound by default is
897given in parentheses.
898.Sq ^character
899means a control character and
900.Sq M-character
901a meta character, typed as
902.Sq escape-character
903on terminals without a meta key.
904Case counts, but commands that are bound
905to letters by default are bound to both lower- and uppercase letters for
906convenience.
907.Bl -tag -width indent
908.It Ic backward-char Ar (^B, left)
909Move back a character.
910Cursor behavior modified by
911.Va vimode
912.It Ic backward-delete-word Ar (M-^H, M-^?)
913Cut from beginning of current word to cursor \- saved in cut buffer.
914Word boundary behavior modified by
915.Va vimode
916.It Ic backward-word Ar (M-b, M-B)
917Move to beginning of current word.
918Word boundary and cursor behavior modified by
919.Va vimode
920.It Ic beginning-of-line Ar (^A, home)
921Move to beginning of line.
922Cursor behavior modified by
923.Va vimode
924.It Ic capitalize-word Ar (M-c, M-C)
925Capitalize the characters from cursor to end of current word.
926Word boundary behavior modified by
927.Va vimode
928.It Ic complete-word Ar (tab)
929Completes a word as described under
930.Sx Completion and listing
931.It Ic complete-word-back Ar (not bound)
932Like
933.Ic complete-word-fwd ,
934but steps up from the end of the list.
935.It Ic complete-word-fwd Ar (not bound)
936Replaces the current word with the first word in the list of possible
937completions.
938May be repeated to step down through the list.
939At the end of the list, beeps and reverts to the incomplete word.
940.It Ic complete-word-raw Ar (^X-tab)
941Like
942.Ic complete-word ,
943but ignores user-defined completions.
944.It Ic copy-prev-word Ar (M-^_)
945Copies the previous word in the current line into the input buffer.
946See also
947.Ic insert-last-word
948Word boundary behavior modified by
949.Va vimode
950.It Ic dabbrev-expand Ar (M-/)
951Expands the current word to the most recent preceding one for which
952the current is a leading substring, wrapping around the history list
953(once) if necessary.
954Repeating
955.Ic dabbrev-expand
956without any intervening typing
957changes to the next previous word etc., skipping identical matches
958much like
959.Ic history-search-backward
960does.
961.It Ic delete-char Ar (not bound)
962Deletes the character under the cursor.
963See also
964.Ic delete-char-or-list-or-eof
965Cursor behavior modified by
966.Va vimode
967.It Ic delete-char-or-eof Ar (not bound)
968Does
969.Ic delete-char
970if there is a character under the cursor or
971.Ic end-of-file
972on an empty line.
973See also
974.Ic delete-char-or-list-or-eof
975Cursor behavior modified by
976.Va vimode
977.It Ic delete-char-or-list Ar (not bound)
978Does
979.Ic delete-char
980if there is a character under the cursor
981or
982.Ic list-choices
983at the end of the line.
984See also
985.Ic delete-char-or-list-or-eof
986.It Ic delete-char-or-list-or-eof Ar (^D)
987Does
988.Ic delete-char
989if there is a character under the cursor,
990.Ic list-choices
991at the end of the line or
992.Ic end-of-file
993on an empty line.
994See also those three commands, each of which does only a single action, and
995.Ic delete-char-or-eof ,
996.Ic delete-char-or-list
997and
998.Ic list-or-eof ,
999each of which does a different two out of the three.
1000.It Ic delete-word Ar (M-d, M-D)
1001Cut from cursor to end of current word \- save in cut buffer.
1002Word boundary behavior modified by
1003.Va vimode
1004.It Ic down-history Ar (down-arrow, ^N)
1005Like
1006.Ic up-history ,
1007but steps down, stopping at the original input line.
1008.It Ic downcase-word Ar (M-l, M-L)
1009Lowercase the characters from cursor to end of current word.
1010Word boundary behavior modified by
1011.Va vimode
1012.It Ic end-of-file Ar (not bound)
1013Signals an end of file, causing the shell to exit unless the
1014.Va ignoreeof
1015shell variable (q.v.) is set to prevent this.
1016See also
1017.Ic delete-char-or-list-or-eof
1018.It Ic end-of-line Ar (^E, end)
1019Move cursor to end of line.
1020Cursor behavior modified by
1021.Va vimode
1022.It Ic expand-history Ar (M-space)
1023Expands history substitutions in the current word.
1024See
1025.Sx History substitution
1026See also
1027.Ic magic-space ,
1028.Ic toggle-literal-history
1029and the
1030.Va autoexpand
1031shell variable.
1032.It Ic expand-glob Ar (^X-*)
1033Expands the glob-pattern to the left of the cursor.
1034See
1035.Sx Filename substitution
1036.It Ic expand-line Ar (not bound)
1037Like
1038.Ic expand-history ,
1039but expands history substitutions in each word in the input buffer.
1040.It Ic expand-variables Ar (^X-$)
1041Expands the variable to the left of the cursor.
1042See
1043.Sx Variable substitution
1044.It Ic forward-char Ar (^F, right)
1045Move forward one character.
1046Cursor behavior modified by
1047.Va vimode
1048.It Ic forward-word Ar (M-f, M-F)
1049Move forward to end of current word.
1050Word boundary and cursor behavior modified by
1051.Va vimode
1052.It Ic history-search-backward Ar (M-p, M-P)
1053Searches backwards through the history list for a command beginning with
1054the current contents of the input buffer up to the cursor and copies it
1055into the input buffer.
1056The search string may be a glob-pattern (see
1057.Sx Filename substitution )
1058containing
1059.Sq * ,
1060.Sq \&?  ,
1061.Sq []
1062or
1063.Sq {}
1064.Ic up-history
1065and
1066.Ic down-history
1067will proceed from the
1068appropriate point in the history list.
1069Emacs mode only.
1070See also
1071.Ic history-search-forward
1072and
1073.Ic i-search-back
1074.It Ic history-search-forward Ar (M-n, M-N)
1075Like
1076.Ic history-search-backward ,
1077but searches forward.
1078.It Ic i-search-back Ar (not bound)
1079Searches backward like
1080.Ic history-search-backward ,
1081copies the first match
1082into the input buffer with the cursor positioned at the end of the pattern,
1083and prompts with
1084.Sq bck:
1085and the first match.
1086Additional characters may be
1087typed to extend the search,
1088.Ic i-search-back
1089may be typed to continue
1090searching with the same pattern, wrapping around the history list if
1091necessary,
1092.Ic ( i-search-back
1093must be bound to a
1094single character for this to work) or one of the following special characters
1095may be typed:
1096.Pp
1097.Sq ^W
1098Appends the rest of the word under the cursor to the search pattern.
1099delete (or any character bound to
1100.Ic backward-delete-char )
1101Undoes the effect of the last character typed and deletes a character
1102from the search pattern if appropriate.
1103.Sq ^G
1104If the previous search was successful, aborts the entire search.
1105If not, goes back to the last successful search.
1106escape
1107Ends the search, leaving the current line in the input buffer.
1108.Pp
1109Any other character not bound to
1110.Ic self-insert-command
1111terminates the
1112search, leaving the current line in the input buffer, and
1113is then interpreted as normal input.
1114In particular, a carriage return
1115causes the current line to be executed.
1116See also
1117.Ic i-search-fwd
1118and
1119.Ic history-search-backward
1120Word boundary behavior modified by
1121.Va vimode
1122.It Ic i-search-fwd Ar (not bound)
1123Like
1124.Ic i-search-back ,
1125but searches forward.
1126Word boundary behavior modified by
1127.Va vimode
1128.It Ic insert-last-word Ar (M-_)
1129Inserts the last word of the previous input line
1130.Sq ( \&!$ )
1131into the input buffer.
1132See also
1133.Ic copy-prev-word
1134.It Ic list-choices Ar (M-^D)
1135Lists completion possibilities as described under
1136.Sx Completion and listing
1137See also
1138.Ic delete-char-or-list-or-eof
1139and
1140.Ic list-choices-raw
1141.It Ic list-choices-raw Ar (^X-^D)
1142Like
1143.Ic list-choices ,
1144but ignores user-defined completions.
1145.It Ic list-glob Ar (^X-g, ^X-G)
1146Lists (via the
1147.Ic ls\-F
1148builtin) matches to the glob-pattern
1149(see
1150.Sx Filename substitution )
1151to the left of the cursor.
1152.It Ic list-or-eof Ar (not bound)
1153Does
1154.Ic list-choices
1155or
1156.Ic end-of-file
1157on an empty line.
1158See also
1159.Ic delete-char-or-list-or-eof
1160.It Ic magic-space Ar (not bound)
1161Expands history substitutions in the current line,
1162like
1163.Ic expand-history ,
1164and inserts a space.
1165.Ic magic-space
1166is designed to be bound to the space bar,
1167but is not bound by default.
1168.It Ic normalize-command Ar (^X-?)
1169Searches for the current word in PATH and, if it is found, replaces it with
1170the full path to the executable.
1171Special characters are quoted.
1172Aliases are
1173expanded and quoted but commands within aliases are not.
1174This command is
1175useful with commands that take commands as arguments, e.g.,
1176.Sq dbx
1177and
1178.Sq sh \-x
1179.It Ic normalize-path Ar (^X-n, ^X-N)
1180Expands the current word as described under the
1181.Sq expand
1182setting
1183of the
1184.Va symlinks
1185shell variable.
1186.It Ic overwrite-mode Ar (unbound)
1187Toggles between input and overwrite modes.
1188.It Ic run-fg-editor Ar (M-^Z)
1189Saves the current input line and
1190looks for a stopped job where the file name portion of its first word
1191is found in the
1192.Va editors
1193shell variable.
1194If
1195.Va editors
1196is not set, then the file name portion of the
1197.Va EDITOR
1198environment variable
1199.Sq ( ed
1200if unset)
1201and the
1202.Va VISUAL
1203environment variable
1204Sq ( vi
1205if unset)
1206will be used.
1207If such a job is found, it is restarted as if
1208.Sq fg %
1209.Ic job
1210had been typed.
1211This is used to toggle back and forth between an editor and
1212the shell easily.
1213Some people bind this command to
1214.Sq ^Z
1215so they
1216can do this even more easily.
1217.It Ic run-help Ar (M-h, M-H)
1218Searches for documentation on the current command, using the same notion of
1219.Sq current command
1220as the completion routines, and prints it.
1221There is no way
1222to use a pager;
1223.Ic run-help
1224is designed for short help files.
1225If the special alias
1226.Va helpcommand
1227is defined, it is run with the
1228command name as a sole argument.
1229Else,
1230documentation should be in a file named
1231.Sq command.help ,
1232.Sq command.1 ,
1233.Sq command.6 ,
1234.Sq command.8 ,
1235or
1236.Sq command ,
1237which should be in one
1238of the directories listed in the
1239.Va HPATH
1240environment variable.
1241If there is more than one help file only the first is printed.
1242.It Ic self-insert-command Ar (text characters)
1243In insert mode (the default), inserts the typed character into the input line after the character under the cursor.
1244In overwrite mode, replaces the character under the cursor with the typed character.
1245The input mode is normally preserved between lines, but the
1246.Va inputmode
1247shell variable can be set to
1248.Dv insert
1249or
1250.Dv overwrite
1251to put the
1252editor in that mode at the beginning of each line.
1253See also
1254.Ic overwrite-mode
1255.It Ic sequence-lead-in Ar (arrow prefix, meta prefix, ^X)
1256Indicates that the following characters are part of a
1257multi-key sequence.
1258Binding a command to a multi-key sequence really creates
1259two bindings: the first character to
1260.Ic sequence-lead-in
1261and the
1262whole sequence to the command.
1263All sequences beginning with a character
1264bound to
1265.Ic sequence-lead-in
1266are effectively bound to
1267.Ic undefined-key
1268unless bound to another command.
1269.It Ic spell-line Ar (M-$)
1270Attempts to correct the spelling of each word in the input buffer, like
1271.Ic spell-word ,
1272but ignores words whose first character is one of
1273.Sq \- ,
1274.Sq \ ! ,
1275.Sq ^
1276or
1277.Sq % ,
1278or which contain
1279.Sq \e ,
1280.Sq *
1281or
1282.Sq \&? ,
1283to avoid problems with switches, substitutions and the like.
1284See
1285.Sx Spelling correction
1286.It Ic spell-word Ar (M-s, M-S)
1287Attempts to correct the spelling of the current word as described under
1288.Sx Spelling correction
1289Checks each component of a word which appears to be a pathname.
1290.It Ic toggle-literal-history Ar (M-r, M-R)
1291Expands or
1292.Sq unexpands
1293history substitutions in the input buffer.
1294See also
1295.Ic expand-history
1296and the
1297.Va autoexpand
1298shell variable.
1299.It Ic undefined-key Ar (any unbound key)
1300Beeps.
1301.It Ic up-history Ar (up-arrow, ^P)
1302Copies the previous entry in the history list into the input buffer.
1303If
1304.Va histlit
1305is set, uses the literal form of the entry.
1306May be repeated to step up through the history list, stopping at the top.
1307.It Ic upcase-word Ar (M-u, M-U)
1308Uppercase the characters from cursor to end of current word.
1309Word boundary behavior modified by
1310.Va vimode
1311.It Ic vi-beginning-of-next-word Ar (not bound)
1312Vi goto the beginning of next word.
1313Word boundary and cursor behavior modified by
1314.Va vimode
1315.It Ic vi-eword Ar (not bound)
1316Vi move to the end of the current word.
1317Word boundary behavior modified by
1318.Va vimode
1319.It Ic vi-search-back Ar (?)
1320Prompts with
1321.Sq \&?
1322for a search string (which may be a glob-pattern, as with
1323.Ic history-search-backward ),
1324searches for it and copies it into the input buffer.
1325The bell rings if no match is found.
1326Hitting return ends the search and leaves the last match in the input
1327buffer.
1328Hitting escape ends the search and executes the match.
1329.Ic vi
1330mode only.
1331.It Ic vi-search-fwd Ar (/)
1332Like
1333.Ic vi-search-back ,
1334but searches forward.
1335.It Ic which-command Ar (M-?)
1336Does a
1337.Ic which
1338(see the description of the builtin command) on the
1339first word of the input buffer.
1340.It Ic yank-pop Ar (M-y)
1341When executed immediately after a
1342.Ic yank
1343or another
1344.Ic yank-pop ,
1345replaces the yanked string with the next previous string from the
1346killring. This also has the effect of rotating the killring, such that
1347this string will be considered the most recently killed by a later
1348.Ic yank
1349command. Repeating
1350.Ic yank-pop
1351will cycle through the
1352killring any number of times.
1353.El
1354.Ss Lexical structure
1355The shell splits input lines into words at blanks and tabs.
1356The special
1357characters
1358.Sq \&& ,
1359.Sq | ,
1360.Sq \&; ,
1361.Sq < ,
1362.Sq > ,
1363.Sq \&( ,
1364and
1365.Sq \&)
1366and the doubled characters
1367.Sq && ,
1368.Sq || ,
1369.Sq <<
1370and
1371.Sq >>
1372are always separate words, whether or not they are
1373surrounded by whitespace.
1374.Pp
1375When the shell's input is not a terminal, the character
1376.Sq #
1377is taken to begin a
1378comment.
1379Each
1380.Sq #
1381and the rest of the input line on which it appears is
1382discarded before further parsing.
1383.Pp
1384A special character (including a blank or tab) may be prevented from having
1385its special meaning, and possibly made part of another word, by preceding it
1386with a backslash
1387.Sq ( \e )
1388or enclosing it in single
1389.Sq ( \&' ) ,
1390, double
1391.Sq ( \&" )
1392or
1393backward
1394.Sq ( \&` )
1395quotes.
1396When not otherwise quoted a newline preceded by a
1397.Sq \e
1398is equivalent to a blank, but inside quotes this sequence results in a
1399newline.
1400.Pp
1401Furthermore, all
1402.Sx Substitutions
1403(see below) except
1404.Sx History substitution
1405can be prevented by enclosing the strings (or parts of strings)
1406in which they appear with single quotes or by quoting the crucial character(s)
1407(e.g.,
1408.Sq $
1409or
1410.Sq \&`
1411for
1412.Sx Variable substitution
1413or
1414.Sx Command substitution
1415respectively)
1416with
1417.Sq \e
1418.Sx ( Alias substitution
1419is no exception: quoting in any way any
1420character of a word for which an
1421.Va alias
1422has been defined prevents
1423substitution of the alias.
1424The usual way of quoting an alias is to precede it
1425with a backslash.)
1426.Sx History substitution
1427is prevented by
1428backslashes but not by single quotes.
1429Strings quoted with double or backward
1430quotes undergo
1431.Sx Variable substitution
1432and
1433.Sx Command substitution ,
1434but other substitutions are prevented.
1435.Pp
1436Text inside single or double quotes becomes a single word (or part of one).
1437Metacharacters in these strings, including blanks and tabs, do not form
1438separate words.
1439Only in one special case (see
1440.Sx Command substitution
1441below) can a double-quoted string yield parts of more than one word;
1442single-quoted strings never do.
1443Backward quotes are special: they signal
1444.Sx Command substitution
1445(q.v.), which may result in more than one word.
1446.Pp
1447Quoting complex strings, particularly strings which themselves contain quoting
1448characters, can be confusing.
1449Remember that quotes need not be used as they are
1450in human writing!
1451It may be easier to quote not an entire string, but only
1452those parts of the string which need quoting, using different types of quoting
1453to do so if appropriate.
1454.Pp
1455The
1456.Va backslash_quote
1457shell variable (q.v.) can be set to make backslashes
1458always quote
1459.Sq \e ,
1460.Sq \&' ,
1461and
1462.Sq \&"
1463(+) This may make complex quoting tasks
1464easier, but it can cause syntax errors in
1465.Xr csh 1
1466scripts.
1467.Ss Substitutions
1468We now describe the various transformations the shell performs on the input in
1469the order in which they occur.
1470We note in passing the data structures involved
1471and the commands and variables which affect them.
1472Remember that substitutions
1473can be prevented by quoting as described under
1474.Sx Lexical structure .
1475.Ss History substitution
1476Each command, or
1477.Sq event ,
1478input from the terminal is saved in the history list.
1479The previous command is always saved, and the
1480.Va history
1481shell
1482variable can be set to a number to save that many commands.
1483The
1484.Va histdup
1485shell variable can be set to not save duplicate events or consecutive duplicate
1486events.
1487.Pp
1488Saved commands are numbered sequentially from 1 and stamped with the time.
1489It is not usually necessary to use event numbers, but the current event number
1490can be made part of the prompt by placing an
1491.Sq \&!
1492in the
1493.Va prompt
1494shell variable.
1495.Pp
1496The shell actually saves history in expanded and literal (unexpanded) forms.
1497If the
1498.Va histlit
1499shell variable is set, commands that display and store
1500history use the literal form.
1501.Pp
1502The
1503.Va history
1504builtin command can print, store in a file, restore
1505and clear the history list at any time,
1506and the
1507.Va savehist
1508and
1509.Va histfile
1510shell variables can be set to
1511store the history list automatically on logout and restore it on login.
1512.Pp
1513History substitutions introduce words from the history list into the input
1514stream, making it easy to repeat commands, repeat arguments of a previous
1515command in the current command, or fix spelling mistakes in the previous
1516command with little typing and a high degree of confidence.
1517.Pp
1518History substitutions begin with the character
1519.Sq \&!
1520They may begin anywhere in
1521the input stream, but they do not nest.
1522The
1523.Sq \&!
1524may be preceded by a
1525.Sq \e
1526to
1527prevent its special meaning; for convenience, a
1528.Sq \&!
1529is passed unchanged when it
1530is followed by a blank, tab, newline,
1531.Sq =
1532or
1533.Sq \&(
1534History substitutions also
1535occur when an input line begins with
1536.Sq ^
1537This special abbreviation will be
1538described later.
1539The characters used to signal history substitution
1540.Sq ( \&!
1541and
1542.Sq ^ )
1543can be changed by setting the
1544.Va histchars
1545shell variable.
1546Any input
1547line which contains a history substitution is printed before it is executed.
1548.Pp
1549A history substitution may have an
1550.Sq event specification ,
1551which indicates the event from which words are to be taken, a
1552.Sq word designator ,
1553which selects particular words from the chosen event, and/or a
1554.Sq modifier ,
1555which manipulates the selected words.
1556.Pp
1557An event specification can be
1558.Pp
1559.Bl -tag -width XXXX -offset indent -compact
1560.It Ar n
1561A number, referring to a particular event
1562.It Ar \-n
1563An offset, referring to the event
1564.Ar n
1565before the current event
1566.It Ar #
1567The current event.
1568This should be used carefully in
1569.Xr csh 1 ,
1570where there is no check for recursion.
1571.Nm
1572allows 10 levels of recursion.
1573(+)
1574.It Ar \&!
1575The previous event (equivalent to
1576.Sq \-1 )
1577.It Ar s
1578The most recent event whose first word begins with the string
1579.Va s
1580.It Ar ?s?
1581The most recent event which contains the string
1582.Va s
1583The second
1584.Sq \&?
1585can be omitted if it is immediately followed by a newline.
1586.El
1587.Pp
1588For example, consider this bit of someone's history list:
1589.Bd -literal -offset indent
1590 9  8:30    nroff \-man wumpus.man
159110  8:31    cp wumpus.man wumpus.man.old
159211  8:36    vi wumpus.man
159312  8:37    diff wumpus.man.old wumpus.man
1594.Ed
1595.Pp
1596The commands are shown with their event numbers and time stamps.
1597The current event, which we haven't typed in yet, is event 13.
1598.Sq !11
1599and
1600.Sq !\-2
1601refer to event 11.
1602.Sq \&!!
1603refers to the previous event, 12.
1604.Sq \&!!
1605can be abbreviated
1606.Sq \&!
1607if it is
1608followed by
1609.Sq \&:
1610.Sq ( \&:
1611is described below).
1612.Sq !n
1613refers to event 9, which begins with
1614.Sq n
1615.Sq !?old?
1616also refers to event 12, which contains
1617.Sq old
1618Without word designators or modifiers history references simply expand to the
1619entire event, so we might type
1620.Sq !cp
1621to redo the copy command or
1622.Sq !!|more
1623if the
1624.Sq diff
1625output scrolled off the top of the screen.
1626.Pp
1627History references may be insulated from the surrounding text with braces if
1628necessary.
1629For example,
1630.Sq !vdoc
1631would look for a command beginning with
1632.Sq vdoc ,
1633and, in this example, not find one, but
1634.Sq !{v}doc
1635would expand
1636unambiguously to
1637.Sq vi wumpus.mandoc
1638Even in braces, history substitutions do not nest.
1639.Pp
1640(+) While
1641.Xr csh 1
1642expands, for example,
1643.Sq !3d
1644to event 3 with the
1645letter
1646.Sq d
1647appended to it,
1648.Nm
1649expands it to the last event beginning
1650with
1651.Sq 3d ;
1652only completely numeric arguments are treated as event numbers.
1653This makes it possible to recall events beginning with numbers.
1654To expand
1655.Sq !3d
1656as in
1657.Xr csh 1
1658say
1659.Sq !{3}d
1660.Pp
1661To select words from an event we can follow the event specification by a
1662.Sq \&:
1663and a designator for the desired words.
1664The words of an input line are
1665numbered from 0, the first (usually command) word being 0, the second word
1666(first argument) being 1, etc.
1667The basic word designators are:
1668.Bl -tag -width XXXX -offset indent -compact
1669.It Ar 0
1670The first (command) word
1671.It Ar n
1672The
1673.Va n
1674th argument
1675.It Ar ^
1676The first argument, equivalent to
1677.Sq 1
1678.It Ar $
1679The last argument
1680.It Ar %
1681The word matched by an ?
1682.Va s
1683? search
1684.It Ar x\-y
1685A range of words
1686.It Ar \-y
1687Equivalent to
1688.Sq 0\-y
1689.It Ar *
1690Equivalent to
1691.Sq ^\-$ ,
1692but returns nothing if the event contains only 1 word
1693.It Ar x*
1694Equivalent to
1695.Sq x\-$
1696.It Ar x\-
1697Equivalent to
1698.Sq x* ,
1699but omitting the last word
1700.Sq ( $ )
1701.El
1702.Pp
1703Selected words are inserted into the command line separated by single blanks.
1704For example, the
1705.Sq diff
1706command in the previous example might have been
1707typed as
1708.Sq diff !!:1.old !!:1
1709(using
1710.Sq \&:1
1711to select the first argument
1712from the previous event) or
1713.Sq diff !\-2:2 !\-2:1
1714to select and swap the
1715arguments from the
1716.Sq cp
1717command.
1718If we didn't care about the order of the
1719`diff' we might have said
1720.Sq diff !\-2:1\-2
1721or simply
1722.Sq diff !\-2:*
1723The
1724.Sq cp
1725command might have been written
1726.Sq cp wumpus.man !#:1.old
1727, using
1728.Sq #
1729to refer to the current event.
1730`!n:\- hurkle.man' would reuse the first two words from the
1731.Sq nroff
1732command
1733to say
1734.Sq nroff \-man hurkle.man
1735.Pp
1736The
1737.Sq \&:
1738separating the event specification from the word designator can be
1739omitted if the argument selector begins with a
1740.Sq ^ ,
1741.Sq $ ,
1742.Sq * ,
1743.Sq %
1744or
1745.Sq \&-
1746For example, our
1747.Sq diff
1748command might have been
1749.Sq diff !!^.old !!^
1750or,
1751equivalently,
1752.Sq diff !!$.old !!$
1753However, if
1754.Sq \&!!
1755is abbreviated
1756.Sq \&!
1757,
1758an argument selector beginning with
1759.Sq \-
1760will be interpreted as an event
1761specification.
1762.Pp
1763A history reference may have a word designator but no event specification.
1764It then references the previous command.
1765Continuing our
1766.Sq diff
1767example, we could have said simply `diff
1768!^.old !^' or, to get the arguments in the opposite order, just
1769.Sq diff !*
1770.Pp
1771The word or words in a history reference can be edited, or
1772.Sq `modified
1773',
1774by following it with one or more modifiers, each preceded by a
1775.Sq \&: :
1776.Pp
1777.Bl -tag -width XXXXXX -offset indent -compact
1778.It Ar h
1779Remove a trailing pathname component, leaving the head.
1780.It Ar t
1781Remove all leading pathname components, leaving the tail.
1782.It Ar r
1783Remove a filename extension
1784.Sq .xxx ,
1785leaving the root name.
1786.It Ar e
1787Remove all but the extension.
1788.It Ar u
1789Uppercase the first lowercase letter.
1790.It Ar l
1791Lowercase the first uppercase letter.
1792.It Ar s/l/r/
1793Substitute
1794.Ar l
1795for
1796.Ar r
1797.Ar l
1798is simply a string like
1799.Ar r
1800, not a regular expression as in
1801the eponymous
1802.Xr ed 1
1803command.
1804Any character may be used as the delimiter in place of
1805.Sq / ;
1806a
1807.Sq \e
1808can be used to quote the delimiter inside
1809.Va l
1810and
1811.Va r
1812The character
1813.Sq &
1814in the
1815.Va r
1816is replaced by
1817.Va l ;
1818.Sq \e
1819also quotes
1820.Sq &
1821If
1822.Va l
1823is empty (
1824.Dq \& ) ,
1825the
1826.Va l
1827from a previous substitution or the
1828.Va s
1829from a previous search or event number in event specification is used.
1830The trailing delimiter may be omitted if it is immediately followed by a
1831newline.
1832.It Ar \&&
1833Repeat the previous substitution.
1834.It Ar g
1835Apply the following modifier once to each word.
1836.It Ar a (+)
1837Apply the following modifier as many times as possible to a single word.
1838.Sq a
1839and
1840.Sq g
1841can be used together to apply a modifier globally.
1842With the
1843.Sq s
1844modifier, only the patterns contained in the original word are
1845substituted, not patterns that contain any substitution result.
1846.It Ar p
1847Print the new command line but do not execute it.
1848.It Ar q
1849Quote the substituted words, preventing further substitutions.
1850.It Ar x
1851Like
1852.Ar q ,
1853but break into words at blanks, tabs and newlines.
1854.El
1855.Pp
1856Modifiers are applied to only the first modifiable word (unless
1857.Sq g
1858is used).
1859It is an error for no word to be modifiable.
1860.Pp
1861For example, the
1862.Sq diff
1863command might have been written as `diff wumpus.man.old
1864!#^:r', using
1865.Sq \&:r
1866to remove
1867.Sq .old
1868from the first argument on the same line
1869(`!#^').
1870We could say
1871.Sq echo hello out there
1872, then
1873.Sq echo !*:u
1874to capitalize
1875`hello',
1876.Sq echo !*:au
1877to say it out loud, or
1878.Sq echo !*:agu
1879to really shout.
1880We might follow
1881.Sq mail \-s "I forgot my password" rot
1882with
1883.Sq !:s/rot/root
1884to
1885correct the spelling of
1886.Sq root
1887(but see
1888.Sx Spelling correction
1889for a
1890different approach).
1891.Pp
1892There is a special abbreviation for substitutions.
1893.Sq ^ ,
1894when it is the first character on an input line, is equivalent to
1895.Sq !:s^
1896Thus we might have said
1897.Sq ^rot^root
1898to make the spelling correction in the
1899previous example.
1900This is the only history substitution which does not explicitly begin with
1901.Sq \&!
1902.Pp
1903(+) In
1904.Xr csh 1
1905as such, only one modifier may be applied to each history
1906or variable expansion.
1907In
1908.Nm ,
1909more than one may be used, for example
1910.Bd -literal -offset indent
1911% mv wumpus.man /usr/man/man1/wumpus.1
1912% man !$:t:r
1913man wumpus
1914.Ed
1915.Pp
1916In
1917.Xr csh 1 ,
1918the result would be
1919.Sq wumpus.1:r
1920A substitution followed by a
1921colon may need to be insulated from it with braces:
1922.Bd -literal -offset indent
1923> mv a.out /usr/games/wumpus
1924> setenv PATH !$:h:$PATH
1925Bad ! modifier: $.
1926> setenv PATH !{\-2$:h}:$PATH
1927setenv PATH /usr/games:/bin:/usr/bin:.
1928.Ed
1929.Pp
1930The first attempt would succeed in
1931.Xr csh 1
1932but fails in
1933.Nm ,
1934because
1935.Nm
1936expects another modifier after the second colon
1937rather than
1938.Sq $
1939.Pp
1940Finally, history can be accessed through the editor as well as through
1941the substitutions just described.
1942The
1943.Ic up-
1944and
1945.Ic down-history ,
1946.Ic history-search-backward
1947and
1948.Va -forward ,
1949.Ic i-search-back
1950and
1951.Ic -fwd ,
1952.Ic vi-search-back
1953and
1954.Ic -fwd ,
1955.Ic copy-prev-word
1956and
1957.Ic insert-last-word
1958editor commands search for
1959events in the history list and copy them into the input buffer.
1960The
1961.Ic toggle-literal-history
1962editor command switches between the
1963expanded and literal forms of history lines in the input buffer.
1964.Ic expand-history
1965and
1966.Ic expand-line
1967expand history substitutions
1968in the current word and in the entire input buffer respectively.
1969.Ss Alias substitution
1970The shell maintains a list of aliases which can be set, unset and printed by
1971the
1972.Ic alias
1973and
1974.Ic unalias
1975commands.
1976After a command line is parsed
1977into simple commands (see
1978.Sx Commands )
1979the first word of each command,
1980left-to-right, is checked to see if it has an alias.
1981If so, the first word is
1982replaced by the alias.
1983If the alias contains a history reference, it undergoes
1984.Va History substitution
1985(q.v.) as though the original command were the
1986previous input line.
1987If the alias does not contain a history reference, the
1988argument list is left untouched.
1989.Pp
1990Thus if the alias for
1991.Sq ls
1992were
1993.Sq ls \-l
1994the command
1995.Sq ls /usr
1996would become `ls
1997\-l /usr', the argument list here being undisturbed.
1998If the alias for
1999.Sq lookup
2000were
2001.Sq grep !/etc/passwd
2002then
2003.Sq lookup bill
2004would become `grep bill
2005/etc/passwd'.
2006Aliases can be used to introduce parser metasyntax.
2007For
2008example,
2009.Sq alias print
2010pr \e!* | lpr'' defines a
2011.Sq `command
2012' (`print') which
2013.Va pr
2014(1)s its arguments to the line printer.
2015.Pp
2016Alias substitution is repeated until the first word of the command has no
2017alias.
2018If an alias substitution does not change the first word (as in the
2019previous example) it is flagged to prevent a loop.
2020Other loops are detected and
2021cause an error.
2022.Pp
2023Some aliases are referred to by the shell; see
2024.Va Special aliases
2025.Sx Variable substitution
2026The shell maintains a list of variables, each of which has as value a list of
2027zero or more words.
2028The values of shell variables can be displayed and changed with the
2029.Va set
2030and
2031.Va unset
2032commands.
2033The system maintains its own list of
2034.Sq `environment
2035' variables.
2036These can be displayed and changed with
2037.Va printenv
2038,
2039.Va setenv
2040and
2041.Va unsetenv
2042.Pp
2043(+) Variables may be made read-only with
2044.Sq set \-r
2045(q.v.).
2046Read-only variables may not be modified or unset;
2047attempting to do so will cause an error.
2048Once made read-only, a variable cannot be made writable,
2049so
2050.Sq set \-r
2051should be used with caution.
2052Environment variables cannot be made read-only.
2053.Pp
2054Some variables are set by the shell or referred to by it.
2055For instance, the
2056.Va argv
2057variable is an image of the shell's argument
2058list, and words of this variable's value are referred to in special ways.
2059Some of the variables referred to by the shell are toggles;
2060the shell does not care what their value is, only whether they are set or not.
2061For instance, the
2062.Va verbose
2063variable is a toggle which causes command
2064input to be echoed.
2065The
2066.Fl v\fR command line option sets this variable.
2067.Va Special shell variables
2068lists all variables which are referred to by the shell.
2069.Pp
2070Other operations treat variables numerically.
2071The
2072.Sq @
2073command permits numeric
2074calculations to be performed and the result assigned to a variable.
2075Variable
2076values are, however, always represented as (zero or more) strings.
2077For the
2078purposes of numeric operations, the null string is considered to be zero, and
2079the second and subsequent words of multi-word values are ignored.
2080.Pp
2081After the input line is aliased and parsed, and before each command is
2082executed, variable substitution is performed keyed by
2083.Sq $
2084characters.
2085This
2086expansion can be prevented by preceding the
2087.Sq $
2088with a
2089.Sq \e
2090except within
2091.Sq "
2092s
2093where it
2094.Va always
2095occurs, and within
2096.Sq
2097's where it
2098.Va never
2099occurs.
2100Strings quoted by
2101.Sq \`
2102are interpreted later (see
2103.Sx Command substitution
2104below) so
2105.Sq $
2106substitution does not occur there until later,
2107if at all.
2108A
2109.Sq $
2110is passed unchanged if followed by a blank, tab, or
2111end-of-line.
2112.Pp
2113Input/output redirections are recognized before variable expansion, and are
2114variable expanded separately.
2115Otherwise, the command name and entire argument
2116list are expanded together.
2117It is thus possible for the first (command) word
2118(to this point) to generate more than one word, the first of which becomes the
2119command name, and the rest of which become arguments.
2120.Pp
2121Unless enclosed in
2122.Sq "
2123or given the
2124.Sq \&:q
2125modifier the results of variable
2126substitution may eventually be command and filename substituted.
2127Within
2128.Sq "
2129, a
2130variable whose value consists of multiple words expands to a (portion of a)
2131single word, with the words of the variable's value separated by blanks.
2132When
2133the
2134.Sq \&:q
2135modifier is applied to a substitution the variable will expand to
2136multiple words with each word separated by a blank and quoted to prevent later
2137command or filename substitution.
2138.Pp
2139The following metasequences are provided for introducing variable values into
2140the shell input.
2141Except as noted, it is an error to reference a variable which
2142is not set.
2143.Pp
2144.Bl -tag -width XXXXXXXXXX -offset indent -compact
2145.PD 0
2146.It Ar $name
2147.It Ar ${name}
2148Substitutes the words of the value of variable
2149.Va name ,
2150each separated
2151by a blank.
2152Braces insulate
2153.Va name
2154from following characters which would
2155otherwise be part of it.
2156Shell variables have names consisting of
2157letters and digits starting with a letter.
2158The underscore character is
2159considered a letter.
2160If
2161.Va name
2162is not a shell variable, but is set in the
2163environment, then that value is returned (but some of the other forms
2164given below are not available in this case).
2165.It Ar $name[selector]
2166.It Ar ${name[selector]}
2167Substitutes only the selected words from the value of
2168.Va name
2169The
2170.Va selector
2171is subjected to
2172.Sq $
2173substitution and may consist of
2174a single number or two numbers separated by a
2175.Sq \&-
2176The first word of a variable's value is numbered
2177.Sq 1
2178If the first number of a range is omitted it defaults to
2179.Sq 1
2180If the last member of a range is omitted it defaults to
2181.Sq $#
2182.Va name
2183The
2184.Va selector
2185.Sq *
2186selects all words.
2187It is not an error for a range to be empty if the
2188second argument is omitted or in range.
2189.It Ar $0
2190Substitutes the name of the file from which command input
2191is being read.
2192An error occurs if the name is not known.
2193.It Ar $number
2194.It Ar ${number}
2195Equivalent to
2196.Sq $argv[number]
2197.It Ar $*
2198Equivalent to
2199.Sq $argv ,
2200which is equivalent to
2201.Sq $argv[*]
2202.El
2203.Pp
2204The
2205.Sq \&:
2206modifiers described under
2207.Sx History substitution ,
2208except for
2209.Sq \&:p ,
2210can be applied to the substitutions above.
2211More than one may be used.
2212(+)
2213Braces may be needed to insulate a variable substitution from a literal colon
2214just as with
2215.Sx History substitution
2216(q.v.); any modifiers must appear
2217within the braces.
2218.Pp
2219The following substitutions can not be modified with
2220.Sq \&:
2221modifiers.
2222.Pp
2223.Bl -tag -width XXXXXXXX -offset indent -compact
2224.It Ar $?name
2225.It Ar ${?name}
2226Substitutes the string
2227.Sq 1
2228if
2229.Va name
2230is set,
2231.Sq 0
2232if it is not.
2233.It Ar $?0
2234Substitutes
2235.Sq 1
2236if the current input filename is known,
2237.Sq 0
2238if it is not.
2239Always
2240.Sq 0
2241in interactive shells.
2242.It Ar
2243$#name
2244${#name}
2245Substitutes the number of words in
2246.Va name
2247.It Ar
2248$#
2249Equivalent to
2250.Sq $#argv
2251(+)
2252.It Ar
2253$%
2254.Va name
2255.It Ar ${%name}
2256Substitutes the number of characters in
2257.Va name
2258(+)
2259.Pp
2260$%
2261.Va number
2262.TP 8
2263.It Ar ${%number}
2264Substitutes the number of characters in
2265.Va $argv[number] .
2266(+)
2267.It Ar $?
2268Equivalent to
2269.Sq $status
2270(+)
2271.It Ar $$
2272Substitutes the (decimal) process number of the (parent) shell.
2273.It Ar $!
2274Substitutes the (decimal) process number of the last
2275background process started by this shell.
2276(+)
2277.It Ar $_
2278Substitutes the command line of the last command executed.
2279(+)
2280.It Ar $<
2281Substitutes a line from the standard input, with no further interpretation
2282thereafter.
2283It can be used to read from the keyboard in a shell script.
2284(+) While
2285.Xr csh 1
2286always quotes $<, as if it were equivalent to
2287.Sq $<:q ,
2288.Nm
2289does not.
2290Furthermore, when
2291.Nm
2292is waiting for a line to be
2293typed the user may type an interrupt to interrupt the sequence into
2294which the line is to be substituted, but
2295.Xr csh 1
2296does not allow this.
2297.El
2298.Pp
2299The editor command
2300.Va expand-variables
2301, normally bound to
2302.Sq ^X-$ ,
2303can be used to interactively expand individual variables.
2304.Ss "Command, filename and directory stack substitution"
2305The remaining substitutions are applied selectively to the arguments
2306of builtin commands.
2307This means that portions of expressions which are not evaluated are
2308not subjected to these expansions.
2309For commands which are not internal to the
2310shell, the command name is substituted separately from the argument list.
2311This occurs very late, after input-output redirection is performed, andk
2312in a child of the main shell.
2313.Ss "Command substitution"
2314Command substitution is indicated by a command enclosed in
2315.Sq \&`
2316The output
2317from such a command is broken into separate words at blanks, tabs and newlines,
2318and null words are discarded.
2319The output is variable and command substituted
2320and put in place of the original string.
2321.Pp
2322Command substitutions inside double
2323quotes
2324.Sq ( \&" )
2325retain blanks and tabs; only newlines force new words.
2326The single
2327final newline does not force a new word in any case.
2328It is thus possible for a
2329command substitution to yield only part of a word, even if the command outputs
2330a complete line.
2331.Pp
2332By default, the shell since version 6.12 replaces all newline and carriage
2333return characters in the command by spaces.
2334If this is switched off by
2335unsetting
2336.Va csubstnonl ,
2337newlines separate commands as usual.
2338.Ss "Filename substitution"
2339If a word contains any of the characters
2340.Sq * ,
2341.Sq \&? ,
2342.Sq \&[
2343or
2344.Sq {
2345or begins with
2346the character
2347.Sq ~
2348it is a candidate for filename substitution, also known as
2349.Dq globbing .
2350This word is then regarded as a pattern
2351.Dq ( glob-pattern ) ,
2352and
2353replaced with an alphabetically sorted list of file names which match the
2354pattern.
2355.Pp
2356In matching filenames, the character
2357.Sq .
2358at the beginning of a filename or
2359immediately following a
2360.Sq / ,
2361as well as the character
2362.Sq /
2363must be matched
2364explicitly (unless either
2365.Va globdot
2366or
2367.Va globstar
2368or both are set(+)).
2369The character
2370.Sq *
2371matches any string of characters,
2372including the null string.
2373The character
2374.Sq \&?
2375matches any single character.
2376The sequence
2377.Sq [...]
2378matches any one of the characters enclosed.
2379Within
2380.Sq [...]
2381, a pair of
2382characters separated by
2383.Sq \&-
2384matches any character lexically between the two.
2385.Pp
2386(+) Some glob-patterns can be negated:
2387The sequence
2388.Sq [^...]
2389matches any single character
2390.Va not
2391specified by the
2392characters and/or ranges of characters in the braces.
2393.Pp
2394An entire glob-pattern can also be negated with
2395.Sq ^ :
2396.Bd -literal -offset indent
2397> echo *
2398bang crash crunch ouch
2399> echo ^cr*
2400bang ouch
2401.Ed
2402.Pp
2403Glob-patterns which do not use
2404.Sq \&? ,
2405.Sq * , or
2406.Sq []
2407or which use
2408.Sq {}
2409or
2410.Sq ~
2411(below) are not negated correctly.
2412.Pp
2413The metanotation
2414.Sq a{b,c,d}e
2415is a shorthand for
2416.Sq abe ace ade
2417Left-to-right order is preserved:
2418.Sq /usr/source/s1/{oldls,ls}.c
2419expands
2420to
2421.Sq /usr/source/s1/oldls.c /usr/source/s1/ls.c
2422The results of matches are
2423sorted separately at a low level to preserve this order:
2424.Sq ../{memo,*box}
2425might expand to
2426.Sq ../memo ../box ../mbox
2427(Note that
2428.Sq memo
2429was not sorted with the results of matching
2430.Sq *box . )
2431It is not an error when this construct expands to files which do not exist,
2432but it is possible to get an error from a command to which the expanded list
2433is passed.
2434This construct may be nested.
2435As a special case the words
2436.Sq { ,
2437.Sq }
2438and
2439.Sq {}
2440are passed undisturbed.
2441.Pp
2442The character
2443.Sq ~
2444at the beginning of a filename refers to home directories.
2445Standing alone, i.e.,
2446.Sq ~ ,
2447it expands to the invoker's home directory as
2448reflected in the value of the
2449.Va home
2450shell variable.
2451When followed by a
2452name consisting of letters, digits and
2453.Sq \&-
2454characters the shell searches for a
2455user with that name and substitutes their home directory; thus
2456.Sq ~ken
2457might
2458expand to
2459.Sq /usr/ken
2460and
2461.Sq ~ken/chmach
2462to
2463.Sq /usr/ken/chmach
2464If the character
2465.Sq ~
2466is followed by a character other than a letter or
2467.Sq /
2468or appears elsewhere
2469than at the beginning of a word, it is left undisturbed.
2470A command like
2471.Sq setenv MANPATH /usr/man:/usr/local/man:~/lib/man
2472does not,
2473therefore, do home directory substitution as one might hope.
2474.Pp
2475It is an error for a glob-pattern containing
2476.Sq * ,
2477.Sq \&?  ,
2478.Sq \&[
2479or
2480.Sq ~ ,
2481with or
2482without
2483.Sq ^ ,
2484not to match any files.
2485However, only one pattern in a list of
2486glob-patterns must match a file (so that, e.g.,
2487.Sq rm *.a *.c *.o
2488would fail
2489only if there were no files in the current directory ending in
2490.Sq .a ,
2491.Sq .c ,
2492or
2493.Sq .o ) ,
2494and if the
2495.Va nonomatch
2496shell variable is set a pattern (or list
2497of patterns) which matches nothing is left unchanged rather than causing
2498an error.
2499.Pp
2500The
2501.Va globstar
2502shell variable can be set to allow
2503.Sq **
2504or
2505.Sq ***
2506as
2507a file glob pattern that matches any string of characters including
2508.Sq / ,
2509recursively traversing any existing sub-directories.
2510For example,
2511.Sq ls **.c
2512will list all the .c files in the current directory tree.
2513If used by itself, it will match zero or more sub-directories
2514(e.g.
2515.Sq ls /usr/include/**/time.h
2516will list any file named
2517.Sq time.h
2518in the /usr/include directory tree;
2519.Sq ls /usr/include/**time.h
2520will match
2521any file in the /usr/include directory tree ending in
2522.Sq time.h ;
2523and
2524.Sq ls /usr/include/**time**.h
2525will match any .h file with
2526.Sq time
2527either
2528in a subdirectory name or in the filename itself).
2529To prevent problems with recursion, the
2530.Sq **
2531glob-pattern will not
2532descend into a symbolic link containing a directory.
2533To override this,
2534use
2535.Sq ***
2536(+)
2537.Pp
2538The
2539.Va noglob
2540shell variable can be set to prevent filename substitution,
2541and the
2542.Va expand-glob
2543editor command, normally bound to
2544.Sq ^X-* ,
2545can be
2546used to interactively expand individual filename substitutions.
2547.Ss "Directory stack substitution (+)"
2548The directory stack is a list of directories, numbered from zero, used by the
2549.Va pushd ,
2550.Va popd
2551and
2552.Va dirs
2553builtin commands (q.v.).
2554.Va dirs
2555can print, store in a file, restore and clear the directory stack
2556at any time, and the
2557.Va savedirs
2558and
2559.Va dirsfile
2560shell variables can be set to
2561store the directory stack automatically on logout and restore it on login.
2562The
2563.Va dirstack
2564shell variable can be examined to see the directory stack and
2565set to put arbitrary directories into the directory stack.
2566.Pp
2567The character
2568.Sq =
2569followed by one or more digits expands to an entry in
2570the directory stack.
2571The special case
2572.Sq =-
2573expands to the last directory in
2574the stack.
2575For example,
2576.Bd -literal -offset indent
2577> dirs \&-v
25780       /usr/bin
25791       /usr/spool/uucp
25802       /usr/accts/sys
2581> echo =1
2582/usr/spool/uucp
2583> echo =0/calendar
2584/usr/bin/calendar
2585> echo =\-
2586/usr/accts/sys
2587.Ed
2588.Pp
2589The
2590.Va noglob
2591and
2592.Va nonomatch
2593shell variables and the
2594.Va expand-glob
2595editor command apply to directory stack as well as filename substitutions.
2596.Ss "Other substitutions (+)"
2597There are several more transformations involving filenames, not strictly
2598related to the above but mentioned here for completeness.
2599.Va Any
2600filename may be expanded to a full path when the
2601.Va symlinks
2602variable (q.v.) is set to
2603.Sq expand
2604Quoting prevents this expansion, and
2605the
2606.Va normalize-path
2607editor command does it on demand.
2608The
2609.Va normalize-command
2610editor command expands commands in PATH into
2611full paths on demand.
2612Finally,
2613.Va cd
2614and
2615.Va pushd
2616interpret
2617.Sq \&-
2618as the old working directory
2619(equivalent to the shell variable
2620.Va owd ) .
2621This is not a substitution at all, but an abbreviation recognized by only
2622those commands.
2623Nonetheless, it too can be prevented by quoting.
2624.Ss "Commands"
2625The next three sections describe how the shell executes commands and
2626deals with their input and output.
2627.Ss "Simple commands, pipelines and sequences"
2628A simple command is a sequence of words, the first of which specifies the
2629command to be executed.
2630A series of simple commands joined by
2631.Sq |
2632characters
2633forms a pipeline.
2634The output of each command in a pipeline is connected to the
2635input of the next.
2636.Pp
2637Simple commands and pipelines may be joined into sequences with
2638.Sq ; ,
2639and will
2640be executed sequentially.
2641Commands and pipelines can also be joined into
2642sequences with
2643.Sq ||
2644or
2645.Sq && ,
2646indicating, as in the C language, that the second
2647is to be executed only if the first fails or succeeds respectively.
2648.Pp
2649A simple command, pipeline or sequence may be placed in parentheses,
2650.Sq () ,
2651to form a simple command, which may in turn be a component of a pipeline or
2652sequence.
2653A command, pipeline or sequence can be executed
2654without waiting for it to terminate by following it with an
2655.Sq \&& .
2656.Ss "Builtin and non-builtin command execution"
2657Builtin commands are executed within the shell.
2658If any component of a
2659pipeline except the last is a builtin command, the pipeline is executed
2660in a subshell.
2661.Pp
2662Parenthesized commands are always executed in a subshell.
2663.Bd -literal -offset indent
2664(cd; pwd); pwd
2665.Ed
2666.Pp
2667thus prints the
2668.Va home
2669directory, leaving you where you were
2670(printing this after the home directory), while
2671.Bd -literal -offset indent
2672cd; pwd
2673.Ed
2674.Pp
2675leaves you in the
2676.Va home
2677directory.
2678Parenthesized commands are most often
2679used to prevent
2680.Va cd
2681from affecting the current shell.
2682.Pp
2683When a command to be executed is found not to be a builtin command the shell
2684attempts to execute the command via
2685.Xr execve 2 .
2686Each word in the variable
2687.Va path
2688names a directory in which the shell will look for the
2689command.
2690If the shell is not given a
2691.Fl f
2692option, the shell
2693hashes the names in these directories into an internal table so that it will
2694try an
2695.Xr execve 2
2696in only a directory where there is a possibility that the
2697command resides there.
2698This greatly speeds command location when a large
2699number of directories are present in the search path. This hashing mechanism is
2700not used:
2701.TP 4
2702.Bl -enum -width indent
2703.It
2704If hashing is turned explicitly off via
2705.Va unhash
2706.It
2707If the shell was given a
2708.Fl f Ar argument
2709.It
2710For each directory component of
2711.Va path
2712which does not begin with a
2713.Sq /
2714.It
2715If the command contains a
2716.Sq /
2717.El
2718.Pp
2719In the above four cases the shell concatenates each component of the path
2720vector with the given command name to form a path name of a file which it
2721then attempts to execute it. If execution is successful, the search stops.
2722.Pp
2723If the file has execute permissions but is not an executable to the system
2724(i.e., it is neither an executable binary nor a script that specifies its
2725interpreter), then it is assumed to be a file containing shell commands and
2726a new shell is spawned to read it.
2727The
2728.Va shell
2729special alias may be set
2730to specify an interpreter other than the shell itself.
2731.Pp
2732On systems which do not understand the
2733.Sq #!
2734script interpreter convention
2735the shell may be compiled to emulate it; see the
2736.Va version
2737shell
2738variable.
2739If so, the shell checks the first line of the file to
2740see if it is of the form
2741.Sq #!interpreter arg ...
2742If it is,
2743the shell starts
2744.Va interpreter
2745with the given
2746.Va arg
2747s and feeds the
2748file to it on standard input.
2749.Ss "Input/output"
2750The standard input and standard output of a command may be redirected with the
2751following syntax:
2752.Pp
2753.Bl -tag -width XXXXXX -offset indent -compact
2754.It Ar < name
2755Open file
2756.Va name
2757(which is first variable, command and filename
2758expanded) as the standard input.
2759.It Ar << word
2760Read the shell input up to a line which is identical to
2761.Va word .
2762.Va word
2763is not subjected to variable, filename or command substitution, and each input
2764line is compared to
2765.Va word
2766before any substitutions are done on this input
2767line.
2768Unless a quoting
2769.Sq \e ,
2770.Sq \&"
2771,
2772.Sq \&'
2773or
2774.Sq \&`
2775appears in
2776.Va word
2777variable and
2778command substitution is performed on the intervening lines, allowing
2779.Sq \e
2780to
2781quote
2782.Sq $ ,
2783.Sq \e
2784and
2785.Sq \&` .
2786Commands which are substituted have all blanks, tabs,
2787and newlines preserved, except for the final newline which is dropped.
2788The
2789resultant text is placed in an anonymous temporary file which is given to the
2790command as standard input.
2791.Pp
2792.It Ar > name
2793.It Ar >! name
2794.It Ar >& name
2795.It Ar >&! name
2796The file
2797.Va name
2798is used as standard output.
2799If the file does not exist
2800then it is created; if the file exists, it is truncated, its previous contents
2801being lost.
2802.Pp
2803If the shell variable
2804.Va noclobber
2805is set, then the file must not exist or be a
2806character special file (e.g., a terminal or
2807.Sq /dev/null )
2808or an error results.
2809This helps prevent accidental destruction of files.
2810In this case the
2811.Sq \&!
2812forms
2813can be used to suppress this check.
2814If
2815.Va notempty
2816is given in
2817.Va noclobber ,
2818.Sq >
2819is allowed on empty files;
2820if
2821.Va ask
2822is set, an interacive confirmation is presented, rather than an
2823error.
2824.Pp
2825The forms involving
2826.Sq \&&
2827route the diagnostic output into the specified file as
2828well as the standard output.
2829.Va name
2830is expanded in the same way as
2831.Sq <
2832input filenames are.
2833.Pp
2834.It Ar >> name
2835.It Ar >>& name
2836.It Ar >>! name
2837.It Ar >>&! name
2838Like
2839.Sq >
2840, but appends output to the end of
2841.Va name
2842If the shell variable
2843.Va noclobber
2844is set, then it is an error for
2845the file
2846.Va not
2847to exist, unless one of the
2848.Sq \&!
2849forms is given.
2850.El
2851.Pp
2852A command receives the environment in which the shell was invoked as modified
2853by the input-output parameters and the presence of the command in a pipeline.
2854Thus, unlike some previous shells, commands run from a file of shell commands
2855have no access to the text of the commands by default; rather they receive the
2856original standard input of the shell.
2857The
2858.Sq <<
2859mechanism should be used to
2860present inline data.
2861This permits shell command scripts to function as
2862components of pipelines and allows the shell to block read its input.
2863Note
2864that the default standard input for a command run detached is
2865.Va not
2866the empty file
2867.Va /dev/null ,
2868but the original standard input of the shell.
2869If this is a terminal and if the process attempts to read from the terminal,
2870then the process will block and the user will be notified (see
2871.Sx Jobs ) .
2872.Pp
2873Diagnostic output may be directed through a pipe with the standard output.
2874Simply use the form
2875.Sq |&
2876rather than just
2877.Sq | .
2878.Pp
2879The shell cannot presently redirect diagnostic output without also redirecting
2880standard output, but
2881.Sq \&( command > output-file ) >&  error-file
2882is often an acceptable workaround.
2883Either
2884.Va output-file
2885or
2886.Va error-file
2887may be
2888.Sq /dev/tty
2889to send output to the terminal.
2890.Ss "Features"
2891Having described how the shell accepts, parses and executes
2892command lines, we now turn to a variety of its useful features.
2893.Ss "Control flow"
2894The shell contains a number of commands which can be used to regulate the
2895flow of control in command files (shell scripts) and (in limited but
2896useful ways) from terminal input.
2897These commands all operate by forcing the
2898shell to reread or skip in its input and, due to the implementation,
2899restrict the placement of some of the commands.
2900.Pp
2901The
2902.Va foreach ,
2903.Va switch ,
2904and
2905.Va while
2906statements, as well as the
2907.Va if-then-else
2908form of the
2909.Va if
2910statement, require that the major
2911keywords appear in a single simple command on an input line as shown below.
2912.Pp
2913If the shell's input is not seekable, the shell buffers up input whenever
2914a loop is being read and performs seeks in this internal buffer to
2915accomplish the rereading implied by the loop.
2916(To the extent that this allows, backward
2917.Va goto
2918s will succeed on non-seekable inputs.)
2919.Ss "Expressions"
2920The
2921.Va if ,
2922.Va while
2923and
2924.Va exit
2925builtin commands
2926use expressions with a common syntax.
2927The expressions can include any
2928of the operators described in the next three sections.
2929Note that the
2930.Va @
2931builtin command (q.v.) has its own separate syntax.
2932.Ss "Logical, arithmetical and comparison operators"
2933These operators are similar to those of C and have the same precedence.
2934They include
2935.IP "" 4
2936.Bl -tag -width XXXXXX -offset indent -compact
2937.It ||  &&  |   &  ==  !=  =~  !~  <=  >=
2938.It <  > <<  >>  +  \-  *  /  %  !  ~  (  )
2939.El
2940.Pp
2941Here the precedence increases to the right,
2942.Sq ==
2943.Sq \&!=
2944.Sq =~
2945and
2946.Sq \&!~ ,
2947.Sq <=
2948.Sq >=
2949.Sq <
2950and
2951.Sq > ,
2952.Sq <<
2953.Sq >> ,
2954.Sq +
2955and
2956.Sq \&- ,
2957.Sq *
2958.Sq /
2959and
2960.Sq %
2961being, in
2962groups, at the same level.
2963The
2964.Sq ==
2965.Sq \&!=
2966.Sq =~
2967and
2968.Sq \&!~
2969operators compare
2970their arguments as strings; all others operate on numbers.
2971The operators
2972.Sq =~
2973and
2974.Sq \&!~
2975are like
2976.Sq \&!=
2977and
2978.Sq ==
2979except that the right hand side is a
2980glob-pattern (see
2981.Sx Filename substitution )
2982against which the left hand operand is matched.
2983This reduces the need for use of the
2984.Va switch
2985builtin command in shell scripts when all that is really needed is
2986pattern matching.
2987.Pp
2988Null or
2989missing arguments are considered
2990.Sq 0
2991The results of all expressions are
2992strings, which represent decimal numbers.
2993It is important to note that
2994no two components of an expression can appear in the same word; except
2995when adjacent to components of expressions which are syntactically
2996significant to the parser
2997.Sq ( \&&
2998.Sq |
2999.Sq <
3000.Sq >
3001.Sq \&(
3002.Sq \&) )
3003they should be
3004surrounded by spaces.
3005.Ss "Command exit status"
3006Commands can be executed in expressions and their exit status
3007returned by enclosing them in braces
3008.Sq ( {} ) .
3009Remember that the braces should
3010be separated from the words of the command by spaces.
3011Command executions
3012succeed, returning true, i.e.,
3013.Sq 1 ,
3014if the command exits with status 0,
3015otherwise they fail, returning false, i.e.,
3016.Sq 0 .
3017If more detailed status
3018information is required then the command should be executed outside of an
3019expression and the
3020.Va status
3021shell variable examined.
3022.Ss "File inquiry operators"
3023Some of these operators perform true/false tests on files and related
3024objects.
3025They are of the form
3026.Fl
3027.Va op file
3028, where
3029.Va op
3030is one of
3031.Bl -tag -width XXX -offset indent -compact
3032.It Ar r
3033Read access
3034.It Ar w
3035Write access
3036.It Ar x
3037Execute access
3038.It Ar X
3039Executable in the path or shell builtin, e.g.,
3040.Sq \&-X ls
3041and
3042.Sq \&-X ls\&-F
3043are
3044generally true, but
3045.Sq \&-X /bin/ls
3046is not (+)
3047.It Ar e
3048Existence
3049.It Ar o
3050Ownership
3051.It Ar z
3052Zero size
3053.It Ar s
3054Non-zero size (+)
3055.It Ar f
3056Plain file
3057.It Ar d
3058Directory
3059.It Ar l
3060Symbolic link (+) *
3061.It Ar b
3062Block special file (+)
3063.It Ar c
3064Character special file (+)
3065.It Ar p
3066Named pipe (fifo) (+) *
3067.It Ar S
3068Socket special file (+) *
3069.It Ar u
3070Set-user-ID bit is set (+)
3071.It Ar g
3072Set-group-ID bit is set (+)
3073.It Ar k
3074Sticky bit is set (+)
3075.It Ar t file
3076(which must be a digit) is an open file descriptor
3077for a terminal device (+)
3078.It Ar R
3079Has been migrated (Convex only) (+)
3080.It Ar L
3081Applies subsequent operators in a multiple-operator test to a symbolic link
3082rather than to the file to which the link points (+) *
3083.El
3084.Pp
3085.Va file
3086is command and filename expanded and then tested to
3087see if it has the specified relationship to the real user.
3088If
3089.Va file
3090does not exist or is inaccessible or, for the operators indicated by
3091.Sq * ,
3092if the specified file type does not exist on the current system,
3093then all inquiries return false, i.e.,
3094.Sq 0 .
3095.Pp
3096These operators may be combined for conciseness:
3097.Sq \&-
3098.Va xy file
3099is
3100equivalent to
3101.Sq \&-x file && \&-y file .
3102(+) For example,
3103.Sq \&-fx
3104is true
3105(returns
3106.Sq 1 )
3107for plain executable files, but not for directories.
3108.Pp
3109.Va L
3110may be used in a multiple-operator test to apply subsequent operators
3111to a symbolic link rather than to the file to which the link points.
3112For example,
3113.Sq \&-lLo
3114is true for links owned by the invoking user.
3115.Va Lr ,
3116.Va Lw
3117and
3118.Va Lx
3119are always true for links and false for
3120non-links.
3121.Va L
3122has a different meaning when it is the last operator
3123in a multiple-operator test; see below.
3124.Pp
3125It is possible but not useful, and sometimes misleading, to combine operators
3126which expect
3127.Va file
3128to be a file with operators which do not
3129(e.g.,
3130.Va X
3131and
3132.Va t ) .
3133Following
3134.Va L
3135with a non-file operator
3136can lead to particularly strange results.
3137.Pp
3138Other operators return other information, i.e., not just
3139.Sq 0
3140or
3141.Sq 1
3142(+)
3143They have the same format as before;
3144.Va op
3145may be one of
3146.Pp
3147.PD 0
3148.RS +4
3149.TP 8
3150.B A
3151Last file access time, as the number of seconds since the epoch
3152.TP 8
3153.B A:
3154Like
3155.Va A
3156, but in timestamp format, e.g.,
3157.Sq Fri May 14 16:36:10 1993
3158.TP 8
3159.B M
3160Last file modification time
3161.TP 8
3162.B M:
3163Like
3164.Va M
3165, but in timestamp format
3166.TP 8
3167.B C
3168Last inode modification time
3169.TP 8
3170.B C:
3171Like
3172.Va C
3173, but in timestamp format
3174.TP 8
3175.B D
3176Device number
3177.TP 8
3178.B I
3179Inode number
3180.TP 8
3181.B F
3182Composite
3183.Va f
3184ile identifier, in the form
3185.Va device
3186:
3187.Va inode
3188.TP 8
3189.B L
3190The name of the file pointed to by a symbolic link
3191.TP 8
3192.B N
3193Number of (hard) links
3194.TP 8
3195.B P
3196Permissions, in octal, without leading zero
3197.TP 8
3198.B P:
3199Like
3200.Va P
3201, with leading zero
3202.TP 8
3203.B P\fImode
3204Equivalent to
3205.Sq \-P
3206.Va file
3207&
3208.Va mode
3209, e.g.,
3210.Sq \-P22
3211.Va file
3212returns
3213`22' if
3214.Va file
3215is writable by group and other,
3216.Sq 20
3217if by group only,
3218and
3219.Sq 0
3220if by neither
3221.TP 8
3222.B P\fImode\fB:
3223Like \fBP
3224.Va mode
3225, with leading zero
3226.TP 8
3227.B U
3228Numeric userid
3229.TP 8
3230.B U:
3231Username, or the numeric userid if the username is unknown
3232.TP 8
3233.B G
3234Numeric groupid
3235.TP 8
3236.B G:
3237Groupname, or the numeric groupid if the groupname is unknown
3238.TP 8
3239.B Z
3240Size, in bytes
3241.RE
3242.PD
3243.Pp
3244Only one of these operators may appear in a multiple-operator test, and it
3245must be the last.
3246Note that
3247.Va L
3248has a different meaning at the end of and
3249elsewhere in a multiple-operator test.
3250Because
3251.Sq 0
3252is a valid return value
3253for many of these operators, they do not return
3254.Sq 0
3255when they fail: most
3256return
3257.Sq \&-1
3258, and
3259.Va F
3260returns
3261.Sq \&:
3262.Pp
3263If the shell is compiled with POSIX defined (see the
3264.Va version
3265shell
3266variable), the result of a file inquiry is based on the permission bits of
3267the file and not on the result of the
3268.Va access
3269(2) system call.
3270For example, if one tests a file with
3271.Fl w\fR whose permissions would
3272ordinarily allow writing but which is on a file system mounted read-only,
3273the test will succeed in a POSIX shell but fail in a non-POSIX shell.
3274.Pp
3275File inquiry operators can also be evaluated with the
3276.Va filetest
3277builtin
3278command (q.v.) (+).
3279.Ss Jobs
3280The shell associates a
3281.Va job
3282with each pipeline.
3283It keeps a table of
3284current jobs, printed by the
3285.Va jobs
3286command, and assigns them small integer
3287numbers.
3288When a job is started asynchronously with
3289.Sq &
3290, the shell prints a
3291line which looks like
3292.IP "" 4
3293[1] 1234
3294.Pp
3295indicating that the job which was started asynchronously was job number 1 and
3296had one (top-level) process, whose process id was 1234.
3297.Pp
3298If you are running a job and wish to do something else you may hit the suspend
3299key (usually
3300.Sq ^Z ) ,
3301which sends a STOP signal to the current job.
3302The shell will then normally
3303indicate that the job has been
3304.Sq Suspended
3305and print another prompt.
3306If the
3307.Va listjobs
3308shell variable is set, all jobs will be listed
3309like the
3310.Va jobs
3311builtin command; if it is set to
3312.Sq long
3313the listing will
3314be in long format, like
3315.Sq jobs \&-l
3316You can then manipulate the state of the suspended job.
3317You can put it in the
3318.Dq background
3319 with the
3320.Va bg
3321command or run some other commands and
3322eventually bring the job back into the
3323.Sq foreground
3324' with
3325.Va fg
3326(See also the
3327.Va run-fg-editor
3328editor command.)
3329A
3330.Sq ^Z
3331takes effect immediately and is like an interrupt
3332in that pending output and unread input are discarded when it is typed.
3333The
3334.Va wait
3335builtin command causes the shell to wait for all background
3336jobs to complete.
3337.Pp
3338The
3339.Sq ^]
3340key sends a delayed suspend signal, which does not generate a STOP
3341signal until a program attempts to
3342.Va read
3343(2) it, to the current job.
3344This can usefully be typed ahead when you have prepared some commands for a
3345job which you wish to stop after it has read them.
3346The
3347.Sq ^Y
3348key performs this function in
3349.Xr csh 1
3350; in
3351.Nm
3352,
3353`^Y' is an editing command.
3354(+)
3355.Pp
3356A job being run in the background stops if it tries to read from the
3357terminal.
3358Background jobs are normally allowed to produce output, but this can
3359be disabled by giving the command
3360.Sq stty tostop
3361If you set this tty option,
3362then background jobs will stop when they try to produce output like they do
3363when they try to read input.
3364.Pp
3365There are several ways to refer to jobs in the shell.
3366The character
3367.Sq %
3368introduces a job name.
3369If you wish to refer to job number 1, you can name it
3370as
3371.Sq %1
3372Just naming a job brings it to the foreground; thus
3373.Sq %1
3374is a synonym
3375for
3376.Sq fg %1
3377, bringing job 1 back into the foreground.
3378Similarly, saying
3379.Sq %1 &
3380resumes job 1 in the background, just like
3381.Sq bg %1
3382A job can also be named
3383by an unambiguous prefix of the string typed in to start it:
3384.Sq %ex
3385would
3386normally restart a suspended
3387.Va ex
3388(1) job, if there were only one suspended
3389job whose name began with the string
3390.Sq ex
3391It is also possible to say
3392`%?
3393.Va string
3394' to specify a job whose text contains
3395.Va string
3396, if there
3397is only one such job.
3398.Pp
3399The shell maintains a notion of the current and previous jobs.
3400In output
3401pertaining to jobs, the current job is marked with a
3402.Sq +
3403and the previous job
3404with a
3405.Sq \-
3406The abbreviations
3407.Sq %+
3408,
3409.Sq %
3410, and (by analogy with the syntax of
3411the
3412.Va history
3413mechanism)
3414.Sq %%
3415all refer to the current job, and
3416.Sq %\-
3417refers
3418to the previous job.
3419.Pp
3420The job control mechanism requires that the
3421.Va stty
3422(1) option
3423.Sq new
3424be set
3425on some systems.
3426It is an artifact from a
3427.Sq new
3428implementation of the tty
3429driver which allows generation of interrupt characters from the keyboard to
3430tell jobs to stop.
3431See
3432.Va stty
3433(1) and the
3434.Va setty
3435builtin command for
3436details on setting options in the new tty driver.
3437.Ss "Status reporting"
3438The shell learns immediately whenever a process changes state.
3439It normally
3440informs you whenever a job becomes blocked so that no further progress is
3441possible, but only right before it prints a prompt.
3442This is done so that it
3443does not otherwise disturb your work.
3444If, however, you set the shell variable
3445.Va notify
3446, the shell will notify you immediately of changes of status in
3447background jobs.
3448There is also a shell command
3449.Va notify
3450which marks a
3451single process so that its status changes will be immediately reported.
3452By
3453default
3454.Va notify
3455marks the current process; simply say
3456.Sq notify
3457after
3458starting a background job to mark it.
3459.Pp
3460When you try to leave the shell while jobs are stopped, you will be
3461warned that
3462.Sq There are suspended jobs.
3463You may use the
3464.Va jobs
3465command to
3466see what they are.
3467If you do this or immediately try to exit again, the shell
3468will not warn you a second time, and the suspended jobs will be terminated.
3469.Ss "Automatic, periodic and timed events (+)"
3470There are various ways to run commands and take other actions automatically
3471at various times in the
3472.Sq `life cycle
3473' of the shell.
3474They are summarized here,
3475and described in detail under the appropriate
3476.Va Builtin commands
3477,
3478.Va Special shell variables
3479and
3480.Va Special aliases
3481.Pp
3482The
3483.Va sched
3484builtin command puts commands in a scheduled-event list,
3485to be executed by the shell at a given time.
3486.Pp
3487The
3488.Va beepcmd
3489,
3490.Va cwdcmd
3491,
3492.Va periodic
3493,
3494.Va precmd
3495,
3496.Va postcmd
3497,
3498and
3499.Va jobcmd
3500.Va Special aliases
3501can be set, respectively, to execute commands when the shell wants
3502to ring the bell, when the working directory changes, every
3503.Va tperiod
3504minutes, before each prompt, before each command gets executed, after each
3505command gets executed, and when a job is started or is brought into the
3506foreground.
3507.Pp
3508The
3509.Va autologout
3510shell variable can be set to log out or lock the shell
3511after a given number of minutes of inactivity.
3512.Pp
3513The
3514.Va mail
3515shell variable can be set to check for new mail periodically.
3516.Pp
3517The
3518.Va printexitvalue
3519shell variable can be set to print the exit status
3520of commands which exit with a status other than zero.
3521.Pp
3522The
3523.Va rmstar
3524shell variable can be set to ask the user, when
3525.Sq rm *
3526is
3527typed, if that is really what was meant.
3528.Pp
3529The
3530.Va time
3531shell variable can be set to execute the
3532.Va time
3533builtin
3534command after the completion of any process that takes more than a given
3535number of CPU seconds.
3536.Pp
3537The
3538.Va watch
3539and
3540.Va who
3541shell variables can be set to report when
3542selected users log in or out, and the
3543.Va log
3544builtin command reports
3545on those users at any time.
3546.Ss "Native Language System support (+)"
3547The shell is eight bit clean
3548(if so compiled; see the
3549.Va version
3550shell variable)
3551and thus supports character sets needing this capability.
3552NLS support differs depending on whether or not
3553the shell was compiled to use the system's NLS (again, see
3554.Va version
3555).
3556In either case, 7-bit ASCII is the default character code
3557(e.g., the classification of which characters are printable) and sorting,
3558and changing the
3559.Va LANG
3560or
3561.Va LC_CTYPE
3562environment variables
3563causes a check for possible changes in these respects.
3564.Pp
3565When using the system's NLS, the
3566.Va setlocale
3567(3) function is called
3568to determine appropriate character code/classification and sorting
3569(e.g., a 'en_CA.UTF-8' would yield "UTF-8" as a character code).
3570This function typically examines the
3571.Va LANG
3572and
3573.Va LC_CTYPE
3574environment variables; refer to the system documentation for further details.
3575When not using the system's NLS, the shell simulates it by assuming that the
3576ISO 8859-1 character set is used
3577whenever either of the
3578.Va LANG
3579and
3580.Va LC_CTYPE
3581variables are set, regardless of
3582their values.
3583Sorting is not affected for the simulated NLS.
3584.Pp
3585In addition, with both real and simulated NLS, all printable
3586characters in the range \e200\-\e377, i.e., those that have
3587M-
3588.Va char
3589bindings, are automatically rebound to
3590.Va self-insert-command
3591The corresponding binding for the escape-
3592.Va char
3593sequence, if any, is
3594left alone.
3595These characters are not rebound if the
3596.Va NOREBIND
3597environment variable
3598is set.
3599This may be useful for the simulated NLS or a primitive real NLS
3600which assumes full ISO 8859-1.
3601Otherwise, all M-
3602.Va char
3603bindings in the
3604range \e240\-\e377 are effectively undone.
3605Explicitly rebinding the relevant keys with
3606.Va bindkey
3607is of course still possible.
3608.Pp
3609Unknown characters (i.e., those that are neither printable nor control
3610characters) are printed in the format \ennn.
3611If the tty is not in 8 bit mode, other 8 bit characters are printed by
3612converting them to ASCII and using standout mode.
3613The shell
3614never changes the 7/8 bit mode of the tty and tracks user-initiated
3615changes of 7/8 bit mode.
3616NLS users (or, for that matter, those who want to
3617use a meta key) may need to explicitly set
3618the tty in 8 bit mode through the appropriate
3619.Va stty
3620(1)
3621command in, e.g., the
3622.Va ~/.login
3623file.
3624.Ss "OS variant support (+)"
3625A number of new builtin commands are provided to support features in
3626particular operating systems.
3627All are described in detail in the
3628.Va Builtin commands
3629section.
3630.Pp
3631On systems that support TCF (aix-ibm370, aix-ps2),
3632.Va getspath
3633and
3634.Va setspath
3635get and set the system execution path,
3636.Va getxvers
3637and
3638.Va setxvers
3639get and set the experimental version prefix
3640and
3641.Va migrate
3642migrates processes between sites.
3643The
3644.Va jobs
3645builtin
3646prints the site on which each job is executing.
3647.Pp
3648Under BS2000,
3649.Va bs2cmd
3650executes commands of the underlying BS2000/OSD
3651operating system.
3652.Pp
3653Under Domain/OS,
3654.Va inlib
3655adds shared libraries to the current environment,
3656.Va rootnode
3657changes the rootnode and
3658.Va ver
3659changes the systype.
3660.Pp
3661Under Mach,
3662.Va setpath
3663is equivalent to Mach's
3664.Va setpath
3665(1).
3666.Pp
3667Under Masscomp/RTU and Harris CX/UX,
3668.Va universe
3669sets the universe.
3670.Pp
3671Under Harris CX/UX,
3672.Va ucb
3673or
3674.Va att
3675runs a command under the specified
3676universe.
3677.Pp
3678Under Convex/OS,
3679.Va warp
3680prints or sets the universe.
3681.Pp
3682The
3683.Va VENDOR
3684,
3685.Va OSTYPE
3686and
3687.Va MACHTYPE
3688environment variables
3689indicate respectively the vendor, operating system and machine type
3690(microprocessor class or machine model) of the
3691system on which the shell thinks it is running.
3692These are particularly useful when sharing one's home directory between several
3693types of machines; one can, for example,
3694.IP "" 4
3695set path = (~/bin.$MACHTYPE /usr/ucb /bin /usr/bin .)
3696.Pp
3697in one's
3698.Va ~/.login
3699and put executables compiled for each machine in the
3700appropriate directory.
3701.Pp
3702The
3703.Va version
3704shell
3705variable indicates what options were chosen when the shell was compiled.
3706.Pp
3707Note also the
3708.Va newgrp
3709builtin, the
3710.Va afsuser
3711and
3712.Va echo_style
3713shell variables and the system-dependent locations of
3714the shell's input files (see
3715.Va FILES
3716).
3717.Ss "Signal handling"
3718Login shells ignore interrupts when reading the file
3719.Va ~/.logout
3720The shell ignores quit signals unless started with
3721.Fl q\fR.
3722Login shells catch the terminate signal, but non-login shells inherit the
3723terminate behavior from their parents.
3724Other signals have the values which the shell inherited from its parent.
3725.Pp
3726In shell scripts, the shell's handling of interrupt and terminate signals
3727can be controlled with
3728.Va onintr
3729, and its handling of hangups can be
3730controlled with
3731.Va hup
3732and
3733.Va nohup
3734.Pp
3735The shell exits on a hangup (see also the
3736.Va logout
3737shell variable).
3738By
3739default, the shell's children do too, but the shell does not send them a
3740hangup when it exits.
3741.Va hup
3742arranges for the shell to send a hangup to
3743a child when it exits, and
3744.Va nohup
3745sets a child to ignore hangups.
3746.Ss "Terminal management (+)"
3747The shell uses three different sets of terminal (
3748.Dq tty
3749) modes:
3750`edit', used when editing,
3751.Sq quote
3752, used when quoting literal characters,
3753and
3754.Sq execute
3755, used when executing commands.
3756The shell holds some settings in each mode constant, so commands which leave
3757the tty in a confused state do not interfere with the shell.
3758The shell also matches changes in the speed and padding of the tty.
3759The list of tty modes that are kept constant
3760can be examined and modified with the
3761.Va setty
3762builtin.
3763Note that although the editor uses CBREAK mode (or its equivalent),
3764it takes typed-ahead characters anyway.
3765.Pp
3766The
3767.Va echotc
3768,
3769.Va settc
3770and
3771.Va telltc
3772commands can be used to
3773manipulate and debug terminal capabilities from the command line.
3774.Pp
3775On systems that support SIGWINCH or SIGWINDOW, the shell
3776adapts to window resizing automatically and adjusts the environment
3777variables
3778.Va LINES
3779and
3780.Va COLUMNS
3781if set.
3782If the environment
3783variable
3784.Va TERMCAP
3785contains li# and co# fields, the shell adjusts
3786them to reflect the new window size.
3787.Sh REFERENCE
3788The next sections of this manual describe all of the available
3789.Va Builtin commands
3790,
3791.Va Special aliases
3792and
3793.Va Special shell variables
3794.Ss "Builtin commands"
3795.TP 8
3796.B %\fIjob
3797A synonym for the
3798.Va fg
3799builtin command.
3800.TP 8
3801.B %\fIjob \fB&
3802A synonym for the
3803.Va bg
3804builtin command.
3805.TP 8
3806.B :
3807Does nothing, successfully.
3808.Pp
3809.B @
3810.br
3811.B @ \fIname\fB = \fIexpr
3812.br
3813.B @
3814.Va name
3815[
3816.Va index
3817]\fB = \fIexpr
3818.br
3819.B @ \fIname
3820.Va ++
3821|\fB--
3822.PD 0
3823.TP 8
3824.B @
3825.Va name
3826[
3827.Va index
3828]
3829.Va ++
3830|\fB--
3831The first form prints the values of all shell variables.
3832.PD
3833.RS +8
3834.Pp
3835The second form assigns the value of
3836.Va expr
3837to
3838.Va name
3839The third form assigns the value of
3840.Va expr
3841to the
3842.Va index
3843'th
3844component of
3845.Va name
3846; both
3847.Va name
3848and its
3849.Va index
3850'th component
3851must already exist.
3852.Pp
3853.Va expr
3854may contain the operators
3855.Sq *
3856,
3857.Sq +
3858, etc., as in C.
3859If
3860.Va expr
3861contains
3862.Sq <
3863,
3864.Sq >
3865,
3866.Sq &
3867or
3868.Sq
3869then at least that part of
3870.Va expr
3871must be placed within
3872.Sq ()
3873Note that the syntax of
3874.Va expr
3875has nothing to do with that described
3876under
3877.Va Expressions
3878.Pp
3879The fourth and fifth forms increment (`++') or decrement (`\-\-')
3880.Va name
3881or its
3882.Va index
3883'th component.
3884.Pp
3885The space between
3886.Sq @
3887and
3888.Va name
3889is required.
3890The spaces between
3891.Va name
3892and
3893.Sq =
3894and between
3895.Sq =
3896and
3897.Va expr
3898are optional.
3899Components of
3900.Va expr
3901must be separated by spaces.
3902.RE
3903.PD
3904.TP 8
3905.B alias \fR[
3906.Va name
3907[
3908.Va wordlist
3909]]
3910Without arguments, prints all aliases.
3911With
3912.Va name
3913, prints the alias for name.
3914With
3915.Va name
3916and
3917.Va wordlist
3918, assigns
3919.Va wordlist
3920as the alias of
3921.Va name
3922.Va wordlist
3923is command and filename substituted.
3924.Va name
3925may not be
3926.Sq alias
3927or
3928.Sq unalias
3929See also the
3930.Va unalias
3931builtin command.
3932.TP 8
3933.B alloc
3934Shows the amount of dynamic memory acquired, broken down into used and free
3935memory.
3936With an argument shows the number of free and used blocks in each size
3937category.
3938The categories start at size 8 and double at each step.
3939This
3940command's output may vary across system types, because systems other than the VAX
3941may use a different memory allocator.
3942.TP 8
3943.B bg \fR[\fB%
3944.Va job
3945...]
3946Puts the specified jobs (or, without arguments, the current job)
3947into the background, continuing each if it is stopped.
3948.Va job
3949may be a number, a string,
3950.Sq
3951,
3952.Sq %
3953,
3954.Sq +
3955or
3956.Sq \-
3957as described
3958under
3959.Va Jobs
3960.Pp
3961.B bindkey \fR[
3962.Fl l\fR|
3963.Fl d\fR|
3964.Fl e\fR|
3965.Fl v\fR|
3966.Fl u\fR] (+)
3967.br
3968.Va bindkey
3969[
3970.Fl a\fR] [
3971.Fl b\fR] [
3972.Fl k\fR] [
3973.Fl r\fR] [
3974.Fl \-\fR]
3975.Va key
3976(+)
3977.PD 0
3978.TP 8
3979.Va bindkey
3980[
3981.Fl a\fR] [
3982.Fl b\fR] [
3983.Fl k\fR] [
3984.Fl c\fR|
3985.Fl s\fR] [
3986.Fl \-\fR]
3987.Va key command
3988(+)
3989.\" .B macro can't take too many words, so I used \fB in the previous tags
3990Without options, the first form lists all bound keys and the editor command to which each is bound,
3991the second form lists the editor command to which
3992.Va key
3993is bound and
3994the third form binds the editor command
3995.Va command
3996to
3997.Va key
3998Options include:
3999.PD
4000.Pp
4001.PD 0
4002.RS +8
4003.TP 4
4004.Fl l
4005Lists all editor commands and a short description of each.
4006.TP 4
4007.Fl d
4008Binds all keys to the standard bindings for the default editor,
4009as per
4010.Va -e
4011and
4012.Va -v
4013below.
4014.TP 4
4015.Fl e
4016Binds all keys to
4017.Va emacs
4018(1)\-style bindings.
4019Unsets
4020.Va vimode
4021.TP 4
4022.Fl v
4023Binds all keys to
4024.Va vi
4025(1)\-style bindings.
4026Sets
4027.Va vimode
4028.TP 4
4029.Fl a
4030Lists or changes key-bindings in the alternative key map.
4031This is the key map used in
4032.Va vimode
4033command mode.
4034.TP 4
4035.Fl b
4036.Va key
4037is interpreted as
4038a control character written ^
4039.Va character
4040(e.g.,
4041.Sq ^A
4042) or
4043C-
4044.Va character
4045(e.g.,
4046.Sq C-A
4047),
4048a meta character written M-
4049.Va character
4050(e.g.,
4051.Sq M-A
4052),
4053a function key written F-
4054.Va string
4055(e.g.,
4056.Sq F-string
4057),
4058or an extended prefix key written X-
4059.Va character
4060(e.g.,
4061.Sq X-A
4062).
4063.TP 4
4064.Fl k
4065.Va key
4066is interpreted as a symbolic arrow key name, which may be one of
4067`down',
4068.Sq up
4069,
4070.Sq left
4071or
4072.Sq right
4073.TP 4
4074.Fl r
4075Removes
4076.Va key
4077's binding.
4078Be careful:
4079.Sq bindkey \-r
4080does
4081.Va not
4082bind
4083.Va key
4084to
4085.Va self-insert-command
4086(q.v.), it unbinds
4087.Va key
4088completely.
4089.TP 4
4090.Fl c
4091.Va command
4092is interpreted as a builtin or external command instead of an
4093editor command.
4094.TP 4
4095.Fl s
4096.Va command
4097is taken as a literal string and treated as terminal input
4098when
4099.Va key
4100is typed.
4101Bound keys in
4102.Va command
4103are themselves
4104reinterpreted, and this continues for ten levels of interpretation.
4105.TP 4
4106.Fl \-
4107Forces a break from option processing, so the next word is taken as
4108.Va key
4109even if it begins with '\-'.
4110.TP 4
4111.Fl u \fR(or any invalid option)
4112Prints a usage message.
4113.PD
4114.Pp
4115.Va key
4116may be a single character or a string.
4117If a command is bound to a string, the first character of the string is bound to
4118.Va sequence-lead-in
4119and the entire string is bound to the command.
4120.Pp
4121Control characters in
4122.Va key
4123can be literal (they can be typed by preceding
4124them with the editor command
4125.Va quoted-insert
4126, normally bound to
4127.Sq ^V
4128) or
4129written caret-character style, e.g.,
4130.Sq ^A
4131Delete is written
4132.Sq ^?
4133(caret-question mark).
4134.Va key
4135and
4136.Va command
4137can contain backslashed
4138escape sequences (in the style of System V
4139.Va echo
4140(1)) as follows:
4141.RS +4
4142.TP 8
4143.PD 0
4144.B \ea
4145Bell
4146.TP 8
4147.B \eb
4148Backspace
4149.TP 8
4150.B \ee
4151Escape
4152.TP 8
4153.B \ef
4154Form feed
4155.TP 8
4156.B \en
4157Newline
4158.TP 8
4159.B \er
4160Carriage return
4161.TP 8
4162.B \et
4163Horizontal tab
4164.TP 8
4165.B \ev
4166Vertical tab
4167.TP 8
4168.B \e\fInnn
4169The ASCII character corresponding to the octal number
4170.Va nnn
4171.PD
4172.RE
4173.Pp
4174`\e' nullifies the special meaning of the following character, if it has
4175any, notably
4176.Sq \e
4177and
4178.Sq ^
4179.RE
4180.TP 8
4181.B bs2cmd
4182.Va bs2000-command
4183(+)
4184Passes
4185.Va bs2000-command
4186to the BS2000 command interpreter for
4187execution. Only non-interactive commands can be executed, and it is
4188not possible to execute any command that would overlay the image
4189of the current process, like /EXECUTE or /CALL-PROCEDURE. (BS2000 only)
4190.TP 8
4191.B break
4192Causes execution to resume after the
4193.Va end
4194of the nearest
4195enclosing
4196.Va foreach
4197or
4198.Va while
4199The remaining commands on the
4200current line are executed.
4201Multi-level breaks are thus
4202possible by writing them all on one line.
4203.TP 8
4204.B breaksw
4205Causes a break from a
4206.Va switch
4207, resuming after the
4208.Va endsw
4209.TP 8
4210.B builtins \fR(+)
4211Prints the names of all builtin commands.
4212.TP 8
4213.B bye \fR(+)
4214A synonym for the
4215.Va logout
4216builtin command.
4217Available only if the shell was so compiled;
4218see the
4219.Va version
4220shell variable.
4221.TP 8
4222.B case \fIlabel\fB:
4223A label in a
4224.Va switch
4225statement as discussed below.
4226.TP 8
4227.B cd \fR[
4228.Fl p\fR] [
4229.Fl l\fR] [
4230.Fl n\fR|
4231.Fl v\fR] [\I--\fR] [
4232.Va name
4233]
4234If a directory
4235.Va name
4236is given, changes the shell's working directory
4237to
4238.Va name
4239If not, changes to
4240.Va home
4241, unless the
4242.Va cdtohome
4243variable is not set, in which case a
4244.Va name
4245is required.
4246If
4247.Va name
4248is
4249.Sq \-
4250it is interpreted as the previous working directory
4251(see
4252.Va Other substitutions
4253).
4254(+)
4255If
4256.Va name
4257is not a subdirectory of the current directory
4258(and does not begin with
4259.Sq /
4260,
4261.Sq ./
4262or
4263.Sq ../
4264), each component of the variable
4265.Va cdpath
4266is checked to see if it has a subdirectory
4267.Va name
4268Finally, if
4269all else fails but
4270.Va name
4271is a shell variable whose value
4272begins with
4273.Sq /
4274or '.', then this is tried to see if it is a directory, and
4275the
4276.Fl p\fR option is implied.
4277.RS +8
4278.Pp
4279With
4280.Fl p\fR, prints the final directory stack, just like
4281.Va dirs
4282The
4283.Fl l\fR,
4284.Fl n\fR and
4285.Fl v\fR flags have the same effect on
4286.Va cd
4287as on
4288.Va dirs
4289, and they imply
4290.Fl p\fR.
4291(+)
4292Using
4293.Fl \-\fR forces a break from option processing so the next word
4294is taken as the directory
4295.Va name
4296even if it begins with '\-'. (+)
4297.Pp
4298See also the
4299.Va implicitcd
4300and
4301.Va cdtohome
4302shell variables.
4303.RE
4304.TP 8
4305.B chdir
4306A synonym for the
4307.Va cd
4308builtin command.
4309.TP 8
4310.B complete \fR[
4311.Va command
4312[\fIword\fB/\fIpattern\fB/
4313.Va list
4314[\fB:
4315.Va select
4316]
4317.Va /
4318[[
4319.Va suffix
4320]
4321.Va /
4322] ...]] (+)
4323Without arguments, lists all completions.
4324With
4325.Va command
4326, lists completions for
4327.Va command
4328With
4329.Va command
4330and
4331.Va word
4332etc., defines completions.
4333.RS +8
4334.Pp
4335.Va command
4336may be a full command name or a glob-pattern
4337(see
4338.Va Filename substitution
4339).
4340It can begin with
4341.Sq \-
4342to indicate that
4343completion should be used only when
4344.Va command
4345is ambiguous.
4346.Pp
4347.Va word
4348specifies which word relative to the current word
4349is to be completed, and may be one of the following:
4350.Pp
4351.PD 0
4352.RS +4
4353.TP 4
4354.B c
4355Current-word completion.
4356.Va pattern
4357is a glob-pattern which must match the beginning of the current word on
4358the command line.
4359.Va pattern
4360is ignored when completing the current word.
4361.TP 4
4362.B C
4363Like
4364.Va c
4365, but includes
4366.Va pattern
4367when completing the current word.
4368.TP 4
4369.B n
4370Next-word completion.
4371.Va pattern
4372is a glob-pattern which must match the beginning of the previous word on
4373the command line.
4374.TP 4
4375.B N
4376Like
4377.Va n
4378, but must match the beginning of the word two before the current word.
4379.TP 4
4380.B p
4381Position-dependent completion.
4382.Va pattern
4383is a numeric range, with the same syntax used to index shell
4384variables, which must include the current word.
4385.PD
4386.RE
4387.Pp
4388.Va list
4389, the list of possible completions, may be one of the following:
4390.Pp
4391.PD 0
4392.RS +4
4393.TP 8
4394.B a
4395Aliases
4396.TP 8
4397.B b
4398Bindings (editor commands)
4399.TP 8
4400.B c
4401Commands (builtin or external commands)
4402.TP 8
4403.B C
4404External commands which begin with the supplied path prefix
4405.TP 8
4406.B d
4407Directories
4408.TP 8
4409.B D
4410Directories which begin with the supplied path prefix
4411.TP 8
4412.B e
4413Environment variables
4414.TP 8
4415.B f
4416Filenames
4417.TP 8
4418.B F
4419Filenames which begin with the supplied path prefix
4420.TP 8
4421.B g
4422Groupnames
4423.TP 8
4424.B j
4425Jobs
4426.TP 8
4427.B l
4428Limits
4429.TP 8
4430.B n
4431Nothing
4432.TP 8
4433.B s
4434Shell variables
4435.TP 8
4436.B S
4437Signals
4438.TP 8
4439.B t
4440Plain (
4441.Dq text )
4442files
4443.TP 8
4444.B T
4445Plain (
4446.Dq text )
4447files which begin with the supplied path prefix
4448.TP 8
4449.B v
4450Any variables
4451.TP 8
4452.B u
4453Usernames
4454.TP 8
4455.B x
4456Like
4457.Va n ,
4458but prints
4459.Va select
4460when
4461.Va list-choices
4462is used.
4463.TP 8
4464.B X
4465Completions
4466.TP 8
4467$
4468.Va var
4469Words from the variable
4470.Va var
4471.TP 8
4472(...)
4473Words from the given list
4474.TP 8
4475\`...\`
4476Words from the output of command
4477.PD
4478.RE
4479.Pp
4480.Va select
4481is an optional glob-pattern.
4482If given, words from only
4483.Va list
4484that match
4485.Va select
4486are considered
4487and the
4488.Va fignore
4489shell variable is ignored.
4490The last three types of completion may not have a
4491.Va select
4492pattern, and
4493.Va x
4494uses
4495.Va select
4496as an explanatory message when
4497the
4498.Va list-choices
4499editor command is used.
4500.Pp
4501.Va suffix
4502is a single character to be appended to a successful
4503completion.
4504If null, no character is appended.
4505If omitted (in which
4506case the fourth delimiter can also be omitted), a slash is appended to
4507directories and a space to other words.
4508.Pp
4509.Va command
4510invoked from \`...\` version has additional environment
4511variable set, the variable name is \%
4512.Va COMMAND_LINE
4513\% and
4514contains (as its name indicates) contents of the current (already
4515typed in) command line. One can examine and use contents of the
4516\%
4517.Va COMMAND_LINE
4518\% variable in her custom script to build more
4519sophisticated completions (see completion for svn(1) included in
4520this package).
4521.Pp
4522Now for some examples.
4523Some commands take only directories as arguments,
4524so there's no point completing plain files.
4525.IP "" 4
4526> complete cd 'p/1/d/'
4527.Pp
4528completes only the first word following
4529.Sq cd
4530(`p/1') with a directory.
4531.Va p
4532-type completion can also be used to narrow down command completion:
4533.IP "" 4
4534> co[^D]
4535.br
4536complete compress
4537.br
4538> complete \-co* 'p/0/(compress)/'
4539.br
4540> co[^D]
4541.br
4542> compress
4543.Pp
4544This completion completes commands (words in position 0,
4545.Sq p/0
4546)
4547which begin with
4548.Sq co
4549(thus matching
4550.Sq co*
4551) to
4552.Sq compress
4553(the only
4554word in the list).
4555The leading
4556.Sq \-
4557indicates that this completion is to be used with only
4558ambiguous commands.
4559.IP "" 4
4560> complete find 'n/\-user/u/'
4561.Pp
4562is an example of
4563.Va n
4564-type completion.
4565Any word following
4566.Sq find
4567and
4568immediately following
4569.Sq \-user
4570is completed from the list of users.
4571.IP "" 4
4572> complete cc 'c/\-I/d/'
4573.Pp
4574demonstrates
4575.Va c
4576-type completion.
4577Any word following
4578.Sq cc
4579and beginning
4580with
4581.Sq \-I
4582is completed as a directory.
4583`\-I' is not taken as part of the
4584directory because we used lowercase
4585.Va c
4586.Pp
4587Different
4588.Va list
4589s are useful with different commands.
4590.IP "" 4
4591> complete alias 'p/1/a/'
4592.br
4593> complete man 'p/*/c/'
4594.br
4595> complete set 'p/1/s/'
4596.br
4597> complete true 'p/1/x:Truth has no options./'
4598.Pp
4599These complete words following
4600.Sq alias
4601with aliases,
4602.Sq man
4603with commands,
4604and
4605.Sq set
4606with shell variables.
4607`true' doesn't have any options, so
4608.Va x
4609does nothing when completion
4610is attempted and prints
4611.Sq Truth has no options.
4612when completion choices are listed.
4613.Pp
4614Note that the
4615.Va man
4616example, and several other examples below, could
4617just as well have used 'c/*' or 'n/*' as 'p/*'.
4618.Pp
4619Words can be completed from a variable evaluated at completion time,
4620.IP "" 4
4621> complete ftp 'p/1/$hostnames/'
4622.br
4623> set hostnames = (rtfm.mit.edu tesla.ee.cornell.edu)
4624.br
4625> ftp [^D]
4626.br
4627rtfm.mit.edu tesla.ee.cornell.edu
4628.br
4629> ftp [^C]
4630.br
4631> set hostnames = (rtfm.mit.edu tesla.ee.cornell.edu uunet.uu.net)
4632.br
4633> ftp [^D]
4634.br
4635rtfm.mit.edu tesla.ee.cornell.edu uunet.uu.net
4636.Pp
4637or from a command run at completion time:
4638.IP "" 4
4639> complete kill 'p/*/\`ps | awk \e{print\e \e$1\e}\`/'
4640.br
4641> kill \-9 [^D]
4642.br
464323113 23377 23380 23406 23429 23529 23530 PID
4644.Pp
4645Note that the
4646.Va complete
4647command does not itself quote its arguments,
4648so the braces, space and
4649.Sq $
4650in
4651.Sq {print $1}
4652must be quoted explicitly.
4653.Pp
4654One command can have multiple completions:
4655.IP "" 4
4656> complete dbx 'p/2/(core)/' 'p/*/c/'
4657.Pp
4658completes the second argument to
4659.Sq dbx
4660with the word
4661.Sq core
4662and all other
4663arguments with commands.
4664Note that the positional completion is specified
4665before the next-word completion.
4666Because completions are evaluated from left to right, if
4667the next-word completion were specified first it would always match
4668and the positional completion would never be executed.
4669This is a
4670common mistake when defining a completion.
4671.Pp
4672The
4673.Va select
4674pattern is useful when a command takes files with only
4675particular forms as arguments.
4676For example,
4677.IP "" 4
4678> complete cc 'p/*/f:*.[cao]/'
4679.Pp
4680completes
4681.Sq cc
4682arguments to files ending in only
4683.Sq .c
4684,
4685.Sq .a
4686, or
4687.Sq .o
4688.Va select
4689can also exclude files, using negation of a glob-pattern as
4690described under
4691.Va Filename substitution
4692One might use
4693.IP "" 4
4694> complete rm 'p/*/f:^*.{c,h,cc,C,tex,1,man,l,y}/'
4695.Pp
4696to exclude precious source code from
4697.Sq rm
4698completion.
4699Of course, one
4700could still type excluded names manually or override the completion
4701mechanism using the
4702.Va complete-word-raw
4703or
4704.Va list-choices-raw
4705editor commands (q.v.).
4706.Pp
4707The
4708.Sq C
4709,
4710.Sq D
4711,
4712.Sq F
4713and
4714.Sq T
4715
4716.Va list
4717s are like
4718.Sq c
4719,
4720.Sq d
4721,
4722.Sq f
4723and
4724.Sq t
4725respectively, but they use the
4726.Va select
4727argument in a different way: to
4728restrict completion to files beginning with a particular path prefix.
4729For
4730example, the Elm mail program uses
4731.Sq =
4732as an abbreviation for one's mail
4733directory.
4734One might use
4735.IP "" 4
4736> complete elm c@=@F:$HOME/Mail/@
4737.Pp
4738to complete
4739.Sq elm \-f =
4740as if it were
4741.Sq elm \-f ~/Mail/
4742Note that we used
4743.Sq @
4744instead of
4745.Sq /
4746to avoid confusion with the
4747.Va select
4748argument, and we used
4749`$HOME' instead of
4750.Sq ~
4751because home directory substitution works at only the
4752beginning of a word.
4753.Pp
4754.Va suffix
4755is used to add a nonstandard suffix
4756(not space or
4757.Sq /
4758for directories) to completed words.
4759.IP "" 4
4760> complete finger 'c/*@/$hostnames/' 'p/1/u/@'
4761.Pp
4762completes arguments to
4763.Sq finger
4764from the list of users, appends an
4765.Sq @
4766,
4767and then completes after the
4768.Sq @
4769from the
4770.Sq hostnames
4771variable.
4772Note
4773again the order in which the completions are specified.
4774.Pp
4775Finally, here's a complex example for inspiration:
4776.IP "" 4
4777> complete find \e
4778.br
4779\&'n/\-name/f/' 'n/\-newer/f/' 'n/\-{,n}cpio/f/' \e
4780.br
4781\&\'n/\-exec/c/' 'n/\-ok/c/' 'n/\-user/u/' \e
4782.br
4783\&'n/\-group/g/' 'n/\-fstype/(nfs 4.2)/' \e
4784.br
4785\&'n/\-type/(b c d f l p s)/' \e
4786.br
4787\'c/\-/(name newer cpio ncpio exec ok user \e
4788.br
4789group fstype type atime ctime depth inum \e
4790.br
4791ls mtime nogroup nouser perm print prune \e
4792.br
4793size xdev)/' \e
4794.br
4795\&'p/*/d/'
4796.Pp
4797This completes words following
4798.Sq \-name
4799,
4800.Sq \-newer
4801,
4802.Sq \-cpio
4803or
4804.Sq ncpio
4805(note the pattern which matches both) to files,
4806words following
4807.Sq \-exec
4808or
4809.Sq \-ok
4810to commands, words following
4811.Sq user
4812and
4813.Sq group
4814to users and groups respectively
4815and words following
4816.Sq \-fstype
4817or
4818.Sq \-type
4819to members of the
4820given lists.
4821It also completes the switches themselves from the given list
4822(note the use of
4823.Va c
4824-type completion)
4825and completes anything not otherwise completed to a directory.
4826Whew.
4827.Pp
4828Remember that programmed completions are ignored if the word being completed
4829is a tilde substitution (beginning with
4830.Sq ~
4831) or a variable (beginning with
4832.Sq $
4833).
4834See also the
4835.Va uncomplete
4836builtin command.
4837.RE
4838.TP 8
4839.B continue
4840Continues execution of the nearest enclosing
4841.Va while
4842or
4843.Va foreach
4844The rest of the commands on the current line are executed.
4845.TP 8
4846.B default:
4847Labels the default case in a
4848.Va switch
4849statement.
4850It should come after all
4851.Va case
4852labels.
4853.Pp
4854.B dirs \fR[
4855.Fl l\fR] [
4856.Fl n\fR|
4857.Fl v\fR]
4858.br
4859.B dirs \-S\fR|
4860.Fl L \fR[
4861.Va filename
4862] (+)
4863.PD 0
4864.TP 8
4865.B dirs \-c \fR(+)
4866The first form prints the directory stack.
4867The top of the stack is at the
4868left and the first directory in the stack is the current directory.
4869With
4870.Fl l\fR,
4871.Sq ~
4872or
4873.Sq ~\fIname\fP
4874in the output is expanded explicitly
4875to
4876.Va home
4877or the pathname of the home directory for user \fIname\fP.
4878(+)
4879With
4880.Fl n\fR, entries are wrapped before they reach the edge of the screen.
4881(+)
4882With
4883.Fl v\fR, entries are printed one per line, preceded by their stack positions.
4884(+)
4885If more than one of
4886.Fl n\fR or
4887.Fl v\fR is given,
4888.Fl v\fR takes precedence.
4889.Fl p\fR is accepted but does nothing.
4890.PD
4891.RS +8
4892.Pp
4893With
4894.Fl S\fR, the second form saves the directory stack to
4895.Va filename
4896as a series of
4897.Va cd
4898and
4899.Va pushd
4900commands.
4901With
4902.Fl L\fR, the shell sources
4903.Va filename
4904, which is presumably
4905a directory stack file saved by the
4906.Fl S\fR option or the
4907.Va savedirs
4908mechanism.
4909In either case,
4910.Va dirsfile
4911is used if
4912.Va filename
4913is not given and
4914.Va ~/.cshdirs
4915is used if
4916.Va dirsfile
4917is unset.
4918.Pp
4919Note that login shells do the equivalent of
4920.Sq dirs \-L
4921on startup
4922and, if
4923.Va savedirs
4924is set,
4925.Sq dirs \-S
4926before exiting.
4927Because only
4928.Va ~/.tcshrc
4929is normally sourced before
4930.Va ~/.cshdirs
4931,
4932.Va dirsfile
4933should be set in
4934.Va ~/.tcshrc
4935rather than
4936.Va ~/.login
4937.Pp
4938The last form clears the directory stack.
4939.RE
4940.TP 8
4941.B echo \fR[
4942.Fl n\fR]
4943.Va word
4944...
4945Writes each
4946.Va word
4947to the shell's standard
4948output, separated by spaces and terminated with a newline.
4949The
4950.Va echo_style
4951shell variable may be set to emulate (or not) the flags and escape
4952sequences of the BSD and/or System V versions of
4953.Va echo
4954; see
4955.Va echo
4956(1).
4957.TP 8
4958.B echotc \fR[
4959.Fl sv\fR]
4960.Va arg
4961... (+)
4962Exercises the terminal capabilities (see
4963.Va termcap
4964(5)) in
4965.Va args
4966For example, 'echotc home' sends the cursor to the home position,
4967\&'echotc cm 3 10' sends it to column 3 and row 10, and
4968\&'echotc ts 0; echo "This is a test."; echotc fs' prints "This is a test."
4969in the status line.
4970.RS +8
4971.Pp
4972If
4973.Va arg
4974is 'baud', 'cols', 'lines', 'meta' or 'tabs', prints the
4975value of that capability ("yes" or "no" indicating that the terminal does
4976or does not have that capability).
4977One might use this to make the output
4978from a shell script less verbose on slow terminals, or limit command
4979output to the number of lines on the screen:
4980.IP "" 4
4981> set history=\`echotc lines\`
4982.br
4983> @ history\-\-
4984.Pp
4985Termcap strings may contain wildcards which will not echo correctly.
4986One should use double quotes when setting a shell variable to a terminal
4987capability string, as in the following example that places the date in
4988the status line:
4989.IP "" 4
4990> set tosl="\`echotc ts 0\`"
4991.br
4992> set frsl="\`echotc fs\`"
4993.br
4994> echo \-n "$tosl";date; echo \-n "$frsl"
4995.Pp
4996With
4997.Fl s\fR, nonexistent capabilities return the empty string rather
4998than causing an error.
4999With
5000.Fl v\fR, messages are verbose.
5001.RE
5002.Pp
5003.B else
5004.br
5005.B end
5006.br
5007.B endif
5008.PD 0
5009.TP 8
5010.B endsw
5011See the description of the
5012.Va foreach
5013,
5014.Va if
5015,
5016.Va switch
5017, and
5018.Va while
5019statements below.
5020.PD
5021.TP 8
5022.B eval
5023.Va arg
5024...
5025Treats the arguments as input to the
5026shell and executes the resulting command(s) in the context
5027of the current shell.
5028This is usually used to execute commands
5029generated as the result of command or variable substitution,
5030because parsing occurs before these substitutions.
5031See
5032.Va tset
5033(1) for a sample use of
5034.Va eval
5035.TP 8
5036.B exec
5037.Va command
5038Executes the specified command in place of the current shell.
5039.TP 8
5040.B exit \fR[
5041.Va expr
5042]
5043The shell exits either with the value of the specified
5044.Va expr
5045(an expression, as described under
5046.Va Expressions
5047)
5048or, without
5049.Va expr
5050, with the value 0.
5051.TP 8
5052.B fg \fR[\fB%
5053.Va job
5054...]
5055Brings the specified jobs (or, without arguments, the current job)
5056into the foreground, continuing each if it is stopped.
5057.Va job
5058may be a number, a string,
5059.Sq
5060,
5061.Sq %
5062,
5063.Sq +
5064or
5065.Sq \-
5066as described
5067under
5068.Va Jobs
5069See also the
5070.Va run-fg-editor
5071editor command.
5072.TP 8
5073.B filetest \-
5074.Va op file
5075... (+)
5076Applies
5077.Va op
5078(which is a file inquiry operator as described under
5079.Va File inquiry operators
5080) to each
5081.Va file
5082and returns the results as a
5083space-separated list.
5084.Pp
5085.B foreach \fIname \fB(\fIwordlist\fB)
5086.br
5087\&...
5088.PD 0
5089.TP 8
5090.B end
5091Successively sets the variable
5092.Va name
5093to each member of
5094.Va wordlist
5095and executes the sequence of commands between this command
5096and the matching
5097.Va end
5098(Both
5099.Va foreach
5100and
5101.Va end
5102must appear alone on separate lines.)  The builtin command
5103.Va continue
5104may be used to continue the loop prematurely and
5105the builtin command
5106.Va break
5107to terminate it prematurely.
5108When this command is read from the terminal, the loop is read once
5109prompting with
5110.Sq foreach?
5111(or
5112.Va prompt2
5113) before any statements in
5114the loop are executed.
5115If you make a mistake typing in a
5116loop at the terminal you can rub it out.
5117.PD
5118.TP 8
5119.B getspath \fR(+)
5120Prints the system execution path.
5121(TCF only)
5122.TP 8
5123.B getxvers \fR(+)
5124Prints the experimental version prefix.
5125(TCF only)
5126.TP 8
5127.B glob \fIwordlist
5128Like
5129.Va echo
5130, but the
5131.Sq -n
5132parameter is not recognized and words are
5133delimited by null characters in the output.
5134Useful for
5135programs which wish to use the shell to filename expand a list of words.
5136.TP 8
5137.B goto \fIword
5138.Va word
5139is filename and command-substituted to
5140yield a string of the form
5141.Sq label
5142The shell rewinds its
5143input as much as possible, searches for a line of the
5144form
5145.Sq label:
5146, possibly preceded by blanks or tabs, and
5147continues execution after that line.
5148.TP 8
5149.B hashstat
5150Prints a statistics line indicating how effective the
5151internal hash table has been at locating commands (and avoiding
5152.Va exec
5153's).
5154An
5155.Va exec
5156is attempted for each component of the
5157.Va path
5158where the hash function indicates a possible hit, and
5159in each component which does not begin with a
5160.Sq /
5161.IP
5162On machines without
5163.Va vfork
5164(2), prints only the number and size of
5165hash buckets.
5166.Pp
5167.B history \fR[
5168.Fl hTr\fR] [
5169.Va n
5170]
5171.br
5172.B history \-S\fR|
5173.Fl L|
5174.Fl M \fR[
5175.Va filename
5176] (+)
5177.PD 0
5178.TP 8
5179.B history \-c \fR(+)
5180The first form prints the history event list.
5181If
5182.Va n
5183is given only the
5184.Va n
5185most recent events are printed or saved.
5186With
5187.Fl h\fR, the history list is printed without leading numbers.
5188If
5189.Va -T
5190is specified, timestamps are printed also in comment form.
5191(This can be used to
5192produce files suitable for loading with 'history \-L' or 'source \-h'.)
5193With
5194.Fl r\fR, the order of printing is most recent
5195first rather than oldest first.
5196.PD
5197.RS +8
5198.Pp
5199With
5200.Fl S\fR, the second form saves the history list to
5201.Va filename
5202If the first word of the
5203.Va savehist
5204shell variable is set to a
5205number, at most that many lines are saved.
5206If the second word of
5207.Va savehist
5208is set to
5209.Sq merge
5210, the history list is merged with the
5211existing history file instead of replacing it (if there is one) and
5212sorted by time stamp.
5213(+) Merging is intended for an environment like
5214the X Window System
5215with several shells in simultaneous use.
5216If the second word of
5217.Va savehist
5218is
5219.Sq merge
5220and the third word is set to
5221.Sq lock
5222, the history file update
5223will be serialized with other shell sessions that would possibly like
5224to merge history at exactly the same time.
5225.Pp
5226With
5227.Fl L\fR, the shell appends
5228.Va filename
5229, which is presumably a
5230history list saved by the
5231.Fl S\fR option or the
5232.Va savehist
5233mechanism,
5234to the history list.
5235.Fl M\fR is like
5236.Fl L\fR, but the contents of
5237.Va filename
5238are merged
5239into the history list and sorted by timestamp.
5240In either case,
5241.Va histfile
5242is used if
5243.Va filename
5244is not given and
5245.Va ~/.history
5246is used if
5247.Va histfile
5248is unset.
5249`history \-L' is exactly like 'source \-h' except that it does not require a
5250filename.
5251.Pp
5252Note that login shells do the equivalent of
5253.Sq history \-L
5254on startup
5255and, if
5256.Va savehist
5257is set,
5258.Sq history \-S
5259before exiting.
5260Because only
5261.Va ~/.tcshrc
5262is normally sourced before
5263.Va ~/.history
5264,
5265.Va histfile
5266should be set in
5267.Va ~/.tcshrc
5268rather than
5269.Va ~/.login
5270.Pp
5271If
5272.Va histlit
5273is set, the first and second forms print and save the literal
5274(unexpanded) form of the history list.
5275.Pp
5276The last form clears the history list.
5277.RE
5278.TP 8
5279.B hup \fR[
5280.Va command
5281] \fR(+)
5282With
5283.Va command
5284, runs
5285.Va command
5286such that it will exit on a hangup
5287signal and arranges for the shell to send it a hangup signal when the shell
5288exits.
5289Note that commands may set their own response to hangups, overriding
5290.Va hup
5291Without an argument, causes the non-interactive shell only to
5292exit on a hangup for the remainder of the script.
5293See also
5294.Va Signal handling
5295and the
5296.Va nohup
5297builtin command.
5298.TP 8
5299.B if (\fIexpr\fB) \fIcommand
5300If
5301.Va expr
5302(an expression, as described under
5303.Va Expressions
5304)
5305evaluates true, then
5306.Va command
5307is executed.
5308Variable substitution on
5309.Va command
5310happens early, at the same time it
5311does for the rest of the
5312.Va if
5313command.
5314.Va command
5315must be a simple command, not an alias, a pipeline, a command list
5316or a parenthesized command list, but it may have arguments.
5317Input/output redirection occurs even if
5318.Va expr
5319is
5320false and
5321.Va command
5322is thus
5323.Va not
5324executed; this is a bug.
5325.Pp
5326.B if (\fIexpr\fB) then
5327.br
5328\&...
5329.br
5330.B else if (\fIexpr2\fB) then
5331.br
5332\&...
5333.br
5334.B else
5335.br
5336\&...
5337.PD 0
5338.TP 8
5339.B endif
5340If the specified
5341.Va expr
5342is true then the commands to the
5343first
5344.Va else
5345are executed; otherwise if
5346.Va expr2
5347is true then
5348the commands to the second
5349.Va else
5350are executed, etc.
5351Any
5352number of
5353.Va else-if
5354pairs are possible; only one
5355.Va endif
5356is
5357needed.
5358The
5359.Va else
5360part is likewise optional.
5361(The words
5362.Va else
5363and
5364.Va endif
5365must appear at the beginning of input lines;
5366the
5367.Va if
5368must appear alone on its input line or after an
5369.Va else
5370.)
5371.PD
5372.TP 8
5373.B inlib
5374.Va shared-library
5375... (+)
5376Adds each
5377.Va shared-library
5378to the current environment.
5379There is no way
5380to remove a shared library.
5381(Domain/OS only)
5382.TP 8
5383.B jobs \fR[
5384.Fl l\fR]
5385Lists the active jobs.
5386With
5387.Fl l\fR, lists process
5388IDs in addition to the normal information.
5389On TCF systems, prints
5390the site on which each job is executing.
5391.Pp
5392.PD 0
5393.TP 8
5394.B kill \fR[
5395.Fl s
5396.Va signal
5397] \fB%
5398.Va job
5399|
5400.Va pid
5401...
5402.PD 0
5403.TP 8
5404.B kill \-l
5405The first and second forms sends the specified
5406.Va signal
5407(or, if none
5408is given, the TERM (terminate) signal) to the specified jobs or processes.
5409.Va job
5410may be a number, a string,
5411.Sq
5412,
5413.Sq %
5414,
5415.Sq +
5416or
5417.Sq \-
5418as described
5419under
5420.Va Jobs
5421Signals are either given by number or by name (as given in
5422.Va /usr/include/signal.h
5423, stripped of the prefix
5424.Sq SIG
5425).
5426There is no default
5427.Va job
5428; saying just
5429.Sq kill
5430does not send a signal
5431to the current job.
5432If the signal being sent is TERM (terminate)
5433or HUP (hangup), then the job or process is sent a
5434CONT (continue) signal as well.
5435The third form lists the signal names.
5436.PD
5437.TP 8
5438.B limit \fR[
5439.Fl h\fR] [
5440.Va resource
5441[
5442.Va maximum-use
5443]]
5444Limits the consumption by the current process and each
5445process it creates to not individually exceed
5446.Va maximum-use
5447on
5448the specified
5449.Va resource
5450If no
5451.Va maximum-use
5452is given, then
5453the current limit is printed; if no
5454.Va resource
5455is given, then
5456all limitations are given.
5457If the
5458.Fl h\fR flag is given, the
5459hard limits are used instead of the current limits.
5460The
5461hard limits impose a ceiling on the values of the current
5462limits.
5463Only the super-user may raise the hard limits, but
5464a user may lower or raise the current limits within the legal range.
5465.Pp
5466Controllable resources currently include (if supported by the OS):
5467.Bl -tag -width pseudoterminals -compact -offset indent
5468.It Va cputime
5469the maximum number of cpu-seconds to be used by each process
5470.It Va filesize
5471the largest single file which can be created
5472.It Va datasize
5473the maximum growth of the data+stack region via sbrk(2) beyond
5474the end of the program text
5475.It Va stacksize
5476the maximum size of the automatically-extended stack region
5477.It Va coredumpsize
5478the size of the largest core dump that will be created
5479.It Va memoryuse
5480the maximum amount of physical memory a process
5481may have allocated to it at a given time
5482.It Va vmemoryuse
5483the maximum amount of virtual memory a process
5484may have allocated to it at a given time (address space)
5485.It Va vmemoryuse
5486the maximum amount of virtual memory a process
5487may have allocated to it at a given time
5488.It Va heapsize
5489the maximum amount of memory a process
5490may allocate per
5491.Xr brk 2
5492system call
5493.It Va descriptors
5494or
5495.It Va openfiles
5496the maximum number of open files for this process
5497.It Va pseudoterminals
5498the maximum number of pseudo-terminals for this user
5499.It Va kqueues
5500the maximum number of kqueues allocated for this process
5501.It Va concurrency
5502the maximum number of threads for this process
5503.It Va memorylocked
5504the maximum size which a process may lock into memory using mlock(2)
5505.It Va maxproc
5506the maximum number of simultaneous processes for this user id
5507.It Va maxthread
5508the maximum number of simultaneous threads (lightweight processes) for this
5509user id
5510.It Va threads
5511the maximum number of threads for this process
5512.It Va sbsize
5513the maximum size of socket buffer usage for this user
5514.It Va swapsize
5515the maximum amount of swap space reserved or used for this user
5516.It Va maxlocks
5517the maximum number of locks for this user
5518.It Va posixlocks
5519the maximum number of POSIX advisory locks for this user
5520.It Va maxsignal
5521the maximum number of pending signals for this user
5522.It Va maxmessage
5523the maximum number of bytes in POSIX mqueues for this user
5524.It Va maxnice
5525the maximum nice priority the user is allowed to raise mapped from [19...-20]
5526to [0...39] for this user
5527.It Va maxrtprio
5528the maximum realtime priority for this user
5529.It Va maxrttime
5530the timeout for RT tasks in microseconds for this user.
5531.El
5532.Pp
5533.Va maximum-use
5534may be given as a (floating point or
5535integer) number followed by a scale factor.
5536For all limits
5537other than
5538.Va cputime
5539the default scale is
5540.Sq k
5541or
5542.Sq kilobytes
5543(1024 bytes); a scale factor of
5544.Sq m
5545or
5546.Sq megabytes
5547or
5548.Sq g
5549or
5550.Sq gigabytes
5551may also be used.
5552For
5553.Va cputime
5554the default scaling is
5555.Sq seconds ,
5556while
5557.Sq m
5558for minutes or
5559.Sq h
5560for hours, or a time of the
5561form
5562.Sq mm:ss
5563giving minutes and seconds may be used.
5564.Pp
5565If
5566.Va maximum-use
5567is
5568.Sq unlimited ,
5569then the limitation on the specified
5570.Va resource
5571is removed (this is equivalent to the
5572.Va unlimit
5573builtin command).
5574.Pp
5575For both
5576.Va resource
5577names and scale factors, unambiguous
5578prefixes of the names suffice.
5579.RE
5580.TP 8
5581.B log \fR(+)
5582Prints the
5583.Va watch
5584shell variable and reports on each user indicated
5585in
5586.Va watch
5587who is logged in, regardless of when they last logged in.
5588See also
5589.Va watchlog
5590.TP 8
5591.B login
5592Terminates a login shell, replacing it with an instance of
5593.Va /bin/login
5594. This is one way to log off, included for
5595compatibility with
5596.Xr sh 1 .
5597.TP 8
5598.B logout
5599Terminates a login shell.
5600Especially useful if
5601.Va ignoreeof
5602is set.
5603.TP 8
5604.B ls\-F \fR[\-
5605.Va switch
5606...] [
5607.Va file
5608...] (+)
5609Lists files like
5610.Sq ls \-F
5611, but much faster.
5612It identifies each type of
5613special file in the listing with a special character:
5614.Bl -tag -width x -offset indent -compact
5615.It Dv /
5616Directory
5617.It Dv *
5618Executable
5619.It Dv #
5620Block device
5621.It Dv %
5622Character device
5623.It Dv |
5624Named pipe (systems with named pipes only)
5625.It Dv =
5626Socket (systems with sockets only)
5627.It Dv @
5628Symbolic link (systems with symbolic links only)
5629.It Dv +
5630Hidden directory (AIX only) or context dependent (HP/UX only)
5631.It Dv :
5632Network special (HP/UX only)
5633.El
5634.Pp
5635If the
5636.Va listlinks
5637shell variable is set, symbolic links are identified
5638in more detail (on only systems that have them, of course):
5639.Pp
5640.PD 0
5641.TP 4
5642@
5643Symbolic link to a non-directory
5644.TP 4
5645>
5646Symbolic link to a directory
5647.TP 4
5648&
5649Symbolic link to nowhere
5650.PD
5651.Pp
5652.Va listlinks
5653also slows down \fIls\-F\fR and causes partitions holding
5654files pointed to by symbolic links to be mounted.
5655.Pp
5656If the
5657.Va listflags
5658shell variable is set to
5659.Sq x
5660,
5661.Sq a
5662or
5663.Sq A
5664, or any
5665combination thereof (e.g.,
5666.Sq xA
5667), they are used as flags to \fIls\-F\fR,
5668making it act like
5669.Sq ls \-xF
5670,
5671.Sq ls \-Fa
5672,
5673.Sq ls \-FA
5674or a combination
5675(e.g.,
5676.Sq ls \-FxA
5677).
5678On machines where
5679.Sq ls \-C
5680is not the default, \fIls\-F\fR acts like
5681.Sq ls \-CF
5682,
5683unless
5684.Va listflags
5685contains an
5686.Sq x
5687, in which case it acts like
5688.Sq ls \-xF
5689\fIls\-F\fR passes its arguments to
5690.Va ls
5691(1) if it is given any switches,
5692so
5693.Sq alias ls ls\-F
5694generally does the right thing.
5695.Pp
5696The \fBls\-F\fR builtin can list files using different colors depending on the
5697filetype or extension.
5698See the
5699.Va color
5700shell variable and the
5701.Va LS_COLORS
5702environment variable.
5703.RE
5704.Pp
5705.B migrate \fR[
5706.Fl
5707.Va site
5708]
5709.Va pid
5710|\fB%
5711.Va jobid
5712... (+)
5713.PD 0
5714.TP 8
5715.B migrate \-
5716.Va site
5717(+)
5718The first form migrates the process or job to the site specified or the
5719default site determined by the system path.
5720The second form is equivalent to
5721.Sq migrate \-
5722.Va site
5723$$
5724: it migrates the
5725current process to the specified site.
5726Migrating the shell
5727itself can cause unexpected behavior, because the shell
5728does not like to lose its tty.
5729(TCF only)
5730.PD
5731.TP 8
5732.B newgrp \fR[
5733.Fl \fR]
5734.Va [group]
5735(+)
5736Equivalent to
5737.Sq exec newgrp
5738; see
5739.Va newgrp
5740(1).
5741Available only if the shell was so compiled;
5742see the
5743.Va version
5744shell variable.
5745.TP 8
5746.B nice \fR[\fB+
5747.Va number
5748] [
5749.Va command
5750]
5751Sets the scheduling priority for the shell to
5752.Va number
5753, or, without
5754.Va number
5755, to 4.
5756With
5757.Va command ,
5758runs
5759.Va command
5760at the appropriate
5761priority.
5762The greater the
5763.Va number
5764, the less cpu
5765the process gets.
5766The super-user may specify negative
5767priority by using
5768.Sq nice \-number ...
5769Command is always
5770executed in a sub-shell, and the restrictions placed on
5771commands in simple
5772.Va if
5773statements apply.
5774.TP 8
5775.B nohup \fR[
5776.Va command
5777]
5778With
5779.Va command
5780, runs
5781.Va command
5782such that it will ignore hangup signals.
5783Note that commands may set their own response to hangups, overriding
5784.Va nohup
5785Without an argument, causes the non-interactive shell only to
5786ignore hangups for the remainder of the script.
5787See also
5788.Va Signal handling
5789and the
5790.Va hup
5791builtin command.
5792.TP 8
5793.B notify \fR[\fB%
5794.Va job
5795...]
5796Causes the shell to notify the user asynchronously when the status of any
5797of the specified jobs (or, without %
5798.Va job
5799, the current job) changes,
5800instead of waiting until the next prompt as is usual.
5801.Va job
5802may be a number, a string,
5803.Sq
5804,
5805.Sq %
5806,
5807.Sq +
5808or
5809.Sq \-
5810as described
5811under
5812.Va Jobs
5813See also the
5814.Va notify
5815shell variable.
5816.TP 8
5817.B onintr \fR[
5818.Fl \fR|
5819.Va label
5820]
5821Controls the action of the shell on interrupts.
5822Without arguments,
5823restores the default action of the shell on interrupts,
5824which is to terminate shell scripts or to return to the
5825terminal command input level.
5826With
5827.Sq \-
5828, causes all interrupts to be ignored.
5829With
5830.Va label
5831, causes the shell to execute a
5832.Sq goto
5833.Va label
5834when an interrupt is received or a child process terminates because it was
5835interrupted.
5836.IP "" 8
5837.Va onintr
5838is ignored if the shell is running detached and in system
5839startup files (see
5840.Va FILES
5841), where interrupts are disabled anyway.
5842.TP 8
5843.B popd \fR[
5844.Fl p\fR] [
5845.Fl l\fR] [
5846.Fl n\fR|
5847.Fl v\fR] \fR[\fB+
5848.Va n
5849]
5850Without arguments, pops the directory stack and returns to the new top directory.
5851With a number
5852.Sq +
5853.Va n
5854, discards the
5855.Va n
5856'th entry in the stack.
5857.IP "" 8
5858Finally, all forms of
5859.Va popd
5860print the final directory stack,
5861just like
5862.Va dirs
5863The
5864.Va pushdsilent
5865shell variable can be set to
5866prevent this and the
5867.Fl p\fR flag can be given to override
5868.Va pushdsilent
5869The
5870.Fl l\fR,
5871.Fl n\fR and
5872.Fl v\fR flags have the same effect on
5873.Va popd
5874as on
5875.Va dirs
5876(+)
5877.TP 8
5878.B printenv \fR[
5879.Va name
5880] (+)
5881Prints the names and values of all environment variables or,
5882with
5883.Va name
5884, the value of the environment variable
5885.Va name
5886.TP 8
5887.B pushd \fR[
5888.Fl p\fR] [
5889.Fl l\fR] [
5890.Fl n\fR|
5891.Fl v\fR] [
5892.Va name
5893|\fB+
5894.Va n
5895]
5896Without arguments, exchanges the top two elements of the directory stack.
5897If
5898.Va pushdtohome
5899is set,
5900.Va pushd
5901without arguments does
5902.Sq pushd ~
5903,
5904like
5905.Va cd
5906(+)
5907With
5908.Va name
5909, pushes the current working directory onto the directory
5910stack and changes to
5911.Va name
5912If
5913.Va name
5914is
5915.Sq \-
5916it is interpreted as the previous working directory
5917(see
5918.Va Filename substitution
5919).
5920(+)
5921If
5922.Va dunique
5923is set,
5924.Va pushd
5925removes any instances of
5926.Va name
5927from the stack before pushing it onto the stack.
5928(+)
5929With a number
5930.Sq +
5931.Va n
5932, rotates the
5933.Va n
5934th element of the
5935directory stack around to be the top element and changes to it.
5936If
5937.Va dextract
5938is set, however,
5939.Sq pushd +
5940.Va n
5941extracts the
5942.Va n
5943th
5944directory, pushes it onto the top of the stack and changes to it.
5945(+)
5946.IP "" 8
5947Finally, all forms of
5948.Va pushd
5949print the final directory stack,
5950just like
5951.Va dirs
5952The
5953.Va pushdsilent
5954shell variable can be set to
5955prevent this and the
5956.Fl p\fR flag can be given to override
5957.Va pushdsilent
5958The
5959.Fl l\fR,
5960.Fl n\fR and
5961.Fl v\fR flags have the same effect on
5962.Va pushd
5963as on
5964.Va dirs
5965(+)
5966.TP 8
5967.B rehash
5968Causes the internal hash table of the contents of the
5969directories in the
5970.Va path
5971variable to be recomputed.
5972This is
5973needed if the
5974.Va autorehash
5975shell variable is not set and new
5976commands are added to directories in
5977.Va path
5978while you are logged
5979in.
5980With
5981.Va autorehash
5982, a new command will be found
5983automatically, except in the special case where another command of
5984the same name which is located in a different directory already
5985exists in the hash table.
5986Also flushes the cache of home directories
5987built by tilde expansion.
5988.TP 8
5989.B repeat \fIcount command
5990The specified
5991.Va command
5992,
5993which is subject to the same restrictions as the
5994.Va command
5995in the one line
5996.Va if
5997statement above, is executed
5998.Va count
5999times.
6000I/O redirections occur exactly once, even if
6001.Va count
6002is 0.
6003.TP 8
6004.B rootnode //
6005.Va nodename
6006(+)
6007Changes the rootnode to //
6008.Va nodename
6009, so that
6010.Sq /
6011will be interpreted
6012as
6013.Sq //
6014.Va nodename
6015(Domain/OS only)
6016.Pp
6017.B sched \fR(+)
6018.br
6019.B sched \fR[
6020.Va +
6021]
6022.Va hh:mm command
6023\fR(+)
6024.PD 0
6025.TP 8
6026.B sched \-
6027.Va n
6028(+)
6029The first form prints the scheduled-event list.
6030The
6031.Va sched
6032shell variable may be set to define the format in which
6033the scheduled-event list is printed.
6034The second form adds
6035.Va command
6036to the scheduled-event list.
6037For example,
6038.PD
6039.RS +8
6040.IP "" 4
6041> sched 11:00 echo It\e's eleven o\e'clock.
6042.Pp
6043causes the shell to echo
6044.Sq It's eleven o'clock .
6045at 11 AM.
6046The time may be in 12-hour AM/PM format
6047.IP "" 4
6048.\" TODO
6049> sched 5pm set prompt='[%h] It\e's after 5; go home: >'
6050.Pp
6051or may be relative to the current time:
6052.IP "" 4
6053> sched +2:15 /usr/lib/uucp/uucico \-r1 \-sother
6054.Pp
6055A relative time specification may not use AM/PM format.
6056The third form removes item
6057.Va n
6058from the event list:
6059.Bd -literal -offset indent
6060> sched
6061	1  Wed Apr  4 15:42  /usr/lib/uucp/uucico \-r1 \-sother
6062	2  Wed Apr  4 17:00  set prompt=[%h] It's after 5; go home: >
6063> sched \-2
6064> sched
6065	1  Wed Apr  4 15:42  /usr/lib/uucp/uucico \-r1 \-sother
6066.Ed
6067.Pp
6068A command in the scheduled-event list is executed just before the first
6069prompt is printed after the time when the command is scheduled.
6070It is possible to miss the exact time when the command is to be run, but
6071an overdue command will execute at the next prompt.
6072A command which comes due while the shell
6073is waiting for user input is executed immediately.
6074However, normal operation of an already-running command will not
6075be interrupted so that a scheduled-event list element may be run.
6076.Pp
6077This mechanism is similar to, but not the same as, the
6078.Va at
6079(1)
6080command on some Unix systems.
6081Its major disadvantage is that it may not run a command at exactly the
6082specified time.
6083Its major advantage is that because
6084.Va sched
6085runs directly from
6086the shell, it has access to shell variables and other structures.
6087This provides a mechanism for changing one's working environment
6088based on the time of day.
6089.RE
6090.Pp
6091.B set
6092.br
6093.B set
6094.Va name
6095...
6096.br
6097.B set
6098.Va name
6099\fB=
6100.Va word
6101...
6102.br
6103.B set [\-r] [\-f|\-l]
6104.Va name
6105\fB=(\fIwordlist
6106.Va )
6107... (+)
6108.br
6109.B set
6110.Va name[index]
6111\fB=
6112.Va word
6113...
6114.br
6115.B set \-r \fR(+)
6116.br
6117.B set \-r
6118.Va name
6119... (+)
6120.PD 0
6121.TP 8
6122.B set \-r
6123.Va name
6124\fB=
6125.Va word
6126... (+)
6127The first form of the command prints the value of all shell variables.
6128Variables which contain more than a single word print as a
6129parenthesized word list.
6130The second form sets
6131.Va name
6132to the null string.
6133The third form sets
6134.Va name
6135to the single
6136.Va word
6137The fourth form sets
6138.Va name
6139to the list of words in
6140.Va wordlist
6141In all cases the value is command and filename expanded.
6142If
6143.Fl r\fR is specified, the value is set read-only.
6144If
6145.Fl f\fR or
6146.Fl l\fR are specified, set only unique words keeping their order.
6147.Fl f\fR prefers the first occurrence of a word, and
6148.Fl l\fR the last.
6149The fifth form sets the
6150.Va index
6151'th component of
6152.Va name
6153to
6154.Va word
6155;
6156this component must already exist.
6157The sixth form lists only the names of all shell variables that are read-only.
6158The seventh form makes
6159.Va name
6160read-only, whether or not it has a value.
6161The eighth form is the same as the third form, but
6162make
6163.Va name
6164read-only at the same time.
6165.PD
6166.IP "" 8
6167These arguments can be repeated to set and/or make read-only multiple variables
6168in a single set command.
6169Note, however, that variable expansion
6170happens for all arguments before any setting occurs.
6171Note also that
6172.Sq =
6173can
6174be adjacent to both
6175.Va name
6176and
6177.Va word
6178or separated from both by
6179whitespace, but cannot be adjacent to only one or the other.
6180See also the
6181.Va unset
6182builtin command.
6183.TP 8
6184.B setenv \fR[
6185.Va name
6186[
6187.Va value
6188]]
6189Without arguments, prints the names and values of all environment variables.
6190Given
6191.Va name
6192, sets the environment variable
6193.Va name
6194to
6195.Va value
6196or, without
6197.Va value
6198, to the null string.
6199.TP 8
6200.B setpath
6201.Va path
6202(+)
6203Equivalent to
6204.Va setpath
6205(1).
6206(Mach only)
6207.TP 8
6208.B setspath\fR LOCAL|
6209.Va site
6210|
6211.Va cpu
6212...
6213(+)
6214Sets the system execution path.
6215(TCF only)
6216.TP 8
6217.B settc
6218.Va cap value
6219(+)
6220Tells the shell to believe that the terminal capability
6221.Va cap
6222(as defined in
6223.Va termcap
6224(5)) has the value
6225.Va value
6226No sanity checking is done.
6227Concept terminal users may have to
6228.Sq settc xn no
6229to get proper
6230wrapping at the rightmost column.
6231.TP 8
6232.B setty \fR[
6233.Fl d\fR|
6234.Fl q\fR|
6235.Fl x\fR] [
6236.Fl a\fR] [[
6237.Va +
6238|
6239.Fl \fR]
6240.Va mode
6241] (+)
6242Controls which tty modes (see
6243.Va Terminal management
6244)
6245the shell does not allow to change.
6246.Fl d\fR,
6247.Fl q\fR or
6248.Fl x\fR tells
6249.Va setty
6250to act
6251on the
6252.Sq edit
6253,
6254.Sq quote
6255or
6256.Sq execute
6257set of tty modes respectively; without
6258.Fl d\fR,
6259.Fl q\fR or
6260.Fl x\fR,
6261.Sq execute
6262is used.
6263.IP "" 8
6264Without other arguments,
6265.Va setty
6266lists the modes in the chosen set
6267which are fixed on (`+mode') or off (`\-mode').
6268The available modes, and thus the display, vary from system to system.
6269With
6270.Fl a\fR, lists all tty modes in the chosen set
6271whether or not they are fixed.
6272With \fB+
6273.Va mode
6274,
6275.Fl
6276.Va mode
6277or
6278.Va mode
6279, fixes
6280.Va mode
6281on or off
6282or removes control from
6283.Va mode
6284in the chosen set.
6285For example,
6286.Sq setty +echok echoe
6287fixes
6288.Sq echok
6289mode on and allows commands
6290to turn
6291.Sq echoe
6292mode on or off, both when the shell is executing commands.
6293.TP 8
6294.B setxvers\fR [
6295.Va string
6296] (+)
6297Set the experimental version prefix to
6298.Va string
6299, or removes it
6300if
6301.Va string
6302is omitted.
6303(TCF only)
6304.TP 8
6305.B shift \fR[
6306.Va variable
6307]
6308Without arguments, discards
6309.Va argv
6310[1] and shifts the members of
6311.Va argv
6312to the left.
6313It is an error for
6314.Va argv
6315not to be set or to have
6316less than one word as value.
6317With
6318.Va variable
6319, performs the
6320same function on
6321.Va variable
6322.TP 8
6323.B source \fR[
6324.Fl h\fR]
6325.Va name
6326[
6327.Va args
6328...]
6329The shell reads and executes commands from
6330.Va name
6331The commands are not placed on the history list.
6332If any
6333.Va args
6334are given, they are placed in
6335.Va argv
6336(+)
6337.Va source
6338commands may be nested;
6339if they are nested too deeply the shell may run out of file descriptors.
6340An error in a
6341.Va source
6342at any level terminates all nested
6343.Va source
6344commands.
6345With
6346.Fl h\fR, commands are placed on the history list instead of being
6347executed, much like
6348.Sq history \-L
6349.TP 8
6350.B stop \fB%
6351.Va job
6352|
6353.Va pid
6354...
6355Stops the specified jobs or processes which are executing in the background.
6356.Va job
6357may be a number, a string,
6358.Sq
6359,
6360.Sq %
6361,
6362.Sq +
6363or
6364.Sq \-
6365as described
6366under
6367.Va Jobs
6368There is no default
6369.Va job
6370; saying just
6371.Sq stop
6372does not stop
6373the current job.
6374.TP 8
6375.B suspend
6376Causes the shell to stop in its tracks, much as if it had
6377been sent a stop signal with
6378.Va ^Z
6379This is most often used to
6380stop shells started by
6381.Va su
6382(1).
6383.Pp
6384.B switch (\fIstring\fB)
6385.br
6386.B case \fIstr1\fB:
6387.PD 0
6388.IP "" 4
6389\&...
6390.br
6391.B breaksw
6392.Pp
6393\&...
6394.Pp
6395.B default:
6396.IP "" 4
6397\&...
6398.br
6399.B breaksw
6400.TP 8
6401.B endsw
6402Each case label is successively matched, against the
6403specified
6404.Va string
6405which is first command and filename expanded.
6406The file metacharacters
6407.Sq *
6408,
6409.Sq \&?
6410and
6411.Sq [...]
6412may be used
6413in the case labels, which are variable expanded.
6414If none
6415of the labels match before a
6416.Sq default
6417label is found, then
6418the execution begins after the default label.
6419Each case
6420label and the default label must appear at the beginning of
6421a line.
6422The command
6423.Va breaksw
6424causes execution to continue
6425after the
6426.Va endsw
6427Otherwise control may fall through case
6428labels and default labels as in C.
6429If no label matches and
6430there is no default, execution continues after the
6431.Va endsw
6432.PD
6433.TP 8
6434.B telltc \fR(+)
6435Lists the values of all terminal capabilities (see
6436.Va termcap
6437(5)).
6438.TP 8
6439.B termname \fR[
6440.Va terminal type
6441] \fR(+)
6442Tests if
6443.Va terminal type
6444(or the current value of
6445.Va TERM
6446if no
6447.Va terminal type
6448is given) has an entry in the hosts termcap(5) or
6449terminfo(5) database. Prints the terminal type to stdout and returns 0
6450if an entry is present otherwise returns 1.
6451.TP 8
6452.B time \fR[
6453.Va command
6454]
6455Executes
6456.Va command
6457(which must be a simple command, not an alias,
6458a pipeline, a command list or a parenthesized command list)
6459and prints a time summary as described under the
6460.Va time
6461variable.
6462If necessary, an extra shell is created to print the time statistic when
6463the command completes.
6464Without
6465.Va command
6466, prints a time summary for the current shell and its
6467children.
6468.TP 8
6469.B umask \fR[
6470.Va value
6471]
6472Sets the file creation mask to
6473.Va value
6474, which is given in octal.
6475Common values for the mask are
6476002, giving all access to the group and read and execute access to others, and
6477022, giving read and execute access to the group and others.
6478Without
6479.Va value
6480, prints the current file creation mask.
6481.TP 8
6482.B unalias
6483.Va pattern
6484.br
6485Removes all aliases whose names match
6486.Va pattern
6487`unalias *' thus removes all aliases.
6488It is not an error for nothing to be
6489.Va unalias
6490ed.
6491.TP 8
6492.B uncomplete
6493.Va pattern
6494(+)
6495Removes all completions whose names match
6496.Va pattern
6497`uncomplete *' thus removes all completions.
6498It is not an error for nothing to be
6499.Va uncomplete
6500d.
6501.TP 8
6502.B unhash
6503Disables use of the internal hash table to speed location of
6504executed programs.
6505.TP 8
6506.B universe
6507.Va universe
6508(+)
6509Sets the universe to
6510.Va universe
6511(Masscomp/RTU only)
6512.TP 8
6513.B unlimit \fR[
6514.Fl hf\fR] [
6515.Va resource
6516]
6517Removes the limitation on
6518.Va resource
6519or, if no
6520.Va resource
6521is
6522specified, all
6523.Va resource
6524limitations.
6525With
6526.Fl h\fR, the corresponding hard limits are removed.
6527Only the super-user may do this.
6528Note that
6529.Va unlimit
6530may not exit successful, since most systems
6531do not allow
6532.Va descriptors
6533to be unlimited.
6534With
6535.Fl f\fR errors are ignored.
6536.TP 8
6537.B unset \fIpattern
6538Removes all variables whose names match
6539.Va pattern
6540, unless they are read-only.
6541`unset *' thus removes all variables unless they are read-only;
6542this is a bad idea.
6543It is not an error for nothing to be
6544.Va unset
6545.TP 8
6546.B unsetenv \fIpattern
6547Removes all environment variables whose names match
6548.Va pattern
6549`unsetenv *' thus removes all environment variables;
6550this is a bad idea.
6551It is not an error for nothing to be
6552.Va unsetenv
6553ed.
6554.TP 8
6555.B ver \fR[
6556.Va systype
6557[
6558.Va command
6559]] (+)
6560Without arguments, prints
6561.Va SYSTYPE
6562With
6563.Va systype
6564, sets
6565.Va SYSTYPE
6566to
6567.Va systype
6568With
6569.Va systype
6570and
6571.Va command
6572, executes
6573.Va command
6574under
6575.Va systype
6576.Va systype
6577may be
6578.Sq bsd4.3
6579or
6580.Sq sys5.3
6581(Domain/OS only)
6582.TP 8
6583.B wait
6584The shell waits for all background jobs.
6585If the shell is interactive, an
6586interrupt will disrupt the wait and cause the shell to print the names and job
6587numbers of all outstanding jobs.
6588.TP 8
6589.B warp
6590.Va universe
6591(+)
6592Sets the universe to
6593.Va universe
6594(Convex/OS only)
6595.TP 8
6596.B watchlog \fR(+)
6597An alternate name for the
6598.Va log
6599builtin command (q.v.).
6600Available only if the shell was so compiled;
6601see the
6602.Va version
6603shell variable.
6604.TP 8
6605.B where
6606.Va command
6607(+)
6608Reports all known instances of
6609.Va command
6610, including aliases, builtins and
6611executables in
6612.Va path
6613.TP 8
6614.B which\fR
6615.Va command
6616(+)
6617Displays the command that will be executed by the shell after substitutions,
6618.Va path
6619searching, etc.
6620The builtin command is just like
6621.Va which
6622(1), but it correctly reports
6623.Nm
6624aliases and builtins and is 10 to 100 times faster.
6625See also the
6626.Va which-command
6627editor command.
6628.Pp
6629.B while (\fIexpr
6630.Va )
6631.br
6632\&...
6633.PD 0
6634.TP 8
6635.B end
6636Executes the commands between the
6637.Va while
6638and the matching
6639.Va end
6640while
6641.Va expr
6642(an expression, as described under
6643.Va Expressions
6644)
6645evaluates non-zero.
6646.Va while
6647and
6648.Va end
6649must appear alone on their input lines.
6650.Va break
6651and
6652.Va continue
6653may be used to terminate or continue the
6654loop prematurely.
6655If the input is a terminal, the user is prompted the first time
6656through the loop as with
6657.Va foreach
6658.PD
6659.Ss "Special aliases (+)"
6660If set, each of these aliases executes automatically at the indicated time.
6661They are all initially undefined.
6662.TP 8
6663.B beepcmd
6664Runs when the shell wants to ring the terminal bell.
6665.TP 8
6666.B cwdcmd
6667Runs after every change of working directory.
6668For example, if the user is
6669working on an X window system using
6670.Va xterm
6671(1) and a re-parenting window
6672manager that supports title bars such as
6673.Va twm
6674(1) and does
6675.RS +8
6676.IP "" 4
6677> alias cwdcmd  'echo \-n "^[]2;${HOST}:$cwd ^G"'
6678.Pp
6679then the shell will change the title of the running
6680.Va xterm
6681(1)
6682to be the name of the host, a colon, and the full current working directory.
6683A fancier way to do that is
6684.IP "" 4
6685> alias cwdcmd 'echo \-n "^[]2;${HOST}:$cwd^G^[]1;${HOST}^G"'
6686.Pp
6687This will put the hostname and working directory on the title bar but
6688only the hostname in the icon manager menu.
6689.Pp
6690Note that putting a
6691.Va cd
6692,
6693.Va pushd
6694or
6695.Va popd
6696in
6697.Va cwdcmd
6698may cause an infinite loop.
6699It is the author's opinion that anyone doing
6700so will get what they deserve.
6701.RE
6702.TP 8
6703.B jobcmd
6704Runs before each command gets executed, or when the command changes state.
6705This is similar to
6706.Va postcmd
6707, but it does not print builtins.
6708.RS +8
6709.IP "" 4
6710> alias jobcmd  'echo \-n "^[]2\e;\e!#:q^G"'
6711.Pp
6712then executing
6713.Va vi foo.c
6714will put the command string in the xterm title bar.
6715.RE
6716.TP 8
6717.B helpcommand
6718Invoked by the
6719.Va run-help
6720editor command.
6721The command name for which help
6722is sought is passed as sole argument.
6723For example, if one does
6724.RS +8
6725.IP "" 4
6726> alias helpcommand '\e!:1 --help'
6727.Pp
6728then the help display of the command itself will be invoked, using the GNU
6729help calling convention.
6730Currently there is no easy way to account for various calling conventions (e.g.,
6731the customary Unix
6732.Sq -h
6733), except by using a table of many commands.
6734.RE
6735.TP 8
6736.B periodic
6737Runs every
6738.Va tperiod
6739minutes.
6740This provides a convenient means for
6741checking on common but infrequent changes such as new mail.
6742For example,
6743if one does
6744.RS +8
6745.IP "" 4
6746> set tperiod = 30
6747.br
6748> alias periodic checknews
6749.Pp
6750then the
6751.Va checknews
6752(1) program runs every 30 minutes.
6753If
6754.Va periodic
6755is set but
6756.Va tperiod
6757is unset or set to 0,
6758.Va periodic
6759behaves like
6760.Va precmd
6761.RE
6762.TP 8
6763.B precmd
6764Runs just before each prompt is printed.
6765For example, if one does
6766.RS +8
6767.IP "" 4
6768> alias precmd date
6769.Pp
6770then
6771.Va date
6772(1) runs just before the shell prompts for each command.
6773There are no limits on what
6774.Va precmd
6775can be set to do, but discretion
6776should be used.
6777.RE
6778.TP 8
6779.B postcmd
6780Runs before each command gets executed.
6781.RS +8
6782.IP "" 4
6783> alias postcmd  'echo \-n "^[]2\e;\e!#:q^G"'
6784.Pp
6785then executing
6786.Va vi foo.c
6787will put the command string in the xterm title bar.
6788.RE
6789.TP 8
6790.B shell
6791Specifies the interpreter for executable scripts which do not themselves
6792specify an interpreter.
6793The first word should be a full path name to the
6794desired interpreter (e.g.,
6795.Sq /bin/csh
6796or
6797.Sq /usr/local/bin/tcsh
6798).
6799.Ss "Special shell variables"
6800The variables described in this section have special meaning to the shell.
6801.Pp
6802The shell sets
6803.Va addsuffix ,
6804.Va argv ,
6805.Va autologout ,
6806.Va csubstnonl ,
6807.Va command ,
6808.Va echo_style ,
6809.Va edit ,
6810.Va gid ,
6811.Va group ,
6812.Va home ,
6813.Va loginsh ,
6814.Va oid ,
6815.Va path ,
6816.Va prompt ,
6817.Va prompt2 ,
6818.Va prompt3 ,
6819.Va shell ,
6820.Va shlvl ,
6821.Va tcsh ,
6822.Va term ,
6823.Va tty ,
6824.Va uid ,
6825.Va user
6826and
6827.Va version
6828at
6829startup; they do not change thereafter unless changed by the user.
6830The shell updates
6831.Va cwd ,
6832.Va dirstack ,
6833.Va owd
6834and
6835.Va status
6836when necessary,
6837and sets
6838.Va logout
6839on logout.
6840.Pp
6841The shell synchronizes
6842.Va group ,
6843.Va home ,
6844.Va path ,
6845.Va shlvl ,
6846.Va term and
6847.Va user
6848with the environment variables of the same names:
6849whenever the environment variable changes the shell changes the corresponding
6850shell variable to match (unless the shell variable is read-only) and vice
6851versa.
6852Note that although
6853.Va cwd
6854and
6855.Va PWD
6856have identical meanings, they
6857are not synchronized in this manner, and that the shell automatically
6858converts between the different formats of
6859.Va path
6860and
6861.Va PATH
6862.TP 8
6863.B addsuffix \fR(+)
6864If set, filename completion adds
6865.Sq /
6866to the end of directories and a space
6867to the end of normal files when they are matched exactly.
6868Set by default.
6869.TP 8
6870.B afsuser \fR(+)
6871If set,
6872.Va autologout
6873's autolock feature uses its value instead of
6874the local username for kerberos authentication.
6875.TP 8
6876.B ampm \fR(+)
6877If set, all times are shown in 12-hour AM/PM format.
6878.TP 8
6879.B anyerror \fR(+)
6880This variable selects what is propagated to the value of the
6881.Va status
6882variable. For more information see the description of the
6883.Va status
6884variable below.
6885.TP 8
6886.B argv
6887The arguments to the shell.
6888Positional parameters are taken from
6889.Va argv
6890,
6891i.e.,
6892.Sq $1
6893is replaced by
6894.Sq $argv[1]
6895, etc.
6896Set by default, but usually empty in interactive shells.
6897.TP 8
6898.B autocorrect \fR(+)
6899If set, the
6900.Va spell-word
6901editor command is invoked automatically before
6902each completion attempt.
6903.TP 8
6904.B autoexpand \fR(+)
6905If set, the
6906.Va expand-history
6907editor command is invoked automatically
6908before each completion attempt. If this is set to
6909.Va onlyhistory
6910, then
6911only history will be expanded and a second completion will expand filenames.
6912.TP 8
6913.B autolist \fR(+)
6914If set, possibilities are listed after an ambiguous completion.
6915If set to
6916.Sq ambiguous
6917, possibilities are listed only when no new
6918characters are added by completion.
6919.TP 8
6920.B autologout \fR(+)
6921The first word is the number of minutes of inactivity before automatic
6922logout.
6923The optional second word is the number of minutes of inactivity
6924before automatic locking.
6925When the shell automatically logs out, it prints
6926.Sq auto-logout
6927, sets the
6928variable
6929.Va logout
6930to
6931.Sq automatic
6932and exits.
6933When the shell automatically locks, the user is required to enter his password
6934to continue working.
6935Five incorrect attempts result in automatic logout.
6936Set to
6937.Sq 60
6938(automatic logout after 60 minutes, and no locking) by default
6939in login and superuser shells, but not if the shell thinks it is running
6940under a window system (i.e., the
6941.Va DISPLAY
6942environment variable is set),
6943the tty is a pseudo-tty (pty) or the shell was not so compiled (see the
6944.Va version
6945shell variable).
6946See also the
6947.Va afsuser
6948and
6949.Va logout
6950shell variables.
6951.TP 8
6952.B autorehash \fR(+)
6953If set, the internal hash table of the contents of the directories in the
6954.Va path
6955variable will be recomputed if a command is not found in the hash
6956table.
6957In addition, the list of available commands will be rebuilt for each
6958command completion or spelling correction attempt if set to
6959.Sq complete
6960or
6961`correct' respectively; if set to
6962.Sq always
6963, this will be done for both
6964cases.
6965.TP 8
6966.B backslash_quote \fR(+)
6967.\" TODO
6968If set, backslashes (`\e') always quote
6969.Sq \e
6970,
6971.Sq \&' ,
6972and
6973.Sq \&"
6974This may make
6975complex quoting tasks easier, but it can cause syntax errors in
6976.Xr csh 1
6977scripts.
6978.TP 8
6979.B catalog
6980The file name of the message catalog.
6981If set, tcsh use
6982.Sq tcsh.${catalog}
6983as a message catalog instead of
6984default
6985.Sq tcsh
6986.TP 8
6987.B cdpath
6988A list of directories in which
6989.Va cd
6990should search for
6991subdirectories if they aren't found in the current directory.
6992.TP 8
6993.B cdtohome \fR(+)
6994If not set,
6995.Va cd
6996requires a directory
6997.Va name
6998, and will not go to the
6999.Va home
7000directory if it's omitted.
7001This is set by default.
7002.TP 8
7003.B color
7004If set, it enables color display for the builtin \fBls\-F\fR and it passes
7005.Fl \-color=auto\fR to
7006.Va ls
7007Alternatively, it can be set to only
7008\fBls\-F\fR or only
7009.Va ls
7010to enable color to only one command.
7011Setting
7012it to nothing is equivalent to setting it to \fB(ls\-F ls)\fR.
7013.TP 8
7014.B colorcat
7015If set, it enables color escape sequence for NLS message files.
7016And display colorful NLS messages.
7017.TP 8
7018.B command \fR(+)
7019If set, the command which was passed to the shell with the
7020.Va -c
7021flag (q.v.).
7022.TP 8
7023.B compat_expr \fR(+)
7024If set, the shell will evaluate expressions right to left, like the original
7025.Xr csh 1
7026.TP 8
7027.B complete \fR(+)
7028If set to
7029.Sq igncase
7030, the completion becomes case insensitive.
7031If set to
7032.Sq enhance
7033, completion ignores case and considers
7034hyphens and underscores to be equivalent; it will also treat
7035periods, hyphens and underscores (`.',
7036.Sq \-
7037and
7038.Sq _
7039) as word
7040separators.
7041If set to
7042.Sq Enhance
7043, completion matches uppercase and underscore
7044characters explicitly and matches lowercase and hyphens in a
7045case-insensitive manner; it will treat periods, hyphens and underscores
7046as word separators.
7047.TP 8
7048.B continue \fR(+)
7049If set to a list of commands, the shell will continue the listed
7050commands, instead of starting a new one.
7051.TP 8
7052.B continue_args \fR(+)
7053Same as continue, but the shell will execute:
7054.RS +8
7055.IP "" 4
7056echo \`pwd\` $argv > ~/.<cmd>_pause; %<cmd>
7057.RE
7058.TP 8
7059.B correct \fR(+)
7060If set to
7061.Sq cmd
7062, commands are automatically spelling-corrected.
7063If set to
7064.Sq complete
7065, commands are automatically completed.
7066If set to
7067.Sq all
7068, the entire command line is corrected.
7069.TP 8
7070.B csubstnonl \fR(+)
7071If set, newlines and carriage returns in command substitution are
7072replaced by spaces.
7073Set by default.
7074.TP 8
7075.B cwd
7076The full pathname of the current directory.
7077See also the
7078.Va dirstack
7079and
7080.Va owd
7081shell variables.
7082.TP 8
7083.B dextract \fR(+)
7084If set,
7085.Sq pushd +
7086.Va n
7087extracts the
7088.Va n
7089th directory from the directory
7090stack rather than rotating it to the top.
7091.TP 8
7092.B dirsfile \fR(+)
7093The default location in which
7094.Sq dirs \-S
7095and
7096.Sq dirs \-L
7097look for
7098a history file.
7099If unset,
7100.Va ~/.cshdirs
7101is used.
7102Because only
7103.Va ~/.tcshrc
7104is normally sourced before
7105.Va ~/.cshdirs
7106,
7107.Va dirsfile
7108should be set in
7109.Va ~/.tcshrc
7110rather than
7111.Va ~/.login
7112.TP 8
7113.B dirstack \fR(+)
7114An array of all the directories on the directory stack.
7115`$dirstack[1]' is the current working directory,
7116.Sq $dirstack[2]
7117the first directory on the stack, etc.
7118Note that the current working directory is
7119.Sq $dirstack[1]
7120but
7121.Sq =0
7122in
7123directory stack substitutions, etc.
7124One can change the stack arbitrarily by setting
7125.Va dirstack
7126,
7127but the first element (the current working directory) is always correct.
7128See also the
7129.Va cwd
7130and
7131.Va owd
7132shell variables.
7133.TP 8
7134.B dspmbyte \fR(+)
7135Has an effect iff 'dspm' is listed as part of the
7136.Va version
7137shell variable.
7138If set to
7139.Sq euc
7140, it enables display and editing EUC-kanji(Japanese) code.
7141If set to
7142.Sq sjis
7143, it enables display and editing Shift-JIS(Japanese) code.
7144If set to
7145.Sq big5
7146, it enables display and editing Big5(Chinese) code.
7147If set to
7148.Sq utf8
7149, it enables display and editing Utf8(Unicode) code.
7150If set to the following format, it enables display and editing of original
7151multi-byte code format:
7152.RS +8
7153.IP "" 4
7154> set dspmbyte = 0000....(256 bytes)....0000
7155.Pp
7156The table requires
7157.Va just
7158256 bytes.
7159Each character of 256 characters
7160corresponds (from left to right) to the ASCII codes 0x00, 0x01, ... 0xff.
7161Each
7162character
7163.\" (position in this table?)
7164is set to number 0,1,2 and 3.
7165Each number has the following meaning:
7166.br
71670 ... not used for multi-byte characters.
7168.br
71691 ... used for the first byte of a multi-byte character.
7170.br
71712 ... used for the second byte of a multi-byte character.
7172.br
71733 ... used for both the first byte and second byte of a multi-byte character.
7174.\" SHK: I tried my best to get the following to be grammatically correct.
7175.\" However, I still don't understand what's going on here.
7176In the
7177.\" following example, there are three bytes, but the text seems to refer to
7178.\" each nybble as a character.
7179What's going on here?  It this 3-byte code
7180.\" in the table?  The text above seems to imply that there are 256
7181.\" characters/bytes in the table.
7182If I get some more info on this (perhaps
7183.\" a complete example), I could fix the text to be grammatically correct.
7184.\" (steve.kelem@xilinx.com 1999/09/13)
7185.Pp
7186Example:
7187.br
7188If set to
7189.Sq 001322
7190, the first character (means 0x00 of the ASCII code) and
7191second character (means 0x01 of ASCII code) are set to
7192.Sq 0
7193Then, it is not
7194used for multi-byte characters.
7195The 3rd character (0x02) is set to '1',
7196indicating that it is used for the first byte of a multi-byte character.
7197The 4th character(0x03) is set '3'.
7198It is used for both the first byte and
7199the second byte of a multi-byte character.
7200The 5th and 6th characters
7201(0x04,0x05) are set to '2', indicating that they are used for the second
7202byte of a multi-byte character.
7203.Pp
7204The GNU fileutils version of ls cannot display multi-byte
7205filenames without the -N ( --literal ) option.
7206If you are using
7207this version, set the second word of dspmbyte to "ls".
7208If not, for
7209example, "ls-F -l" cannot display multi-byte filenames.
7210.Pp
7211Note:
7212.br
7213This variable can only be used if KANJI and DSPMBYTE has been defined at
7214compile time.
7215.RE
7216.TP 8
7217.B dunique \fR(+)
7218If set,
7219.Va pushd
7220removes any instances of
7221.Va name
7222from the stack before pushing it onto the stack.
7223.TP 8
7224.B echo
7225If set, each command with its arguments is echoed just before it is
7226executed.
7227For non-builtin commands all expansions occur before
7228echoing.
7229Builtin commands are echoed before command and filename
7230substitution, because these substitutions are then done selectively.
7231Set by the
7232.Fl x\fR command line option.
7233.TP 8
7234.B echo_style \fR(+)
7235The style of the
7236.Va echo
7237builtin.
7238May be set to
7239.Pp
7240.RS +8
7241.PD 0
7242.TP 8
7243bsd
7244Don't echo a newline if the first argument is
7245.Sq \-n ;
7246the default for
7247.Xr csh 1
7248.TP 8
7249sysv
7250Recognize backslashed escape sequences in echo strings.
7251.TP 8
7252both
7253Recognize both the
7254.Sq \-n
7255flag and backslashed escape sequences; the default
7256for
7257.Nm
7258.TP 8
7259none
7260Recognize neither.
7261.PD
7262.Pp
7263Set by default to the local system default.
7264The BSD and System V
7265options are described in the
7266.Va echo
7267(1) man pages on the appropriate
7268systems.
7269.RE
7270.TP 8
7271.B edit \fR(+)
7272If set, the command-line editor is used.
7273Set by default in interactive
7274shells.
7275.TP 8
7276.B editors \fR(+)
7277A list of command names for the
7278.Va run-fg-editor
7279editor command to match.
7280If not set, the
7281.Va EDITOR
7282(`ed' if unset) and
7283.Va VISUAL
7284(`vi' if unset)
7285environment variables will be used instead.
7286.TP 8
7287.B ellipsis \fR(+)
7288If set, the
7289.Sq %c
7290/`%.' and
7291.Sq %C
7292prompt sequences (see the
7293.Va prompt
7294shell variable) indicate skipped directories with an ellipsis (`...')
7295instead of
7296.Sq /<skipped>
7297.TP 8
7298.B euid \fR(+)
7299The user's effective user ID.
7300.TP 8
7301.B euser \fR(+)
7302The first matching passwd entry name corresponding to the effective user ID.
7303.TP 8
7304.B fignore \fR(+)
7305Lists file name suffixes to be ignored by completion.
7306.TP 8
7307.B filec
7308In
7309.Nm
7310, completion is always used and this variable is ignored
7311by default. If
7312.B edit
7313is unset, then the traditional
7314.Xr csh 1
7315completion is used.
7316If set in
7317.Xr csh 1
7318, filename completion is used.
7319.TP 8
7320.B gid \fR(+)
7321The user's real group ID.
7322.TP 8
7323.B globdot \fR(+)
7324If set, wild-card glob patterns will match files and directories beginning
7325with
7326.Sq .
7327except for
7328.Sq .
7329and
7330.Sq ..
7331.TP 8
7332.B globstar \fR(+)
7333If set, the
7334.Sq **
7335and
7336.Sq ***
7337file glob patterns will match any string of
7338characters including
7339.Sq /
7340traversing any existing sub-directories.
7341(e.g.
7342`ls **.c' will list all the .c files in the current directory tree).
7343If used by itself, it will match zero or more sub-directories
7344(e.g.
7345.Sq ls /usr/include/**/time.h
7346will list any file named
7347.Sq time.h
7348in the /usr/include directory tree; whereas
7349.Sq ls /usr/include/**time.h
7350will match any file in the /usr/include directory tree ending in
7351.Sq time.h
7352).
7353To prevent problems with recursion, the
7354.Sq **
7355glob-pattern will not
7356descend into a symbolic link containing a directory.
7357To override this,
7358use
7359.Sq ***
7360.TP 8
7361.B group \fR(+)
7362The user's group name.
7363.TP 8
7364.B highlight
7365If set, the incremental search match (in
7366.Va i-search-back
7367and
7368.Va i-search-fwd
7369) and the region between the mark and the cursor are
7370highlighted in reverse video.
7371.IP "" 8
7372Highlighting requires more frequent terminal writes, which introduces extra
7373overhead. If you care about terminal performance, you may want to leave this
7374unset.
7375.TP 8
7376.B histchars
7377A string value determining the characters used in \fBHistory
7378substitution\fR (q.v.).
7379The first character of its value is used as
7380the history substitution character, replacing the default character
7381`!'.
7382The second character of its value replaces the character
7383.Sq ^
7384in
7385quick substitutions.
7386.TP 8
7387.B histdup \fR(+)
7388Controls handling of duplicate entries in the history list.
7389If set to
7390`all' only unique history events are entered in the history list.
7391If
7392set to
7393.Sq prev
7394and the last history event is the same as the current
7395command, then the current command is not entered in the history.
7396If
7397set to
7398.Sq erase
7399and the same event is found in the history list, that
7400old event gets erased and the current one gets inserted.
7401Note that the
7402`prev' and
7403.Sq all
7404options renumber history events so there are no gaps.
7405.TP 8
7406.B histfile \fR(+)
7407The default location in which
7408.Sq history \-S
7409and
7410.Sq history \-L
7411look for
7412a history file.
7413If unset,
7414.Va ~/.history
7415is used.
7416.Va histfile
7417is
7418useful when sharing the same home directory between different machines,
7419or when saving separate histories on different terminals.
7420Because only
7421.Va ~/.tcshrc
7422is normally sourced before
7423.Va ~/.history
7424,
7425.Va histfile
7426should be set in
7427.Va ~/.tcshrc
7428rather than
7429.Va ~/.login
7430.TP 8
7431.B histlit \fR(+)
7432If set, builtin and editor commands and the
7433.Va savehist
7434mechanism
7435use the literal (unexpanded) form of lines in the history list.
7436See
7437also the
7438.Va toggle-literal-history
7439editor command.
7440.TP 8
7441.B history
7442The first word indicates the number of history events to save.
7443The
7444optional second word (+) indicates the format in which history is
7445printed; if not given,
7446.Sq %h\et%T\et%R\en
7447is used.
7448The format sequences
7449are described below under
7450.Va prompt
7451; note the variable meaning of
7452`%R'.
7453Set to
7454.Sq 100
7455by default.
7456.TP 8
7457.B home
7458Initialized to the home directory of the invoker.
7459The filename
7460expansion of
7461.Sq
7462.Va ~
7463refers to this variable.
7464.TP 8
7465.B ignoreeof
7466If set to the empty string or
7467.Sq 0
7468and the input device is a terminal,
7469the
7470.Va end-of-file
7471command (usually generated by the user by typing
7472`^D' on an empty line) causes the shell to print `Use "exit" to leave
7473tcsh.' instead of exiting.
7474This prevents the shell from accidentally
7475being killed.
7476Historically this setting exited after 26 successive
7477EOF's to avoid infinite loops.
7478If set to a number
7479.Va n
7480, the shell
7481ignores
7482.Va n - 1
7483consecutive
7484.Va end-of-file
7485s and exits on the
7486.Va n
7487th.
7488(+) If unset,
7489.Sq 1
7490is used, i.e., the shell exits on a
7491single
7492.Sq ^D
7493.TP 8
7494.B implicitcd \fR(+)
7495If set, the shell treats a directory name typed as a command as though
7496it were a request to change to that directory.
7497If set to
7498.Va verbose
7499,
7500the change of directory is echoed to the standard output.
7501This behavior
7502is inhibited in non-interactive shell scripts, or for command strings
7503with more than one word.
7504Changing directory takes precedence over
7505executing a like-named command, but it is done after alias
7506substitutions.
7507Tilde and variable expansions work as expected.
7508.TP 8
7509.B inputmode \fR(+)
7510If set to
7511.Sq insert
7512or
7513.Sq overwrite
7514, puts the editor into that input mode
7515at the beginning of each line.
7516.TP 8
7517.B killdup \fR(+)
7518Controls handling of duplicate entries in the kill ring.
7519If set to
7520`all' only unique strings are entered in the kill ring.
7521If set to
7522`prev' and the last killed string is the same as the current killed
7523string, then the current string is not entered in the ring.
7524If set
7525to
7526.Sq erase
7527and the same string is found in the kill ring, the old
7528string is erased and the current one is inserted.
7529.TP 8
7530.B killring \fR(+)
7531Indicates the number of killed strings to keep in memory.
7532Set to
7533.Sq 30
7534by default.
7535If unset or set to less than
7536.Sq 2
7537, the shell will only
7538keep the most recently killed string.
7539Strings are put in the killring by the editor commands that delete
7540(kill) strings of text, e.g.
7541.Va backward-delete-word
7542,
7543.Va kill-line
7544, etc, as well as the
7545.Va copy-region-as-kill
7546command.
7547The
7548.Va yank
7549editor command will yank the most recently killed string
7550into the command-line, while
7551.Va yank-pop
7552(see
7553.Va Editor commands
7554)
7555can be used to yank earlier killed strings.
7556.TP 8
7557.B listflags \fR(+)
7558If set to
7559.Sq x
7560,
7561.Sq a
7562or
7563.Sq A
7564, or any combination thereof (e.g.,
7565.Sq xA
7566), they
7567are used as flags to \fIls\-F\fR, making it act like
7568.Sq ls \-xF
7569, `ls
7570\-Fa',
7571.Sq ls \-FA
7572or a combination (e.g.,
7573.Sq ls \-FxA
7574):
7575.Sq a
7576shows all
7577files (even if they start with a
7578.Sq .
7579),
7580.Sq A
7581shows all files but
7582.Sq .
7583and
7584`..', and
7585.Sq x
7586sorts across instead of down.
7587If the second word of
7588.Va listflags
7589is set, it is used as the path to
7590.Sq ls(1)
7591.TP 8
7592.B listjobs \fR(+)
7593If set, all jobs are listed when a job is suspended.
7594If set to
7595.Sq long
7596,
7597the listing is in long format.
7598.TP 8
7599.B listlinks \fR(+)
7600If set, the \fIls\-F\fR builtin command shows the type of file to which
7601each symbolic link points.
7602.TP 8
7603.B listmax \fR(+)
7604The maximum number of items which the
7605.Va list-choices
7606editor command
7607will list without asking first.
7608.TP 8
7609.B listmaxrows \fR(+)
7610The maximum number of rows of items which the
7611.Va list-choices
7612editor
7613command will list without asking first.
7614.TP 8
7615.B loginsh \fR(+)
7616Set by the shell if it is a login shell.
7617Setting or unsetting it
7618within a shell has no effect.
7619See also
7620.Va shlvl
7621.TP 8
7622.B logout \fR(+)
7623Set by the shell to
7624.Sq normal
7625before a normal logout,
7626.Sq automatic
7627before
7628an automatic logout, and
7629.Sq hangup
7630if the shell was killed by a hangup
7631signal (see
7632.Va Signal handling
7633).
7634See also the
7635.Va autologout
7636shell variable.
7637.TP 8
7638.B mail
7639A list of files and directories to check for incoming mail, optionally
7640preceded by a numeric word.
7641Before each prompt, if 10 minutes have
7642passed since the last check, the shell checks each file and says `You
7643have new mail.' (or, if
7644.Va mail
7645contains multiple files, `You have
7646new mail in
7647.Va name
7648.') if the filesize is greater than zero in size
7649and has a modification time greater than its access time.
7650.Pp
7651.RS +8
7652.PD
7653.Pp
7654If you are in a login shell, then no mail file is reported unless it has
7655been modified after the time the shell has started up, to prevent
7656redundant notifications.
7657Most login programs will tell you whether or not
7658you have mail when you log in.
7659.Pp
7660If a file specified in
7661.Va mail
7662is a directory, the shell will count each
7663file within that directory as a separate message, and will report `You have
7664.Va n
7665mails.' or
7666.Sq You have
7667.Va n
7668mails in
7669.Va name
7670as appropriate.
7671This functionality is provided primarily for those systems which store mail
7672in this manner, such as the Andrew Mail System.
7673.Pp
7674If the first word of
7675.Va mail
7676is numeric it is taken as a different mail
7677checking interval, in seconds.
7678.Pp
7679Under very rare circumstances, the shell may report
7680.Sq You have mail.
7681instead
7682of
7683.Sq You have new mail.
7684.RE
7685.TP 8
7686.B matchbeep \fR(+)
7687If set to
7688.Sq never
7689, completion never beeps.
7690If set to
7691.Sq nomatch
7692, it beeps only when there is no match.
7693If set to
7694.Sq ambiguous
7695, it beeps when there are multiple matches.
7696If set to
7697.Sq notunique
7698, it beeps when there is one exact and other longer matches.
7699If unset,
7700.Sq ambiguous
7701is used.
7702.TP 8
7703.B nobeep \fR(+)
7704If set, beeping is completely disabled.
7705See also
7706.Va visiblebell
7707.TP 8
7708.B noclobber
7709If set, restrictions are placed on output redirection to insure that files
7710are not accidentally destroyed and that
7711.Sq >>
7712redirections refer to existing
7713files, as described in the
7714.Va Input/output
7715section.
7716.TP 8
7717.B noding
7718If set, disable the printing of
7719.Sq DING!
7720in the
7721.Va prompt
7722time
7723specifiers at the change of hour.
7724.TP 8
7725.B noglob
7726If set,
7727.Va Filename substitution
7728and
7729.Va Directory stack substitution
7730(q.v.) are inhibited.
7731This is most useful in shell scripts which do not deal
7732with filenames, or after a list of filenames has been obtained and further
7733expansions are not desirable.
7734.TP 8
7735.B nokanji \fR(+)
7736If set and the shell supports Kanji (see the
7737.Va version
7738shell variable),
7739it is disabled so that the meta key can be used.
7740.TP 8
7741.B nonomatch
7742If set, a
7743.Va Filename substitution
7744or
7745.Va Directory stack substitution
7746(q.v.) which does not match any
7747existing files is left untouched rather than causing an error.
7748It is still an error for the substitution to be
7749malformed, e.g.,
7750.Sq echo [
7751still gives an error.
7752.TP 8
7753.B nostat \fR(+)
7754A list of directories (or glob-patterns which match directories; see
7755.Va Filename substitution
7756) that should not be
7757.Va stat
7758(2)ed during a
7759completion operation.
7760This is usually used to exclude directories which
7761take too much time to
7762.Va stat
7763(2), for example
7764.Va /afs
7765.TP 8
7766.B notify
7767If set, the shell announces job completions asynchronously.
7768The default is to present job completions just before printing a prompt.
7769.TP 8
7770.B oid \fR(+)
7771The user's real organization ID.
7772(Domain/OS only)
7773.TP 8
7774.B owd \fR(+)
7775The old working directory, equivalent to the
7776.Sq \-
7777used by
7778.Va cd
7779and
7780.Va pushd
7781See also the
7782.Va cwd
7783and
7784.Va dirstack
7785shell variables.
7786.TP 8
7787.B padhour
7788If set, enable the printing of padding '0' for hours, in 24 and 12 hour
7789formats.
7790E.G.: 07:45:42 vs. 7:45:42.
7791.TP 8
7792.B parseoctal
7793To retain compatibily with older versions numeric variables starting with
77940 are not interpreted as octal. Setting this variable enables proper octal
7795parsing.
7796.TP 8
7797.B path
7798A list of directories in which to look for executable commands.
7799A null word specifies the current directory.
7800If there is no
7801.Va path
7802variable then only full path names will execute.
7803.Va path
7804is set by the shell at startup from the
7805.Va PATH
7806environment
7807variable or, if
7808.Va PATH
7809does not exist, to a system-dependent default
7810something like
7811.Sq (/usr/local/bin /usr/bsd /bin /usr/bin .)
7812The shell may put
7813.Sq .
7814first or last in
7815.Va path
7816or omit it entirely
7817depending on how it was compiled; see the
7818.Va version
7819shell variable.
7820A shell which is given neither the
7821.Fl c\fR nor the
7822.Fl t\fR option
7823hashes the contents of the directories in
7824.Va path
7825after
7826reading
7827.Va ~/.tcshrc
7828and each time
7829.Va path
7830is reset.
7831If one adds a new command to a directory in
7832.Va path
7833while the shell
7834is active, one may need to do a
7835.Va rehash
7836for the shell to find it.
7837.TP 8
7838.B printexitvalue \fR(+)
7839If set and an interactive program exits with a non-zero status, the shell
7840prints
7841.Sq Exit
7842.Va status
7843.TP 8
7844.B prompt
7845The string which is printed before reading each command from the terminal.
7846.Va prompt
7847may include any of the following formatting sequences (+), which
7848are replaced by the given information:
7849.Pp
7850.RS +8
7851.PD 0
7852.TP 4
7853%/
7854The current working directory.
7855.TP 4
7856%~
7857The current working directory, but with one's home directory
7858represented by
7859.Sq ~
7860and other users' home directories represented by
7861`~user' as per
7862.Va Filename substitution
7863`~user' substitution
7864happens only if the shell has already used
7865.Sq ~
7866.Va user
7867in a pathname
7868in the current session.
7869.TP 4
7870%c[[0]
7871.Va n
7872], %.[[0]
7873.Va n
7874]
7875The trailing component of the current working directory, or
7876.Va n
7877trailing components if a digit
7878.Va n
7879is given.
7880If
7881.Va n
7882begins with
7883.Sq 0
7884, the number of skipped components precede
7885the trailing component(s) in the format
7886.Sq /<
7887.Va skipped
7888>trailing
7889If the
7890.Va ellipsis
7891shell variable is set, skipped components
7892are represented by an ellipsis so the whole becomes
7893.Sq ...trailing
7894`~' substitution is done as in
7895.Sq %~
7896above, but the
7897.Sq ~
7898component
7899is ignored when counting trailing components.
7900.TP 4
7901%C
7902Like %c, but without
7903.Sq ~
7904substitution.
7905.TP 4
7906%h, %!, !
7907The current history event number.
7908.TP 4
7909%M
7910The full hostname.
7911.TP 4
7912%m
7913The hostname up to the first
7914.Sq .
7915.TP 4
7916%S (%s)
7917Start (stop) standout mode.
7918.TP 4
7919%B (%b)
7920Start (stop) boldfacing mode.
7921.TP 4
7922%U (%u)
7923Start (stop) underline mode.
7924.TP 4
7925%t, %@
7926The time of day in 12-hour AM/PM format.
7927.TP 4
7928%T
7929Like
7930.Sq %t
7931, but in 24-hour format (but see the
7932.Va ampm
7933shell variable).
7934.TP 4
7935%p
7936The
7937.Sq precise
7938time of day in 12-hour AM/PM format, with seconds.
7939.TP 4
7940%P
7941Like
7942.Sq %p
7943, but in 24-hour format (but see the
7944.Va ampm
7945shell variable).
7946.TP 4
7947\e
7948.Va c
7949.Va c
7950is parsed as in
7951.Va bindkey
7952.TP 4
7953^
7954.Va c
7955.Va c
7956is parsed as in
7957.Va bindkey
7958.TP 4
7959%%
7960A single
7961.Sq %
7962.TP 4
7963%n
7964The user name.
7965.TP 4
7966%N
7967The effective user name.
7968.TP 4
7969%j
7970The number of jobs.
7971.TP 4
7972%d
7973The weekday in
7974.Sq Day
7975format.
7976.TP 4
7977%D
7978The day in
7979.Sq dd
7980format.
7981.TP 4
7982%w
7983The month in
7984.Sq Mon
7985format.
7986.TP 4
7987%W
7988The month in
7989.Sq mm
7990format.
7991.TP 4
7992%y
7993The year in
7994.Sq yy
7995format.
7996.TP 4
7997%Y
7998The year in
7999.Sq yyyy
8000format.
8001.TP 4
8002%l
8003The shell's tty.
8004.TP 4
8005%L
8006Clears from the end of the prompt to end of the display or the end of the line.
8007.TP 4
8008%$
8009Expands the shell or environment variable name immediately after the
8010.Sq $
8011.TP 4
8012%#
8013`>' (or the first character of the
8014.Va promptchars
8015shell variable)
8016for normal users,
8017.Sq #
8018(or the second character of
8019.Va promptchars
8020)
8021for the superuser.
8022.TP 4
8023%{
8024.Va string
8025%}
8026Includes
8027.Va string
8028as a literal escape sequence.
8029It should be used only to change terminal attributes and
8030should not move the cursor location.
8031This
8032cannot be the last sequence in
8033.Va prompt
8034.TP 4
8035%?
8036The return code of the command executed just before the prompt.
8037.TP 4
8038%R
8039In
8040.Va prompt2
8041, the status of the parser.
8042In
8043.Va prompt3
8044, the corrected string.
8045In
8046.Va history
8047, the history string.
8048.PD
8049.Pp
8050`%B',
8051.Sq %S
8052,
8053.Sq %U
8054and
8055.Sq %{
8056.Va string
8057%}
8058are available in only
8059eight-bit-clean shells; see the
8060.Va version
8061shell variable.
8062.Pp
8063The bold, standout and underline sequences are often used to distinguish a
8064superuser shell.
8065For example,
8066.IP "" 4
8067> set prompt = "%m [%h] %B[%@]%b [%/] you rang? "
8068.br
8069tut [37]
8070.Va [2:54pm]
8071[/usr/accts/sys] you rang? _
8072.Pp
8073If
8074.Sq %t
8075,
8076.Sq %@
8077,
8078.Sq %T
8079,
8080.Sq %p
8081, or
8082.Sq %P
8083is used, and
8084.Va noding
8085is not set,
8086then print
8087.Sq DING!
8088on the change of hour (i.e,
8089.Sq \&:00
8090minutes) instead of
8091the actual time.
8092.Pp
8093Set by default to
8094.Sq %#
8095in interactive shells.
8096.RE
8097.TP 8
8098.B prompt2 \fR(+)
8099The string with which to prompt in
8100.Va while
8101and
8102.Va foreach
8103loops and
8104after lines ending in
8105.Sq \e
8106The same format sequences may be used as in
8107.Va prompt
8108(q.v.);
8109note the variable meaning of
8110.Sq %R
8111Set by default to
8112.Sq %R?
8113in interactive shells.
8114.TP 8
8115.B prompt3 \fR(+)
8116The string with which to prompt when confirming automatic spelling correction.
8117The same format sequences may be used as in
8118.Va prompt
8119(q.v.);
8120note the variable meaning of
8121.Sq %R
8122Set by default to
8123.Sq CORRECT>%R (y|n|e|a)?
8124in interactive shells.
8125.TP 8
8126.B promptchars \fR(+)
8127If set (to a two-character string), the
8128.Sq %#
8129formatting sequence in the
8130.Va prompt
8131shell variable is replaced with the first character for
8132normal users and the second character for the superuser.
8133.TP 8
8134.B pushdtohome \fR(+)
8135If set,
8136.Va pushd
8137without arguments does
8138.Sq pushd ~
8139, like
8140.Va cd
8141.TP 8
8142.B pushdsilent \fR(+)
8143If set,
8144.Va pushd
8145and
8146.Va popd
8147do not print the directory stack.
8148.TP 8
8149.B recexact \fR(+)
8150If set, completion completes on an exact match even if a longer match is
8151possible.
8152.TP 8
8153.B recognize_only_executables \fR(+)
8154If set, command listing displays only files in the path that are
8155executable.
8156Slow.
8157.TP 8
8158.B rmstar \fR(+)
8159If set, the user is prompted before
8160.Sq rm *
8161is executed.
8162.TP 8
8163.B rprompt \fR(+)
8164The string to print on the right-hand side of the screen (after
8165the command input) when the prompt is being displayed on the left.
8166It recognizes the same formatting characters as
8167.Va prompt
8168It will automatically disappear and reappear as necessary, to ensure that
8169command input isn't obscured, and will appear only if the prompt,
8170command input, and itself will fit together on the first line.
8171If
8172.Va edit
8173isn't set, then
8174.Va rprompt
8175will be printed after
8176the prompt and before the command input.
8177.TP 8
8178.B savedirs \fR(+)
8179If set, the shell does
8180.Sq dirs \-S
8181before exiting.
8182If the first word is set to a number, at most that many directory stack
8183entries are saved.
8184.TP 8
8185.B savehist
8186If set, the shell does
8187.Sq history \-S
8188before exiting.
8189If the first word is set to a number, at most that many lines are saved.
8190(The number should be less than or equal to the number
8191.Va history
8192entries;
8193if it is set to greater than the number of
8194.Va history
8195settings, only
8196.Va history
8197entries will be saved)
8198If the second word is set to
8199.Sq merge
8200, the history list is merged with
8201the existing history file instead of replacing it (if there is one) and
8202sorted by time stamp and the most recent events are retained.
8203If the second word of
8204.Va savehist
8205is
8206.Sq merge
8207and the third word is set to
8208`lock', the history file update will be serialized with other shell sessions
8209that would possibly like to merge history at exactly the same time. (+)
8210.TP 8
8211.B sched \fR(+)
8212The format in which the
8213.Va sched
8214builtin command prints scheduled events;
8215if not given,
8216.Sq %h\et%T\et%R\en
8217is used.
8218The format sequences are described above under
8219.Va prompt
8220;
8221note the variable meaning of
8222.Sq %R
8223.TP 8
8224.B shell
8225The file in which the shell resides.
8226This is used in forking
8227shells to interpret files which have execute bits set, but
8228which are not executable by the system.
8229(See the description
8230of
8231.Va Builtin and non-builtin command execution
8232.)  Initialized to the
8233(system-dependent) home of the shell.
8234.TP 8
8235.B shlvl \fR(+)
8236The number of nested shells.
8237Reset to 1 in login shells.
8238See also
8239.Va loginsh
8240.TP 8
8241.B status
8242The exit status from the last command or backquote expansion, or any
8243command in a pipeline is propagated to
8244.Va status
8245(This is also the
8246default
8247.Xr csh 1
8248behavior.)
8249This default does not match what POSIX mandates (to return the
8250status of the last command only). To match the POSIX behavior, you need
8251to unset
8252.Va anyerror
8253.RS +8
8254.Pp
8255If the
8256.Va anyerror
8257variable is unset, the exit status of a pipeline
8258is determined only from the last command in the pipeline, and the exit
8259status of a backquote expansion is
8260.Va not
8261propagated to
8262.Va status
8263.Pp
8264If a command terminated abnormally, then 0200 is added to the status.
8265Builtin commands which fail return exit status
8266.Sq 1
8267, all other builtin
8268commands return status
8269.Sq 0
8270.RE
8271.TP 8
8272.B symlinks \fR(+)
8273Can be set to several different values to control symbolic link (`symlink')
8274resolution:
8275.RS +8
8276.Pp
8277If set to
8278.Sq chase
8279, whenever the current directory changes to a directory
8280containing a symbolic link, it is expanded to the real name of the directory
8281to which the link points.
8282This does not work for the user's home directory;
8283this is a bug.
8284.Pp
8285If set to
8286.Sq ignore
8287, the shell tries to construct a current directory
8288relative to the current directory before the link was crossed.
8289This means that
8290.Va cd
8291ing through a symbolic link and then
8292.Sq cd ..
8293ing
8294returns one to the original directory.
8295This affects only builtin commands
8296and filename completion.
8297.Pp
8298If set to
8299.Sq expand
8300, the shell tries to fix symbolic links by actually expanding
8301arguments which look like path names.
8302This affects any command, not just
8303builtins.
8304Unfortunately, this does not work for hard-to-recognize filenames,
8305such as those embedded in command options.
8306Expansion may be prevented by
8307quoting.
8308While this setting is usually the most convenient, it is sometimes
8309misleading and sometimes confusing when it fails to recognize an argument
8310which should be expanded.
8311A compromise is to use
8312.Sq ignore
8313and use the
8314editor command
8315.Va normalize-path
8316(bound by default to ^X-n) when necessary.
8317.Pp
8318Some examples are in order.
8319First, let's set up some play directories:
8320.IP "" 4
8321> cd /tmp
8322.br
8323> mkdir from from/src to
8324.br
8325> ln \-s from/src to/dst
8326.Pp
8327Here's the behavior with
8328.Va symlinks
8329unset,
8330.IP "" 4
8331> cd /tmp/to/dst; echo $cwd
8332.br
8333/tmp/to/dst
8334.br
8335> cd ..; echo $cwd
8336.br
8337/tmp/from
8338.Pp
8339here's the behavior with
8340.Va symlinks
8341set to
8342.Sq chase
8343,
8344.IP "" 4
8345> cd /tmp/to/dst; echo $cwd
8346.br
8347/tmp/from/src
8348.br
8349> cd ..; echo $cwd
8350.br
8351/tmp/from
8352.Pp
8353here's the behavior with
8354.Va symlinks
8355set to
8356.Sq ignore
8357,
8358.IP "" 4
8359> cd /tmp/to/dst; echo $cwd
8360.br
8361/tmp/to/dst
8362.br
8363> cd ..; echo $cwd
8364.br
8365/tmp/to
8366.Pp
8367and here's the behavior with
8368.Va symlinks
8369set to
8370.Sq expand
8371.IP "" 4
8372> cd /tmp/to/dst; echo $cwd
8373.br
8374/tmp/to/dst
8375.br
8376> cd ..; echo $cwd
8377.br
8378/tmp/to
8379.br
8380> cd /tmp/to/dst; echo $cwd
8381.br
8382/tmp/to/dst
8383.br
8384> cd ".."; echo $cwd
8385.br
8386/tmp/from
8387.br
8388> /bin/echo ..
8389.br
8390/tmp/to
8391.br
8392> /bin/echo ".."
8393.br
8394\&..
8395.Pp
8396Note that
8397.Sq expand
8398expansion 1) works just like
8399.Sq ignore
8400for builtins
8401like
8402.Va cd
8403, 2) is prevented by quoting, and 3) happens before
8404filenames are passed to non-builtin commands.
8405.RE
8406.TP 8
8407.B tcsh \fR(+)
8408The version number of the shell in the format
8409.Sq R.VV.Pp
8410,
8411where
8412.Sq R
8413is the major release number,
8414.Sq VV
8415the current version
8416and
8417.Sq PP
8418the patchlevel.
8419.TP 8
8420.B term
8421The terminal type.
8422Usually set in
8423.Va ~/.login
8424as described under
8425.Va Startup and shutdown
8426.TP 8
8427.B time
8428If set to a number, then the
8429.Va time
8430builtin (q.v.) executes automatically
8431after each command which takes more than that many CPU seconds.
8432If there is a second word, it is used as a format string for the output
8433of the
8434.Va time
8435builtin.
8436(u) The following sequences may be used in the
8437format string:
8438.Pp
8439.RS +8
8440.PD 0
8441.TP 4
8442%U
8443The time the process spent in user mode in cpu seconds.
8444.TP 4
8445%S
8446The time the process spent in kernel mode in cpu seconds.
8447.TP 4
8448%E
8449The elapsed (wall clock) time in seconds.
8450.TP 4
8451%P
8452The CPU percentage computed as (%U + %S) / %E.
8453.TP 4
8454%W
8455Number of times the process was swapped.
8456.TP 4
8457%X
8458The average amount in (shared) text space used in Kbytes.
8459.TP 4
8460%D
8461The average amount in (unshared) data/stack space used in Kbytes.
8462.TP 4
8463%K
8464The total space used (%X + %D) in Kbytes.
8465.TP 4
8466%M
8467The maximum memory the process had in use at any time in Kbytes.
8468.TP 4
8469%F
8470The number of major page faults (page needed to be brought from disk).
8471.TP 4
8472%R
8473The number of minor page faults.
8474.TP 4
8475%I
8476The number of input operations.
8477.TP 4
8478%O
8479The number of output operations.
8480.TP 4
8481%r
8482The number of socket messages received.
8483.TP 4
8484%s
8485The number of socket messages sent.
8486.TP 4
8487%k
8488The number of signals received.
8489.TP 4
8490%w
8491The number of voluntary context switches (waits).
8492.TP 4
8493%c
8494The number of involuntary context switches.
8495.PD
8496.Pp
8497Only the first four sequences are supported on systems without BSD resource
8498limit functions.
8499The default time format is
8500.Sq %Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww
8501for
8502systems that support resource usage reporting and
8503.Sq %Uu %Ss %E %P
8504for
8505systems that do not.
8506.Pp
8507Under Sequent's DYNIX/ptx, %X, %D, %K, %r and %s are not
8508available, but the following additional sequences are:
8509.Pp
8510.PD 0
8511.TP 4
8512%Y
8513The number of system calls performed.
8514.TP 4
8515%Z
8516The number of pages which are zero-filled on demand.
8517.TP 4
8518%i
8519The number of times a process's resident set size was increased by the kernel.
8520.TP 4
8521%d
8522The number of times a process's resident set size was decreased by the kernel.
8523.TP 4
8524%l
8525The number of read system calls performed.
8526.TP 4
8527%m
8528The number of write system calls performed.
8529.TP 4
8530%p
8531The number of reads from raw disk devices.
8532.TP 4
8533%q
8534The number of writes to raw disk devices.
8535.PD
8536.Pp
8537and the default time format is
8538.Sq %Uu %Ss %E %P %I+%Oio %Fpf+%Ww
8539Note that the CPU percentage can be higher than 100% on multi-processors.
8540.RE
8541.TP 8
8542.B tperiod \fR(+)
8543The period, in minutes, between executions of the
8544.Va periodic
8545special alias.
8546.TP 8
8547.B tty \fR(+)
8548The name of the tty, or empty if not attached to one.
8549.TP 8
8550.B uid \fR(+)
8551The user's real user ID.
8552.TP 8
8553.B user
8554The user's login name.
8555.TP 8
8556.B verbose
8557If set, causes the words of each
8558command to be printed, after history substitution (if any).
8559Set by the
8560.Fl v\fR command line option.
8561.TP 8
8562.B version \fR(+)
8563The version ID stamp.
8564It contains the shell's version number (see
8565.Va tcsh
8566),
8567origin, release date, vendor, operating system and machine (see
8568.Va VENDOR
8569,
8570.Va OSTYPE
8571and
8572.Va MACHTYPE
8573) and a comma-separated
8574list of options which were set at compile time.
8575Options which are set by default in the distribution are noted.
8576.Pp
8577.RS +8
8578.PD 0
8579.TP 6
85808b
8581The shell is eight bit clean; default
8582.TP 6
85837b
8584The shell is not eight bit clean
8585.TP 6
8586wide
8587The shell is multibyte encoding clean (like UTF-8)
8588.TP 6
8589nls
8590The system's NLS is used; default for systems with NLS
8591.TP 6
8592lf
8593Login shells execute
8594.Va /etc/csh.login
8595before instead of after
8596.Va /etc/csh.cshrc
8597and
8598.Va ~/.login
8599before instead of after
8600.Va ~/.tcshrc
8601and
8602.Va ~/.history
8603.TP 6
8604dl
8605`.' is put last in
8606.Va path
8607for security; default
8608.TP 6
8609nd
8610`.' is omitted from
8611.Va path
8612for security
8613.TP 6
8614vi
8615.Va vi
8616(1)\-style editing is the default rather than
8617.Va emacs
8618(1)\-style
8619.TP 6
8620dtr
8621Login shells drop DTR when exiting
8622.TP 6
8623bye
8624.Va bye
8625is a synonym for
8626.Va logout
8627and
8628.Va log
8629is an alternate name for
8630.Va watchlog
8631.TP 6
8632al
8633.Va autologout
8634is enabled; default
8635.TP 6
8636kan
8637Kanji is used if appropriate according to locale settings,
8638unless the
8639.Va nokanji
8640shell variable is set
8641.TP 6
8642sm
8643The system's
8644.Va malloc
8645(3) is used
8646.TP 6
8647hb
8648The
8649.Sq #!<program> <args>
8650convention is emulated when executing shell scripts
8651.TP 6
8652ng
8653The
8654.Va newgrp
8655builtin is available
8656.TP 6
8657rh
8658The shell attempts to set the
8659.Va REMOTEHOST
8660environment variable
8661.TP 6
8662afs
8663The shell verifies your password with the kerberos server if local
8664authentication fails.
8665The
8666.Va afsuser
8667shell variable or the
8668.Va AFSUSER
8669environment variable override your local username if set.
8670.PD
8671.Pp
8672An administrator may enter additional strings to indicate differences
8673in the local version.
8674.RE
8675.TP 8
8676.B vimode \fR(+)
8677.RS +8
8678If unset, various key bindings change behavior to be more
8679.Va emacs
8680(1)\-style:
8681word boundaries are determined by
8682.Va wordchars
8683versus other characters.
8684.Pp
8685If set, various key bindings change behavior to be more
8686.Va vi
8687(1)\-style:
8688word boundaries are determined by
8689.Va wordchars
8690versus whitespace
8691versus other characters;
8692cursor behavior depends upon current vi mode (command, delete, insert, replace).
8693.Pp
8694This variable is unset by
8695.Va bindkey
8696
8697.Va -e
8698and
8699set by
8700.Va bindkey
8701
8702.Va -v
8703.B vimode
8704may be explicitly set or unset by the user after those
8705.Va bindkey
8706operations if required.
8707.RE
8708.TP 8
8709.B visiblebell \fR(+)
8710If set, a screen flash is used rather than the audible bell.
8711See also
8712.Va nobeep
8713.TP 8
8714.B watch \fR(+)
8715A list of user/terminal pairs to watch for logins and logouts.
8716If either the user is
8717.Sq any
8718all terminals are watched for the given user
8719and vice versa.
8720Setting
8721.Va watch
8722to
8723.Sq (any any)
8724watches all users and terminals.
8725For example,
8726.RS +8
8727.IP "" 4
8728set watch = (george ttyd1 any console $user any)
8729.Pp
8730reports activity of the user
8731.Sq george
8732on ttyd1, any user on the console, and
8733oneself (or a trespasser) on any terminal.
8734.Pp
8735Logins and logouts are checked every 10 minutes by default, but the first
8736word of
8737.Va watch
8738can be set to a number to check every so many minutes.
8739For example,
8740.IP "" 4
8741set watch = (1 any any)
8742.Pp
8743reports any login/logout once every minute.
8744For the impatient, the
8745.Va log
8746builtin command triggers a
8747.Va watch
8748report at any time.
8749All current logins
8750are reported (as with the
8751.Va log
8752builtin) when
8753.Va watch
8754is first set.
8755.Pp
8756The
8757.Va who
8758shell variable controls the format of
8759.Va watch
8760reports.
8761.RE
8762.TP 8
8763.B who \fR(+)
8764The format string for
8765.Va watch
8766messages.
8767The following sequences
8768are replaced by the given information:
8769.Pp
8770.RS +8
8771.PD 0
8772.TP 4
8773%n
8774The name of the user who logged in/out.
8775.TP 4
8776%a
8777The observed action, i.e.,
8778.Sq logged on
8779,
8780.Sq logged off
8781or
8782.Sq replaced
8783.Va olduser
8784on
8785.TP 4
8786%l
8787The terminal (tty) on which the user logged in/out.
8788.TP 4
8789%M
8790The full hostname of the remote host, or
8791.Sq local
8792if the login/logout was
8793from the local host.
8794.TP 4
8795%m
8796The hostname of the remote host up to the first
8797.Sq .
8798The full name is printed if it is an IP address or an X Window System display.
8799.PD
8800.Pp
8801%M and %m are available on only systems that store the remote hostname in
8802.Va /etc/utmp
8803If unset,
8804.Sq %n has %a %l from %m.
8805is used, or
8806.Sq %n has %a %l.
8807on systems
8808which don't store the remote hostname.
8809.RE
8810.TP 8
8811.B wordchars \fR(+)
8812A list of non-alphanumeric characters to be considered part of a word by the
8813.Va forward-word
8814,
8815.Va backward-word
8816etc., editor commands.
8817If unset, the default value is determined based on the state of
8818.Va vimode
8819:
8820if
8821.Va vimode
8822is unset,
8823.Sq *?_\-.[]~=
8824is used as the default;
8825if
8826.Va vimode
8827is set,
8828.Sq _
8829is used as the default.
8830.Sh ENVIRONMENT
8831.TP 8
8832.B AFSUSER \fR(+)
8833Equivalent to the
8834.Va afsuser
8835shell variable.
8836.TP 8
8837.B COLUMNS
8838The number of columns in the terminal.
8839See
8840.Va Terminal management
8841.TP 8
8842.B DISPLAY
8843Used by X Window System (see
8844.Va X
8845(1)).
8846If set, the shell does not set
8847.Va autologout
8848(q.v.).
8849.TP 8
8850.B EDITOR
8851The pathname to a default editor.
8852Used by the
8853.Va run-fg-editor
8854editor command if the
8855the
8856.Va editors
8857shell variable is unset.
8858See also the
8859.Va VISUAL
8860environment variable.
8861.TP 8
8862.B GROUP \fR(+)
8863Equivalent to the
8864.Va group
8865shell variable.
8866.TP 8
8867.B HOME
8868Equivalent to the
8869.Va home
8870shell variable.
8871.TP 8
8872.B HOST \fR(+)
8873Initialized to the name of the machine on which the shell
8874is running, as determined by the
8875.Va gethostname
8876(2) system call.
8877.TP 8
8878.B HOSTTYPE \fR(+)
8879Initialized to the type of machine on which the shell
8880is running, as determined at compile time.
8881This variable is obsolete and
8882will be removed in a future version.
8883.TP 8
8884.B HPATH \fR(+)
8885A colon-separated list of directories in which the
8886.Va run-help
8887editor
8888command looks for command documentation.
8889.TP 8
8890.B LANG
8891Gives the preferred character environment.
8892See
8893.Va Native Language System support
8894.TP 8
8895.B LC_CTYPE
8896If set, only ctype character handling is changed.
8897See
8898.Va Native Language System support
8899.TP 8
8900.B LINES
8901The number of lines in the terminal.
8902See
8903.Va Terminal management
8904.TP 8
8905.B LS_COLORS
8906The format of this variable is reminiscent of the
8907.Va termcap(5)
8908file format; a colon-separated list of expressions of the form
8909"
8910.Va xx=string
8911", where "
8912.Va xx
8913" is a two-character variable name.
8914The
8915variables with their associated defaults are:
8916.Pp
8917.RS +8
8918.RS +4
8919.PD 0
8920.TP 12
8921no	0
8922Normal (non-filename) text
8923.TP 12
8924fi	0
8925Regular file
8926.TP 12
8927di	01;34
8928Directory
8929.TP 12
8930ln	01;36
8931Symbolic link
8932.TP 12
8933pi	33
8934Named pipe (FIFO)
8935.TP 12
8936so	01;35
8937Socket
8938.TP 12
8939do	01;35
8940Door
8941.TP 12
8942bd	01;33
8943Block device
8944.TP 12
8945cd	01;32
8946Character device
8947.TP 12
8948ex	01;32
8949Executable file
8950.TP 12
8951mi	(none)
8952Missing file (defaults to fi)
8953.TP 12
8954or	(none)
8955Orphaned symbolic link (defaults to ln)
8956.TP 12
8957lc	^[[
8958Left code
8959.TP 12
8960rc	m
8961Right code
8962.TP 12
8963ec	(none)
8964End code (replaces lc+no+rc)
8965.PD
8966.RE
8967.Pp
8968You need to include only the variables you want to change from
8969the default.
8970.Pp
8971File names can also be colorized based on filename extension.
8972This is specified in the
8973.Va LS_COLORS
8974variable using the syntax
8975.Va "*ext=string"
8976For example, using ISO 6429 codes, to color
8977all C\-language source files blue you would specify
8978.Va "*.c=34"
8979This would color all files ending in
8980.Va .c
8981in blue (34) color.
8982.Pp
8983Control characters can be written either in C\-style\-escaped
8984notation, or in stty\-like ^\-notation.
8985The C\-style notation
8986adds
8987.Va ^[
8988for Escape, \fB\_\fR for a normal space character,
8989and
8990.Va ?
8991for Delete.
8992In addition, the
8993.Va ^[
8994escape character
8995can be used to override the default interpretation of
8996.Va ^[
8997,
8998.Va ^
8999,
9000.Va :
9001and
9002.Va =
9003.Pp
9004Each file will be written as
9005.Va <lc>
9006
9007.Va <color-code>
9008.Va <rc>
9009
9010.Va <filename>
9011
9012.Va <ec>
9013If the
9014.Va <ec>
9015code is undefined, the sequence
9016.Va <lc>
9017\fB<no>
9018.Va <rc>
9019will be used instead.
9020This is generally more convenient
9021to use, but less general.
9022The left, right and end codes are
9023provided so you don't have to type common parts over and over
9024again and to support weird terminals; you will generally not
9025need to change them at all unless your terminal does not use
9026ISO 6429 color sequences but a different system.
9027.Pp
9028If your terminal does use ISO 6429 color codes, you can
9029compose the type codes (i.e., all except the
9030.Va lc
9031,
9032.Va rc
9033,
9034and
9035.Va ec
9036codes) from numerical commands separated by semicolons.
9037The
9038most common commands are:
9039.Pp
9040.RS +8
9041.PD 0
9042.TP 4
90430
9044to restore default color
9045.TP 4
90461
9047for brighter colors
9048.TP 4
90494
9050for underlined text
9051.TP 4
90525
9053for flashing text
9054.TP 4
905530
9056for black foreground
9057.TP 4
905831
9059for red foreground
9060.TP 4
906132
9062for green foreground
9063.TP 4
906433
9065for yellow (or brown) foreground
9066.TP 4
906734
9068for blue foreground
9069.TP 4
907035
9071for purple foreground
9072.TP 4
907336
9074for cyan foreground
9075.TP 4
907637
9077for white (or gray) foreground
9078.TP 4
907940
9080for black background
9081.TP 4
908241
9083for red background
9084.TP 4
908542
9086for green background
9087.TP 4
908843
9089for yellow (or brown) background
9090.TP 4
909144
9092for blue background
9093.TP 4
909445
9095for purple background
9096.TP 4
909746
9098for cyan background
9099.TP 4
910047
9101for white (or gray) background
9102.PD
9103.RE
9104.Pp
9105Not all commands will work on all systems or display devices.
9106.Pp
9107A few terminal programs do not recognize the default end code
9108properly.
9109If all text gets colorized after you do a directory
9110listing, try changing the
9111.Va no
9112and
9113.Va fi
9114codes from 0 to the
9115numerical codes for your standard fore- and background colors.
9116.RE
9117.TP 8
9118.B MACHTYPE \fR(+)
9119The machine type (microprocessor class or machine model), as determined at compile time.
9120.TP 8
9121.B NOREBIND \fR(+)
9122If set, printable characters are not rebound to
9123.Va self-insert-command
9124See
9125.Va Native Language System support
9126.TP 8
9127.B OSTYPE \fR(+)
9128The operating system, as determined at compile time.
9129.TP 8
9130.B PATH
9131A colon-separated list of directories in which to look for executables.
9132Equivalent to the
9133.Va path
9134shell variable, but in a different format.
9135.TP 8
9136.B PWD \fR(+)
9137Equivalent to the
9138.Va cwd
9139shell variable, but not synchronized to it;
9140updated only after an actual directory change.
9141.TP 8
9142.B REMOTEHOST \fR(+)
9143The host from which the user has logged in remotely, if this is the case and
9144the shell is able to determine it.
9145Set only if the shell was so compiled;
9146see the
9147.Va version
9148shell variable.
9149.TP 8
9150.B SHLVL \fR(+)
9151Equivalent to the
9152.Va shlvl
9153shell variable.
9154.TP 8
9155.B SYSTYPE \fR(+)
9156The current system type.
9157(Domain/OS only)
9158.TP 8
9159.B TERM
9160Equivalent to the
9161.Va term
9162shell variable.
9163.TP 8
9164.B TERMCAP
9165The terminal capability string.
9166See
9167.Va Terminal management
9168.TP 8
9169.B USER
9170Equivalent to the
9171.Va user
9172shell variable.
9173.TP 8
9174.B VENDOR \fR(+)
9175The vendor, as determined at compile time.
9176.TP 8
9177.B VISUAL
9178The pathname to a default full-screen editor.
9179Used by the
9180.Va run-fg-editor
9181editor command if the
9182the
9183.Va editors
9184shell variable is unset.
9185See also the
9186.Va EDITOR
9187environment variable.
9188.Sh FILES
9189.PD 0
9190.TP 16
9191.I /etc/csh.cshrc
9192Read first by every shell.
9193ConvexOS, Stellix and Intel use
9194.Va /etc/cshrc
9195and
9196NeXTs use
9197.Va /etc/cshrc.std
9198A/UX, AMIX, Cray and IRIX have no equivalent in
9199.Xr csh 1
9200,
9201but read this file in
9202.Nm
9203anyway.
9204Solaris 2.x does not have it either, but
9205.Nm
9206reads
9207.Va /etc/.cshrc
9208(+)
9209.TP 16
9210.I /etc/csh.login
9211Read by login shells after
9212.Va /etc/csh.cshrc
9213ConvexOS, Stellix and Intel use
9214.Va /etc/login
9215,
9216NeXTs use
9217.Va /etc/login.std
9218, Solaris 2.x uses
9219.Va /etc/.login
9220and
9221A/UX, AMIX, Cray and IRIX use
9222.Va /etc/cshrc
9223.TP 16
9224.I ~/.tcshrc \fR(+)
9225Read by every shell after
9226.Va /etc/csh.cshrc
9227or its equivalent.
9228.TP 16
9229.I ~/.cshrc
9230Read by every shell, if
9231.Va ~/.tcshrc
9232doesn't exist,
9233after
9234.Va /etc/csh.cshrc
9235or its equivalent.
9236This manual uses
9237.Sq
9238.Va ~/.tcshrc
9239to mean `
9240.Va ~/.tcshrc
9241or,
9242if
9243.Va ~/.tcshrc
9244is not found,
9245.Va ~/.cshrc
9246'.
9247.TP 16
9248.I ~/.history
9249Read by login shells after
9250.Va ~/.tcshrc
9251if
9252.Va savehist
9253is set, but see also
9254.Va histfile
9255.TP 16
9256.I ~/.login
9257Read by login shells after
9258.Va ~/.tcshrc
9259or
9260.Va ~/.history
9261The shell may be compiled to read
9262.Va ~/.login
9263before instead of after
9264.Va ~/.tcshrc
9265and
9266.Va ~/.history
9267; see the
9268.Va version
9269shell variable.
9270.TP 16
9271.I ~/.cshdirs \fR(+)
9272Read by login shells after
9273.Va ~/.login
9274if
9275.Va savedirs
9276is set, but see also
9277.Va dirsfile
9278.TP 16
9279.I /etc/csh.logout
9280Read by login shells at logout.
9281ConvexOS, Stellix and Intel use
9282.Va /etc/logout
9283and
9284NeXTs use
9285.Va /etc/logout.std
9286A/UX, AMIX, Cray and IRIX have no equivalent in
9287.Xr csh 1
9288,
9289but read this file in
9290.Nm
9291anyway.
9292Solaris 2.x does not have it either, but
9293.Nm
9294reads
9295.Va /etc/.logout
9296(+)
9297.TP 16
9298.I ~/.logout
9299Read by login shells at logout after
9300.Va /etc/csh.logout
9301or its equivalent.
9302.TP 16
9303.I /bin/sh
9304Used to interpret shell scripts not starting with a
9305.Sq #
9306.TP 16
9307.I /tmp/sh*
9308Temporary file for
9309.Sq <<
9310.TP 16
9311.I /etc/passwd
9312Source of home directories for
9313.Sq ~name
9314substitutions.
9315.PD
9316.Pp
9317The order in which startup files are read may differ if the shell was so
9318compiled; see
9319.Va Startup and shutdown
9320and the
9321.Va version
9322shell variable.
9323.Sh "NEW FEATURES (+)"
9324This manual describes
9325.Nm
9326as a single entity,
9327but experienced
9328.Xr csh 1
9329users will want to pay special attention to
9330.Nm
9331's new features.
9332.Pp
9333A command-line editor, which supports
9334.Va emacs
9335(1)\-style
9336or
9337.Va vi
9338(1)\-style key bindings.
9339See
9340.Va The command-line editor
9341and
9342.Va Editor commands
9343.Pp
9344Programmable, interactive word completion and listing.
9345See
9346.Sx Completion and listing
9347and the
9348.Va complete
9349and
9350.Va uncomplete
9351builtin commands.
9352.Pp
9353.Va Spelling correction
9354(q.v.) of filenames, commands and variables.
9355.Pp
9356.Va Editor commands
9357(q.v.) which perform other useful functions in the middle of
9358typed commands, including documentation lookup
9359.Va ( run-help ),
9360quick editor restarting
9361.Va ( run-fg-editor )
9362and
9363command resolution
9364.Va ( which-command ).
9365.Pp
9366An enhanced history mechanism.
9367Events in the history list are time-stamped.
9368See also the
9369.Va history
9370command and its associated shell variables,
9371the previously undocumented
9372.Sq #
9373event specifier and new modifiers
9374under
9375.Va History substitution
9376,
9377the
9378.Va *-history
9379,
9380.Va history-search-*
9381,
9382.Va i-search-*
9383,
9384.Va vi-search-*
9385and
9386.Va toggle-literal-history
9387editor commands
9388and the
9389.Va histlit
9390shell variable.
9391.Pp
9392Enhanced directory parsing and directory stack handling.
9393See the
9394.Va cd
9395,
9396.Va pushd
9397,
9398.Va popd
9399and
9400.Va dirs
9401commands and their associated
9402shell variables, the description of
9403.Va Directory stack substitution
9404,
9405the
9406.Va dirstack
9407,
9408.Va owd
9409and
9410.Va symlinks
9411shell variables and
9412the
9413.Va normalize-command
9414and
9415.Va normalize-path
9416editor commands.
9417.Pp
9418Negation in glob-patterns.
9419See
9420.Va Filename substitution
9421.Pp
9422New
9423.Va File inquiry operators
9424(q.v.) and a
9425.Va filetest
9426builtin which uses them.
9427.Pp
9428A variety of
9429.Va Automatic, periodic and timed events
9430(q.v.) including
9431scheduled events, special aliases, automatic logout and terminal locking,
9432command timing and watching for logins and logouts.
9433.Pp
9434Support for the Native Language System
9435(see
9436.Va Native Language System support
9437),
9438OS variant features
9439(see
9440.Va OS variant support
9441and the
9442.Va echo_style
9443shell variable)
9444and system-dependent file locations (see
9445.Va FILES
9446).
9447.Pp
9448Extensive terminal-management capabilities.
9449See
9450.Va Terminal management
9451.Pp
9452New builtin commands including
9453.Va builtins
9454,
9455.Va hup
9456, \fIls\-F\fR,
9457.Va newgrp
9458,
9459.Va printenv
9460,
9461.Va which
9462and
9463.Va where
9464(q.v.).
9465.Pp
9466New variables that make useful information easily available to the shell.
9467See the
9468.Va gid
9469,
9470.Va loginsh
9471,
9472.Va oid
9473,
9474.Va shlvl
9475,
9476.Va tcsh
9477,
9478.Va tty
9479,
9480.Va uid
9481and
9482.Va version
9483shell variables and the
9484.Va HOST
9485,
9486.Va REMOTEHOST
9487,
9488.Va VENDOR
9489,
9490.Va OSTYPE
9491and
9492.Va MACHTYPE
9493environment
9494variables.
9495.Pp
9496A new syntax for including useful information in the prompt string
9497(see
9498.Va prompt
9499),
9500and special prompts for loops and spelling correction
9501(see
9502.Va prompt2
9503and
9504.Va prompt3
9505).
9506.Pp
9507Read-only variables.
9508See
9509.Va Variable substitution
9510.Sh BUGS
9511When a suspended command is restarted, the shell prints the directory
9512it started in if this is different from the current directory.
9513This can
9514be misleading (i.e., wrong) as the job may have changed directories internally.
9515.Pp
9516Shell builtin functions are not stoppable/restartable.
9517Command sequences
9518of the form
9519.Sq a ; b ; c
9520are also not handled gracefully when stopping is
9521attempted.
9522If you suspend
9523.Sq b
9524, the shell will then immediately execute
9525`c'.
9526This is especially noticeable if this expansion results from an
9527.Va alias
9528It suffices to place the sequence of commands in ()'s to force it
9529to a subshell, i.e.,
9530.Sq ( a ; b ; c )
9531.Pp
9532Control over tty output after processes are started is primitive; perhaps
9533this will inspire someone to work on a good virtual terminal interface.
9534In a virtual terminal interface much more interesting things could be
9535done with output control.
9536.Pp
9537Alias substitution is most often used to clumsily simulate shell procedures;
9538shell procedures should be provided rather than aliases.
9539.Pp
9540Control structures should be parsed rather than being recognized as
9541built-in commands.
9542This would allow control commands to be placed anywhere,
9543to be combined with
9544.Sq |
9545, and to be used with
9546.Sq &
9547and
9548.Sq ;
9549metasyntax.
9550.Pp
9551.Va foreach
9552doesn't ignore here documents when looking for its
9553.Va end
9554.Pp
9555It should be possible to use the
9556.Sq \&:
9557modifiers on the output of command
9558substitutions.
9559.Pp
9560The screen update for lines longer than the screen width is very poor
9561if the terminal cannot move the cursor up (i.e., terminal type
9562.Sq dumb
9563).
9564.Pp
9565.Va HPATH
9566and
9567.Va NOREBIND
9568don't need to be environment variables.
9569.Pp
9570Glob-patterns which do not use
9571.Sq \&?
9572,
9573.Sq *
9574or
9575.Sq []
9576or which use
9577.Sq {}
9578or
9579.Sq ~
9580are not negated correctly.
9581.Pp
9582The single-command form of
9583.Va if
9584does output redirection even if
9585the expression is false and the command is not executed.
9586.Pp
9587\fIls\-F\fR includes file identification characters when sorting filenames
9588and does not handle control characters in filenames well.
9589It cannot be
9590interrupted.
9591.Pp
9592Command substitution supports multiple commands and conditions, but not
9593cycles or backward
9594.Va goto
9595s.
9596.Pp
9597Report bugs at http://bugs.gw.com/, preferably with fixes.
9598If you want to
9599help maintain and test tcsh, send mail to tcsh-request@mx.gw.com with the
9600text
9601.Sq subscribe tcsh
9602on a line by itself in the body.
9603.Sh THE T IN TCSH
9604In 1964, DEC produced the PDP-6.
9605The PDP-10 was a later re-implementation.
9606It
9607was re-christened the DECsystem-10 in 1970 or so when DEC brought out the
9608second model, the KI10.
9609.Pp
9610TENEX was created at Bolt, Beranek & Newman (a Cambridge, Massachusetts
9611think tank) in
96121972 as an experiment in demand-paged virtual memory operating systems.
9613They
9614built a new pager for the DEC PDP-10 and created the OS to go with it.
9615It was
9616extremely successful in academia.
9617.Pp
9618In 1975, DEC brought out a new model of the PDP-10, the KL10; they intended to
9619have only a version of TENEX, which they had licensed from BBN, for the new
9620box.
9621They called their version TOPS-20 (their capitalization is trademarked).
9622A lot of TOPS-10 users (`The OPerating System for PDP-10') objected; thus DEC
9623found themselves supporting two incompatible systems on the same hardware--but
9624then there were 6 on the PDP-11!
9625.Pp
9626TENEX, and TOPS-20 to version 3, had command completion
9627via a user-code-level subroutine library called ULTCMD.
9628With version 3, DEC
9629moved all that capability and more into the monitor (`kernel' for you Unix
9630types), accessed by the COMND% JSYS (`Jump to SYStem' instruction, the
9631supervisor call mechanism [are my IBM roots also showing?]).
9632.Pp
9633The creator of tcsh was impressed by this feature and several others of TENEX
9634and TOPS-20, and created a version of csh which mimicked them.
9635.Sh LIMITATIONS
9636The system limits argument lists to ARG_MAX characters.
9637.Pp
9638The number of arguments to a command which involves filename expansion is
9639limited to 1/6th the number of characters allowed in an argument list.
9640.Pp
9641Command substitutions may substitute no more characters than are allowed in
9642an argument list.
9643.Pp
9644To detect looping, the shell restricts the number of
9645.Va alias
9646substitutions on a single line to 20.
9647.Sh "SEE ALSO"
9648csh(1), emacs(1), ls(1), newgrp(1), sh(1), setpath(1), stty(1), su(1),
9649tset(1), vi(1), x(1), access(2), execve(2), fork(2), killpg(2),
9650pipe(2), setrlimit(2), sigvec(2), stat(2), umask(2), vfork(2), wait(2),
9651malloc(3), setlocale(3), tty(4), a.out(5), termcap(5), environ(7),
9652termio(7), Introduction to the C Shell
9653.Sh VERSION
9654This manual documents tcsh 6.20.00 (Astron) 2016-11-24.
9655.Sh AUTHORS
9656.PD 0
9657.TP 2
9658William Joy
9659Original author of
9660.Xr csh 1
9661.TP 2
9662J.E. Kulp, IIASA, Laxenburg, Austria
9663Job control and directory stack features
9664.TP 2
9665Ken Greer, HP Labs, 1981
9666File name completion
9667.TP 2
9668Mike Ellis, Fairchild, 1983
9669Command name recognition/completion
9670.TP 2
9671Paul Placeway, Ohio State CIS Dept., 1983-1993
9672Command line editor, prompt routines, new glob syntax and numerous fixes
9673and speedups
9674.TP 2
9675Karl Kleinpaste, CCI 1983-4
9676Special aliases, directory stack extraction stuff, login/logout watch,
9677scheduled events, and the idea of the new prompt format
9678.TP 2
9679Rayan Zachariassen, University of Toronto, 1984
9680\fIls\-F\fR and
9681.Va which
9682builtins and numerous bug fixes, modifications
9683and speedups
9684.TP 2
9685Chris Kingsley, Caltech
9686Fast storage allocator routines
9687.TP 2
9688Chris Grevstad, TRW, 1987
9689Incorporated 4.3BSD
9690.Xr csh 1
9691into
9692.Nm
9693.TP 2
9694Christos S. Zoulas, Cornell U. EE Dept., 1987-94
9695Ports to HPUX, SVR2 and SVR3, a SysV version of getwd.c, SHORT_STRINGS support
9696and a new version of sh.glob.c
9697.TP 2
9698James J Dempsey, BBN, and Paul Placeway, OSU, 1988
9699A/UX port
9700.TP 2
9701Daniel Long, NNSC, 1988
9702.Va wordchars
9703.TP 2
9704Patrick Wolfe, Kuck and Associates, Inc., 1988
9705.Va vi
9706mode cleanup
9707.TP 2
9708David C Lawrence, Rensselaer Polytechnic Institute, 1989
9709.Va autolist
9710and ambiguous completion listing
9711.TP 2
9712Alec Wolman, DEC, 1989
9713Newlines in the prompt
9714.TP 2
9715Matt Landau, BBN, 1989
9716.Va ~/.tcshrc
9717.TP 2
9718Ray Moody, Purdue Physics, 1989
9719Magic space bar history expansion
9720.TP 2
9721Mordechai ????, Intel, 1989
9722printprompt() fixes and additions
9723.TP 2
9724Kazuhiro Honda, Dept. of Computer Science, Keio University, 1989
9725Automatic spelling correction and
9726.Va prompt3
9727.TP 2
9728Per Hedeland, Ellemtel, Sweden, 1990-
9729Various bugfixes, improvements and manual updates
9730.TP 2
9731Hans J. Albertsson (Sun Sweden)
9732.Va ampm
9733,
9734.Va settc
9735and
9736.Va telltc
9737.TP 2
9738Michael Bloom
9739Interrupt handling fixes
9740.TP 2
9741Michael Fine, Digital Equipment Corp
9742Extended key support
9743.TP 2
9744Eric Schnoebelen, Convex, 1990
9745Convex support, lots of
9746.Xr csh 1
9747bug fixes,
9748save and restore of directory stack
9749.TP 2
9750Ron Flax, Apple, 1990
9751A/UX 2.0 (re)port
9752.TP 2
9753Dan Oscarsson, LTH Sweden, 1990
9754NLS support and simulated NLS support for non NLS sites, fixes
9755.TP 2
9756Johan Widen, SICS Sweden, 1990
9757.Va shlvl
9758, Mach support,
9759.Va correct-line
9760, 8-bit printing
9761.TP 2
9762Matt Day, Sanyo Icon, 1990
9763POSIX termio support, SysV limit fixes
9764.TP 2
9765Jaap Vermeulen, Sequent, 1990-91
9766Vi mode fixes, expand-line, window change fixes, Symmetry port
9767.TP 2
9768Martin Boyer, Institut de recherche d'Hydro-Quebec, 1991
9769.Va autolist
9770beeping options, modified the history search to search for
9771the whole string from the beginning of the line to the cursor.
9772.TP 2
9773Scott Krotz, Motorola, 1991
9774Minix port
9775.TP 2
9776David Dawes, Sydney U. Australia, Physics Dept., 1991
9777SVR4 job control fixes
9778.TP 2
9779Jose Sousa, Interactive Systems Corp., 1991
9780Extended
9781.Va vi
9782fixes and
9783.Va vi
9784delete command
9785.TP 2
9786Marc Horowitz, MIT, 1991
9787ANSIfication fixes, new exec hashing code, imake fixes,
9788.Va where
9789.TP 2
9790Bruce Sterling Woodcock, sterling@netcom.com, 1991-1995
9791ETA and Pyramid port, Makefile and lint fixes,
9792.Va ignoreeof
9793=n addition, and
9794various other portability changes and bug fixes
9795.TP 2
9796Jeff Fink, 1992
9797.Va complete-word-fwd
9798and
9799.Va complete-word-back
9800.TP 2
9801Harry C. Pulley, 1992
9802Coherent port
9803.TP 2
9804Andy Phillips, Mullard Space Science Lab U.K., 1992
9805VMS-POSIX port
9806.TP 2
9807Beto Appleton, IBM Corp., 1992
9808Walking process group fixes,
9809.Xr csh 1
9810bug fixes,
9811POSIX file tests, POSIX SIGHUP
9812.TP 2
9813Scott Bolte, Cray Computer Corp., 1992
9814CSOS port
9815.TP 2
9816Kaveh R. Ghazi, Rutgers University, 1992
9817Tek, m88k, Titan and Masscomp ports and fixes.
9818Added autoconf support.
9819.TP 2
9820Mark Linderman, Cornell University, 1992
9821OS/2 port
9822.TP 2
9823Mika Liljeberg, liljeber@kruuna.Helsinki.FI, 1992
9824Linux port
9825.TP 2
9826Tim P. Starrin, NASA Langley Research Center Operations, 1993
9827Read-only variables
9828.TP 2
9829Dave Schweisguth, Yale University, 1993-4
9830New man page and tcsh.man2html
9831.TP 2
9832Larry Schwimmer, Stanford University, 1993
9833AFS and HESIOD patches
9834.TP 2
9835Luke Mewburn, RMIT University, 1994-6
9836Enhanced directory printing in prompt,
9837added
9838.Va ellipsis
9839and
9840.Va rprompt
9841.TP 2
9842Edward Hutchins, Silicon Graphics Inc., 1996
9843Added implicit cd.
9844.TP 2
9845Martin Kraemer, 1997
9846Ported to Siemens Nixdorf EBCDIC machine
9847.TP 2
9848Amol Deshpande, Microsoft, 1997
9849Ported to WIN32 (Windows/95 and Windows/NT); wrote all the missing library
9850and message catalog code to interface to Windows.
9851.TP 2
9852Taga Nayuta, 1998
9853Color ls additions.
9854.PD
9855.Pp
9856.Sh "THANKS TO"
9857Bryan Dunlap, Clayton Elwell, Karl Kleinpaste, Bob Manson, Steve Romig,
9858Diana Smetters, Bob Sutterfield, Mark Verber, Elizabeth Zwicky and all
9859the other people at Ohio State for suggestions and encouragement
9860.Pp
9861All the people on the net, for putting up with,
9862reporting bugs in, and suggesting new additions to each and every version
9863.Pp
9864Richard M. Alderson III, for writing the
9865.Sq T in tcsh
9866section
9867