1 .\" $tcsh: tcsh.man.new,v 1.5 2016/11/24 15:06:09 christos Exp $
2 .\" From: tcsh: tcsh.man,v 3.266 2016/11/24 15:04:52 christos Exp
3 .\" Copyright (c) 1980, 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS `AS IS' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LESS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" - Indent in multiples of 4, usually 8.
32 .\" - Use \` for literal back-quote (`).
34 .\" - Use \e for literal backslash (\).
38 .\" - Include the tilde when naming dot files. .Pa ~/.login , not .Pa .login
40 .\" - Refer to external commands in man page format, e.g., .Xr csh 1
41 .\" However, tcsh is .Nm , because this is the tcsh man page (and
42 .\" see the next note anyway).
44 .\" - Say .Sq the shell , not .Sq tcsh ,
45 .\" unless distinguishing between tcsh and csh.
47 .\" - Say .Sq shell variable / .Sq environment variable instead of
48 .\" .Sq variable and .Sq builtin command / .Sq editor command instead of
49 .\" .Sq builtin or .Sq command
50 .\" unless the distinction is absolutely clear from context.
52 .\" - Use the simple present tense.
53 .\" .Sq The shell uses , not .Sq The shell will use
55 .\" - IMPORTANT: Cross-reference as much as possible. Commands, variables,
56 .\" etc. in the reference section should be mentioned in the appropriate
57 .\" descriptive section, or at least in the reference-section description
58 .\" of another command (or whatever) which is mentioned in a description
59 .\" section. Remember to note OS-specific things in "OS variant support",
60 .\" new features in NEW FEATURES and referenced external commands in SEE
63 .\" - tcsh.man2html depends heavily on the specific nroff commands used in the
64 .\" man page when the script was written. Please stick closely to the style
65 .\" used here if you can. In particular, please don't use nroff commands
66 .\" which aren't already used herein.
73 .Nd C shell with file name completion and command line editing
76 .Op Fl bcdefFimnqstvVxX
77 .Op Fl Dname Ns Op =value
84 is an enhanced but completely compatible version of the Berkeley
87 It is a command language interpreter usable both as an interactive login
88 shell and a shell script command processor.
89 It includes a command-line editor (see
90 .Sx The command-line editor )
91 programmable word completion (see
92 .Sx Completion and listing )
93 spelling correction (see
94 .Sx Spelling correction ) ,
95 a history mechanism (see
96 .Sx History substitution ) ,
102 section describes major enhancements of
106 Throughout this manual, features of
111 (specifically, the 4.4BSD one)
114 and features which are present in
116 but not usually documented are labeled with
119 .Ss Argument list processing
120 If the first argument (argument 0) to the shell is
122 then it is a login shell.
123 A login shell can be also specified by invoking the shell with
126 flag as the only argument.
128 The rest of the flag arguments are interpreted as follows:
129 .Bl -tag -width indent
133 from option processing, causing any
134 further shell arguments to be treated as non-option arguments.
135 The remaining arguments will not be interpreted as shell options.
136 This may be used to pass options to a shell script without confusion
137 or possible subterfuge.
138 The shell will not run a set-user ID script without this option.
140 Commands are read from the following argument (which must be present, and
141 must be a single argument),
144 shell variable for reference, and executed.
145 Any remaining arguments are placed in the
149 The shell loads the directory stack from
152 .Sx Startup and shutdown ,
153 whether or not it is a login shell. (+)
154 .It Fl Dname Ns Op =value
155 Sets the environment variable
160 The shell exits if any invoked command terminates abnormally or
161 yields a non-zero exit status.
163 The shell does not load any resource or startup files, or perform any
164 command hashing, and thus starts faster.
170 to spawn processes. (+)
172 The shell is interactive and prompts for its top-level input, even if
173 it appears to not be a terminal.
174 Shells are interactive without this option if
175 their inputs and outputs are terminals.
177 The shell is a login shell.
185 even if it does not belong to the effective user.
192 The shell parses commands but does not execute them.
193 This aids in debugging shell scripts.
195 The shell accepts SIGQUIT (see
196 .Sx Signal handling )
197 and behaves when it is used under a debugger.
198 Job control is disabled. (u)
200 Command input is taken from the standard input.
202 The shell reads and executes a single line of input.
206 escape the newline at the end of this line and continue onto another line.
210 shell variable, so that
211 command input is echoed after history substitution.
215 shell variable, so that commands are echoed
216 immediately before execution.
220 shell variable even before executing
231 Print a help message on the standard output and exit. (+)
233 Print the version/platform/compilation options on the standard output and exit.
234 This information is also contained in the
239 After processing of flag arguments, if arguments remain but none of the
245 options were given, the first argument is taken as the name of a file of
249 The shell opens this file and saves its name for possible
252 Because many systems use either the standard
253 version 6 or version 7 shells whose shell scripts are not compatible
254 with this shell, the shell uses such a
256 shell to execute a script
257 whose first character is not a
259 i.e., that does not start with a
262 Remaining arguments are placed in the
265 .Ss Startup and shutdown
266 A login shell begins by executing commands from the system files
270 It then executes commands from files in the user's
283 shell variable), then
292 before instead of after
296 before instead of after
307 Non-login shells read only
315 For examples of startup files, please consult:
316 .Lk http://tcshrc.sourceforge.net
322 which need be run only once per login, usually go in one's
325 Users who need to use the same set of files with both
331 which checks for the existence of the
333 shell variable (q.v.) before using
342 (see the builtin command)
344 The rest of this manual uses
354 In the normal case, the shell begins reading commands from the terminal,
357 (Processing of arguments and the use of the shell to
358 process files containing command scripts are described later.)
359 The shell repeatedly reads a line of command input, breaks it into words,
360 places it on the command history list, parses it and executes each command
363 One can log out by typing
370 via the shell's autologout mechanism (see the
373 When a login shell terminates it sets the
379 as appropriate, then executes commands from the files
383 The shell may drop DTR on logout
384 if so compiled; see the
388 The names of the system login and logout files vary from system to system for
389 compatibility with different
395 .Sx The command-line editor"
397 .Sx Completion and listing
399 .Sx Spelling correction
400 sections describe two sets of functionality that are implemented as editor
401 commands but which deserve their own treatment.
405 the editor commands specific to the shell and their default bindings.
406 .It Sx The command-line editor (+)
407 Command-line input can be edited using key sequences much like those used in
411 The editor is active only when the
413 shell variable is set, which it is by default in interactive shells.
416 builtin can display and change key bindings.
418 style key bindings are used by default
419 (unless the shell was compiled otherwise; see the
424 can change the key bindings to
426 style bindings en masse.
428 The shell always binds the arrow keys (as defined in the
430 environment variable) to:
432 .Bl -tag -width right -compact -offset indent
443 unless doing so would alter another single-character binding.
444 One can set the arrow key escape sequences to the empty string with
446 to prevent these bindings.
447 The ANSI/VT100 sequences for arrow keys are always bound.
449 Other key bindings are, for the most part, what
453 users would expect and can easily be displayed by
456 is no need to list them here.
460 commands with a short description of each.
461 Certain key bindings have different behavior depending if
465 style bindings are being used; see
467 for more information.
469 Note that editor commands do not have the same notion of a
472 The editor delimits words with any non-alphanumeric characters not in
475 while the shell recognizes only whitespace
476 and some of the characters with special meanings to it, listed under
477 .Sx Lexical structure .
478 .Ss Completion and listing (+)
479 The shell is often able to complete words when given a unique abbreviation.
480 Type part of a word (for example
483 and hit the tab key to run the
486 The shell completes the filename
489 .Pa /usr/lost+found/ ,
490 replacing the incomplete word with the complete word in the input buffer.
495 to the end of completed directories and a space to the end of other completed
496 words, to speed typing and provide a visual indicator of successful completion.
499 shell variable can be unset to prevent this.)
500 If no match is found (perhaps
502 doesn't exist), the terminal bell rings.
503 If the word is already complete (perhaps there is a
506 system, or perhaps you were thinking too far ahead and typed the whole thing)
509 or space is added to the end if it isn't already there.
511 Completion works anywhere in the line, not at just the end; completed
512 text pushes the rest of the line to the right.
513 Completion in the middle of a word
514 often results in leftover characters to the right of the cursor that need
517 Commands and variables can be completed in much the same way.
526 were the only command on your system beginning with
528 Completion can find a command in any directory in
530 or if given a full pathname.
537 if no other variable began with
540 The shell parses the input buffer to determine whether the word you want to
541 complete should be completed as a filename, command or variable.
542 The first word in the buffer and the first word following
549 is considered to be a command.
550 A word beginning with
552 is considered to be a variable.
553 Anything else is a filename.
558 You can list the possible completions of a word at any time by typing
561 .Ic delete-char-or-list-or-eof
563 The shell lists the possible completions using the
566 and reprints the prompt and unfinished command line, for example:
567 .Bd -literal -offset indent
569 lbin/ lib/ local/ lost+found/
575 shell variable is set, the shell lists the remaining
576 choices (if any) whenever completion fails:
577 .Bd -literal -offset indent
579 > nm /usr/lib/libt[tab]
580 libtermcap.a@ libtermlib.a@
581 > nm /usr/lib/libterm
586 shell variable is set to
588 choices are listed only when
589 completion fails and adds no new characters to the word being completed.
591 A filename to be completed can contain variables, your own or others' home
592 directories abbreviated with
595 .Sx Filename substitution )
596 and directory stack entries abbreviated with
599 .Sx Directory stack substitution ) .
601 .Bd -literal -offset indent
608 .Bd -literal -offset indent
609 > set local = /usr/local
612 bin/ etc/ lib/ man/ src/
616 Note that variables can also be expanded explicitly with the
620 .Ic delete-char-or-list-or-eof
621 lists at only the end of the line;
622 in the middle of a line it deletes the character under the cursor and
623 on an empty line it logs one out or, if then
625 variable is set, does nothing.
627 bound to the editor command
630 possibilities anywhere on a line, and
633 related editor commands that do or don't delete, list and/or log out,
635 .Ic delete-char-or-list-or-eof )
640 builtin command if so desired.
643 .Ic complete-word-fwd
645 .Ic complete-word-back
647 (not bound to any keys by default) can be used to cycle up and down through
648 the list of possible completions, replacing the current word with the next or
649 previous word in the list.
653 can be set to a list of suffixes to be ignored by completion.
654 Consider the following:
655 .Bd -literal -offset indent
657 Makefile condiments.h~ main.o side.c
658 README main.c meal side.o
660 > set fignore = (.o \e~)
662 main.c main.c~ main.o
670 are ignored by completion (but not listing),
671 because they end in suffixes in
675 was needed in front of
677 to prevent it from being expanded to
680 .Sx Filename substitution .
682 is ignored if only one completion is possible.
686 shell variable is set to
689 1) ignores case and 2) considers periods, hyphens and underscores
694 to be word separators and hyphens and underscores to be equivalent.
695 If you had the following files
696 .Bd -literal -offset indent
697 comp.lang.c comp.lang.perl comp.std.c++
698 comp.lang.c++ comp.std.c
702 .Sq mail \-f c.l.c[tab] ,
703 it would be completed to
704 .Sq mail \-f comp.lang.c ,
711 .Sq mail \-f c..c++[^D]
718 in the following directory
719 .Bd -literal -offset indent
720 A_silly_file a-hyphenated-file another_silly_file
723 would list all three files, because case is ignored and hyphens and
724 underscores are equivalent.
725 Periods, however, are not equivalent to
726 hyphens or underscores.
730 shell variable is set to
733 ignores case and differences between a hyphen and an underscore word
734 separator only when the user types a lowercase character or a hyphen.
735 Entering an uppercase character or an underscore will not match the
736 corresponding lowercase character or hyphen word separator.
739 in the directory of the previous example would
740 still list all three files, but typing
749 .Sq another_silly_file
750 because the user explicitly used an uppercase
751 or an underscore character.
753 Completion and listing are affected by several other shell variables:
755 can be set to complete on the shortest possible unique
756 match, even if more typing might result in a longer match:
757 .Bd -literal -offset indent
759 fodder foo food foonly
770 but if we type another
772 .Bd -literal -offset indent
777 the completion completes on
785 can be set to run the
788 before each completion attempt,
791 spelling-correct the word to be completed (see
792 .Sx Spelling correction )
793 before each completion attempt and
795 can be set to complete commands automatically after one hits
798 can be set to make completion beep or not beep in a variety
801 can be set to never beep at all.
803 can be set to a list of directories and/or patterns that
804 match directories to prevent the completion mechanism from
811 can be set to limit the number of items
812 and rows (respectively) that are listed without asking first.
813 .Va recognize_only_executables
814 can be set to make the shell list only
815 executables when listing commands, but it is quite slow.
819 builtin command can be used to tell the shell how
820 to complete words other than filenames, commands and variables.
821 Completion and listing do not work on glob-patterns (see
822 .Sx Filename substitution ) ,
827 editor commands perform
828 equivalent functions for glob-patterns.
829 .Ss Spelling correction (+)
830 The shell can sometimes correct the spelling of filenames, commands and
831 variable names as well as completing and listing them.
833 Individual words can be spelling-corrected with the
835 editor command (usually bound to M-s and M-S)
836 and the entire input buffer with
838 (usually bound to M-$).
841 shell variable can be set to
843 to correct the command name or
845 to correct the entire line each time return is typed, and
847 can be set to correct the word to be completed
848 before each completion attempt.
850 When spelling correction is invoked in any of these ways and
851 the shell thinks that any part of the command line is misspelled,
852 it prompts with the corrected line:
853 .Bd -literal -offset indent
856 CORRECT>ls /usr/bin (y|n|e|a)?
861 or space to execute the corrected line,
863 to leave the uncorrected command in the input buffer,
865 to abort the command as if
868 anything else to execute the original line unchanged.
870 Spelling correction recognizes user-defined completions (see the
873 If an input word in a position for
874 which a completion is defined resembles a word in the completion list,
875 spelling correction registers a misspelling and suggests the latter
876 word as a correction.
877 However, if the input word does not match any of
878 the possible completions for that position, spelling correction does
879 not register a misspelling.
881 Like completion, spelling correction works anywhere in the line,
882 pushing the rest of the line to the right and possibly leaving
883 extra characters to the right of the cursor.
884 .Ss Editor commands (+)
886 lists key bindings and
888 lists and briefly describes editor commands.
889 Only new or especially interesting editor commands are described here.
894 for descriptions of each editor's key bindings.
896 The character or characters to which each command is bound by default is
897 given in parentheses.
899 means a control character and
901 a meta character, typed as
903 on terminals without a meta key.
904 Case counts, but commands that are bound
905 to letters by default are bound to both lower- and uppercase letters for
907 .Bl -tag -width indent
908 .It Ic backward-char Ar (^B, left)
909 Move back a character.
910 Cursor behavior modified by
912 .It Ic backward-delete-word Ar (M-^H, M-^?)
913 Cut from beginning of current word to cursor \- saved in cut buffer.
914 Word boundary behavior modified by
916 .It Ic backward-word Ar (M-b, M-B)
917 Move to beginning of current word.
918 Word boundary and cursor behavior modified by
920 .It Ic beginning-of-line Ar (^A, home)
921 Move to beginning of line.
922 Cursor behavior modified by
924 .It Ic capitalize-word Ar (M-c, M-C)
925 Capitalize the characters from cursor to end of current word.
926 Word boundary behavior modified by
928 .It Ic complete-word Ar (tab)
929 Completes a word as described under
930 .Sx Completion and listing
931 .It Ic complete-word-back Ar (not bound)
933 .Ic complete-word-fwd ,
934 but steps up from the end of the list.
935 .It Ic complete-word-fwd Ar (not bound)
936 Replaces the current word with the first word in the list of possible
938 May be repeated to step down through the list.
939 At the end of the list, beeps and reverts to the incomplete word.
940 .It Ic complete-word-raw Ar (^X-tab)
943 but ignores user-defined completions.
944 .It Ic copy-prev-word Ar (M-^_)
945 Copies the previous word in the current line into the input buffer.
948 Word boundary behavior modified by
950 .It Ic dabbrev-expand Ar (M-/)
951 Expands the current word to the most recent preceding one for which
952 the current is a leading substring, wrapping around the history list
956 without any intervening typing
957 changes to the next previous word etc., skipping identical matches
959 .Ic history-search-backward
961 .It Ic delete-char Ar (not bound)
962 Deletes the character under the cursor.
964 .Ic delete-char-or-list-or-eof
965 Cursor behavior modified by
967 .It Ic delete-char-or-eof Ar (not bound)
970 if there is a character under the cursor or
974 .Ic delete-char-or-list-or-eof
975 Cursor behavior modified by
977 .It Ic delete-char-or-list Ar (not bound)
980 if there is a character under the cursor
983 at the end of the line.
985 .Ic delete-char-or-list-or-eof
986 .It Ic delete-char-or-list-or-eof Ar (^D)
989 if there is a character under the cursor,
991 at the end of the line or
994 See also those three commands, each of which does only a single action, and
995 .Ic delete-char-or-eof ,
996 .Ic delete-char-or-list
999 each of which does a different two out of the three.
1000 .It Ic delete-word Ar (M-d, M-D)
1001 Cut from cursor to end of current word \- save in cut buffer.
1002 Word boundary behavior modified by
1004 .It Ic down-history Ar (down-arrow, ^N)
1007 but steps down, stopping at the original input line.
1008 .It Ic downcase-word Ar (M-l, M-L)
1009 Lowercase the characters from cursor to end of current word.
1010 Word boundary behavior modified by
1012 .It Ic end-of-file Ar (not bound)
1013 Signals an end of file, causing the shell to exit unless the
1015 shell variable (q.v.) is set to prevent this.
1017 .Ic delete-char-or-list-or-eof
1018 .It Ic end-of-line Ar (^E, end)
1019 Move cursor to end of line.
1020 Cursor behavior modified by
1022 .It Ic expand-history Ar (M-space)
1023 Expands history substitutions in the current word.
1025 .Sx History substitution
1028 .Ic toggle-literal-history
1032 .It Ic expand-glob Ar (^X-*)
1033 Expands the glob-pattern to the left of the cursor.
1035 .Sx Filename substitution
1036 .It Ic expand-line Ar (not bound)
1038 .Ic expand-history ,
1039 but expands history substitutions in each word in the input buffer.
1040 .It Ic expand-variables Ar (^X-$)
1041 Expands the variable to the left of the cursor.
1043 .Sx Variable substitution
1044 .It Ic forward-char Ar (^F, right)
1045 Move forward one character.
1046 Cursor behavior modified by
1048 .It Ic forward-word Ar (M-f, M-F)
1049 Move forward to end of current word.
1050 Word boundary and cursor behavior modified by
1052 .It Ic history-search-backward Ar (M-p, M-P)
1053 Searches backwards through the history list for a command beginning with
1054 the current contents of the input buffer up to the cursor and copies it
1055 into the input buffer.
1056 The search string may be a glob-pattern (see
1057 .Sx Filename substitution )
1067 will proceed from the
1068 appropriate point in the history list.
1071 .Ic history-search-forward
1074 .It Ic history-search-forward Ar (M-n, M-N)
1076 .Ic history-search-backward ,
1077 but searches forward.
1078 .It Ic i-search-back Ar (not bound)
1079 Searches backward like
1080 .Ic history-search-backward ,
1081 copies the first match
1082 into the input buffer with the cursor positioned at the end of the pattern,
1085 and the first match.
1086 Additional characters may be
1087 typed to extend the search,
1089 may be typed to continue
1090 searching with the same pattern, wrapping around the history list if
1094 single character for this to work) or one of the following special characters
1098 Appends the rest of the word under the cursor to the search pattern.
1099 delete (or any character bound to
1100 .Ic backward-delete-char )
1101 Undoes the effect of the last character typed and deletes a character
1102 from the search pattern if appropriate.
1104 If the previous search was successful, aborts the entire search.
1105 If not, goes back to the last successful search.
1107 Ends the search, leaving the current line in the input buffer.
1109 Any other character not bound to
1110 .Ic self-insert-command
1112 search, leaving the current line in the input buffer, and
1113 is then interpreted as normal input.
1114 In particular, a carriage return
1115 causes the current line to be executed.
1119 .Ic history-search-backward
1120 Word boundary behavior modified by
1122 .It Ic i-search-fwd Ar (not bound)
1125 but searches forward.
1126 Word boundary behavior modified by
1128 .It Ic insert-last-word Ar (M-_)
1129 Inserts the last word of the previous input line
1131 into the input buffer.
1134 .It Ic list-choices Ar (M-^D)
1135 Lists completion possibilities as described under
1136 .Sx Completion and listing
1138 .Ic delete-char-or-list-or-eof
1140 .Ic list-choices-raw
1141 .It Ic list-choices-raw Ar (^X-^D)
1144 but ignores user-defined completions.
1145 .It Ic list-glob Ar (^X-g, ^X-G)
1148 builtin) matches to the glob-pattern
1150 .Sx Filename substitution )
1151 to the left of the cursor.
1152 .It Ic list-or-eof Ar (not bound)
1159 .Ic delete-char-or-list-or-eof
1160 .It Ic magic-space Ar (not bound)
1161 Expands history substitutions in the current line,
1163 .Ic expand-history ,
1164 and inserts a space.
1166 is designed to be bound to the space bar,
1167 but is not bound by default.
1168 .It Ic normalize-command Ar (^X-?)
1169 Searches for the current word in PATH and, if it is found, replaces it with
1170 the full path to the executable.
1171 Special characters are quoted.
1173 expanded and quoted but commands within aliases are not.
1175 useful with commands that take commands as arguments, e.g.,
1179 .It Ic normalize-path Ar (^X-n, ^X-N)
1180 Expands the current word as described under the
1186 .It Ic overwrite-mode Ar (unbound)
1187 Toggles between input and overwrite modes.
1188 .It Ic run-fg-editor Ar (M-^Z)
1189 Saves the current input line and
1190 looks for a stopped job where the file name portion of its first word
1196 is not set, then the file name portion of the
1198 environment variable
1203 environment variable
1207 If such a job is found, it is restarted as if
1211 This is used to toggle back and forth between an editor and
1213 Some people bind this command to
1216 can do this even more easily.
1217 .It Ic run-help Ar (M-h, M-H)
1218 Searches for documentation on the current command, using the same notion of
1220 as the completion routines, and prints it.
1224 is designed for short help files.
1225 If the special alias
1227 is defined, it is run with the
1228 command name as a sole argument.
1230 documentation should be in a file named
1237 which should be in one
1238 of the directories listed in the
1240 environment variable.
1241 If there is more than one help file only the first is printed.
1242 .It Ic self-insert-command Ar (text characters)
1243 In insert mode (the default), inserts the typed character into the input line after the character under the cursor.
1244 In overwrite mode, replaces the character under the cursor with the typed character.
1245 The input mode is normally preserved between lines, but the
1247 shell variable can be set to
1252 editor in that mode at the beginning of each line.
1255 .It Ic sequence-lead-in Ar (arrow prefix, meta prefix, ^X)
1256 Indicates that the following characters are part of a
1258 Binding a command to a multi-key sequence really creates
1259 two bindings: the first character to
1260 .Ic sequence-lead-in
1262 whole sequence to the command.
1263 All sequences beginning with a character
1265 .Ic sequence-lead-in
1266 are effectively bound to
1268 unless bound to another command.
1269 .It Ic spell-line Ar (M-$)
1270 Attempts to correct the spelling of each word in the input buffer, like
1272 but ignores words whose first character is one of
1283 to avoid problems with switches, substitutions and the like.
1285 .Sx Spelling correction
1286 .It Ic spell-word Ar (M-s, M-S)
1287 Attempts to correct the spelling of the current word as described under
1288 .Sx Spelling correction
1289 Checks each component of a word which appears to be a pathname.
1290 .It Ic toggle-literal-history Ar (M-r, M-R)
1293 history substitutions in the input buffer.
1299 .It Ic undefined-key Ar (any unbound key)
1301 .It Ic up-history Ar (up-arrow, ^P)
1302 Copies the previous entry in the history list into the input buffer.
1305 is set, uses the literal form of the entry.
1306 May be repeated to step up through the history list, stopping at the top.
1307 .It Ic upcase-word Ar (M-u, M-U)
1308 Uppercase the characters from cursor to end of current word.
1309 Word boundary behavior modified by
1311 .It Ic vi-beginning-of-next-word Ar (not bound)
1312 Vi goto the beginning of next word.
1313 Word boundary and cursor behavior modified by
1315 .It Ic vi-eword Ar (not bound)
1316 Vi move to the end of the current word.
1317 Word boundary behavior modified by
1319 .It Ic vi-search-back Ar (?)
1322 for a search string (which may be a glob-pattern, as with
1323 .Ic history-search-backward ),
1324 searches for it and copies it into the input buffer.
1325 The bell rings if no match is found.
1326 Hitting return ends the search and leaves the last match in the input
1328 Hitting escape ends the search and executes the match.
1331 .It Ic vi-search-fwd Ar (/)
1333 .Ic vi-search-back ,
1334 but searches forward.
1335 .It Ic which-command Ar (M-?)
1338 (see the description of the builtin command) on the
1339 first word of the input buffer.
1340 .It Ic yank-pop Ar (M-y)
1341 When executed immediately after a
1345 replaces the yanked string with the next previous string from the
1346 killring. This also has the effect of rotating the killring, such that
1347 this string will be considered the most recently killed by a later
1351 will cycle through the
1352 killring any number of times.
1354 .Ss Lexical structure
1355 The shell splits input lines into words at blanks and tabs.
1366 and the doubled characters
1372 are always separate words, whether or not they are
1373 surrounded by whitespace.
1375 When the shell's input is not a terminal, the character
1381 and the rest of the input line on which it appears is
1382 discarded before further parsing.
1384 A special character (including a blank or tab) may be prevented from having
1385 its special meaning, and possibly made part of another word, by preceding it
1388 or enclosing it in single
1396 When not otherwise quoted a newline preceded by a
1398 is equivalent to a blank, but inside quotes this sequence results in a
1404 .Sx History substitution
1405 can be prevented by enclosing the strings (or parts of strings)
1406 in which they appear with single quotes or by quoting the crucial character(s)
1412 .Sx Variable substitution
1414 .Sx Command substitution
1418 .Sx ( Alias substitution
1419 is no exception: quoting in any way any
1420 character of a word for which an
1422 has been defined prevents
1423 substitution of the alias.
1424 The usual way of quoting an alias is to precede it
1426 .Sx History substitution
1428 backslashes but not by single quotes.
1429 Strings quoted with double or backward
1431 .Sx Variable substitution
1433 .Sx Command substitution ,
1434 but other substitutions are prevented.
1436 Text inside single or double quotes becomes a single word (or part of one).
1437 Metacharacters in these strings, including blanks and tabs, do not form
1439 Only in one special case (see
1440 .Sx Command substitution
1441 below) can a double-quoted string yield parts of more than one word;
1442 single-quoted strings never do.
1443 Backward quotes are special: they signal
1444 .Sx Command substitution
1445 (q.v.), which may result in more than one word.
1447 Quoting complex strings, particularly strings which themselves contain quoting
1448 characters, can be confusing.
1449 Remember that quotes need not be used as they are
1451 It may be easier to quote not an entire string, but only
1452 those parts of the string which need quoting, using different types of quoting
1453 to do so if appropriate.
1457 shell variable (q.v.) can be set to make backslashes
1463 (+) This may make complex quoting tasks
1464 easier, but it can cause syntax errors in
1468 We now describe the various transformations the shell performs on the input in
1469 the order in which they occur.
1470 We note in passing the data structures involved
1471 and the commands and variables which affect them.
1472 Remember that substitutions
1473 can be prevented by quoting as described under
1474 .Sx Lexical structure .
1475 .Ss History substitution
1478 input from the terminal is saved in the history list.
1479 The previous command is always saved, and the
1482 variable can be set to a number to save that many commands.
1485 shell variable can be set to not save duplicate events or consecutive duplicate
1488 Saved commands are numbered sequentially from 1 and stamped with the time.
1489 It is not usually necessary to use event numbers, but the current event number
1490 can be made part of the prompt by placing an
1496 The shell actually saves history in expanded and literal (unexpanded) forms.
1499 shell variable is set, commands that display and store
1500 history use the literal form.
1504 builtin command can print, store in a file, restore
1505 and clear the history list at any time,
1510 shell variables can be set to
1511 store the history list automatically on logout and restore it on login.
1513 History substitutions introduce words from the history list into the input
1514 stream, making it easy to repeat commands, repeat arguments of a previous
1515 command in the current command, or fix spelling mistakes in the previous
1516 command with little typing and a high degree of confidence.
1518 History substitutions begin with the character
1520 They may begin anywhere in
1521 the input stream, but they do not nest.
1524 may be preceded by a
1527 prevent its special meaning; for convenience, a
1529 is passed unchanged when it
1530 is followed by a blank, tab, newline,
1534 History substitutions also
1535 occur when an input line begins with
1537 This special abbreviation will be
1539 The characters used to signal history substitution
1543 can be changed by setting the
1547 line which contains a history substitution is printed before it is executed.
1549 A history substitution may have an
1550 .Sq event specification ,
1551 which indicates the event from which words are to be taken, a
1552 .Sq word designator ,
1553 which selects particular words from the chosen event, and/or a
1555 which manipulates the selected words.
1557 An event specification can be
1559 .Bl -tag -width XXXX -offset indent -compact
1561 A number, referring to a particular event
1563 An offset, referring to the event
1565 before the current event
1568 This should be used carefully in
1570 where there is no check for recursion.
1572 allows 10 levels of recursion.
1575 The previous event (equivalent to
1578 The most recent event whose first word begins with the string
1581 The most recent event which contains the string
1585 can be omitted if it is immediately followed by a newline.
1588 For example, consider this bit of someone's history list:
1589 .Bd -literal -offset indent
1590 9 8:30 nroff \-man wumpus.man
1591 10 8:31 cp wumpus.man wumpus.man.old
1592 11 8:36 vi wumpus.man
1593 12 8:37 diff wumpus.man.old wumpus.man
1596 The commands are shown with their event numbers and time stamps.
1597 The current event, which we haven't typed in yet, is event 13.
1603 refers to the previous event, 12.
1611 is described below).
1613 refers to event 9, which begins with
1616 also refers to event 12, which contains
1618 Without word designators or modifiers history references simply expand to the
1619 entire event, so we might type
1621 to redo the copy command or
1625 output scrolled off the top of the screen.
1627 History references may be insulated from the surrounding text with braces if
1631 would look for a command beginning with
1633 and, in this example, not find one, but
1637 .Sq vi wumpus.mandoc
1638 Even in braces, history substitutions do not nest.
1642 expands, for example,
1649 expands it to the last event beginning
1652 only completely numeric arguments are treated as event numbers.
1653 This makes it possible to recall events beginning with numbers.
1661 To select words from an event we can follow the event specification by a
1663 and a designator for the desired words.
1664 The words of an input line are
1665 numbered from 0, the first (usually command) word being 0, the second word
1666 (first argument) being 1, etc.
1667 The basic word designators are:
1668 .Bl -tag -width XXXX -offset indent -compact
1670 The first (command) word
1676 The first argument, equivalent to
1681 The word matched by an ?
1692 but returns nothing if the event contains only 1 word
1699 but omitting the last word
1703 Selected words are inserted into the command line separated by single blanks.
1706 command in the previous example might have been
1708 .Sq diff !!:1.old !!:1
1711 to select the first argument
1712 from the previous event) or
1713 .Sq diff !\-2:2 !\-2:1
1714 to select and swap the
1718 If we didn't care about the order of the
1719 `diff' we might have said
1725 command might have been written
1726 .Sq cp wumpus.man !#:1.old
1729 to refer to the current event.
1730 `!n:\- hurkle.man' would reuse the first two words from the
1734 .Sq nroff \-man hurkle.man
1738 separating the event specification from the word designator can be
1739 omitted if the argument selector begins with a
1748 command might have been
1749 .Sq diff !!^.old !!^
1752 .Sq diff !!$.old !!$
1758 an argument selector beginning with
1760 will be interpreted as an event
1763 A history reference may have a word designator but no event specification.
1764 It then references the previous command.
1767 example, we could have said simply `diff
1768 !^.old !^' or, to get the arguments in the opposite order, just
1771 The word or words in a history reference can be edited, or
1774 by following it with one or more modifiers, each preceded by a
1777 .Bl -tag -width XXXXXX -offset indent -compact
1779 Remove a trailing pathname component, leaving the head.
1781 Remove all leading pathname components, leaving the tail.
1783 Remove a filename extension
1785 leaving the root name.
1787 Remove all but the extension.
1789 Uppercase the first lowercase letter.
1791 Lowercase the first uppercase letter.
1798 is simply a string like
1800 , not a regular expression as in
1804 Any character may be used as the delimiter in place of
1808 can be used to quote the delimiter inside
1827 from a previous substitution or the
1829 from a previous search or event number in event specification is used.
1830 The trailing delimiter may be omitted if it is immediately followed by a
1833 Repeat the previous substitution.
1835 Apply the following modifier once to each word.
1837 Apply the following modifier as many times as possible to a single word.
1841 can be used together to apply a modifier globally.
1844 modifier, only the patterns contained in the original word are
1845 substituted, not patterns that contain any substitution result.
1847 Print the new command line but do not execute it.
1849 Quote the substituted words, preventing further substitutions.
1853 but break into words at blanks, tabs and newlines.
1856 Modifiers are applied to only the first modifiable word (unless
1859 It is an error for no word to be modifiable.
1863 command might have been written as `diff wumpus.man.old
1868 from the first argument on the same line
1871 .Sq echo hello out there
1877 to say it out loud, or
1881 .Sq mail \-s "I forgot my password" rot
1885 correct the spelling of
1888 .Sx Spelling correction
1890 different approach).
1892 There is a special abbreviation for substitutions.
1894 when it is the first character on an input line, is equivalent to
1896 Thus we might have said
1898 to make the spelling correction in the
1900 This is the only history substitution which does not explicitly begin with
1905 as such, only one modifier may be applied to each history
1906 or variable expansion.
1909 more than one may be used, for example
1910 .Bd -literal -offset indent
1911 % mv wumpus.man /usr/man/man1/wumpus.1
1920 A substitution followed by a
1921 colon may need to be insulated from it with braces:
1922 .Bd -literal -offset indent
1923 > mv a.out /usr/games/wumpus
1924 > setenv PATH !$:h:$PATH
1926 > setenv PATH !{\-2$:h}:$PATH
1927 setenv PATH /usr/games:/bin:/usr/bin:.
1930 The first attempt would succeed in
1936 expects another modifier after the second colon
1940 Finally, history can be accessed through the editor as well as through
1941 the substitutions just described.
1946 .Ic history-search-backward
1957 .Ic insert-last-word
1958 editor commands search for
1959 events in the history list and copy them into the input buffer.
1961 .Ic toggle-literal-history
1962 editor command switches between the
1963 expanded and literal forms of history lines in the input buffer.
1967 expand history substitutions
1968 in the current word and in the entire input buffer respectively.
1969 .Ss Alias substitution
1970 The shell maintains a list of aliases which can be set, unset and printed by
1976 After a command line is parsed
1977 into simple commands (see
1979 the first word of each command,
1980 left-to-right, is checked to see if it has an alias.
1981 If so, the first word is
1982 replaced by the alias.
1983 If the alias contains a history reference, it undergoes
1984 .Va History substitution
1985 (q.v.) as though the original command were the
1986 previous input line.
1987 If the alias does not contain a history reference, the
1988 argument list is left untouched.
1990 Thus if the alias for
1997 \-l /usr', the argument list here being undisturbed.
2001 .Sq grep !/etc/passwd
2004 would become `grep bill
2006 Aliases can be used to introduce parser metasyntax.
2010 pr \e!* | lpr'' defines a
2014 (1)s its arguments to the line printer.
2016 Alias substitution is repeated until the first word of the command has no
2018 If an alias substitution does not change the first word (as in the
2019 previous example) it is flagged to prevent a loop.
2020 Other loops are detected and
2023 Some aliases are referred to by the shell; see
2025 .Sx Variable substitution
2026 The shell maintains a list of variables, each of which has as value a list of
2028 The values of shell variables can be displayed and changed with the
2033 The system maintains its own list of
2036 These can be displayed and changed with
2043 (+) Variables may be made read-only with
2046 Read-only variables may not be modified or unset;
2047 attempting to do so will cause an error.
2048 Once made read-only, a variable cannot be made writable,
2051 should be used with caution.
2052 Environment variables cannot be made read-only.
2054 Some variables are set by the shell or referred to by it.
2057 variable is an image of the shell's argument
2058 list, and words of this variable's value are referred to in special ways.
2059 Some of the variables referred to by the shell are toggles;
2060 the shell does not care what their value is, only whether they are set or not.
2063 variable is a toggle which causes command
2066 .Fl v\fR command line option sets this variable.
2067 .Va Special shell variables
2068 lists all variables which are referred to by the shell.
2070 Other operations treat variables numerically.
2073 command permits numeric
2074 calculations to be performed and the result assigned to a variable.
2076 values are, however, always represented as (zero or more) strings.
2078 purposes of numeric operations, the null string is considered to be zero, and
2079 the second and subsequent words of multi-word values are ignored.
2081 After the input line is aliased and parsed, and before each command is
2082 executed, variable substitution is performed keyed by
2086 expansion can be prevented by preceding the
2102 are interpreted later (see
2103 .Sx Command substitution
2106 substitution does not occur there until later,
2110 is passed unchanged if followed by a blank, tab, or
2113 Input/output redirections are recognized before variable expansion, and are
2114 variable expanded separately.
2115 Otherwise, the command name and entire argument
2116 list are expanded together.
2117 It is thus possible for the first (command) word
2118 (to this point) to generate more than one word, the first of which becomes the
2119 command name, and the rest of which become arguments.
2125 modifier the results of variable
2126 substitution may eventually be command and filename substituted.
2130 variable whose value consists of multiple words expands to a (portion of a)
2131 single word, with the words of the variable's value separated by blanks.
2135 modifier is applied to a substitution the variable will expand to
2136 multiple words with each word separated by a blank and quoted to prevent later
2137 command or filename substitution.
2139 The following metasequences are provided for introducing variable values into
2141 Except as noted, it is an error to reference a variable which
2144 .Bl -tag -width XXXXXXXXXX -offset indent -compact
2148 Substitutes the words of the value of variable
2154 from following characters which would
2155 otherwise be part of it.
2156 Shell variables have names consisting of
2157 letters and digits starting with a letter.
2158 The underscore character is
2159 considered a letter.
2162 is not a shell variable, but is set in the
2163 environment, then that value is returned (but some of the other forms
2164 given below are not available in this case).
2165 .It Ar $name[selector]
2166 .It Ar ${name[selector]}
2167 Substitutes only the selected words from the value of
2173 substitution and may consist of
2174 a single number or two numbers separated by a
2176 The first word of a variable's value is numbered
2178 If the first number of a range is omitted it defaults to
2180 If the last member of a range is omitted it defaults to
2187 It is not an error for a range to be empty if the
2188 second argument is omitted or in range.
2190 Substitutes the name of the file from which command input
2192 An error occurs if the name is not known.
2200 which is equivalent to
2206 modifiers described under
2207 .Sx History substitution ,
2210 can be applied to the substitutions above.
2211 More than one may be used.
2213 Braces may be needed to insulate a variable substitution from a literal colon
2215 .Sx History substitution
2216 (q.v.); any modifiers must appear
2219 The following substitutions can not be modified with
2223 .Bl -tag -width XXXXXXXX -offset indent -compact
2226 Substitutes the string
2236 if the current input filename is known,
2241 in interactive shells.
2245 Substitutes the number of words in
2256 Substitutes the number of characters in
2264 Substitutes the number of characters in
2272 Substitutes the (decimal) process number of the (parent) shell.
2274 Substitutes the (decimal) process number of the last
2275 background process started by this shell.
2278 Substitutes the command line of the last command executed.
2281 Substitutes a line from the standard input, with no further interpretation
2283 It can be used to read from the keyboard in a shell script.
2286 always quotes $<, as if it were equivalent to
2292 is waiting for a line to be
2293 typed the user may type an interrupt to interrupt the sequence into
2294 which the line is to be substituted, but
2296 does not allow this.
2300 .Va expand-variables
2303 can be used to interactively expand individual variables.
2304 .Ss "Command, filename and directory stack substitution"
2305 The remaining substitutions are applied selectively to the arguments
2306 of builtin commands.
2307 This means that portions of expressions which are not evaluated are
2308 not subjected to these expansions.
2309 For commands which are not internal to the
2310 shell, the command name is substituted separately from the argument list.
2311 This occurs very late, after input-output redirection is performed, andk
2312 in a child of the main shell.
2313 .Ss "Command substitution"
2314 Command substitution is indicated by a command enclosed in
2317 from such a command is broken into separate words at blanks, tabs and newlines,
2318 and null words are discarded.
2319 The output is variable and command substituted
2320 and put in place of the original string.
2322 Command substitutions inside double
2325 retain blanks and tabs; only newlines force new words.
2327 final newline does not force a new word in any case.
2328 It is thus possible for a
2329 command substitution to yield only part of a word, even if the command outputs
2332 By default, the shell since version 6.12 replaces all newline and carriage
2333 return characters in the command by spaces.
2334 If this is switched off by
2337 newlines separate commands as usual.
2338 .Ss "Filename substitution"
2339 If a word contains any of the characters
2348 it is a candidate for filename substitution, also known as
2350 This word is then regarded as a pattern
2351 .Dq ( glob-pattern ) ,
2353 replaced with an alphabetically sorted list of file names which match the
2356 In matching filenames, the character
2358 at the beginning of a filename or
2359 immediately following a
2361 as well as the character
2364 explicitly (unless either
2368 or both are set(+)).
2371 matches any string of characters,
2372 including the null string.
2375 matches any single character.
2378 matches any one of the characters enclosed.
2382 characters separated by
2384 matches any character lexically between the two.
2386 (+) Some glob-patterns can be negated:
2389 matches any single character
2392 characters and/or ranges of characters in the braces.
2394 An entire glob-pattern can also be negated with
2396 .Bd -literal -offset indent
2398 bang crash crunch ouch
2403 Glob-patterns which do not use
2411 (below) are not negated correctly.
2417 Left-to-right order is preserved:
2418 .Sq /usr/source/s1/{oldls,ls}.c
2421 .Sq /usr/source/s1/oldls.c /usr/source/s1/ls.c
2422 The results of matches are
2423 sorted separately at a low level to preserve this order:
2426 .Sq ../memo ../box ../mbox
2429 was not sorted with the results of matching
2431 It is not an error when this construct expands to files which do not exist,
2432 but it is possible to get an error from a command to which the expanded list
2434 This construct may be nested.
2435 As a special case the words
2440 are passed undisturbed.
2444 at the beginning of a filename refers to home directories.
2445 Standing alone, i.e.,
2447 it expands to the invoker's home directory as
2448 reflected in the value of the
2452 name consisting of letters, digits and
2454 characters the shell searches for a
2455 user with that name and substitutes their home directory; thus
2466 is followed by a character other than a letter or
2468 or appears elsewhere
2469 than at the beginning of a word, it is left undisturbed.
2471 .Sq setenv MANPATH /usr/man:/usr/local/man:~/lib/man
2473 therefore, do home directory substitution as one might hope.
2475 It is an error for a glob-pattern containing
2484 not to match any files.
2485 However, only one pattern in a list of
2486 glob-patterns must match a file (so that, e.g.,
2489 only if there were no files in the current directory ending in
2496 shell variable is set a pattern (or list
2497 of patterns) which matches nothing is left unchanged rather than causing
2502 shell variable can be set to allow
2507 a file glob pattern that matches any string of characters including
2509 recursively traversing any existing sub-directories.
2512 will list all the .c files in the current directory tree.
2513 If used by itself, it will match zero or more sub-directories
2515 .Sq ls /usr/include/**/time.h
2516 will list any file named
2518 in the /usr/include directory tree;
2519 .Sq ls /usr/include/**time.h
2521 any file in the /usr/include directory tree ending in
2524 .Sq ls /usr/include/**time**.h
2525 will match any .h file with
2528 in a subdirectory name or in the filename itself).
2529 To prevent problems with recursion, the
2531 glob-pattern will not
2532 descend into a symbolic link containing a directory.
2540 shell variable can be set to prevent filename substitution,
2543 editor command, normally bound to
2546 used to interactively expand individual filename substitutions.
2547 .Ss "Directory stack substitution (+)"
2548 The directory stack is a list of directories, numbered from zero, used by the
2553 builtin commands (q.v.).
2555 can print, store in a file, restore and clear the directory stack
2556 at any time, and the
2560 shell variables can be set to
2561 store the directory stack automatically on logout and restore it on login.
2564 shell variable can be examined to see the directory stack and
2565 set to put arbitrary directories into the directory stack.
2569 followed by one or more digits expands to an entry in
2570 the directory stack.
2573 expands to the last directory in
2576 .Bd -literal -offset indent
2593 shell variables and the
2595 editor command apply to directory stack as well as filename substitutions.
2596 .Ss "Other substitutions (+)"
2597 There are several more transformations involving filenames, not strictly
2598 related to the above but mentioned here for completeness.
2600 filename may be expanded to a full path when the
2602 variable (q.v.) is set to
2604 Quoting prevents this expansion, and
2607 editor command does it on demand.
2609 .Va normalize-command
2610 editor command expands commands in PATH into
2611 full paths on demand.
2618 as the old working directory
2619 (equivalent to the shell variable
2621 This is not a substitution at all, but an abbreviation recognized by only
2623 Nonetheless, it too can be prevented by quoting.
2625 The next three sections describe how the shell executes commands and
2626 deals with their input and output.
2627 .Ss "Simple commands, pipelines and sequences"
2628 A simple command is a sequence of words, the first of which specifies the
2629 command to be executed.
2630 A series of simple commands joined by
2634 The output of each command in a pipeline is connected to the
2637 Simple commands and pipelines may be joined into sequences with
2640 be executed sequentially.
2641 Commands and pipelines can also be joined into
2646 indicating, as in the C language, that the second
2647 is to be executed only if the first fails or succeeds respectively.
2649 A simple command, pipeline or sequence may be placed in parentheses,
2651 to form a simple command, which may in turn be a component of a pipeline or
2653 A command, pipeline or sequence can be executed
2654 without waiting for it to terminate by following it with an
2656 .Ss "Builtin and non-builtin command execution"
2657 Builtin commands are executed within the shell.
2658 If any component of a
2659 pipeline except the last is a builtin command, the pipeline is executed
2662 Parenthesized commands are always executed in a subshell.
2663 .Bd -literal -offset indent
2669 directory, leaving you where you were
2670 (printing this after the home directory), while
2671 .Bd -literal -offset indent
2678 Parenthesized commands are most often
2681 from affecting the current shell.
2683 When a command to be executed is found not to be a builtin command the shell
2684 attempts to execute the command via
2686 Each word in the variable
2688 names a directory in which the shell will look for the
2690 If the shell is not given a
2693 hashes the names in these directories into an internal table so that it will
2696 in only a directory where there is a possibility that the
2697 command resides there.
2698 This greatly speeds command location when a large
2699 number of directories are present in the search path. This hashing mechanism is
2702 .Bl -enum -width indent
2704 If hashing is turned explicitly off via
2707 If the shell was given a
2710 For each directory component of
2712 which does not begin with a
2715 If the command contains a
2719 In the above four cases the shell concatenates each component of the path
2720 vector with the given command name to form a path name of a file which it
2721 then attempts to execute it. If execution is successful, the search stops.
2723 If the file has execute permissions but is not an executable to the system
2724 (i.e., it is neither an executable binary nor a script that specifies its
2725 interpreter), then it is assumed to be a file containing shell commands and
2726 a new shell is spawned to read it.
2729 special alias may be set
2730 to specify an interpreter other than the shell itself.
2732 On systems which do not understand the
2734 script interpreter convention
2735 the shell may be compiled to emulate it; see the
2739 If so, the shell checks the first line of the file to
2740 see if it is of the form
2741 .Sq #!interpreter arg ...
2748 file to it on standard input.
2750 The standard input and standard output of a command may be redirected with the
2753 .Bl -tag -width XXXXXX -offset indent -compact
2757 (which is first variable, command and filename
2758 expanded) as the standard input.
2760 Read the shell input up to a line which is identical to
2763 is not subjected to variable, filename or command substitution, and each input
2766 before any substitutions are done on this input
2778 command substitution is performed on the intervening lines, allowing
2786 Commands which are substituted have all blanks, tabs,
2787 and newlines preserved, except for the final newline which is dropped.
2789 resultant text is placed in an anonymous temporary file which is given to the
2790 command as standard input.
2798 is used as standard output.
2799 If the file does not exist
2800 then it is created; if the file exists, it is truncated, its previous contents
2803 If the shell variable
2805 is set, then the file must not exist or be a
2806 character special file (e.g., a terminal or
2808 or an error results.
2809 This helps prevent accidental destruction of files.
2813 can be used to suppress this check.
2819 is allowed on empty files;
2822 is set, an interacive confirmation is presented, rather than an
2827 route the diagnostic output into the specified file as
2828 well as the standard output.
2830 is expanded in the same way as
2832 input filenames are.
2840 , but appends output to the end of
2842 If the shell variable
2844 is set, then it is an error for
2847 to exist, unless one of the
2852 A command receives the environment in which the shell was invoked as modified
2853 by the input-output parameters and the presence of the command in a pipeline.
2854 Thus, unlike some previous shells, commands run from a file of shell commands
2855 have no access to the text of the commands by default; rather they receive the
2856 original standard input of the shell.
2859 mechanism should be used to
2860 present inline data.
2861 This permits shell command scripts to function as
2862 components of pipelines and allows the shell to block read its input.
2864 that the default standard input for a command run detached is
2868 but the original standard input of the shell.
2869 If this is a terminal and if the process attempts to read from the terminal,
2870 then the process will block and the user will be notified (see
2873 Diagnostic output may be directed through a pipe with the standard output.
2879 The shell cannot presently redirect diagnostic output without also redirecting
2880 standard output, but
2881 .Sq \&( command > output-file ) >& error-file
2882 is often an acceptable workaround.
2889 to send output to the terminal.
2891 Having described how the shell accepts, parses and executes
2892 command lines, we now turn to a variety of its useful features.
2894 The shell contains a number of commands which can be used to regulate the
2895 flow of control in command files (shell scripts) and (in limited but
2896 useful ways) from terminal input.
2897 These commands all operate by forcing the
2898 shell to reread or skip in its input and, due to the implementation,
2899 restrict the placement of some of the commands.
2906 statements, as well as the
2910 statement, require that the major
2911 keywords appear in a single simple command on an input line as shown below.
2913 If the shell's input is not seekable, the shell buffers up input whenever
2914 a loop is being read and performs seeks in this internal buffer to
2915 accomplish the rereading implied by the loop.
2916 (To the extent that this allows, backward
2918 s will succeed on non-seekable inputs.)
2926 use expressions with a common syntax.
2927 The expressions can include any
2928 of the operators described in the next three sections.
2931 builtin command (q.v.) has its own separate syntax.
2932 .Ss "Logical, arithmetical and comparison operators"
2933 These operators are similar to those of C and have the same precedence.
2936 .Bl -tag -width XXXXXX -offset indent -compact
2937 .It || && | & == != =~ !~ <= >=
2938 .It < > << >> + \- * / % ! ~ ( )
2941 Here the precedence increases to the right,
2962 groups, at the same level.
2970 their arguments as strings; all others operate on numbers.
2979 except that the right hand side is a
2981 .Sx Filename substitution )
2982 against which the left hand operand is matched.
2983 This reduces the need for use of the
2985 builtin command in shell scripts when all that is really needed is
2989 missing arguments are considered
2991 The results of all expressions are
2992 strings, which represent decimal numbers.
2993 It is important to note that
2994 no two components of an expression can appear in the same word; except
2995 when adjacent to components of expressions which are syntactically
2996 significant to the parser
3004 surrounded by spaces.
3005 .Ss "Command exit status"
3006 Commands can be executed in expressions and their exit status
3007 returned by enclosing them in braces
3009 Remember that the braces should
3010 be separated from the words of the command by spaces.
3012 succeed, returning true, i.e.,
3014 if the command exits with status 0,
3015 otherwise they fail, returning false, i.e.,
3017 If more detailed status
3018 information is required then the command should be executed outside of an
3021 shell variable examined.
3022 .Ss "File inquiry operators"
3023 Some of these operators perform true/false tests on files and related
3025 They are of the form
3031 .Bl -tag -width XXX -offset indent -compact
3039 Executable in the path or shell builtin, e.g.,
3062 Block special file (+)
3064 Character special file (+)
3066 Named pipe (fifo) (+) *
3068 Socket special file (+) *
3070 Set-user-ID bit is set (+)
3072 Set-group-ID bit is set (+)
3074 Sticky bit is set (+)
3076 (which must be a digit) is an open file descriptor
3077 for a terminal device (+)
3079 Has been migrated (Convex only) (+)
3081 Applies subsequent operators in a multiple-operator test to a symbolic link
3082 rather than to the file to which the link points (+) *
3086 is command and filename expanded and then tested to
3087 see if it has the specified relationship to the real user.
3090 does not exist or is inaccessible or, for the operators indicated by
3092 if the specified file type does not exist on the current system,
3093 then all inquiries return false, i.e.,
3096 These operators may be combined for conciseness:
3101 .Sq \&-x file && \&-y file .
3107 for plain executable files, but not for directories.
3110 may be used in a multiple-operator test to apply subsequent operators
3111 to a symbolic link rather than to the file to which the link points.
3114 is true for links owned by the invoking user.
3119 are always true for links and false for
3122 has a different meaning when it is the last operator
3123 in a multiple-operator test; see below.
3125 It is possible but not useful, and sometimes misleading, to combine operators
3128 to be a file with operators which do not
3135 with a non-file operator
3136 can lead to particularly strange results.
3138 Other operators return other information, i.e., not just
3143 They have the same format as before;
3151 Last file access time, as the number of seconds since the epoch
3156 , but in timestamp format, e.g.,
3157 .Sq Fri May 14 16:36:10 1993
3160 Last file modification time
3165 , but in timestamp format
3168 Last inode modification time
3173 , but in timestamp format
3184 ile identifier, in the form
3190 The name of the file pointed to by a symbolic link
3193 Number of (hard) links
3196 Permissions, in octal, without leading zero
3215 is writable by group and other,
3231 Username, or the numeric userid if the username is unknown
3237 Groupname, or the numeric groupid if the groupname is unknown
3244 Only one of these operators may appear in a multiple-operator test, and it
3248 has a different meaning at the end of and
3249 elsewhere in a multiple-operator test.
3252 is a valid return value
3253 for many of these operators, they do not return
3255 when they fail: most
3263 If the shell is compiled with POSIX defined (see the
3266 variable), the result of a file inquiry is based on the permission bits of
3267 the file and not on the result of the
3270 For example, if one tests a file with
3271 .Fl w\fR whose permissions would
3272 ordinarily allow writing but which is on a file system mounted read-only,
3273 the test will succeed in a POSIX shell but fail in a non-POSIX shell.
3275 File inquiry operators can also be evaluated with the
3280 The shell associates a
3284 current jobs, printed by the
3286 command, and assigns them small integer
3288 When a job is started asynchronously with
3290 , the shell prints a
3291 line which looks like
3295 indicating that the job which was started asynchronously was job number 1 and
3296 had one (top-level) process, whose process id was 1234.
3298 If you are running a job and wish to do something else you may hit the suspend
3301 which sends a STOP signal to the current job.
3302 The shell will then normally
3303 indicate that the job has been
3305 and print another prompt.
3308 shell variable is set, all jobs will be listed
3311 builtin command; if it is set to
3314 be in long format, like
3316 You can then manipulate the state of the suspended job.
3317 You can put it in the
3321 command or run some other commands and
3322 eventually bring the job back into the
3331 takes effect immediately and is like an interrupt
3332 in that pending output and unread input are discarded when it is typed.
3335 builtin command causes the shell to wait for all background
3340 key sends a delayed suspend signal, which does not generate a STOP
3341 signal until a program attempts to
3343 (2) it, to the current job.
3344 This can usefully be typed ahead when you have prepared some commands for a
3345 job which you wish to stop after it has read them.
3348 key performs this function in
3353 `^Y' is an editing command.
3356 A job being run in the background stops if it tries to read from the
3358 Background jobs are normally allowed to produce output, but this can
3359 be disabled by giving the command
3361 If you set this tty option,
3362 then background jobs will stop when they try to produce output like they do
3363 when they try to read input.
3365 There are several ways to refer to jobs in the shell.
3368 introduces a job name.
3369 If you wish to refer to job number 1, you can name it
3372 Just naming a job brings it to the foreground; thus
3377 , bringing job 1 back into the foreground.
3380 resumes job 1 in the background, just like
3382 A job can also be named
3383 by an unambiguous prefix of the string typed in to start it:
3386 normally restart a suspended
3388 (1) job, if there were only one suspended
3389 job whose name began with the string
3391 It is also possible to say
3394 ' to specify a job whose text contains
3397 is only one such job.
3399 The shell maintains a notion of the current and previous jobs.
3401 pertaining to jobs, the current job is marked with a
3403 and the previous job
3410 , and (by analogy with the syntax of
3415 all refer to the current job, and
3418 to the previous job.
3420 The job control mechanism requires that the
3426 It is an artifact from a
3428 implementation of the tty
3429 driver which allows generation of interrupt characters from the keyboard to
3436 details on setting options in the new tty driver.
3437 .Ss "Status reporting"
3438 The shell learns immediately whenever a process changes state.
3440 informs you whenever a job becomes blocked so that no further progress is
3441 possible, but only right before it prints a prompt.
3442 This is done so that it
3443 does not otherwise disturb your work.
3444 If, however, you set the shell variable
3446 , the shell will notify you immediately of changes of status in
3448 There is also a shell command
3451 single process so that its status changes will be immediately reported.
3455 marks the current process; simply say
3458 starting a background job to mark it.
3460 When you try to leave the shell while jobs are stopped, you will be
3462 .Sq There are suspended jobs.
3467 If you do this or immediately try to exit again, the shell
3468 will not warn you a second time, and the suspended jobs will be terminated.
3469 .Ss "Automatic, periodic and timed events (+)"
3470 There are various ways to run commands and take other actions automatically
3471 at various times in the
3474 They are summarized here,
3475 and described in detail under the appropriate
3476 .Va Builtin commands
3478 .Va Special shell variables
3484 builtin command puts commands in a scheduled-event list,
3485 to be executed by the shell at a given time.
3501 can be set, respectively, to execute commands when the shell wants
3502 to ring the bell, when the working directory changes, every
3504 minutes, before each prompt, before each command gets executed, after each
3505 command gets executed, and when a job is started or is brought into the
3510 shell variable can be set to log out or lock the shell
3511 after a given number of minutes of inactivity.
3515 shell variable can be set to check for new mail periodically.
3519 shell variable can be set to print the exit status
3520 of commands which exit with a status other than zero.
3524 shell variable can be set to ask the user, when
3527 typed, if that is really what was meant.
3531 shell variable can be set to execute the
3534 command after the completion of any process that takes more than a given
3535 number of CPU seconds.
3541 shell variables can be set to report when
3542 selected users log in or out, and the
3544 builtin command reports
3545 on those users at any time.
3546 .Ss "Native Language System support (+)"
3547 The shell is eight bit clean
3548 (if so compiled; see the
3551 and thus supports character sets needing this capability.
3552 NLS support differs depending on whether or not
3553 the shell was compiled to use the system's NLS (again, see
3556 In either case, 7-bit ASCII is the default character code
3557 (e.g., the classification of which characters are printable) and sorting,
3562 environment variables
3563 causes a check for possible changes in these respects.
3565 When using the system's NLS, the
3567 (3) function is called
3568 to determine appropriate character code/classification and sorting
3569 (e.g., a 'en_CA.UTF-8' would yield "UTF-8" as a character code).
3570 This function typically examines the
3574 environment variables; refer to the system documentation for further details.
3575 When not using the system's NLS, the shell simulates it by assuming that the
3576 ISO 8859-1 character set is used
3577 whenever either of the
3581 variables are set, regardless of
3583 Sorting is not affected for the simulated NLS.
3585 In addition, with both real and simulated NLS, all printable
3586 characters in the range \e200\-\e377, i.e., those that have
3589 bindings, are automatically rebound to
3590 .Va self-insert-command
3591 The corresponding binding for the escape-
3593 sequence, if any, is
3595 These characters are not rebound if the
3597 environment variable
3599 This may be useful for the simulated NLS or a primitive real NLS
3600 which assumes full ISO 8859-1.
3604 range \e240\-\e377 are effectively undone.
3605 Explicitly rebinding the relevant keys with
3607 is of course still possible.
3609 Unknown characters (i.e., those that are neither printable nor control
3610 characters) are printed in the format \ennn.
3611 If the tty is not in 8 bit mode, other 8 bit characters are printed by
3612 converting them to ASCII and using standout mode.
3614 never changes the 7/8 bit mode of the tty and tracks user-initiated
3615 changes of 7/8 bit mode.
3616 NLS users (or, for that matter, those who want to
3617 use a meta key) may need to explicitly set
3618 the tty in 8 bit mode through the appropriate
3621 command in, e.g., the
3624 .Ss "OS variant support (+)"
3625 A number of new builtin commands are provided to support features in
3626 particular operating systems.
3627 All are described in detail in the
3628 .Va Builtin commands
3631 On systems that support TCF (aix-ibm370, aix-ps2),
3635 get and set the system execution path,
3639 get and set the experimental version prefix
3642 migrates processes between sites.
3646 prints the site on which each job is executing.
3650 executes commands of the underlying BS2000/OSD
3655 adds shared libraries to the current environment,
3657 changes the rootnode and
3659 changes the systype.
3663 is equivalent to Mach's
3667 Under Masscomp/RTU and Harris CX/UX,
3675 runs a command under the specified
3680 prints or sets the universe.
3688 environment variables
3689 indicate respectively the vendor, operating system and machine type
3690 (microprocessor class or machine model) of the
3691 system on which the shell thinks it is running.
3692 These are particularly useful when sharing one's home directory between several
3693 types of machines; one can, for example,
3695 set path = (~/bin.$MACHTYPE /usr/ucb /bin /usr/bin .)
3699 and put executables compiled for each machine in the
3700 appropriate directory.
3705 variable indicates what options were chosen when the shell was compiled.
3713 shell variables and the system-dependent locations of
3714 the shell's input files (see
3717 .Ss "Signal handling"
3718 Login shells ignore interrupts when reading the file
3720 The shell ignores quit signals unless started with
3722 Login shells catch the terminate signal, but non-login shells inherit the
3723 terminate behavior from their parents.
3724 Other signals have the values which the shell inherited from its parent.
3726 In shell scripts, the shell's handling of interrupt and terminate signals
3727 can be controlled with
3729 , and its handling of hangups can be
3735 The shell exits on a hangup (see also the
3739 default, the shell's children do too, but the shell does not send them a
3740 hangup when it exits.
3742 arranges for the shell to send a hangup to
3743 a child when it exits, and
3745 sets a child to ignore hangups.
3746 .Ss "Terminal management (+)"
3747 The shell uses three different sets of terminal (
3750 `edit', used when editing,
3752 , used when quoting literal characters,
3755 , used when executing commands.
3756 The shell holds some settings in each mode constant, so commands which leave
3757 the tty in a confused state do not interfere with the shell.
3758 The shell also matches changes in the speed and padding of the tty.
3759 The list of tty modes that are kept constant
3760 can be examined and modified with the
3763 Note that although the editor uses CBREAK mode (or its equivalent),
3764 it takes typed-ahead characters anyway.
3772 commands can be used to
3773 manipulate and debug terminal capabilities from the command line.
3775 On systems that support SIGWINCH or SIGWINDOW, the shell
3776 adapts to window resizing automatically and adjusts the environment
3785 contains li# and co# fields, the shell adjusts
3786 them to reflect the new window size.
3788 The next sections of this manual describe all of the available
3789 .Va Builtin commands
3793 .Va Special shell variables
3794 .Ss "Builtin commands"
3807 Does nothing, successfully.
3811 .B @ \fIname\fB = \fIexpr
3831 The first form prints the values of all shell variables.
3835 The second form assigns the value of
3839 The third form assigns the value of
3854 may contain the operators
3869 then at least that part of
3871 must be placed within
3873 Note that the syntax of
3875 has nothing to do with that described
3879 The fourth and fifth forms increment (`++') or decrement (`\-\-')
3901 must be separated by spaces.
3910 Without arguments, prints all aliases.
3913 , prints the alias for name.
3923 is command and filename substituted.
3934 Shows the amount of dynamic memory acquired, broken down into used and free
3936 With an argument shows the number of free and used blocks in each size
3938 The categories start at size 8 and double at each step.
3940 command's output may vary across system types, because systems other than the VAX
3941 may use a different memory allocator.
3946 Puts the specified jobs (or, without arguments, the current job)
3947 into the background, continuing each if it is stopped.
3949 may be a number, a string,
3989 .\" .B macro can't take too many words, so I used \fB in the previous tags
3990 Without options, the first form lists all bound keys and the editor command to which each is bound,
3991 the second form lists the editor command to which
3994 the third form binds the editor command
4005 Lists all editor commands and a short description of each.
4008 Binds all keys to the standard bindings for the default editor,
4018 (1)\-style bindings.
4025 (1)\-style bindings.
4030 Lists or changes key-bindings in the alternative key map.
4031 This is the key map used in
4038 a control character written ^
4048 a meta character written M-
4053 a function key written F-
4058 or an extended prefix key written X-
4066 is interpreted as a symbolic arrow key name, which may be one of
4085 .Va self-insert-command
4092 is interpreted as a builtin or external command instead of an
4097 is taken as a literal string and treated as terminal input
4104 reinterpreted, and this continues for ten levels of interpretation.
4107 Forces a break from option processing, so the next word is taken as
4109 even if it begins with '\-'.
4111 .Fl u \fR(or any invalid option)
4112 Prints a usage message.
4116 may be a single character or a string.
4117 If a command is bound to a string, the first character of the string is bound to
4118 .Va sequence-lead-in
4119 and the entire string is bound to the command.
4121 Control characters in
4123 can be literal (they can be typed by preceding
4124 them with the editor command
4129 written caret-character style, e.g.,
4133 (caret-question mark).
4137 can contain backslashed
4138 escape sequences (in the style of System V
4169 The ASCII character corresponding to the octal number
4174 `\e' nullifies the special meaning of the following character, if it has
4186 to the BS2000 command interpreter for
4187 execution. Only non-interactive commands can be executed, and it is
4188 not possible to execute any command that would overlay the image
4189 of the current process, like /EXECUTE or /CALL-PROCEDURE. (BS2000 only)
4192 Causes execution to resume after the
4199 The remaining commands on the
4200 current line are executed.
4201 Multi-level breaks are thus
4202 possible by writing them all on one line.
4205 Causes a break from a
4207 , resuming after the
4211 Prints the names of all builtin commands.
4217 Available only if the shell was so compiled;
4222 .B case \fIlabel\fB:
4225 statement as discussed below.
4231 .Fl v\fR] [\I--\fR] [
4236 is given, changes the shell's working directory
4243 variable is not set, in which case a
4250 it is interpreted as the previous working directory
4252 .Va Other substitutions
4257 is not a subdirectory of the current directory
4258 (and does not begin with
4264 ), each component of the variable
4266 is checked to see if it has a subdirectory
4271 is a shell variable whose value
4274 or '.', then this is tried to see if it is a directory, and
4276 .Fl p\fR option is implied.
4280 .Fl p\fR, prints the final directory stack, just like
4285 .Fl v\fR flags have the same effect on
4293 .Fl \-\fR forces a break from option processing so the next word
4294 is taken as the directory
4296 even if it begins with '\-'. (+)
4312 [\fIword\fB/\fIpattern\fB/
4323 Without arguments, lists all completions.
4326 , lists completions for
4332 etc., defines completions.
4336 may be a full command name or a glob-pattern
4338 .Va Filename substitution
4343 completion should be used only when
4348 specifies which word relative to the current word
4349 is to be completed, and may be one of the following:
4355 Current-word completion.
4357 is a glob-pattern which must match the beginning of the current word on
4360 is ignored when completing the current word.
4367 when completing the current word.
4370 Next-word completion.
4372 is a glob-pattern which must match the beginning of the previous word on
4378 , but must match the beginning of the word two before the current word.
4381 Position-dependent completion.
4383 is a numeric range, with the same syntax used to index shell
4384 variables, which must include the current word.
4389 , the list of possible completions, may be one of the following:
4398 Bindings (editor commands)
4401 Commands (builtin or external commands)
4404 External commands which begin with the supplied path prefix
4410 Directories which begin with the supplied path prefix
4413 Environment variables
4419 Filenames which begin with the supplied path prefix
4447 files which begin with the supplied path prefix
4469 Words from the variable
4473 Words from the given list
4476 Words from the output of command
4481 is an optional glob-pattern.
4482 If given, words from only
4489 shell variable is ignored.
4490 The last three types of completion may not have a
4496 as an explanatory message when
4499 editor command is used.
4502 is a single character to be appended to a successful
4504 If null, no character is appended.
4505 If omitted (in which
4506 case the fourth delimiter can also be omitted), a slash is appended to
4507 directories and a space to other words.
4510 invoked from \`...\` version has additional environment
4511 variable set, the variable name is \%
4514 contains (as its name indicates) contents of the current (already
4515 typed in) command line. One can examine and use contents of the
4518 \% variable in her custom script to build more
4519 sophisticated completions (see completion for svn(1) included in
4522 Now for some examples.
4523 Some commands take only directories as arguments,
4524 so there's no point completing plain files.
4526 > complete cd 'p/1/d/'
4528 completes only the first word following
4530 (`p/1') with a directory.
4532 -type completion can also be used to narrow down command completion:
4538 > complete \-co* 'p/0/(compress)/'
4544 This completion completes commands (words in position 0,
4557 indicates that this completion is to be used with only
4560 > complete find 'n/\-user/u/'
4568 immediately following
4570 is completed from the list of users.
4572 > complete cc 'c/\-I/d/'
4582 is completed as a directory.
4583 `\-I' is not taken as part of the
4584 directory because we used lowercase
4589 s are useful with different commands.
4591 > complete alias 'p/1/a/'
4593 > complete man 'p/*/c/'
4595 > complete set 'p/1/s/'
4597 > complete true 'p/1/x:Truth has no options./'
4599 These complete words following
4606 with shell variables.
4607 `true' doesn't have any options, so
4609 does nothing when completion
4610 is attempted and prints
4611 .Sq Truth has no options.
4612 when completion choices are listed.
4616 example, and several other examples below, could
4617 just as well have used 'c/*' or 'n/*' as 'p/*'.
4619 Words can be completed from a variable evaluated at completion time,
4621 > complete ftp 'p/1/$hostnames/'
4623 > set hostnames = (rtfm.mit.edu tesla.ee.cornell.edu)
4627 rtfm.mit.edu tesla.ee.cornell.edu
4631 > set hostnames = (rtfm.mit.edu tesla.ee.cornell.edu uunet.uu.net)
4635 rtfm.mit.edu tesla.ee.cornell.edu uunet.uu.net
4637 or from a command run at completion time:
4639 > complete kill 'p/*/\`ps | awk \e{print\e \e$1\e}\`/'
4643 23113 23377 23380 23406 23429 23529 23530 PID
4647 command does not itself quote its arguments,
4648 so the braces, space and
4652 must be quoted explicitly.
4654 One command can have multiple completions:
4656 > complete dbx 'p/2/(core)/' 'p/*/c/'
4658 completes the second argument to
4663 arguments with commands.
4664 Note that the positional completion is specified
4665 before the next-word completion.
4666 Because completions are evaluated from left to right, if
4667 the next-word completion were specified first it would always match
4668 and the positional completion would never be executed.
4670 common mistake when defining a completion.
4674 pattern is useful when a command takes files with only
4675 particular forms as arguments.
4678 > complete cc 'p/*/f:*.[cao]/'
4682 arguments to files ending in only
4689 can also exclude files, using negation of a glob-pattern as
4691 .Va Filename substitution
4694 > complete rm 'p/*/f:^*.{c,h,cc,C,tex,1,man,l,y}/'
4696 to exclude precious source code from
4700 could still type excluded names manually or override the completion
4702 .Va complete-word-raw
4704 .Va list-choices-raw
4705 editor commands (q.v.).
4725 respectively, but they use the
4727 argument in a different way: to
4728 restrict completion to files beginning with a particular path prefix.
4730 example, the Elm mail program uses
4732 as an abbreviation for one's mail
4736 > complete elm c@=@F:$HOME/Mail/@
4746 to avoid confusion with the
4748 argument, and we used
4751 because home directory substitution works at only the
4752 beginning of a word.
4755 is used to add a nonstandard suffix
4758 for directories) to completed words.
4760 > complete finger 'c/*@/$hostnames/' 'p/1/u/@'
4762 completes arguments to
4764 from the list of users, appends an
4767 and then completes after the
4773 again the order in which the completions are specified.
4775 Finally, here's a complex example for inspiration:
4779 \&'n/\-name/f/' 'n/\-newer/f/' 'n/\-{,n}cpio/f/' \e
4781 \&\'n/\-exec/c/' 'n/\-ok/c/' 'n/\-user/u/' \e
4783 \&'n/\-group/g/' 'n/\-fstype/(nfs 4.2)/' \e
4785 \&'n/\-type/(b c d f l p s)/' \e
4787 \'c/\-/(name newer cpio ncpio exec ok user \e
4789 group fstype type atime ctime depth inum \e
4791 ls mtime nogroup nouser perm print prune \e
4797 This completes words following
4805 (note the pattern which matches both) to files,
4810 to commands, words following
4814 to users and groups respectively
4821 It also completes the switches themselves from the given list
4825 and completes anything not otherwise completed to a directory.
4828 Remember that programmed completions are ignored if the word being completed
4829 is a tilde substitution (beginning with
4831 ) or a variable (beginning with
4840 Continues execution of the nearest enclosing
4844 The rest of the commands on the current line are executed.
4847 Labels the default case in a
4850 It should come after all
4866 The first form prints the directory stack.
4867 The top of the stack is at the
4868 left and the first directory in the stack is the current directory.
4874 in the output is expanded explicitly
4877 or the pathname of the home directory for user \fIname\fP.
4880 .Fl n\fR, entries are wrapped before they reach the edge of the screen.
4883 .Fl v\fR, entries are printed one per line, preceded by their stack positions.
4888 .Fl v\fR takes precedence.
4889 .Fl p\fR is accepted but does nothing.
4894 .Fl S\fR, the second form saves the directory stack to
4902 .Fl L\fR, the shell sources
4904 , which is presumably
4905 a directory stack file saved by the
4906 .Fl S\fR option or the
4919 Note that login shells do the equivalent of
4929 is normally sourced before
4938 The last form clears the directory stack.
4947 to the shell's standard
4948 output, separated by spaces and terminated with a newline.
4951 shell variable may be set to emulate (or not) the flags and escape
4952 sequences of the BSD and/or System V versions of
4962 Exercises the terminal capabilities (see
4966 For example, 'echotc home' sends the cursor to the home position,
4967 \&'echotc cm 3 10' sends it to column 3 and row 10, and
4968 \&'echotc ts 0; echo "This is a test."; echotc fs' prints "This is a test."
4974 is 'baud', 'cols', 'lines', 'meta' or 'tabs', prints the
4975 value of that capability ("yes" or "no" indicating that the terminal does
4976 or does not have that capability).
4977 One might use this to make the output
4978 from a shell script less verbose on slow terminals, or limit command
4979 output to the number of lines on the screen:
4981 > set history=\`echotc lines\`
4985 Termcap strings may contain wildcards which will not echo correctly.
4986 One should use double quotes when setting a shell variable to a terminal
4987 capability string, as in the following example that places the date in
4990 > set tosl="\`echotc ts 0\`"
4992 > set frsl="\`echotc fs\`"
4994 > echo \-n "$tosl";date; echo \-n "$frsl"
4997 .Fl s\fR, nonexistent capabilities return the empty string rather
4998 than causing an error.
5000 .Fl v\fR, messages are verbose.
5011 See the description of the
5025 Treats the arguments as input to the
5026 shell and executes the resulting command(s) in the context
5027 of the current shell.
5028 This is usually used to execute commands
5029 generated as the result of command or variable substitution,
5030 because parsing occurs before these substitutions.
5033 (1) for a sample use of
5038 Executes the specified command in place of the current shell.
5043 The shell exits either with the value of the specified
5045 (an expression, as described under
5055 Brings the specified jobs (or, without arguments, the current job)
5056 into the foreground, continuing each if it is stopped.
5058 may be a number, a string,
5078 (which is a file inquiry operator as described under
5079 .Va File inquiry operators
5082 and returns the results as a
5083 space-separated list.
5085 .B foreach \fIname \fB(\fIwordlist\fB)
5091 Successively sets the variable
5095 and executes the sequence of commands between this command
5102 must appear alone on separate lines.) The builtin command
5104 may be used to continue the loop prematurely and
5107 to terminate it prematurely.
5108 When this command is read from the terminal, the loop is read once
5113 ) before any statements in
5114 the loop are executed.
5115 If you make a mistake typing in a
5116 loop at the terminal you can rub it out.
5120 Prints the system execution path.
5124 Prints the experimental version prefix.
5132 parameter is not recognized and words are
5133 delimited by null characters in the output.
5135 programs which wish to use the shell to filename expand a list of words.
5139 is filename and command-substituted to
5140 yield a string of the form
5142 The shell rewinds its
5143 input as much as possible, searches for a line of the
5146 , possibly preceded by blanks or tabs, and
5147 continues execution after that line.
5150 Prints a statistics line indicating how effective the
5151 internal hash table has been at locating commands (and avoiding
5156 is attempted for each component of the
5158 where the hash function indicates a possible hit, and
5159 in each component which does not begin with a
5164 (2), prints only the number and size of
5179 .B history \-c \fR(+)
5180 The first form prints the history event list.
5185 most recent events are printed or saved.
5187 .Fl h\fR, the history list is printed without leading numbers.
5190 is specified, timestamps are printed also in comment form.
5191 (This can be used to
5192 produce files suitable for loading with 'history \-L' or 'source \-h'.)
5194 .Fl r\fR, the order of printing is most recent
5195 first rather than oldest first.
5200 .Fl S\fR, the second form saves the history list to
5202 If the first word of the
5204 shell variable is set to a
5205 number, at most that many lines are saved.
5206 If the second word of
5210 , the history list is merged with the
5211 existing history file instead of replacing it (if there is one) and
5212 sorted by time stamp.
5213 (+) Merging is intended for an environment like
5215 with several shells in simultaneous use.
5216 If the second word of
5220 and the third word is set to
5222 , the history file update
5223 will be serialized with other shell sessions that would possibly like
5224 to merge history at exactly the same time.
5227 .Fl L\fR, the shell appends
5229 , which is presumably a
5230 history list saved by the
5231 .Fl S\fR option or the
5234 to the history list.
5236 .Fl L\fR, but the contents of
5239 into the history list and sorted by timestamp.
5249 `history \-L' is exactly like 'source \-h' except that it does not require a
5252 Note that login shells do the equivalent of
5262 is normally sourced before
5273 is set, the first and second forms print and save the literal
5274 (unexpanded) form of the history list.
5276 The last form clears the history list.
5286 such that it will exit on a hangup
5287 signal and arranges for the shell to send it a hangup signal when the shell
5289 Note that commands may set their own response to hangups, overriding
5291 Without an argument, causes the non-interactive shell only to
5292 exit on a hangup for the remainder of the script.
5299 .B if (\fIexpr\fB) \fIcommand
5302 (an expression, as described under
5305 evaluates true, then
5308 Variable substitution on
5310 happens early, at the same time it
5311 does for the rest of the
5315 must be a simple command, not an alias, a pipeline, a command list
5316 or a parenthesized command list, but it may have arguments.
5317 Input/output redirection occurs even if
5324 executed; this is a bug.
5326 .B if (\fIexpr\fB) then
5330 .B else if (\fIexpr2\fB) then
5342 is true then the commands to the
5345 are executed; otherwise if
5348 the commands to the second
5354 pairs are possible; only one
5360 part is likewise optional.
5365 must appear at the beginning of input lines;
5368 must appear alone on its input line or after an
5378 to the current environment.
5380 to remove a shared library.
5385 Lists the active jobs.
5387 .Fl l\fR, lists process
5388 IDs in addition to the normal information.
5389 On TCF systems, prints
5390 the site on which each job is executing.
5405 The first and second forms sends the specified
5408 is given, the TERM (terminate) signal) to the specified jobs or processes.
5410 may be a number, a string,
5421 Signals are either given by number or by name (as given in
5422 .Va /usr/include/signal.h
5423 , stripped of the prefix
5430 does not send a signal
5432 If the signal being sent is TERM (terminate)
5433 or HUP (hangup), then the job or process is sent a
5434 CONT (continue) signal as well.
5435 The third form lists the signal names.
5444 Limits the consumption by the current process and each
5445 process it creates to not individually exceed
5453 the current limit is printed; if no
5456 all limitations are given.
5458 .Fl h\fR flag is given, the
5459 hard limits are used instead of the current limits.
5461 hard limits impose a ceiling on the values of the current
5463 Only the super-user may raise the hard limits, but
5464 a user may lower or raise the current limits within the legal range.
5466 Controllable resources currently include (if supported by the OS):
5467 .Bl -tag -width pseudoterminals -compact -offset indent
5469 the maximum number of cpu-seconds to be used by each process
5471 the largest single file which can be created
5473 the maximum growth of the data+stack region via sbrk(2) beyond
5474 the end of the program text
5476 the maximum size of the automatically-extended stack region
5478 the size of the largest core dump that will be created
5480 the maximum amount of physical memory a process
5481 may have allocated to it at a given time
5483 the maximum amount of virtual memory a process
5484 may have allocated to it at a given time (address space)
5486 the maximum amount of virtual memory a process
5487 may have allocated to it at a given time
5489 the maximum amount of memory a process
5496 the maximum number of open files for this process
5497 .It Va pseudoterminals
5498 the maximum number of pseudo-terminals for this user
5500 the maximum number of kqueues allocated for this process
5502 the maximum number of threads for this process
5504 the maximum size which a process may lock into memory using mlock(2)
5506 the maximum number of simultaneous processes for this user id
5508 the maximum number of simultaneous threads (lightweight processes) for this
5511 the maximum number of threads for this process
5513 the maximum size of socket buffer usage for this user
5515 the maximum amount of swap space reserved or used for this user
5517 the maximum number of locks for this user
5519 the maximum number of POSIX advisory locks for this user
5521 the maximum number of pending signals for this user
5523 the maximum number of bytes in POSIX mqueues for this user
5525 the maximum nice priority the user is allowed to raise mapped from [19...-20]
5526 to [0...39] for this user
5528 the maximum realtime priority for this user
5530 the timeout for RT tasks in microseconds for this user.
5534 may be given as a (floating point or
5535 integer) number followed by a scale factor.
5539 the default scale is
5543 (1024 bytes); a scale factor of
5554 the default scaling is
5560 for hours, or a time of the
5563 giving minutes and seconds may be used.
5569 then the limitation on the specified
5571 is removed (this is equivalent to the
5577 names and scale factors, unambiguous
5578 prefixes of the names suffice.
5584 shell variable and reports on each user indicated
5587 who is logged in, regardless of when they last logged in.
5592 Terminates a login shell, replacing it with an instance of
5594 . This is one way to log off, included for
5599 Terminates a login shell.
5600 Especially useful if
5612 It identifies each type of
5613 special file in the listing with a special character:
5614 .Bl -tag -width x -offset indent -compact
5624 Named pipe (systems with named pipes only)
5626 Socket (systems with sockets only)
5628 Symbolic link (systems with symbolic links only)
5630 Hidden directory (AIX only) or context dependent (HP/UX only)
5632 Network special (HP/UX only)
5637 shell variable is set, symbolic links are identified
5638 in more detail (on only systems that have them, of course):
5643 Symbolic link to a non-directory
5646 Symbolic link to a directory
5649 Symbolic link to nowhere
5653 also slows down \fIls\-F\fR and causes partitions holding
5654 files pointed to by symbolic links to be mounted.
5658 shell variable is set to
5665 combination thereof (e.g.,
5667 ), they are used as flags to \fIls\-F\fR,
5680 is not the default, \fIls\-F\fR acts like
5687 , in which case it acts like
5689 \fIls\-F\fR passes its arguments to
5691 (1) if it is given any switches,
5694 generally does the right thing.
5696 The \fBls\-F\fR builtin can list files using different colors depending on the
5697 filetype or extension.
5700 shell variable and the
5702 environment variable.
5718 The first form migrates the process or job to the site specified or the
5719 default site determined by the system path.
5720 The second form is equivalent to
5725 current process to the specified site.
5727 itself can cause unexpected behavior, because the shell
5728 does not like to lose its tty.
5741 Available only if the shell was so compiled;
5751 Sets the scheduling priority for the shell to
5766 The super-user may specify negative
5768 .Sq nice \-number ...
5770 executed in a sub-shell, and the restrictions placed on
5782 such that it will ignore hangup signals.
5783 Note that commands may set their own response to hangups, overriding
5785 Without an argument, causes the non-interactive shell only to
5786 ignore hangups for the remainder of the script.
5796 Causes the shell to notify the user asynchronously when the status of any
5797 of the specified jobs (or, without %
5799 , the current job) changes,
5800 instead of waiting until the next prompt as is usual.
5802 may be a number, a string,
5821 Controls the action of the shell on interrupts.
5823 restores the default action of the shell on interrupts,
5824 which is to terminate shell scripts or to return to the
5825 terminal command input level.
5828 , causes all interrupts to be ignored.
5831 , causes the shell to execute a
5834 when an interrupt is received or a child process terminates because it was
5838 is ignored if the shell is running detached and in system
5841 ), where interrupts are disabled anyway.
5850 Without arguments, pops the directory stack and returns to the new top directory.
5856 'th entry in the stack.
5858 Finally, all forms of
5860 print the final directory stack,
5865 shell variable can be set to
5866 prevent this and the
5867 .Fl p\fR flag can be given to override
5872 .Fl v\fR flags have the same effect on
5881 Prints the names and values of all environment variables or,
5884 , the value of the environment variable
5896 Without arguments, exchanges the top two elements of the directory stack.
5901 without arguments does
5909 , pushes the current working directory onto the directory
5910 stack and changes to
5916 it is interpreted as the previous working directory
5918 .Va Filename substitution
5925 removes any instances of
5927 from the stack before pushing it onto the stack.
5935 directory stack around to be the top element and changes to it.
5944 directory, pushes it onto the top of the stack and changes to it.
5947 Finally, all forms of
5949 print the final directory stack,
5954 shell variable can be set to
5955 prevent this and the
5956 .Fl p\fR flag can be given to override
5961 .Fl v\fR flags have the same effect on
5968 Causes the internal hash table of the contents of the
5971 variable to be recomputed.
5975 shell variable is not set and new
5976 commands are added to directories in
5978 while you are logged
5982 , a new command will be found
5983 automatically, except in the special case where another command of
5984 the same name which is located in a different directory already
5985 exists in the hash table.
5986 Also flushes the cache of home directories
5987 built by tilde expansion.
5989 .B repeat \fIcount command
5993 which is subject to the same restrictions as the
5997 statement above, is executed
6000 I/O redirections occur exactly once, even if
6007 Changes the rootnode to //
6029 The first form prints the scheduled-event list.
6032 shell variable may be set to define the format in which
6033 the scheduled-event list is printed.
6034 The second form adds
6036 to the scheduled-event list.
6041 > sched 11:00 echo It\e's eleven o\e'clock.
6043 causes the shell to echo
6044 .Sq It's eleven o'clock .
6046 The time may be in 12-hour AM/PM format
6049 > sched 5pm set prompt='[%h] It\e's after 5; go home: >'
6051 or may be relative to the current time:
6053 > sched +2:15 /usr/lib/uucp/uucico \-r1 \-sother
6055 A relative time specification may not use AM/PM format.
6056 The third form removes item
6058 from the event list:
6059 .Bd -literal -offset indent
6061 1 Wed Apr 4 15:42 /usr/lib/uucp/uucico \-r1 \-sother
6062 2 Wed Apr 4 17:00 set prompt=[%h] It's after 5; go home: >
6065 1 Wed Apr 4 15:42 /usr/lib/uucp/uucico \-r1 \-sother
6068 A command in the scheduled-event list is executed just before the first
6069 prompt is printed after the time when the command is scheduled.
6070 It is possible to miss the exact time when the command is to be run, but
6071 an overdue command will execute at the next prompt.
6072 A command which comes due while the shell
6073 is waiting for user input is executed immediately.
6074 However, normal operation of an already-running command will not
6075 be interrupted so that a scheduled-event list element may be run.
6077 This mechanism is similar to, but not the same as, the
6080 command on some Unix systems.
6081 Its major disadvantage is that it may not run a command at exactly the
6083 Its major advantage is that because
6086 the shell, it has access to shell variables and other structures.
6087 This provides a mechanism for changing one's working environment
6088 based on the time of day.
6103 .B set [\-r] [\-f|\-l]
6127 The first form of the command prints the value of all shell variables.
6128 Variables which contain more than a single word print as a
6129 parenthesized word list.
6130 The second form sets
6137 The fourth form sets
6139 to the list of words in
6141 In all cases the value is command and filename expanded.
6143 .Fl r\fR is specified, the value is set read-only.
6146 .Fl l\fR are specified, set only unique words keeping their order.
6147 .Fl f\fR prefers the first occurrence of a word, and
6149 The fifth form sets the
6156 this component must already exist.
6157 The sixth form lists only the names of all shell variables that are read-only.
6158 The seventh form makes
6160 read-only, whether or not it has a value.
6161 The eighth form is the same as the third form, but
6164 read-only at the same time.
6167 These arguments can be repeated to set and/or make read-only multiple variables
6168 in a single set command.
6169 Note, however, that variable expansion
6170 happens for all arguments before any setting occurs.
6178 or separated from both by
6179 whitespace, but cannot be adjacent to only one or the other.
6189 Without arguments, prints the names and values of all environment variables.
6192 , sets the environment variable
6198 , to the null string.
6208 .B setspath\fR LOCAL|
6214 Sets the system execution path.
6220 Tells the shell to believe that the terminal capability
6226 No sanity checking is done.
6227 Concept terminal users may have to
6230 wrapping at the rightmost column.
6242 Controls which tty modes (see
6243 .Va Terminal management
6245 the shell does not allow to change.
6257 set of tty modes respectively; without
6264 Without other arguments,
6266 lists the modes in the chosen set
6267 which are fixed on (`+mode') or off (`\-mode').
6268 The available modes, and thus the display, vary from system to system.
6270 .Fl a\fR, lists all tty modes in the chosen set
6271 whether or not they are fixed.
6282 or removes control from
6286 .Sq setty +echok echoe
6289 mode on and allows commands
6292 mode on or off, both when the shell is executing commands.
6297 Set the experimental version prefix to
6308 Without arguments, discards
6310 [1] and shifts the members of
6315 not to be set or to have
6316 less than one word as value.
6329 The shell reads and executes commands from
6331 The commands are not placed on the history list.
6334 are given, they are placed in
6338 commands may be nested;
6339 if they are nested too deeply the shell may run out of file descriptors.
6342 at any level terminates all nested
6346 .Fl h\fR, commands are placed on the history list instead of being
6355 Stops the specified jobs or processes which are executing in the background.
6357 may be a number, a string,
6376 Causes the shell to stop in its tracks, much as if it had
6377 been sent a stop signal with
6379 This is most often used to
6380 stop shells started by
6384 .B switch (\fIstring\fB)
6402 Each case label is successively matched, against the
6405 which is first command and filename expanded.
6406 The file metacharacters
6413 in the case labels, which are variable expanded.
6415 of the labels match before a
6417 label is found, then
6418 the execution begins after the default label.
6420 label and the default label must appear at the beginning of
6424 causes execution to continue
6427 Otherwise control may fall through case
6428 labels and default labels as in C.
6429 If no label matches and
6430 there is no default, execution continues after the
6435 Lists the values of all terminal capabilities (see
6444 (or the current value of
6448 is given) has an entry in the hosts termcap(5) or
6449 terminfo(5) database. Prints the terminal type to stdout and returns 0
6450 if an entry is present otherwise returns 1.
6457 (which must be a simple command, not an alias,
6458 a pipeline, a command list or a parenthesized command list)
6459 and prints a time summary as described under the
6462 If necessary, an extra shell is created to print the time statistic when
6463 the command completes.
6466 , prints a time summary for the current shell and its
6472 Sets the file creation mask to
6474 , which is given in octal.
6475 Common values for the mask are
6476 002, giving all access to the group and read and execute access to others, and
6477 022, giving read and execute access to the group and others.
6480 , prints the current file creation mask.
6485 Removes all aliases whose names match
6487 `unalias *' thus removes all aliases.
6488 It is not an error for nothing to be
6495 Removes all completions whose names match
6497 `uncomplete *' thus removes all completions.
6498 It is not an error for nothing to be
6503 Disables use of the internal hash table to speed location of
6509 Sets the universe to
6517 Removes the limitation on
6526 .Fl h\fR, the corresponding hard limits are removed.
6527 Only the super-user may do this.
6530 may not exit successful, since most systems
6535 .Fl f\fR errors are ignored.
6538 Removes all variables whose names match
6540 , unless they are read-only.
6541 `unset *' thus removes all variables unless they are read-only;
6543 It is not an error for nothing to be
6546 .B unsetenv \fIpattern
6547 Removes all environment variables whose names match
6549 `unsetenv *' thus removes all environment variables;
6551 It is not an error for nothing to be
6560 Without arguments, prints
6584 The shell waits for all background jobs.
6585 If the shell is interactive, an
6586 interrupt will disrupt the wait and cause the shell to print the names and job
6587 numbers of all outstanding jobs.
6592 Sets the universe to
6597 An alternate name for the
6599 builtin command (q.v.).
6600 Available only if the shell was so compiled;
6608 Reports all known instances of
6610 , including aliases, builtins and
6617 Displays the command that will be executed by the shell after substitutions,
6620 The builtin command is just like
6622 (1), but it correctly reports
6624 aliases and builtins and is 10 to 100 times faster.
6636 Executes the commands between the
6642 (an expression, as described under
6649 must appear alone on their input lines.
6653 may be used to terminate or continue the
6655 If the input is a terminal, the user is prompted the first time
6656 through the loop as with
6659 .Ss "Special aliases (+)"
6660 If set, each of these aliases executes automatically at the indicated time.
6661 They are all initially undefined.
6664 Runs when the shell wants to ring the terminal bell.
6667 Runs after every change of working directory.
6668 For example, if the user is
6669 working on an X window system using
6671 (1) and a re-parenting window
6672 manager that supports title bars such as
6677 > alias cwdcmd 'echo \-n "^[]2;${HOST}:$cwd ^G"'
6679 then the shell will change the title of the running
6682 to be the name of the host, a colon, and the full current working directory.
6683 A fancier way to do that is
6685 > alias cwdcmd 'echo \-n "^[]2;${HOST}:$cwd^G^[]1;${HOST}^G"'
6687 This will put the hostname and working directory on the title bar but
6688 only the hostname in the icon manager menu.
6698 may cause an infinite loop.
6699 It is the author's opinion that anyone doing
6700 so will get what they deserve.
6704 Runs before each command gets executed, or when the command changes state.
6707 , but it does not print builtins.
6710 > alias jobcmd 'echo \-n "^[]2\e;\e!#:q^G"'
6714 will put the command string in the xterm title bar.
6721 The command name for which help
6722 is sought is passed as sole argument.
6723 For example, if one does
6726 > alias helpcommand '\e!:1 --help'
6728 then the help display of the command itself will be invoked, using the GNU
6729 help calling convention.
6730 Currently there is no easy way to account for various calling conventions (e.g.,
6733 ), except by using a table of many commands.
6740 This provides a convenient means for
6741 checking on common but infrequent changes such as new mail.
6748 > alias periodic checknews
6752 (1) program runs every 30 minutes.
6757 is unset or set to 0,
6764 Runs just before each prompt is printed.
6765 For example, if one does
6772 (1) runs just before the shell prompts for each command.
6773 There are no limits on what
6775 can be set to do, but discretion
6780 Runs before each command gets executed.
6783 > alias postcmd 'echo \-n "^[]2\e;\e!#:q^G"'
6787 will put the command string in the xterm title bar.
6791 Specifies the interpreter for executable scripts which do not themselves
6792 specify an interpreter.
6793 The first word should be a full path name to the
6794 desired interpreter (e.g.,
6797 .Sq /usr/local/bin/tcsh
6799 .Ss "Special shell variables"
6800 The variables described in this section have special meaning to the shell.
6829 startup; they do not change thereafter unless changed by the user.
6841 The shell synchronizes
6848 with the environment variables of the same names:
6849 whenever the environment variable changes the shell changes the corresponding
6850 shell variable to match (unless the shell variable is read-only) and vice
6856 have identical meanings, they
6857 are not synchronized in this manner, and that the shell automatically
6858 converts between the different formats of
6864 If set, filename completion adds
6866 to the end of directories and a space
6867 to the end of normal files when they are matched exactly.
6873 's autolock feature uses its value instead of
6874 the local username for kerberos authentication.
6877 If set, all times are shown in 12-hour AM/PM format.
6880 This variable selects what is propagated to the value of the
6882 variable. For more information see the description of the
6887 The arguments to the shell.
6888 Positional parameters are taken from
6896 Set by default, but usually empty in interactive shells.
6898 .B autocorrect \fR(+)
6901 editor command is invoked automatically before
6902 each completion attempt.
6904 .B autoexpand \fR(+)
6907 editor command is invoked automatically
6908 before each completion attempt. If this is set to
6911 only history will be expanded and a second completion will expand filenames.
6914 If set, possibilities are listed after an ambiguous completion.
6917 , possibilities are listed only when no new
6918 characters are added by completion.
6920 .B autologout \fR(+)
6921 The first word is the number of minutes of inactivity before automatic
6923 The optional second word is the number of minutes of inactivity
6924 before automatic locking.
6925 When the shell automatically logs out, it prints
6933 When the shell automatically locks, the user is required to enter his password
6934 to continue working.
6935 Five incorrect attempts result in automatic logout.
6938 (automatic logout after 60 minutes, and no locking) by default
6939 in login and superuser shells, but not if the shell thinks it is running
6940 under a window system (i.e., the
6942 environment variable is set),
6943 the tty is a pseudo-tty (pty) or the shell was not so compiled (see the
6952 .B autorehash \fR(+)
6953 If set, the internal hash table of the contents of the directories in the
6955 variable will be recomputed if a command is not found in the hash
6957 In addition, the list of available commands will be rebuilt for each
6958 command completion or spelling correction attempt if set to
6961 `correct' respectively; if set to
6963 , this will be done for both
6966 .B backslash_quote \fR(+)
6968 If set, backslashes (`\e') always quote
6975 complex quoting tasks easier, but it can cause syntax errors in
6980 The file name of the message catalog.
6983 as a message catalog instead of
6988 A list of directories in which
6991 subdirectories if they aren't found in the current directory.
6996 requires a directory
6998 , and will not go to the
7000 directory if it's omitted.
7001 This is set by default.
7004 If set, it enables color display for the builtin \fBls\-F\fR and it passes
7005 .Fl \-color=auto\fR to
7007 Alternatively, it can be set to only
7010 to enable color to only one command.
7012 it to nothing is equivalent to setting it to \fB(ls\-F ls)\fR.
7015 If set, it enables color escape sequence for NLS message files.
7016 And display colorful NLS messages.
7019 If set, the command which was passed to the shell with the
7023 .B compat_expr \fR(+)
7024 If set, the shell will evaluate expressions right to left, like the original
7030 , the completion becomes case insensitive.
7033 , completion ignores case and considers
7034 hyphens and underscores to be equivalent; it will also treat
7035 periods, hyphens and underscores (`.',
7043 , completion matches uppercase and underscore
7044 characters explicitly and matches lowercase and hyphens in a
7045 case-insensitive manner; it will treat periods, hyphens and underscores
7049 If set to a list of commands, the shell will continue the listed
7050 commands, instead of starting a new one.
7052 .B continue_args \fR(+)
7053 Same as continue, but the shell will execute:
7056 echo \`pwd\` $argv > ~/.<cmd>_pause; %<cmd>
7062 , commands are automatically spelling-corrected.
7065 , commands are automatically completed.
7068 , the entire command line is corrected.
7070 .B csubstnonl \fR(+)
7071 If set, newlines and carriage returns in command substitution are
7076 The full pathname of the current directory.
7089 th directory from the directory
7090 stack rather than rotating it to the top.
7093 The default location in which
7104 is normally sourced before
7114 An array of all the directories on the directory stack.
7115 `$dirstack[1]' is the current working directory,
7117 the first directory on the stack, etc.
7118 Note that the current working directory is
7123 directory stack substitutions, etc.
7124 One can change the stack arbitrarily by setting
7127 but the first element (the current working directory) is always correct.
7135 Has an effect iff 'dspm' is listed as part of the
7140 , it enables display and editing EUC-kanji(Japanese) code.
7143 , it enables display and editing Shift-JIS(Japanese) code.
7146 , it enables display and editing Big5(Chinese) code.
7149 , it enables display and editing Utf8(Unicode) code.
7150 If set to the following format, it enables display and editing of original
7151 multi-byte code format:
7154 > set dspmbyte = 0000....(256 bytes)....0000
7159 Each character of 256 characters
7160 corresponds (from left to right) to the ASCII codes 0x00, 0x01, ... 0xff.
7163 .\" (position in this table?)
7164 is set to number 0,1,2 and 3.
7165 Each number has the following meaning:
7167 0 ... not used for multi-byte characters.
7169 1 ... used for the first byte of a multi-byte character.
7171 2 ... used for the second byte of a multi-byte character.
7173 3 ... used for both the first byte and second byte of a multi-byte character.
7174 .\" SHK: I tried my best to get the following to be grammatically correct.
7175 .\" However, I still don't understand what's going on here.
7177 .\" following example, there are three bytes, but the text seems to refer to
7178 .\" each nybble as a character.
7179 What's going on here? It this 3-byte code
7180 .\" in the table? The text above seems to imply that there are 256
7181 .\" characters/bytes in the table.
7182 If I get some more info on this (perhaps
7183 .\" a complete example), I could fix the text to be grammatically correct.
7184 .\" (steve.kelem@xilinx.com 1999/09/13)
7190 , the first character (means 0x00 of the ASCII code) and
7191 second character (means 0x01 of ASCII code) are set to
7194 used for multi-byte characters.
7195 The 3rd character (0x02) is set to '1',
7196 indicating that it is used for the first byte of a multi-byte character.
7197 The 4th character(0x03) is set '3'.
7198 It is used for both the first byte and
7199 the second byte of a multi-byte character.
7200 The 5th and 6th characters
7201 (0x04,0x05) are set to '2', indicating that they are used for the second
7202 byte of a multi-byte character.
7204 The GNU fileutils version of ls cannot display multi-byte
7205 filenames without the -N ( --literal ) option.
7207 this version, set the second word of dspmbyte to "ls".
7209 example, "ls-F -l" cannot display multi-byte filenames.
7213 This variable can only be used if KANJI and DSPMBYTE has been defined at
7220 removes any instances of
7222 from the stack before pushing it onto the stack.
7225 If set, each command with its arguments is echoed just before it is
7227 For non-builtin commands all expansions occur before
7229 Builtin commands are echoed before command and filename
7230 substitution, because these substitutions are then done selectively.
7232 .Fl x\fR command line option.
7234 .B echo_style \fR(+)
7244 Don't echo a newline if the first argument is
7250 Recognize backslashed escape sequences in echo strings.
7255 flag and backslashed escape sequences; the default
7263 Set by default to the local system default.
7264 The BSD and System V
7265 options are described in the
7267 (1) man pages on the appropriate
7272 If set, the command-line editor is used.
7273 Set by default in interactive
7277 A list of command names for the
7279 editor command to match.
7285 environment variables will be used instead.
7292 prompt sequences (see the
7294 shell variable) indicate skipped directories with an ellipsis (`...')
7299 The user's effective user ID.
7302 The first matching passwd entry name corresponding to the effective user ID.
7305 Lists file name suffixes to be ignored by completion.
7310 , completion is always used and this variable is ignored
7313 is unset, then the traditional
7318 , filename completion is used.
7321 The user's real group ID.
7324 If set, wild-card glob patterns will match files and directories beginning
7337 file glob patterns will match any string of
7338 characters including
7340 traversing any existing sub-directories.
7342 `ls **.c' will list all the .c files in the current directory tree).
7343 If used by itself, it will match zero or more sub-directories
7345 .Sq ls /usr/include/**/time.h
7346 will list any file named
7348 in the /usr/include directory tree; whereas
7349 .Sq ls /usr/include/**time.h
7350 will match any file in the /usr/include directory tree ending in
7353 To prevent problems with recursion, the
7355 glob-pattern will not
7356 descend into a symbolic link containing a directory.
7362 The user's group name.
7365 If set, the incremental search match (in
7369 ) and the region between the mark and the cursor are
7370 highlighted in reverse video.
7372 Highlighting requires more frequent terminal writes, which introduces extra
7373 overhead. If you care about terminal performance, you may want to leave this
7377 A string value determining the characters used in \fBHistory
7378 substitution\fR (q.v.).
7379 The first character of its value is used as
7380 the history substitution character, replacing the default character
7382 The second character of its value replaces the character
7385 quick substitutions.
7388 Controls handling of duplicate entries in the history list.
7390 `all' only unique history events are entered in the history list.
7394 and the last history event is the same as the current
7395 command, then the current command is not entered in the history.
7399 and the same event is found in the history list, that
7400 old event gets erased and the current one gets inserted.
7404 options renumber history events so there are no gaps.
7407 The default location in which
7418 useful when sharing the same home directory between different machines,
7419 or when saving separate histories on different terminals.
7422 is normally sourced before
7432 If set, builtin and editor commands and the
7435 use the literal (unexpanded) form of lines in the history list.
7438 .Va toggle-literal-history
7442 The first word indicates the number of history events to save.
7444 optional second word (+) indicates the format in which history is
7445 printed; if not given,
7448 The format sequences
7449 are described below under
7451 ; note the variable meaning of
7458 Initialized to the home directory of the invoker.
7463 refers to this variable.
7466 If set to the empty string or
7468 and the input device is a terminal,
7471 command (usually generated by the user by typing
7472 `^D' on an empty line) causes the shell to print `Use "exit" to leave
7473 tcsh.' instead of exiting.
7474 This prevents the shell from accidentally
7476 Historically this setting exited after 26 successive
7477 EOF's to avoid infinite loops.
7490 is used, i.e., the shell exits on a
7494 .B implicitcd \fR(+)
7495 If set, the shell treats a directory name typed as a command as though
7496 it were a request to change to that directory.
7500 the change of directory is echoed to the standard output.
7502 is inhibited in non-interactive shell scripts, or for command strings
7503 with more than one word.
7504 Changing directory takes precedence over
7505 executing a like-named command, but it is done after alias
7507 Tilde and variable expansions work as expected.
7514 , puts the editor into that input mode
7515 at the beginning of each line.
7518 Controls handling of duplicate entries in the kill ring.
7520 `all' only unique strings are entered in the kill ring.
7522 `prev' and the last killed string is the same as the current killed
7523 string, then the current string is not entered in the ring.
7527 and the same string is found in the kill ring, the old
7528 string is erased and the current one is inserted.
7531 Indicates the number of killed strings to keep in memory.
7535 If unset or set to less than
7537 , the shell will only
7538 keep the most recently killed string.
7539 Strings are put in the killring by the editor commands that delete
7540 (kill) strings of text, e.g.
7541 .Va backward-delete-word
7544 , etc, as well as the
7545 .Va copy-region-as-kill
7549 editor command will yank the most recently killed string
7550 into the command-line, while
7555 can be used to yank earlier killed strings.
7564 , or any combination thereof (e.g.,
7567 are used as flags to \fIls\-F\fR, making it act like
7572 or a combination (e.g.,
7577 files (even if they start with a
7586 sorts across instead of down.
7587 If the second word of
7589 is set, it is used as the path to
7593 If set, all jobs are listed when a job is suspended.
7597 the listing is in long format.
7600 If set, the \fIls\-F\fR builtin command shows the type of file to which
7601 each symbolic link points.
7604 The maximum number of items which the
7607 will list without asking first.
7609 .B listmaxrows \fR(+)
7610 The maximum number of rows of items which the
7613 command will list without asking first.
7616 Set by the shell if it is a login shell.
7617 Setting or unsetting it
7618 within a shell has no effect.
7625 before a normal logout,
7628 an automatic logout, and
7630 if the shell was killed by a hangup
7639 A list of files and directories to check for incoming mail, optionally
7640 preceded by a numeric word.
7641 Before each prompt, if 10 minutes have
7642 passed since the last check, the shell checks each file and says `You
7643 have new mail.' (or, if
7645 contains multiple files, `You have
7648 .') if the filesize is greater than zero in size
7649 and has a modification time greater than its access time.
7654 If you are in a login shell, then no mail file is reported unless it has
7655 been modified after the time the shell has started up, to prevent
7656 redundant notifications.
7657 Most login programs will tell you whether or not
7658 you have mail when you log in.
7660 If a file specified in
7662 is a directory, the shell will count each
7663 file within that directory as a separate message, and will report `You have
7671 This functionality is provided primarily for those systems which store mail
7672 in this manner, such as the Andrew Mail System.
7674 If the first word of
7676 is numeric it is taken as a different mail
7677 checking interval, in seconds.
7679 Under very rare circumstances, the shell may report
7683 .Sq You have new mail.
7689 , completion never beeps.
7692 , it beeps only when there is no match.
7695 , it beeps when there are multiple matches.
7698 , it beeps when there is one exact and other longer matches.
7704 If set, beeping is completely disabled.
7709 If set, restrictions are placed on output redirection to insure that files
7710 are not accidentally destroyed and that
7712 redirections refer to existing
7713 files, as described in the
7718 If set, disable the printing of
7723 specifiers at the change of hour.
7727 .Va Filename substitution
7729 .Va Directory stack substitution
7730 (q.v.) are inhibited.
7731 This is most useful in shell scripts which do not deal
7732 with filenames, or after a list of filenames has been obtained and further
7733 expansions are not desirable.
7736 If set and the shell supports Kanji (see the
7739 it is disabled so that the meta key can be used.
7743 .Va Filename substitution
7745 .Va Directory stack substitution
7746 (q.v.) which does not match any
7747 existing files is left untouched rather than causing an error.
7748 It is still an error for the substitution to be
7751 still gives an error.
7754 A list of directories (or glob-patterns which match directories; see
7755 .Va Filename substitution
7756 ) that should not be
7759 completion operation.
7760 This is usually used to exclude directories which
7761 take too much time to
7767 If set, the shell announces job completions asynchronously.
7768 The default is to present job completions just before printing a prompt.
7771 The user's real organization ID.
7775 The old working directory, equivalent to the
7788 If set, enable the printing of padding '0' for hours, in 24 and 12 hour
7790 E.G.: 07:45:42 vs. 7:45:42.
7793 To retain compatibily with older versions numeric variables starting with
7794 0 are not interpreted as octal. Setting this variable enables proper octal
7798 A list of directories in which to look for executable commands.
7799 A null word specifies the current directory.
7802 variable then only full path names will execute.
7804 is set by the shell at startup from the
7809 does not exist, to a system-dependent default
7811 .Sq (/usr/local/bin /usr/bsd /bin /usr/bin .)
7817 depending on how it was compiled; see the
7820 A shell which is given neither the
7823 hashes the contents of the directories in
7831 If one adds a new command to a directory in
7834 is active, one may need to do a
7836 for the shell to find it.
7838 .B printexitvalue \fR(+)
7839 If set and an interactive program exits with a non-zero status, the shell
7845 The string which is printed before reading each command from the terminal.
7847 may include any of the following formatting sequences (+), which
7848 are replaced by the given information:
7854 The current working directory.
7857 The current working directory, but with one's home directory
7860 and other users' home directories represented by
7862 .Va Filename substitution
7863 `~user' substitution
7864 happens only if the shell has already used
7868 in the current session.
7875 The trailing component of the current working directory, or
7877 trailing components if a digit
7884 , the number of skipped components precede
7885 the trailing component(s) in the format
7891 shell variable is set, skipped components
7892 are represented by an ellipsis so the whole becomes
7894 `~' substitution is done as in
7899 is ignored when counting trailing components.
7902 Like %c, but without
7907 The current history event number.
7913 The hostname up to the first
7917 Start (stop) standout mode.
7920 Start (stop) boldfacing mode.
7923 Start (stop) underline mode.
7926 The time of day in 12-hour AM/PM format.
7931 , but in 24-hour format (but see the
7938 time of day in 12-hour AM/PM format, with seconds.
7943 , but in 24-hour format (but see the
7967 The effective user name.
8006 Clears from the end of the prompt to end of the display or the end of the line.
8009 Expands the shell or environment variable name immediately after the
8013 `>' (or the first character of the
8018 (or the second character of
8028 as a literal escape sequence.
8029 It should be used only to change terminal attributes and
8030 should not move the cursor location.
8032 cannot be the last sequence in
8036 The return code of the command executed just before the prompt.
8041 , the status of the parser.
8044 , the corrected string.
8047 , the history string.
8058 are available in only
8059 eight-bit-clean shells; see the
8063 The bold, standout and underline sequences are often used to distinguish a
8067 > set prompt = "%m [%h] %B[%@]%b [%/] you rang? "
8071 [/usr/accts/sys] you rang? _
8088 on the change of hour (i.e,
8095 in interactive shells.
8099 The string with which to prompt in
8104 after lines ending in
8106 The same format sequences may be used as in
8109 note the variable meaning of
8113 in interactive shells.
8116 The string with which to prompt when confirming automatic spelling correction.
8117 The same format sequences may be used as in
8120 note the variable meaning of
8123 .Sq CORRECT>%R (y|n|e|a)?
8124 in interactive shells.
8126 .B promptchars \fR(+)
8127 If set (to a two-character string), the
8129 formatting sequence in the
8131 shell variable is replaced with the first character for
8132 normal users and the second character for the superuser.
8134 .B pushdtohome \fR(+)
8137 without arguments does
8142 .B pushdsilent \fR(+)
8147 do not print the directory stack.
8150 If set, completion completes on an exact match even if a longer match is
8153 .B recognize_only_executables \fR(+)
8154 If set, command listing displays only files in the path that are
8159 If set, the user is prompted before
8164 The string to print on the right-hand side of the screen (after
8165 the command input) when the prompt is being displayed on the left.
8166 It recognizes the same formatting characters as
8168 It will automatically disappear and reappear as necessary, to ensure that
8169 command input isn't obscured, and will appear only if the prompt,
8170 command input, and itself will fit together on the first line.
8175 will be printed after
8176 the prompt and before the command input.
8179 If set, the shell does
8182 If the first word is set to a number, at most that many directory stack
8186 If set, the shell does
8189 If the first word is set to a number, at most that many lines are saved.
8190 (The number should be less than or equal to the number
8193 if it is set to greater than the number of
8197 entries will be saved)
8198 If the second word is set to
8200 , the history list is merged with
8201 the existing history file instead of replacing it (if there is one) and
8202 sorted by time stamp and the most recent events are retained.
8203 If the second word of
8207 and the third word is set to
8208 `lock', the history file update will be serialized with other shell sessions
8209 that would possibly like to merge history at exactly the same time. (+)
8212 The format in which the
8214 builtin command prints scheduled events;
8218 The format sequences are described above under
8221 note the variable meaning of
8225 The file in which the shell resides.
8226 This is used in forking
8227 shells to interpret files which have execute bits set, but
8228 which are not executable by the system.
8229 (See the description
8231 .Va Builtin and non-builtin command execution
8232 .) Initialized to the
8233 (system-dependent) home of the shell.
8236 The number of nested shells.
8237 Reset to 1 in login shells.
8242 The exit status from the last command or backquote expansion, or any
8243 command in a pipeline is propagated to
8249 This default does not match what POSIX mandates (to return the
8250 status of the last command only). To match the POSIX behavior, you need
8257 variable is unset, the exit status of a pipeline
8258 is determined only from the last command in the pipeline, and the exit
8259 status of a backquote expansion is
8264 If a command terminated abnormally, then 0200 is added to the status.
8265 Builtin commands which fail return exit status
8268 commands return status
8273 Can be set to several different values to control symbolic link (`symlink')
8279 , whenever the current directory changes to a directory
8280 containing a symbolic link, it is expanded to the real name of the directory
8281 to which the link points.
8282 This does not work for the user's home directory;
8287 , the shell tries to construct a current directory
8288 relative to the current directory before the link was crossed.
8291 ing through a symbolic link and then
8294 returns one to the original directory.
8295 This affects only builtin commands
8296 and filename completion.
8300 , the shell tries to fix symbolic links by actually expanding
8301 arguments which look like path names.
8302 This affects any command, not just
8304 Unfortunately, this does not work for hard-to-recognize filenames,
8305 such as those embedded in command options.
8306 Expansion may be prevented by
8308 While this setting is usually the most convenient, it is sometimes
8309 misleading and sometimes confusing when it fails to recognize an argument
8310 which should be expanded.
8311 A compromise is to use
8316 (bound by default to ^X-n) when necessary.
8318 Some examples are in order.
8319 First, let's set up some play directories:
8323 > mkdir from from/src to
8325 > ln \-s from/src to/dst
8327 Here's the behavior with
8331 > cd /tmp/to/dst; echo $cwd
8339 here's the behavior with
8345 > cd /tmp/to/dst; echo $cwd
8353 here's the behavior with
8359 > cd /tmp/to/dst; echo $cwd
8367 and here's the behavior with
8372 > cd /tmp/to/dst; echo $cwd
8380 > cd /tmp/to/dst; echo $cwd
8384 > cd ".."; echo $cwd
8398 expansion 1) works just like
8403 , 2) is prevented by quoting, and 3) happens before
8404 filenames are passed to non-builtin commands.
8408 The version number of the shell in the format
8413 is the major release number,
8425 .Va Startup and shutdown
8428 If set to a number, then the
8430 builtin (q.v.) executes automatically
8431 after each command which takes more than that many CPU seconds.
8432 If there is a second word, it is used as a format string for the output
8436 (u) The following sequences may be used in the
8443 The time the process spent in user mode in cpu seconds.
8446 The time the process spent in kernel mode in cpu seconds.
8449 The elapsed (wall clock) time in seconds.
8452 The CPU percentage computed as (%U + %S) / %E.
8455 Number of times the process was swapped.
8458 The average amount in (shared) text space used in Kbytes.
8461 The average amount in (unshared) data/stack space used in Kbytes.
8464 The total space used (%X + %D) in Kbytes.
8467 The maximum memory the process had in use at any time in Kbytes.
8470 The number of major page faults (page needed to be brought from disk).
8473 The number of minor page faults.
8476 The number of input operations.
8479 The number of output operations.
8482 The number of socket messages received.
8485 The number of socket messages sent.
8488 The number of signals received.
8491 The number of voluntary context switches (waits).
8494 The number of involuntary context switches.
8497 Only the first four sequences are supported on systems without BSD resource
8499 The default time format is
8500 .Sq %Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww
8502 systems that support resource usage reporting and
8505 systems that do not.
8507 Under Sequent's DYNIX/ptx, %X, %D, %K, %r and %s are not
8508 available, but the following additional sequences are:
8513 The number of system calls performed.
8516 The number of pages which are zero-filled on demand.
8519 The number of times a process's resident set size was increased by the kernel.
8522 The number of times a process's resident set size was decreased by the kernel.
8525 The number of read system calls performed.
8528 The number of write system calls performed.
8531 The number of reads from raw disk devices.
8534 The number of writes to raw disk devices.
8537 and the default time format is
8538 .Sq %Uu %Ss %E %P %I+%Oio %Fpf+%Ww
8539 Note that the CPU percentage can be higher than 100% on multi-processors.
8543 The period, in minutes, between executions of the
8548 The name of the tty, or empty if not attached to one.
8551 The user's real user ID.
8554 The user's login name.
8557 If set, causes the words of each
8558 command to be printed, after history substitution (if any).
8560 .Fl v\fR command line option.
8563 The version ID stamp.
8564 It contains the shell's version number (see
8567 origin, release date, vendor, operating system and machine (see
8573 ) and a comma-separated
8574 list of options which were set at compile time.
8575 Options which are set by default in the distribution are noted.
8581 The shell is eight bit clean; default
8584 The shell is not eight bit clean
8587 The shell is multibyte encoding clean (like UTF-8)
8590 The system's NLS is used; default for systems with NLS
8593 Login shells execute
8595 before instead of after
8599 before instead of after
8607 for security; default
8616 (1)\-style editing is the default rather than
8621 Login shells drop DTR when exiting
8629 is an alternate name for
8637 Kanji is used if appropriate according to locale settings,
8640 shell variable is set
8649 .Sq #!<program> <args>
8650 convention is emulated when executing shell scripts
8655 builtin is available
8658 The shell attempts to set the
8660 environment variable
8663 The shell verifies your password with the kerberos server if local
8664 authentication fails.
8667 shell variable or the
8669 environment variable override your local username if set.
8672 An administrator may enter additional strings to indicate differences
8673 in the local version.
8678 If unset, various key bindings change behavior to be more
8681 word boundaries are determined by
8683 versus other characters.
8685 If set, various key bindings change behavior to be more
8688 word boundaries are determined by
8691 versus other characters;
8692 cursor behavior depends upon current vi mode (command, delete, insert, replace).
8694 This variable is unset by
8704 may be explicitly set or unset by the user after those
8706 operations if required.
8709 .B visiblebell \fR(+)
8710 If set, a screen flash is used rather than the audible bell.
8715 A list of user/terminal pairs to watch for logins and logouts.
8716 If either the user is
8718 all terminals are watched for the given user
8724 watches all users and terminals.
8728 set watch = (george ttyd1 any console $user any)
8730 reports activity of the user
8732 on ttyd1, any user on the console, and
8733 oneself (or a trespasser) on any terminal.
8735 Logins and logouts are checked every 10 minutes by default, but the first
8738 can be set to a number to check every so many minutes.
8741 set watch = (1 any any)
8743 reports any login/logout once every minute.
8744 For the impatient, the
8746 builtin command triggers a
8750 are reported (as with the
8758 shell variable controls the format of
8764 The format string for
8767 The following sequences
8768 are replaced by the given information:
8774 The name of the user who logged in/out.
8777 The observed action, i.e.,
8787 The terminal (tty) on which the user logged in/out.
8790 The full hostname of the remote host, or
8792 if the login/logout was
8793 from the local host.
8796 The hostname of the remote host up to the first
8798 The full name is printed if it is an IP address or an X Window System display.
8801 %M and %m are available on only systems that store the remote hostname in
8804 .Sq %n has %a %l from %m.
8808 which don't store the remote hostname.
8812 A list of non-alphanumeric characters to be considered part of a word by the
8816 etc., editor commands.
8817 If unset, the default value is determined based on the state of
8824 is used as the default;
8829 is used as the default.
8838 The number of columns in the terminal.
8840 .Va Terminal management
8843 Used by X Window System (see
8846 If set, the shell does not set
8851 The pathname to a default editor.
8854 editor command if the
8857 shell variable is unset.
8860 environment variable.
8873 Initialized to the name of the machine on which the shell
8874 is running, as determined by the
8879 Initialized to the type of machine on which the shell
8880 is running, as determined at compile time.
8881 This variable is obsolete and
8882 will be removed in a future version.
8885 A colon-separated list of directories in which the
8888 command looks for command documentation.
8891 Gives the preferred character environment.
8893 .Va Native Language System support
8896 If set, only ctype character handling is changed.
8898 .Va Native Language System support
8901 The number of lines in the terminal.
8903 .Va Terminal management
8906 The format of this variable is reminiscent of the
8908 file format; a colon-separated list of expressions of the form
8913 " is a two-character variable name.
8915 variables with their associated defaults are:
8922 Normal (non-filename) text
8952 Missing file (defaults to fi)
8955 Orphaned symbolic link (defaults to ln)
8964 End code (replaces lc+no+rc)
8968 You need to include only the variables you want to change from
8971 File names can also be colorized based on filename extension.
8972 This is specified in the
8974 variable using the syntax
8976 For example, using ISO 6429 codes, to color
8977 all C\-language source files blue you would specify
8979 This would color all files ending in
8983 Control characters can be written either in C\-style\-escaped
8984 notation, or in stty\-like ^\-notation.
8985 The C\-style notation
8988 for Escape, \fB\_\fR for a normal space character,
8995 can be used to override the default interpretation of
9004 Each file will be written as
9015 code is undefined, the sequence
9019 will be used instead.
9020 This is generally more convenient
9021 to use, but less general.
9022 The left, right and end codes are
9023 provided so you don't have to type common parts over and over
9024 again and to support weird terminals; you will generally not
9025 need to change them at all unless your terminal does not use
9026 ISO 6429 color sequences but a different system.
9028 If your terminal does use ISO 6429 color codes, you can
9029 compose the type codes (i.e., all except the
9036 codes) from numerical commands separated by semicolons.
9038 most common commands are:
9044 to restore default color
9056 for black foreground
9062 for green foreground
9065 for yellow (or brown) foreground
9071 for purple foreground
9077 for white (or gray) foreground
9080 for black background
9086 for green background
9089 for yellow (or brown) background
9095 for purple background
9101 for white (or gray) background
9105 Not all commands will work on all systems or display devices.
9107 A few terminal programs do not recognize the default end code
9109 If all text gets colorized after you do a directory
9110 listing, try changing the
9115 numerical codes for your standard fore- and background colors.
9119 The machine type (microprocessor class or machine model), as determined at compile time.
9122 If set, printable characters are not rebound to
9123 .Va self-insert-command
9125 .Va Native Language System support
9128 The operating system, as determined at compile time.
9131 A colon-separated list of directories in which to look for executables.
9134 shell variable, but in a different format.
9139 shell variable, but not synchronized to it;
9140 updated only after an actual directory change.
9142 .B REMOTEHOST \fR(+)
9143 The host from which the user has logged in remotely, if this is the case and
9144 the shell is able to determine it.
9145 Set only if the shell was so compiled;
9156 The current system type.
9165 The terminal capability string.
9167 .Va Terminal management
9175 The vendor, as determined at compile time.
9178 The pathname to a default full-screen editor.
9181 editor command if the
9184 shell variable is unset.
9187 environment variable.
9192 Read first by every shell.
9193 ConvexOS, Stellix and Intel use
9198 A/UX, AMIX, Cray and IRIX have no equivalent in
9201 but read this file in
9204 Solaris 2.x does not have it either, but
9211 Read by login shells after
9213 ConvexOS, Stellix and Intel use
9221 A/UX, AMIX, Cray and IRIX use
9225 Read by every shell after
9230 Read by every shell, if
9249 Read by login shells after
9253 is set, but see also
9257 Read by login shells after
9261 The shell may be compiled to read
9263 before instead of after
9271 .I ~/.cshdirs \fR(+)
9272 Read by login shells after
9276 is set, but see also
9280 Read by login shells at logout.
9281 ConvexOS, Stellix and Intel use
9286 A/UX, AMIX, Cray and IRIX have no equivalent in
9289 but read this file in
9292 Solaris 2.x does not have it either, but
9299 Read by login shells at logout after
9304 Used to interpret shell scripts not starting with a
9312 Source of home directories for
9317 The order in which startup files are read may differ if the shell was so
9319 .Va Startup and shutdown
9323 .Sh "NEW FEATURES (+)"
9324 This manual describes
9329 users will want to pay special attention to
9333 A command-line editor, which supports
9338 (1)\-style key bindings.
9340 .Va The command-line editor
9344 Programmable, interactive word completion and listing.
9346 .Sx Completion and listing
9353 .Va Spelling correction
9354 (q.v.) of filenames, commands and variables.
9357 (q.v.) which perform other useful functions in the middle of
9358 typed commands, including documentation lookup
9360 quick editor restarting
9361 .Va ( run-fg-editor )
9364 .Va ( which-command ).
9366 An enhanced history mechanism.
9367 Events in the history list are time-stamped.
9370 command and its associated shell variables,
9371 the previously undocumented
9373 event specifier and new modifiers
9375 .Va History substitution
9380 .Va history-search-*
9386 .Va toggle-literal-history
9392 Enhanced directory parsing and directory stack handling.
9401 commands and their associated
9402 shell variables, the description of
9403 .Va Directory stack substitution
9413 .Va normalize-command
9418 Negation in glob-patterns.
9420 .Va Filename substitution
9423 .Va File inquiry operators
9426 builtin which uses them.
9429 .Va Automatic, periodic and timed events
9431 scheduled events, special aliases, automatic logout and terminal locking,
9432 command timing and watching for logins and logouts.
9434 Support for the Native Language System
9436 .Va Native Language System support
9440 .Va OS variant support
9444 and system-dependent file locations (see
9448 Extensive terminal-management capabilities.
9450 .Va Terminal management
9452 New builtin commands including
9466 New variables that make useful information easily available to the shell.
9483 shell variables and the
9496 A new syntax for including useful information in the prompt string
9500 and special prompts for loops and spelling correction
9507 Read-only variables.
9509 .Va Variable substitution
9511 When a suspended command is restarted, the shell prints the directory
9512 it started in if this is different from the current directory.
9514 be misleading (i.e., wrong) as the job may have changed directories internally.
9516 Shell builtin functions are not stoppable/restartable.
9520 are also not handled gracefully when stopping is
9524 , the shell will then immediately execute
9526 This is especially noticeable if this expansion results from an
9528 It suffices to place the sequence of commands in ()'s to force it
9529 to a subshell, i.e.,
9532 Control over tty output after processes are started is primitive; perhaps
9533 this will inspire someone to work on a good virtual terminal interface.
9534 In a virtual terminal interface much more interesting things could be
9535 done with output control.
9537 Alias substitution is most often used to clumsily simulate shell procedures;
9538 shell procedures should be provided rather than aliases.
9540 Control structures should be parsed rather than being recognized as
9542 This would allow control commands to be placed anywhere,
9545 , and to be used with
9552 doesn't ignore here documents when looking for its
9555 It should be possible to use the
9557 modifiers on the output of command
9560 The screen update for lines longer than the screen width is very poor
9561 if the terminal cannot move the cursor up (i.e., terminal type
9568 don't need to be environment variables.
9570 Glob-patterns which do not use
9580 are not negated correctly.
9582 The single-command form of
9584 does output redirection even if
9585 the expression is false and the command is not executed.
9587 \fIls\-F\fR includes file identification characters when sorting filenames
9588 and does not handle control characters in filenames well.
9592 Command substitution supports multiple commands and conditions, but not
9597 Report bugs at http://bugs.gw.com/, preferably with fixes.
9599 help maintain and test tcsh, send mail to tcsh-request@mx.gw.com with the
9602 on a line by itself in the body.
9604 In 1964, DEC produced the PDP-6.
9605 The PDP-10 was a later re-implementation.
9607 was re-christened the DECsystem-10 in 1970 or so when DEC brought out the
9608 second model, the KI10.
9610 TENEX was created at Bolt, Beranek & Newman (a Cambridge, Massachusetts
9612 1972 as an experiment in demand-paged virtual memory operating systems.
9614 built a new pager for the DEC PDP-10 and created the OS to go with it.
9616 extremely successful in academia.
9618 In 1975, DEC brought out a new model of the PDP-10, the KL10; they intended to
9619 have only a version of TENEX, which they had licensed from BBN, for the new
9621 They called their version TOPS-20 (their capitalization is trademarked).
9622 A lot of TOPS-10 users (`The OPerating System for PDP-10') objected; thus DEC
9623 found themselves supporting two incompatible systems on the same hardware--but
9624 then there were 6 on the PDP-11!
9626 TENEX, and TOPS-20 to version 3, had command completion
9627 via a user-code-level subroutine library called ULTCMD.
9629 moved all that capability and more into the monitor (`kernel' for you Unix
9630 types), accessed by the COMND% JSYS (`Jump to SYStem' instruction, the
9631 supervisor call mechanism [are my IBM roots also showing?]).
9633 The creator of tcsh was impressed by this feature and several others of TENEX
9634 and TOPS-20, and created a version of csh which mimicked them.
9636 The system limits argument lists to ARG_MAX characters.
9638 The number of arguments to a command which involves filename expansion is
9639 limited to 1/6th the number of characters allowed in an argument list.
9641 Command substitutions may substitute no more characters than are allowed in
9644 To detect looping, the shell restricts the number of
9646 substitutions on a single line to 20.
9648 csh(1), emacs(1), ls(1), newgrp(1), sh(1), setpath(1), stty(1), su(1),
9649 tset(1), vi(1), x(1), access(2), execve(2), fork(2), killpg(2),
9650 pipe(2), setrlimit(2), sigvec(2), stat(2), umask(2), vfork(2), wait(2),
9651 malloc(3), setlocale(3), tty(4), a.out(5), termcap(5), environ(7),
9652 termio(7), Introduction to the C Shell
9654 This manual documents tcsh 6.20.00 (Astron) 2016-11-24.
9662 J.E. Kulp, IIASA, Laxenburg, Austria
9663 Job control and directory stack features
9665 Ken Greer, HP Labs, 1981
9666 File name completion
9668 Mike Ellis, Fairchild, 1983
9669 Command name recognition/completion
9671 Paul Placeway, Ohio State CIS Dept., 1983-1993
9672 Command line editor, prompt routines, new glob syntax and numerous fixes
9675 Karl Kleinpaste, CCI 1983-4
9676 Special aliases, directory stack extraction stuff, login/logout watch,
9677 scheduled events, and the idea of the new prompt format
9679 Rayan Zachariassen, University of Toronto, 1984
9682 builtins and numerous bug fixes, modifications
9685 Chris Kingsley, Caltech
9686 Fast storage allocator routines
9688 Chris Grevstad, TRW, 1987
9694 Christos S. Zoulas, Cornell U. EE Dept., 1987-94
9695 Ports to HPUX, SVR2 and SVR3, a SysV version of getwd.c, SHORT_STRINGS support
9696 and a new version of sh.glob.c
9698 James J Dempsey, BBN, and Paul Placeway, OSU, 1988
9701 Daniel Long, NNSC, 1988
9704 Patrick Wolfe, Kuck and Associates, Inc., 1988
9708 David C Lawrence, Rensselaer Polytechnic Institute, 1989
9710 and ambiguous completion listing
9712 Alec Wolman, DEC, 1989
9713 Newlines in the prompt
9715 Matt Landau, BBN, 1989
9718 Ray Moody, Purdue Physics, 1989
9719 Magic space bar history expansion
9721 Mordechai ????, Intel, 1989
9722 printprompt() fixes and additions
9724 Kazuhiro Honda, Dept. of Computer Science, Keio University, 1989
9725 Automatic spelling correction and
9728 Per Hedeland, Ellemtel, Sweden, 1990-
9729 Various bugfixes, improvements and manual updates
9731 Hans J. Albertsson (Sun Sweden)
9739 Interrupt handling fixes
9741 Michael Fine, Digital Equipment Corp
9742 Extended key support
9744 Eric Schnoebelen, Convex, 1990
9745 Convex support, lots of
9748 save and restore of directory stack
9750 Ron Flax, Apple, 1990
9753 Dan Oscarsson, LTH Sweden, 1990
9754 NLS support and simulated NLS support for non NLS sites, fixes
9756 Johan Widen, SICS Sweden, 1990
9762 Matt Day, Sanyo Icon, 1990
9763 POSIX termio support, SysV limit fixes
9765 Jaap Vermeulen, Sequent, 1990-91
9766 Vi mode fixes, expand-line, window change fixes, Symmetry port
9768 Martin Boyer, Institut de recherche d'Hydro-Quebec, 1991
9770 beeping options, modified the history search to search for
9771 the whole string from the beginning of the line to the cursor.
9773 Scott Krotz, Motorola, 1991
9776 David Dawes, Sydney U. Australia, Physics Dept., 1991
9777 SVR4 job control fixes
9779 Jose Sousa, Interactive Systems Corp., 1991
9786 Marc Horowitz, MIT, 1991
9787 ANSIfication fixes, new exec hashing code, imake fixes,
9790 Bruce Sterling Woodcock, sterling@netcom.com, 1991-1995
9791 ETA and Pyramid port, Makefile and lint fixes,
9794 various other portability changes and bug fixes
9797 .Va complete-word-fwd
9799 .Va complete-word-back
9801 Harry C. Pulley, 1992
9804 Andy Phillips, Mullard Space Science Lab U.K., 1992
9807 Beto Appleton, IBM Corp., 1992
9808 Walking process group fixes,
9811 POSIX file tests, POSIX SIGHUP
9813 Scott Bolte, Cray Computer Corp., 1992
9816 Kaveh R. Ghazi, Rutgers University, 1992
9817 Tek, m88k, Titan and Masscomp ports and fixes.
9818 Added autoconf support.
9820 Mark Linderman, Cornell University, 1992
9823 Mika Liljeberg, liljeber@kruuna.Helsinki.FI, 1992
9826 Tim P. Starrin, NASA Langley Research Center Operations, 1993
9829 Dave Schweisguth, Yale University, 1993-4
9830 New man page and tcsh.man2html
9832 Larry Schwimmer, Stanford University, 1993
9833 AFS and HESIOD patches
9835 Luke Mewburn, RMIT University, 1994-6
9836 Enhanced directory printing in prompt,
9842 Edward Hutchins, Silicon Graphics Inc., 1996
9845 Martin Kraemer, 1997
9846 Ported to Siemens Nixdorf EBCDIC machine
9848 Amol Deshpande, Microsoft, 1997
9849 Ported to WIN32 (Windows/95 and Windows/NT); wrote all the missing library
9850 and message catalog code to interface to Windows.
9857 Bryan Dunlap, Clayton Elwell, Karl Kleinpaste, Bob Manson, Steve Romig,
9858 Diana Smetters, Bob Sutterfield, Mark Verber, Elizabeth Zwicky and all
9859 the other people at Ohio State for suggestions and encouragement
9861 All the people on the net, for putting up with,
9862 reporting bugs in, and suggesting new additions to each and every version
9864 Richard M. Alderson III, for writing the