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