BSD 4_3_Reno development
[unix-history] / usr / share / man / cat1 / pushd.0
CommitLineData
38e06a58
C
1CSH(1) UNIX Reference Manual CSH(1)
2
3N\bNA\bAM\bME\bE
4 c\bcs\bsh\bh - a shell (command interpreter) with C-like syntax
5
6S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
7 c\bcs\bsh\bh [-\b-c\bce\bef\bf^\b^i\bin\bns\bst\btv\bvV\bVx\bxX\bX] [arg ...]
8
9D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
10 The C\bCs\bsh\bh is a command language interpreter incorporating a history mechan-
11 ism (see H\bHi\bis\bst\bto\bor\bry\by S\bSu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bns\bs), job control facilities (see J\bJo\bob\bbs\bs), in-
12 teractive file name and user name completion (see F\bFi\bil\ble\be N\bNa\bam\bme\be C\bCo\bom\bmp\bpl\ble\bet\bti\bio\bon\bn),
13 and a C-like syntax. It is used both as an interactive login shell and a
14 shell script command processor.
15
16 A\bAr\brg\bgu\bum\bme\ben\bnt\bt l\bli\bis\bst\bt p\bpr\bro\boc\bce\bes\bss\bsi\bin\bng\bg
17 If the first argument (argument 0) to the shell is `-\b-' then this is a
18 login shell. The flag arguments are interpreted as follows:
19
20 -\b-b\bb This flag forces a ``break'' from option processing, causing any
21 further shell arguments to be treated as non-option arguments. The
22 remaining arguments will not be interpreted as shell options. This
23 may be used to pass options to a shell script without confusion or
24 possible subterfuge. The shell will not run a set-user ID script
25 without this option.
26
27 -\b-c\bc Commands are read from the (single) following argument which must be
28 present. Any remaining arguments are placed in _\ba_\br_\bg_\bv.
29
30 -\b-e\be The shell exits if any invoked command terminates abnormally or
31 yields a non-zero exit status.
32
33 -\b-f\bf The shell will start faster, because it will neither search for nor
34 execute commands from the file ._\bc_\bs_\bh_\br_\bc in the invoker's home directo-
35 ry.
36
37 -\b-i\bi The shell is interactive and prompts for its top-level input, even
38 if it appears to not be a terminal. Shells are interactive without
39 this option if their inputs and outputs are terminals.
40
41 -\b-n\bn Commands are parsed, but not executed. This aids in syntactic
42 checking of shell scripts.
43
44 -\b-s\bs Command input is taken from the standard input.
45
46 -\b-t\bt A single line of input is read and executed. A `\' may be used to
47 escape the newline at the end of this line and continue onto another
48 line.
49
50 -\b-v\bv Causes the _\bv_\be_\br_\bb_\bo_\bs_\be variable to be set, with the effect that command
51 input is echoed after history substitution.
52
53 -\b-x\bx Causes the _\be_\bc_\bh_\bo variable to be set, so that commands are echoed im-
54 mediately before execution.
55
56 -\b-V\bV Causes the _\bv_\be_\br_\bb_\bo_\bs_\be variable to be set even before ._\bc_\bs_\bh_\br_\bc _\bi_\bs
57 _\be_\bx_\be_\bc_\bu_\bt_\be_\bd.
58
59 -\b-X\bX Is to -\b-x\bx as -\b-V\bV is to -\b-v\bv.
60
61 After processing of flag arguments, if arguments remain but none of the
62 -\b-c\bc, -\b-i\bi, -\b-s\bs, or -\b-t\bt options were given, the first argument is taken as the
63 name of a file of commands to be executed. The shell opens this file,
64 and saves its name for possible resubstitution by `$0'. Since many sys-
65 tems use either the standard version 6 or version 7 shells whose shell
66 scripts are not compatible with this shell, the shell will execute such a
67 `standard' shell if the first character of a script is not a `#', i.e. if
68 the script does not start with a comment. Remaining arguments initialize
69 the variable _\ba_\br_\bg_\bv.
70
71 An instance of c\bcs\bsh\bh begins by executing commands from the file
72 /_\be_\bt_\bc/_\bc_\bs_\bh._\bc_\bs_\bh_\br_\bc and, if this is a login shell, /_\be_\bt_\bc/_\bc_\bs_\bh._\bl_\bo_\bg_\bi_\bn. It then
73 executes commands from ._\bc_\bs_\bh_\br_\bc in the _\bh_\bo_\bm_\be directory of the invoker, and,
74 if this is a login shell, the file ._\bl_\bo_\bg_\bi_\bn in the same location. It is
75 typical for users on crt's to put the command ``stty crt'' in their
76 ._\bl_\bo_\bg_\bi_\bn file, and to also invoke tset(1) there.
77
78 In the normal case, the shell will then begin reading commands from the
79 terminal, prompting with `% '. Processing of arguments and the use of
80 the shell to process files containing command scripts will be described
81 later.
82
83 The shell then repeatedly performs the following actions: a line of com-
84 mand input is read and broken into _\bw_\bo_\br_\bd_\bs. This sequence of words is
85 placed on the command history list and then parsed. Finally each command
86 in the current line is executed.
87
88 When a login shell terminates it executes commands from the files ._\bl_\bo_\bg_\bo_\bu_\bt
89 in the user's _\bh_\bo_\bm_\be directory and /_\be_\bt_\bc/_\bc_\bs_\bh._\bl_\bo_\bg_\bo_\bu_\bt.
90
91 L\bLe\bex\bxi\bic\bca\bal\bl s\bst\btr\bru\buc\bct\btu\bur\bre\be
92 The shell splits input lines into words at blanks and tabs with the fol-
93 lowing exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form
94 separate words. If doubled in `&&', `||', `<<' or `>>' these pairs form
95 single words. These parser metacharacters may be made part of other
96 words, or prevented their special meaning, by preceding them with `\'. A
97 newline preceded by a `\' is equivalent to a blank.
98
99 In addition strings enclosed in matched pairs of quotations, `'', ``' or
100 `"', form parts of a word; metacharacters in these strings, including
101 blanks and tabs, do not form separate words. These quotations have se-
102 mantics to be described subsequently. Within pairs of `'' or `"' charac-
103 ters a newline preceded by a `\' gives a true newline character.
104
105 When the shell's input is not a terminal, the character `#' introduces a
106 comment which continues to the end of the input line. It is prevented
107 this special meaning when preceded by `\' and in quotations using ``',
108 `'', and `"'.
109
110 C\bCo\bom\bmm\bma\ban\bnd\bds\bs
111 A simple command is a sequence of words, the first of which specifies the
112 command to be executed. A simple command or a sequence of simple com-
113 mands separated by `|' characters forms a pipeline. The output of each
114 command in a pipeline is connected to the input of the next. Sequences
115 of pipelines may be separated by `;', and are then executed sequentially.
116 A sequence of pipelines may be executed without immediately waiting for
117 it to terminate by following it with an `&'.
118
119 Any of the above may be placed in `(' `)' to form a simple command (which
120 may be a component of a pipeline, etc.) It is also possible to separate
121 pipelines with `||' or `&&' indicating, as in the C language, that the
122 second is to be executed only if the first fails or succeeds respective-
123 ly. (See _\bE_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn_\bs.)
124
125 J\bJo\bob\bbs\bs
126 The shell associates a _\bj_\bo_\bb with each pipeline. It keeps a table of
127 current jobs, printed by the _\bj_\bo_\bb_\bs command, and assigns them small integer
128 numbers. When a job is started asynchronously with `&', the shell prints
129 a line which looks like:
130
131 [1] 1234
132
133
134 indicating that the job which was started asynchronously was job number 1
135 and had one (top-level) process, whose process id was 1234.
136
137 If you are running a job and wish to do something else you may hit the
138 key ^\b^Z\bZ (control-Z) which sends a STOP signal to the current job. The
139 shell will then normally indicate that the job has been `Stopped', and
140 print another prompt. You can then manipulate the state of this job,
141 putting it in the background with the _\bb_\bg command, or run some other com-
142 mands and then eventually bring the job back into the foreground with the
143 foreground command _\bf_\bg. A ^\b^Z\bZ takes effect immediately and is like an in-
144 terrupt in that pending output and unread input are discarded when it is
145 typed. There is another special key ^\b^Y\bY which does not generate a STOP
146 signal until a program attempts to read(2) it. This can usefully be
147 typed ahead when you have prepared some commands for a job which you wish
148 to stop after it has read them.
149
150 A job being run in the background will stop if it tries to read from the
151 terminal. Background jobs are normally allowed to produce output, but
152 this can be disabled by giving the command ``stty tostop''. If you set
153 this tty option, then background jobs will stop when they try to produce
154 output like they do when they try to read input.
155
156 There are several ways to refer to jobs in the shell. The character `%'
157 introduces a job name. If you wish to refer to job number 1, you can
158 name it as `%1'. Just naming a job brings it to the foreground; thus
159 `%1' is a synonym for `fg %1', bringing job 1 back into the foreground.
160 Similarly saying `%1 &' resumes job 1 in the background. Jobs can also
161 be named by prefixes of the string typed in to start them, if these pre-
162 fixes are unambiguous, thus `%ex' would normally restart a suspended
163 ex(1) job, if there were only one suspended job whose name began with the
164 string `ex'. It is also possible to say `%?string' which specifies a job
165 whose text contains _\bs_\bt_\br_\bi_\bn_\bg, if there is only one such job.
166
167 The shell maintains a notion of the current and previous jobs. In output
168 pertaining to jobs, the current job is marked with a `+' and the previous
169 job with a `-'. The abbreviation `%+' refers to the current job and `%-'
170 refers to the previous job. For close analogy with the syntax of the
171 _\bh_\bi_\bs_\bt_\bo_\br_\by mechanism (described below), `%%' is also a synonym for the
172 current job.
173
174 The job control mechanism requires that the stty(1) option n\bne\bew\bw be set. It
175 is an artifact from a _\bn_\be_\bw implementation of the tty driver which allows
176 generation of interrupt characters from the keyboard to tell jobs to
177 stop. See stty(1) for details on setting options in the new tty driver.
178
179 S\bSt\bta\bat\btu\bus\bs r\bre\bep\bpo\bor\brt\bti\bin\bng\bg
180 This shell learns immediately whenever a process changes state. It nor-
181 mally informs you whenever a job becomes blocked so that no further pro-
182 gress is possible, but only just before it prints a prompt. This is done
183 so that it does not otherwise disturb your work. If, however, you set
184 the shell variable _\bn_\bo_\bt_\bi_\bf_\by, the shell will notify you immediately of
185 changes of status in background jobs. There is also a shell command
186 _\bn_\bo_\bt_\bi_\bf_\by which marks a single process so that its status changes will be
187 immediately reported. By default _\bn_\bo_\bt_\bi_\bf_\by marks the current process; sim-
188 ply say `notify' after starting a background job to mark it.
189
190 When you try to leave the shell while jobs are stopped, you will be
191 warned that `You have stopped jobs.' You may use the _\bj_\bo_\bb_\bs command to see
192 what they are. If you do this or immediately try to exit again, the
193 shell will not warn you a second time, and the suspended jobs will be
194 terminated.
195
196 F\bFi\bil\ble\be N\bNa\bam\bme\be C\bCo\bom\bmp\bpl\ble\bet\bti\bio\bon\bn
197 When the file name completion feature is enabled by setting the shell
198 variable _\bf_\bi_\bl_\be_\bc (see s\bse\bet\bt), c\bcs\bsh\bh will interactively complete file names and
199 user names from unique prefixes, when they are input from the terminal
200 followed by the escape character (the escape key, or control-[) For exam-
201 ple, if the current directory looks like
202
203 DSC.OLD bin cmd lib xmpl.c
204 DSC.NEW chaosnet cmtest mail xmpl.o
205 bench class dev mbox xmpl.out
206
207 and the input is
208
209 % vi ch<escape>
210
211 c\bcs\bsh\bh will complete the prefix ``ch'' to the only matching file name
212 ``chaosnet'', changing the input line to
213
214 % vi chaosnet
215
216 However, given
217
218 % vi D<escape>
219
220 c\bcs\bsh\bh will only expand the input to
221
222 % vi DSC.
223
224 and will sound the terminal bell to indicate that the expansion is incom-
225 plete, since there are two file names matching the prefix ``D''.
226
227 If a partial file name is followed by the end-of-file character (usually
228 control-D), then, instead of completing the name, c\bcs\bsh\bh will list all file
229 names matching the prefix. For example, the input
230
231 % vi D<control-D>
232
233 causes all files beginning with ``D'' to be listed:
234
235 DSC.NEW DSC.OLD
236
237 while the input line remains unchanged.
238
239 The same system of escape and end-of-file can also be used to expand par-
240 tial user names, if the word to be completed (or listed) begins with the
241 character ``~''. For example, typing
242
243 cd ~ro<escape>
244
245 may produce the expansion
246
247 cd ~root
248
249 The use of the terminal bell to signal errors or multiple matches can be
250 inhibited by setting the variable _\bn_\bo_\bb_\be_\be_\bp.
251
252 Normally, all files in the particular directory are candidates for name
253 completion. Files with certain suffixes can be excluded from considera-
254 tion by setting the variable _\bf_\bi_\bg_\bn_\bo_\br_\be to the list of suffixes to be ig-
255 nored. Thus, if _\bf_\bi_\bg_\bn_\bo_\br_\be is set by the command
256
257 % set fignore = (.o .out)
258
259 then typing
260
261 % vi x<escape>
262
263 would result in the completion to
264
265
266 % vi xmpl.c
267
268 ignoring the files "xmpl.o" and "xmpl.out". However, if the only comple-
269 tion possible requires not ignoring these suffixes, then they are not ig-
270 nored. In addition, _\bf_\bi_\bg_\bn_\bo_\br_\be does not affect the listing of file names by
271 control-D. All files are listed regardless of their suffixes.
272
273 S\bSu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bns\bs
274 We now describe the various transformations the shell performs on the in-
275 put in the order in which they occur.
276
277 H\bHi\bis\bst\bto\bor\bry\by s\bsu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bns\bs
278 History substitutions place words from previous command input as portions
279 of new commands, making it easy to repeat commands, repeat arguments of a
280 previous command in the current command, or fix spelling mistakes in the
281 previous command with little typing and a high degree of confidence.
282 History substitutions begin with the character `!' and may begin _\ba_\bn_\by_\bw_\bh_\be_\br_\be
283 in the input stream (with the proviso that they d\bdo\bo n\bno\bot\bt nest.) This `!'
284 may be preceded by an `\' to prevent its special meaning; for conveni-
285 ence, a `!' is passed unchanged when it is followed by a blank, tab, new-
286 line, `=' or `('. (History substitutions also occur when an input line
287 begins with `^'. This special abbreviation will be described later.) Any
288 input line which contains history substitution is echoed on the terminal
289 before it is executed as it could have been typed without history substi-
290 tution.
291
292 Commands input from the terminal which consist of one or more words are
293 saved on the history list. The history substitutions reintroduce se-
294 quences of words from these saved commands into the input stream. The
295 size of which is controlled by the _\bh_\bi_\bs_\bt_\bo_\br_\by variable; the previous command
296 is always retained, regardless of its value. Commands are numbered
297 sequentially from 1.
298
299 For definiteness, consider the following output from the _\bh_\bi_\bs_\bt_\bo_\br_\by command:
300
301 9 write michael
302 10 ex write.c
303 11 cat oldwrite.c
304 12 diff *write.c
305
306 The commands are shown with their event numbers. It is not usually
307 necessary to use event numbers, but the current event number can be made
308 part of the _\bp_\br_\bo_\bm_\bp_\bt by placing an `!' in the prompt string.
309
310 With the current event 13 we can refer to previous events by event number
311 `!11', relatively as in `!-2' (referring to the same event), by a prefix
312 of a command word as in `!d' for event 12 or `!wri' for event 9, or by a
313 string contained in a word in the command as in `!?mic?' also referring
314 to event 9. These forms, without further modification, simply reintro-
315 duce the words of the specified events, each separated by a single blank.
316 As a special case `!!' refers to the previous command; thus `!!' alone is
317 essentially a _\br_\be_\bd_\bo.
318
319 To select words from an event we can follow the event specification by a
320 `:' and a designator for the desired words. The words of an input line
321 are numbered from 0, the first (usually command) word being 0, the second
322 word (first argument) being 1, etc. The basic word designators are:
323
324 0 first (command) word
325 _\bn _\bn'th argument
326 ^ first argument, i.e. `1'
327 $ last argument
328 % word matched by (immediately preceding) ?_\bs? search
329 _\bx-_\by range of words
330 -_\by abbreviates `_\b0-_\by'
331 * abbreviates `^-$', or nothing if only 1 word in event
332 _\bx* abbreviates `_\bx-$'
333 _\bx- like `_\bx*' but omitting word `$'
334
335
336 The `:' separating the event specification from the word designator can
337 be omitted if the argument selector begins with a `^', `$', `*' `-' or
338 `%'. After the optional word designator can be placed a sequence of
339 modifiers, each preceded by a `:'. The following modifiers are defined:
340
341 h Remove a trailing pathname component, leaving the head.
342 r Remove a trailing `.xxx' component, leaving the root name.
343 e Remove all but the extension `.xxx' part.
344 s/_\bl/_\br/
345 Substitute _\bl for _\br
346 t Remove all leading pathname components, leaving the tail.
347 & Repeat the previous substitution.
348 g Apply the change globally, prefixing the above, e.g. `g&'.
349 p Print the new command line but do not execute it.
350 q Quote the substituted words, preventing further substitu-
351 tions.
352 x Like q, but break into words at blanks, tabs and newlines.
353
354
355 Unless preceded by a `g' the modification is applied only to the first
356 modifiable word. With substitutions, it is an error for no word to be
357 applicable.
358
359 The left hand side of substitutions are not regular expressions in the
360 sense of the editors, but rather strings. Any character may be used as
361 the delimiter in place of `/'; a `\' quotes the delimiter into the _\bl and
362 _\br strings. The character `&' in the right hand side is replaced by the
363 text from the left. A `\' quotes `&' also. A null _\bl uses the previous
364 string either from a _\bl or from a contextual scan string _\bs in `!? _\bs ?'.
365 The trailing delimiter in the substitution may be omitted if a newline
366 follows immediately as may the trailing `?' in a contextual scan.
367
368 A history reference may be given without an event specification, e.g.
369 `!$'. In this case the reference is to the previous command unless a
370 previous history reference occurred on the same line in which case this
371 form repeats the previous reference. Thus `!?foo?^ !$' gives the first
372 and last arguments from the command matching `?foo?'.
373
374 A special abbreviation of a history reference occurs when the first non-
375 blank character of an input line is a `^'. This is equivalent to `!:s^'
376 providing a convenient shorthand for substitutions on the text of the
377 previous line. Thus `^lb^lib' fixes the spelling of `lib' in the previ-
378 ous command. Finally, a history substitution may be surrounded with `{'
379 and `}' if necessary to insulate it from the characters which follow.
380 Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula',
381 while `!la' would look for a command starting `la'.
382
383 Q\bQu\buo\bot\bta\bat\bti\bio\bon\bns\bs w\bwi\bit\bth\bh '\b' a\ban\bnd\bd "\b"
384 The quotation of strings by `'' and `"' can be used to prevent all or
385 some of the remaining substitutions. Strings enclosed in `'' are
386 prevented any further interpretation. Strings enclosed in `"' may be ex-
387 panded as described below.
388
389 In both cases the resulting text becomes (all or part of) a single word;
390 only in one special case (see _\bC_\bo_\bm_\bm_\ba_\bn_\bd _\bS_\bu_\bb_\bs_\bt_\bi_\bt_\bi_\bt_\bi_\bo_\bn below) does a `"'
391 quoted string yield parts of more than one word; `'' quoted strings never
392 do.
393
394 A\bAl\bli\bia\bas\bs s\bsu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bn
395 The shell maintains a list of aliases which can be established, displayed
396 and modified by the _\ba_\bl_\bi_\ba_\bs and _\bu_\bn_\ba_\bl_\bi_\ba_\bs commands. After a command line is
397 scanned, it is parsed into distinct commands and the first word of each
398 command, left-to-right, is checked to see if it has an alias. If it
399 does, then the text which is the alias for that command is reread with
400 the history mechanism available as though that command were the previous
401 input line. The resulting words replace the command and argument list.
402 If no reference is made to the history list, then the argument list is
403 left unchanged.
404
405 Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to
406 `ls -l /usr', the argument list here being undisturbed. Similarly if the
407 alias for `lookup' was `grep !^ /etc/passwd' then `lookup bill' would map
408 to `grep bill /etc/passwd'.
409
410 If an alias is found, the word transformation of the input text is per-
411 formed and the aliasing process begins again on the reformed input line.
412 Looping is prevented if the first word of the new text is the same as the
413 old by flagging it to prevent further aliasing. Other loops are detected
414 and cause an error.
415
416 Note that the mechanism allows aliases to introduce parser metasyntax.
417 Thus we can `alias print 'pr \!* | lpr'' to make a command which _\bp_\br '_\bs
418 its arguments to the line printer.
419
420 V\bVa\bar\bri\bia\bab\bbl\ble\be s\bsu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bn
421 The shell maintains a set of variables, each of which has as value a list
422 of zero or more words. Some of these variables are set by the shell or
423 referred to by it. For instance, the _\ba_\br_\bg_\bv variable is an image of the
424 shell's argument list, and words of this variable's value are referred to
425 in special ways.
426
427 The values of variables may be displayed and changed by using the _\bs_\be_\bt and
428 _\bu_\bn_\bs_\be_\bt commands. Of the variables referred to by the shell a number are
429 toggles; the shell does not care what their value is, only whether they
430 are set or not. For instance, the _\bv_\be_\br_\bb_\bo_\bs_\be variable is a toggle which
431 causes command input to be echoed. The setting of this variable results
432 from the -\b-v\bv command line option.
433
434 Other operations treat variables numerically. The `@' command permits
435 numeric calculations to be performed and the result assigned to a vari-
436 able. Variable values are, however, always represented as (zero or more)
437 strings. For the purposes of numeric operations, the null string is con-
438 sidered to be zero, and the second and subsequent words of multiword
439 values are ignored.
440
441 After the input line is aliased and parsed, and before each command is
442 executed, variable substitution is performed keyed by `$' characters.
443 This expansion can be prevented by preceding the `$' with a `\' except
444 within `"'s where it _\ba_\bl_\bw_\ba_\by_\bs occurs, and within `''s where it _\bn_\be_\bv_\be_\br oc-
445 curs. Strings quoted by ``' are interpreted later (see C\bCo\bom\bmm\bma\ban\bnd\bd
446 s\bsu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bn below) so `$' substitution does not occur there until later,
447 if at all. A `$' is passed unchanged if followed by a blank, tab, or
448 end-of-line.
449
450 Input/output redirections are recognized before variable expansion, and
451 are variable expanded separately. Otherwise, the command name and entire
452 argument list are expanded together. It is thus possible for the first
453 (command) word to this point to generate more than one word, the first of
454 which becomes the command name, and the rest of which become arguments.
455
456 Unless enclosed in `"' or given the `:q' modifier the results of variable
457 substitution may eventually be command and filename substituted. Within
458 `"', a variable whose value consists of multiple words expands to a (por-
459 tion of) a single word, with the words of the variables value separated
460 by blanks. When the `:q' modifier is applied to a substitution the vari-
461 able will expand to multiple words with each word separated by a blank
462 and quoted to prevent later command or filename substitution.
463
464 The following metasequences are provided for introducing variable values
465 into the shell input. Except as noted, it is an error to reference a
466 variable which is not set.
467
468 $name
469 ${name}
470 Are replaced by the words of the value of variable _\bn_\ba_\bm_\be, each
471 separated by a blank. Braces insulate _\bn_\ba_\bm_\be from following charac-
472 ters which would otherwise be part of it. Shell variables have
473 names consisting of up to 20 letters and digits starting with a
474 letter. The underscore character is considered a letter.
475 If _\bn_\ba_\bm_\be is not a shell variable, but is set in the environment,
476 then that value is returned (but : modifiers and the other forms
477 given below are not available in this case).
478
479 $name[selector]
480 ${name[selector]}
481 May be used to select only some of the words from the value of
482 _\bn_\ba_\bm_\be. The selector is subjected to `$' substitution and may con-
483 sist of a single number or two numbers separated by a `-'. The
484 first word of a variables value is numbered `1'. If the first
485 number of a range is omitted it defaults to `1'. If the last
486 member of a range is omitted it defaults to `$#name'. The selector
487 `*' selects all words. It is not an error for a range to be empty
488 if the second argument is omitted or in range.
489
490 $#name
491 ${#name}
492 Gives the number of words in the variable. This is useful for
493 later use in a `$argv[selector]'.
494
495 $0 Substitutes the name of the file from which command input is being
496 read. An error occurs if the name is not known.
497
498 $number
499 ${number}
500 Equivalent to `$argv[number]'.
501
502 $* Equivalent to `$argv[*]'. The modifiers `:e', `:h', `:t', `:r',
503 `:q' and `:x' may be applied to the substitutions above as may
504 `:gh', `:gt' and `:gr'. If braces `{' '}' appear in the command
505 form then the modifiers must appear within the braces. The current
506 implementation allows only one `:' modifier on each `$' expansion.
507
508
509 The following substitutions may not be modified with `:' modifiers.
510
511 $?name
512 ${?name}
513 Substitutes the string `1' if name is set, `0' if it is not.
514
515 $?0 Substitutes `1' if the current input filename is known, `0' if it
516 is not.
517
518 $$ Substitute the (decimal) process number of the (parent) shell.
519
520 $< Substitutes a line from the standard input, with no further
521 interpretation thereafter. It can be used to read from the
522 keyboard in a shell script.
523
524
525 C\bCo\bom\bmm\bma\ban\bnd\bd a\ban\bnd\bd f\bfi\bil\ble\ben\bna\bam\bme\be s\bsu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bn
526 The remaining substitutions, command and filename substitution, are
527 applied selectively to the arguments of builtin commands. This means
528 that portions of expressions which are not evaluated are not subjected to
529 these expansions. For commands which are not internal to the shell, the
530 command name is substituted separately from the argument list. This
531 occurs very late, after input-output redirection is performed, and in a
532 child of the main shell.
533
534 C\bCo\bom\bmm\bma\ban\bnd\bd s\bsu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bn
535 Command substitution is indicated by a command enclosed in ``'. The
536 output from such a command is normally broken into separate words at
537 blanks, tabs and newlines, with null words being discarded, this text
538 then replacing the original string. Within `"'s, only newlines force new
539 words; blanks and tabs are preserved.
540
541 In any case, the single final newline does not force a new word. Note
542 that it is thus possible for a command substitution to yield only part of
543 a word, even if the command outputs a complete line.
544
545 F\bFi\bil\ble\ben\bna\bam\bme\be s\bsu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bn
546 If a word contains any of the characters `*', `?', `[' or `{' or begins
547 with the character `~', then that word is a candidate for filename
548 substitution, also known as `globbing'. This word is then regarded as a
549 pattern, and replaced with an alphabetically sorted list of file names
550 which match the pattern. In a list of words specifying filename
551 substitution it is an error for no pattern to match an existing file
552 name, but it is not required for each pattern to match. Only the
553 metacharacters `*', `?' and `[' imply pattern matching, the characters
554 `~' and `{' being more akin to abbreviations.
555
556 In matching filenames, the character `.' at the beginning of a filename
557 or immediately following a `/', as well as the character `/' must be
558 matched explicitly. The character `*' matches any string of characters,
559 including the null string. The character `?' matches any single
560 character. The sequence `[...]' matches any one of the characters
561 enclosed. Within `[...]', a pair of characters separated by `-' matches
562 any character lexically between the two.
563
564 The character `~' at the beginning of a filename is used to refer to home
565 directories. Standing alone, i.e. `~' it expands to the invokers home
566 directory as reflected in the value of the variable _\bh_\bo_\bm_\be. When followed
567 by a name consisting of letters, digits and `-' characters the shell
568 searches for a user with that name and substitutes their home directory;
569 thus `~ken' might expand to `/usr/ken' and `~ken/chmach' to
570 `/usr/ken/chmach'. If the character `~' is followed by a character other
571 than a letter or `/' or appears not at the beginning of a word, it is
572 left undisturbed.
573
574 The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to
575 right order is preserved, with results of matches being sorted separately
576 at a low level to preserve this order. This construct may be nested.
577 Thus `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c
578 /usr/source/s1/ls.c' whether or not these files exist without any chance
579 of error if the home directory for `source' is `/usr/source'. Similarly
580 `../{memo,*box}' might expand to `../memo ../box ../mbox'. (Note that
581 `memo' was not sorted with the results of matching `*box'.) As a special
582 case `{', `}' and `{}' are passed undisturbed.
583
584 I\bIn\bnp\bpu\but\bt/\b/o\bou\but\btp\bpu\but\bt
585 The standard input and standard output of a command may be redirected
586 with the following syntax:
587
588 < name
589 Open file _\bn_\ba_\bm_\be (which is first variable, command and filename ex-
590 panded) as the standard input.
591
592 << word
593 Read the shell input up to a line which is identical to _\bw_\bo_\br_\bd. _\bW_\bo_\br_\bd
594 is not subjected to variable, filename or command substitution, and
595 each input line is compared to _\bw_\bo_\br_\bd before any substitutions are
596 done on this input line. Unless a quoting `\', `"', `'' or ``' ap-
597 pears in _\bw_\bo_\br_\bd variable and command substitution is performed on the
598 intervening lines, allowing `\' to quote `$', `\' and ``'. Com-
599 mands which are substituted have all blanks, tabs, and newlines
600 preserved, except for the final newline which is dropped. The
601 resultant text is placed in an anonymous temporary file which is
602 given to the command as standard input.
603
604 > name
605 >! name
606 >& name
607 >&! name
608 The file _\bn_\ba_\bm_\be is used as standard output. If the file does not ex-
609 ist then it is created; if the file exists, its is truncated, its
610 previous contents being lost.
611
612 If the variable _\bn_\bo_\bc_\bl_\bo_\bb_\bb_\be_\br is set, then the file must not exist or
613 be a character special file (e.g. a terminal or `/dev/null') or an
614 error results. This helps prevent accidental destruction of files.
615 In this case the `!' forms can be used and suppress this check.
616
617 The forms involving `&' route the diagnostic output into the speci-
618 fied file as well as the standard output. _\bN_\ba_\bm_\be is expanded in the
619 same way as `<' input filenames are.
620
621 >> name
622 >>& name
623 >>! name
624 >>&! name
625 Uses file _\bn_\ba_\bm_\be as standard output like `>' but places output at the
626 end of the file. If the variable _\bn_\bo_\bc_\bl_\bo_\bb_\bb_\be_\br is set, then it is an
627 error for the file not to exist unless one of the `!' forms is
628 given. Otherwise similar to `>'.
629
630
631 A command receives the environment in which the shell was invoked as
632 modified by the input-output parameters and the presence of the command
633 in a pipeline. Thus, unlike some previous shells, commands run from a
634 file of shell commands have no access to the text of the commands by de-
635 fault; rather they receive the original standard input of the shell. The
636 `<<' mechanism should be used to present inline data. This permits shell
637 command scripts to function as components of pipelines and allows the
638 shell to block read its input. Note that the default standard input for
639 a command run detached is _\bn_\bo_\bt modified to be the empty file /_\bd_\be_\bv/_\bn_\bu_\bl_\bl;
640 rather the standard input remains as the original standard input of the
641 shell. If this is a terminal and if the process attempts to read from
642 the terminal, then the process will block and the user will be notified
643 (see _\bJ_\bo_\bb_\bs above).
644
645 Diagnostic output may be directed through a pipe with the standard out-
646 put. Simply use the form `|&' rather than just `|'.
647
648 E\bEx\bxp\bpr\bre\bes\bss\bsi\bio\bon\bns\bs
649 A number of the builtin commands (to be described subsequently) take ex-
650 pressions, in which the operators are similar to those of C, with the
651 same precedence. These expressions appear in the @\b@,\b, _\be_\bx_\bi_\bt, _\bi_\bf, and _\bw_\bh_\bi_\bl_\be
652 commands. The following operators are available:
653
654 || && | *(ua & == != =~ !~ <= >= < >
655 << >> + - * / % ! ~ ( )
656
657 Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<='
658 `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in
659 groups, at the same level. The `==' `!=' `=~' and `!~' operators compare
660 their arguments as strings; all others operate on numbers. The operators
661 `=~' and `!~' are like `!=' and `==' except that the right hand side is a
662 _\bp_\ba_\bt_\bt_\be_\br_\bn (containing, e.g. `*'s, `?'s and instances of `[...]') against
663 which the left hand operand is matched. This reduces the need for use of
664 the _\bs_\bw_\bi_\bt_\bc_\bh statement in shell scripts when all that is really needed is
665 pattern matching.
666
667 Strings which begin with `0' are considered octal numbers. Null or miss-
668 ing arguments are considered `0'. The result of all expressions are
669 strings, which represent decimal numbers. It is important to note that
670 no two components of an expression can appear in the same word; except
671 when adjacent to components of expressions which are syntactically signi-
672 ficant to the parser (`&' `|' `<' `>' `(' `)') they should be surrounded
673 by spaces.
674
675 Also available in expressions as primitive operands are command execu-
676 tions enclosed in `{' and `}' and file enquiries of the form -\b-l\bl _\bn_\ba_\bm_\be
677 where l\bl is one of:
678
679 r read access
680 w write access
681 x execute access
682 e existence
683 o ownership
684 z zero size
685 f plain file
686 d directory
687
688 The specified name is command and filename expanded and then tested to
689 see if it has the specified relationship to the real user. If the file
690 does not exist or is inaccessible then all enquiries return false, i.e.
691 `0'. Command executions succeed, returning true, i.e. `1', if the com-
692 mand exits with status 0, otherwise they fail, returning false, i.e. `0'.
693 If more detailed status information is required then the command should
694 be executed outside of an expression and the variable _\bs_\bt_\ba_\bt_\bu_\bs examined.
695
696 C\bCo\bon\bnt\btr\bro\bol\bl f\bfl\blo\bow\bw
697 The shell contains a number of commands which can be used to regulate the
698 flow of control in command files (shell scripts) and (in limited but use-
699 ful ways) from terminal input. These commands all operate by forcing the
700 shell to reread or skip in its input and, due to the implementation, res-
701 trict the placement of some of the commands.
702
703 The f\bfo\bor\bre\bea\bac\bch\bh, s\bsw\bwi\bit\btc\bch\bh, and w\bwh\bhi\bil\ble\be statements, as well as the i\bif\bf-\b-t\bth\bhe\ben\bn-\b-e\bel\bls\bse\be
704 form of the i\bif\bf statement require that the major keywords appear in a sin-
705 gle simple command on an input line as shown below.
706
707 If the shell's input is not seekable, the shell buffers up input whenever
708 a loop is being read and performs seeks in this internal buffer to accom-
709 plish the rereading implied by the loop. (To the extent that this al-
710 lows, backward goto's will succeed on non-seekable inputs.)
711
712 B\bBu\bui\bil\blt\bti\bin\bn c\bco\bom\bmm\bma\ban\bnd\bds\bs
713 Builtin commands are executed within the shell. If a builtin command oc-
714 curs as any component of a pipeline except the last then it is executed
715 in a subshell.
716
717 a\bal\bli\bia\bas\bs
718 a\bal\bli\bia\bas\bs _\bn_\ba_\bm_\be
719 a\bal\bli\bia\bas\bs _\bn_\ba_\bm_\be _\bw_\bo_\br_\bd_\bl_\bi_\bs_\bt
720 The first form prints all aliases. The second form prints the
721 alias for name. The final form assigns the specified _\bw_\bo_\br_\bd_\bl_\bi_\bs_\bt as
722 the alias of _\bn_\ba_\bm_\be; _\bw_\bo_\br_\bd_\bl_\bi_\bs_\bt is command and filename substituted.
723 _\bN_\ba_\bm_\be is not allowed to be _\ba_\bl_\bi_\ba_\bs or _\bu_\bn_\ba_\bl_\bi_\ba_\bs.
724
725 a\bal\bll\blo\boc\bc
726 Shows the amount of dynamic memory acquired, broken down into used
727 and free memory. With an argument shows the number of free and
728 used blocks in each size category. The categories start at size 8
729 and double at each step. This command's output may vary across
730 system types, since systems other than the VAX may use a different
731 memory allocator.
732
733 b\bbg\bg
734 b\bbg\bg %\b%_\bj_\bo_\bb ...
735 Puts the current or specified jobs into the background, continuing
736 them if they were stopped.
737
738 b\bbr\bre\bea\bak\bk
739 Causes execution to resume after the e\ben\bnd\bd of the nearest enclosing
740 f\bfo\bor\bre\bea\bac\bch\bh or w\bwh\bhi\bil\ble\be. The remaining commands on the current line are
741 executed. Multi-level breaks are thus possible by writing them all
742 on one line.
743
744 b\bbr\bre\bea\bak\bks\bsw\bw
745 Causes a break from a s\bsw\bwi\bit\btc\bch\bh, resuming after the e\ben\bnd\bds\bsw\bw.
746
747 c\bca\bas\bse\be _\bl_\ba_\bb_\be_\bl:
748 A label in a s\bsw\bwi\bit\btc\bch\bh statement as discussed below.
749
750 c\bcd\bd
751 c\bcd\bd _\bn_\ba_\bm_\be
752 c\bch\bhd\bdi\bir\br
753 c\bch\bhd\bdi\bir\br _\bn_\ba_\bm_\be
754 Change the shell's working directory to directory _\bn_\ba_\bm_\be. If no ar-
755 gument is given then change to the home directory of the user. If
756 _\bn_\ba_\bm_\be is not found as a subdirectory of the current directory (and
757 does not begin with `/', `./' or `../'), then each component of the
758 variable c\bcd\bdp\bpa\bat\bth\bh is checked to see if it has a subdirectory _\bn_\ba_\bm_\be.
759 Finally, if all else fails but _\bn_\ba_\bm_\be is a shell variable whose value
760 begins with `/', then this is tried to see if it is a directory.
761
762 c\bco\bon\bnt\bti\bin\bnu\bue\be
763 Continue execution of the nearest enclosing w\bwh\bhi\bil\ble\be or f\bfo\bor\bre\bea\bac\bch\bh. The
764 rest of the commands on the current line are executed.
765
766 d\bde\bef\bfa\bau\bul\blt\bt:
767 Labels the default case in a s\bsw\bwi\bit\btc\bch\bh statement. The default should
768 come after all c\bca\bas\bse\be labels.
769
770 d\bdi\bir\brs\bs
771 Prints the directory stack; the top of the stack is at the left,
772 the first directory in the stack being the current directory.
773
774 e\bec\bch\bho\bo _\bw_\bo_\br_\bd_\bl_\bi_\bs_\bt
775 e\bec\bch\bho\bo -\b-n\bn _\bw_\bo_\br_\bd_\bl_\bi_\bs_\bt
776 The specified words are written to the shells standard output,
777 separated by spaces, and terminated with a newline unless the -\b-n\bn
778 option is specified.
779
780 e\bel\bls\bse\be
781 e\ben\bnd\bd
782 e\ben\bnd\bdi\bif\bf
783 e\ben\bnd\bds\bsw\bw
784 See the description of the f\bfo\bor\bre\bea\bac\bch\bh, i\bif\bf, s\bsw\bwi\bit\btc\bch\bh, and w\bwh\bhi\bil\ble\be state-
785 ments below.
786
787 e\bev\bva\bal\bl _\ba_\br_\bg ...
788 (As in sh(1).) The arguments are read as input to the shell and the
789 resulting command(s) executed in the context of the current shell.
790 This is usually used to execute commands generated as the result of
791 command or variable substitution, since parsing occurs before these
792 substitutions. See tset(1) for an example of using e\bev\bva\bal\bl.
793
794 e\bex\bxe\bec\bc _\bc_\bo_\bm_\bm_\ba_\bn_\bd
795 The specified command is executed in place of the current shell.
796
797 e\bex\bxi\bit\bt
798 e\bex\bxi\bit\bt (_\be_\bx_\bp_\br)
799 The shell exits either with the value of the s\bst\bta\bat\btu\bus\bs variable (first
800 form) or with the value of the specified e\bex\bxp\bpr\br (second form).
801
802 f\bfg\bg
803 f\bfg\bg %\b%_\bj_\bo_\bb ...
804 Brings the current or specified jobs into the foreground,
805 continuing them if they were stopped.
806
807 f\bfo\bor\bre\bea\bac\bch\bh _\bn_\ba_\bm_\be (_\bw_\bo_\br_\bd_\bl_\bi_\bs_\bt)
808 ...
809 e\ben\bnd\bd The variable n\bna\bam\bme\be is successively set to each member of w\bwo\bor\brd\bdl\bli\bis\bst\bt
810 and the sequence of commands between this command and the matching
811 e\ben\bnd\bd are executed. (Both f\bfo\bor\bre\bea\bac\bch\bh and e\ben\bnd\bd must appear alone on
812 separate lines.) The builtin command c\bco\bon\bnt\bti\bin\bnu\bue\be may be used to con-
813 tinue the loop prematurely and the builtin command b\bbr\bre\bea\bak\bk to ter-
814 minate it prematurely. When this command is read from the termi-
815 nal, the loop is read up once prompting with `?' before any state-
816 ments in the loop are executed. If you make a mistake typing in a
817 loop at the terminal you can rub it out.
818
819 g\bgl\blo\bob\bb _\bw_\bo_\br_\bd_\bl_\bi_\bs_\bt
820 Like e\bec\bch\bho\bo but no `\' escapes are recognized and words are delimited
821 by null characters in the output. Useful for programs which wish
822 to use the shell to filename expand a list of words.
823
824 g\bgo\bot\bto\bo _\bw_\bo_\br_\bd
825 The specified w\bwo\bor\brd\bd is filename and command expanded to yield a
826 string of the form `label'. The shell rewinds its input as much as
827 possible and searches for a line of the form `label:' possibly pre-
828 ceded by blanks or tabs. Execution continues after the specified
829 line.
830
831 h\bha\bas\bsh\bhs\bst\bta\bat\bt
832 Print a statistics line indicating how effective the internal hash
833 table has been at locating commands (and avoiding e\bex\bxe\bec\bc's). An e\bex\bxe\bec\bc
834 is attempted for each component of the _\bp_\ba_\bt_\bh where the hash function
835 indicates a possible hit, and in each component which does not be-
836 gin with a `/'.
837
838 h\bhi\bis\bst\bto\bor\bry\by
839 h\bhi\bis\bst\bto\bor\bry\by _\bn
840 h\bhi\bis\bst\bto\bor\bry\by -\b-r\br _\bn
841 h\bhi\bis\bst\bto\bor\bry\by -\b-h\bh _\bn
842 Displays the history event list; if _\bn is given only the _\bn most re-
843 cent events are printed. The -\b-r\br option reverses the order of prin-
844 tout to be most recent first rather than oldest first. The -\b-h\bh op-
845 tion causes the history list to be printed without leading numbers.
846 This is used to produce files suitable for sourceing using the -h
847 option to s\bso\bou\bur\brc\bce\be.
848
849 i\bif\bf (_\be_\bx_\bp_\br)
850 _\bc_\bo_\bm_\bm_\ba_\bn_\bd If the specified expression evaluates true, then the single
851 _\bc_\bo_\bm_\bm_\ba_\bn_\bd with arguments is executed. Variable substitution on
852 _\bc_\bo_\bm_\bm_\ba_\bn_\bd happens early, at the same time it does for the rest of the
853 i\bif\bf _\bc_\bo_\bm_\bm_\ba_\bn_\bd. _\bC_\bo_\bm_\bm_\ba_\bn_\bd must be a simple command, not a pipeline, a
854 command list, or a parenthesized command list. Input/output
855 redirection occurs even if _\be_\bx_\bp_\br is false, when command is n\bno\bot\bt exe-
856 cuted (this is a bug).
857
858 i\bif\bf (_\be_\bx_\bp_\br) _\bt_\bh_\be_\bn
859 ...
860 e\bel\bls\bse\be i\bif\bf (_\be_\bx_\bp_\br_\b2) t\bth\bhe\ben\bn
861 ...
862 e\bel\bls\bse\be
863 ...
864 e\ben\bnd\bdi\bif\bf
865 If the specified _\be_\bx_\bp_\br is true then the commands to the first e\bel\bls\bse\be
866 are executed; otherwise if _\be_\bx_\bp_\br_\b2 is true then the commands to the
867 second e\bel\bls\bse\be are executed, etc. Any number of e\bel\bls\bse\be-\b-i\bif\bf pairs are
868 possible; only one e\ben\bnd\bdi\bif\bf is needed. The e\bel\bls\bse\be part is likewise op-
869 tional. (The words e\bel\bls\bse\be and e\ben\bnd\bdi\bif\bf must appear at the beginning of
870 input lines; the i\bif\bf must appear alone on its input line or after an
871 e\bel\bls\bse\be.)
872
873 j\bjo\bob\bbs\bs
874 j\bjo\bob\bbs\bs -\b-l\bl
875 Lists the active jobs; given the -\b-l\bl options lists process id's in
876 addition to the normal information.
877
878 k\bki\bil\bll\bl %\b%_\bj_\bo_\bb
879 k\bki\bil\bll\bl _\bp_\bi_\bd
880 k\bki\bil\bll\bl -\b-s\bsi\big\bg_\bp_\bi_\bd ...
881 k\bki\bil\bll\bl -\b-l\bl
882 Sends either the TERM (terminate) signal or the specified signal to
883 the specified jobs or processes. Signals are either given by
884 number or by names (as given in /_\bu_\bs_\br/_\bi_\bn_\bc_\bl_\bu_\bd_\be/_\bs_\bi_\bg_\bn_\ba_\bl._\bh, stripped of
885 the prefix ``SIG''). The signal names are listed by ``kill -l''.
886 There is no default, saying just `kill' does not send a signal to
887 the current job. If the signal being sent is TERM (terminate) or
888 HUP (hangup), then the job or process will be sent a CONT (contin-
889 ue) signal as well.
890
891 l\bli\bim\bmi\bit\bt
892 l\bli\bim\bmi\bit\bt _\br_\be_\bs_\bo_\bu_\br_\bc_\be
893 l\bli\bim\bmi\bit\bt _\br_\be_\bs_\bo_\bu_\br_\bc_\be _\bm_\ba_\bx_\bi_\bm_\bu_\bm-_\bu_\bs_\be
894 l\bli\bim\bmi\bit\bt -\b-h\bh
895 l\bli\bim\bmi\bit\bt -\b-h\bh _\br_\be_\bs_\bo_\bu_\br_\bc_\be
896 l\bli\bim\bmi\bit\bt -\b-h\bh _\br_\be_\bs_\bo_\bu_\br_\bc_\be _\bm_\ba_\bx_\bi_\bm_\bu_\bm-_\bu_\bs_\be
897 Limits the consumption by the current process and each process it
898 creates to not individually exceed _\bm_\ba_\bx_\bi_\bm_\bu_\bm-_\bu_\bs_\be on the specified
899 _\br_\be_\bs_\bo_\bu_\br_\bc_\be. If no _\bm_\ba_\bx_\bi_\bm_\bu_\bm-_\bu_\bs_\be is given, then the current limit is
900 printed; if no _\br_\be_\bs_\bo_\bu_\br_\bc_\be is given, then all limitations are given.
901 If the -\b-h\bh flag is given, the hard limits are used instead of the
902 current limits. The hard limits impose a ceiling on the values of
903 the current limits. Only the super-user may raise the hard limits,
904 but a user may lower or raise the current limits within the legal
905 range.
906
907 Resources controllable currently include _\bc_\bp_\bu_\bt_\bi_\bm_\be (the maximum
908 number of cpu-seconds to be used by each process), _\bf_\bi_\bl_\be_\bs_\bi_\bz_\be (the
909 largest single file which can be created), _\bd_\ba_\bt_\ba_\bs_\bi_\bz_\be (the maximum
910 growth of the data+stack region via sbrk(2) beyond the end of the
911 program text), _\bs_\bt_\ba_\bc_\bk_\bs_\bi_\bz_\be (the maximum size of the automatically-
912 extended stack region), and _\bc_\bo_\br_\be_\bd_\bu_\bm_\bp_\bs_\bi_\bz_\be (the size of the largest
913 core dump that will be created).
914
915 The _\bm_\ba_\bx_\bi_\bm_\bu_\bm-_\bu_\bs_\be may be given as a (floating point or integer)
916 number followed by a scale factor. For all limits other than
917 _\bc_\bp_\bu_\bt_\bi_\bm_\be the default scale is `k' or `kilobytes' (1024 bytes); a
918 scale factor of `m' or `megabytes' may also be used. For _\bc_\bp_\bu_\bt_\bi_\bm_\be
919 the default scaling is `seconds', while `m' for minutes or `h' for
920 hours, or a time of the form `mm:ss' giving minutes and seconds may
921 be used.
922
923 For both _\br_\be_\bs_\bo_\bu_\br_\bc_\be names and scale factors, unambiguous prefixes of
924 the names suffice.
925
926 l\blo\bog\bgi\bin\bn
927 Terminate a login shell, replacing it with an instance of
928 /_\bb_\bi_\bn/_\bl_\bo_\bg_\bi_\bn. This is one way to log off, included for compatibility
929 with sh(1).
930
931 l\blo\bog\bgo\bou\but\bt
932 Terminate a login shell. Especially useful if i\big\bgn\bno\bor\bre\bee\beo\bof\bf is set.
933
934 n\bni\bic\bce\be
935 n\bni\bic\bce\be +_\bn_\bu_\bm_\bb_\be_\br
936 n\bni\bic\bce\be _\bc_\bo_\bm_\bm_\ba_\bn_\bd
937 n\bni\bic\bce\be +_\bn_\bu_\bm_\bb_\be_\br _\bc_\bo_\bm_\bm_\ba_\bn_\bd
938 The first form sets the scheduling priority for this shell to 4.
939 The second form sets the priority to the given _\bn_\bu_\bm_\bb_\be_\br. The final
940 two forms run command at priority 4 and _\bn_\bu_\bm_\bb_\be_\br respectively. The
941 greater the number, the less cpu the process will get. The super-
942 user may specify negative priority by using `nice -number ...'.
943 Command is always executed in a sub-shell, and the restrictions
944 placed on commands in simple i\bif\bf statements apply.
945
946 n\bno\boh\bhu\bup\bp
947 n\bno\boh\bhu\bup\bp _\bc_\bo_\bm_\bm_\ba_\bn_\bd
948 The first form can be used in shell scripts to cause hangups to be
949 ignored for the remainder of the script. The second form causes
950 the specified command to be run with hangups ignored. All
951 processes detached with `&' are effectively n\bno\boh\bhu\bup\bp'ed.
952
953 n\bno\bot\bti\bif\bfy\by
954 n\bno\bot\bti\bif\bfy\by %\b% _\bj_\bo_\bb ...
955 Causes the shell to notify the user asynchronously when the status
956 of the current or specified jobs changes; normally notification is
957 presented before a prompt. This is automatic if the shell variable
958 n\bno\bot\bti\bif\bfy\by is set.
959
960 o\bon\bni\bin\bnt\btr\br
961 o\bon\bni\bin\bnt\btr\br -\b-
962 o\bon\bni\bin\bnt\btr\br _\bl_\ba_\bb_\be_\bl
963 Control the action of the shell on interrupts. The first form
964 restores the default action of the shell on interrupts which is to
965 terminate shell scripts or to return to the terminal command input
966 level. The second form `onintr -' causes all interrupts to be
967 ignored. The final form causes the shell to execute a `goto label'
968 when an interrupt is received or a child process terminates because
969 it was interrupted.
970
971 In any case, if the shell is running detached and interrupts are
972 being ignored, all forms of o\bon\bni\bin\bnt\btr\br have no meaning and interrupts
973 continue to be ignored by the shell and all invoked commands.
974
975 p\bpo\bop\bpd\bd
976 p\bpo\bop\bpd\bd +_\bn
977 Pops the directory stack, returning to the new top directory. With
978 an argument `+_\bn' discards the _\bn'th entry in the stack. The
979 elements of the directory stack are numbered from 0 starting at the
980 top.
981
982 p\bpu\bus\bsh\bhd\bd
983 p\bpu\bus\bsh\bhd\bd _\bn_\ba_\bm_\be
984 p\bpu\bus\bsh\bhd\bd _\bn
985 With no arguments, p\bpu\bus\bsh\bhd\bd exchanges the top two elements of the
986 directory stack. Given a _\bn_\ba_\bm_\be argument, p\bpu\bus\bsh\bhd\bd changes to the new
987 directory (ala c\bcd\bd) and pushes the old current working directory (as
988 in c\bcs\bsw\bw) onto the directory stack. With a numeric argument, rotates
989 the _\bn'th argument of the directory stack around to be the top
990 element and changes to it. The members of the directory stack are
991 numbered from the top starting at 0.
992 r\bre\beh\bha\bas\bsh\bh
993 Causes the internal hash table of the contents of the directories
994 in the p\bpa\bat\bth\bh variable to be recomputed. This is needed if new com-
995 mands are added to directories in the p\bpa\bat\bth\bh while you are logged in.
996 This should only be necessary if you add commands to one of your
997 own directories, or if a systems programmer changes the contents of
998 one of the system directories.
999
1000 r\bre\bep\bpe\bea\bat\bt _\bc_\bo_\bu_\bn_\bt _\bc_\bo_\bm_\bm_\ba_\bn_\bd
1001 The specified _\bc_\bo_\bm_\bm_\ba_\bn_\bd which is subject to the same restrictions as
1002 the _\bc_\bo_\bm_\bm_\ba_\bn_\bd in the one line i\bif\bf statement above, is executed _\bc_\bo_\bu_\bn_\bt
1003 times. I/O redirections occur exactly once, even if _\bc_\bo_\bu_\bn_\bt is 0.
1004
1005 s\bse\bet\bt
1006 s\bse\bet\bt _\bn_\ba_\bm_\be
1007 s\bse\bet\bt _\bn_\ba_\bm_\be=_\bw_\bo_\br_\bd
1008 s\bse\bet\bt _\bn_\ba_\bm_\be[index]=_\bw_\bo_\br_\bd
1009 s\bse\bet\bt _\bn_\ba_\bm_\be=(_\bw_\bo_\br_\bd_\bl_\bi_\bs_\bt)
1010 The first form of the command shows the value of all shell
1011 variables. Variables which have other than a single word as value
1012 print as a parenthesized word list. The second form sets n\bna\bam\bme\be to
1013 the null string. The third form sets n\bna\bam\bme\be to the single w\bwo\bor\brd\bd. The
1014 fourth form sets the _\bi_\bn_\bd_\be_\bx'th component of name to word; this
1015 component must already exist. The final form sets _\bn_\ba_\bm_\be to the list
1016 of words in _\bw_\bo_\br_\bd_\bl_\bi_\bs_\bt. In all cases the value is command and
1017 filename expanded.
1018
1019 These arguments may be repeated to set multiple values in a single
1020 set command. Note however, that variable expansion happens for all
1021 arguments before any setting occurs.
1022
1023 s\bse\bet\bte\ben\bnv\bv
1024 s\bse\bet\bte\ben\bnv\bv _\bn_\ba_\bm_\be _\bv_\ba_\bl_\bu_\be
1025 s\bse\bet\bte\ben\bnv\bv _\bn_\ba_\bm_\be
1026 The first form lists all current environment variables. The last
1027 form sets the value of environment variable _\bn_\ba_\bm_\be to be _\bv_\ba_\bl_\bu_\be, a
1028 single string. The second form sets _\bn_\ba_\bm_\be to an empty string. The
1029 most commonly used environment variable USER, TERM, and PATH are
1030 automatically imported to and exported from the c\bcs\bsh\bh variables _\bu_\bs_\be_\br,
1031 [_\bt_\be_\br_\bm], and _\bp_\ba_\bt_\bh; there is no need to use s\bse\bet\bte\ben\bnv\bv for these.
1032
1033 s\bsh\bhi\bif\bft\bt
1034 s\bsh\bhi\bif\bft\bt _\bv_\ba_\br_\bi_\ba_\bb_\bl_\be
1035 The members of a\bar\brg\bgv\bv are shifted to the left, discarding a\bar\brg\bgv\bv[1].
1036 It is an error for a\bar\brg\bgv\bv not to be set or to have less than one word
1037 as value. The second form performs the same function on the speci-
1038 fied variable.
1039
1040 s\bso\bou\bur\brc\bce\be _\bn_\ba_\bm_\be
1041 s\bso\bou\bur\brc\bce\be -\b-h\bh _\bn_\ba_\bm_\be
1042 The shell reads commands from n\bna\bam\bme\be. S\bSo\bou\bur\brc\bce\be commands may be nested;
1043 if they are nested too deeply the shell may run out of file
1044 descriptors. An error in a s\bso\bou\bur\brc\bce\be at any level terminates all
1045 nested s\bso\bou\bur\brc\bce\be commands. Normally input during s\bso\bou\bur\brc\bce\be commands is
1046 not placed on the history list; the -h option causes the commands
1047 to be placed in the history list without being executed.
1048
1049 s\bst\bto\bop\bp
1050 s\bst\bto\bop\bp %\b%_\bj_\bo_\bb ...
1051 Stops the current or specified job which is executing in the
1052 background.
1053
1054 s\bsu\bus\bsp\bpe\ben\bnd\bd
1055 Causes the shell to stop in its tracks, much as if it had been sent
1056 a stop signal with ^\b^Z\bZ. This is most often used to stop shells
1057 started by su(1).
1058 s\bsw\bwi\bit\btc\bch\bh (_\bs_\bt_\br_\bi_\bn_\bg)
1059 c\bca\bas\bse\be _\bs_\bt_\br_\b1:
1060 ...
1061 b\bbr\bre\bea\bak\bks\bsw\bw
1062 ...
1063 d\bde\bef\bfa\bau\bul\blt\bt:
1064 ...
1065 b\bbr\bre\bea\bak\bks\bsw\bw
1066 e\ben\bnd\bds\bsw\bw
1067 Each case label is successively matched, against the specified
1068 _\bs_\bt_\br_\bi_\bn_\bg which is first command and filename expanded. The file
1069 metacharacters `*', `?' and `[...]' may be used in the case labels,
1070 which are variable expanded. If none of the labels match before a
1071 `default' label is found, then the execution begins after the de-
1072 fault label. Each case label and the default label must appear at
1073 the beginning of a line. The command b\bbr\bre\bea\bak\bks\bsw\bw causes execution to
1074 continue after the e\ben\bnd\bds\bsw\bw. Otherwise control may fall through case
1075 labels and default labels as in C. If no label matches and there
1076 is no default, execution continues after the e\ben\bnd\bds\bsw\bw.
1077
1078 t\bti\bim\bme\be
1079 t\bti\bim\bme\be _\bc_\bo_\bm_\bm_\ba_\bn_\bd
1080 With no argument, a summary of time used by this shell and its
1081 children is printed. If arguments are given the specified simple
1082 command is timed and a time summary as described under the t\bti\bim\bme\be
1083 variable is printed. If necessary, an extra shell is created to
1084 print the time statistic when the command completes.
1085
1086 u\bum\bma\bas\bsk\bk
1087 u\bum\bma\bas\bsk\bk _\bv_\ba_\bl_\bu_\be
1088 The file creation mask is displayed (first form) or set to the
1089 specified value (second form). The mask is given in octal. Common
1090 values for the mask are 002 giving all access to the group and read
1091 and execute access to others or 022 giving all access except no
1092 write access for users in the group or others.
1093
1094 u\bun\bna\bal\bli\bia\bas\bs _\bp_\ba_\bt_\bt_\be_\br_\bn
1095 All aliases whose names match the specified pattern are discarded.
1096 Thus all aliases are removed by `unalias *'. It is not an error
1097 for nothing to be u\bun\bna\bal\bli\bia\bas\bse\bed\bd.
1098
1099 u\bun\bnh\bha\bas\bsh\bh
1100 Use of the internal hash table to speed location of executed pro-
1101 grams is disabled.
1102
1103 u\bun\bnl\bli\bim\bmi\bit\bt
1104 u\bun\bnl\bli\bim\bmi\bit\bt _\br_\be_\bs_\bo_\bu_\br_\bc_\be
1105 u\bun\bnl\bli\bim\bmi\bit\bt -\b-h\bh
1106 u\bun\bnl\bli\bim\bmi\bit\bt -\b-h\bh _\br_\be_\bs_\bo_\bu_\br_\bc_\be
1107 Removes the limitation on _\br_\be_\bs_\bo_\bu_\br_\bc_\be. If no _\br_\be_\bs_\bo_\bu_\br_\bc_\be is specified,
1108 then all _\br_\be_\bs_\bo_\bu_\br_\bc_\be limitations are removed. If -\b-h\bh is given, the
1109 corresponding hard limits are removed. Only the super-user may do
1110 this.
1111
1112 u\bun\bns\bse\bet\bt _\bp_\ba_\bt_\bt_\be_\br_\bn
1113 All variables whose names match the specified pattern are removed.
1114 Thus all variables are removed by `unset *'; this has noticeably
1115 distasteful side-effects. It is not an error for nothing to be
1116 u\bun\bns\bse\bet\bt.
1117
1118 u\bun\bns\bse\bet\bte\ben\bnv\bv _\bp_\ba_\bt_\bt_\be_\br_\bn
1119 Removes all variables whose name match the specified pattern from
1120 the environment. See also the s\bse\bet\bte\ben\bnv\bv command above and prin-
1121 tenv(1).
1122
1123
1124 w\bwa\bai\bit\bt
1125 All background jobs are waited for. It the shell is interactive,
1126 then an interrupt can disrupt the wait, at which time the shell
1127 prints names and job numbers of all jobs known to be outstanding.
1128
1129 w\bwh\bhi\bil\ble\be (_\be_\bx_\bp_\br)
1130 ...
1131 e\ben\bnd\bd While the specified expression evaluates non-zero, the commands
1132 between the w\bwh\bhi\bil\ble\be and the matching end are evaluated. B\bBr\bre\bea\bak\bk and
1133 c\bco\bon\bnt\bti\bin\bnu\bue\be may be used to terminate or continue the loop prematurely.
1134 (The w\bwh\bhi\bil\ble\be and e\ben\bnd\bd must appear alone on their input lines.) Prompt-
1135 ing occurs here the first time through the loop as for the f\bfo\bor\bre\bea\bac\bch\bh
1136 statement if the input is a terminal.
1137
1138 %\b% _\bj_\bo_\bb
1139 Brings the specified job into the foreground.
1140
1141 %\b% _\bj_\bo_\bb &\b&
1142 Continues the specified job in the background.
1143
1144 @\b@
1145 @\b@ _\bn_\ba_\bm_\be = _\be_\bx_\bp_\br
1146 @\b@ _\bn_\ba_\bm_\be[index] =expr
1147 The first form prints the values of all the shell variables. The
1148 second form sets the specified _\bn_\ba_\bm_\be to the value of _\be_\bx_\bp_\br. If the
1149 expression contains `<', `>', `&' or `' then at least this part of
1150 the expression must be placed within `(' `)'. The third form as-
1151 signs the value of _\be_\bx_\bp_\br to the _\bi_\bn_\bd_\be_\bx'th argument of _\bn_\ba_\bm_\be. Both
1152 _\bn_\ba_\bm_\be and its _\bi_\bn_\bd_\be_\bx'th component must already exist.
1153
1154
1155 The operators `*=', `+=', etc are available as in C. The space
1156 separating the name from the assignment operator is optional. Spaces
1157 are, however, mandatory in separating components of _\be_\bx_\bp_\br which would oth-
1158 erwise be single words.
1159
1160 Special postfix `++' and `--' operators increment and decrement _\bn_\ba_\bm_\be
1161 respectively, i.e. `@ i++'.
1162
1163 P\bPr\bre\be-\b-d\bde\bef\bfi\bin\bne\bed\bd a\ban\bnd\bd e\ben\bnv\bvi\bir\bro\bon\bnm\bme\ben\bnt\bt v\bva\bar\bri\bia\bab\bbl\ble\bes\bs
1164 The following variables have special meaning to the shell. Of these,
1165 _\ba_\br_\bg_\bv, _\bc_\bw_\bd, _\bh_\bo_\bm_\be, _\bp_\ba_\bt_\bh, _\bp_\br_\bo_\bm_\bp_\bt, _\bs_\bh_\be_\bl_\bl and _\bs_\bt_\ba_\bt_\bu_\bs are always set by the
1166 shell. Except for _\bc_\bw_\bd and _\bs_\bt_\ba_\bt_\bu_\bs this setting occurs only at initializa-
1167 tion; these variables will not then be modified unless this is done ex-
1168 plicitly by the user.
1169
1170 This shell copies the environment variable USER into the variable _\bu_\bs_\be_\br,
1171 TERM into _\bt_\be_\br_\bm, and HOME into _\bh_\bo_\bm_\be, and copies these back into the en-
1172 vironment whenever the normal shell variables are reset. The environment
1173 variable PATH is likewise handled; it is not necessary to worry about its
1174 setting other than in the file ._\bc_\bs_\bh_\br_\bc as inferior c\bcs\bsh\bh processes will im-
1175 port the definition of _\bp_\ba_\bt_\bh from the environment, and re-export it if you
1176 then change it.
1177
1178 a\bar\brg\bgv\bv Set to the arguments to the shell, it is from this variable
1179 that positional parameters are substituted, i.e. `$1' is re-
1180 placed by `$argv[1]', etc.
1181
1182 c\bcd\bdp\bpa\bat\bth\bh Gives a list of alternate directories searched to find sub-
1183 directories in _\bc_\bh_\bd_\bi_\br commands.
1184
1185 c\bcw\bwd\bd The full pathname of the current directory.
1186
1187 e\bec\bch\bho\bo Set when the -\b-x\bx command line option is given. Causes each com-
1188 mand and its arguments to be echoed just before it is executed.
1189 For non-builtin commands all expansions occur before echoing.
1190 Builtin commands are echoed before command and filename substi-
1191 tution, since these substitutions are then done selectively.
1192
1193 f\bfi\bil\ble\bec\bc Enable file name completion.
1194
1195 h\bhi\bis\bst\btc\bch\bha\bar\brs\bs
1196 Can be given a string value to change the characters used in
1197 history substitution. The first character of its value is used
1198 as the history substitution character, replacing the default
1199 character `!'. The second character of its value replaces the
1200 character `|\b^' in quick substitutions.
1201
1202 h\bhi\bis\bst\bto\bor\bry\by Can be given a numeric value to control the size of the history
1203 list. Any command which has been referenced in this many
1204 events will not be discarded. Too large values of _\bh_\bi_\bs_\bt_\bo_\br_\by may
1205 run the shell out of memory. The last executed command is al-
1206 ways saved on the history list.
1207
1208 h\bho\bom\bme\be The home directory of the invoker, initialized from the en-
1209 vironment. The filename expansion of `~' refers to this
1210 variable.
1211
1212 i\big\bgn\bno\bor\bre\bee\beo\bof\bf
1213 If set the shell ignores end-of-file from input devices which
1214 are terminals. This prevents shells from accidentally being
1215 killed by control-D's.
1216
1217 m\bma\bai\bil\bl The files where the shell checks for mail. This is done after
1218 each command completion which will result in a prompt, if a
1219 specified interval has elapsed. The shell says `You have new
1220 mail.' if the file exists with an access time not greater than
1221 its modify time.
1222
1223 If the first word of the value of _\bm_\ba_\bi_\bl is numeric it specifies
1224 a different mail checking interval, in seconds, than the de-
1225 fault, which is 10 minutes.
1226
1227 If multiple mail files are specified, then the shell says `New
1228 mail in _\bn_\ba_\bm_\be' when there is mail in the file _\bn_\ba_\bm_\be.
1229
1230 n\bno\boc\bcl\blo\bob\bbb\bbe\ber\br
1231 As described in the section on _\bI_\bn_\bp_\bu_\bt/_\bo_\bu_\bt_\bp_\bu_\bt, restrictions are
1232 placed on output redirection to insure that files are not ac-
1233 cidentally destroyed, and that `>>' redirections refer to ex-
1234 isting files.
1235
1236 n\bno\bog\bgl\blo\bob\bb If set, filename expansion is inhibited. This is most useful
1237 in shell scripts which are not dealing with filenames, or after
1238 a list of filenames has been obtained and further expansions
1239 are not desirable.
1240
1241 n\bno\bon\bno\bom\bma\bat\btc\bch\bh
1242 If set, it is not an error for a filename expansion to not
1243 match any existing files; rather the primitive pattern is re-
1244 turned. It is still an error for the primitive pattern to be
1245 malformed, i.e. `echo [' still gives an error.
1246
1247 n\bno\bot\bti\bif\bfy\by If set, the shell notifies asynchronously of job completions.
1248 The default is to rather present job completions just before
1249 printing a prompt.
1250
1251 p\bpa\bat\bth\bh Each word of the path variable specifies a directory in which
1252 commands are to be sought for execution. A null word specifies
1253 the current directory. If there is no _\bp_\ba_\bt_\bh variable then only
1254 full path names will execute. The usual search path is `.',
1255 `/bin' and `/usr/bin', but this may vary from system to system.
1256 For the super-user the default search path is `/etc', `/bin'
1257 and `/usr/bin'. A shell which is given neither the -\b-c\bc nor the
1258 -\b-t\bt option will normally hash the contents of the directories in
1259 the _\bp_\ba_\bt_\bh variable after reading ._\bc_\bs_\bh_\br_\bc, and each time the _\bp_\ba_\bt_\bh
1260 variable is reset. If new commands are added to these direc-
1261 tories while the shell is active, it may be necessary to give
1262 the _\br_\be_\bh_\ba_\bs_\bh or the commands may not be found.
1263
1264 p\bpr\bro\bom\bmp\bpt\bt The string which is printed before each command is read from an
1265 interactive terminal input. If a `!' appears in the string it
1266 will be replaced by the current event number unless a preceding
1267 `\' is given. Default is `% ', or `# ' for the super-user.
1268
1269 s\bsa\bav\bve\beh\bhi\bis\bst\bt
1270 Is given a numeric value to control the number of entries of
1271 the history list that are saved in ~/.history when the user
1272 logs out. Any command which has been referenced in this many
1273 events will be saved. During start up the shell sources
1274 ~/.history into the history list enabling history to be saved
1275 across logins. Too large values of _\bs_\ba_\bv_\be_\bh_\bi_\bs_\bt will slow down the
1276 shell during start up.
1277
1278 s\bsh\bhe\bel\bll\bl The file in which the shell resides. This is used in forking
1279 shells to interpret files which have execute bits set, but
1280 which are not executable by the system. (See the description
1281 of _\bN_\bo_\bn-_\bb_\bu_\bi_\bl_\bt_\bi_\bn _\bC_\bo_\bm_\bm_\ba_\bn_\bd _\bE_\bx_\be_\bc_\bu_\bt_\bi_\bo_\bn below.) Initialized to the
1282 (system-dependent) home of the shell.
1283
1284 s\bst\bta\bat\btu\bus\bs The status returned by the last command. If it terminated ab-
1285 normally, then 0200 is added to the status. Builtin commands
1286 which fail return exit status `1', all other builtin commands
1287 set status `0'.
1288
1289 t\bti\bim\bme\be Controls automatic timing of commands. If set, then any com-
1290 mand which takes more than this many cpu seconds will cause a
1291 line giving user, system, and real times and a utilization per-
1292 centage which is the ratio of user plus system times to real
1293 time to be printed when it terminates.
1294
1295 v\bve\ber\brb\bbo\bos\bse\be Set by the -\b-v\bv command line option, causes the words of each
1296 command to be printed after history substitution.
1297
1298 N\bNo\bon\bn-\b-b\bbu\bui\bil\blt\bti\bin\bn c\bco\bom\bmm\bma\ban\bnd\bd e\bex\bxe\bec\bcu\but\bti\bio\bon\bn
1299 When a command to be executed is found to not be a builtin command the
1300 shell attempts to execute the command via execve(2). Each word in the
1301 variable _\bp_\ba_\bt_\bh names a directory from which the shell will attempt to exe-
1302 cute the command. If it is given neither a -\b-c\bc nor a -\b-t\bt option, the shell
1303 will hash the names in these directories into an internal table so that
1304 it will only try an e\bex\bxe\bec\bc in a directory if there is a possibility that
1305 the command resides there. This greatly speeds command location when a
1306 large number of directories are present in the search path. If this
1307 mechanism has been turned off (via u\bun\bnh\bha\bas\bsh\bh), or if the shell was given a
1308 -\b-c\bc or -\b-t\bt argument, and in any case for each directory component of _\bp_\ba_\bt_\bh
1309 which does not begin with a `/', the shell concatenates with the given
1310 command name to form a path name of a file which it then attempts to exe-
1311 cute.
1312
1313 Parenthesized commands are always executed in a subshell. Thus
1314
1315 (cd ; pwd) ; pwd
1316
1317 prints the _\bh_\bo_\bm_\be directory; leaving you where you were (printing this
1318 after the home directory), while
1319
1320 cd ; pwd
1321
1322 leaves you in the _\bh_\bo_\bm_\be directory. Parenthesized commands are most often
1323 used to prevent c\bch\bhd\bdi\bir\br from affecting the current shell.
1324
1325 If the file has execute permissions but is not an executable binary to
1326 the system, then it is assumed to be a file containing shell commands and
1327 a new shell is spawned to read it.
1328
1329 If there is an a\bal\bli\bia\bas\bs for s\bsh\bhe\bel\bll\bl then the words of the alias will be
1330 prepended to the argument list to form the shell command. The first word
1331 of the a\bal\bli\bia\bas\bs should be the full path name of the shell (e.g. `$shell').
1332 Note that this is a special, late occurring, case of a\bal\bli\bia\bas\bs substitution,
1333 and only allows words to be prepended to the argument list without modif-
1334 ication.
1335
1336 S\bSi\big\bgn\bna\bal\bl h\bha\ban\bnd\bdl\bli\bin\bng\bg
1337 The shell normally ignores _\bq_\bu_\bi_\bt signals. Jobs running detached (either
1338 by &\b& or the b\bbg\bg or %\b%.\b..\b..\b. &\b& commands) are immune to signals generated from
1339 the keyboard, including hangups. Other signals have the values which the
1340 shell inherited from its parent. The shell's handling of interrupts and
1341 terminate signals in shell scripts can be controlled by o\bon\bni\bin\bnt\btr\br. Login
1342 shells catch the _\bt_\be_\br_\bm_\bi_\bn_\ba_\bt_\be signal; otherwise this signal is passed on to
1343 children from the state in the shell's parent. In no case are interrupts
1344 allowed when a login shell is reading the file ._\bl_\bo_\bg_\bo_\bu_\bt.
1345
1346A\bAU\bUT\bTH\bHO\bOR\bR
1347 William Joy. Job control and directory stack features first implemented
1348 by J.E. Kulp of I.I.A.S.A, Laxenburg, Austria, with different syntax than
1349 that used now. File name completion code written by Ken Greer, HP Labs.
1350
1351F\bFI\bIL\bLE\bES\bS
1352 ~/._\bc_\bs_\bh_\br_\bc Read at beginning of execution by each shell.
1353 ~/._\bl_\bo_\bg_\bi_\bn Read by login shell, after `.cshrc' at login.
1354 ~/._\bl_\bo_\bg_\bo_\bu_\bt Read by login shell, at logout.
1355 /_\bb_\bi_\bn/_\bs_\bh Standard shell, for shell scripts not starting with a `#'.
1356 /_\bt_\bm_\bp/_\bs_\bh* Temporary file for `<<'.
1357 /_\be_\bt_\bc/_\bp_\ba_\bs_\bs_\bw_\bd Source of home directories for `~name'.
1358
1359
1360L\bLI\bIM\bMI\bIT\bTA\bAT\bTI\bIO\bON\bNS\bS
1361 Word lengths - Words can be no longer than 1024 characters. The system
1362 limits argument lists to 10240 characters. The number of arguments to a
1363 command which involves filename expansion is limited to 1/6'th the number
1364 of characters allowed in an argument list. Command substitutions may
1365 substitute no more characters than are allowed in an argument list. To
1366 detect looping, the shell restricts the number of a\bal\bli\bia\bas\bs substitutions on
1367 a single line to 20.
1368
1369S\bSE\bEE\bE A\bAL\bLS\bSO\bO
1370 sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), sigvec(2),
1371 umask(2), setrlimit(2), wait(2), tty(4), a.out(5), environ(7),
1372 _\bA_\bn _\bi_\bn_\bt_\br_\bo_\bd_\bu_\bc_\bt_\bi_\bo_\bn _\bt_\bo _\bt_\bh_\be _\bC _\bs_\bh_\be_\bl_\bl
1373
1374H\bHI\bIS\bST\bTO\bOR\bRY\bY
1375 C\bCs\bsh\bh Appeared in 3 BSD. It was a first implementation of a command
1376 language interpreter incorporating a history mechanism (see H\bHi\bis\bst\bto\bor\bry\by
1377 S\bSu\bub\bbs\bst\bti\bit\btu\but\bti\bio\bon\bns\bs), job control facilities (see J\bJo\bob\bbs\bs), interactive file name
1378 and user name completion (see F\bFi\bil\ble\be N\bNa\bam\bme\be C\bCo\bom\bmp\bpl\ble\bet\bti\bio\bon\bn), and a C-like syntax.
1379 There are now many shells which also have these mechanisms, plus a few
1380 more (and maybe some bugs too), which are available thru the internet, or
1381 as contributed software such as the ksh(korn shell).
1382
1383B\bBU\bUG\bGS\bS
1384 When a command is restarted from a stop, the shell prints the directory
1385 it started in if this is different from the current directory; this can
1386 be misleading (i.e. wrong) as the job may have changed directories inter-
1387 nally.
1388 Shell builtin functions are not stoppable/restartable. Command sequences
1389 of the form `a ; b ; c' are also not handled gracefully when stopping is
1390 attempted. If you suspend `b', the shell will then immediately execute
1391 `c'. This is especially noticeable if this expansion results from an
1392 _\ba_\bl_\bi_\ba_\bs. It suffices to place the sequence of commands in ()'s to force it
1393 to a subshell, i.e. `( a ; b ; c )'.
1394
1395 Control over tty output after processes are started is primitive; perhaps
1396 this will inspire someone to work on a good virtual terminal interface.
1397 In a virtual terminal interface much more interesting things could be
1398 done with output control.
1399
1400 Alias substitution is most often used to clumsily simulate shell pro-
1401 cedures; shell procedures should be provided rather than aliases.
1402
1403 Commands within loops, prompted for by `?', are not placed in the h\bhi\bis\bst\bto\bor\bry\by
1404 list. Control structure should be parsed rather than being recognized as
1405 built-in commands. This would allow control commands to be placed any-
1406 where, to be combined with `|', and to be used with `&' and `;' metasyn-
1407 tax.
1408
1409 It should be possible to use the `:' modifiers on the output of command
1410 substitutions. All and more than one `:' modifier should be allowed on
1411 `$' substitutions.
1412
1413 The way the f\bfi\bil\ble\bec\bc facility is implemented is ugly and expensive.