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