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