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