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