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