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