From 32424d04c2aa5f2c859ca8cac1d59bdb5349e688 Mon Sep 17 00:00:00 2001 From: CSRG Date: Sun, 14 May 1995 01:10:46 -0800 Subject: [PATCH] BSD 4_4_Lite2 development Work on file usr/share/man/cat1/cat.0 Work on file usr/share/man/cat1/chmod.0 Work on file usr/share/man/cat1/cp.0 Work on file usr/share/man/cat1/repeat.0 Work on file usr/share/man/cat1/pushd.0 Work on file usr/share/man/cat1/dirs.0 Work on file usr/share/man/cat1/suspend.0 Work on file usr/share/man/cat1/alias.0 Work on file usr/share/man/cat1/csh.0 Work on file usr/share/man/cat1/limit.0 Work on file usr/share/man/cat1/foreach.0 Work on file usr/share/man/cat1/fg.0 Work on file usr/share/man/cat1/bg.0 Work on file usr/share/man/cat1/jobs.0 Work on file usr/share/man/cat1/popd.0 Work on file usr/share/man/cat1/rehash.0 Work on file usr/share/man/cat1/history.0 Work on file usr/share/man/cat1/source.0 Work on file usr/share/man/cat1/stop.0 Work on file usr/share/man/cat1/date.0 Work on file usr/share/man/cat1/dd.0 Work on file usr/share/man/cat1/df.0 Work on file usr/share/man/cat1/echo.0 Work on file usr/share/man/cat1/hostname.0 Work on file usr/share/man/cat1/kill.0 Work on file usr/share/man/cat1/ln.0 Work on file usr/share/man/cat7/symlink.0 Work on file usr/share/man/cat1/ls.0 Work on file usr/share/man/cat1/mkdir.0 Work on file usr/share/man/cat1/mv.0 Work on file usr/share/man/cat1/pax.0 Work on file usr/share/man/cat1/ps.0 Work on file usr/share/man/cat1/pwd.0 Work on file usr/share/man/cat1/rcp.0 Work on file usr/share/man/cat1/rm.0 Work on file usr/share/man/cat8/rmail.0 Work on file usr/share/man/cat1/rmdir.0 Work on file usr/share/man/cat1/sleep.0 Work on file usr/share/man/cat1/stty.0 Work on file usr/share/man/cat8/sync.0 Work on file usr/share/man/cat1/[.0 Work on file usr/share/man/cat1/test.0 Synthesized-from: CSRG/cd3/4.4BSD-Lite2 --- usr/share/man/cat1/[.0 | 114 +++ usr/share/man/cat1/alias.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/bg.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/cat.0 | 53 ++ usr/share/man/cat1/chmod.0 | 149 ++++ usr/share/man/cat1/cp.0 | 99 +++ usr/share/man/cat1/csh.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/date.0 | 121 +++ usr/share/man/cat1/dd.0 | 185 +++++ usr/share/man/cat1/df.0 | 56 ++ usr/share/man/cat1/dirs.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/echo.0 | 26 + usr/share/man/cat1/fg.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/foreach.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/history.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/hostname.0 | 24 + usr/share/man/cat1/jobs.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/kill.0 | 66 ++ usr/share/man/cat1/limit.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/ln.0 | 52 ++ usr/share/man/cat1/ls.0 | 198 +++++ usr/share/man/cat1/mkdir.0 | 38 + usr/share/man/cat1/mv.0 | 53 ++ usr/share/man/cat1/pax.0 | 545 ++++++++++++ usr/share/man/cat1/popd.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/ps.0 | 307 +++++++ usr/share/man/cat1/pushd.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/pwd.0 | 26 + usr/share/man/cat1/rcp.0 | 65 ++ usr/share/man/cat1/rehash.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/repeat.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/rm.0 | 74 ++ usr/share/man/cat1/rmdir.0 | 32 + usr/share/man/cat1/sleep.0 | 56 ++ usr/share/man/cat1/source.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/stop.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/stty.0 | 414 ++++++++++ usr/share/man/cat1/suspend.0 | 1456 +++++++++++++++++++++++++++++++++ usr/share/man/cat1/test.0 | 114 +++ usr/share/man/cat7/symlink.0 | 198 +++++ usr/share/man/cat8/rmail.0 | 26 + usr/share/man/cat8/sync.0 | 25 + 42 files changed, 26412 insertions(+) create mode 100644 usr/share/man/cat1/[.0 create mode 100644 usr/share/man/cat1/alias.0 create mode 100644 usr/share/man/cat1/bg.0 create mode 100644 usr/share/man/cat1/cat.0 create mode 100644 usr/share/man/cat1/chmod.0 create mode 100644 usr/share/man/cat1/cp.0 create mode 100644 usr/share/man/cat1/csh.0 create mode 100644 usr/share/man/cat1/date.0 create mode 100644 usr/share/man/cat1/dd.0 create mode 100644 usr/share/man/cat1/df.0 create mode 100644 usr/share/man/cat1/dirs.0 create mode 100644 usr/share/man/cat1/echo.0 create mode 100644 usr/share/man/cat1/fg.0 create mode 100644 usr/share/man/cat1/foreach.0 create mode 100644 usr/share/man/cat1/history.0 create mode 100644 usr/share/man/cat1/hostname.0 create mode 100644 usr/share/man/cat1/jobs.0 create mode 100644 usr/share/man/cat1/kill.0 create mode 100644 usr/share/man/cat1/limit.0 create mode 100644 usr/share/man/cat1/ln.0 create mode 100644 usr/share/man/cat1/ls.0 create mode 100644 usr/share/man/cat1/mkdir.0 create mode 100644 usr/share/man/cat1/mv.0 create mode 100644 usr/share/man/cat1/pax.0 create mode 100644 usr/share/man/cat1/popd.0 create mode 100644 usr/share/man/cat1/ps.0 create mode 100644 usr/share/man/cat1/pushd.0 create mode 100644 usr/share/man/cat1/pwd.0 create mode 100644 usr/share/man/cat1/rcp.0 create mode 100644 usr/share/man/cat1/rehash.0 create mode 100644 usr/share/man/cat1/repeat.0 create mode 100644 usr/share/man/cat1/rm.0 create mode 100644 usr/share/man/cat1/rmdir.0 create mode 100644 usr/share/man/cat1/sleep.0 create mode 100644 usr/share/man/cat1/source.0 create mode 100644 usr/share/man/cat1/stop.0 create mode 100644 usr/share/man/cat1/stty.0 create mode 100644 usr/share/man/cat1/suspend.0 create mode 100644 usr/share/man/cat1/test.0 create mode 100644 usr/share/man/cat7/symlink.0 create mode 100644 usr/share/man/cat8/rmail.0 create mode 100644 usr/share/man/cat8/sync.0 diff --git a/usr/share/man/cat1/[.0 b/usr/share/man/cat1/[.0 new file mode 100644 index 0000000000..ef7df518e1 --- /dev/null +++ b/usr/share/man/cat1/[.0 @@ -0,0 +1,114 @@ +TEST(1) BSD Reference Manual TEST(1) + +NNAAMMEE + tteesstt - condition evaluation utility + +SSYYNNOOPPSSIISS + tteesstt _e_x_p_r_e_s_s_i_o_n + +DDEESSCCRRIIPPTTIIOONN + The tteesstt utility evaluates the expression and, if it evaluates to true, + returns a zero (true) exit status; otherwise it returns 1 (false). If + there is no expression, test also returns 1 (false). + + All operators and flags are separate arguments to the tteesstt utility. + + The following primaries are used to construct expression: + + --bb _f_i_l_e True if _f_i_l_e exists and is a block special file. + + --cc _f_i_l_e True if _f_i_l_e exists and is a character special file. + + --dd _f_i_l_e True if _f_i_l_e exists and is a directory. + + --ee _f_i_l_e True if _f_i_l_e exists (regardless of type). + + --ff _f_i_l_e True if _f_i_l_e exists and is a regular file. + + --gg _f_i_l_e True if _f_i_l_e exists and its set group ID flag is set. + + --hh _f_i_l_e True if _f_i_l_e exists and is a symbolic link. + + --nn _s_t_r_i_n_g True if the length of _s_t_r_i_n_g is nonzero. + + --pp _f_i_l_e True if _f_i_l_e is a named pipe (FIFO). + + --rr _f_i_l_e True if _f_i_l_e _e_x_i_s_t_s _a_n_d _i_s _r_e_a_d_a_b_l_e_. + + --ss _f_i_l_e True if _f_i_l_e exists and has a size greater than zero. + + --tt _[_f_i_l_e___d_e_s_c_r_i_p_t_o_r_] + True if the file whose file descriptor number is + _f_i_l_e___d_e_s_c_r_i_p_t_o_r (default 1) is open and is associated with + a terminal. + + --uu _f_i_l_e True if _f_i_l_e exists and its set user ID flag is set. + + --ww _f_i_l_e True if _f_i_l_e exists and is writable. True indicates only + that the write flag is on. The file is not writable on a + read-only file system even if this test indicates true. + + --xx _f_i_l_e True if _f_i_l_e exists and is executable. True indicates only + that the execute flag is on. If _f_i_l_e is a directory, true + indicates that _f_i_l_e can be searched. + + --zz _s_t_r_i_n_g True if the length of _s_t_r_i_n_g is zero. + + _s_t_r_i_n_g True if _s_t_r_i_n_g is not the null string. + + _s_1 == _s_2 True if the strings _s_1 and _s_2 are identical. + + _s_1 !!== _s_2 True if the strings _s_1 and _s_2 are not identical. + + _n_1 --eeqq _n_2 True if the integers _n_1 and _n_2 are algebraically equal. + + _n_1 --nnee _n_2 True if the integers _n_1 and _n_2 are not algebraically equal. + + + _n_1 --ggtt _n_2 True if the integer _n_1 is algebraically greater than the + integer _n_2. + + _n_1 --ggee _n_2 True if the integer _n_1 is algebraically greater than or + equal to the integer _n_2. + + _n_1 --lltt _n_2 True if the integer _n_1 is algebraically less than the inte- + ger _n_2. + + _n_1 --llee _n_2 True if the integer _n_1 is algebraically less than or equal + to the integer _n_2. + + These primaries can be combined with the following operators: + + !! _e_x_p_r_e_s_s_i_o_n True if _e_x_p_r_e_s_s_i_o_n is false. + + _e_x_p_r_e_s_s_i_o_n_1 --aa _e_x_p_r_e_s_s_i_o_n_2 + True if both _e_x_p_r_e_s_s_i_o_n_1 and _e_x_p_r_e_s_s_i_o_n_2 are true. + + _e_x_p_r_e_s_s_i_o_n_1 --oo _e_x_p_r_e_s_s_i_o_n_2 + True if either _e_x_p_r_e_s_s_i_o_n_1 or _e_x_p_r_e_s_s_i_o_n_2 are true. + + ((_e_x_p_r_e_s_s_i_o_n)) True if expression is true. + + The --aa operator has higher precedence than the --oo operator. + +GGRRAAMMMMAARR AAMMBBIIGGUUIITTYY + The tteesstt grammar is inherently ambiguous. In order to assure a degree of + consistency, the cases described in the IEEE Std1003.2 (``POSIX''), sec- + tion D11.2/4.62.4, standard are evaluated consistently according to the + rules specified in the standards document. All other cases are subject + to the ambiguity in the command semantics. + +RREETTUURRNN VVAALLUUEESS + The tteesstt utility exits with one of the following values: + + 0 expression evaluated to true. + + 1 expression evaluated to false or expression was missing. + + >1 An error occurred. + +SSTTAANNDDAARRDDSS + The tteesstt function is expected to be IEEE Std1003.2 (``POSIX'') compati- + ble. + +4.4BSD May 31, 1993 2 diff --git a/usr/share/man/cat1/alias.0 b/usr/share/man/cat1/alias.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/alias.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/bg.0 b/usr/share/man/cat1/bg.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/bg.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/cat.0 b/usr/share/man/cat1/cat.0 new file mode 100644 index 0000000000..644fff2e5e --- /dev/null +++ b/usr/share/man/cat1/cat.0 @@ -0,0 +1,53 @@ +CAT(1) BSD Reference Manual CAT(1) + +NNAAMMEE + ccaatt - concatenate and print files + +SSYYNNOOPPSSIISS + ccaatt [--bbeennssttuuvv] [--] [_f_i_l_e _._._.] + +DDEESSCCRRIIPPTTIIOONN + The ccaatt utility reads files sequentially, writing them to the standard + output. The _f_i_l_e operands are processed in command line order. A single + dash represents the standard input. + + The options are as follows: + + --bb Implies the --nn option but doesn't number blank lines. + + --ee Implies the --vv option, and displays a dollar sign (`$') at the + end of each line as well. + + --nn Number the output lines, starting at 1. + + --ss Squeeze multiple adjacent empty lines, causing the output to be + single spaced. + + --tt Implies the --vv option, and displays tab characters as `^I' as + well. + + --uu The --uu option guarantees that the output is unbuffered. + + --vv Displays non-printing characters so they are visible. Control + characters print as `^X' for control-X; the delete character (oc- + tal 0177) prints as `^?' Non-ascii characters (with the high bit + set) are printed as `M-' (for meta) followed by the character for + the low 7 bits. + + The ccaatt utility exits 0 on success, and >0 if an error occurs. + +BBUUGGSS + Because of the shell language mechanism used to perform output redirec- + tion, the command ``cat file1 file 2 > file1'' will cause the original + data in file1 to be destroyed! + +SSEEEE AALLSSOO + head(1), more(1), pr(1), tail(1), vis(1) + + Rob Pike, "UNIX Style, or cat -v Considered Harmful", _U_S_E_N_I_X _S_u_m_m_e_r + _C_o_n_f_e_r_e_n_c_e _P_r_o_c_e_e_d_i_n_g_s, 1983. + +HHIISSTTOORRYY + A ccaatt command appeared in Version 6 AT&T UNIX. + +3rd Berkeley Distribution May 2, 1995 1 diff --git a/usr/share/man/cat1/chmod.0 b/usr/share/man/cat1/chmod.0 new file mode 100644 index 0000000000..96f8e990ef --- /dev/null +++ b/usr/share/man/cat1/chmod.0 @@ -0,0 +1,149 @@ +CHMOD(1) BSD Reference Manual CHMOD(1) + +NNAAMMEE + cchhmmoodd - change file modes + +SSYYNNOOPPSSIISS + cchhmmoodd [--RR [--HH | --LL | --PP]] _m_o_d_e _f_i_l_e _._._. + +DDEESSCCRRIIPPTTIIOONN + The cchhmmoodd utility modifies the file mode bits of the listed files as + specified by the _m_o_d_e operand. + + The options are as follows: + + --HH If the --RR option is specified, symbolic links on the command line + are followed. (Symbolic links encountered in the tree traversal + are not followed.) + + --LL If the --RR option is specified, all symbolic links are followed. + + --PP If the --RR option is specified, no symbolic links are followed. + + --RR Change the modes of the file hierarchies rooted in the files in- + stead of just the files themselves. + + Symbolic links do not have modes, so unless the --HH or --LL option is set, + cchhmmoodd on a symbolic link always succeeds and has no effect. The --HH, --LL + and --PP options are ignored unless the --RR option is specified. In addi- + tion, these options override each other and the command's actions are de- + termined by the last one specified. + + Only the owner of a file or the super-user is permitted to change the + mode of a file. + + The cchhmmoodd utility exits 0 on success, and >0 if an error occurs. + +MMOODDEESS + Modes may be absolute or symbolic. An absolute mode is an octal number + constructed by _o_r_-_i_n_g the following values: + + 4000 set-user-ID-on-execution + 2000 set-group-ID-on-execution + 1000 sticky bit, see chmod(2) + 0400 read by owner + 0200 write by owner + 0100 execute (or search for directories) by owner + 0070 read, write, execute/search by group + 0007 read, write, execute/search by others + + The read, write, and execute/search values for group and others are en- + coded as described for owner. + + The symbolic mode is described by the following grammar: + + mode ::= clause [, clause ...] + clause ::= [who ...] [action ...] last_action + action ::= op [perm ...] + last_action ::= op [perm ...] + who ::= a | u | g | o + op ::= + | - | = + perm ::= r | s | t | w | x | X | u | g | o + + The _w_h_o symbols ``u'', ``g'', and ``o'' specify the user, group, and oth- + er parts of the mode bits, respectively. The _w_h_o symbol ``a'' is equiva- + lent to ``ugo''. + + The _p_e_r_m symbols represent the portions of the mode bits as follows: + + r The read bits. + s The set-user-ID-on-execution and set-group-ID-on-execution + bits. + t The sticky bit. + w The write bits. + x The execute/search bits. + X The execute/search bits if the file is a directory or any + of the execute/search bits are set in the original (unmodi- + fied) mode. Operations with the _p_e_r_m symbol ``X'' are only + meaningful in conjunction with the _o_p symbol ``+'', and are + ignored in all other cases. + u The user permission bits in the mode of the original file. + g The group permission bits in the mode of the original file. + o The other permission bits in the mode of the original file. + + The _o_p symbols represent the operation performed, as follows: + + + If no value is supplied for _p_e_r_m, the ``+'' operation has no ef- + fect. If no value is supplied for _w_h_o, each permission bit speci- + fied in _p_e_r_m, for which the corresponding bit in the file mode cre- + ation mask is clear, is set. Otherwise, the mode bits represented + by the specified _w_h_o and _p_e_r_m values are set. + + - If no value is supplied for _p_e_r_m, the ``-'' operation has no ef- + fect. If no value is supplied for _w_h_o, each permission bit speci- + fied in _p_e_r_m, for which the corresponding bit in the file mode cre- + ation mask is clear, is cleared. Otherwise, the mode bits repre- + sented by the specified _w_h_o and _p_e_r_m values are cleared. + + = The mode bits specified by the _w_h_o value are cleared, or, if no who + value is specified, the owner, group and other mode bits are + cleared. Then, if no value is supplied for _w_h_o, each permission + bit specified in _p_e_r_m, for which the corresponding bit in the file + mode creation mask is clear, is set. Otherwise, the mode bits rep- + resented by the specified _w_h_o and _p_e_r_m values are set. + + Each _c_l_a_u_s_e specifies one or more operations to be performed on the mode + bits, and each operation is applied to the mode bits in the order speci- + fied. + + Operations upon the other permissions only (specified by the symbol ``o'' + by itself), in combination with the _p_e_r_m symbols ``s'' or ``t'', are ig- + nored. + +EEXXAAMMPPLLEESS + 644 make a file readable by anyone and writable by the owner + only. + + go-w deny write permission to group and others. + + =rw,+X set the read and write permissions to the usual defaults, + but retain any execute permissions that are currently set. + + +X make a directory or file searchable/executable by everyone + if it is already searchable/executable by anyone. + + 755 + u=rwx,go=rx + u=rwx,go=u-w make a file readable/executable by everyone and writable by + the owner only. + + + + go= clear all mode bits for group and others. + + g=u-w set the group bits equal to the user bits, but clear the + group write bit. + +BBUUGGSS + There's no _p_e_r_m option for the naughty bits. + +SSEEEE AALLSSOO + install(1), chmod(2), stat(2), umask(2), fts(3), setmode(3), + symlink(7), chown(8) + +SSTTAANNDDAARRDDSS + The cchhmmoodd utility is expected to be POSIX 1003.2 compatible with the ex- + ception of the _p_e_r_m symbols ``t'' and ``X'' which are not included in + that standard. + +4.4BSD March 31, 1994 3 diff --git a/usr/share/man/cat1/cp.0 b/usr/share/man/cat1/cp.0 new file mode 100644 index 0000000000..3852ccb38a --- /dev/null +++ b/usr/share/man/cat1/cp.0 @@ -0,0 +1,99 @@ +CP(1) BSD Reference Manual CP(1) + +NNAAMMEE + ccpp - copy files + +SSYYNNOOPPSSIISS + ccpp [--RR [--HH | --LL | --PP]] [--ffiipp] _s_o_u_r_c_e___f_i_l_e _t_a_r_g_e_t___f_i_l_e + ccpp [--RR [--HH | --LL | --PP]] [--ffiipp] _s_o_u_r_c_e___f_i_l_e _._._. _t_a_r_g_e_t___d_i_r_e_c_t_o_r_y + +DDEESSCCRRIIPPTTIIOONN + In the first synopsis form, the ccpp utility copies the contents of the + _s_o_u_r_c_e___f_i_l_e to the _t_a_r_g_e_t___f_i_l_e. In the second synopsis form, the contents + of each named _s_o_u_r_c_e___f_i_l_e is copied to the destination _t_a_r_g_e_t___d_i_r_e_c_t_o_r_y. + The names of the files themselves are not changed. If ccpp detects an at- + tempt to copy a file to itself, the copy will fail. + + The following options are available: + + --HH If the --RR option is specified, symbolic links on the command line + are followed. (Symbolic links encountered in the tree traversal + are not followed.) + + --LL If the --RR option is specified, all symbolic links are followed. + + --PP If the --RR option is specified, no symbolic links are followed. + + --RR If _s_o_u_r_c_e___f_i_l_e designates a directory, ccpp copies the directory and + the entire subtree connected at that point. This option also caus- + es symbolic links to be copied, rather than indirected through, and + for ccpp to create special files rather than copying them as normal + files. Created directories have the same mode as the corresponding + source directory, unmodified by the process' umask. + + --ff For each existing destination pathname, remove it and create a new + file, without prompting for confirmation regardless of its permis- + sions. (The --ii option is ignored if the --ff option is specified.) + + --ii Causes ccpp to write a prompt to the standard error output before + copying a file that would overwrite an existing file. If the re- + sponse from the standard input begins with the character `y', the + file copy is attempted. + + --pp Causes ccpp to preserve in the copy as many of the modification time, + access time, file flags, file mode, user ID, and group ID as al- + lowed by permissions. + + If the user ID and group ID cannot be preserved, no error message + is displayed and the exit value is not altered. + + If the source file has its set user ID bit on and the user ID can- + not be preserved, the set user ID bit is not preserved in the + copy's permissions. If the source file has its set group ID bit on + and the group ID cannot be preserved, the set group ID bit is not + preserved in the copy's permissions. If the source file has both + its set user ID and set group ID bits on, and either the user ID or + group ID cannot be preserved, neither the set user ID or set group + ID bits are preserved in the copy's permissions. + + For each destination file that already exists, its contents are overwrit- + ten if permissions allow, but its mode, user ID, and group ID are un- + changed. + + In the second synopsis form, _t_a_r_g_e_t___d_i_r_e_c_t_o_r_y must exist unless there is + only one named _s_o_u_r_c_e___f_i_l_e which is a directory and the --RR flag is speci- + fied. + + If the destination file does not exist, the mode of the source file is + used as modified by the file mode creation mask (uummaasskk, see csh(1)). If + the source file has its set user ID bit on, that bit is removed unless + both the source file and the destination file are owned by the same user. + If the source file has its set group ID bit on, that bit is removed un- + less both the source file and the destination file are in the same group + and the user is a member of that group. If both the set user ID and set + group ID bits are set, all of the above conditions must be fulfilled or + both bits are removed. + + Appropriate permissions are required for file creation or overwriting. + + Symbolic links are always followed unless the --RR flag is set, in which + case symbolic links are not followed, by default. The --HH or --LL flags (in + conjunction with the --RR flag) cause symbolic links to be followed as de- + scribed above. The --HH, --LL and --PP options are ignored unless the --RR op- + tion is specified. In addition, these options override each other and + the command's actions are determined by the last one specified. + + CCpp exits 0 on success, >0 if an error occurred. + +CCOOMMPPAATTIIBBIILLIITTYY + Historic versions of the ccpp utility had a --rr option. This implementation + supports that option, however, its use is strongly discouraged, as it + does not correctly copy special files, symbolic links or fifo's. + +SSEEEE AALLSSOO + mv(1), rcp(1), umask(2), fts(3), symlink(7) + +HHIISSTTOORRYY + The ccpp command is expected to be IEEE Std1003.2 (``POSIX'') compatible. + +4th Berkeley Distribution April 18, 1994 2 diff --git a/usr/share/man/cat1/csh.0 b/usr/share/man/cat1/csh.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/csh.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/date.0 b/usr/share/man/cat1/date.0 new file mode 100644 index 0000000000..4c4b9e7508 --- /dev/null +++ b/usr/share/man/cat1/date.0 @@ -0,0 +1,121 @@ +DATE(1) BSD Reference Manual DATE(1) + +NNAAMMEE + ddaattee - display or set date and time + +SSYYNNOOPPSSIISS + ddaattee [--dd _d_s_t] [--rr _s_e_c_o_n_d_s] [--tt _m_i_n_u_t_e_s___w_e_s_t] [--nnuu] [++_f_o_r_m_a_t] + [[yy[mm[dd[hh]]]]mm[.ss]] + +DDEESSCCRRIIPPTTIIOONN + DDaattee displays the current date and time when invoked without arguments. + Providing arguments will format the date and time in a user-defined way + or set the date. Only the superuser may set the date. + + The options are as follows: + + --dd Set the kernel's value for daylight savings time. If _d_s_t is non- + zero, future calls to gettimeofday(2) will return a non-zero + `tz_dsttime'. + + --nn The utility timed(8) is used to synchronize the clocks on groups + of machines. By default, if timed is running, ddaattee will set the + time on all of the machines in the local group. The --nn option + stops ddaattee from setting the time for other than the current ma- + chine. + + --rr Print out the date and time in _s_e_c_o_n_d_s from the Epoch. + + --tt Set the kernel's value for minutes west of GMT. _M_i_n_u_t_e_s___w_e_s_t + specifies the number of minutes returned in `tz_minuteswest' by + future calls to gettimeofday(2). + + --uu Display or set the date in UCT (universal) time. + + An operand with a leading plus (``+'') sign signals a user-defined format + string which specifies the format in which to display the date and time. + The format string may contain any of the conversion specifications de- + scribed in the strftime(3) manual page, as well as any arbitrary text. A + character is always output after the characters specified by + the format string. The format string for the default display is: + + ``%a %b %e %H:%M:%S %Z %Y''. + + If an operand does not have a leading plus sign, it is interpreted as a + value for setting the system's notion of the current date and time. The + canonical representation for setting the date and time is: + + _y_y Year in abbreviated form (.e.g 89 for 1989). + _m_m Numeric month. A number from 1 to 12. + _d_d Day, a number from 1 to 31. + _h_h Hour, a number from 0 to 23. + _m_m Minutes, a number from 0 to 59. + _._s_s Seconds, a number from 0 to 61 (59 plus a a maximum of two + leap seconds). + + Everything but the minutes is optional. + + Time changes for Daylight Saving and Standard time and leap seconds and + years are handled automatically. + +EEXXAAMMPPLLEESS + The command: + + date ``+DATE: %m/%d/%y%nTIME: %H:%M:%S'' + + + will display: + + DATE: 11/21/87 + TIME: 13:36:16 + + The command: + + date 8506131627 + + sets the date to ``June 13, 1985, 4:27 PM''. + + The command: + + date 1432 + + sets the time to 2:32 PM, without modifying the date. + +EENNVVIIRROONNMMEENNTTAALL VVAARRIIAABBLLEESS + The following environment variables affect the execution of ddaattee: + + TZ + The timezone to use when displaying dates. See environ(7) for more in- + formation. + +FFIILLEESS + /var/log/wtmp A record of date resets and time changes. + /var/log/messages A record of the user setting the time. + +SSEEEE AALLSSOO + gettimeofday(2), strftime(3), utmp(5), timed(8) + + R. Gusella, and S. Zatti, _T_S_P_: _T_h_e _T_i_m_e _S_y_n_c_h_r_o_n_i_z_a_t_i_o_n _P_r_o_t_o_c_o_l _f_o_r _U_N_I_X + _4_._3_B_S_D. + +DDIIAAGGNNOOSSTTIICCSS + Exit status is 0 on success, 1 if unable to set the date, and 2 if able + to set the local date, but unable to set it globally. + + Occasionally, when timed synchronizes the time on many hosts, the setting + of a new time value may require more than a few seconds. On these occa- + sions, ddaattee prints: `Network time being set'. The message `Communication + error with timed' occurs when the communication between ddaattee and timed + fails. + +BBUUGGSS + The system attempts to keep the date in a format closely compatible with + VMS. VMS, however, uses local time (rather than GMT) and does not under- + stand daylight-savings time. Thus, if you use both UNIX and VMS, VMS + will be running on GMT. + +SSTTAANNDDAARRDDSS + The ddaattee command is expected to be compatible with IEEE Std1003.2 + (``POSIX''). + +4.4BSD April 28, 1995 2 diff --git a/usr/share/man/cat1/dd.0 b/usr/share/man/cat1/dd.0 new file mode 100644 index 0000000000..d1c937bf2a --- /dev/null +++ b/usr/share/man/cat1/dd.0 @@ -0,0 +1,185 @@ +DD(1) BSD Reference Manual DD(1) + +NNAAMMEE + dddd - convert and copy a file + +SSYYNNOOPPSSIISS + dddd [operands ...] + +DDEESSCCRRIIPPTTIIOONN + The dddd utility copies the standard input to the standard output. Input + data is read and written in 512-byte blocks. If input reads are short, + input from multiple reads are aggregated to form the output block. When + finished, dddd displays the number of complete and partial input and output + blocks and truncated input records to the standard error output. + + The following operands are available: + + bbss==_n Set both input and output block size, superseding the iibbss and + oobbss operands. If no conversion values other than nnooeerrrroorr, + nnoottrruunncc or ssyynncc are specified, then each input block is copied + to the output as a single block without any aggregation of short + blocks. + + ccbbss==_n Set the conversion record size to _n bytes. The conversion + record size is required by the record oriented conversion val- + ues. + + ccoouunntt==_n Copy only _n input blocks. + + ffiilleess==_n Copy _n input files before terminating. This operand is only ap- + plicable when the input device is a tape. + + iibbss==_n Set the input block size to _n bytes instead of the default 512. + + iiff==_f_i_l_e Read input from _f_i_l_e instead of the standard input. + + oobbss==_n Set the output block size to _n bytes instead of the default 512. + + ooff==_f_i_l_e Write output to _f_i_l_e instead of the standard output. Any regu- + lar output file is truncated unless the nnoottrruunncc conversion value + is specified. If an initial portion of the output file is + skipped (see the sseeeekk operand) the output file is truncated at + that point. + + sseeeekk==_n Seek _n blocks from the beginning of the output before copying. + On non-tape devices, a lseek(2) operation is used. Otherwise, + existing blocks are read and the data discarded. If the user + does not have read permission for the tape, it is positioned us- + ing the tape ioctl(2) function calls. If the seek operation is + past the end of file, space from the current end of file to the + specified offset is filled with blocks of NUL bytes. + + sskkiipp==_n Skip _n blocks from the beginning of the input before copying. + On input which supports seeks, a lseek(2) operation is used. + Otherwise, input data is read and discarded. For pipes, the + correct number of bytes is read. For all other devices, the + correct number of blocks is read without distinguishing between + a partial or complete block being read. + + ccoonnvv== vvaalluuee[, vvaalluuee ......] + Where vvaalluuee is one of the symbols from the following list. + + aasscciiii, oollddaasscciiii + The same as the uunnbblloocckk value except that characters + are translated from ECBDIC to ASCII before the records + are converted. (These values imply uunnbblloocckk if the + operand ccbbss is also specified.) There are two conver- + sion maps for ASCII. The value aasscciiii specifies the rec- + ommended one which is compatible with System V. The + value oollddaasscciiii specifies the one used in historic AT&T + and pre-4.3BSD-reno systems. + + bblloocckk Treats the input as a sequence of newline or end-of- + file terminated variable length records independent of + input and output block boundaries. Any trailing new- + line character is discarded. Each input record is con- + verted to a fixed length output record where the length + is specified by the ccbbss operand. Input records shorter + than the conversion record size are padded with spaces. + Input records longer than the conversion record size + are truncated. The number of truncated input records, + if any, are reported to the standard error output at + the completion of the copy. + + eebbccddiicc, iibbmm, oollddeebbccddiicc, oollddiibbmm + The same as the bblloocckk value except that characters are + translated from ASCII to EBCDIC after the records are + converted. (These values imply bblloocckk if the operand + ccbbss is also specified.) There are four conversion maps + for EBCDIC. The value eebbccddiicc specifies the recommended + one which is compatible with AT&T System V UNIX. The + value iibbmm is a slightly different mapping, which is + compatible with the AT&T System V UNIX iibbmm value. The + values oollddeebbccddiicc and oollddiibbmm are maps used in historic + AT&T and pre-4.3BSD-reno systems. + + llccaassee Transform uppercase characters into lowercase charac- + ters. + + nnooeerrrroorr Do not stop processing on an input error. When an in- + put error occurs, a diagnostic message followed by the + current input and output block counts will be written + to the standard error output in the same format as the + standard completion message. If the ssyynncc conversion is + also specified, any missing input data will be replaced + with NUL bytes (or with spaces if a block oriented con- + version value was specified) and processed as a normal + input buffer. If the ssyynncc conversion is not specified, + the input block is omitted from the output. On input + files which are not tapes or pipes, the file offset + will be positioned past the block in which the error + occurred using lseek(2). + + nnoottrruunncc Do not truncate the output file. This will preserve + any blocks in the output file not explicitly written by + dddd. The nnoottrruunncc value is not supported for tapes. + + oossyynncc Pad the final output block to the full output block + size. If the input file is not a multiple of the out- + put block size after conversion, this conversion forces + the final output block to be the same size as preceding + blocks for use on devices that require regularly sized + blocks to be written. This option is incompatible with + use of the bbss==_n block size specification. + + sswwaabb Swap every pair of input bytes. If an input buffer has + an odd number of bytes, the last byte will be ignored + during swapping. + + ssyynncc Pad every input block to the input buffer size. Spaces + are used for pad bytes if a block oriented conversion + + value is specified, otherwise NUL bytes are used. + + uuccaassee Transform lowercase characters into uppercase charac- + ters. + + uunnbblloocckk Treats the input as a sequence of fixed length records + independent of input and output block boundaries. The + length of the input records is specified by the ccbbss + operand. Any trailing space characters are discarded + and a newline character is appended. + + Where sizes are specified, a decimal number of bytes is expected. If the + number ends with a ``b'', ``k'', ``m'' or ``w'', the number is multiplied + by 512, 1024 (1K), 1048576 (1M) or the number of bytes in an integer, re- + spectively. Two or more numbers may be separated by an ``x'' to indicate + a product. + + When finished, dddd displays the number of complete and partial input and + output blocks, truncated input records and odd-length byte-swapping + blocks to the standard error output. A partial input block is one where + less than the input block size was read. A partial output block is one + where less than the output block size was written. Partial output blocks + to tape devices are considered fatal errors. Otherwise, the rest of the + block will be written. Partial output blocks to character devices will + produce a warning message. A truncated input block is one where a vari- + able length record oriented conversion value was specified and the input + line was too long to fit in the conversion record or was not newline ter- + minated. + + Normally, data resulting from input or conversion or both are aggregated + into output blocks of the specified size. After the end of input is + reached, any remaining output is written as a block. This means that the + final output block may be shorter than the output block size. + + If dddd receives a SIGINFO (see the ``status'' argument for stty(1)) sig- + nal, the current input and output block counts will be written to the + standard error output in the same format as the standard completion mes- + sage. If dddd receives a SIGINT signal, the current input and output block + counts will be written to the standard error output in the same format as + the standard completion message and dddd will exit. + + The dddd utility exits 0 on success and >0 if an error occurred. + +SSEEEE AALLSSOO + cp(1), mt(1), tr(1) + +SSTTAANNDDAARRDDSS + The dddd utility is expected to be a superset of the IEEE Std1003.2 + (``POSIX'') standard. The ffiilleess operand and the aasscciiii, eebbccddiicc, iibbmm, + oollddaasscciiii, oollddeebbccddiicc and oollddiibbmm values are extensions to the POSIX stan- + dard. + +4.4BSD January 13, 1994 3 diff --git a/usr/share/man/cat1/df.0 b/usr/share/man/cat1/df.0 new file mode 100644 index 0000000000..41706c0405 --- /dev/null +++ b/usr/share/man/cat1/df.0 @@ -0,0 +1,56 @@ +DF(1) BSD Reference Manual DF(1) + +NNAAMMEE + ddff - display free disk space + +SSYYNNOOPPSSIISS + ddff [--iinn] [--tt _t_y_p_e] [_f_i_l_e | _f_i_l_e_s_y_s_t_e_m _._._.] + +DDEESSCCRRIIPPTTIIOONN + DDff displays statistics about the amount of free disk space on the speci- + fied _f_i_l_e_s_y_s_t_e_m or on the filesystem of which _f_i_l_e is a part. Values are + displayed in 512-byte per block block counts. If neither a file or a + filesystem operand is specified, statistics for all mounted filesystems + are displayed (subject to the --tt option below). + + The following options are available: + + --ii Include statistics on the number of free inodes. + + --nn Print out the previously obtained statistics from the filesys- + tems. This option should be used if it is possible that one or + more filesystems are in a state such that they will not be able + to provide statistics without a long delay. When this option is + specified, ddff will not request new statistics from the filesys- + tems, but will respond with the possibly stale statistics that + were previously obtained. + + --tt Only print out statistics for filesystems of the specified types. + More than one type may be specified in a comma separated list. + The list of filesystem types can be prefixed with ``no'' to spec- + ify the filesystem types for which action should _n_o_t be taken. + For example, the ddff command: + + df -t nonfs,mfs + + lists all filesystems except those of type NFS and MFS. The + sysctl(8) command can be used to find out the types of filesys- + tems that are available on the system: + + sysctl vfs + +EENNVVIIRROONNMMEENNTTAALL VVAARRIIAABBLLEESS + BLOCKSIZE If the environmental variable BLOCKSIZE is set, the block + counts will be displayed in units of that size block. + +BBUUGGSS + The --nn and --tt flags are ignored if a file or filesystem is specified. + +SSEEEE AALLSSOO + quota(1), statfs(2), fstatfs(2), getfsstat(2), getmntinfo(3), + fstab(5), mount(8), quot(8), sysctl(8) + +HHIISSTTOORRYY + A ddff command appeared in Version 6 AT&T UNIX. + +4th Berkeley Distribution May 8, 1995 1 diff --git a/usr/share/man/cat1/dirs.0 b/usr/share/man/cat1/dirs.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/dirs.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/echo.0 b/usr/share/man/cat1/echo.0 new file mode 100644 index 0000000000..6c671fce14 --- /dev/null +++ b/usr/share/man/cat1/echo.0 @@ -0,0 +1,26 @@ +ECHO(1) BSD Reference Manual ECHO(1) + +NNAAMMEE + eecchhoo - write arguments to the standard output + +SSYYNNOOPPSSIISS + eecchhoo [--nn] [string ...] + +DDEESSCCRRIIPPTTIIOONN + The eecchhoo utility writes any specified operands, separated by single blank + (`` '') characters and followed by a newline (``\n'') character, to the + standard output. + + The following option is available: + + --nn Do not print the trailing newline character. + + The eecchhoo utility exits 0 on success, and >0 if an error occurs. + +SSEEEE AALLSSOO + printf(1) + +SSTTAANNDDAARRDDSS + The eecchhoo utility is expected to be IEEE Std1003.2 (``POSIX'') compatible. + +4.4BSD July 22, 1993 1 diff --git a/usr/share/man/cat1/fg.0 b/usr/share/man/cat1/fg.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/fg.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/foreach.0 b/usr/share/man/cat1/foreach.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/foreach.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/history.0 b/usr/share/man/cat1/history.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/history.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/hostname.0 b/usr/share/man/cat1/hostname.0 new file mode 100644 index 0000000000..f83217269d --- /dev/null +++ b/usr/share/man/cat1/hostname.0 @@ -0,0 +1,24 @@ +HOSTNAME(1) BSD Reference Manual HOSTNAME(1) + +NNAAMMEE + hhoossttnnaammee - set or print name of current host system + +SSYYNNOOPPSSIISS + hhoossttnnaammee [--ss] [_n_a_m_e_-_o_f_-_h_o_s_t] + +DDEESSCCRRIIPPTTIIOONN + HHoossttnnaammee prints the name of the current host. The super-user can set the + hostname by supplying an argument; this is usually done in the network + initialization script _/_e_t_c_/_n_e_t_s_t_a_r_t, normally run at boot time. + + Options: + + --ss Trims off any domain information from the printed name. + +SSEEEE AALLSSOO + gethostname(2), sethostname(2) + +HHIISSTTOORRYY + The hhoossttnnaammee command appeared in 4.2BSD. + +4.2 Berkeley Distribution April 28, 1995 1 diff --git a/usr/share/man/cat1/jobs.0 b/usr/share/man/cat1/jobs.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/jobs.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/kill.0 b/usr/share/man/cat1/kill.0 new file mode 100644 index 0000000000..92b9a8dae3 --- /dev/null +++ b/usr/share/man/cat1/kill.0 @@ -0,0 +1,66 @@ +KILL(1) BSD Reference Manual KILL(1) + +NNAAMMEE + kkiillll - terminate or signal a process + +SSYYNNOOPPSSIISS + kkiillll [--ss _s_i_g_n_a_l___n_a_m_e] _p_i_d ... + kkiillll --ll [_e_x_i_t___s_t_a_t_u_s] + kkiillll --ssiiggnnaall__nnaammee _p_i_d ... + kkiillll --ssiiggnnaall__nnuummbbeerr _p_i_d ... + +DDEESSCCRRIIPPTTIIOONN + The kill utility sends a signal to the processes specified by the pid + operand(s). + + Only the super-user may send signals to other users' processes. + + The options are as follows: + + --ss _s_i_g_n_a_l___n_a_m_e + A symbolic signal name specifying the signal to be sent instead + of the default TERM. + + --ll [_e_x_i_t___s_t_a_t_u_s] + If no operand is given, list the signal names; otherwise, write + the signal name corresponding to _e_x_i_t___s_t_a_t_u_s. + + --ssiiggnnaall__nnaammee + A symbolic signal name specifying the signal to be sent instead + of the default TERM. + + --ssiiggnnaall__nnuummbbeerr + A non-negative decimal integer, specifying the signal to be sent + instead of the default TERM. + + The following pids have special meanings: + -1 If superuser, broadcast the signal to all processes; otherwise + broadcast to all processes belonging to the user. + + Some of the more commonly used signals: + 1 HUP (hang up) + 2 INT (interrupt) + 3 QUIT (quit) + 6 ABRT (abort) + 9 KILL (non-catchable, non-ignorable kill) + 14 ALRM (alarm clock) + 15 TERM (software termination signal) + + KKiillll is a built-in to csh(1); it allows job specifiers of the form + ``%...'' as arguments so process id's are not as often used as kkiillll argu- + ments. See csh(1) for details. + +SSEEEE AALLSSOO + csh(1), ps(1), kill(2), sigvec(2) + +SSTTAANNDDAARRDDSS + The kkiillll function is expected to be IEEE Std1003.2 (``POSIX'') compati- + ble. + +HHIISSTTOORRYY + A kkiillll command appeared in Version 6 AT&T UNIX. + +BBUUGGSS + A replacement for the command ``kill 0'' for csh(1) users should be pro- + vided. + diff --git a/usr/share/man/cat1/limit.0 b/usr/share/man/cat1/limit.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/limit.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/ln.0 b/usr/share/man/cat1/ln.0 new file mode 100644 index 0000000000..934bc2cf43 --- /dev/null +++ b/usr/share/man/cat1/ln.0 @@ -0,0 +1,52 @@ +LN(1) BSD Reference Manual LN(1) + +NNAAMMEE + llnn - make links + +SSYYNNOOPPSSIISS + llnn [--ffss] _s_o_u_r_c_e___f_i_l_e [target_file] + llnn [--ffss] _s_o_u_r_c_e___f_i_l_e _._._. [target_dir] + +DDEESSCCRRIIPPTTIIOONN + The llnn utility creates a new directory entry (linked file) which has the + same modes as the original file. It is useful for maintaining multiple + copies of a file in many places at once without using up storage for the + ``copies''; instead, a link ``points'' to the original copy. There are + two types of links; hard links and symbolic links. How a link ``points'' + to a file is one of the differences between a hard or symbolic link. + + The options are as follows: + + --ff Unlink any already existing file, permitting the link to occur. + + --ss Create a symbolic link. + + By default llnn makes _h_a_r_d links. A hard link to a file is indistinguish- + able from the original directory entry; any changes to a file are effec- + tive independent of the name used to reference the file. Hard links may + not normally refer to directories and may not span file systems. + + A symbolic link contains the name of the file to which it is linked. The + referenced file is used when an open(2) operation is performed on the + link. A stat(2) on a symbolic link will return the linked-to file; an + lstat(2) must be done to obtain information about the link. The read- + link(2) call may be used to read the contents of a symbolic link. Sym- + bolic links may span file systems and may refer to directories. + + Given one or two arguments, llnn creates a link to an existing file + _s_o_u_r_c_e___f_i_l_e. If _t_a_r_g_e_t___f_i_l_e is given, the link has that name; _t_a_r_g_e_t___f_i_l_e + may also be a directory in which to place the link; otherwise it is + placed in the current directory. If only the directory is specified, the + link will be made to the last component of _s_o_u_r_c_e___f_i_l_e. + + Given more than two arguments, llnn makes links in _t_a_r_g_e_t___d_i_r to all the + named source files. The links made will have the same name as the files + being linked to. + +SSEEEE AALLSSOO + link(2), lstat(2), readlink(2), stat(2), symlink(2), symlink(7) + +HHIISSTTOORRYY + A llnn command appeared in Version 6 AT&T UNIX. + +4th Berkeley Distribution December 30, 1993 1 diff --git a/usr/share/man/cat1/ls.0 b/usr/share/man/cat1/ls.0 new file mode 100644 index 0000000000..63fd4b3cf5 --- /dev/null +++ b/usr/share/man/cat1/ls.0 @@ -0,0 +1,198 @@ +LS(1) BSD Reference Manual LS(1) + +NNAAMMEE + llss - list directory contents + +SSYYNNOOPPSSIISS + llss [--AACCFFLLRRTTWWaaccddffiillooqqrrssttuu11] [_f_i_l_e _._._.] + +DDEESSCCRRIIPPTTIIOONN + For each operand that names a _f_i_l_e of a type other than directory, llss + displays its name as well as any requested, associated information. For + each operand that names a _f_i_l_e of type directory, llss displays the names + of files contained within that directory, as well as any requested, asso- + ciated information. + + If no operands are given, the contents of the current directory are dis- + played. If more than one operand is given, non-directory operands are + displayed first; directory and non-directory operands are sorted sepa- + rately and in lexicographical order. + + The following options are available: + + --AA List all entries except for `.' and `..'. Always set for the su- + per-user. + + --CC Force multi-column output; this is the default when output is to + a terminal. + + --FF Display a slash (/) immediately after each pathname that is a di- + rectory, an asterisk (*) after each that is executable, an at + sign (@) after each symbolic link, and a percent sign (%) after + each whiteout. + + --LL If argument is a symbolic link, list the file or directory the + link references rather than the link itself. + + --RR Recursively list subdirectories encountered. + + --TT Display complete time information for the file, including month, + day, hour, minute, second, and year. + + --WW Display whiteouts when scanning directories. + + --aa Include directory entries whose names begin with a dot (.). + + --cc Use time when file status was last changed for sorting or print- + ing. + + --dd Directories are listed as plain files (not searched recursively) + and symbolic links in the argument list are not indirected + through. + + --ff Output is not sorted. + + --ii For each file, print the file's file serial number (inode num- + ber). + + --ll (The lowercase letter ``ell.'') List in long format. (See be- + low.) If the output is to a terminal, a total sum for all the + file sizes is output on a line before the long listing. + + --oo Include the file flags in a long (--ll) output + + --qq Force printing of non-graphic characters in file names as the + character `?'; this is the default when output is to a terminal. + + + --rr Reverse the order of the sort to get reverse lexicographical or- + der or the oldest entries first. + + --ss Display the number of file system blocks actually used by each + file, in units of 512 bytes, where partial units are rounded up + to the next integer value. If the output is to a terminal, a to- + tal sum for all the file sizes is output on a line before the + listing. + + --tt Sort by time modified (most recently modified first) before sort- + ing the operands by lexicographical order. + + --uu Use time of last access, instead of last modification of the file + for sorting (--tt) or printing (--ll). + + --11 (The numeric digit ``one.'') Force output to be one entry per + line. This is the default when output is not to a terminal. + + The --11, --CC, and --ll options all override each other; the last one speci- + fied determines the format used. + + The --cc, and --uu options override each other; the last one specified deter- + mines the file time used. + + By default, llss lists one entry per line to standard output; the excep- + tions are to terminals or when the --CC option is specified. + + File information is displayed with one or more s separating the + information associated with the --ii, --ss, and --ll options. + + TThhee LLoonngg FFoorrmmaatt + If the --ll option is given, the following information is displayed for + each file: file mode, number of links, owner name, group name, number of + bytes in the file, abbreviated month, day-of-month file was last modi- + fied, hour file last modified, minute file last modified, and the path- + name. In addition, for each directory whose contents are displayed, the + total number of 512-byte blocks used by the files in the directory is + displayed on a line by itself immediately before the information for the + files in the directory. + + If the owner or group names are not a known user or group name the numer- + ic ID's are displayed. + + If the file is a character special or block special file, the major and + minor device numbers for the file are displayed in the size field. If the + file is a symbolic link the pathname of the linked-to file is preceded by + ``->''. + + The file mode printed under the -l option consists of the entry type, + owner permissions, and group permissions. The entry type character de- + scribes the type of file, as follows: + + bb Block special file. + cc Character special file. + dd Directory. + ll Symbolic link. + ss Socket link. + ww Whiteout. + -- Regular file. + + The next three fields are three characters each: owner permissions, group + permissions, and other permissions. Each field has three character posi- + + + tions: + + 1. If rr, the file is readable; if --, it is not readable. + + 2. If ww, the file is writable; if --, it is not writable. + + 3. The first of the following that applies: + + SS If in the owner permissions, the file is not exe- + cutable and set-user-ID mode is set. If in the + group permissions, the file is not executable and + set-group-ID mode is set. + + ss If in the owner permissions, the file is exe- + cutable and set-user-ID mode is set. If in the + group permissions, the file is executable and set- + group-ID mode is set. + + xx The file is executable or the directory is search- + able. + + -- The file is neither readable, writeable, exe- + cutable, nor set-user-ID nor set-group-ID mode, + nor sticky. (See below.) + + These next two apply only to the third character in the last + group (other permissions). + + TT The sticky bit is set (mode 1000), but not execute + or search permission. (See chmod(1) or sticky(8).) + + + tt The sticky bit is set (mode 1000), and is search- + able or executable. (See chmod(1) or sticky(8).) + + The llss utility exits 0 on success, and >0 if an error occurs. + +EENNVVIIRROONNMMEENNTTAALL VVAARRIIAABBLLEESS + The following environment variables affect the execution of llss: + + BLOCKSIZE If the environmental variable BLOCKSIZE is set, the block + counts (see --ss) will be displayed in units of that size block. + + COLUMNS If this variable contains a string representing a decimal in- + teger, it is used as the column position width for displaying + multiple-text-column output. The llss utility calculates how + many pathname text columns to display based on the width pro- + vided. (See --CC.) + + TZ The timezone to use when displaying dates. See environ(7) for + more information. + +CCOOMMPPAATTIIBBIILLIITTYY + The group field is now automatically included in the long listing for + files in order to be compatible with the IEEE Std1003.2 (``POSIX'') spec- + ification. + +SSEEEE AALLSSOO + chmod(1), symlink(7), sticky(8) + +HHIISSTTOORRYY + An llss command appeared in Version 6 AT&T UNIX. + +SSTTAANNDDAARRDDSS + The llss function is expected to be a superset of the IEEE Std1003.2 + (``POSIX'') specification. + diff --git a/usr/share/man/cat1/mkdir.0 b/usr/share/man/cat1/mkdir.0 new file mode 100644 index 0000000000..bafeb7fcc7 --- /dev/null +++ b/usr/share/man/cat1/mkdir.0 @@ -0,0 +1,38 @@ +MKDIR(1) BSD Reference Manual MKDIR(1) + +NNAAMMEE + mmkkddiirr - make directories + +SSYYNNOOPPSSIISS + mmkkddiirr [--pp] [--mm _m_o_d_e] _d_i_r_e_c_t_o_r_y___n_a_m_e _._._. + +DDEESSCCRRIIPPTTIIOONN + MMkkddiirr creates the directories named as operands, in the order specified, + using mode rwxrwxrwx (0777) as modified by the current umask(2). + + The options are as follows: + + --mm Set the file permission bits of the final created directory to + the specified mode. The mode argument can be in any of the for- + mats specified to the chmod(1) command. If a symbolic mode is + specified, the operation characters ``+'' and ``-'' are inter- + preted relative to an initial mode of ``a=rwx''. + + --pp Create intermediate directories as required. If this option is + not specified, the full path prefix of each operand must already + exist. Intermediate directories are created with permission bits + of rwxrwxrwx (0777) as modified by the current umask, plus write + and search permission for the owner. + + The user must have write permission in the parent directory. + + MMkkddiirr exits 0 if successful, and >0 if an error occurred. + +SSEEEE AALLSSOO + rmdir(1) + +SSTTAANNDDAARRDDSS + The mmkkddiirr utility is expected to be IEEE Std1003.2 (``POSIX'') compati- + ble. + +4.4BSD January 25, 1994 1 diff --git a/usr/share/man/cat1/mv.0 b/usr/share/man/cat1/mv.0 new file mode 100644 index 0000000000..0b5564abbe --- /dev/null +++ b/usr/share/man/cat1/mv.0 @@ -0,0 +1,53 @@ +MV(1) BSD Reference Manual MV(1) + +NNAAMMEE + mmvv - move files + +SSYYNNOOPPSSIISS + mmvv [--ff | --ii] _s_o_u_r_c_e _t_a_r_g_e_t + mmvv [--ff | --ii] _s_o_u_r_c_e _._._. _s_o_u_r_c_e _d_i_r_e_c_t_o_r_y + +DDEESSCCRRIIPPTTIIOONN + In its first form, the mmvv utility renames the file named by the _s_o_u_r_c_e + operand to the destination path named by the _t_a_r_g_e_t operand. This form + is assumed when the last operand does not name an already existing direc- + tory. + + In its second form, mmvv moves each file named by a _s_o_u_r_c_e operand to a + destination file in the existing directory named by the _d_i_r_e_c_t_o_r_y + operand. The destination path for each operand is the pathname produced + by the concatenation of the last operand, a slash, and the final pathname + component of the named file. + + The following options are available: + + --ff Do not prompt for confirmation before overwriting the destination + path. (The --ii option is ignored if the --ff option is specified.) + + --ii Causes mmvv to write a prompt to standard error before moving a file + that would overwrite an existing file. If the response from the + standard input begins with the character ``y'', the move is at- + tempted. + + It is an error for either the _s_o_u_r_c_e operand or the destination path to + specify a directory unless both do. + + If the destination path does not have a mode which permits writing, mmvv + prompts the user for confirmation as specified for the --ii option. + + As the rename(2) call does not work across file systems, mmvv uses cp(1) + and rm(1) to accomplish the move. The effect is equivalent to: + + rm -f destination_path && \ + cp -pr source_file destination && \ + rm -rf source_file + + The mmvv utility exits 0 on success, and >0 if an error occurs. + +SSEEEE AALLSSOO + cp(1), symlink(7) + +SSTTAANNDDAARRDDSS + The mmvv utility is expected to be IEEE Std1003.2 (``POSIX'') compatible. + +4.4BSD May 31, 1993 1 diff --git a/usr/share/man/cat1/pax.0 b/usr/share/man/cat1/pax.0 new file mode 100644 index 0000000000..f5ebe3bc9e --- /dev/null +++ b/usr/share/man/cat1/pax.0 @@ -0,0 +1,545 @@ +PAX(1) BSD Reference Manual PAX(1) + +NNAAMMEE + ppaaxx - read and write file archives and copy directory hierarchies + +SSYYNNOOPPSSIISS + ppaaxx [--ccddnnvv] [--ff _a_r_c_h_i_v_e] [--ss _r_e_p_l_s_t_r] _._._. [--UU _u_s_e_r] _._._. [--GG _g_r_o_u_p] _._._. + [--TT [_f_r_o_m___d_a_t_e] [_,_t_o___d_a_t_e]] _._._. [_p_a_t_t_e_r_n _._._.] + ppaaxx --rr [--ccddiikknnuuvvDDYYZZ] [--ff _a_r_c_h_i_v_e] [--oo _o_p_t_i_o_n_s] _._._. [--pp _s_t_r_i_n_g] _._._. + [--ss _r_e_p_l_s_t_r] _._._. [--EE _l_i_m_i_t] [--UU _u_s_e_r] _._._. [--GG _g_r_o_u_p] _._._. [--TT + [_f_r_o_m___d_a_t_e] [_,_t_o___d_a_t_e]] _._._. [_p_a_t_t_e_r_n _._._.] + ppaaxx --ww [--ddiittuuvvHHLLPPXX] [--bb _b_l_o_c_k_s_i_z_e] [[--aa] [--ff _a_r_c_h_i_v_e]] [--xx _f_o_r_m_a_t] + [--ss _r_e_p_l_s_t_r] _._._. [--oo _o_p_t_i_o_n_s] _._._. [--UU _u_s_e_r] _._._. [--GG _g_r_o_u_p] _._._. + [--BB _b_y_t_e_s] [--TT [_f_r_o_m___d_a_t_e] [_,_t_o___d_a_t_e] [_/_[_c_]_[_m_]]] _._._. [_f_i_l_e _._._.] + ppaaxx --rr --ww [--ddiikkllnnttuuvvDDHHLLPPXXYYZZ] [--pp _s_t_r_i_n_g] _._._. [--ss _r_e_p_l_s_t_r] _._._. [--UU _u_s_e_r] + _._._. [--GG _g_r_o_u_p] _._._. [--TT [_f_r_o_m___d_a_t_e] [_,_t_o___d_a_t_e] [_/_[_c_]_[_m_]]] _._._. [_f_i_l_e + _._._.] _d_i_r_e_c_t_o_r_y + +DDEESSCCRRIIPPTTIIOONN + PPaaxx will read, write, and list the members of an archive file, and will + copy directory hierarchies. PPaaxx operation is independent of the specific + archive format, and supports a wide variety of different archive formats. + A list of supported archive formats can be found under the description of + the --xx option. + + The presence of the --rr and the --ww options specifies which of the follow- + ing functional modes ppaaxx will operate under: _l_i_s_t, _r_e_a_d, _w_r_i_t_e, and _c_o_p_y_. + + _L_i_s_t. PPaaxx will write to standard output a table of contents of + the members of the archive file read from standard input, whose + pathnames match the specified _p_a_t_t_e_r_n_s_. The table of contents + contains one filename per line and is written using single line + buffering. + + --rr _R_e_a_d. PPaaxx extracts the members of the archive file read from the + standard input, with pathnames matching the specified _p_a_t_t_e_r_n_s_. + The archive format and blocking is automatically determined on + input. When an extracted file is a directory, the entire file + hierarchy rooted at that directory is extracted. All extracted + files are created relative to the current file hierarchy. The + setting of ownership, access and modification times, and file + mode of the extracted files are discussed in more detail under + the --pp option. + + --ww _W_r_i_t_e. PPaaxx writes an archive containing the _f_i_l_e operands to + standard output using the specified archive format. When no _f_i_l_e + operands are specified, a list of files to copy with one per line + is read from standard input. When a _f_i_l_e operand is also a direc- + tory, the entire file hierarchy rooted at that directory will be + included. + + --rr --ww _C_o_p_y. PPaaxx copies the _f_i_l_e operands to the destination _d_i_r_e_c_t_o_r_y. + When no _f_i_l_e operands are specified, a list of files to copy with + one per line is read from the standard input. When a _f_i_l_e operand + is also a directory the entire file hierarchy rooted at that di- + rectory will be included. The effect of the _c_o_p_y is as if the + copied files were written to an archive file and then subsequent- + ly extracted, except that there may be hard links between the + original and the copied files (see the --ll option below). + + _W_a_r_n_i_n_g: The destination _d_i_r_e_c_t_o_r_y must not be one of the _f_i_l_e + operands or a member of a file hierarchy rooted at one of the + _f_i_l_e operands. The result of a _c_o_p_y under these conditions is + unpredictable. + + + While processing a damaged archive during a _r_e_a_d or _l_i_s_t operation, ppaaxx + will attempt to recover from media defects and will search through the + archive to locate and process the largest number of archive members pos- + sible (see the --EE option for more details on error handling). + +OOPPEERRAANNDDSS + The _d_i_r_e_c_t_o_r_y operand specifies a destination directory pathname. If the + _d_i_r_e_c_t_o_r_y operand does not exist, or it is not writable by the user, or + it is not of type directory, PPaaxx will exit with a non-zero exit status. + + The _p_a_t_t_e_r_n operand is used to select one or more pathnames of archive + members. Archive members are selected using the pattern matching nota- + tion described by fnmatch(3). When the _p_a_t_t_e_r_n operand is not supplied, + all members of the archive will be selected. When a _p_a_t_t_e_r_n matches a + directory, the entire file hierarchy rooted at that directory will be se- + lected. When a _p_a_t_t_e_r_n operand does not select at least one archive mem- + ber, ppaaxx will write these _p_a_t_t_e_r_n operands in a diagnostic message to + standard error and then exit with a non-zero exit status. + + The _f_i_l_e operand specifies the pathname of a file to be copied or + archived. When a _f_i_l_e operand does not select at least one archive mem- + ber, ppaaxx will write these _f_i_l_e operand pathnames in a diagnostic message + to standard error and then exit with a non-zero exit status. + +OOPPTTIIOONNSS + The following options are supported: + + --rr Read an archive file from standard input and extract the specified + _f_i_l_e_s. If any intermediate directories are needed in order to ex- + tract an archive member, these directories will be created as if + mkdir(2) was called with the bitwise inclusive OR of S_IRWXU, + S_IRWXG, and S_IRWXO as the mode argument. When the selected + archive format supports the specification of linked files and these + files cannot be linked while the archive is being extracted, ppaaxx + will write a diagnostic message to standard error and exit with a + non-zero exit status at the completion of operation. + + --ww Write files to the standard output in the specified archive format. + When no _f_i_l_e operands are specified, standard input is read for a + list of pathnames with one per line without any leading or trailing + . + + --aa Append _f_i_l_e_s to the end of an archive that was previously written. + If an archive format is not specified with a --xx option, the format + currently being used in the archive will be selected. Any attempt + to append to an archive in a format different from the format al- + ready used in the archive will cause ppaaxx to exit immediately with a + non-zero exit status. The blocking size used in the archive volume + where writing starts will continue to be used for the remainder of + that archive volume. + + _W_a_r_n_i_n_g: Many storage devices are not able to support the opera- + tions necessary to perform an append operation. Any attempt to ap- + pend to an archive stored on such a device may damage the archive + or have other unpredictable results. Tape drives in particular are + more likely to not support an append operation. An archive stored + in a regular file system file or on a disk device will usually sup- + port an append operation. + + --bb _b_l_o_c_k_s_i_z_e + When _w_r_i_t_i_n_g an archive, block the output at a positive decimal in- + teger number of bytes per write to the archive file. The _b_l_o_c_k_s_i_z_e + must be a multiple of 512 bytes with a maximum of 32256 bytes. A + _b_l_o_c_k_s_i_z_e can end with k or b to specify multiplication by 1024 + (1K) or 512, respectively. A pair of _b_l_o_c_k_s_i_z_e_s can be separated + by x to indicate a product. A specific archive device may impose + additional restrictions on the size of blocking it will support. + When blocking is not specified, the default _b_l_o_c_k_s_i_z_e is dependent + on the specific archive format being used (see the --xx option). + + --cc Match all file or archive members _e_x_c_e_p_t those specified by the + _p_a_t_t_e_r_n and _f_i_l_e operands. + + --dd Cause files of type directory being copied or archived, or archive + members of type directory being extracted, to match only the direc- + tory file or archive member and not the file hierarchy rooted at + the directory. + + --ff _a_r_c_h_i_v_e + Specify _a_r_c_h_i_v_e as the pathname of the input or output archive, + overriding the default standard input (for _l_i_s_t and _r_e_a_d) or + standard output (for _w_r_i_t_e). A single archive may span multiple + files and different archive devices. When required, ppaaxx will + prompt for the pathname of the file or device of the next volume in + the archive. + + --ii Interactively rename files or archive members. For each archive + member matching a _p_a_t_t_e_r_n operand or each file matching a _f_i_l_e + operand, ppaaxx will prompt to _/_d_e_v_/_t_t_y giving the name of the file, + its file mode and its modification time. PPaaxx will then read a line + from _/_d_e_v_/_t_t_y. If this line is blank, the file or archive member is + skipped. If this line consists of a single period, the file or + archive member is processed with no modification to its name. Oth- + erwise, its name is replaced with the contents of the line. PPaaxx + will immediately exit with a non-zero exit status if is en- + countered when reading a response or if _/_d_e_v_/_t_t_y cannot be opened + for reading and writing. + + --kk Do not overwrite existing files. + + --ll Link files. (The letter ell). In the _c_o_p_y mode ( --rr --ww), hard + links are made between the source and destination file hierarchies + whenever possible. + + --nn Select the first archive member that matches each _p_a_t_t_e_r_n operand. + No more than one archive member is matched for each _p_a_t_t_e_r_n. When + members of type directory are matched, the file hierarchy rooted at + that directory is also matched (unless --dd is also specified). + + --oo _o_p_t_i_o_n_s + Information to modify the algorithm for extracting or writing + archive files which is specific to the archive format specified by + --xx. In general, _o_p_t_i_o_n_s take the form: nnaammee==vvaalluuee + + --pp _s_t_r_i_n_g + Specify one or more file characteristic options (privileges). The + _s_t_r_i_n_g option-argument is a string specifying file characteristics + to be retained or discarded on extraction. The string consists of + the specification characters aa, ee, mm, oo, and pp. Multiple character- + istics can be concatenated within the same string and multiple --pp + options can be specified. The meaning of the specification charac- + ters are as follows: + + aa Do not preserve file access times. By default, file access + times are preserved whenever possible. + + ee `Preserve everything', the user ID, group ID, file mode bits, + file access time, and file modification time. This is intended + to be used by _r_o_o_t, someone with all the appropriate privi- + leges, in order to preserve all aspects of the files as they + are recorded in the archive. The ee flag is the sum of the oo + + and pp flags. + + mm Do not preserve file modification times. By default, file mod- + ification times are preserved whenever possible. + + oo Preserve the user ID and group ID. + + pp `Preserve' the file mode bits. This intended to be used by a + _u_s_e_r with regular privileges who wants to preserve all aspects + of the file other than the ownership. The file times are pre- + served by default, but two other flags are offered to disable + this and use the time of extraction instead. + + In the preceding list, `preserve' indicates that an attribute + stored in the archive is given to the extracted file, subject to + the permissions of the invoking process. Otherwise the attribute + of the extracted file is determined as part of the normal file cre- + ation action. If neither the ee nor the oo specification character + is specified, or the user ID and group ID are not preserved for any + reason, ppaaxx will not set the S_ISUID (_s_e_t_u_i_d) and S_ISGID (_s_e_t_g_i_d) + bits of the file mode. If the preservation of any of these items + fails for any reason, ppaaxx will write a diagnostic message to + standard error. Failure to preserve these items will affect the fi- + nal exit status, but will not cause the extracted file to be delet- + ed. If the file characteristic letters in any of the string op- + tion-arguments are duplicated or conflict with each other, the + one(s) given last will take precedence. For example, if + --pp _e_m_e + is specified, file modification times are still preserved. + + --ss _r_e_p_l_s_t_r + Modify the file or archive member names specified by the _p_a_t_t_e_r_n or + _f_i_l_e operands according to the substitution expression _r_e_p_l_s_t_r, us- + ing the syntax of the ed(1) utility regular expressions. The for- + mat of these regular expressions are: + /old/new/[gp] + As in ed(1), oolldd is a basic regular expression and nneeww can contain + an ampersand (&), \n (where n is a digit) back-references, or + subexpression matching. The oolldd string may also contain + characters. Any non-null character can be used as a delimiter (/ + is shown here). Multiple --ss expressions can be specified. The ex- + pressions are applied in the order they are specified on the com- + mand line, terminating with the first successful substitution. The + optional trailing gg continues to apply the substitution expression + to the pathname substring which starts with the first character + following the end of the last successful substitution. The first + unsuccessful substitution stops the operation of the gg option. The + optional trailing pp will cause the final result of a successful + substitution to be written to standard error in the following for- + mat: + >> + File or archive member names that substitute to the empty string + are not selected and will be skipped. + + --tt Reset the access times of any file or directory read or accessed by + ppaaxx to be the same as they were before being read or accessed by + ppaaxx. + + --uu Ignore files that are older (having a less recent file modification + time) than a pre-existing file or archive member with the same + name. During _r_e_a_d, an archive member with the same name as a file + in the file system will be extracted if the archive member is newer + than the file. During _w_r_i_t_e, a file system member with the same + name as an archive member will be written to the archive if it is + newer than the archive member. During _c_o_p_y, the file in the desti- + nation hierarchy is replaced by the file in the source hierarchy or + by a link to the file in the source hierarchy if the file in the + source hierarchy is newer. + + --vv During a _l_i_s_t operation, produce a verbose table of contents using + the format of the ls(1) utility with the --ll option. For pathnames + representing a hard link to a previous member of the archive, the + output has the format: + == + For pathnames representing a symbolic link, the output has the for- + mat: + => + Where is the output format specified by the ls(1) + utility when used with the --ll option. Otherwise for all the other + operational modes ( _r_e_a_d, _w_r_i_t_e, and _c_o_p_y), pathnames are written + and flushed to standard error without a trailing as soon + as processing begins on that file or archive member. The trailing + , is not buffered, and is written only after the file has + been read or written. + + --xx _f_o_r_m_a_t + Specify the output archive format, with the default format being + _u_s_t_a_r. PPaaxx currently supports the following formats: + + _c_p_i_o The extended cpio interchange format specified in the IEEE + Std1003.2 (``POSIX'') standard. The default blocksize for + this format is 5120 bytes. Inode and device information + about a file (used for detecting file hard links by this + format) which may be truncated by this format is detected + by ppaaxx and is repaired. + + _b_c_p_i_o The old binary cpio format. The default blocksize for + this format is 5120 bytes. This format is not very + portable and should not be used when other formats are + available. Inode and device information about a file + (used for detecting file hard links by this format) which + may be truncated by this format is detected by ppaaxx and is + repaired. + + _s_v_4_c_p_i_o The System V release 4 cpio. The default blocksize for + this format is 5120 bytes. Inode and device information + about a file (used for detecting file hard links by this + format) which may be truncated by this format is detected + by ppaaxx and is repaired. + + _s_v_4_c_r_c The System V release 4 cpio with file crc checksums. The + default blocksize for this format is 5120 bytes. Inode + and device information about a file (used for detecting + file hard links by this format) which may be truncated by + this format is detected by ppaaxx and is repaired. + + _t_a_r The old BSD tar format as found in BSD4.3. The default + blocksize for this format is 10240 bytes. Pathnames + stored by this format must be 100 characters or less in + length. Only _r_e_g_u_l_a_r files, _h_a_r_d _l_i_n_k_s, _s_o_f_t _l_i_n_k_s, and + _d_i_r_e_c_t_o_r_i_e_s will be archived (other file system types are + not supported). For backwards compatibility with even + older tar formats, a --oo option can be used when writing an + archive to omit the storage of directories. This option + takes the form: + --oo wwrriittee__oopptt==nnooddiirr + + _u_s_t_a_r The extended tar interchange format specified in the IEEE + Std1003.2 (``POSIX'') standard. The default blocksize for + this format is 10240 bytes. Pathnames stored by this for- + mat must be 250 characters or less in length. + + PPaaxx will detect and report any file that it is unable to store or + extract as the result of any specific archive format restrictions. + The individual archive formats may impose additional restrictions + on use. Typical archive format restrictions include (but are not + limited to): file pathname length, file size, link pathname length + and the type of the file. + + --BB _b_y_t_e_s + Limit the number of bytes written to a single archive volume to + _b_y_t_e_s. The _b_y_t_e_s limit can end with m, k, or b to specify multipli- + cation by 1048576 (1M), 1024 (1K) or 512, respectively. A pair of + _b_y_t_e_s limits can be separated by x to indicate a product. + + _W_a_r_n_i_n_g: Only use this option when writing an archive to a device + which supports an end of file read condition based on last (or + largest) write offset (such as a regular file or a tape drive). + The use of this option with a floppy or hard disk is not recommend- + ed. + + --DD This option is the same as the --uu option, except that the file in- + ode change time is checked instead of the file modification time. + The file inode change time can be used to select files whose inode + information (e.g. uid, gid, etc.) is newer than a copy of the file + in the destination _d_i_r_e_c_t_o_r_y. + + --EE _l_i_m_i_t + Limit the number of consecutive read faults while trying to read a + flawed archives to _l_i_m_i_t. With a positive _l_i_m_i_t, ppaaxx will attempt + to recover from an archive read error and will continue processing + starting with the next file stored in the archive. A _l_i_m_i_t of 0 + will cause ppaaxx to stop operation after the first read error is de- + tected on an archive volume. A _l_i_m_i_t of NONE will cause ppaaxx to at- + tempt to recover from read errors forever. The default _l_i_m_i_t is a + small positive number of retries. + + _W_a_r_n_i_n_g_: Using this option with NONE should be used with extreme + caution as ppaaxx may get stuck in an infinite loop on a very badly + flawed archive. + + --GG _g_r_o_u_p + Select a file based on its _g_r_o_u_p name, or when starting with a ##, a + numeric gid. A '\' can be used to escape the ##. Multiple --GG op- + tions may be supplied and checking stops with the first match. + + --HH Follow only command line symbolic links while performing a physical + file system traversal. + + --LL Follow all symbolic links to perform a logical file system traver- + sal. + + --PP Do not follow symbolic links, perform a physical file system + traversal. This is the default mode. + + --TT _[_f_r_o_m___d_a_t_e_]_[_,_t_o___d_a_t_e_]_[_/_[_c_]_[_m_]_] + Allow files to be selected based on a file modification or inode + change time falling within a specified time range of _f_r_o_m___d_a_t_e to + _t_o___d_a_t_e (the dates are inclusive). If only a _f_r_o_m___d_a_t_e is sup- + plied, all files with a modification or inode change time equal to + or younger are selected. If only a _t_o___d_a_t_e is supplied, all files + with a modification or inode change time equal to or older will be + selected. When the _f_r_o_m___d_a_t_e is equal to the _t_o___d_a_t_e, only files + with a modification or inode change time of exactly that time will + be selected. + + + When ppaaxx is in the _w_r_i_t_e or _c_o_p_y mode, the optional trailing field + _[_c_]_[_m_] can be used to determine which file time (inode change, file + modification or both) are used in the comparison. If neither is + specified, the default is to use file modification time only. The + _m specifies the comparison of file modification time (the time when + the file was last written). The _c specifies the comparison of in- + ode change time (the time when the file inode was last changed; + e.g. a change of owner, group, mode, etc). When _c and _m are both + specified, then the modification and inode change times are both + compared. The inode change time comparison is useful in selecting + files whose attributes were recently changed or selecting files + which were recently created and had their modification time reset + to an older time (as what happens when a file is extracted from an + archive and the modification time is preserved). Time comparisons + using both file times is useful when ppaaxx is used to create a time + based incremental archive (only files that were changed during a + specified time range will be archived). + + A time range is made up of six different fields and each field must + contain two digits. The format is: + [yy[mm[dd[hh]]]]mm[.ss] + Where yyyy is the last two digits of the year, the first mmmm is the + month (from 01 to 12), dddd is the day of the month (from 01 to 31), + hhhh is the hour of the day (from 00 to 23), the second mmmm is the + minute (from 00 to 59), and ssss is the seconds (from 00 to 59). The + minute field mmmm is required, while the other fields are optional + and must be added in the following order: + hhhh, dddd, mmmm, yyyy. + The ssss field may be added independently of the other fields. Time + ranges are relative to the current time, so + --TT _1_2_3_4_/_c_m + would select all files with a modification or inode change time of + 12:34 PM today or later. Multiple --TT time range can be supplied + and checking stops with the first match. + + --UU _u_s_e_r + Select a file based on its _u_s_e_r name, or when starting with a ##, a + numeric uid. A '\' can be used to escape the ##. Multiple --UU op- + tions may be supplied and checking stops with the first match. + + --XX When traversing the file hierarchy specified by a pathname, do not + descend into directories that have a different device ID. See the + st_dev field as described in stat(2) for more information about de- + vice ID's. + + --YY This option is the same as the --DD option, except that the inode + change time is checked using the pathname created after all the + file name modifications have completed. + + --ZZ This option is the same as the --uu option, except that the modifica- + tion time is checked using the pathname created after all the file + name modifications have completed. + + The options that operate on the names of files or archive members ( --cc, + --ii, --nn, --ss, --uu, --vv, --DD, --GG, --TT, --UU, --YY, and --ZZ) interact as follows. + + When extracting files during a _r_e_a_d operation, archive members are + `selected', based only on the user specified pattern operands as modified + by the --cc, --nn, --uu, --DD, --GG, --TT, --UU options. Then any --ss and --ii options + will modify in that order, the names of these selected files. Then the + --YY and --ZZ options will be applied based on the final pathname. Finally + the --vv option will write the names resulting from these modifications. + + When archiving files during a _w_r_i_t_e operation, or copying files during a + _c_o_p_y operation, archive members are `selected', based only on the user + specified pathnames as modified by the --nn, --uu, --DD, --GG, --TT, and --UU options + (the --DD option only applies during a copy operation). Then any --ss and --ii + options will modify in that order, the names of these selected files. + Then during a _c_o_p_y operation the --YY and the --ZZ options will be applied + based on the final pathname. Finally the --vv option will write the names + resulting from these modifications. + + When one or both of the --uu or --DD options are specified along with the --nn + option, a file is not considered selected unless it is newer than the + file to which it is compared. + +EEXXAAMMPPLLEESS + The command: + pax -w -f /dev/rst0 . + copies the contents of the current directory to the device _/_d_e_v_/_r_s_t_0. + + The command: + pax -r -v -f filename + gives the verbose table of contents for an archive stored in _f_i_l_e_n_a_m_e. + + The following commands: + mkdir newdir + cd olddir + pax -rw . newdir + will copy the entire _o_l_d_d_i_r directory hierarchy to _n_e_w_d_i_r. + + The command: + pax -r -s ',^//*usr//*,,' -f a.pax + reads the archive _a_._p_a_x, with all files rooted in ``/usr'' into the + archive extracted relative to the current directory. + + The command: + pax -rw -i . dest_dir + can be used to interactively select the files to copy from the current + directory to _d_e_s_t___d_i_r. + + The command: + pax -r -pe -U root -G bin -f a.pax + will extract all files from the archive _a_._p_a_x which are owned by _r_o_o_t + with group _b_i_n and will preserve all file permissions. + + The command: + pax -r -w -v -Y -Z home /backup + will update (and list) only those files in the destination directory + _/_b_a_c_k_u_p which are older (less recent inode change or file modification + times) than files with the same name found in the source file tree _h_o_m_e. + +SSTTAANNDDAARRDDSS + The ppaaxx utility is a superset of the IEEE Std1003.2 (``POSIX'') standard. + The options --BB, --DD, --EE, --GG, --HH, --LL, --PP, --TT, --UU, --YY, --ZZ, the archive for- + mats _b_c_p_i_o, _s_v_4_c_p_i_o, _s_v_4_c_r_c, _t_a_r, and the flawed archive handling during + _l_i_s_t and _r_e_a_d operations are extensions to the POSIX standard. + +AAUUTTHHOORR + Keith Muller at the University of California, San Diego + +EERRRROORRSS + ppaaxx will exit with one of the following values: + + 0 All files were processed successfully. + + 1 An error occurred. + + Whenever ppaaxx cannot create a file or a link when reading an archive or + cannot find a file when writing an archive, or cannot preserve the user + ID, group ID, or file mode when the --pp option is specified, a diagnostic + message is written to standard error and a non-zero exit status will be + returned, but processing will continue. In the case where pax cannot + create a link to a file, ppaaxx will not create a second copy of the file. + + If the extraction of a file from an archive is prematurely terminated by + a signal or error, ppaaxx may have only partially extracted a file the user + wanted. Additionally, the file modes of extracted files and directories + may have incorrect file bits, and the modification and access times may + be wrong. + + If the creation of an archive is prematurely terminated by a signal or + error, ppaaxx may have only partially created the archive which may violate + the specific archive format specification. + + If while doing a _c_o_p_y, ppaaxx detects a file is about to overwrite itself, + the file is not copied, a diagnostic message is written to standard error + and when ppaaxx completes it will exit with a non-zero exit status. + +4.4BSD April 18, 1994 9 diff --git a/usr/share/man/cat1/popd.0 b/usr/share/man/cat1/popd.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/popd.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/ps.0 b/usr/share/man/cat1/ps.0 new file mode 100644 index 0000000000..e711710ab4 --- /dev/null +++ b/usr/share/man/cat1/ps.0 @@ -0,0 +1,307 @@ +PS(1) BSD Reference Manual PS(1) + +NNAAMMEE + ppss - process status + +SSYYNNOOPPSSIISS + ppss [--aaCCeehhjjllmmrrSSTTuuvvwwxx] [--MM _c_o_r_e] [--NN _s_y_s_t_e_m] [--OO _f_m_t] [--oo _f_m_t] [--pp _p_i_d] [--tt + _t_t_y] [--WW _s_w_a_p] + ppss [--LL] + +DDEESSCCRRIIPPTTIIOONN + PPss displays a header line followed by lines containing information about + your processes that have controlling terminals. This information is + sorted by process ID. + + The information displayed is selected based on a set of keywords (see the + --LL --OO and --oo options). The default output format includes, for each pro- + cess, the process' ID, controlling terminal, cpu time (including both us- + er and system time), state, and associated command. + + The options are as follows: + + --aa Display information about other users' processes as well as your + own. + + --CC Change the way the cpu percentage is calculated by using a + ``raw'' cpu calculation that ignores ``resident'' time (this nor- + mally has no effect). + + --ee Display the environment as well. + + --hh Repeat the information header as often as necessary to guarantee + one header per page of information. + + --jj Print information associated with the following keywords: user, + pid, ppid, pgid, sess, jobc, state, tt, time and command. + + --LL List the set of available keywords. + + --ll Display information associated with the following keywords: uid, + pid, ppid, cpu, pri, nice, vsz, rss, wchan, state, tt, time and + command. + + --MM Extract values associated with the name list from the specified + core instead of the default ``_/_d_e_v_/_k_m_e_m''. + + --mm Sort by memory usage, instead of by process ID. + + --NN Extract the name list from the specified system instead of the + default ``_/_v_m_u_n_i_x''. + + --OO Add the information associated with the space or comma separated + list of keywords specified, after the process ID, in the default + information display. Keywords may be appended with an equals + (``='') sign and a string. This causes the printed header to use + the specified string instead of the standard header. + + --oo Display information associated with the space or comma separated + list of keywords specified. Keywords may be appended with an + equals (``='') sign and a string. This causes the printed header + to use the specified string instead of the standard header. + + --pp Display information associated with the specified process ID. + + + --rr Sort by current cpu usage, instead of by process ID. + + --SS Change the way the process time is calculated by summing all ex- + ited children to their parent process. + + --TT Display information about processes attached to the device asso- + ciated with the standard input. + + --tt Display information about processes attached to the specified + terminal device. + + --uu Display information associated with the following keywords: user, + pid, %cpu, %mem, vsz, rss, tt, state, start, time and command. + The --uu option implies the --rr option. + + --vv Display information associated with the following keywords: pid, + state, time, sl, re, pagein, vsz, rss, lim, tsiz, %cpu, %mem and + command. The --vv option implies the --mm option. + + --WW Extract swap information from the specified file instead of the + default ``_/_d_e_v_/_s_w_a_p''. + + --ww Use 132 columns to display information, instead of the default + which is your window size. If the --ww option is specified more + than once, ppss will use as many columns as necessary without re- + gard for your window size. + + --xx Display information about processes without controlling termi- + nals. + + A complete list of the available keywords are listed below. Some of + these keywords are further specified as follows: + + %cpu The cpu utilization of the process; this is a decaying average + over up to a minute of previous (real) time. Since the time base + over which this is computed varies (since processes may be very + young) it is possible for the sum of all %CPU fields to exceed + 100%. + + %mem The percentage of real memory used by this process. + + flags The flags (in hexadecimal) associated with the process as in the + include file <_s_y_s_/_p_r_o_c_._h>: + + SLOAD 0x0000001 in core + SSYS 0x0000002 swapper or pager process + SLOCK 0x0000004 process being swapped out + SSWAP 0x0000008 save area flag + STRC 0x0000010 process is being traced + SWTED 0x0000020 another tracing flag + SSINTR 0x0000040 sleep is interruptible + SKEEP 0x0000100 another flag to prevent swap out + SOMASK 0x0000200 restore old mask after taking signal + SWEXIT 0x0000400 working on exiting + SPHYSIO 0x0000800 doing physical I/O + SVFORK 0x0001000 process resulted from vfork(2) + SVFDONE 0x0002000 another vfork flag + SNOVM 0x0004000 no vm, parent in a vfork + SPAGV 0x0008000 init data space on demand, from vnode + SSEQL 0x0010000 user warned of sequential vm behavior + SUANOM 0x0020000 user warned of random vm behavior + STIMO 0x0040000 timing out during sleep + SNOCLDSTOP 0x0080000 no SIGCHLD when children stop + SCTTY 0x0100000 has a controlling terminal + SOWEUPC 0x0200000 owe process an addupc() call at next + + ast + SSEL 0x0400000 selecting; wakeup/waiting danger + SEXEC 0x0800000 process called exec(2) + SHPUX 0x1000000 HP-UX process (HPUXCOMPAT) + SULOCK 0x2000000 locked in core after swap error + SPTECHG 0x4000000 pte's for process have changed + + lim The soft limit on memory used, specified via a call to + setrlimit(2). + + lstart The exact time the command started, using the ``%C'' format de- + scribed in strftime(3). + + nice The process scheduling increment (see setpriority(2)). + + rss the real memory (resident set) size of the process (in 1024 byte + units). + + start The time the command started. If the command started less than + 24 hours ago, the start time is displayed using the ``%l:ps.1p'' + format described in strftime(3). If the command started less + than 7 days ago, the start time is displayed using the + ``%a6.15p'' format. Otherwise, the start time is displayed using + the ``%e%b%y'' format. + + state The state is given by a sequence of letters, for example, + ``RWNA''. The first letter indicates the run state of the pro- + cess: + + D Marks a process in disk (or other short term, uninter- + ruptible) wait. + I Marks a process that is idle (sleeping for longer than + about 20 seconds). + R Marks a runnable process. + S Marks a process that is sleeping for less than about 20 + seconds. + T Marks a stopped process. + Z Marks a dead process (a ``zombie''). + + Additional characters after these, if any, indicate additional + state information: + + + The process is in the foreground process group of its + control terminal. + < The process has raised CPU scheduling priority. + > The process has specified a soft limit on memory require- + ments and is currently exceeding that limit; such a pro- + cess is (necessarily) not swapped. + A the process has asked for random page replacement + (VA_ANOM, from vadvise(2), for example, lisp(1) in a + garbage collect). + E The process is trying to exit. + L The process has pages locked in core (for example, for + raw I/O). + N The process has reduced CPU scheduling priority (see + setpriority(2)). + S The process has asked for FIFO page replacement (VA_SEQL, + from vadvise(2), for example, a large image processing + program using virtual memory to sequentially address vo- + luminous data). + s The process is a session leader. + V The process is suspended during a vfork. + W The process is swapped out. + X The process is being traced or debugged. + + + + tt An abbreviation for the pathname of the controlling terminal, if + any. The abbreviation consists of the two letters following + ``_/_d_e_v_/_t_t_y'', or, for the console, ``co''. This is followed by a + ``-'' if the process can no longer reach that controlling termi- + nal (i.e., it has been revoked). + + wchan The event (an address in the system) on which a process waits. + When printed numerically, the initial part of the address is + trimmed off and the result is printed in hex, for example, + 0x80324000 prints as 324000. + + When printing using the command keyword, a process that has exited and + has a parent that has not yet waited for the process (in other words, a + zombie) is listed as ``'', and a process which is blocked while + trying to exit is listed as ``''. PPss makes an educated guess as + to the file name and arguments given when the process was created by ex- + amining memory or the swap area. The method is inherently somewhat unre- + liable and in any event a process is entitled to destroy this informa- + tion, so the names cannot be depended on too much. The ucomm (account- + ing) keyword can, however, be depended on. + +KKEEYYWWOORRDDSS + The following is a complete list of the available keywords and their + meanings. Several of them have aliases (keywords which are synonyms). + + %cpu percentage cpu usage (alias pcpu) + %mem percentage memory usage (alias pmem) + acflag accounting flag (alias acflg) + command command and arguments + cpu short-term cpu usage factor (for scheduling) + flags the process flags, in hexadecimal (alias f) + inblk total blocks read (alias inblock) + jobc job control count + ktrace tracing flags + ktracep tracing vnode + lim memoryuse limit + logname login name of user who started the process + lstart time started + majflt total page faults + minflt total page reclaims + msgrcv total messages received (reads from pipes/sockets) + msgsnd total messages sent (writes on pipes/sockets) + nice nice value (alias ni) + nivcsw total involuntary context switches + nsigs total signals taken (alias nsignals) + nswap total swaps in/out + nvcsw total voluntary context switches + nwchan wait channel (as an address) + oublk total blocks written (alias oublock) + p_ru resource usage (valid only for zombie) + paddr swap address + pagein pageins (same as majflt) + pgid process group number + pid process ID + poip pageouts in progress + ppid parent process ID + pri scheduling priority + re core residency time (in seconds; 127 = infinity) + rgid real group ID + rlink reverse link on run queue, or 0 + rss resident set size + rsz resident set size + (text size / text use count) (alias rs- + size) + + + ruid real user ID + ruser user name (from ruid) + sess session pointer + sig pending signals (alias pending) + sigcatch caught signals (alias caught) + sigignore ignored signals (alias ignored) + sigmask blocked signals (alias blocked) + sl sleep time (in seconds; 127 = infinity) + start time started + state symbolic process state (alias stat) + svgid saved gid from a setgid executable + svuid saved uid from a setuid executable + tdev control terminal device number + time accumulated cpu time, user + system (alias cputime) + tpgid control terminal process group ID + tsess control terminal session pointer + tsiz text size (in Kbytes) + tt control terminal name (two letter abbreviation) + tty full name of control terminal + uprocp process pointer + ucomm name to be used for accounting + uid effective user ID + upr scheduling priority on return from system call (alias usrpri) + user user name (from uid) + vsz virtual size in Kbytes (alias vsize) + wchan wait channel (as a symbolic name) + xstat exit or stop status (valid only for stopped or zombie process) + +FFIILLEESS + /dev special files and device names + /dev/drum default swap device + /dev/kmem default kernel memory + /var/run/dev.db /dev name database + /var/run/kvm_vmunix.db system namelist database + /vmunix default system namelist + +SSEEEE AALLSSOO + kill(1), w(1), kvm(3), strftime(3), pstat(8) + +BBUUGGSS + Since ppss cannot run faster than the system and is run as any other sched- + uled process, the information it displays can never be exact. + +4th Berkeley Distribution April 18, 1994 5 diff --git a/usr/share/man/cat1/pushd.0 b/usr/share/man/cat1/pushd.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/pushd.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/pwd.0 b/usr/share/man/cat1/pwd.0 new file mode 100644 index 0000000000..e92911e81c --- /dev/null +++ b/usr/share/man/cat1/pwd.0 @@ -0,0 +1,26 @@ +PWD(1) BSD Reference Manual PWD(1) + +NNAAMMEE + ppwwdd - return working directory name + +SSYYNNOOPPSSIISS + ppwwdd + +DDEESSCCRRIIPPTTIIOONN + PPwwdd writes the absolute pathname of the current working directory to the + standard output. + + The pwd utility exits 0 on success, and >0 if an error occurs. + +SSTTAANNDDAARRDDSS + The ppwwdd command is expected to be IEEE Std1003.2 (``POSIX'') compatible . + +SSEEEE AALLSSOO + cd(1), csh(1), getcwd(3) + +BBUUGGSS + In csh(1) the command ddiirrss is always faster (although it can give a dif- + ferent answer in the rare case that the current directory or a containing + directory was moved after the shell descended into it). + +4th Berkeley Distribution April 28, 1995 1 diff --git a/usr/share/man/cat1/rcp.0 b/usr/share/man/cat1/rcp.0 new file mode 100644 index 0000000000..478cdab80d --- /dev/null +++ b/usr/share/man/cat1/rcp.0 @@ -0,0 +1,65 @@ +RCP(1) BSD Reference Manual RCP(1) + +NNAAMMEE + rrccpp - remote file copy + +SSYYNNOOPPSSIISS + rrccpp [--KKppxx] [--kk _r_e_a_l_m] _f_i_l_e_1 _f_i_l_e_2 + rrccpp [--KKpprrxx] [--kk _r_e_a_l_m] _f_i_l_e _._._. _d_i_r_e_c_t_o_r_y + +DDEESSCCRRIIPPTTIIOONN + RRccpp copies files between machines. Each _f_i_l_e or _d_i_r_e_c_t_o_r_y argument is + either a remote file name of the form ``rname@rhost:path'', or a local + file name (containing no `:' characters, or a `/' before any `:'s). + + --KK The --KK option turns off all Kerberos authentication. + + --kk The --kk option requests rrccpp to obtain tickets for the remote host in + realm _r_e_a_l_m instead of the remote host's realm as determined by + krb_realmofhost(3). + + --pp The --pp option causes rrccpp to attempt to preserve (duplicate) in its + copies the modification times and modes of the source files, ignor- + ing the _u_m_a_s_k. By default, the mode and owner of _f_i_l_e_2 are pre- + served if it already existed; otherwise the mode of the source file + modified by the umask(2) on the destination host is used. + + --rr If any of the source files are directories, rrccpp copies each subtree + rooted at that name; in this case the destination must be a direc- + tory. + + --xx The --xx option turns on DES encryption for all data passed by rrccpp. + This may impact response time and CPU utilization, but provides in- + creased security. + + If _p_a_t_h is not a full path name, it is interpreted relative to the login + directory of the specified user _r_u_s_e_r on _r_h_o_s_t, or your current user name + if no other remote user name is specified. A _p_a_t_h on a remote host may + be quoted (using \, ", or ') so that the metacharacters are interpreted + remotely. + + RRccpp does not prompt for passwords; it performs remote execution via + rsh(1), and requires the same authorization. + + RRccpp handles third party copies, where neither source nor target files are + on the current machine. + +SSEEEE AALLSSOO + cp(1), ftp(1), rsh(1), rlogin(1) + +HHIISSTTOORRYY + The rrccpp command appeared in 4.2BSD. The version of rrccpp described here has + been reimplemented with Kerberos in 4.3BSD-Reno. + +BBUUGGSS + Doesn't detect all cases where the target of a copy might be a file in + cases where only a directory should be legal. + + Is confused by any output generated by commands in a _._l_o_g_i_n, _._p_r_o_f_i_l_e, or + _._c_s_h_r_c file on the remote host. + + The destination user and hostname may have to be specified as + ``rhost.rname'' when the destination machine is running the 4.2BSD ver- + sion of rrccpp. + +4.3-Reno Berkeley Distribution May 31, 1993 1 diff --git a/usr/share/man/cat1/rehash.0 b/usr/share/man/cat1/rehash.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/rehash.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/repeat.0 b/usr/share/man/cat1/repeat.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/repeat.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/rm.0 b/usr/share/man/cat1/rm.0 new file mode 100644 index 0000000000..903e4fba29 --- /dev/null +++ b/usr/share/man/cat1/rm.0 @@ -0,0 +1,74 @@ +RM(1) BSD Reference Manual RM(1) + +NNAAMMEE + rrmm - remove directory entries + +SSYYNNOOPPSSIISS + rrmm [--ff | --ii] [--ddPPRRrrWW] _f_i_l_e _._._. + +DDEESSCCRRIIPPTTIIOONN + The rrmm utility attempts to remove the non-directory type files specified + on the command line. If the permissions of the file do not permit writ- + ing, and the standard input device is a terminal, the user is prompted + (on the standard error output) for confirmation. + + The options are as follows: + + --dd Attempt to remove directories as well as other types of files. + + --ff Attempt to remove the files without prompting for confirmation, re- + gardless of the file's permissions. If the file does not exist, do + not display a diagnostic message or modify the exit status to re- + flect an error. The --ff option overrides any previous --ii options. + + --ii Request confirmation before attempting to remove each file, regard- + less of the file's permissions, or whether or not the standard in- + put device is a terminal. The --ii option overrides any previous --ff + options. + + --PP Overwrite regular files before deleting them. Files are overwrit- + ten three times, first with the byte pattern 0xff, then 0x00, and + then 0xff again, before they are deleted. + + --RR Attempt to remove the file hierarchy rooted in each file argument. + The --RR option implies the --dd option. If the --ii option is speci- + fied, the user is prompted for confirmation before each directory's + contents are processed (as well as before the attempt is made to + remove the directory). If the user does not respond affirmatively, + the file hierarchy rooted in that directory is skipped. + + --rr Equivalent to --RR. + + --WW Attempts to undelete the named files. Currently, this option can + only be used to recover files covered by whiteouts. + + The rrmm utility removes symbolic links, not the files referenced by the + links. + + It is an error to attempt to remove the files ``.'' and ``..''. + + The rrmm utility exits 0 if all of the named files or file hierarchies were + removed, or if the --ff option was specified and all of the existing files + or file hierarchies were removed. If an error occurs, rrmm exits with a + value >0. + +SSEEEE AALLSSOO + rmdir(1), undelete(2), unlink(2), fts(3), symlink(7) + +BBUUGGSS + The --PP option assumes that the underlying file system is a fixed-block + file system. UFS is a fixed-block file system, LFS is not. In addition, + only regular files are overwritten, other types of files are not. + +CCOOMMPPAATTIIBBIILLIITTYY + The rrmm utility differs from historical implementations in that the --ff op- + tion only masks attempts to remove non-existent files instead of masking + a large variety of errors. + + Also, historical BSD implementations prompted on the standard output, not + the standard error output. + +SSTTAANNDDAARRDDSS + The rrmm command is expected to be IEEE Std1003.2 (``POSIX'') compatible. + +4.4BSD December 5, 1994 2 diff --git a/usr/share/man/cat1/rmdir.0 b/usr/share/man/cat1/rmdir.0 new file mode 100644 index 0000000000..d3998905b3 --- /dev/null +++ b/usr/share/man/cat1/rmdir.0 @@ -0,0 +1,32 @@ +RMDIR(1) BSD Reference Manual RMDIR(1) + +NNAAMMEE + rrmmddiirr - remove directories + +SSYYNNOOPPSSIISS + rrmmddiirr _d_i_r_e_c_t_o_r_y _._._. + +DDEESSCCRRIIPPTTIIOONN + The rmdir utility removes the directory entry specified by each _d_i_r_e_c_t_o_r_y + argument, provided it is empty. + + Arguments are processed in the order given. In order to remove both a + parent directory and a subdirectory of that parent, the subdirectory must + be specified first so the parent directory is empty when rrmmddiirr tries to + remove it. + + The rrmmddiirr utility exits with one of the following values: + + 0 Each directory entry specified by a dir operand referred to an emp- + ty directory and was removed successfully. + + >0 An error occurred. + +SSEEEE AALLSSOO + rm(1) + +SSTTAANNDDAARRDDSS + The rrmmddiirr command is expected to be IEEE Std1003.2 (``POSIX'') compati- + ble. + +4.4BSD May 31, 1993 1 diff --git a/usr/share/man/cat1/sleep.0 b/usr/share/man/cat1/sleep.0 new file mode 100644 index 0000000000..7199987508 --- /dev/null +++ b/usr/share/man/cat1/sleep.0 @@ -0,0 +1,56 @@ +SLEEP(1) BSD Reference Manual SLEEP(1) + +NNAAMMEE + sslleeeepp - suspend execution for an interval of time + +SSYYNNOOPPSSIISS + sslleeeepp _s_e_c_o_n_d_s + +DDEESSCCRRIIPPTTIIOONN + The sslleeeepp command suspends execution for a minimum of _s_e_c_o_n_d_s. SSlleeeepp is + used to schedule the execution of other commands (see _E_X_A_M_P_L_E_S below). + + The SSlleeeepp utility exits with one of the following values: + + 0 On successful completion, or if the signal SIGALRM was received. + + >0 An error occurred. + +EEXXAAMMPPLLEESS + To schedule the execution of a command for _x number seconds later: + + (sleep 1800; sh command_file >& errors)& + + This incantation would wait a half hour before running the script com- + mand_file. (See the at(1) utility.) + + To reiteratively run a command (with the csh(1)): + + while (1) + if (! -r zzz.rawdata) then + sleep 300 + else + foreach i (`ls *.rawdata`) + sleep 70 + awk -f collapse_data $i >> results + end + break + endif + end + + The scenario for a script such as this might be: a program currently run- + ning is taking longer than expected to process a series of files, and it + would be nice to have another program start processing the files created + by the first program as soon as it is finished (when zzz.rawdata is cre- + ated). The script checks every five minutes for the file zzz.rawdata, + when the file is found, then another portion processing is done courte- + ously by sleeping for 70 seconds in between each awk job. + +SSEEEE AALLSSOO + setitimer(2), alarm(3), sleep(3), at(1) + +SSTTAANNDDAARRDDSS + The sslleeeepp command is expected to be IEEE Std1003.2 (``POSIX'') compati- + ble. + +4.4BSD April 18, 1994 1 diff --git a/usr/share/man/cat1/source.0 b/usr/share/man/cat1/source.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/source.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/stop.0 b/usr/share/man/cat1/stop.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/stop.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/stty.0 b/usr/share/man/cat1/stty.0 new file mode 100644 index 0000000000..ee5ff16168 --- /dev/null +++ b/usr/share/man/cat1/stty.0 @@ -0,0 +1,414 @@ +STTY(1) BSD Reference Manual STTY(1) + +NNAAMMEE + ssttttyy - set the options for a terminal device interface + +SSYYNNOOPPSSIISS + ssttttyy [--aa | --ee | --gg] [--ff _f_i_l_e] [operands] + +DDEESSCCRRIIPPTTIIOONN + The ssttttyy utility sets or reports on terminal characteristics for the de- + vice that is its standard input. If no options or operands are speci- + fied, it reports the settings of a subset of characteristics as well as + additional ones if they differ from their default values. Otherwise it + modifies the terminal state according to the specified arguments. Some + combinations of arguments are mutually exclusive on some terminal types. + + The following options are available: + + --aa Display all the current settings for the terminal to standard + output as per IEEE Std1003.2 (``POSIX''). + + --ee Display all the current settings for the terminal to standard + output in the traditional BSD ``all'' and ``everything'' formats. + + --ff Open and use the terminal named by _f_i_l_e rather than using stan- + dard input. The file is opened using the O_NONBLOCK flag of + ooppeenn(), making it possible to set or display settings on a termi- + nal that might otherwise block on the open. + + --gg Display all the current settings for the terminal to standard + output in a form that may be used as an argument to a subsequent + invocation of ssttttyy to restore the current terminal state as per + IEEE Std1003.2 (``POSIX''). + + The following arguments are available to set the terminal characteris- + tics: + + CCoonnttrrooll MMooddeess:: + + Control mode flags affect hardware characteristics associated with the + terminal. This corresponds to the c_cflag in the termios structure. + + ppaarreennbb (--ppaarreennbb) + Enable (disable) parity generation and detection. + + ppaarroodddd (--ppaarroodddd) + Select odd (even) parity. + + ccss55 ccss66 ccss77 ccss88 + Select character size, if possible. + + _n_u_m_b_e_r Set terminal baud rate to the number given, if possible. If + the baud rate is set to zero, modem control is no longer as- + serted. + + iissppeeeedd _n_u_m_b_e_r + Set terminal input baud rate to the number given, if possi- + ble. If the input baud rate is set to zero, the input baud + rate is set to the value of the output baud rate. + + oossppeeeedd _n_u_m_b_e_r + Set terminal output baud rate to the number given, if possi- + ble. If the output baud rate is set to zero, modem control + + + + is no longer asserted. + + ssppeeeedd _n_u_m_b_e_r + This sets both iissppeeeedd and oossppeeeedd to _n_u_m_b_e_r. + + hhuuppccll (--hhuuppccll) + Stop asserting modem control (do not stop asserting modem + control) on last close. + + hhuupp (--hhuupp) Same as hupcl (--hhuuppccll). + + ccssttooppbb (--ccssttooppbb) + Use two (one) stop bits per character. + + ccrreeaadd (--ccrreeaadd) + Enable (disable) the receiver. + + ccllooccaall (--ccllooccaall) + Assume a line without (with) modem control. + + ccrrttssccttss (--ccrrttssccttss) + Enable RTS/CTS flow control. + + IInnppuutt MMooddeess:: + This corresponds to the c_iflag in the termios structure. + + iiggnnbbrrkk (--iiggnnbbrrkk) + Ignore (do not ignore) break on input. + + bbrrkkiinntt (--bbrrkkiinntt) + Signal (do not signal) INTR on break. + + iiggnnppaarr (--iiggnnppaarr) + Ignore (do not ignore) parity errors. + + ppaarrmmrrkk (--ppaarrmmrrkk) + Mark (do not mark) parity errors. + + iinnppcckk (--iinnppcckk) + Enable (disable) input parity checking. + + iissttrriipp (--iissttrriipp) + Strip (do not strip) input characters to seven bits. + + iinnllccrr (--iinnllccrr) + Map (do not map) NL to CR on input. + + iiggnnccrr (--iiggnnccrr) + Ignore (do not ignore) CR on input. + + iiccrrnnll (--iiccrrnnll) + Map (do not map) CR to NL on input. + + iixxoonn (--iixxoonn) + Enable (disable) START/STOP output control. Output from the + system is stopped when the system receives STOP and started + when the system receives START, or if iixxaannyy is set, any char- + acter restarts output. + + iixxooffff (--iixxooffff) + Request that the system send (not send) START/STOP characters + when the input queue is nearly empty/full. + + iixxaannyy (--iixxaannyy) + + Allow any character (allow only START) to restart output. + + iimmaaxxbbeell (--iimmaaxxbbeell) + The system imposes a limit of MAX_INPUT (currently 255) char- + acters in the input queue. If iimmaaxxbbeell is set and the input + queue limit has been reached, subsequent input causes the + system to send an ASCII BEL character to the output queue + (the terminal beeps at you). Otherwise, if iimmaaxxbbeell is unset + and the input queue is full, the next input character causes + the entire input and output queues to be discarded. + + OOuuttppuutt MMooddeess:: + This corresponds to the c_oflag of the termios structure. + + ooppoosstt (--ooppoosstt) + Post-process output (do not post-process output; ignore all + other output modes). + + oonnllccrr (--oonnllccrr) + Map (do not map) NL to on output. + + ooxxttaabbss (--ooxxttaabbss) + Expand (do not expand) tabs to spaces on output. + + LLooccaall MMooddeess:: + + Local mode flags (lflags) affect various and sundry characteristics of + terminal processing. Historically the term "local" pertained to new job + control features implemented by Jim Kulp on a Pdp 11/70 at IIASA. Later + the driver ran on the first VAX at Evans Hall, UC Berkeley, where the job + control details were greatly modified but the structure definitions and + names remained essentially unchanged. The second interpretation of the + 'l' in lflag is ``line discipline flag'' which corresponds to the _c___l_f_l_a_g + of the _t_e_r_m_i_o_s structure. + + iissiigg (--iissiigg) + Enable (disable) the checking of characters against the spe- + cial control characters INTR, QUIT, and SUSP. + + iiccaannoonn (--iiccaannoonn) + Enable (disable) canonical input (ERASE and KILL processing). + + iieexxtteenn (--iieexxtteenn) + Enable (disable) any implementation defined special control + characters not currently controlled by icanon, isig, or ixon. + + eecchhoo (--eecchhoo) + Echo back (do not echo back) every character typed. + + eecchhooee (--eecchhooee) + The ERASE character shall (shall not) visually erase the last + character in the current line from the display, if possible. + + eecchhookk (--eecchhookk) + Echo (do not echo) NL after KILL character. + + eecchhookkee (--eecchhookkee) + The KILL character shall (shall not) visually erase the the + current line from the display, if possible. + + eecchhoonnll (--eecchhoonnll) + Echo (do not echo) NL, even if echo is disabled. + + eecchhooccttll (--eecchhooccttll) + If eecchhooccttll is set, echo control characters as ^X. Otherwise + + control characters echo as themselves. + + eecchhoopprrtt (--eecchhoopprrtt) + For printing terminals. If set, echo erased characters back- + wards within ``\'' and ``/''. Otherwise, disable this fea- + ture. + + nnooffllsshh (--nnooffllsshh) + Disable (enable) flush after INTR, QUIT, SUSP. + + ttoossttoopp (--ttoossttoopp) + Send (do not send) SIGTTOU for background output. This caus- + es background jobs to stop if they attempt terminal output. + + aallttwweerraassee (--aallttwweerraassee) + Use (do not use) an alternate word erase algorithm when pro- + cessing WERASE characters. This alternate algorithm consid- + ers sequences of alphanumeric/underscores as words. It also + skips the first preceding character in its classification (as + a convenience since the one preceding character could have + been erased with simply an ERASE character.) + + mmddmmbbuuff (--mmddmmbbuuff) + If set, flow control output based on condition of Carrier De- + tect. Otherwise writes return an error if Carrier Detect is + low (and Carrier is not being ignored with the CLOCAL flag.) + + fflluusshhoo (--fflluusshhoo) + Indicates output is (is not) being discarded. + + ppeennddiinn (--ppeennddiinn) + Indicates input is (is not) pending after a switch from non- + canonical to canonical mode and will be re-input when a read + becomes pending or more input arrives. + + CCoonnttrrooll CChhaarraacctteerrss:: + + _c_o_n_t_r_o_l_-_c_h_a_r_a_c_t_e_r _s_t_r_i_n_g + Set _c_o_n_t_r_o_l_-_c_h_a_r_a_c_t_e_r to _s_t_r_i_n_g. If string is a single char- + acter, the control character is set to that character. If + string is the two character sequence "^-" or the string "un- + def" the control character is disabled (i.e. set to + {_POSIX_VDISABLE}.) + + Recognized control-characters: + + + control- + character Subscript Description + _________ _________ _______________ + eof VEOF EOF character + eol VEOL EOL character + eol2 VEOL2 EOL2 character + erase VERASE ERASE character + werase VWERASE WERASE character + intr VINTR INTR character + kill VKILL KILL character + quit VQUIT QUIT character + susp VSUSP SUSP character + start VSTART START character + stop VSTOP STOP character + dsusp VDSUSP DSUSP character + lnext VLNEXT LNEXT character + reprint VREPRINT REPRINT character + status VSTATUS STATUS character + + + mmiinn _n_u_m_b_e_r + + ttiimmee _n_u_m_b_e_r + Set the value of min or time to number. MIN and TIME are + used in Non-Canonical mode input processing (-icanon). + + CCoommbbiinnaattiioonn MMooddeess:: + + _s_a_v_e_d _s_e_t_t_i_n_g_s + Set the current terminal characteristics to the saved set- + tings produced by the --gg option. + + eevveennpp or ppaarriittyy + Enable parenb and cs7; disable parodd. + + ooddddpp Enable parenb, cs7, and parodd. + + --ppaarriittyy, --eevveennpp, --ooddddpp + Disable parenb, and set cs8. + + nnll (--nnll) Enable (disable) icrnl. In addition -nl unsets inlcr and + igncr. + + eekk Reset ERASE and KILL characters back to system defaults. + + ssaannee Resets all modes to reasonable values for interactive termi- + nal use. + + ttttyy Set the line discipline to the standard terminal line disci- + pline TTYDISC. + + ccrrtt (--ccrrtt) Set (disable) all modes suitable for a CRT display device. + + kkeerrnniinnffoo (--kkeerrnniinnffoo) + Enable (disable) the system generated status line associated + with processing a STATUS character (usually set to ^T). The + status line consists of the system load average, the current + command name, its process ID, the event the process is wait- + ing on (or the status of the process), the user and system + times, percent cpu, and current memory usage. + + ccoolluummnnss _n_u_m_b_e_r + The terminal size is recorded as having _n_u_m_b_e_r columns. + + ccoollss _n_u_m_b_e_r + is an alias for ccoolluummnnss.. + + rroowwss _n_u_m_b_e_r + The terminal size is recorded as having _n_u_m_b_e_r rows. + + ddeecc Set modes suitable for users of Digital Equipment Corporation + systems ( ERASE, KILL, and INTR characters are set to ^?, ^U, + and ^C; ixany is disabled, and crt is enabled.) + + eexxttpprroocc (--eexxttpprroocc) + If set, this flag indicates that some amount of terminal pro- + cessing is being performed by either the terminal hardware or + by the remote side connected to a pty. + + rraaww (--rraaww) If set, change the modes of the terminal so that no input or + output processing is performed. If unset, change the modes of + the terminal to some reasonable state that performs input and + output processing. Note that since the terminal driver no + longer has a single RAW bit, it is not possible to intuit + what flags were set prior to setting rraaww. This means that un- + setting rraaww may not put back all the setting that were previ- + ously in effect. To set the terminal into a raw state and + then accurately restore it, the following shell code is rec- + ommended: + + save_state=$(stty -g) + stty raw + ... + stty "$save_state" + + + ssiizzee The size of the terminal is printed as two numbers on a sin- + gle line, first rows, then columns. + + CCoommppaattiibbiilliittyy MMooddeess:: + + These modes remain for compatibility with the previous version of the + stty command. + + aallll Reports all the terminal modes as with ssttttyy --aa except that + the control characters are printed in a columnar format. + + eevveerryytthhiinngg Same as aallll. + + ccooookkeedd Same as ssaannee. + + ccbbrreeaakk If set, enables bbrrkkiinntt, iixxoonn, iimmaaxxbbeell, ooppoosstt, iissiigg, iieexxtteenn, + and --iiccaannoonn. If unset, same as ssaannee. + + nneeww Same as ttttyy. + + oolldd Same as ttttyy. + + nneewwccrrtt (--nneewwccrrtt) + Same as ccrrtt. + + ppaassss88 The converse of ppaarriittyy. + + ttaannddeemm (--ttaannddeemm) + Same as iixxooffff. + + ddeeccccttllqq (--ddeeccccttllqq) + The converse of iixxaannyy. + + ccrrtteerraassee (--ccrrtteerraassee) + Same as eecchhooee. + + ccrrttbbss (--ccrrttbbss) + Same as eecchhooee. + + ccrrttkkiillll (--ccrrttkkiillll) + Same as eecchhookkee. + + ccttlleecchhoo (--ccttlleecchhoo) + Same as eecchhooccttll. + + pprrtteerraassee (--pprrtteerraassee) + Same as eecchhoopprrtt. + + lliittoouutt (--lliittoouutt) + The converse of ooppoosstt. + + ttaabbss (--ttaabbss) + The converse of ttaabbss. + + + bbrrkk _v_a_l_u_e Same as the control character eeooll. + + fflluusshh _v_a_l_u_e + Same as the control character ddiissccaarrdd. + + rrpprrnntt _v_a_l_u_e + Same as the control character rreepprriinntt. + + The ssttttyy utility exits with a value of 0 if successful, and >0 if an er- + ror occurs. + +SSEEEE AALLSSOO + termios(4) + +SSTTAANNDDAARRDDSS + The ssttttyy function is expected to be IEEE Std1003.2 (``POSIX'') compati- + ble. The flags --ee and --ff are extensions to the standard. + +4.4BSD June 1, 1994 7 diff --git a/usr/share/man/cat1/suspend.0 b/usr/share/man/cat1/suspend.0 new file mode 100644 index 0000000000..d6db503112 --- /dev/null +++ b/usr/share/man/cat1/suspend.0 @@ -0,0 +1,1456 @@ +CSH(1) BSD Reference Manual CSH(1) + +NNAAMMEE + ccsshh - a shell (command interpreter) with C-like syntax + +SSYYNNOOPPSSIISS + ccsshh [--bbcceeffiinnssttvvVVxxXX] [arg ...] + ccsshh [--ll] + +DDEESSCCRRIIPPTTIIOONN + The ccsshh is a command language interpreter incorporating a history mecha- + nism (see HHiissttoorryy SSuubbssttiittuuttiioonnss), job control facilities (see JJoobbss), in- + teractive file name and user name completion (see FFiillee NNaammee CCoommpplleettiioonn), + and a C-like syntax. It is used both as an interactive login shell and a + shell script command processor. + + AArrgguummeenntt lliisstt pprroocceessssiinngg + If the first argument (argument 0) to the shell is `--', then this is a + login shell. A login shell also can be specified by invoking the shell + with the `--ll' flag as the only argument. + + The rest of the flag arguments are interpreted as follows: + + --bb This flag forces a ``break'' from option processing, causing any + further shell arguments to be treated as non-option arguments. + The remaining arguments will not be interpreted as shell options. + This may be used to pass options to a shell script without confu- + sion or possible subterfuge. The shell will not run a set-user ID + script without this option. + + --cc Commands are read from the (single) following argument which must + be present. Any remaining arguments are placed in _a_r_g_v. + + --ee The shell exits if any invoked command terminates abnormally or + yields a non-zero exit status. + + --ff The shell will start faster, because it will neither search for + nor execute commands from the file _._c_s_h_r_c in the invoker's home + directory. + + --ii The shell is interactive and prompts for its top-level input, even + if it appears not to be a terminal. Shells are interactive with- + out this option if their inputs and outputs are terminals. + + --ll The shell is a login shell (only applicable if --ll is the only flag + specified). + + --nn Commands are parsed, but not executed. This aids in syntactic + checking of shell scripts. + + --ss Command input is taken from the standard input. + + --tt A single line of input is read and executed. A `\' may be used to + escape the newline at the end of this line and continue onto an- + other line. + + --vv Causes the _v_e_r_b_o_s_e variable to be set, with the effect that com- + mand input is echoed after history substitution. + + --xx Causes the _e_c_h_o variable to be set, so that commands are echoed + immediately before execution. + + --VV Causes the _v_e_r_b_o_s_e variable to be set even before _._c_s_h_r_c is exe- + + + cuted. + + --XX Is to --xx as --VV is to --vv. + + After processing of flag arguments, if arguments remain but none of the + --cc, --ii, --ss, or --tt options were given, the first argument is taken as the + name of a file of commands to be executed. The shell opens this file, + and saves its name for possible resubstitution by `$0'. Since many sys- + tems use either the standard version 6 or version 7 shells whose shell + scripts are not compatible with this shell, the shell will execute such a + `standard' shell if the first character of a script is not a `#', i.e., + if the script does not start with a comment. Remaining arguments ini- + tialize the variable _a_r_g_v. + + An instance of ccsshh begins by executing commands from the file + _/_e_t_c_/_c_s_h_._c_s_h_r_c and, if this is a login shell, _/_e_t_c_/_c_s_h_._l_o_g_i_n. It then ex- + ecutes commands from _._c_s_h_r_c in the _h_o_m_e directory of the invoker, and, if + this is a login shell, the file _._l_o_g_i_n in the same location. It is typi- + cal for users on crt's to put the command ``stty crt'' in their _._l_o_g_i_n + file, and to also invoke tset(1) there. + + In the normal case, the shell will begin reading commands from the termi- + nal, prompting with `% '. Processing of arguments and the use of the + shell to process files containing command scripts will be described lat- + er. + + The shell repeatedly performs the following actions: a line of command + input is read and broken into _w_o_r_d_s. This sequence of words is placed on + the command history list and parsed. Finally each command in the current + line is executed. + + When a login shell terminates it executes commands from the files _._l_o_g_o_u_t + in the user's _h_o_m_e directory and _/_e_t_c_/_c_s_h_._l_o_g_o_u_t. + + LLeexxiiccaall ssttrruuccttuurree + The shell splits input lines into words at blanks and tabs with the fol- + lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form sepa- + rate words. If doubled in `&&', `||', `<<' or `>>' these pairs form sin- + gle words. These parser metacharacters may be made part of other words, + or prevented their special meaning, by preceding them with `\'. A new- + line preceded by a `\' is equivalent to a blank. + + Strings enclosed in matched pairs of quotations, `'', ``' or `"', form + parts of a word; metacharacters in these strings, including blanks and + tabs, do not form separate words. These quotations have semantics to be + described later. Within pairs of `'' or `"' characters, a newline pre- + ceded by a `\' gives a true newline character. + + When the shell's input is not a terminal, the character `#' introduces a + comment that continues to the end of the input line. It is prevented + this special meaning when preceded by `\' and in quotations using ``', + `'', and `"'. + + CCoommmmaannddss + A simple command is a sequence of words, the first of which specifies the + command to be executed. A simple command or a sequence of simple com- + mands separated by `|' characters forms a pipeline. The output of each + command in a pipeline is connected to the input of the next. Sequences + of pipelines may be separated by `;', and are then executed sequentially. + A sequence of pipelines may be executed without immediately waiting for + it to terminate by following it with an `&'. + + Any of the above may be placed in `(' `)' to form a simple command (that + may be a component of a pipeline, etc.). It is also possible to separate + pipelines with `||' or `&&' showing, as in the C language, that the sec- + ond is to be executed only if the first fails or succeeds respectively. + (See _E_x_p_r_e_s_s_i_o_n_s.) + + JJoobbss + The shell associates a _j_o_b with each pipeline. It keeps a table of cur- + rent jobs, printed by the _j_o_b_s command, and assigns them small integer + numbers. When a job is started asynchronously with `&', the shell prints + a line that looks like: + + [1] 1234 + + showing that the job which was started asynchronously was job number 1 + and had one (top-level) process, whose process id was 1234. + + If you are running a job and wish to do something else you may hit the + key ^^ZZ (control-Z) which sends a STOP signal to the current job. The + shell will then normally show that the job has been `Stopped', and print + another prompt. You can then manipulate the state of this job, putting + it in the _b_a_c_k_g_r_o_u_n_d with the _b_g command, or run some other commands and + eventually bring the job back into the foreground with the _f_o_r_e_g_r_o_u_n_d + command _f_g. A ^^ZZ takes effect immediately and is like an interrupt in + that pending output and unread input are discarded when it is typed. + There is another special key ^^YY that does not generate a STOP signal un- + til a program attempts to read(2) it. This request can usefully be typed + ahead when you have prepared some commands for a job that you wish to + stop after it has read them. + + A job being run in the background will stop if it tries to read from the + terminal. Background jobs are normally allowed to produce output, but + this can be disabled by giving the command ``stty tostop''. If you set + this tty option, then background jobs will stop when they try to produce + output like they do when they try to read input. + + There are several ways to refer to jobs in the shell. The character `%' + introduces a job name. If you wish to refer to job number 1, you can + name it as `%1'. Just naming a job brings it to the foreground; thus + `%1' is a synonym for `fg %1', bringing job number 1 back into the fore- + ground. Similarly saying `%1 &' resumes job number 1 in the background. + Jobs can also be named by prefixes of the string typed in to start them, + if these prefixes are unambiguous, thus `%ex' would normally restart a + suspended ex(1) job, if there were only one suspended job whose name be- + gan with the string `ex'. It is also possible to say `%?string' which + specifies a job whose text contains _s_t_r_i_n_g, if there is only one such + job. + + The shell maintains a notion of the current and previous jobs. In output + about jobs, the current job is marked with a `+' and the previous job + with a `-'. The abbreviation `%+' refers to the current job and `%-' + refers to the previous job. For close analogy with the syntax of the + _h_i_s_t_o_r_y mechanism (described below), `%%' is also a synonym for the cur- + rent job. + + The job control mechanism requires that the stty(1) option nneeww be set. It + is an artifact from a _n_e_w implementation of the tty driver that allows + generation of interrupt characters from the keyboard to tell jobs to + stop. See stty(1) for details on setting options in the new tty driver. + + SSttaattuuss rreeppoorrttiinngg + This shell learns immediately whenever a process changes state. It nor- + mally informs you whenever a job becomes blocked so that no further + progress is possible, but only just before it prints a prompt. This is + done so that it does not otherwise disturb your work. If, however, you + set the shell variable _n_o_t_i_f_y, the shell will notify you immediately of + changes of status in background jobs. There is also a shell command + _n_o_t_i_f_y that marks a single process so that its status changes will be im- + mediately reported. By default _n_o_t_i_f_y marks the current process; simply + say `notify' after starting a background job to mark it. + + When you try to leave the shell while jobs are stopped, you will be + warned that `You have stopped jobs.' You may use the _j_o_b_s command to see + what they are. If you do this or immediately try to exit again, the + shell will not warn you a second time, and the suspended jobs will be + terminated. + + FFiillee NNaammee CCoommpplleettiioonn + When the file name completion feature is enabled by setting the shell + variable _f_i_l_e_c (see sseett), ccsshh will interactively complete file names and + user names from unique prefixes, when they are input from the terminal + followed by the escape character (the escape key, or control-[) For exam- + ple, if the current directory looks like + + DSC.OLD bin cmd lib xmpl.c + DSC.NEW chaosnet cmtest mail xmpl.o + bench class dev mbox xmpl.out + + and the input is + + % vi ch + + ccsshh will complete the prefix ``ch'' to the only matching file name + ``chaosnet'', changing the input line to + + % vi chaosnet + + However, given + + % vi D + + ccsshh will only expand the input to + + % vi DSC. + + and will sound the terminal bell to indicate that the expansion is incom- + plete, since there are two file names matching the prefix ``D''. + + If a partial file name is followed by the end-of-file character (usually + control-D), then, instead of completing the name, ccsshh will list all file + names matching the prefix. For example, the input + + % vi D + + causes all files beginning with ``D'' to be listed: + + DSC.NEW DSC.OLD + + while the input line remains unchanged. + + The same system of escape and end-of-file can also be used to expand par- + tial user names, if the word to be completed (or listed) begins with the + character ``~''. For example, typing + + cd ~ro + + may produce the expansion + + cd ~root + + The use of the terminal bell to signal errors or multiple matches can be + inhibited by setting the variable _n_o_b_e_e_p. + + Normally, all files in the particular directory are candidates for name + completion. Files with certain suffixes can be excluded from considera- + tion by setting the variable _f_i_g_n_o_r_e to the list of suffixes to be ig- + nored. Thus, if _f_i_g_n_o_r_e is set by the command + + % set fignore = (.o .out) + + then typing + + % vi x + + would result in the completion to + + % vi xmpl.c + + ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple- + tion possible requires not ignoring these suffixes, then they are not ig- + nored. In addition, _f_i_g_n_o_r_e does not affect the listing of file names by + control-D. All files are listed regardless of their suffixes. + + SSuubbssttiittuuttiioonnss + We now describe the various transformations the shell performs on the in- + put in the order in which they occur. + + HHiissttoorryy ssuubbssttiittuuttiioonnss + History substitutions place words from previous command input as portions + of new commands, making it easy to repeat commands, repeat arguments of a + previous command in the current command, or fix spelling mistakes in the + previous command with little typing and a high degree of confidence. + History substitutions begin with the character `!' and may begin _a_n_y_w_h_e_r_e + in the input stream (with the proviso that they ddoo nnoott nest.) This `!' + may be preceded by a `\' to prevent its special meaning; for convenience, + an `!' is passed unchanged when it is followed by a blank, tab, newline, + `=' or `('. (History substitutions also occur when an input line begins + with `^'. This special abbreviation will be described later.) Any input + line that contains history substitution is echoed on the terminal before + it is executed as it could have been typed without history substitution. + + Commands input from the terminal that consist of one or more words are + saved on the history list. The history substitutions reintroduce se- + quences of words from these saved commands into the input stream. The + size of the history list is controlled by the _h_i_s_t_o_r_y variable; the pre- + vious command is always retained, regardless of the value of the history + variable. Commands are numbered sequentially from 1. + + For definiteness, consider the following output from the _h_i_s_t_o_r_y command: + + 9 write michael + 10 ex write.c + 11 cat oldwrite.c + 12 diff *write.c + + The commands are shown with their event numbers. It is not usually nec- + essary to use event numbers, but the current event number can be made + part of the _p_r_o_m_p_t by placing an `!' in the prompt string. + + With the current event 13 we can refer to previous events by event number + `!11', relatively as in `!-2' (referring to the same event), by a prefix + of a command word as in `!d' for event 12 or `!wri' for event 9, or by a + string contained in a word in the command as in `!?mic?' also referring + to event 9. These forms, without further change, simply reintroduce the + words of the specified events, each separated by a single blank. As a + special case, `!!' refers to the previous command; thus `!!' alone is a + _r_e_d_o. + + To select words from an event we can follow the event specification by a + `:' and a designator for the desired words. The words of an input line + are numbered from 0, the first (usually command) word being 0, the second + word (first argument) being 1, etc. The basic word designators are: + + 0 first (command) word + _n _n'th argument + ^ first argument, i.e., `1' + $ last argument + % word matched by (immediately preceding) ?_s? search + _x_-_y range of words + _-_y abbreviates _`_0_-_y_' + * abbreviates `^-$', or nothing if only 1 word in event + _x_* abbreviates _`_x_-_$_' + _x_- like _`_x_*_' but omitting word `$' + + The `:' separating the event specification from the word designator can + be omitted if the argument selector begins with a `^', `$', `*' `-' or + `%'. After the optional word designator can be placed a sequence of mod- + ifiers, each preceded by a `:'. The following modifiers are defined: + + h Remove a trailing pathname component, leaving the head. + r Remove a trailing `.xxx' component, leaving the root name. + e Remove all but the extension `.xxx' part. + s_/_l_/_r_/ Substitute _l for _r + t Remove all leading pathname components, leaving the tail. + & Repeat the previous substitution. + g Apply the change once on each word, prefixing the above, + e.g., `g&'. + a Apply the change as many times as possible on a single + word, prefixing the above. It can be used together with `g' + to apply a substitution globally. + p Print the new command line but do not execute it. + q Quote the substituted words, preventing further substitu- + tions. + x Like q, but break into words at blanks, tabs and newlines. + + Unless preceded by a `g' the change is applied only to the first modifi- + able word. With substitutions, it is an error for no word to be applica- + ble. + + The left hand side of substitutions are not regular expressions in the + sense of the editors, but instead strings. Any character may be used as + the delimiter in place of `/'; a `\' quotes the delimiter into the _l and + _r strings. The character `&' in the right hand side is replaced by the + text from the left. A `\' also quotes `&'. A null _l (`//') uses the + previous string either from an _l or from a contextual scan string _s in + `!?_s\?'. The trailing delimiter in the substitution may be omitted if a + newline follows immediately as may the trailing `?' in a contextual scan. + + A history reference may be given without an event specification, e.g., + `!$'. Here, the reference is to the previous command unless a previous + history reference occurred on the same line in which case this form re- + peats the previous reference. Thus `!?foo?^ !$' gives the first and last + arguments from the command matching `?foo?'. + + A special abbreviation of a history reference occurs when the first non- + blank character of an input line is a `^'. This is equivalent to `!:s^' + providing a convenient shorthand for substitutions on the text of the + previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ- + ous command. Finally, a history substitution may be surrounded with `{' + and `}' if necessary to insulate it from the characters that follow. + Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', + while `!la' would look for a command starting with `la'. + + QQuuoottaattiioonnss wwiitthh '' aanndd "" + The quotation of strings by `'' and `"' can be used to prevent all or + some of the remaining substitutions. Strings enclosed in `'' are pre- + vented any further interpretation. Strings enclosed in `"' may be ex- + panded as described below. + + In both cases the resulting text becomes (all or part of) a single word; + only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_u_t_i_o_n below) does a `"' + quoted string yield parts of more than one word; `'' quoted strings never + do. + + AAlliiaass ssuubbssttiittuuttiioonn + The shell maintains a list of aliases that can be established, displayed + and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s commands. After a command line is + scanned, it is parsed into distinct commands and the first word of each + command, left-to-right, is checked to see if it has an alias. If it + does, then the text that is the alias for that command is reread with the + history mechanism available as though that command were the previous in- + put line. The resulting words replace the command and argument list. If + no reference is made to the history list, then the argument list is left + unchanged. + + Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to + `ls -l /usr', the argument list here being undisturbed. Similarly if the + alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map + to `grep bill /etc/passwd'. + + If an alias is found, the word transformation of the input text is per- + formed and the aliasing process begins again on the reformed input line. + Looping is prevented if the first word of the new text is the same as the + old by flagging it to prevent further aliasing. Other loops are detected + and cause an error. + + Note that the mechanism allows aliases to introduce parser metasyntax. + Thus, we can `alias print 'pr \!* | lpr'' to make a command that _p_r's its + arguments to the line printer. + + VVaarriiaabbllee ssuubbssttiittuuttiioonn + The shell maintains a set of variables, each of which has as value a list + of zero or more words. Some of these variables are set by the shell or + referred to by it. For instance, the _a_r_g_v variable is an image of the + shell's argument list, and words of this variable's value are referred to + in special ways. + + The values of variables may be displayed and changed by using the _s_e_t and + _u_n_s_e_t commands. Of the variables referred to by the shell a number are + toggles; the shell does not care what their value is, only whether they + are set or not. For instance, the _v_e_r_b_o_s_e variable is a toggle that + causes command input to be echoed. The setting of this variable results + from the --vv command line option. + + Other operations treat variables numerically. The `@' command permits + numeric calculations to be performed and the result assigned to a vari- + able. Variable values are, however, always represented as (zero or more) + strings. For the purposes of numeric operations, the null string is con- + sidered to be zero, and the second and additional words of multiword val- + ues are ignored. + + After the input line is aliased and parsed, and before each command is + executed, variable substitution is performed keyed by `$' characters. + This expansion can be prevented by preceding the `$' with a `\' except + within `"'s where it _a_l_w_a_y_s occurs, and within `''s where it _n_e_v_e_r oc- + curs. Strings quoted by ``' are interpreted later (see CCoommmmaanndd + ssuubbssttiittuuttiioonn below) so `$' substitution does not occur there until later, + if at all. A `$' is passed unchanged if followed by a blank, tab, or + end-of-line. + + Input/output redirections are recognized before variable expansion, and + are variable expanded separately. Otherwise, the command name and entire + argument list are expanded together. It is thus possible for the first + (command) word (to this point) to generate more than one word, the first + of which becomes the command name, and the rest of which become argu- + ments. + + Unless enclosed in `"' or given the `:q' modifier the results of variable + substitution may eventually be command and filename substituted. Within + `"', a variable whose value consists of multiple words expands to a (por- + tion of) a single word, with the words of the variables value separated + by blanks. When the `:q' modifier is applied to a substitution the vari- + able will expand to multiple words with each word separated by a blank + and quoted to prevent later command or filename substitution. + + The following metasequences are provided for introducing variable values + into the shell input. Except as noted, it is an error to reference a + variable that is not set. + + $name + ${name} + Are replaced by the words of the value of variable _n_a_m_e, + each separated by a blank. Braces insulate _n_a_m_e from fol- + lowing characters that would otherwise be part of it. + Shell variables have names consisting of up to 20 letters + and digits starting with a letter. The underscore charac- + ter is considered a letter. If _n_a_m_e is not a shell vari- + able, but is set in the environment, then that value is re- + turned (but : modifiers and the other forms given below are + not available here). + $name[selector] + ${name[selector] } + May be used to select only some of the words from the value + of _n_a_m_e. The selector is subjected to `$' substitution and + may consist of a single number or two numbers separated by + a `-'. The first word of a variables value is numbered + `1'. If the first number of a range is omitted it defaults + to `1'. If the last number of a range is omitted it de- + faults to `$#name'. The selector `*' selects all words. + It is not an error for a range to be empty if the second + argument is omitted or in range. + $#name + ${#name} + Gives the number of words in the variable. This is useful + for later use in a `$argv[selector]'. + $0 Substitutes the name of the file from which command input + is being read. An error occurs if the name is not known. + $number + ${number} + Equivalent to `$argv[number]'. + $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', + `:r', `:q' and `:x' may be applied to the substitutions + above as may `:gh', `:gt' and `:gr'. If braces `{' '}' ap- + pear in the command form then the modifiers must appear + within the braces. The current implementation allows only + one `:' modifier on each `$' expansion. + + The following substitutions may not be modified with `:' modifiers. + $?name + ${?name} + Substitutes the string `1' if name is set, `0' if it is + not. + $?0 Substitutes `1' if the current input filename is known, `0' + if it is not. + $$ Substitute the (decimal) process number of the (parent) + shell. + $! Substitute the (decimal) process number of the last back- + ground process started by this shell. + $< Substitutes a line from the standard input, with no further + interpretation. It can be used to read from the keyboard + in a shell script. + + CCoommmmaanndd aanndd ffiilleennaammee ssuubbssttiittuuttiioonn + The remaining substitutions, command and filename substitution, are ap- + plied selectively to the arguments of builtin commands. By selectively, + we mean that portions of expressions which are not evaluated are not sub- + jected to these expansions. For commands that are not internal to the + shell, the command name is substituted separately from the argument list. + This occurs very late, after input-output redirection is performed, and + in a child of the main shell. + + CCoommmmaanndd ssuubbssttiittuuttiioonn + Command substitution is shown by a command enclosed in ``'. The output + from such a command is normally broken into separate words at blanks, + tabs and newlines, with null words being discarded; this text then re- + places the original string. Within `"'s, only newlines force new words; + blanks and tabs are preserved. + + In any case, the single final newline does not force a new word. Note + that it is thus possible for a command substitution to yield only part of + a word, even if the command outputs a complete line. + + FFiilleennaammee ssuubbssttiittuuttiioonn + If a word contains any of the characters `*', `?', `[' or `{' or begins + with the character `~', then that word is a candidate for filename sub- + stitution, also known as `globbing'. This word is then regarded as a + pattern, and replaced with an alphabetically sorted list of file names + that match the pattern. In a list of words specifying filename substitu- + tion it is an error for no pattern to match an existing file name, but it + is not required for each pattern to match. Only the metacharacters `*', + `?' and `[' imply pattern matching, the characters `~' and `{' being more + akin to abbreviations. + + In matching filenames, the character `.' at the beginning of a filename + or immediately following a `/', as well as the character `/' must be + matched explicitly. The character `*' matches any string of characters, + including the null string. The character `?' matches any single charac- + ter. The sequence `[...]' matches any one of the characters enclosed. + Within `[...]', a pair of characters separated by `-' matches any charac- + ter lexically between the two (inclusive). + + The character `~' at the beginning of a filename refers to home directo- + ries. Standing alone, i.e., `~' it expands to the invokers home directo- + ry as reflected in the value of the variable _h_o_m_e. When followed by a + name consisting of letters, digits and `-' characters, the shell searches + for a user with that name and substitutes their home directory; thus + `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. + If the character `~' is followed by a character other than a letter or + `/' or does not appear at the beginning of a word, it is left undis- + turbed. + + The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to + right order is preserved, with results of matches being sorted separately + at a low level to preserve this order. This construct may be nested. + Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c + /usr/source/s1/ls.c' without chance of error if the home directory for + `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to + `../memo ../box ../mbox'. (Note that `memo' was not sorted with the re- + sults of the match to `*box'.) As a special case `{', `}' and `{}' are + passed undisturbed. + + IInnppuutt//oouuttppuutt + The standard input and the standard output of a command may be redirected + with the following syntax: + + + + < name Open file _n_a_m_e (which is first variable, command and file- + name expanded) as the standard input. + << word + Read the shell input up to a line that is identical to + _w_o_r_d. _W_o_r_d is not subjected to variable, filename or com- + mand substitution, and each input line is compared to _w_o_r_d + before any substitutions are done on the input line. Un- + less a quoting `\', `"', `' or ``' appears in _w_o_r_d, vari- + able and command substitution is performed on the interven- + ing lines, allowing `\' to quote `$', `\' and ``'. Com- + mands that are substituted have all blanks, tabs, and new- + lines preserved, except for the final newline which is + dropped. The resultant text is placed in an anonymous tem- + porary file that is given to the command as its standard + input. + > name + >! name + >& name + >&! name + The file _n_a_m_e is used as the standard output. If the file + does not exist then it is created; if the file exists, it + is truncated; its previous contents are lost. + + If the variable _n_o_c_l_o_b_b_e_r is set, then the file must not + exist or be a character special file (e.g., a terminal or + `/dev/null') or an error results. This helps prevent acci- + dental destruction of files. Here, the `!' forms can be + used to suppress this check. + + The forms involving `&' route the standard error output in- + to the specified file as well as the standard output. _N_a_m_e + is expanded in the same way as `<' input filenames are. + >> name + >>& name + >>! name + >>&! name + Uses file _n_a_m_e as the standard output; like `>' but places + output at the end of the file. If the variable _n_o_c_l_o_b_b_e_r + is set, then it is an error for the file not to exist un- + less one of the `!' forms is given. Otherwise similar to + `>'. + + A command receives the environment in which the shell was invoked as mod- + ified by the input-output parameters and the presence of the command in a + pipeline. Thus, unlike some previous shells, commands run from a file of + shell commands have no access to the text of the commands by default; in- + stead they receive the original standard input of the shell. The `<<' + mechanism should be used to present inline data. This permits shell com- + mand scripts to function as components of pipelines and allows the shell + to block read its input. Note that the default standard input for a com- + mand run detached is _n_o_t modified to be the empty file _/_d_e_v_/_n_u_l_l; instead + the standard input remains as the original standard input of the shell. + If this is a terminal and if the process attempts to read from the termi- + nal, then the process will block and the user will be notified (see _J_o_b_s + above). + + The standard error output may be directed through a pipe with the stan- + dard output. Simply use the form `|&' instead of just `|'. + + EExxpprreessssiioonnss + Several of the builtin commands (to be described later) take expressions, + in which the operators are similar to those of C, with the same prece- + dence. These expressions appear in the @@,, _e_x_i_t, _i_f, and _w_h_i_l_e commands. + The following operators are available: + + || && | ^ & == != =~ !~ <= >= < > << >> + - * / % + ! ~ ( ) + + Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' + `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in + groups, at the same level. The `==' `!=' `=~' and `!~' operators compare + their arguments as strings; all others operate on numbers. The operators + `=~' and `!~' are like `!=' and `==' except that the right hand side is a + _p_a_t_t_e_r_n (containing, e.g., `*'s, `?'s and instances of `[...]') against + which the left hand operand is matched. This reduces the need for use of + the _s_w_i_t_c_h statement in shell scripts when all that is really needed is + pattern matching. + + Strings that begin with `0' are considered octal numbers. Null or miss- + ing arguments are considered `0'. The result of all expressions are + strings, which represent decimal numbers. It is important to note that + no two components of an expression can appear in the same word; except + when adjacent to components of expressions that are syntactically signif- + icant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded + by spaces. + + Also available in expressions as primitive operands are command execu- + tions enclosed in `{' and `}' and file enquiries of the form --ll _n_a_m_e + where ll is one of: + + r read access + w write access + x execute access + e existence + o ownership + z zero size + f plain file + d directory + + The specified name is command and filename expanded and then tested to + see if it has the specified relationship to the real user. If the file + does not exist or is inaccessible then all enquiries return false, i.e., + `0'. Command executions succeed, returning true, i.e., `1', if the com- + mand exits with status 0, otherwise they fail, returning false, i.e., + `0'. If more detailed status information is required then the command + should be executed outside an expression and the variable _s_t_a_t_u_s exam- + ined. + + CCoonnttrrooll ffllooww + The shell contains several commands that can be used to regulate the flow + of control in command files (shell scripts) and (in limited but useful + ways) from terminal input. These commands all operate by forcing the + shell to reread or skip in its input and, because of the implementation, + restrict the placement of some of the commands. + + The ffoorreeaacchh, sswwiittcchh, and wwhhiillee statements, as well as the iiff--tthheenn--eellssee + form of the iiff statement require that the major keywords appear in a sin- + gle simple command on an input line as shown below. + + If the shell's input is not seekable, the shell buffers up input whenever + a loop is being read and performs seeks in this internal buffer to accom- + plish the rereading implied by the loop. (To the extent that this al- + lows, backward goto's will succeed on non-seekable inputs.) + + BBuuiillttiinn ccoommmmaannddss + Builtin commands are executed within the shell. If a builtin command oc- + curs as any component of a pipeline except the last then it is executed + in a subshell. + + aalliiaass + aalliiaass _n_a_m_e + + aalliiaass _n_a_m_e _w_o_r_d_l_i_s_t + The first form prints all aliases. The second form prints + the alias for name. The final form assigns the specified + _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is command and + filename substituted. _N_a_m_e is not allowed to be _a_l_i_a_s or + _u_n_a_l_i_a_s. + + aalllloocc Shows the amount of dynamic memory acquired, broken down + into used and free memory. With an argument shows the num- + ber of free and used blocks in each size category. The + categories start at size 8 and double at each step. This + command's output may vary across system types, since sys- + tems other than the VAX may use a different memory alloca- + tor. + + bbgg + bbgg %%_j_o_b _._._. + Puts the current or specified jobs into the background, + continuing them if they were stopped. + + bbrreeaakk Causes execution to resume after the eenndd of the nearest en- + closing ffoorreeaacchh or wwhhiillee. The remaining commands on the + current line are executed. Multi-level breaks are thus + possible by writing them all on one line. + + bbrreeaakkssww + Causes a break from a sswwiittcchh, resuming after the eennddssww. + + ccaassee _l_a_b_e_l: + A label in a sswwiittcchh statement as discussed below. + + ccdd + ccdd _n_a_m_e + cchhddiirr + cchhddiirr _n_a_m_e + Change the shell's working directory to directory _n_a_m_e. If + no argument is given then change to the home directory of + the user. If _n_a_m_e is not found as a subdirectory of the + current directory (and does not begin with `/', `./' or + `../'), then each component of the variable ccddppaatthh is + checked to see if it has a subdirectory _n_a_m_e. Finally, if + all else fails but _n_a_m_e is a shell variable whose value be- + gins with `/', then this is tried to see if it is a direc- + tory. + + ccoonnttiinnuuee + Continue execution of the nearest enclosing wwhhiillee or + ffoorreeaacchh. The rest of the commands on the current line are + executed. + + ddeeffaauulltt: + Labels the default case in a sswwiittcchh statement. The default + should come after all ccaassee labels. + + ddiirrss Prints the directory stack; the top of the stack is at the + left, the first directory in the stack being the current + directory. + + eecchhoo _w_o_r_d_l_i_s_t + eecchhoo --nn _w_o_r_d_l_i_s_t + The specified words are written to the shell's standard + output, separated by spaces, and terminated with a newline + unless the --nn option is specified. + + eellssee + + + eenndd + eennddiiff + eennddssww See the description of the ffoorreeaacchh, iiff, sswwiittcchh, and wwhhiillee + statements below. + + eevvaall _a_r_g _._._. + (As in sh(1).) The arguments are read as input to the + shell and the resulting command(s) executed in the context + of the current shell. This is usually used to execute com- + mands generated as the result of command or variable sub- + stitution, since parsing occurs before these substitutions. + See tset(1) for an example of using eevvaall. + + eexxeecc _c_o_m_m_a_n_d + The specified command is executed in place of the current + shell. + + eexxiitt + eexxiitt _(_e_x_p_r) + The shell exits either with the value of the ssttaattuuss vari- + able (first form) or with the value of the specified eexxpprr + (second form). + + ffgg + ffgg %%_j_o_b _._._. + Brings the current or specified jobs into the foreground, + continuing them if they were stopped. + + ffoorreeaacchh _n_a_m_e _(_w_o_r_d_l_i_s_t_) + ... + eenndd The variable nnaammee is successively set to each member of + wwoorrddlliisstt and the sequence of commands between this command + and the matching eenndd are executed. (Both ffoorreeaacchh and eenndd + must appear alone on separate lines.) The builtin command + ccoonnttiinnuuee may be used to continue the loop prematurely and + the builtin command bbrreeaakk to terminate it prematurely. + When this command is read from the terminal, the loop is + read once prompting with `?' before any statements in the + loop are executed. If you make a mistake typing in a loop + at the terminal you can rub it out. + + gglloobb _w_o_r_d_l_i_s_t + Like eecchhoo but no `\' escapes are recognized and words are + delimited by null characters in the output. Useful for + programs that wish to use the shell to filename expand a + list of words. + + ggoottoo _w_o_r_d + The specified wwoorrdd is filename and command expanded to + yield a string of the form `label'. The shell rewinds its + input as much as possible and searches for a line of the + form `label:' possibly preceded by blanks or tabs. Execu- + tion continues after the specified line. + + hhaasshhssttaatt + Print a statistics line showing how effective the internal + hash table has been at locating commands (and avoiding + eexxeecc's). An eexxeecc is attempted for each component of the + _p_a_t_h where the hash function indicates a possible hit, and + in each component that does not begin with a `/'. + + hhiissttoorryy + hhiissttoorryy _n + hhiissttoorryy --rr _n + hhiissttoorryy --hh _n + Displays the history event list; if _n is given only the _n + most recent events are printed. The --rr option reverses the + order of printout to be most recent first instead of oldest + first. The --hh option causes the history list to be printed + without leading numbers. This format produces files suit- + able for sourcing using the -h option to ssoouurrccee. + + iiff (_e_x_p_r) command + If the specified expression evaluates true, then the single + _c_o_m_m_a_n_d with arguments is executed. Variable substitution + on _c_o_m_m_a_n_d happens early, at the same time it does for the + rest of the iiff command. _C_o_m_m_a_n_d must be a simple command, + not a pipeline, a command list, or a parenthesized command + list. Input/output redirection occurs even if _e_x_p_r is + false, i.e., when command is nnoott executed (this is a bug). + + iiff (_e_x_p_r) tthheenn + ... + eellssee iiff (_e_x_p_r_2) tthheenn + ... + eellssee + ... + eennddiiff If the specified _e_x_p_r is true then the commands up to the + first eellssee are executed; otherwise if _e_x_p_r_2 is true then + the commands up to the second eellssee are executed, etc. Any + number of eellssee--iiff pairs are possible; only one eennddiiff is + needed. The eellssee part is likewise optional. (The words + eellssee and eennddiiff must appear at the beginning of input lines; + the iiff must appear alone on its input line or after an + eellssee.) + + jjoobbss + jjoobbss --ll + Lists the active jobs; the --ll option lists process id's in + addition to the normal information. + + kkiillll %%_j_o_b + kkiillll _p_i_d + kkiillll --ssiigg _p_i_d _._._. + kkiillll --ll + Sends either the TERM (terminate) signal or the specified + signal to the specified jobs or processes. Signals are ei- + ther given by number or by names (as given in + _/_u_s_r_/_i_n_c_l_u_d_e_/_s_i_g_n_a_l_._h_, stripped of the prefix ``SIG''). + The signal names are listed by ``kill -l''. There is no + default, just saying `kill' does not send a signal to the + current job. If the signal being sent is TERM (terminate) + or HUP (hangup), then the job or process will be sent a + CONT (continue) signal as well. + + lliimmiitt + lliimmiitt _r_e_s_o_u_r_c_e + lliimmiitt _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + lliimmiitt --hh + lliimmiitt --hh _r_e_s_o_u_r_c_e + lliimmiitt --hh _r_e_s_o_u_r_c_e _m_a_x_i_m_u_m_-_u_s_e + Limits the consumption by the current process and each pro- + cess it creates to not individually exceed _m_a_x_i_m_u_m_-_u_s_e on + the specified _r_e_s_o_u_r_c_e. If no _m_a_x_i_m_u_m_-_u_s_e is given, then + the current limit is printed; if no _r_e_s_o_u_r_c_e is given, then + all limitations are given. If the --hh flag is given, the + hard limits are used instead of the current limits. The + hard limits impose a ceiling on the values of the current + limits. Only the super-user may raise the hard limits, but + a user may lower or raise the current limits within the le- + gal range. + + Resources controllable currently include _c_p_u_t_i_m_e (the maxi- + mum number of cpu-seconds to be used by each process), + _f_i_l_e_s_i_z_e (the largest single file that can be created), + _d_a_t_a_s_i_z_e (the maximum growth of the data+stack region via + sbrk(2) beyond the end of the program text), _s_t_a_c_k_s_i_z_e (the + maximum size of the automatically-extended stack region), + and _c_o_r_e_d_u_m_p_s_i_z_e (the size of the largest core dump that + will be created). (.ne 1i + + The _m_a_x_i_m_u_m_-_u_s_e may be given as a (floating point or inte- + ger) number followed by a scale factor. For all limits + other than _c_p_u_t_i_m_e the default scale is `k' or `kilobytes' + (1024 bytes); a scale factor of `m' or `megabytes' may also + be used. For _c_p_u_t_i_m_e the default scale is `seconds'; a + scale factor of `m' for minutes or `h' for hours, or a time + of the form `mm:ss' giving minutes and seconds also may be + used. + + For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous pre- + fixes of the names suffice. + + llooggiinn Terminate a login shell, replacing it with an instance of + _/_b_i_n_/_l_o_g_i_n_. This is one way to log off, included for com- + patibility with sh(1). + + llooggoouutt Terminate a login shell. Especially useful if iiggnnoorreeeeooff is + set. + + nniiccee + nniiccee _+_n_u_m_b_e_r + nniiccee _c_o_m_m_a_n_d + nniiccee _+_n_u_m_b_e_r _c_o_m_m_a_n_d + The first form sets the scheduling priority for this shell + to 4. The second form sets the priority to the given + _n_u_m_b_e_r. The final two forms run command at priority 4 and + _n_u_m_b_e_r respectively. The greater the number, the less cpu + the process will get. The super-user may specify negative + priority by using `nice -number ...'. _C_o_m_m_a_n_d is always + executed in a sub-shell, and the restrictions placed on + commands in simple iiff statements apply. + + nnoohhuupp + nnoohhuupp _c_o_m_m_a_n_d + The first form can be used in shell scripts to cause + hangups to be ignored for the remainder of the script. The + second form causes the specified command to be run with + hangups ignored. All processes detached with `&' are ef- + fectively nnoohhuupp'ed. + + nnoottiiffyy + nnoottiiffyy %%_j_o_b _._._. + Causes the shell to notify the user asynchronously when the + status of the current or specified jobs change; normally + notification is presented before a prompt. This is auto- + matic if the shell variable nnoottiiffyy is set. + + oonniinnttrr + oonniinnttrr -- + oonniinnttrr _l_a_b_e_l + Control the action of the shell on interrupts. The first + form restores the default action of the shell on interrupts + which is to terminate shell scripts or to return to the + terminal command input level. The second form `onintr -' + causes all interrupts to be ignored. The final form causes + the shell to execute a `goto label' when an interrupt is + received or a child process terminates because it was in- + terrupted. + + + In any case, if the shell is running detached and inter- + rupts are being ignored, all forms of oonniinnttrr have no mean- + ing and interrupts continue to be ignored by the shell and + all invoked commands. Finally oonniinnttrr statements are ig- + nored in the system startup files where interrupts are dis- + abled (/etc/csh.cshrc, /etc/csh.login). + + ppooppdd + ppooppdd _+_n + Pops the directory stack, returning to the new top directo- + ry. With an argument `+ _n' discards the _n'th entry in the + stack. The members of the directory stack are numbered + from the top starting at 0. + + ppuusshhdd + ppuusshhdd _n_a_m_e + ppuusshhdd _n + With no arguments, ppuusshhdd exchanges the top two elements of + the directory stack. Given a _n_a_m_e argument, ppuusshhdd changes + to the new directory (ala ccdd) and pushes the old current + working directory (as in ccssww) onto the directory stack. + With a numeric argument, ppuusshhdd rotates the _n'th argument of + the directory stack around to be the top element and + changes to it. The members of the directory stack are num- + bered from the top starting at 0. + + rreehhaasshh Causes the internal hash table of the contents of the di- + rectories in the ppaatthh variable to be recomputed. This is + needed if new commands are added to directories in the ppaatthh + while you are logged in. This should only be necessary if + you add commands to one of your own directories, or if a + systems programmer changes the contents of a system direc- + tory. + + rreeppeeaatt _c_o_u_n_t _c_o_m_m_a_n_d + The specified _c_o_m_m_a_n_d which is subject to the same restric- + tions as the _c_o_m_m_a_n_d in the one line iiff statement above, is + executed _c_o_u_n_t times. I/O redirections occur exactly once, + even if _c_o_u_n_t is 0. + + sseett + sseett _n_a_m_e + sseett _n_a_m_e=word + sseett _n_a_m_e_[_i_n_d_e_x_]=word + sseett _n_a_m_e=(wordlist) + The first form of the command shows the value of all shell + variables. Variables that have other than a single word as + their value print as a parenthesized word list. The second + form sets _n_a_m_e to the null string. The third form sets + _n_a_m_e to the single _w_o_r_d. The fourth form sets the _i_n_d_e_x'th + component of _n_a_m_e to _w_o_r_d; this component must already ex- + ist. The final form sets _n_a_m_e to the list of words in + _w_o_r_d_l_i_s_t. The value is always command and filename expand- + ed. + + These arguments may be repeated to set multiple values in a + single set command. Note however, that variable expansion + happens for all arguments before any setting occurs. + + sseetteennvv + sseetteennvv _n_a_m_e + sseetteennvv _n_a_m_e _v_a_l_u_e + The first form lists all current environment variables. It + is equivalent to printenv(1). The last form sets the value + of environment variable _n_a_m_e to be _v_a_l_u_e, a single string. + The second form sets _n_a_m_e to an empty string. The most + commonly used environment variables USER, TERM, and PATH + are automatically imported to and exported from the ccsshh + variables _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use + sseetteennvv for these. + + sshhiifftt + sshhiifftt _v_a_r_i_a_b_l_e + The members of aarrggvv are shifted to the left, discarding + aarrggvv[1]. It is an error for aarrggvv not to be set or to have + less than one word as value. The second form performs the + same function on the specified variable. + + ssoouurrccee _n_a_m_e + ssoouurrccee --hh _n_a_m_e + The shell reads commands from _n_a_m_e. SSoouurrccee commands may be + nested; if they are nested too deeply the shell may run out + of file descriptors. An error in a ssoouurrccee at any level + terminates all nested ssoouurrccee commands. Normally input dur- + ing ssoouurrccee commands is not placed on the history list; the + -h option causes the commands to be placed on the history + list without being executed. + + ssttoopp + ssttoopp %%_j_o_b _._._. + Stops the current or specified jobs that are executing in + the background. + + ssuussppeenndd + Causes the shell to stop in its tracks, much as if it had + been sent a stop signal with ^^ZZ. This is most often used to + stop shells started by su(1). + + sswwiittcchh _(_s_t_r_i_n_g_) + ccaassee _s_t_r_1: + ... + bbrreeaakkssww + ... + ddeeffaauulltt: + ... + bbrreeaakkssww + eennddssww Each case label is successively matched against the speci- + fied _s_t_r_i_n_g which is first command and filename expanded. + The file metacharacters `*', `?' and `[...]' may be used + in the case labels, which are variable expanded. If none + of the labels match before the `default' label is found, + then the execution begins after the default label. Each + case label and the default label must appear at the begin- + ning of a line. The command bbrreeaakkssww causes execution to + continue after the eennddssww. Otherwise control may fall + through case labels and the default label as in C. If no + label matches and there is no default, execution continues + after the eennddssww. + + ttiimmee + ttiimmee _c_o_m_m_a_n_d + With no argument, a summary of time used by this shell and + its children is printed. If arguments are given the speci- + fied simple command is timed and a time summary as de- + scribed under the ttiimmee variable is printed. If necessary, + an extra shell is created to print the time statistic when + the command completes. + + uummaasskk + uummaasskk _v_a_l_u_e + The file creation mask is displayed (first form) or set to + the specified value (second form). The mask is given in + octal. Common values for the mask are 002 giving all ac- + cess to the group and read and execute access to others or + 022 giving all access except write access for users in the + group or others. + + uunnaalliiaass _p_a_t_t_e_r_n + All aliases whose names match the specified pattern are + discarded. Thus all aliases are removed by `unalias *'. + It is not an error for nothing to be uunnaalliiaasseedd. + + uunnhhaasshh Use of the internal hash table to speed location of execut- + ed programs is disabled. + + uunnlliimmiitt + uunnlliimmiitt _r_e_s_o_u_r_c_e + uunnlliimmiitt --hh + uunnlliimmiitt --hh _r_e_s_o_u_r_c_e + Removes the limitation on _r_e_s_o_u_r_c_e. If no _r_e_s_o_u_r_c_e is spec- + ified, then all _r_e_s_o_u_r_c_e limitations are removed. If --hh is + given, the corresponding hard limits are removed. Only the + super-user may do this. + + uunnsseett _p_a_t_t_e_r_n + All variables whose names match the specified pattern are + removed. Thus all variables are removed by `unset *'; this + has noticeably distasteful side-effects. It is not an er- + ror for nothing to be uunnsseett. + + uunnsseetteennvv _p_a_t_t_e_r_n + Removes all variables whose name match the specified pat- + tern from the environment. See also the sseetteennvv command + above and printenv(1). + + wwaaiitt Wait for all background jobs. If the shell is interactive, + then an interrupt can disrupt the wait. After the inter- + rupt, the shell prints names and job numbers of all jobs + known to be outstanding. + wwhhiicchh _c_o_m_m_a_n_d + Displays the resolved command that will be executed by the + shell. + + wwhhiillee _(_e_x_p_r_) + ... + eenndd While the specified expression evaluates non-zero, the com- + mands between the wwhhiillee and the matching eenndd are evaluated. + BBrreeaakk and ccoonnttiinnuuee may be used to terminate or continue the + loop prematurely. (The wwhhiillee and eenndd must appear alone on + their input lines.) Prompting occurs here the first time + through the loop as for the ffoorreeaacchh statement if the input + is a terminal. + + %%_j_o_b Brings the specified job into the foreground. + + %%_j_o_b && Continues the specified job in the background. + + @@ + @@_n_a_m_e= expr + @@_n_a_m_e_[_i_n_d_e_x_]= expr + The first form prints the values of all the shell vari- + ables. The second form sets the specified _n_a_m_e to the val- + ue of _e_x_p_r. If the expression contains `<', `>', `&' or `|' + then at least this part of the expression must be placed + within `(' `)'. The third form assigns the value of _e_x_p_r + to the _i_n_d_e_x'th argument of _n_a_m_e. Both _n_a_m_e and its + _i_n_d_e_x'th component must already exist. + + + The operators `*=', `+=', etc are available as in C. The space separat- + ing the name from the assignment operator is optional. Spaces are, how- + ever, mandatory in separating components of _e_x_p_r which would otherwise be + single words. + + Special postfix `++' and `--' operators increment and decrement _n_a_m_e re- + spectively, i.e., `@ i++'. + + PPrree--ddeeffiinneedd aanndd eennvviirroonnmmeenntt vvaarriiaabblleess + The following variables have special meaning to the shell. Of these, + _a_r_g_v, _c_w_d_, _h_o_m_e, _p_a_t_h_, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s are always set by the + shell. Except for _c_w_d and _s_t_a_t_u_s, this setting occurs only at initial- + ization; these variables will not then be modified unless done explicitly + by the user. + + The shell copies the environment variable USER into the variable _u_s_e_r, + TERM into _t_e_r_m, and HOME into _h_o_m_e, and copies these back into the envi- + ronment whenever the normal shell variables are reset. The environment + variable PATH is likewise handled; it is not necessary to worry about its + setting other than in the file _._c_s_h_r_c as inferior ccsshh processes will im- + port the definition of _p_a_t_h from the environment, and re-export it if you + then change it. + + aarrggvv Set to the arguments to the shell, it is from this variable + that positional parameters are substituted, i.e., `$1' is re- + placed by `$argv[1]', etc. + + ccddppaatthh Gives a list of alternate directories searched to find subdi- + rectories in _c_h_d_i_r commands. + + ccwwdd The full pathname of the current directory. + + eecchhoo Set when the --xx command line option is given. Causes each + command and its arguments to be echoed just before it is exe- + cuted. For non-builtin commands all expansions occur before + echoing. Builtin commands are echoed before command and file- + name substitution, since these substitutions are then done se- + lectively. + + ffiilleecc Enable file name completion. + + hhiissttcchhaarrss Can be given a string value to change the characters used in + history substitution. The first character of its value is + used as the history substitution character, replacing the de- + fault character `!'. The second character of its value re- + places the character `|^' in quick substitutions. + + hhiissttffiillee Can be set to the pathname where history is going to be + saved/restored. + + hhiissttoorryy Can be given a numeric value to control the size of the histo- + ry list. Any command that has been referenced in this many + events will not be discarded. Too large values of _h_i_s_t_o_r_y may + run the shell out of memory. The last executed command is al- + ways saved on the history list. + + hhoommee The home directory of the invoker, initialized from the envi- + ronment. The filename expansion of `_~' refers to this vari- + able. + + iiggnnoorreeeeooff If set the shell ignores end-of-file from input devices which + are terminals. This prevents shells from accidentally being + killed by control-D's. + + mmaaiill The files where the shell checks for mail. This checking is + done after each command completion that will result in a + prompt, if a specified interval has elapsed. The shell says + `You have new mail.' if the file exists with an access time + not greater than its modify time. + + If the first word of the value of _m_a_i_l is numeric it specifies + a different mail checking interval, in seconds, than the de- + fault, which is 10 minutes. + + If multiple mail files are specified, then the shell says `New + mail in _n_a_m_e' when there is mail in the file _n_a_m_e. + + nnoocclloobbbbeerr As described in the section on _i_n_p_u_t_/_o_u_t_p_u_t, restrictions are + placed on output redirection to insure that files are not ac- + cidentally destroyed, and that `>>' redirections refer to ex- + isting files. + + nnoogglloobb If set, filename expansion is inhibited. This inhibition is + most useful in shell scripts that + are not dealing with filenames, or after a list of filenames + has been obtained and further expansions are not desirable. + + nnoonnoommaattcchh If set, it is not an error for a filename expansion to not + match any existing files; instead the primitive pattern is re- + turned. It is still an error for the primitive pattern to be + malformed, i.e., `echo [' still gives an error. + + nnoottiiffyy If set, the shell notifies asynchronously of job completions; + the default is to present job completions just before printing + a prompt. + + ppaatthh Each word of the path variable specifies a directory in which + commands are to be sought for execution. A null word speci- + fies the current directory. If there is no _p_a_t_h variable then + only full path names will execute. The usual search path is + `.', `/bin' and `/usr/bin', but this may vary from system to + system. For the super-user the default search path is `/etc', + `/bin' and `/usr/bin'. A shell that is given neither the --cc + nor the --tt option will normally hash the contents of the di- + rectories in the _p_a_t_h variable after reading _._c_s_h_r_c, and each + time the _p_a_t_h variable is reset. If new commands are added to + these directories while the shell is active, it may be neces- + sary to do a rreehhaasshh or the commands may not be found. + + pprroommpptt The string that is printed before each command is read from an + interactive terminal input. If a `!' appears in the string it + will be replaced by the current event number unless a preced- + ing `\' is given. Default is `% ', or `# ' for the super- + user. + + ssaavveehhiisstt Is given a numeric value to control the number of entries of + the history list that are saved in ~/.history when the user + logs out. Any command that has been referenced in this many + events will be saved. During start up the shell sources + ~/.history into the history list enabling history to be saved + across logins. Too large values of _s_a_v_e_h_i_s_t will slow down + the shell during start up. If _s_a_v_e_h_i_s_t is just set, the shell + will use the value of _h_i_s_t_o_r_y_. + + sshheellll The file in which the shell resides. This variable is used in + forking shells to interpret files that have execute bits set, + but which are not executable by the system. (See the descrip- + tion of _N_o_n_-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n below.) Initialized to + the (system-dependent) home of the shell. + + ssttaattuuss The status returned by the last command. If it terminated ab- + normally, then 0200 is added to the status. Builtin commands + that fail return exit status `1', all other builtin commands + set status to `0'. + + ttiimmee Controls automatic timing of commands. If set, then any com- + mand that takes more than this many cpu seconds will cause a + line giving user, system, and real times and a utilization + percentage which is the ratio of user plus system times to re- + al time to be printed when it terminates. + + vveerrbboossee Set by the --vv command line option, causes the words of each + command to be printed after history substitution. + + NNoonn--bbuuiillttiinn ccoommmmaanndd eexxeeccuuttiioonn + When a command to be executed is found to not be a builtin command the + shell attempts to execute the command via execve(2). Each word in the + variable _p_a_t_h names a directory from which the shell will attempt to exe- + cute the command. If it is given neither a --cc nor a --tt option, the shell + will hash the names in these directories into an internal table so that + it will only try an eexxeecc in a directory if there is a possibility that + the command resides there. This shortcut greatly speeds command location + when many directories are present in the search path. If this mechanism + has been turned off (via uunnhhaasshh), or if the shell was given a --cc or --tt + argument, and in any case for each directory component of _p_a_t_h that does + not begin with a `/', the shell concatenates with the given command name + to form a path name of a file which it then attempts to execute. + + Parenthesized commands are always executed in a subshell. Thus + + (cd; pwd); pwd + + prints the _h_o_m_e directory; leaving you where you were (printing this af- + ter the home directory), while + + cd; pwd + + leaves you in the _h_o_m_e directory. Parenthesized commands are most often + used to prevent cchhddiirr from affecting the current shell. + + If the file has execute permissions but is not an executable binary to + the system, then it is assumed to be a file containing shell commands and + a new shell is spawned to read it. + + If there is an aalliiaass for sshheellll then the words of the alias will be + prepended to the argument list to form the shell command. The first word + of the aalliiaass should be the full path name of the shell (e.g., `$shell'). + Note that this is a special, late occurring, case of aalliiaass substitution, + and only allows words to be prepended to the argument list without + change. + + SSiiggnnaall hhaannddlliinngg + The shell normally ignores _q_u_i_t signals. Jobs running detached (either + by && or the bbgg or %%...... && commands) are immune to signals generated from + the keyboard, including hangups. Other signals have the values which the + shell inherited from its parent. The shell's handling of interrupts and + terminate signals in shell scripts can be controlled by oonniinnttrr. Login + shells catch the _t_e_r_m_i_n_a_t_e signal; otherwise this signal is passed on to + children from the state in the shell's parent. Interrupts are not al- + lowed when a login shell is reading the file _._l_o_g_o_u_t. + +AAUUTTHHOORR + William Joy. Job control and directory stack features first implemented + by J.E. Kulp of IIASA, Laxenburg, Austria, with different syntax than + that used now. File name completion code written by Ken Greer, HP Labs. + Eight-bit implementation Christos S. Zoulas, Cornell University. + +FFIILLEESS + + + ~/.cshrc Read at beginning of execution by each shell. + ~/.login Read by login shell, after `.cshrc' at login. + ~/.logout Read by login shell, at logout. + /bin/sh Standard shell, for shell scripts not starting with a `#'. + /tmp/sh* Temporary file for `<<'. + /etc/passwd Source of home directories for `~name'. + +LLIIMMIITTAATTIIOONNSS + Word lengths - Words can be no longer than 1024 characters. The system + limits argument lists to 10240 characters. The number of arguments to a + command that involves filename expansion is limited to 1/6'th the number + of characters allowed in an argument list. Command substitutions may + substitute no more characters than are allowed in an argument list. To + detect looping, the shell restricts the number of aalliiaass substitutions on + a single line to 20. + +SSEEEE AALLSSOO + sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), + sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), + environ(7), + introduction to the C shell + +HHIISSTTOORRYY + CCsshh appeared in 3BSD. It was a first implementation of a command language + interpreter incorporating a history mechanism (see _H_i_s_t_o_r_y + _S_u_b_s_t_i_t_u_t_i_o_n_s), job control facilities (see _J_o_b_s), interactive file name + and user name completion (see _F_i_l_e _N_a_m_e _C_o_m_p_l_e_t_i_o_n), and a C-like syntax. + There are now many shells that also have these mechanisms, plus a few + more (and maybe some bugs too), which are available through the usenet. + +BBUUGGSS + When a command is restarted from a stop, the shell prints the directory + it started in if this is different from the current directory; this can + be misleading (i.e., wrong) as the job may have changed directories in- + ternally. + + Shell builtin functions are not stoppable/restartable. Command sequences + of the form `a ; b ; c' are also not handled gracefully when stopping is + attempted. If you suspend `b', the shell will immediately execute `c'. + This is especially noticeable if this expansion results from an _a_l_i_a_s. It + suffices to place the sequence of commands in ()'s to force it to a sub- + shell, i.e., `( a ; b ; c )'. + + Control over tty output after processes are started is primitive; perhaps + this will inspire someone to work on a good virtual terminal interface. + In a virtual terminal interface much more interesting things could be + done with output control. + + Alias substitution is most often used to clumsily simulate shell proce- + dures; shell procedures should be provided instead of aliases. + + Commands within loops, prompted for by `?', are not placed on the hhiissttoorryy + list. Control structure should be parsed instead of being recognized as + built-in commands. This would allow control commands to be placed any- + where, to be combined with `|', and to be used with `&' and `;' metasyn- + tax. + + It should be possible to use the `:' modifiers on the output of command + substitutions. + + The way the ffiilleecc facility is implemented is ugly and expensive. + +4th Berkeley Distribution June 1, 1994 22 diff --git a/usr/share/man/cat1/test.0 b/usr/share/man/cat1/test.0 new file mode 100644 index 0000000000..ef7df518e1 --- /dev/null +++ b/usr/share/man/cat1/test.0 @@ -0,0 +1,114 @@ +TEST(1) BSD Reference Manual TEST(1) + +NNAAMMEE + tteesstt - condition evaluation utility + +SSYYNNOOPPSSIISS + tteesstt _e_x_p_r_e_s_s_i_o_n + +DDEESSCCRRIIPPTTIIOONN + The tteesstt utility evaluates the expression and, if it evaluates to true, + returns a zero (true) exit status; otherwise it returns 1 (false). If + there is no expression, test also returns 1 (false). + + All operators and flags are separate arguments to the tteesstt utility. + + The following primaries are used to construct expression: + + --bb _f_i_l_e True if _f_i_l_e exists and is a block special file. + + --cc _f_i_l_e True if _f_i_l_e exists and is a character special file. + + --dd _f_i_l_e True if _f_i_l_e exists and is a directory. + + --ee _f_i_l_e True if _f_i_l_e exists (regardless of type). + + --ff _f_i_l_e True if _f_i_l_e exists and is a regular file. + + --gg _f_i_l_e True if _f_i_l_e exists and its set group ID flag is set. + + --hh _f_i_l_e True if _f_i_l_e exists and is a symbolic link. + + --nn _s_t_r_i_n_g True if the length of _s_t_r_i_n_g is nonzero. + + --pp _f_i_l_e True if _f_i_l_e is a named pipe (FIFO). + + --rr _f_i_l_e True if _f_i_l_e _e_x_i_s_t_s _a_n_d _i_s _r_e_a_d_a_b_l_e_. + + --ss _f_i_l_e True if _f_i_l_e exists and has a size greater than zero. + + --tt _[_f_i_l_e___d_e_s_c_r_i_p_t_o_r_] + True if the file whose file descriptor number is + _f_i_l_e___d_e_s_c_r_i_p_t_o_r (default 1) is open and is associated with + a terminal. + + --uu _f_i_l_e True if _f_i_l_e exists and its set user ID flag is set. + + --ww _f_i_l_e True if _f_i_l_e exists and is writable. True indicates only + that the write flag is on. The file is not writable on a + read-only file system even if this test indicates true. + + --xx _f_i_l_e True if _f_i_l_e exists and is executable. True indicates only + that the execute flag is on. If _f_i_l_e is a directory, true + indicates that _f_i_l_e can be searched. + + --zz _s_t_r_i_n_g True if the length of _s_t_r_i_n_g is zero. + + _s_t_r_i_n_g True if _s_t_r_i_n_g is not the null string. + + _s_1 == _s_2 True if the strings _s_1 and _s_2 are identical. + + _s_1 !!== _s_2 True if the strings _s_1 and _s_2 are not identical. + + _n_1 --eeqq _n_2 True if the integers _n_1 and _n_2 are algebraically equal. + + _n_1 --nnee _n_2 True if the integers _n_1 and _n_2 are not algebraically equal. + + + _n_1 --ggtt _n_2 True if the integer _n_1 is algebraically greater than the + integer _n_2. + + _n_1 --ggee _n_2 True if the integer _n_1 is algebraically greater than or + equal to the integer _n_2. + + _n_1 --lltt _n_2 True if the integer _n_1 is algebraically less than the inte- + ger _n_2. + + _n_1 --llee _n_2 True if the integer _n_1 is algebraically less than or equal + to the integer _n_2. + + These primaries can be combined with the following operators: + + !! _e_x_p_r_e_s_s_i_o_n True if _e_x_p_r_e_s_s_i_o_n is false. + + _e_x_p_r_e_s_s_i_o_n_1 --aa _e_x_p_r_e_s_s_i_o_n_2 + True if both _e_x_p_r_e_s_s_i_o_n_1 and _e_x_p_r_e_s_s_i_o_n_2 are true. + + _e_x_p_r_e_s_s_i_o_n_1 --oo _e_x_p_r_e_s_s_i_o_n_2 + True if either _e_x_p_r_e_s_s_i_o_n_1 or _e_x_p_r_e_s_s_i_o_n_2 are true. + + ((_e_x_p_r_e_s_s_i_o_n)) True if expression is true. + + The --aa operator has higher precedence than the --oo operator. + +GGRRAAMMMMAARR AAMMBBIIGGUUIITTYY + The tteesstt grammar is inherently ambiguous. In order to assure a degree of + consistency, the cases described in the IEEE Std1003.2 (``POSIX''), sec- + tion D11.2/4.62.4, standard are evaluated consistently according to the + rules specified in the standards document. All other cases are subject + to the ambiguity in the command semantics. + +RREETTUURRNN VVAALLUUEESS + The tteesstt utility exits with one of the following values: + + 0 expression evaluated to true. + + 1 expression evaluated to false or expression was missing. + + >1 An error occurred. + +SSTTAANNDDAARRDDSS + The tteesstt function is expected to be IEEE Std1003.2 (``POSIX'') compati- + ble. + +4.4BSD May 31, 1993 2 diff --git a/usr/share/man/cat7/symlink.0 b/usr/share/man/cat7/symlink.0 new file mode 100644 index 0000000000..830313cc95 --- /dev/null +++ b/usr/share/man/cat7/symlink.0 @@ -0,0 +1,198 @@ +SYMLINK(7) BSD Reference Manual SYMLINK(7) + +NNAAMMEE + ssyymmlliinnkk - symbolic link handling + +SSYYMMBBOOLLIICC LLIINNKK HHAANNDDLLIINNGG + Symbolic links are files that act as pointers to other files. To under- + stand their behavior, you must first understand how hard links work. A + hard link to a file is indistinguishable from the original file because + it is a reference to the object underlying the original file name. + Changes to a file are independent of the name used to reference the file. + Hard links may not refer to directories and may not reference files on + different file systems. A symbolic link contains the name of the file to + which it is linked, i.e. it is a pointer to another name, and not to an + underlying object. For this reason, symbolic links may reference direc- + tories and may span file systems. + + Because a symbolic link and its referenced object coexist in the filesys- + tem name space, confusion can arise in distinguishing between the link + itself and the referenced object. Historically, commands and system + calls have adopted their own link following conventions in a somewhat ad- + hoc fashion. Rules for more a uniform approach, as they are implemented + in this system, are outlined here. It is important that local applica- + tions conform to these rules, too, so that the user interface can be as + consistent as possible. + + Symbolic links are handled either by operating on the link itself, or by + operating on the object referenced by the link. In the latter case, an + application or system call is said to ``follow'' the link. Symbolic + links may reference other symbolic links, in which case the links are + dereferenced until an object that is not a symbolic link is found, a sym- + bolic link which references a file which doesn't exist is found, or a + loop is detected. (Loop detection is done by placing an upper limit on + the number of links that may be followed, and an error results if this + limit is exceeded.) + + There are three separate areas that need to be discussed. They are as + follows: + + 1. Symbolic links used as file name arguments for system calls. + 2. Symbolic links specified as command line arguments to utili- + ties that are not traversing a file tree. + 3. Symbolic links encountered by utilities that are traversing a + file tree (either specified on the command line or encountered + as part of the file hierarchy walk). + + SSyysstteemm ccaallllss.. + The first area is symbolic links used as file name arguments for system + calls. + + Except as noted below, all system calls follow symbolic links. For exam- + ple, if there were a symbolic link ``slink'' which pointed to a file + named ``afile'', the system call ``open("slink" ...)'' would return a + file descriptor to the file ``afile''. + + There are four system calls that do not follow links, and which operate + on the symbolic link itself. They are: lstat(2), readlink(2), + rename(2), and unlink(2). Because remove(3) is an alias for unlink(2), + it also does not follow symbolic links. + + Unlike other filesystem objects, symbolic links do not have an owner, + group, permissions, access and modification times, etc. The only at- + tributes returned from an lstat(2) that refer to the symbolic link itself + are the file type (S_IFLNK), size, blocks, and link count (always 1). + The other attributes are filled in from the directory that contains the + link. For portability reasons, you should be aware that other implemen- + tations (including historic implementations of 4BSD), implement symbolic + links such that they have the same attributes as any other file. + + The 4.4BSD system differs from historical 4BSD systems in that the system + call chown(2) has been changed to follow symbolic links. + + CCoommmmaannddss nnoott ttrraavveerrssiinngg aa ffiillee ttrreeee.. + The second area is symbolic links, specified as command line file name + arguments, to commands which are not traversing a file tree. + + Except as noted below, commands follow symbolic links named as command + line arguments. For example, if there were a symbolic link ``slink'' + which pointed to a file named ``afile'', the command ``cat slink'' would + display the contents of the file ``afile''. + + It is important to realize that this rule includes commands which may op- + tionally traverse file trees, e.g. the command ``chown file'' is included + in this rule, while the command ``chown -R file'' is not. (The latter is + described in the third area, below.) + + If it is explicitly intended that the command operate on the symbolic + link instead of following the symbolic link, e.g., it is desired that + ``file slink'' display the type of file that ``slink'' is, whether it is + a symbolic link or not, the --hh option should be used. In the above exam- + ple, ``file slink'' would report the type of the file referenced by + ``slink'', while ``file -h slink'' would report that ``slink'' was a sym- + bolic link. + + There are three exceptions to this rule. The mv(1) and rm(1) commands do + not follow symbolic links named as arguments, but respectively attempt to + rename and delete them. (Note, if the symbolic link references a file + via a relative path, moving it to another directory may very well cause + it to stop working, since the path may no longer be correct.) + + The ls(1) command is also an exception to this rule. For compatibility + with historic systems (when llss is not doing a tree walk, i.e. the --RR op- + tion is not specified), the llss command follows symbolic links named as + arguments if the --LL option is specified, or if the --FF, --dd or --ll options + are not specified. (If the --LL option is specified, llss always follows + symbolic links. LLss is the only command where the --LL option affects its + behavior even though it is not doing a walk of a file tree.) + + The 4.4BSD system differs from historical 4BSD systems in that the cchhoowwnn, + cchhggrrpp and ffiillee commands follow symbolic links specified on the command + line. + + CCoommmmaannddss ttrraavveerrssiinngg aa ffiillee ttrreeee.. + The following commands either optionally or always traverse file trees: + chflags(1), chgrp(1), chmod(1), cp(1), du(1), find(1), ls(1), + pax(1), rm(1), tar(1) and chown(8). + + It is important to realize that the following rules apply equally to sym- + bolic links encountered during the file tree traversal and symbolic links + listed as command line arguments. + + The first rule applies to symbolic links that reference files that are + not of type directory. Operations that apply to symbolic links are per- + formed on the links themselves, but otherwise the links are ignored. + + For example, the command ``chown -R user slink directory'' will ignore + ``slink'', because symbolic links in this system do not have owners. Any + symbolic links encountered during the tree traversal will also be ig- + nored. The command ``rm -r slink directory'' will remove ``slink'', as + well as any symbolic links encountered in the tree traversal of + ``directory'', because symbolic links may be removed. In no case will + either cchhoowwnn or rrmm affect the file which ``slink'' references in any way. + + The second rule applies to symbolic links that reference files of type + directory. Symbolic links which reference files of type directory are + never ``followed'' by default. This is often referred to as a + ``physical'' walk, as opposed to a ``logical'' walk (where symbolic links + referencing directories are followed). + + As consistently as possible, you can make commands doing a file tree walk + follow any symbolic links named on the command line, regardless of the + type of file they reference, by specifying the --HH (for ``half-logical'') + flag. This flag is intended to make the command line name space look + like the logical name space. (Note, for commands that do not always do + file tree traversals, the --HH flag will be ignored if the --RR flag is not + also specified.) + + For example, the command ``chown -HR user slink'' will traverse the file + hierarchy rooted in the file pointed to by ``slink''. Note, the --HH is not + the same as the previously discussed --hh flag. The --HH flag causes symbol- + ic links specified on the command line to be dereferenced both for the + purposes of the action to be performed and the tree walk, and it is as if + the user had specified the name of the file to which the symbolic link + pointed. + + As consistently as possible, you can make commands doing a file tree walk + follow any symbolic links named on the command line, as well as any sym- + bolic links encountered during the traversal, regardless of the type of + file they reference, by specifying the --LL (for ``logical'') flag. This + flag is intended to make the entire name space look like the logical name + space. (Note, for commands that do not always do file tree traversals, + the --LL flag will be ignored if the --RR flag is not also specified.) + + For example, the command ``chown -LR user slink'' will change the owner + of the file referenced by ``slink''. If ``slink'' references a directory, + cchhoowwnn will traverse the file hierarchy rooted in the directory that it + references. In addition, if any symbolic links are encountered in any + file tree that cchhoowwnn traverses, they will be treated in the same fashion + as ``slink''. + + As consistently as possible, you can specify the default behavior by + specifying the --PP (for ``physical'') flag. This flag is intended to make + the entire name space look like the physical name space. + + For commands that do not by default do file tree traversals, the --HH, --LL + and --PP flags are ignored if the --RR flag is not also specified. In addi- + tion, you may specify the --HH, --LL and --PP options more than once; the last + one specified determines the command's behavior. This is intended to + permit you to alias commands to behave one way or the other, and then + override that behavior on the command line. + + The ls(1) and rm(1) commands have exceptions to these rules. The rrmm com- + mand operates on the symbolic link, and not the file it references, and + therefore never follows a symbolic link. The rrmm command does not support + the --HH, --LL or --PP options. + + To maintain compatibility with historic systems, the llss command never + follows symbolic links unless the --LL flag is specified. If the --LL flag + is specified, llss follows all symbolic links, regardless of their type, + whether specified on the command line or encountered in the tree walk. + The llss command does not support the --HH or --PP options. + +SSEEEE AALLSSOO + chflags(1), chgrp(1), chmod(1), cp(1), du(1), find(1), ln(1), + ls(1), mv(1), pax(1), rm(1), tar(1), lstat(2), readlink(2), + rename(2), unlink(2), fts(3), remove(3), chown(8) + +4th Berkeley Distribution March 31, 1994 3 diff --git a/usr/share/man/cat8/rmail.0 b/usr/share/man/cat8/rmail.0 new file mode 100644 index 0000000000..92b7dd717f --- /dev/null +++ b/usr/share/man/cat8/rmail.0 @@ -0,0 +1,26 @@ +RMAIL(8) BSD System Manager's Manual RMAIL(8) + +NNAAMMEE + rrmmaaiill - handle remote mail received via uucp + +SSYYNNOOPPSSIISS + rrmmaaiill _u_s_e_r _._._. + +DDEESSCCRRIIPPTTIIOONN + RRmmaaiill interprets incoming mail received via uucp(1), collapsing ``From'' + lines in the form generated by mail.local(8) into a single line of the + form ``return-path!sender'', and passing the processed mail on to + sendmail(8). + + RRmmaaiill is explicitly designed for use with uucp and sendmail. + +SSEEEE AALLSSOO + uucp(1), mail.local(8), sendmail(8) + +HHIISSTTOORRYY + The rrmmaaiill program appeared in 4.2BSD. + +BBUUGGSS + RRmmaaiill should not reside in _/_b_i_n. + +4.2 Berkeley Distribution April 29, 1993 1 diff --git a/usr/share/man/cat8/sync.0 b/usr/share/man/cat8/sync.0 new file mode 100644 index 0000000000..6274ff13e0 --- /dev/null +++ b/usr/share/man/cat8/sync.0 @@ -0,0 +1,25 @@ +SYNC(8) BSD System Manager's Manual SYNC(8) + +NNAAMMEE + ssyynncc - force completion of pending disk writes (flush cache) + +SSYYNNOOPPSSIISS + ssyynncc + +DDEESSCCRRIIPPTTIIOONN + SSyynncc can be called to insure that all disk writes have been completed be- + fore the processor is halted in a way not suitably done by reboot(8) or + halt(8). Generally, it is preferable to use reboot or halt to shut down + the system, as they may perform additional actions such as resynchroniz- + ing the hardware clock and flushing internal caches before performing a + final ssyynncc. + + SSyynncc utilizes the sync(2) function call. + +SSEEEE AALLSSOO + sync(2), fsync(2), halt(8), reboot(8), update(8) + +HHIISSTTOORRYY + A ssyynncc command appeared in Version 6 AT&T UNIX. + +4th Berkeley Distribution May 31, 1993 1 -- 2.20.1