]>
Commit | Line | Data |
---|---|---|
726f6388 JA |
1 | .\" |
2 | .\" MAN PAGE COMMENTS to | |
3 | .\" | |
4 | .\" Chet Ramey | |
5 | .\" Information Network Services | |
6 | .\" Case Western Reserve University | |
7 | .\" chet@ins.CWRU.Edu | |
8 | .\" | |
cce855bc | 9 | .\" Last Change: Wed Apr 1 12:16:09 EST 1998 |
726f6388 JA |
10 | .\" |
11 | .\" bash_builtins, strip all but Built-Ins section | |
12 | .if \n(zZ=1 .ig zZ | |
cce855bc | 13 | .TH BASH 1 "1998 Apr 1" GNU |
726f6388 JA |
14 | .\" |
15 | .\" There's some problem with having a `@' | |
16 | .\" in a tagged paragraph with the BSD man macros. | |
17 | .\" It has to do with `@' appearing in the }1 macro. | |
18 | .\" This is a problem on 4.3 BSD and Ultrix, but Sun | |
19 | .\" appears to have fixed it. | |
20 | .\" If you're seeing the characters | |
21 | .\" `@u-3p' appearing before the lines reading | |
22 | .\" `possible-hostname-completions | |
23 | .\" and `complete-hostname' down in READLINE, | |
24 | .\" then uncomment this redefinition. | |
25 | .\" | |
26 | .de }1 | |
27 | .ds ]X \&\\*(]B\\ | |
28 | .nr )E 0 | |
29 | .if !"\\$1"" .nr )I \\$1n | |
30 | .}f | |
31 | .ll \\n(LLu | |
32 | .in \\n()Ru+\\n(INu+\\n()Iu | |
33 | .ti \\n(INu | |
34 | .ie !\\n()Iu+\\n()Ru-\w\a\\*(]X\au-3p \{\\*(]X | |
35 | .br\} | |
36 | .el \\*(]X\h\a|\\n()Iu+\\n()Ru\a\c | |
37 | .}f | |
38 | .. | |
39 | .\" | |
40 | .\" File Name macro. This used to be `.PN', for Path Name, | |
41 | .\" but Sun doesn't seem to like that very much. | |
42 | .\" | |
43 | .de FN | |
44 | \fI\|\\$1\|\fP | |
45 | .. | |
46 | .SH NAME | |
ccc6cda3 | 47 | bash \- GNU Bourne-Again SHell |
726f6388 JA |
48 | .SH SYNOPSIS |
49 | .B bash | |
50 | [options] | |
51 | [file] | |
52 | .SH COPYRIGHT | |
ccc6cda3 JA |
53 | .if n Bash is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc. |
54 | .if t Bash is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc. | |
726f6388 JA |
55 | .SH DESCRIPTION |
56 | .B Bash | |
ccc6cda3 | 57 | is an \fBsh\fR-compatible command language interpreter that |
726f6388 JA |
58 | executes commands read from the standard input or from a file. |
59 | .B Bash | |
60 | also incorporates useful features from the \fIKorn\fP and \fIC\fP | |
61 | shells (\fBksh\fP and \fBcsh\fP). | |
62 | .PP | |
63 | .B Bash | |
cce855bc | 64 | is intended to be a conformant implementation of the IEEE |
ccc6cda3 | 65 | POSIX Shell and Tools specification (IEEE Working Group 1003\.2). |
726f6388 | 66 | .SH OPTIONS |
ccc6cda3 | 67 | In addition to the single-character shell options documented in the |
726f6388 | 68 | description of the \fBset\fR builtin command, \fBbash\fR |
cce855bc | 69 | interprets the following options when it is invoked: |
726f6388 JA |
70 | .PP |
71 | .PD 0 | |
72 | .TP 10 | |
73 | .BI \-c "\| string\^" | |
ccc6cda3 | 74 | If the |
726f6388 | 75 | .B \-c |
cce855bc | 76 | option is present, then commands are read from |
726f6388 JA |
77 | .IR string . |
78 | If there are arguments after the | |
79 | .IR string , | |
80 | they are assigned to the positional parameters, starting with | |
81 | .BR $0 . | |
82 | .TP | |
ccc6cda3 JA |
83 | .B \-r |
84 | If the | |
85 | .B \-r | |
cce855bc | 86 | option is present, the shell becomes |
ccc6cda3 JA |
87 | .I restricted |
88 | (see | |
89 | .SM | |
90 | .B "RESTRICTED SHELL" | |
91 | below). | |
92 | .TP | |
726f6388 JA |
93 | .B \-i |
94 | If the | |
95 | .B \-i | |
cce855bc | 96 | option is present, the shell is |
726f6388 JA |
97 | .IR interactive . |
98 | .TP | |
99 | .B \-s | |
100 | If the | |
101 | .B \-s | |
cce855bc | 102 | option is present, or if no arguments remain after option |
726f6388 JA |
103 | processing, then commands are read from the standard input. |
104 | This option allows the positional parameters to be set | |
105 | when invoking an interactive shell. | |
106 | .TP | |
ccc6cda3 JA |
107 | .B \-D |
108 | A list of all double-quoted strings preceded by \fB$\fP | |
109 | is printed on the standard ouput. | |
110 | These are the strings that | |
111 | are subject to language translation when the current locale | |
112 | is not C or POSIX. | |
113 | This implies the \fB\-n\fP option; no commands will be executed. | |
114 | .TP | |
115 | .B \-\- | |
116 | A | |
117 | .B \-\- | |
726f6388 JA |
118 | signals the end of options and disables further option processing. |
119 | Any arguments after the | |
726f6388 | 120 | .B \-\- |
ccc6cda3 JA |
121 | are treated as filenames and arguments. An argument of |
122 | .B \- | |
123 | is equivalent to \fB\-\-\fP. | |
726f6388 JA |
124 | .PD |
125 | .PP | |
126 | .B Bash | |
ccc6cda3 JA |
127 | also interprets a number of multi-character options. |
128 | These options must appear on the command line before the | |
129 | single-character options in order for them to be recognized. | |
726f6388 JA |
130 | .PP |
131 | .PD 0 | |
726f6388 | 132 | .TP |
cce855bc JA |
133 | .B \-\-dump\-po\-strings |
134 | Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP | |
135 | \fBpo\fP (portable object) file format. | |
136 | .TP | |
ccc6cda3 JA |
137 | .B \-\-dump\-strings |
138 | Equivalent to \fB\-D\fP. | |
139 | .TP | |
140 | .B \-\-help | |
141 | Display a usage message on standard output and exit successfully. | |
142 | .TP | |
143 | .B \-\-login | |
144 | Make | |
145 | .B bash | |
146 | act as if it had been invoked as a login shell (see | |
147 | .SM | |
148 | .B INVOCATION | |
149 | below). | |
150 | .TP | |
151 | .B \-\-noediting | |
152 | Do not use the GNU | |
153 | .B readline | |
154 | library to read command lines if interactive. | |
155 | .TP | |
156 | .B \-\-noprofile | |
157 | Do not read either the system-wide startup file | |
726f6388 JA |
158 | .FN /etc/profile |
159 | or any of the personal initialization files | |
160 | .IR ~/.bash_profile , | |
161 | .IR ~/.bash_login , | |
162 | or | |
163 | .IR ~/.profile . | |
164 | By default, | |
165 | .B bash | |
ccc6cda3 | 166 | reads these files when it is invoked as a login shell (see |
726f6388 JA |
167 | .SM |
168 | .B INVOCATION | |
169 | below). | |
170 | .TP | |
ccc6cda3 JA |
171 | .B \-\-norc |
172 | Do not read and execute the personal initialization file | |
173 | .I ~/.bashrc | |
174 | if the shell is interactive. | |
175 | This option is on by default if the shell is invoked as | |
176 | .BR sh . | |
177 | .TP | |
178 | .B \-\-posix | |
179 | Change the behavior of \fBbash\fP where the default operation differs | |
180 | from the POSIX 1003.2 standard to match the standard. | |
181 | .TP | |
182 | \fB\-\-rcfile\fP \fIfile\fP | |
726f6388 JA |
183 | Execute commands from |
184 | .I file | |
185 | instead of the standard personal initialization file | |
ccc6cda3 | 186 | .I ~/.bashrc |
726f6388 JA |
187 | if the shell is interactive (see |
188 | .SM | |
189 | .B INVOCATION | |
190 | below). | |
191 | .TP | |
ccc6cda3 JA |
192 | .B \-\-restricted |
193 | The shell becomes restricted (see | |
194 | .SM | |
195 | .B "RESTRICTED SHELL" | |
726f6388 JA |
196 | below). |
197 | .TP | |
ccc6cda3 JA |
198 | .B \-\-verbose |
199 | Equivalent to \fB\-v\fP. | |
726f6388 | 200 | .TP |
ccc6cda3 JA |
201 | .B \-\-version |
202 | Show version information for this instance of | |
203 | .B bash | |
204 | on the standard output and exit successfully. | |
726f6388 JA |
205 | .PD |
206 | .SH ARGUMENTS | |
207 | If arguments remain after option processing, and neither the | |
208 | .B \-c | |
209 | nor the | |
210 | .B \-s | |
211 | option has been supplied, the first argument is assumed to | |
ccc6cda3 JA |
212 | be the name of a file containing shell commands. |
213 | If | |
726f6388 JA |
214 | .B bash |
215 | is invoked in this fashion, | |
216 | .B $0 | |
217 | is set to the name of the file, and the positional parameters | |
218 | are set to the remaining arguments. | |
219 | .B Bash | |
220 | reads and executes commands from this file, then exits. | |
ccc6cda3 JA |
221 | \fBBash\fP's exit status is the exit status of the last command |
222 | executed in the script. | |
223 | If no commands are executed, the exit status is 0. | |
224 | .SH INVOCATION | |
225 | A \fIlogin shell\fP is one whose first character of argument zero is a | |
226 | .BR \- , | |
227 | or one started with the | |
228 | .B \-\-login | |
229 | option. | |
230 | .PP | |
231 | An \fIinteractive\fP shell is one whose standard input and output are | |
232 | both connected to terminals (as determined by | |
233 | .IR isatty (3)), | |
234 | or one started with the | |
235 | .B \-i | |
236 | option. | |
237 | .SM | |
238 | .B PS1 | |
239 | is set and | |
240 | .B $\- | |
241 | includes | |
242 | .B i | |
243 | if | |
244 | .B bash | |
245 | is interactive, | |
246 | allowing a shell script or a startup file to test this state. | |
247 | .PP | |
248 | The following paragraphs describe how | |
249 | .B bash | |
250 | executes its startup files. | |
251 | If any of the files exist but cannot be read, | |
252 | .B bash | |
253 | reports an error. | |
254 | Tildes are expanded in file names as described below under | |
255 | .B "Tilde Expansion" | |
256 | in the | |
257 | .SM | |
258 | .B EXPANSION | |
259 | section. | |
260 | .PP | |
261 | When | |
262 | .B bash | |
d166f048 JA |
263 | is invoked as an interactive login shell, it first reads and |
264 | executes commands from the file \fI/etc/profile\fP, if that | |
265 | file exists. | |
ccc6cda3 JA |
266 | After reading that file, it looks for \fI~/.bash_profile\fP, |
267 | \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads | |
268 | and executes commands from the first one that exists and is readable. | |
269 | The | |
270 | .B \-\-noprofile | |
271 | option may be used when the shell is started to inhibit this behavior. | |
272 | .PP | |
273 | When a login shell exits, | |
274 | .B bash | |
275 | reads and executes commands from the file \fI~/.bash_logout\fP, if it | |
276 | exists. | |
277 | .PP | |
278 | When an interactive shell that is not a login shell is started, | |
279 | .B bash | |
280 | reads and executes commands from \fI~/.bashrc\fP, if that file exists. | |
281 | This may be inhibited by using the | |
282 | .B \-\-norc | |
283 | option. | |
284 | The \fB\-\-rcfile\fP \fIfile\fP option will force | |
285 | .B bash | |
286 | to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP. | |
287 | .PP | |
288 | When | |
289 | .B bash | |
290 | is started non-interactively, to run a shell script, for example, it | |
291 | looks for the variable | |
292 | .SM | |
293 | .B BASH_ENV | |
294 | in the environment, expands its value if it appears there, and uses the | |
295 | expanded value as the name of a file to read and execute. | |
296 | .B Bash | |
297 | behaves as if the following command were executed: | |
298 | .sp .5 | |
299 | .RS | |
300 | \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP | |
301 | .RE | |
302 | .sp .5 | |
303 | but the value of the | |
304 | .SM | |
305 | .B PATH | |
306 | variable is not used to search for the file name. | |
307 | .PP | |
308 | If | |
309 | .B bash | |
310 | is invoked with the name | |
311 | .BR sh , | |
312 | it tries to mimic the startup behavior of historical versions of | |
313 | .B sh | |
314 | as closely as possible, | |
315 | while conforming to the POSIX standard as well. | |
cce855bc JA |
316 | When invoked as an interactive login shell, it first attempts to |
317 | read and execute commands from | |
ccc6cda3 JA |
318 | .I /etc/profile |
319 | and | |
320 | .IR ~/.profile , | |
321 | in that order. | |
322 | The | |
323 | .B \-\-noprofile | |
324 | option may be used to inhibit this behavior. | |
325 | When invoked as an interactive shell with the name | |
326 | .BR sh , | |
327 | .B bash | |
328 | looks for the variable | |
329 | .SM | |
330 | .BR ENV , | |
331 | expands its value if it is defined, and uses the | |
332 | expanded value as the name of a file to read and execute. | |
333 | Since a shell invoked as | |
334 | .B sh | |
335 | does not attempt to read and execute commands from any other startup | |
336 | files, the | |
337 | .B \-\-rcfile | |
338 | option has no effect. | |
339 | A non-interactive shell invoked with the name | |
340 | .B sh | |
341 | does not attempt to read any startup files. | |
342 | When invoked as | |
343 | .BR sh , | |
344 | .B bash | |
345 | enters | |
346 | .I posix | |
347 | mode after the startup files are read. | |
348 | .PP | |
349 | When | |
350 | .B bash | |
351 | is started in | |
352 | .I posix | |
353 | mode, as with the | |
354 | .B \-\-posix | |
355 | command line option, it follows the POSIX standard for startup files. | |
cce855bc | 356 | In this mode, interactive shells expand the |
ccc6cda3 JA |
357 | .SM |
358 | .B ENV | |
cce855bc | 359 | variable and commands are read and executed from the file |
ccc6cda3 JA |
360 | whose name is the expanded value. |
361 | No other startup files are read. | |
ccc6cda3 JA |
362 | .PP |
363 | .B Bash | |
364 | attempts to determine when it is being run by the remote shell | |
365 | daemon, usually \fIrshd\fP. | |
366 | If | |
367 | .B bash | |
368 | determines it is being run by \fIrshd\fP, it reads and executes | |
369 | commands from \fI~/.bashrc\fP, if that file exists and is readable. | |
370 | It will not do this if invoked as \fBsh\fP. | |
371 | The | |
372 | .B \-\-norc | |
373 | option may be used to inhibit this behavior, and the | |
374 | .B \-\-rcfile | |
375 | option may be used to force another file to be read, but | |
376 | \fIrshd\fP does not generally invoke the shell with those options | |
377 | or allow them to be specified. | |
726f6388 | 378 | .SH DEFINITIONS |
ccc6cda3 JA |
379 | .PP |
380 | The following definitions are used throughout the rest of this | |
381 | document. | |
726f6388 JA |
382 | .PD 0 |
383 | .TP | |
384 | .B blank | |
385 | A space or tab. | |
386 | .TP | |
387 | .B word | |
388 | A sequence of characters considered as a single unit by the shell. | |
389 | Also known as a | |
390 | .BR token . | |
391 | .TP | |
392 | .B name | |
393 | A | |
394 | .I word | |
395 | consisting only of alphanumeric characters and underscores, and | |
396 | beginning with an alphabetic character or an underscore. Also | |
397 | referred to as an | |
398 | .BR identifier . | |
399 | .TP | |
400 | .B metacharacter | |
401 | A character that, when unquoted, separates words. One of the following: | |
402 | .br | |
403 | .RS | |
404 | .PP | |
405 | .if t \fB| & ; ( ) < > space tab\fP | |
406 | .if n \fB| & ; ( ) < > space tab\fP | |
407 | .RE | |
408 | .PP | |
409 | .TP | |
410 | .B control operator | |
411 | A \fItoken\fP that performs a control function. It is one of the following | |
412 | symbols: | |
413 | .RS | |
414 | .PP | |
ccc6cda3 | 415 | .if t \fB\(bv\(bv & && ; ;; ( ) | <newline>\fP |
726f6388 JA |
416 | .if n \fB|| & && ; ;; ( ) | <newline>\fP |
417 | .RE | |
418 | .PD | |
419 | .SH "RESERVED WORDS" | |
420 | \fIReserved words\fP are words that have a special meaning to the shell. | |
421 | The following words are recognized as reserved when unquoted and either | |
422 | the first word of a simple command (see | |
423 | .SM | |
424 | .B SHELL GRAMMAR | |
425 | below) or the third word of a | |
426 | .B case | |
427 | or | |
428 | .B for | |
429 | command: | |
430 | .if t .RS | |
431 | .PP | |
432 | .B | |
cce855bc JA |
433 | .if n ! case do done elif else esac fi for function if in select then until while { } time [[ ]] |
434 | .if t ! case do done elif else esac fi for function if in select then until while { } time [[ ]] | |
726f6388 JA |
435 | .if t .RE |
436 | .RE | |
437 | .SH "SHELL GRAMMAR" | |
438 | .SS Simple Commands | |
439 | .PP | |
440 | A \fIsimple command\fP is a sequence of optional variable assignments | |
ccc6cda3 | 441 | followed by \fBblank\fP-separated words and redirections, and |
726f6388 JA |
442 | terminated by a \fIcontrol operator\fP. The first word |
443 | specifies the command to be executed. The remaining words are | |
444 | passed as arguments to the invoked command. | |
445 | .PP | |
446 | The return value of a \fIsimple command\fP is its exit status, or | |
447 | 128+\fIn\^\fP if the command is terminated by signal | |
448 | .IR n . | |
449 | .SS Pipelines | |
450 | .PP | |
451 | A \fIpipeline\fP is a sequence of one or more commands separated by | |
452 | the character | |
453 | .BR | . | |
454 | The format for a pipeline is: | |
455 | .RS | |
456 | .PP | |
ccc6cda3 | 457 | [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ] |
726f6388 JA |
458 | .RE |
459 | .PP | |
460 | The standard output of | |
461 | .I command | |
462 | is connected to the standard input of | |
463 | .IR command2 . | |
464 | This connection is performed before any redirections specified by the | |
465 | command (see | |
466 | .SM | |
467 | .B REDIRECTION | |
468 | below). | |
469 | .PP | |
470 | If the reserved word | |
471 | .B ! | |
472 | precedes a pipeline, the exit status of that | |
473 | pipeline is the logical NOT of the exit status of the last command. | |
474 | Otherwise, the status of the pipeline is the exit status of the last | |
ccc6cda3 JA |
475 | command. |
476 | The shell waits for all commands in the pipeline to | |
726f6388 JA |
477 | terminate before returning a value. |
478 | .PP | |
ccc6cda3 JA |
479 | If the |
480 | .B time | |
481 | reserved word precedes a pipeline, the elapsed as well as user and | |
482 | system time consumed by its execution are reported when the pipeline | |
483 | terminates. | |
484 | The \fB\-p\fP option changes the output format to that specified by POSIX. | |
485 | The | |
486 | .SM | |
487 | .B TIMEFORMAT | |
488 | variable may be set to a format string that specifies how the timing | |
489 | information should be displayed; see the description of | |
490 | .SM | |
491 | .B TIMEFORMAT | |
492 | under | |
493 | .B "Shell Variables" | |
494 | below. | |
495 | .PP | |
726f6388 JA |
496 | Each command in a pipeline is executed as a separate process (i.e., in a |
497 | subshell). | |
498 | .SS Lists | |
499 | .PP | |
500 | A \fIlist\fP is a sequence of one or more pipelines separated by one | |
501 | of the operators | |
502 | .BR ; , | |
503 | .BR & , | |
504 | .BR && , | |
505 | or | |
ccc6cda3 JA |
506 | .BR \(bv\(bv , |
507 | and optionally terminated by one of | |
726f6388 JA |
508 | .BR ; , |
509 | .BR & , | |
510 | or | |
511 | .BR <newline> . | |
512 | .PP | |
513 | Of these list operators, | |
514 | .B && | |
515 | and | |
ccc6cda3 | 516 | .B \(bv\(bv |
726f6388 JA |
517 | have equal precedence, followed by |
518 | .B ; | |
519 | and | |
520 | .BR &, | |
521 | which have equal precedence. | |
522 | .PP | |
523 | If a command is terminated by the control operator | |
524 | .BR & , | |
525 | the shell executes the command in the \fIbackground\fP | |
526 | in a subshell. The shell does not wait for the command to | |
527 | finish, and the return status is 0. Commands separated by a | |
528 | .B ; | |
529 | are executed sequentially; the shell waits for each | |
530 | command to terminate in turn. The return status is the | |
531 | exit status of the last command executed. | |
532 | .PP | |
533 | The control operators | |
534 | .B && | |
535 | and | |
ccc6cda3 | 536 | .B \(bv\(bv |
726f6388 JA |
537 | denote AND lists and OR lists, respectively. |
538 | An AND list has the form | |
539 | .RS | |
540 | .PP | |
541 | \fIcommand\fP \fB&&\fP \fIcommand2\fP | |
542 | .RE | |
543 | .PP | |
544 | .I command2 | |
545 | is executed if, and only if, | |
546 | .I command | |
547 | returns an exit status of zero. | |
548 | .PP | |
549 | An OR list has the form | |
550 | .RS | |
551 | .PP | |
ccc6cda3 | 552 | \fIcommand\fP \fB\(bv\(bv\fP \fIcommand2\fP |
726f6388 JA |
553 | .PP |
554 | .RE | |
555 | .PP | |
556 | .I command2 | |
557 | is executed if and only if | |
558 | .I command | |
ccc6cda3 | 559 | returns a non-zero exit status. The return status of |
726f6388 JA |
560 | AND and OR lists is the exit status of the last command |
561 | executed in the list. | |
562 | .SS Compound Commands | |
563 | .PP | |
564 | A \fIcompound command\fP is one of the following: | |
565 | .TP | |
566 | (\fIlist\fP) | |
567 | \fIlist\fP is executed in a subshell. Variable assignments and builtin | |
568 | commands that affect the shell's environment do not remain in effect | |
569 | after the command completes. The return status is the exit status of | |
570 | \fIlist\fP. | |
571 | .TP | |
572 | { \fIlist\fP; } | |
ccc6cda3 JA |
573 | \fIlist\fP is simply executed in the current shell environment. |
574 | \fIlist\fP must be terminated with a newline or semicolon. | |
575 | This is known as a \fIgroup command\fP. | |
576 | The return status is the exit status of | |
726f6388 JA |
577 | \fIlist\fP. |
578 | .TP | |
ccc6cda3 JA |
579 | ((\fIexpression\fP)) |
580 | The \fIexpression\fP is evaluated according to the rules described | |
581 | below under | |
582 | .SM | |
583 | .BR "ARITHMETIC EVALUATION" . | |
584 | If the value of the expression is non-zero, the return status is 0; | |
585 | otherwise the return status is 1. This is exactly equivalent to | |
586 | \fBlet "\fIexpression\fP"\fR. | |
587 | .TP | |
cce855bc JA |
588 | \fB[[\fP \fIexpression\fP \fB]]\fP |
589 | Return a status of 0 or 1 depending on the evaluation of | |
590 | the conditional expression \fIexpression\fP. | |
591 | Expressions are composed of the primaries described below under | |
592 | .SM | |
593 | .BR "CONDITIONAL EXPRESSIONS" . | |
594 | Word splitting and pathname expansion are not performed on the words | |
595 | between the \fB[[\fP and \fB]]\fP; tilde expansion, parameter and | |
596 | variable expansion, arithmetic expansion, command substitution, process | |
597 | substitution, and quote removal are performed. | |
598 | .if t .sp 0.5 | |
599 | .if n .sp 1 | |
600 | When the \fB==\fP and \fB!=\fP operators are used, the string to the | |
601 | right of the operator is considered a pattern and matched according | |
602 | to the rules described below under \fBPattern Matching\fP. | |
603 | The return value is 0 if the string matches or does not match | |
604 | the pattern, respectively, and 1 otherwise. | |
605 | Any part of the pattern may be quoted to force it to be matched as a | |
606 | string. | |
607 | .if t .sp 0.5 | |
608 | .if n .sp 1 | |
609 | Expressions may be combined using the following operators, listed | |
610 | in decreasing order of precedence: | |
611 | .if t .sp 0.5 | |
612 | .if n .sp 1 | |
613 | .RS | |
614 | .PD 0 | |
615 | .TP | |
616 | .B ( \fIexpression\fP ) | |
617 | Returns the value of \fIexpression\fP. | |
618 | This may be used to override the normal precedence of operators. | |
619 | .TP | |
620 | .B ! \fIexpression\fP | |
621 | True if | |
622 | .I expression | |
623 | is false. | |
624 | .TP | |
625 | \fIexpression1\fP \fB&&\fP \fIexpression2\fP | |
626 | True if both | |
627 | .I expression1 | |
628 | and | |
629 | .I expression2 | |
630 | are true. | |
631 | .TP | |
632 | .if t \fIexpression1\fP \fB\(bv\(bv\fP \fIexpression2\fP | |
633 | .if n \fIexpression1\fP \fB||\fP \fIexpression2\fP | |
634 | True if either | |
635 | .I expression1 | |
636 | or | |
637 | .I expression2 | |
638 | is true. | |
639 | .PD | |
640 | .RE | |
641 | .LP | |
642 | The \fB&&\fP and | |
643 | .if t \fB\(bv\(bv\fP | |
644 | .if n \fB||\fP | |
645 | operators do not execute \fIexpression2\fP if the value of | |
646 | \fIexpression1\fP is sufficient to determine the return value of | |
647 | the entire conditional expression. | |
648 | .TP | |
726f6388 JA |
649 | \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP; ] \fBdo\fP \fIlist\fP ; \fBdone\fP |
650 | The list of words following \fBin\fP is expanded, generating a list | |
651 | of items. The variable \fIname\fP is set to each element of this list | |
652 | in turn, and \fIlist\fP is executed each time. If the \fBin\fP | |
653 | \fIword\fP is omitted, the \fBfor\fP command executes \fIlist\fP | |
654 | once for each positional parameter that is set (see | |
655 | .SM | |
656 | .B PARAMETERS | |
657 | below). | |
cce855bc JA |
658 | The return status is the exit status of the last command that executes. |
659 | If the expansion of the items following \fBin\fP results in an empty | |
660 | list, no commands are executed, and the return status is 0. | |
726f6388 JA |
661 | .TP |
662 | \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP; ] \fBdo\fP \fIlist\fP ; \fBdone\fP | |
663 | The list of words following \fBin\fP is expanded, generating a list | |
664 | of items. The set of expanded words is printed on the standard | |
665 | error, each preceded by a number. If the \fBin\fP | |
666 | \fIword\fP is omitted, the positional parameters are printed (see | |
667 | .SM | |
668 | .B PARAMETERS | |
669 | below). The | |
670 | .B PS3 | |
671 | prompt is then displayed and a line read from the standard input. | |
ccc6cda3 | 672 | If the line consists of a number corresponding to one of |
726f6388 JA |
673 | the displayed words, then the value of |
674 | .I name | |
675 | is set to that word. If the line is empty, the words and prompt | |
676 | are displayed again. If EOF is read, the command completes. Any | |
677 | other value read causes | |
678 | .I name | |
679 | to be set to null. The line read is saved in the variable | |
680 | .BR REPLY . | |
681 | The | |
682 | .I list | |
683 | is executed after each selection until a | |
684 | .B break | |
685 | or | |
686 | .B return | |
687 | command is executed. | |
688 | The exit status of | |
689 | .B select | |
690 | is the exit status of the last command executed in | |
691 | .IR list , | |
692 | or zero if no commands were executed. | |
693 | .TP | |
d166f048 | 694 | \fBcase\fP \fIword\fP \fBin\fP [ ( \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \ |
726f6388 JA |
695 | ... ) \fIlist\fP ;; ] ... \fBesac\fP |
696 | A \fBcase\fP command first expands \fIword\fP, and tries to match | |
697 | it against each \fIpattern\fP in turn, using the same matching rules | |
698 | as for pathname expansion (see | |
699 | .B Pathname Expansion | |
700 | below). When a match is found, the | |
701 | corresponding \fIlist\fP is executed. After the first match, no | |
702 | subsequent matches are attempted. The exit status is zero if no | |
ccc6cda3 | 703 | pattern matches. Otherwise, it is the exit status of the |
726f6388 JA |
704 | last command executed in \fIlist\fP. |
705 | .TP | |
ccc6cda3 JA |
706 | \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \ |
707 | [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \ | |
708 | [ \fBelse\fP \fIlist\fP; ] \fBfi\fP | |
726f6388 JA |
709 | The |
710 | .B if | |
711 | .I list | |
712 | is executed. If its exit status is zero, the | |
713 | \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP | |
714 | \fIlist\fP is executed in turn, and if its exit status is zero, | |
715 | the corresponding \fBthen\fP \fIlist\fP is executed and the | |
716 | command completes. Otherwise, the \fBelse\fP \fIlist\fP is | |
717 | executed, if present. The exit status is the exit status of the | |
718 | last command executed, or zero if no condition tested true. | |
719 | .TP | |
720 | .PD 0 | |
ccc6cda3 | 721 | \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP |
726f6388 | 722 | .TP |
ccc6cda3 | 723 | \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP |
726f6388 JA |
724 | .PD |
725 | The \fBwhile\fP command continuously executes the \fBdo\fP | |
726 | \fIlist\fP as long as the last command in \fIlist\fP returns | |
727 | an exit status of zero. The \fBuntil\fP command is identical | |
728 | to the \fBwhile\fP command, except that the test is negated; | |
729 | the | |
730 | .B do | |
731 | .I list | |
732 | is executed as long as the last command in | |
733 | .I list | |
ccc6cda3 | 734 | returns a non-zero exit status. |
726f6388 JA |
735 | The exit status of the \fBwhile\fP and \fBuntil\fP commands |
736 | is the exit status | |
737 | of the last \fBdo\fP \fIlist\fP command executed, or zero if | |
738 | none was executed. | |
739 | .TP | |
740 | [ \fBfunction\fP ] \fIname\fP () { \fIlist\fP; } | |
741 | This defines a function named \fIname\fP. The \fIbody\fP of the | |
742 | function is the | |
743 | .I list | |
744 | of commands between { and }. This list | |
745 | is executed whenever \fIname\fP is specified as the | |
746 | name of a simple command. The exit status of a function is | |
747 | the exit status of the last command executed in the body. (See | |
748 | .SM | |
749 | .B FUNCTIONS | |
750 | below.) | |
751 | .SH COMMENTS | |
ccc6cda3 JA |
752 | In a non-interactive shell, or an interactive shell in which the |
753 | .B interactive_comments | |
754 | option to the | |
755 | .B shopt | |
756 | builtin is enabled (see | |
757 | .SM | |
758 | .B "SHELL BUILTIN COMMANDS" | |
759 | below), a word beginning with | |
726f6388 JA |
760 | .B # |
761 | causes that word and all remaining characters on that line to | |
762 | be ignored. An interactive shell without the | |
ccc6cda3 | 763 | .B interactive_comments |
ccc6cda3 JA |
764 | option enabled does not allow comments. The |
765 | .B interactive_comments | |
766 | option is on by default in interactive shells. | |
726f6388 JA |
767 | .SH QUOTING |
768 | \fIQuoting\fP is used to remove the special meaning of certain | |
769 | characters or words to the shell. Quoting can be used to | |
770 | disable special treatment for special characters, to prevent | |
771 | reserved words from being recognized as such, and to prevent | |
772 | parameter expansion. | |
773 | .PP | |
774 | Each of the \fImetacharacters\fP listed above under | |
775 | .SM | |
776 | .B DEFINITIONS | |
777 | has special meaning to the shell and must be quoted if they are to | |
778 | represent themselves. There are three quoting mechanisms: the | |
779 | .IR "escape character" , | |
780 | single quotes, and double quotes. | |
781 | .PP | |
782 | A non-quoted backslash (\fB\e\fP) is the | |
783 | .IR "escape character" . | |
784 | It preserves the literal value of the next character that follows, | |
785 | with the exception of <newline>. If a \fB\e\fP<newline> pair | |
cce855bc JA |
786 | appears, and the backslash is not itself quoted, the \fB\e\fP<newline> |
787 | is treated as a line continuation (that is, it is removed from the | |
788 | input stream and effectively ignored). | |
726f6388 JA |
789 | .PP |
790 | Enclosing characters in single quotes preserves the literal value | |
791 | of each character within the quotes. A single quote may not occur | |
792 | between single quotes, even when preceded by a backslash. | |
793 | .PP | |
794 | Enclosing characters in double quotes preserves the literal value | |
795 | of all characters within the quotes, with the exception of | |
796 | .BR $ , | |
797 | .BR ` , | |
798 | and | |
799 | .BR \e . | |
800 | The characters | |
801 | .B $ | |
802 | and | |
803 | .B ` | |
804 | retain their special meaning within double quotes. The backslash | |
805 | retains its special meaning only when followed by one of the following | |
806 | characters: | |
807 | .BR $ , | |
808 | .BR ` , | |
809 | \^\fB"\fP\^, | |
810 | .BR \e , | |
811 | or | |
812 | .BR <newline> . | |
813 | A double quote may be quoted within double quotes by preceding it with | |
814 | a backslash. | |
815 | .PP | |
816 | The special parameters | |
817 | .B * | |
818 | and | |
819 | .B @ | |
820 | have special meaning when in double | |
821 | quotes (see | |
822 | .SM | |
823 | .B PARAMETERS | |
824 | below). | |
ccc6cda3 JA |
825 | .PP |
826 | Words of the form \fB$\fP'\fIstring\fP' are treated specially. The | |
827 | word expands to \fIstring\fP, with backslash-escaped characters replaced | |
828 | as specifed by the ANSI C standard. Backslash escape sequences, if | |
829 | present, are decoded as follows: | |
830 | .RS | |
831 | .PD 0 | |
832 | .TP | |
833 | .B \ea | |
834 | alert (bell) | |
835 | .TP | |
836 | .B \eb | |
837 | backspace | |
838 | .TP | |
839 | .B \ee | |
840 | an escape character | |
841 | .TP | |
842 | .B \ef | |
843 | form feed | |
844 | .TP | |
845 | .B \en | |
846 | new line | |
847 | .TP | |
848 | .B \er | |
849 | carriage return | |
850 | .TP | |
851 | .B \et | |
852 | horizontal tab | |
853 | .TP | |
854 | .B \ev | |
855 | vertical tab | |
856 | .TP | |
857 | .B \e\e | |
858 | backslash | |
859 | .TP | |
860 | .B \e\fInnn\fP | |
cce855bc JA |
861 | the character whose ASCII code is the octal value \fInnn\fP |
862 | (one to three digits) | |
863 | .TP | |
864 | .B \ex\fInnn\fP | |
865 | the character whose ASCII code is the hexadecimal value \fInnn\fP | |
866 | (one to three digits) | |
ccc6cda3 JA |
867 | .PD |
868 | .RE | |
869 | .LP | |
870 | The translated result is single-quoted, as if the dollar sign had | |
871 | not been present. | |
872 | .PP | |
873 | A double-quoted string preceded by a dollar sign (\fB$\fP) will cause | |
874 | the string to be translated according to the current locale. | |
875 | If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign | |
876 | is ignored. | |
877 | If the string is translated and replaced, the replacement is | |
878 | double-quoted. | |
726f6388 JA |
879 | .SH PARAMETERS |
880 | A | |
881 | .I parameter | |
ccc6cda3 JA |
882 | is an entity that stores values. |
883 | It can be a | |
726f6388 JA |
884 | .IR name , |
885 | a number, or one of the special characters listed below under | |
886 | .BR "Special Parameters" . | |
887 | For the shell's purposes, a | |
888 | .I variable | |
889 | is a parameter denoted by a | |
890 | .IR name . | |
891 | .PP | |
892 | A parameter is set if it has been assigned a value. The null string is | |
893 | a valid value. Once a variable is set, it may be unset only by using | |
894 | the | |
895 | .B unset | |
896 | builtin command (see | |
897 | .SM | |
898 | .B SHELL BUILTIN COMMANDS | |
899 | below). | |
900 | .PP | |
901 | A | |
902 | .I variable | |
903 | may be assigned to by a statement of the form | |
904 | .RS | |
905 | .PP | |
906 | \fIname\fP=[\fIvalue\fP] | |
907 | .RE | |
908 | .PP | |
909 | If | |
910 | .I value | |
911 | is not given, the variable is assigned the null string. All | |
912 | .I values | |
ccc6cda3 JA |
913 | undergo tilde expansion, parameter and variable expansion, string |
914 | expansion, command substitution, arithmetic expansion, and quote | |
915 | removal (see | |
916 | .SM | |
917 | .B EXPANSION | |
918 | below). If the variable has its | |
cce855bc | 919 | .B integer |
726f6388 JA |
920 | attribute set (see |
921 | .B declare | |
922 | below in | |
923 | .SM | |
924 | .BR "SHELL BUILTIN COMMANDS" ) | |
925 | then | |
926 | .I value | |
cce855bc JA |
927 | is subject to arithmetic expansion even if the $((...)) expansion is |
928 | not used (see | |
ccc6cda3 JA |
929 | .B "Arithmetic Expansion" |
930 | below). | |
931 | Word splitting is not performed, with the exception | |
726f6388 JA |
932 | of \fB"$@"\fP as explained below under |
933 | .BR "Special Parameters" . | |
934 | Pathname expansion is not performed. | |
935 | .SS Positional Parameters | |
936 | .PP | |
937 | A | |
938 | .I positional parameter | |
939 | is a parameter denoted by one or more | |
940 | digits, other than the single digit 0. Positional parameters are | |
941 | assigned from the shell's arguments when it is invoked, | |
942 | and may be reassigned using the | |
943 | .B set | |
944 | builtin command. Positional parameters may not be assigned to | |
945 | with assignment statements. The positional parameters are | |
946 | temporarily replaced when a shell function is executed (see | |
947 | .SM | |
948 | .B FUNCTIONS | |
949 | below). | |
950 | .PP | |
951 | When a positional parameter consisting of more than a single | |
952 | digit is expanded, it must be enclosed in braces (see | |
953 | .SM | |
954 | .B EXPANSION | |
955 | below). | |
956 | .SS Special Parameters | |
957 | .PP | |
958 | The shell treats several parameters specially. These parameters may | |
959 | only be referenced; assignment to them is not allowed. | |
960 | .PD 0 | |
961 | .TP | |
962 | .B * | |
963 | Expands to the positional parameters, starting from one. When the | |
964 | expansion occurs within double quotes, it expands to a single word | |
965 | with the value of each parameter separated by the first character | |
966 | of the | |
967 | .SM | |
968 | .B IFS | |
cce855bc JA |
969 | special variable. That is, "\fB$*\fP" is equivalent |
970 | to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where | |
726f6388 JA |
971 | .I c |
972 | is the first character of the value of the | |
973 | .SM | |
974 | .B IFS | |
975 | variable. If | |
976 | .SM | |
977 | .B IFS | |
d166f048 JA |
978 | is unset, the parameters are separated by spaces. |
979 | If | |
980 | .SM | |
981 | .B IFS | |
982 | is null, the parameters are joined without intervening separators. | |
726f6388 JA |
983 | .TP |
984 | .B @ | |
985 | Expands to the positional parameters, starting from one. When the | |
cce855bc JA |
986 | expansion occurs within double quotes, each parameter expands to a |
987 | separate word. That is, "\fB$@\fP" is equivalent to | |
988 | "\fB$1\fP" "\fB$2\fP" ... | |
989 | When there are no positional parameters, "\fB$@\fP" and | |
726f6388 JA |
990 | .B $@ |
991 | expand to nothing (i.e., they are removed). | |
992 | .TP | |
993 | .B # | |
994 | Expands to the number of positional parameters in decimal. | |
995 | .TP | |
996 | .B ? | |
997 | Expands to the status of the most recently executed foreground | |
998 | pipeline. | |
999 | .TP | |
1000 | .B \- | |
1001 | Expands to the current option flags as specified upon invocation, | |
1002 | by the | |
1003 | .B set | |
1004 | builtin command, or those set by the shell itself | |
1005 | (such as the | |
1006 | .B \-i | |
cce855bc | 1007 | option). |
726f6388 JA |
1008 | .TP |
1009 | .B $ | |
1010 | Expands to the process ID of the shell. In a () subshell, it | |
1011 | expands to the process ID of the current shell, not the | |
1012 | subshell. | |
1013 | .TP | |
1014 | .B ! | |
1015 | Expands to the process ID of the most recently executed background | |
1016 | (asynchronous) command. | |
1017 | .TP | |
1018 | .B 0 | |
1019 | Expands to the name of the shell or shell script. This is set at | |
1020 | shell initialization. If | |
1021 | .B bash | |
1022 | is invoked with a file of commands, | |
1023 | .B $0 | |
1024 | is set to the name of that file. If | |
1025 | .B bash | |
1026 | is started with the | |
1027 | .B \-c | |
1028 | option, then | |
1029 | .B $0 | |
1030 | is set to the first argument after the string to be | |
1031 | executed, if one is present. Otherwise, it is set | |
ccc6cda3 | 1032 | to the file name used to invoke |
726f6388 JA |
1033 | .BR bash , |
1034 | as given by argument zero. | |
1035 | .TP | |
1036 | .B _ | |
ccc6cda3 JA |
1037 | At shell startup, set to the absolute file name of the shell or shell |
1038 | script being executed as passed in the argument list. | |
1039 | Subsequently, expands to the last argument to the previous command, | |
1040 | after expansion. | |
1041 | Also set to the full file name of each command executed and placed in | |
726f6388 | 1042 | the environment exported to that command. |
ccc6cda3 JA |
1043 | When checking mail, this parameter holds the name of the mail file |
1044 | currently being checked. | |
726f6388 JA |
1045 | .PD |
1046 | .SS Shell Variables | |
1047 | .PP | |
1048 | The following variables are set by the shell: | |
1049 | .PP | |
1050 | .PD 0 | |
1051 | .TP | |
1052 | .B PPID | |
cce855bc | 1053 | The process ID of the shell's parent. This variable is readonly. |
726f6388 JA |
1054 | .TP |
1055 | .B PWD | |
1056 | The current working directory as set by the | |
1057 | .B cd | |
1058 | command. | |
1059 | .TP | |
1060 | .B OLDPWD | |
1061 | The previous working directory as set by the | |
1062 | .B cd | |
1063 | command. | |
1064 | .TP | |
1065 | .B REPLY | |
1066 | Set to the line of input read by the | |
1067 | .B read | |
1068 | builtin command when no arguments are supplied. | |
1069 | .TP | |
1070 | .B UID | |
1071 | Expands to the user ID of the current user, initialized at shell startup. | |
cce855bc | 1072 | This variable is readonly. |
726f6388 JA |
1073 | .TP |
1074 | .B EUID | |
1075 | Expands to the effective user ID of the current user, initialized at | |
cce855bc | 1076 | shell startup. This variable is readonly. |
726f6388 | 1077 | .TP |
d166f048 JA |
1078 | .B GROUPS |
1079 | An array variable containing the list of groups of which the current | |
cce855bc | 1080 | user is a member. This variable is readonly. |
d166f048 | 1081 | .TP |
726f6388 | 1082 | .B BASH |
ccc6cda3 | 1083 | Expands to the full file name used to invoke this instance of |
726f6388 JA |
1084 | .BR bash . |
1085 | .TP | |
1086 | .B BASH_VERSION | |
ccc6cda3 | 1087 | Expands to a string describing the version of this instance of |
726f6388 JA |
1088 | .BR bash . |
1089 | .TP | |
ccc6cda3 | 1090 | .B BASH_VERSINFO |
cce855bc JA |
1091 | A readonly array variable whose members hold version information for |
1092 | this instance of | |
ccc6cda3 JA |
1093 | .BR bash . |
1094 | The values assigned to the array members are as follows: | |
1095 | .sp .5 | |
1096 | .RS | |
1097 | .PD 0 | |
1098 | .TP 24 | |
1099 | .B BASH_VERSINFO[\fR0\fP] | |
1100 | The major version number (the \fIrelease\fP). | |
1101 | .TP | |
1102 | .B BASH_VERSINFO[\fR1\fP] | |
1103 | The minor version number (the \fIversion\fP). | |
1104 | .TP | |
1105 | .B BASH_VERSINFO[\fR2\fP] | |
1106 | The patch level. | |
1107 | .TP | |
1108 | .B BASH_VERSINFO[\fR3\fP] | |
1109 | The build version. | |
1110 | .TP | |
1111 | .B BASH_VERSINFO[\fR4\fP] | |
1112 | The release status (e.g., \fIbeta1\fP). | |
1113 | .TP | |
1114 | .B BASH_VERSINFO[\fR5\fP] | |
1115 | The value of \fBMACHTYPE\fP. | |
1116 | .PD | |
1117 | .RE | |
1118 | .TP | |
726f6388 JA |
1119 | .B SHLVL |
1120 | Incremented by one each time an instance of | |
1121 | .B bash | |
1122 | is started. | |
1123 | .TP | |
1124 | .B RANDOM | |
ccc6cda3 JA |
1125 | Each time this parameter is referenced, a random integer between |
1126 | 0 and 32767 is | |
726f6388 JA |
1127 | generated. The sequence of random numbers may be initialized by assigning |
1128 | a value to | |
1129 | .SM | |
1130 | .BR RANDOM . | |
1131 | If | |
1132 | .SM | |
1133 | .B RANDOM | |
1134 | is unset, it loses its special properties, even if it is | |
1135 | subsequently reset. | |
1136 | .TP | |
1137 | .B SECONDS | |
1138 | Each time this parameter is | |
1139 | referenced, the number of seconds since shell invocation is returned. If a | |
1140 | value is assigned to | |
1141 | .SM | |
1142 | .BR SECONDS , | |
1143 | the value returned upon subsequent | |
1144 | references is | |
1145 | the number of seconds since the assignment plus the value assigned. | |
1146 | If | |
1147 | .SM | |
1148 | .B SECONDS | |
1149 | is unset, it loses its special properties, even if it is | |
1150 | subsequently reset. | |
1151 | .TP | |
1152 | .B LINENO | |
1153 | Each time this parameter is referenced, the shell substitutes | |
1154 | a decimal number representing the current sequential line number | |
1155 | (starting with 1) within a script or function. When not in a | |
1156 | script or function, the value substituted is not guaranteed to | |
ccc6cda3 | 1157 | be meaningful. |
726f6388 JA |
1158 | If |
1159 | .SM | |
1160 | .B LINENO | |
1161 | is unset, it loses its special properties, even if it is | |
1162 | subsequently reset. | |
1163 | .TP | |
1164 | .B HISTCMD | |
1165 | The history number, or index in the history list, of the current | |
ccc6cda3 JA |
1166 | command. |
1167 | If | |
726f6388 JA |
1168 | .SM |
1169 | .B HISTCMD | |
1170 | is unset, it loses its special properties, even if it is | |
1171 | subsequently reset. | |
1172 | .TP | |
ccc6cda3 JA |
1173 | .B DIRSTACK |
1174 | An array variable (see | |
1175 | .B Arrays | |
1176 | below) containing the current contents of the directory stack. | |
1177 | Directories appear in the stack in the order they are displayed by the | |
1178 | .B dirs | |
1179 | builtin. | |
1180 | Assigning to members of this array variable may be used to modify | |
1181 | directories already in the stack, but the | |
1182 | .B pushd | |
1183 | and | |
1184 | .B popd | |
1185 | builtins must be used to add and remove directories. | |
1186 | Assignment to this variable will not change the current directory. | |
1187 | If | |
1188 | .SM | |
1189 | .B DIRSTACK | |
1190 | is unset, it loses its special properties, even if it is | |
1191 | subsequently reset. | |
1192 | .TP | |
1193 | .B PIPESTATUS | |
1194 | An array variable (see | |
1195 | .B Arrays | |
1196 | below) containing a list of exit status values from the processes | |
1197 | in the most-recently-executed foreground pipeline (which may | |
1198 | contain only a single command). | |
1199 | .TP | |
726f6388 JA |
1200 | .B OPTARG |
1201 | The value of the last option argument processed by the | |
1202 | .B getopts | |
1203 | builtin command (see | |
1204 | .SM | |
1205 | .B SHELL BUILTIN COMMANDS | |
1206 | below). | |
1207 | .TP | |
1208 | .B OPTIND | |
1209 | The index of the next argument to be processed by the | |
1210 | .B getopts | |
1211 | builtin command (see | |
1212 | .SM | |
1213 | .B SHELL BUILTIN COMMANDS | |
1214 | below). | |
1215 | .TP | |
ccc6cda3 JA |
1216 | .B HOSTNAME |
1217 | Automatically set to the name of the current host. | |
1218 | .TP | |
726f6388 JA |
1219 | .B HOSTTYPE |
1220 | Automatically set to a string that uniquely | |
1221 | describes the type of machine on which | |
1222 | .B bash | |
ccc6cda3 JA |
1223 | is executing. |
1224 | The default is system-dependent. | |
726f6388 JA |
1225 | .TP |
1226 | .B OSTYPE | |
1227 | Automatically set to a string that | |
1228 | describes the operating system on which | |
1229 | .B bash | |
ccc6cda3 JA |
1230 | is executing. |
1231 | The default is system-dependent. | |
1232 | .TP | |
1233 | .B MACHTYPE | |
1234 | Automatically set to a string that fully describes the system | |
1235 | type on which | |
1236 | .B bash | |
1237 | is executing, in the standard GNU \fIcpu-company-system\fP format. | |
1238 | The default is system-dependent. | |
1239 | .TP | |
1240 | .B SHELLOPTS | |
1241 | A colon-separated list of enabled shell options. Each word in | |
1242 | the list is a valid argument for the | |
1243 | .B \-o | |
1244 | option to the | |
1245 | .B set | |
1246 | builtin command (see | |
1247 | .SM | |
1248 | .B "SHELL BUILTIN COMMANDS" | |
1249 | below). The options appearing in | |
1250 | .SM | |
1251 | .B SHELLOPTS | |
1252 | are those reported as | |
1253 | .I on | |
1254 | by \fBset \-o\fP. | |
1255 | If this variable is in the environment when | |
1256 | .B bash | |
1257 | starts up, each shell option in the list will be enabled before | |
1258 | reading any startup files. | |
1259 | This variable is read-only. | |
726f6388 JA |
1260 | .PD |
1261 | .PP | |
1262 | The following variables are used by the shell. In some cases, | |
1263 | .B bash | |
1264 | assigns a default value to a variable; these cases are noted | |
1265 | below. | |
1266 | .PP | |
1267 | .PD 0 | |
1268 | .TP | |
1269 | .B IFS | |
1270 | The | |
1271 | .I Internal Field Separator | |
1272 | that is used | |
1273 | for word splitting after expansion and to | |
1274 | split lines into words with the | |
1275 | .B read | |
1276 | builtin command. The default value is | |
1277 | ``<space><tab><newline>''. | |
1278 | .TP | |
1279 | .B PATH | |
1280 | The search path for commands. It | |
1281 | is a colon-separated list of directories in which | |
1282 | the shell looks for commands (see | |
1283 | .SM | |
1284 | .B COMMAND EXECUTION | |
ccc6cda3 | 1285 | below). The default path is system-dependent, |
726f6388 JA |
1286 | and is set by the administrator who installs |
1287 | .BR bash . | |
1288 | A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.''. | |
1289 | .TP | |
1290 | .B HOME | |
1291 | The home directory of the current user; the default argument for the | |
1292 | \fBcd\fP builtin command. | |
cce855bc | 1293 | The value of this variable is also used when performing tilde expansion. |
726f6388 JA |
1294 | .TP |
1295 | .B CDPATH | |
1296 | The search path for the | |
1297 | .B cd | |
cce855bc JA |
1298 | command. |
1299 | This is a colon-separated list of directories in which the shell looks | |
1300 | for destination directories specified by the | |
726f6388 | 1301 | .B cd |
cce855bc JA |
1302 | command. |
1303 | A sample value is ``.:~:/usr''. | |
726f6388 | 1304 | .TP |
d166f048 | 1305 | .B BASH_ENV |
726f6388 JA |
1306 | If this parameter is set when \fBbash\fP is executing a shell script, |
1307 | its value is interpreted as a filename containing commands to | |
1308 | initialize the shell, as in | |
cce855bc | 1309 | .IR ~/.bashrc . |
726f6388 JA |
1310 | The value of |
1311 | .SM | |
d166f048 | 1312 | .B BASH_ENV |
726f6388 | 1313 | is subjected to parameter expansion, command substitution, and arithmetic |
ccc6cda3 | 1314 | expansion before being interpreted as a file name. |
726f6388 JA |
1315 | .SM |
1316 | .B PATH | |
ccc6cda3 | 1317 | is not used to search for the resultant file name. |
726f6388 JA |
1318 | .TP |
1319 | .B MAIL | |
ccc6cda3 | 1320 | If this parameter is set to a file name and the |
726f6388 JA |
1321 | .SM |
1322 | .B MAILPATH | |
1323 | variable is not set, | |
1324 | .B bash | |
1325 | informs the user of the arrival of mail in the specified file. | |
1326 | .TP | |
1327 | .B MAILCHECK | |
1328 | Specifies how | |
1329 | often (in seconds) | |
1330 | .B bash | |
1331 | checks for mail. The default is 60 seconds. When it is time to check | |
ccc6cda3 | 1332 | for mail, the shell does so before displaying the primary prompt. |
726f6388 JA |
1333 | If this variable is unset, the shell disables mail checking. |
1334 | .TP | |
1335 | .B MAILPATH | |
ccc6cda3 | 1336 | A colon-separated list of file names to be checked for mail. |
cce855bc JA |
1337 | The message to be printed when mail arrives in a particular file |
1338 | may be specified by separating the file name from the message with a `?'. | |
1339 | When used in the text of the message, \fB$_\fP expands to the name of | |
1340 | the current mailfile. | |
726f6388 JA |
1341 | Example: |
1342 | .RS | |
1343 | .PP | |
ccc6cda3 | 1344 | \fBMAILPATH\fP='/usr/spool/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"' |
726f6388 JA |
1345 | .PP |
1346 | .B Bash | |
1347 | supplies a default value for this variable, but the location of the user | |
1348 | mail files that it uses is system dependent (e.g., /usr/spool/mail/\fB$USER\fP). | |
1349 | .RE | |
1350 | .TP | |
726f6388 JA |
1351 | .B PS1 |
1352 | The value of this parameter is expanded (see | |
1353 | .SM | |
1354 | .B PROMPTING | |
1355 | below) and used as the primary prompt string. The default value is | |
ccc6cda3 | 1356 | ``\fB\es\-\ev\e$ \fP''. |
726f6388 JA |
1357 | .TP |
1358 | .B PS2 | |
ccc6cda3 JA |
1359 | The value of this parameter is expanded as with |
1360 | .B PS1 | |
726f6388 JA |
1361 | and used as the secondary prompt string. The default is |
1362 | ``\fB> \fP''. | |
1363 | .TP | |
1364 | .B PS3 | |
1365 | The value of this parameter is used as the prompt for the | |
ccc6cda3 | 1366 | .B select |
726f6388 JA |
1367 | command (see |
1368 | .SM | |
1369 | .B SHELL GRAMMAR | |
1370 | above). | |
1371 | .TP | |
1372 | .B PS4 | |
ccc6cda3 JA |
1373 | The value of this parameter is expanded as with |
1374 | .B PS1 | |
726f6388 JA |
1375 | and the value is printed before each command |
1376 | .B bash | |
1377 | displays during an execution trace. The first character of | |
1378 | .SM | |
1379 | .B PS4 | |
1380 | is replicated multiple times, as necessary, to indicate multiple | |
1381 | levels of indirection. The default is ``\fB+ \fP''. | |
1382 | .TP | |
ccc6cda3 JA |
1383 | .B TIMEFORMAT |
1384 | The value of this parameter is used as a format string specifying | |
1385 | how the timing information for pipelines prefixed with the | |
1386 | .B time | |
1387 | reserved word should be displayed. | |
1388 | The \fB%\fP character introduces an escape sequence that is | |
1389 | expanded to a time value or other information. | |
1390 | The escape sequences and their meanings are as follows; the | |
1391 | braces denote optional portions. | |
1392 | .sp .5 | |
1393 | .RS | |
1394 | .PD 0 | |
1395 | .TP 10 | |
1396 | .B %% | |
1397 | A literal \fB%\fP. | |
1398 | .TP | |
1399 | .B %[\fIp\fP][l]R | |
1400 | The elapsed time in seconds. | |
1401 | .TP | |
1402 | .B %[\fIp\fP][l]U | |
1403 | The number of CPU seconds spent in user mode. | |
1404 | .TP | |
1405 | .B %[\fIp\fP][l]S | |
1406 | The number of CPU seconds spent in system mode. | |
1407 | .TP | |
1408 | .B %P | |
1409 | The CPU percentage, computed as (%U + %S) / %R. | |
1410 | .PD | |
1411 | .RE | |
1412 | .IP | |
1413 | The optional \fIp\fP is a digit specifying the \fIprecision\fP, | |
1414 | the number of fractional digits after a decimal point. | |
1415 | A value of 0 causes no decimal point or fraction to be output. | |
1416 | At most three places after the decimal point may be specified; | |
1417 | values of \fIp\fP greater than 3 are changed to 3. | |
1418 | If \fIp\fP is not specified, the value 3 is used. | |
1419 | .IP | |
1420 | The optional \fBl\fP specifies a longer format, including | |
1421 | minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs. | |
1422 | The value of \fIp\fP determines whether or not the fraction is | |
1423 | included. | |
1424 | .IP | |
1425 | If this variable is not set, \fBbash\fP acts as if it had the | |
1426 | value \fB$'\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS'\fP. | |
1427 | If the value is null, no timing information is displayed. | |
1428 | A trailing newline is added when the format string is displayed. | |
1429 | .TP | |
726f6388 JA |
1430 | .B HISTSIZE |
1431 | The number of commands to remember in the command history (see | |
1432 | .SM | |
1433 | .B HISTORY | |
1434 | below). The default value is 500. | |
1435 | .TP | |
1436 | .B HISTFILE | |
ccc6cda3 | 1437 | The name of the file in which command history is saved (see |
726f6388 JA |
1438 | .SM |
1439 | .B HISTORY | |
ccc6cda3 | 1440 | below). The default value is \fI~/.bash_history\fP. If unset, the |
726f6388 JA |
1441 | command history is not saved when an interactive shell exits. |
1442 | .TP | |
1443 | .B HISTFILESIZE | |
1444 | The maximum number of lines contained in the history file. When this | |
1445 | variable is assigned a value, the history file is truncated, if | |
1446 | necessary, to contain no more than that number of lines. The default | |
ccc6cda3 JA |
1447 | value is 500. The history file is also truncated to this size after |
1448 | writing it when an interactive shell exits. | |
726f6388 JA |
1449 | .TP |
1450 | .B OPTERR | |
1451 | If set to the value 1, | |
1452 | .B bash | |
1453 | displays error messages generated by the | |
1454 | .B getopts | |
1455 | builtin command (see | |
1456 | .SM | |
1457 | .B SHELL BUILTIN COMMANDS | |
1458 | below). | |
1459 | .SM | |
1460 | .B OPTERR | |
1461 | is initialized to 1 each time the shell is invoked or a shell | |
1462 | script is executed. | |
1463 | .TP | |
ccc6cda3 JA |
1464 | .B LANG |
1465 | Used to determine the locale category for any category not specifically | |
1466 | selected with a variable starting with \fBLC_\fP. | |
1467 | .TP | |
1468 | .B LC_ALL | |
1469 | This variable overrides the value of \fBLANG\fP and any other | |
1470 | \fBLC_\fP variable specifying a locale category. | |
1471 | .TP | |
1472 | .B LC_COLLATE | |
1473 | This variable determines the collation order used when sorting the | |
cce855bc JA |
1474 | results of pathname expansion, and determines the behavior of range |
1475 | expressions, equivalence classes, and collating sequences within | |
1476 | pathname expansion and pattern matching. | |
1477 | .TP | |
1478 | .B LC_CTYPE | |
1479 | This variable determines the interpretation of characters and the | |
1480 | behavior of character classes within pathname expansion and pattern | |
1481 | matching. | |
ccc6cda3 JA |
1482 | .TP |
1483 | .B LC_MESSAGES | |
1484 | This variable determines the locale used to translate double-quoted | |
1485 | strings preceded by a \fB$\fP. | |
1486 | .TP | |
726f6388 JA |
1487 | .B PROMPT_COMMAND |
1488 | If set, the value is executed as a command prior to issuing each primary | |
1489 | prompt. | |
1490 | .TP | |
1491 | .B IGNOREEOF | |
1492 | Controls the | |
ccc6cda3 | 1493 | action of an interactive shell on receipt of an |
726f6388 JA |
1494 | .SM |
1495 | .B EOF | |
1496 | character as the sole input. If set, the value is the number of | |
1497 | consecutive | |
1498 | .SM | |
1499 | .B EOF | |
ccc6cda3 JA |
1500 | characters which must be |
1501 | typed as the first characters on an input line before | |
726f6388 JA |
1502 | .B bash |
1503 | exits. If the variable exists but does not have a numeric value, or | |
1504 | has no value, the default value is 10. If it does not exist, | |
1505 | .SM | |
1506 | .B EOF | |
ccc6cda3 | 1507 | signifies the end of input to the shell. |
726f6388 JA |
1508 | .TP |
1509 | .B TMOUT | |
1510 | If set to a value greater than zero, the value is interpreted as the | |
1511 | number of seconds to wait for input after issuing the primary prompt. | |
1512 | .B Bash | |
1513 | terminates after waiting for that number of seconds if input does | |
1514 | not arrive. | |
1515 | .TP | |
1516 | .B FCEDIT | |
1517 | The default editor for the | |
1518 | .B fc | |
1519 | builtin command. | |
1520 | .TP | |
1521 | .B FIGNORE | |
1522 | A colon-separated list of suffixes to ignore when performing | |
1523 | filename completion (see | |
1524 | .SM | |
1525 | .B READLINE | |
ccc6cda3 JA |
1526 | below). |
1527 | A filename whose suffix matches one of the entries in | |
726f6388 JA |
1528 | .SM |
1529 | .B FIGNORE | |
ccc6cda3 JA |
1530 | is excluded from the list of matched filenames. |
1531 | A sample value is ``.o:~''. | |
1532 | .TP | |
1533 | .B GLOBIGNORE | |
1534 | A colon-separated list of patterns defining the set of filenames to | |
1535 | be ignored by pathname expansion. | |
1536 | If a filename matched by a pathname expansion pattern also matches one | |
1537 | of the patterns in | |
1538 | .SM | |
1539 | .BR GLOBIGNORE , | |
1540 | it is removed from the list of matches. | |
726f6388 JA |
1541 | .TP |
1542 | .B INPUTRC | |
ccc6cda3 JA |
1543 | The filename for the |
1544 | .B readline | |
1545 | startup file, overriding the default of | |
726f6388 JA |
1546 | .FN ~/.inputrc |
1547 | (see | |
1548 | .SM | |
1549 | .B READLINE | |
1550 | below). | |
1551 | .TP | |
726f6388 | 1552 | .B HISTCONTROL |
726f6388 JA |
1553 | If set to a value of |
1554 | .IR ignorespace , | |
1555 | lines which begin with a | |
1556 | .B space | |
1557 | character are not entered on the history list. If set to | |
1558 | a value of | |
1559 | .IR ignoredups , | |
1560 | lines matching the last history line are not entered. | |
1561 | A value of | |
1562 | .I ignoreboth | |
1563 | combines the two options. | |
1564 | If unset, or if set to any other value than those above, | |
1565 | all lines read | |
ccc6cda3 JA |
1566 | by the parser are saved on the history list, subject to the value |
1567 | of | |
1568 | .BR HISTIGNORE . | |
1569 | This variable's function is superseded by | |
1570 | .BR HISTIGNORE . | |
cce855bc JA |
1571 | The second and subsequent lines of a multi-line compound command are |
1572 | not tested, and are added to the history regardless of the value of | |
1573 | .BR HISTCONTROL . | |
ccc6cda3 JA |
1574 | .TP |
1575 | .B HISTIGNORE | |
1576 | A colon-separated list of patterns used to decide which command lines | |
1577 | should be saved on the history list. Each pattern is anchored at the | |
1578 | beginning of the line and must fully specify the line (no implicit | |
1579 | `\fB*\fP' is appended). Each pattern is tested against the line | |
1580 | after the checks specified by | |
1581 | .B HISTCONTROL | |
1582 | are applied. | |
1583 | In addition to the normal shell pattern matching characters, `\fB&\fP' | |
1584 | matches the previous history line. `\fB&\fP' may be escaped using a | |
1585 | backslash. The backslash is removed before attempting a match. | |
cce855bc JA |
1586 | The second and subsequent lines of a multi-line compound command are |
1587 | not tested, and are added to the history regardless of the value of | |
1588 | .BR HISTIGNORE . | |
726f6388 JA |
1589 | .TP |
1590 | .B histchars | |
1591 | The two or three characters which control history expansion | |
1592 | and tokenization (see | |
1593 | .SM | |
1594 | .B HISTORY EXPANSION | |
1595 | below). The first character is the | |
1596 | .IR "history expansion character" , | |
cce855bc | 1597 | the character which signals the start of a history |
726f6388 JA |
1598 | expansion, normally `\fB!\fP'. |
1599 | The second character is the | |
1600 | .IR "quick substitution" | |
1601 | character, which is used as shorthand for re-running the previous | |
1602 | command entered, substituting one string for another in the command. | |
1603 | The default is `\fB^\fP'. | |
1604 | The optional third character is the character | |
cce855bc | 1605 | which indicates that the remainder of the line is a comment when found |
726f6388 JA |
1606 | as the first character of a word, normally `\fB#\fP'. The history |
1607 | comment character causes history substitution to be skipped for the | |
1608 | remaining words on the line. It does not necessarily cause the shell | |
1609 | parser to treat the rest of the line as a comment. | |
1610 | .TP | |
726f6388 | 1611 | .B HOSTFILE |
726f6388 JA |
1612 | Contains the name of a file in the same format as |
1613 | .FN /etc/hosts | |
1614 | that should be read when the shell needs to complete a | |
1615 | hostname. The file may be changed interactively; the next | |
1616 | time hostname completion is attempted | |
1617 | .B bash | |
1618 | adds the contents of the new file to the already existing database. | |
1619 | .TP | |
726f6388 JA |
1620 | .B auto_resume |
1621 | This variable controls how the shell interacts with the user and | |
1622 | job control. If this variable is set, single word simple | |
1623 | commands without redirections are treated as candidates for resumption | |
1624 | of an existing stopped job. There is no ambiguity allowed; if there is | |
1625 | more than one job beginning with the string typed, the job most recently | |
1626 | accessed is selected. The | |
1627 | .I name | |
1628 | of a stopped job, in this context, is the command line used to | |
1629 | start it. | |
1630 | If set to the value | |
1631 | .IR exact , | |
1632 | the string supplied must match the name of a stopped job exactly; | |
1633 | if set to | |
1634 | .IR substring , | |
1635 | the string supplied needs to match a substring of the name of a | |
1636 | stopped job. The | |
1637 | .I substring | |
1638 | value provides functionality analogous to the | |
1639 | .B %? | |
ccc6cda3 | 1640 | job identifier (see |
726f6388 JA |
1641 | .SM |
1642 | .B JOB CONTROL | |
1643 | below). If set to any other value, the supplied string must | |
1644 | be a prefix of a stopped job's name; this provides functionality | |
1645 | analogous to the | |
1646 | .B % | |
ccc6cda3 | 1647 | job identifier. |
726f6388 | 1648 | .PD |
ccc6cda3 JA |
1649 | .SS Arrays |
1650 | .B Bash | |
1651 | provides one-dimensional array variables. Any variable may be used as | |
1652 | an array; the | |
1653 | .B declare | |
1654 | builtin will explicitly declare an array. There is no maximum | |
1655 | limit on the size of an array, nor any requirement that members | |
1656 | be indexed or assigned contiguously. Arrays are indexed using | |
1657 | integers and are zero-based. | |
1658 | .PP | |
1659 | An array is created automatically if any variable is assigned to using | |
1660 | the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The | |
1661 | .I subscript | |
1662 | is treated as an arithmetic expression that must evaluate to a number | |
1663 | greater than or equal to zero. To explicitly declare an array, use | |
1664 | .B declare \-a \fIname\fP | |
1665 | (see | |
1666 | .SM | |
1667 | .B SHELL BUILTIN COMMANDS | |
1668 | below). | |
1669 | .B declare \-a \fIname\fP[\fIsubscript\fP] | |
1670 | is also accepted; the \fIsubscript\fP is ignored. Attributes may be | |
1671 | specified for an array variable using the | |
1672 | .B declare | |
1673 | and | |
1674 | .B readonly | |
1675 | builtins. Each attribute applies to all members of an array. | |
1676 | .PP | |
1677 | Arrays are assigned to using compound assignments of the form | |
1678 | \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each | |
1679 | \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only | |
1680 | \fIstring\fP is required. If | |
1681 | the optional brackets and subscript are supplied, that index is assigned to; | |
1682 | otherwise the index of the element assigned is the last index assigned | |
1683 | to by the statement plus one. Indexing starts at zero. | |
1684 | This syntax is also accepted by the | |
1685 | .B declare | |
1686 | builtin. Individual array elements may be assigned to using the | |
1687 | \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above. | |
1688 | .PP | |
1689 | Any element of an array may be referenced using | |
1690 | ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid | |
1691 | conflicts with pathname expansion. If | |
1692 | \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to | |
1693 | all members of \fIname\fP. These subscripts differ only when the | |
1694 | word appears within double quotes. If the word is double-quoted, | |
1695 | ${\fIname\fP[*]} expands to a single | |
1696 | word with the value of each array member separated by the first | |
1697 | character of the | |
1698 | .SM | |
1699 | .B IFS | |
1700 | special variable, and ${\fIname\fP[@]} expands each element of | |
1701 | \fIname\fP to a separate word. When there are no array members, | |
1702 | ${\fIname\fP[@]} expands to nothing. This is analogous to the expansion | |
1703 | of the special parameters \fB*\fP and \fB@\fP (see | |
1704 | .B Special Parameters | |
1705 | above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of | |
1706 | ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or | |
1707 | \fB@\fP, the expansion is the number of elements in the array. | |
1708 | Referencing an array variable without a subscript is equivalent to | |
1709 | referencing element zero. | |
1710 | .PP | |
1711 | The | |
1712 | .B unset | |
cce855bc | 1713 | builtin is used to destroy arrays. \fBunset\fP \fBname\fP[\fIsubscript\fP] |
ccc6cda3 JA |
1714 | destroys the array element at index \fIsubscript\fP. |
1715 | \fBunset\fP \fIname\fP, where \fIname\fP is an array, or | |
1716 | \fBunset\fP \fIname\fP[\fIsubscript\fP], where | |
1717 | \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array. | |
1718 | .PP | |
1719 | The | |
1720 | .BR declare , | |
1721 | .BR local , | |
1722 | and | |
1723 | .B readonly | |
1724 | builtins each accept a | |
1725 | .B \-a | |
1726 | option to specify an array. The | |
1727 | .B read | |
1728 | builtin accepts a | |
1729 | .B \-a | |
1730 | option to assign a list of words read from the standard input | |
1731 | to an array. The | |
1732 | .B set | |
1733 | and | |
1734 | .B declare | |
1735 | builtins display array values in a way that allows them to be | |
1736 | reused as assignments. | |
726f6388 JA |
1737 | .SH EXPANSION |
1738 | Expansion is performed on the command line after it has been split into | |
1739 | words. There are seven kinds of expansion performed: | |
1740 | .IR "brace expansion" , | |
1741 | .IR "tilde expansion" , | |
1742 | .IR "parameter and variable expansion" , | |
1743 | .IR "command substitution" , | |
1744 | .IR "arithmetic expansion" , | |
1745 | .IR "word splitting" , | |
1746 | and | |
1747 | .IR "pathname expansion" . | |
1748 | .PP | |
1749 | The order of expansions is: brace expansion, tilde expansion, | |
ccc6cda3 JA |
1750 | parameter, variable and arithmetic expansion and |
1751 | command substitution | |
1752 | (done in a left-to-right fashion), word splitting, and pathname | |
726f6388 JA |
1753 | expansion. |
1754 | .PP | |
1755 | On systems that can support it, there is an additional expansion | |
1756 | available: \fIprocess substitution\fP. | |
1757 | .PP | |
1758 | Only brace expansion, word splitting, and pathname expansion | |
1759 | can change the number of words of the expansion; other expansions | |
1760 | expand a single word to a single word. | |
ccc6cda3 | 1761 | The only exceptions to this are the expansions of |
cce855bc | 1762 | "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP" |
ccc6cda3 | 1763 | as explained above (see |
726f6388 JA |
1764 | .SM |
1765 | .BR PARAMETERS ). | |
1766 | .SS Brace Expansion | |
1767 | .PP | |
1768 | .I "Brace expansion" | |
1769 | is a mechanism by which arbitrary strings | |
1770 | may be generated. This mechanism is similar to | |
1771 | \fIpathname expansion\fP, but the filenames generated | |
1772 | need not exist. Patterns to be brace expanded take | |
1773 | the form of an optional | |
1774 | .IR preamble , | |
1775 | followed by a series of comma-separated strings | |
1776 | between a pair of braces, followed by an optional | |
cce855bc | 1777 | .IR postscript . |
ccc6cda3 | 1778 | The preamble is prefixed to each string contained |
cce855bc | 1779 | within the braces, and the postscript is then appended |
726f6388 JA |
1780 | to each resulting string, expanding left to right. |
1781 | .PP | |
1782 | Brace expansions may be nested. The results of each expanded | |
1783 | string are not sorted; left to right order is preserved. | |
1784 | For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'. | |
1785 | .PP | |
1786 | Brace expansion is performed before any other expansions, | |
1787 | and any characters special to other expansions are preserved | |
1788 | in the result. It is strictly textual. | |
1789 | .B Bash | |
1790 | does not apply any syntactic interpretation to the context of the | |
1791 | expansion or the text between the braces. | |
1792 | .PP | |
1793 | A correctly-formed brace expansion must contain unquoted opening | |
1794 | and closing braces, and at least one unquoted comma. | |
1795 | Any incorrectly formed brace expansion is left unchanged. | |
ccc6cda3 JA |
1796 | A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its |
1797 | being considered part of a brace expression. | |
726f6388 JA |
1798 | .PP |
1799 | This construct is typically used as shorthand when the common | |
1800 | prefix of the strings to be generated is longer than in the | |
1801 | above example: | |
1802 | .RS | |
1803 | .PP | |
1804 | mkdir /usr/local/src/bash/{old,new,dist,bugs} | |
1805 | .RE | |
1806 | or | |
1807 | .RS | |
1808 | chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} | |
1809 | .RE | |
1810 | .PP | |
1811 | Brace expansion introduces a slight incompatibility with | |
ccc6cda3 JA |
1812 | historical versions of |
1813 | .BR sh . | |
726f6388 JA |
1814 | .B sh |
1815 | does not treat opening or closing braces specially when they | |
1816 | appear as part of a word, and preserves them in the output. | |
1817 | .B Bash | |
1818 | removes braces from words as a consequence of brace | |
1819 | expansion. For example, a word entered to | |
1820 | .B sh | |
1821 | as \fIfile{1,2}\fP | |
1822 | appears identically in the output. The same word is | |
1823 | output as | |
1824 | .I file1 file2 | |
1825 | after expansion by | |
1826 | .BR bash . | |
1827 | If strict compatibility with | |
1828 | .B sh | |
1829 | is desired, start | |
1830 | .B bash | |
1831 | with the | |
ccc6cda3 JA |
1832 | .B +B |
1833 | option or disable brace expansion with the | |
1834 | .B +B | |
726f6388 JA |
1835 | option to the |
1836 | .B set | |
1837 | command (see | |
1838 | .SM | |
1839 | .B SHELL BUILTIN COMMANDS | |
1840 | below). | |
1841 | .SS Tilde Expansion | |
1842 | .PP | |
cce855bc JA |
1843 | If a word begins with an unquoted tilde character (`\fB~\fP'), all of |
1844 | the characters preceding the first unquoted slash (or all characters, | |
1845 | if there is no unquoted slash) are considered a \fItilde-prefix\fP. | |
1846 | If none of the characters in the tilde-prefix are quoted, the | |
1847 | characters in the tilde-prefix following the tilde are treated as a | |
1848 | possible \fIlogin name\fP. | |
1849 | If this login name is the null string, the tilde is replaced with the | |
1850 | value of the shell parameter | |
726f6388 JA |
1851 | .SM |
1852 | .BR HOME . | |
1853 | If | |
1854 | .SM | |
1855 | .B HOME | |
cce855bc JA |
1856 | is unset, the home directory of the user executing the shell is |
1857 | substituted instead. | |
1858 | Otherwise, the tilde-prefix is replaced with the home directory | |
1859 | associated with the specified login name. | |
726f6388 | 1860 | .PP |
cce855bc | 1861 | If the tilde-prefix is a `~+', the value of the shell variable |
726f6388 JA |
1862 | .SM |
1863 | .B PWD | |
cce855bc JA |
1864 | replaces the tilde-prefix. |
1865 | If the tilde-prefix is a `~\-', the value of the shell variable | |
1866 | .SM | |
1867 | .BR OLDPWD , | |
1868 | if it is set, is substituted. | |
1869 | If the characters following the tilde in the tilde-prefix consist | |
1870 | of a number \fIN\fP, optionally prefixed | |
1871 | by a `+' or a `\-', the tilde-prefix is replaced with the corresponding | |
1872 | element from the directory stack, as it would be displayed by the | |
1873 | .B dirs | |
1874 | builtin invoked with the tilde-prefix as an argument. | |
1875 | If the characters following the tilde in the tilde-prefix consist of a | |
1876 | number without a leading `+' or `\-', `+' is assumed. | |
1877 | .PP | |
1878 | If the login name is invalid, or the tilde expansion fails, the word | |
1879 | is unchanged. | |
726f6388 | 1880 | .PP |
cce855bc JA |
1881 | Each variable assignment is checked for unquoted tilde-prefixes immediately |
1882 | following a | |
726f6388 JA |
1883 | .B : |
1884 | or | |
1885 | .BR = . | |
cce855bc JA |
1886 | In these cases, tilde expansion is also performed. |
1887 | Consequently, one may use file names with tildes in assignments to | |
726f6388 JA |
1888 | .SM |
1889 | .BR PATH , | |
1890 | .SM | |
1891 | .BR MAILPATH , | |
1892 | and | |
1893 | .SM | |
1894 | .BR CDPATH , | |
1895 | and the shell assigns the expanded value. | |
1896 | .SS Parameter Expansion | |
1897 | .PP | |
1898 | The `\fB$\fP' character introduces parameter expansion, | |
1899 | command substitution, or arithmetic expansion. The parameter name | |
1900 | or symbol to be expanded may be enclosed in braces, which | |
1901 | are optional but serve to protect the variable to be expanded from | |
1902 | characters immediately following it which could be | |
1903 | interpreted as part of the name. | |
1904 | .PP | |
cce855bc JA |
1905 | When braces are used, the matching ending brace is the first `\fB}\fP' |
1906 | not escaped by a backslash or within a quoted string, and not within an | |
1907 | embedded arithmetic expansion, command substitution, or paramter | |
1908 | expansion. | |
1909 | .PP | |
726f6388 JA |
1910 | .PD 0 |
1911 | .TP | |
1912 | ${\fIparameter\fP} | |
1913 | The value of \fIparameter\fP is substituted. The braces are required | |
1914 | when | |
1915 | .I parameter | |
1916 | is a positional parameter with more than one digit, | |
1917 | or when | |
1918 | .I parameter | |
1919 | is followed by a character which is not to be | |
1920 | interpreted as part of its name. | |
1921 | .PD | |
1922 | .PP | |
ccc6cda3 JA |
1923 | If the first character of \fIparameter\fP is an exclamation point, |
1924 | a level of variable indirection is introduced. | |
1925 | \fBBash\fP uses the value of the variable formed from the rest of | |
1926 | \fIparameter\fP as the name of the variable; this variable is then | |
1927 | expanded and that value used in the rest of the substitution, rather | |
1928 | than the value of \fIparameter\fP itself. | |
1929 | This is known as \fIindirect expansion\fP. | |
1930 | .PP | |
726f6388 JA |
1931 | In each of the cases below, \fIword\fP is subject to tilde expansion, |
1932 | parameter expansion, command substitution, and arithmetic expansion. | |
ccc6cda3 JA |
1933 | When not performing substring expansion, \fBbash\fP tests for a parameter |
1934 | that is unset or null; omitting the colon results in a test only for a | |
1935 | parameter that is unset. | |
726f6388 JA |
1936 | .PP |
1937 | .PD 0 | |
1938 | .TP | |
1939 | ${\fIparameter\fP\fB:\-\fP\fIword\fP} | |
1940 | \fBUse Default Values\fP. If | |
1941 | .I parameter | |
1942 | is unset or null, the expansion of | |
1943 | .I word | |
1944 | is substituted. Otherwise, the value of | |
1945 | .I parameter | |
1946 | is substituted. | |
1947 | .TP | |
1948 | ${\fIparameter\fP\fB:=\fP\fIword\fP} | |
1949 | \fBAssign Default Values\fP. | |
1950 | If | |
1951 | .I parameter | |
1952 | is unset or null, the expansion of | |
1953 | .I word | |
1954 | is assigned to | |
1955 | .IR parameter . | |
1956 | The value of | |
1957 | .I parameter | |
1958 | is then substituted. Positional parameters and special parameters may | |
1959 | not be assigned to in this way. | |
1960 | .TP | |
1961 | ${\fIparameter\fP\fB:?\fP\fIword\fP} | |
1962 | \fBDisplay Error if Null or Unset\fP. | |
1963 | If | |
1964 | .I parameter | |
1965 | is null or unset, the expansion of \fIword\fP (or a message to that effect | |
1966 | if | |
1967 | .I word | |
1968 | is not present) is written to the standard error and the shell, if it | |
1969 | is not interactive, exits. Otherwise, the value of \fIparameter\fP is | |
1970 | substituted. | |
1971 | .TP | |
1972 | ${\fIparameter\fP\fB:+\fP\fIword\fP} | |
1973 | \fBUse Alternate Value\fP. | |
1974 | If | |
1975 | .I parameter | |
1976 | is null or unset, nothing is substituted, otherwise the expansion of | |
1977 | .I word | |
1978 | is substituted. | |
1979 | .TP | |
ccc6cda3 JA |
1980 | .PD 0 |
1981 | ${\fIparameter\fP\fB:\fP\fIoffset\fP} | |
1982 | .TP | |
1983 | ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP} | |
1984 | .PD | |
1985 | \fBSubstring Expansion.\fP | |
1986 | Expands to up to \fIlength\fP characters of \fIparameter\fP, | |
cce855bc | 1987 | starting at the characters specified by \fIoffset\fP. |
ccc6cda3 JA |
1988 | If \fIlength\fP is omitted, expands to the substring of |
1989 | \fIparameter\fP, starting at the character specified by \fIoffset\fP. | |
1990 | \fIlength\fP and \fIoffset\fP are arithmetic expressions (see | |
1991 | .SM | |
1992 | .B | |
1993 | ARITHMETIC EVALUATION | |
1994 | below). | |
1995 | \fIlength\fP must evaluate to a number greater than or equal to zero. | |
1996 | If \fIoffset\fP evaluates to a number less than zero, the value | |
1997 | is used as an offset from the end of the value of \fIparameter\fP. | |
1998 | If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional | |
1999 | parameters beginning at \fIoffset\fP. | |
2000 | If \fIparameter\fP is an array name indexed by @ or *, | |
2001 | the result is the \fIlength\fP | |
2002 | members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}. | |
cce855bc JA |
2003 | Substring indexing is zero-based unless the positional parameters |
2004 | are used, in which case the indexing starts at 1. | |
ccc6cda3 | 2005 | .TP |
726f6388 JA |
2006 | ${\fB#\fP\fIparameter\fP} |
2007 | The length in characters of the value of \fIparameter\fP is substituted. | |
ccc6cda3 JA |
2008 | If |
2009 | .I parameter | |
2010 | is | |
726f6388 JA |
2011 | .B * |
2012 | or | |
2013 | .BR @ , | |
cce855bc | 2014 | the value substituted is the number of positional parameters. |
ccc6cda3 JA |
2015 | If |
2016 | .I parameter | |
2017 | is an array name subscripted by | |
726f6388 | 2018 | .B * |
ccc6cda3 JA |
2019 | or |
2020 | .BR @ , | |
cce855bc | 2021 | the value substituted is the number of elements in the array. |
726f6388 JA |
2022 | .TP |
2023 | .PD 0 | |
2024 | ${\fIparameter\fP\fB#\fP\fIword\fP} | |
2025 | .TP | |
2026 | ${\fIparameter\fP\fB##\fP\fIword\fP} | |
2027 | .PD | |
2028 | The | |
2029 | .I word | |
2030 | is expanded to produce a pattern just as in pathname | |
2031 | expansion. If the pattern matches the beginning of | |
2032 | the value of | |
2033 | .IR parameter , | |
cce855bc | 2034 | then the result of the expansion is the expanded value of |
726f6388 | 2035 | .I parameter |
ccc6cda3 JA |
2036 | with the shortest matching pattern (the ``\fB#\fP'' case) or the |
2037 | longest matching pattern (the ``\fB##\fP'' case) deleted. | |
2038 | If | |
2039 | .I parameter | |
2040 | is | |
2041 | .B @ | |
2042 | or | |
2043 | .BR * , | |
2044 | the pattern removal operation is applied to each positional | |
2045 | parameter in turn, and the expansion is the resultant list. | |
2046 | If | |
2047 | .I parameter | |
2048 | is an array variable subscripted with | |
2049 | .B @ | |
2050 | or | |
2051 | .BR * , | |
2052 | the pattern removal operation is applied to each member of the | |
2053 | array in turn, and the expansion is the resultant list. | |
726f6388 JA |
2054 | .TP |
2055 | .PD 0 | |
2056 | ${\fIparameter\fP\fB%\fP\fIword\fP} | |
2057 | .TP | |
2058 | ${\fIparameter\fP\fB%%\fP\fIword\fP} | |
2059 | .PD | |
2060 | The \fIword\fP is expanded to produce a pattern just as in | |
ccc6cda3 | 2061 | pathname expansion. |
cce855bc | 2062 | If the pattern matches a trailing portion of the expanded value of |
726f6388 | 2063 | .IR parameter , |
cce855bc | 2064 | then the result of the expansion is the expanded value of |
726f6388 | 2065 | .I parameter |
ccc6cda3 JA |
2066 | with the shortest matching pattern (the ``\fB%\fP'' case) or the |
2067 | longest matching pattern (the ``\fB%%\fP'' case) deleted. | |
2068 | If | |
2069 | .I parameter | |
2070 | is | |
2071 | .B @ | |
2072 | or | |
2073 | .BR * , | |
2074 | the pattern removal operation is applied to each positional | |
2075 | parameter in turn, and the expansion is the resultant list. | |
2076 | If | |
2077 | .I parameter | |
2078 | is an array variable subscripted with | |
2079 | .B @ | |
2080 | or | |
2081 | .BR * , | |
2082 | the pattern removal operation is applied to each member of the | |
2083 | array in turn, and the expansion is the resultant list. | |
2084 | .TP | |
2085 | .PD 0 | |
2086 | ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP} | |
2087 | .TP | |
2088 | ${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP} | |
2089 | .PD | |
2090 | The \fIpattern\fP is expanded to produce a pattern just as in | |
2091 | pathname expansion. | |
2092 | \fIParameter\fP is expanded and the longest match of \fIpattern\fP | |
2093 | against its value is replaced with \fIstring\fP. | |
2094 | In the first form, only the first match is replaced. | |
2095 | The second form causes all matches of \fIpattern\fP to be | |
2096 | replaced with \fIstring\fP. | |
2097 | If \fIpattern\fP begins with \fB#\fP, it must match at the beginning | |
2098 | of \fIstring\fP. | |
2099 | If \fIpattern\fP begins with \fB%\fP, it must match at the end | |
2100 | of \fIstring\fP. | |
2101 | If \fIstring\fP is null, matches of \fIpattern\fP are deleted | |
2102 | and the \fB/\fP following \fIpattern\fP may be omitted. | |
2103 | If | |
2104 | .I parameter | |
2105 | is | |
2106 | .B @ | |
2107 | or | |
2108 | .BR * , | |
2109 | the substitution operation is applied to each positional | |
2110 | parameter in turn, and the expansion is the resultant list. | |
2111 | If | |
2112 | .I parameter | |
2113 | is an array variable subscripted with | |
2114 | .B @ | |
2115 | or | |
2116 | .BR * , | |
2117 | the substitution operation is applied to each member of the | |
2118 | array in turn, and the expansion is the resultant list. | |
726f6388 JA |
2119 | .SS Command Substitution |
2120 | .PP | |
cce855bc | 2121 | \fICommand substitution\fP allows the output of a command to replace |
726f6388 JA |
2122 | the command name. There are two forms: |
2123 | .PP | |
2124 | .RS | |
2125 | .PP | |
2126 | \fB$(\fP\fIcommand\fP\|\fB)\fP | |
2127 | .RE | |
2128 | or | |
2129 | .RS | |
2130 | \fB`\fP\fIcommand\fP\fB`\fP | |
2131 | .RE | |
2132 | .PP | |
ccc6cda3 | 2133 | .B Bash |
726f6388 JA |
2134 | performs the expansion by executing \fIcommand\fP and |
2135 | replacing the command substitution with the standard output of the | |
2136 | command, with any trailing newlines deleted. | |
cce855bc JA |
2137 | Embedded newlines are not deleted, but they may be removed during |
2138 | word splitting. | |
2139 | The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by | |
2140 | the equivalent but faster \fB$(< \fIfile\fP)\fR. | |
726f6388 | 2141 | .PP |
ccc6cda3 | 2142 | When the old-style backquote form of substitution is used, |
726f6388 JA |
2143 | backslash retains its literal meaning except when followed by |
2144 | .BR $ , | |
2145 | .BR ` , | |
2146 | or | |
2147 | .BR \e . | |
cce855bc JA |
2148 | The first backquote not preceded by a backslash terminates the |
2149 | command substitution. | |
726f6388 JA |
2150 | When using the $(\^\fIcommand\fP\|) form, all characters between the |
2151 | parentheses make up the command; none are treated specially. | |
2152 | .PP | |
cce855bc | 2153 | Command substitutions may be nested. To nest when using the backquoted form, |
726f6388 JA |
2154 | escape the inner backquotes with backslashes. |
2155 | .PP | |
2156 | If the substitution appears within double quotes, word splitting and | |
2157 | pathname expansion are not performed on the results. | |
2158 | .SS Arithmetic Expansion | |
2159 | .PP | |
2160 | Arithmetic expansion allows the evaluation of an arithmetic expression | |
ccc6cda3 | 2161 | and the substitution of the result. The format for arithmetic expansion is: |
726f6388 JA |
2162 | .RS |
2163 | .PP | |
726f6388 JA |
2164 | \fB$((\fP\fIexpression\fP\fB))\fP |
2165 | .RE | |
2166 | .PP | |
2167 | The | |
2168 | .I expression | |
2169 | is treated as if it were within double quotes, but a double quote | |
ccc6cda3 JA |
2170 | inside the parentheses is not treated specially. |
2171 | All tokens in the expression undergo parameter expansion, string | |
2172 | expansion, command substitution, and quote removal. | |
2173 | Arithmetic substitutions may be nested. | |
726f6388 JA |
2174 | .PP |
2175 | The evaluation is performed according to the rules listed below under | |
2176 | .SM | |
2177 | .BR "ARITHMETIC EVALUATION" . | |
2178 | If | |
2179 | .I expression | |
2180 | is invalid, | |
2181 | .B bash | |
2182 | prints a message indicating failure and no substitution occurs. | |
2183 | .SS Process Substitution | |
2184 | .PP | |
2185 | \fIProcess substitution\fP is supported on systems that support named | |
2186 | pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files. | |
2187 | It takes the form of | |
2188 | \fB<(\fP\fIlist\^\fP\fB)\fP | |
2189 | or | |
2190 | \fB>(\fP\fIlist\^\fP\fB)\fP. | |
2191 | The process \fIlist\fP is run with its input or output connected to a | |
2192 | \fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is | |
2193 | passed as an argument to the current command as the result of the | |
2194 | expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to | |
2195 | the file will provide input for \fIlist\fP. If the | |
2196 | \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an | |
2197 | argument should be read to obtain the output of \fIlist\fP. | |
2198 | .PP | |
cce855bc | 2199 | When available, \fIprocess substitution\fP is performed |
ccc6cda3 JA |
2200 | simultaneously with parameter and variable expansion, |
2201 | command substitution, | |
2202 | and arithmetic expansion. | |
726f6388 JA |
2203 | .SS Word Splitting |
2204 | .PP | |
2205 | The shell scans the results of | |
2206 | parameter expansion, | |
2207 | command substitution, | |
2208 | and | |
2209 | arithmetic expansion | |
2210 | that did not occur within double quotes for | |
2211 | .IR "word splitting" . | |
2212 | .PP | |
2213 | The shell treats each character of | |
2214 | .SM | |
2215 | .B IFS | |
2216 | as a delimiter, and splits the results of the other | |
ccc6cda3 | 2217 | expansions into words on these characters. If |
726f6388 JA |
2218 | .SM |
2219 | .B IFS | |
ccc6cda3 JA |
2220 | is unset, or its |
2221 | value is exactly | |
726f6388 JA |
2222 | .BR <space><tab><newline> , |
2223 | the default, then | |
2224 | any sequence of | |
2225 | .SM | |
2226 | .B IFS | |
2227 | characters serves to delimit words. If | |
2228 | .SM | |
2229 | .B IFS | |
2230 | has a value other than the default, then sequences of | |
2231 | the whitespace characters | |
2232 | .B space | |
2233 | and | |
2234 | .B tab | |
2235 | are ignored at the beginning and end of the | |
2236 | word, as long as the whitespace character is in the | |
2237 | value of | |
2238 | .SM | |
2239 | .BR IFS | |
2240 | (an | |
2241 | .SM | |
2242 | .B IFS | |
2243 | whitespace character). | |
2244 | Any character in | |
2245 | .SM | |
2246 | .B IFS | |
2247 | that is not | |
2248 | .SM | |
2249 | .B IFS | |
2250 | whitespace, along with any adjacent | |
2251 | .SM | |
2252 | .B IFS | |
2253 | whitespace characters, delimits a field. | |
2254 | A sequence of | |
2255 | .SM | |
2256 | .B IFS | |
2257 | whitespace characters is also treated as a delimiter. | |
2258 | If the value of | |
2259 | .SM | |
2260 | .B IFS | |
2261 | is null, no word splitting occurs. | |
726f6388 | 2262 | .PP |
ccc6cda3 JA |
2263 | Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained. |
2264 | Unquoted implicit null arguments, resulting from the expansion of | |
726f6388 JA |
2265 | .I parameters |
2266 | that have no values, are removed. | |
ccc6cda3 JA |
2267 | If a parameter with no value is expanded within double quotes, a |
2268 | null argument results and is retained. | |
726f6388 JA |
2269 | .PP |
2270 | Note that if no expansion occurs, no splitting | |
2271 | is performed. | |
2272 | .SS Pathname Expansion | |
2273 | .PP | |
2274 | After word splitting, | |
2275 | unless the | |
2276 | .B \-f | |
2277 | option has been set, | |
2278 | .B bash | |
ccc6cda3 | 2279 | scans each word for the characters |
726f6388 JA |
2280 | .BR * , |
2281 | .BR ? , | |
cce855bc | 2282 | .BR ( , |
726f6388 JA |
2283 | and |
2284 | .BR [ . | |
2285 | If one of these characters appears, then the word is | |
2286 | regarded as a | |
2287 | .IR pattern , | |
2288 | and replaced with an alphabetically sorted list of | |
ccc6cda3 JA |
2289 | file names matching the pattern. |
2290 | If no matching file names are found, | |
2291 | and the shell option | |
2292 | .B nullglob | |
2293 | is disabled, the word is left unchanged. | |
cce855bc JA |
2294 | If the |
2295 | .B nullglob | |
2296 | option is set, and no matches are found, | |
726f6388 | 2297 | the word is removed. |
cce855bc JA |
2298 | If the shell option |
2299 | .B nocaseglob | |
2300 | is enabled, the match is performed without regard to the case | |
2301 | of alphabetic characters. | |
ccc6cda3 | 2302 | When a pattern is used for pathname expansion, |
726f6388 JA |
2303 | the character |
2304 | .B ``.'' | |
2305 | at the start of a name or immediately following a slash | |
ccc6cda3 JA |
2306 | must be matched explicitly, unless the shell option |
2307 | .B dotglob | |
2308 | is set. | |
cce855bc JA |
2309 | When matching a pathname, the slash character must always be |
2310 | matched explicitly. | |
ccc6cda3 | 2311 | In other cases, the |
726f6388 JA |
2312 | .B ``.'' |
2313 | character is not treated specially. | |
ccc6cda3 JA |
2314 | See the description of |
2315 | .B shopt | |
2316 | below under | |
2317 | .SM | |
2318 | .B SHELL BUILTIN COMMANDS | |
2319 | for a description of the | |
cce855bc JA |
2320 | .BR nocaseglob , |
2321 | .BR nullglob , | |
ccc6cda3 JA |
2322 | and |
2323 | .B dotglob | |
2324 | shell options. | |
2325 | .PP | |
2326 | The | |
2327 | .SM | |
2328 | .B GLOBIGNORE | |
2329 | shell variable may be used to restrict the set of file names matching a | |
2330 | .IR pattern . | |
2331 | If | |
2332 | .SM | |
2333 | .B GLOBIGNORE | |
2334 | is set, each matching file name that also matches one of the patterns in | |
2335 | .SM | |
2336 | .B GLOBIGNORE | |
2337 | is removed from the list of matches. | |
2338 | The file names | |
2339 | .B ``.'' | |
2340 | and | |
2341 | .B ``..'' | |
2342 | are always ignored, even when | |
2343 | .SM | |
2344 | .B GLOBIGNORE | |
2345 | is set. However, setting | |
2346 | .SM | |
2347 | .B GLOBIGNORE | |
2348 | has the effect of enabling the | |
2349 | .B dotglob | |
2350 | shell option, so all other file names beginning with a | |
2351 | .B ``.'' | |
2352 | will match. | |
2353 | To get the old behavior of ignoring file names beginning with a | |
2354 | .BR ``.'' , | |
2355 | make | |
2356 | .B ``.*'' | |
2357 | one of the patterns in | |
2358 | .SM | |
2359 | .BR GLOBIGNORE . | |
2360 | The | |
2361 | .B dotglob | |
2362 | option is disabled when | |
2363 | .SM | |
2364 | .B GLOBIGNORE | |
2365 | is unset. | |
726f6388 | 2366 | .PP |
cce855bc JA |
2367 | \fBPattern Matching\fP |
2368 | .PP | |
2369 | Any character that appears in a pattern, other than the special pattern | |
2370 | characters described below, matches itself. The NUL character may not | |
2371 | occur in a pattern. The special pattern characters must be quoted if | |
2372 | they are to be matched literally. | |
2373 | .PP | |
726f6388 JA |
2374 | The special pattern characters have the following meanings: |
2375 | .PP | |
2376 | .PD 0 | |
2377 | .TP | |
2378 | .B * | |
2379 | Matches any string, including the null string. | |
2380 | .TP | |
2381 | .B ? | |
2382 | Matches any single character. | |
2383 | .TP | |
2384 | .B [...] | |
2385 | Matches any one of the enclosed characters. A pair of characters | |
2386 | separated by a minus sign denotes a | |
2387 | .IR range ; | |
2388 | any character lexically between those two characters, inclusive, | |
2389 | is matched. If the first character following the | |
2390 | .B [ | |
2391 | is a | |
2392 | .B ! | |
2393 | or a | |
2394 | .B ^ | |
ccc6cda3 JA |
2395 | then any character not enclosed is matched. |
2396 | A | |
726f6388 | 2397 | .B \- |
726f6388 JA |
2398 | may be matched by including it as the first or last character |
2399 | in the set. | |
ccc6cda3 JA |
2400 | A |
2401 | .B ] | |
2402 | may be matched by including it as the first character | |
2403 | in the set. | |
cce855bc JA |
2404 | .br |
2405 | .if t .sp 0.5 | |
2406 | .if n .sp 1 | |
2407 | Within | |
2408 | .B [ | |
2409 | and | |
2410 | .BR ] , | |
2411 | \fIcharacter classes\fP can be specified using the syntax | |
2412 | \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the | |
2413 | following classes defined in the POSIX.2 standard: | |
2414 | .PP | |
2415 | .RS | |
2416 | .B | |
2417 | .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper xdigit | |
2418 | .if t alnum alpha ascii blank cntrl digit graph lower print punct space upper xdigit | |
2419 | .br | |
2420 | A character class matches any character belonging to that class. | |
2421 | .br | |
2422 | .if t .sp 0.5 | |
2423 | .if n .sp 1 | |
2424 | Within | |
2425 | .B [ | |
2426 | and | |
2427 | .BR ] , | |
2428 | an \fIequivalence class\fP can be specified using the syntax | |
2429 | \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the | |
2430 | same collation weight (as defined by the current locale) as | |
2431 | the character \fIc\fP. | |
2432 | .br | |
2433 | .if t .sp 0.5 | |
2434 | .if n .sp 1 | |
2435 | Within | |
2436 | .B [ | |
2437 | and | |
2438 | .BR ] , | |
2439 | the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol | |
2440 | \fIsymbol\fP. | |
2441 | .RE | |
2442 | .PD | |
2443 | .PP | |
2444 | If the \fBextglob\fP shell option is enabled using the \fBshopt\fP | |
2445 | builtin, several extended pattern matching operators are recognized. | |
2446 | In the following description, a \fIpattern\-list\fP is a list of one | |
2447 | or more patterns separated by a \fB|\fP. | |
2448 | Composite patterns may be formed using one or more of the following | |
2449 | sub-patterns: | |
2450 | .sp 1 | |
2451 | .PD 0 | |
2452 | .RS | |
2453 | .TP | |
2454 | \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP | |
2455 | Matches zero or one occurrence of the given patterns | |
2456 | .TP | |
2457 | \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP | |
2458 | Matches zero or more occurrences of the given patterns | |
2459 | .TP | |
2460 | \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP | |
2461 | Matches one or more occurrences of the given patterns | |
2462 | .TP | |
2463 | \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP | |
2464 | Matches exactly one of the given patterns | |
2465 | .TP | |
2466 | \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP | |
2467 | Matches anything except one of the given patterns | |
2468 | .RE | |
726f6388 JA |
2469 | .PD |
2470 | .SS Quote Removal | |
2471 | .PP | |
2472 | After the preceding expansions, all unquoted occurrences of the | |
2473 | characters | |
2474 | .BR \e , | |
cce855bc | 2475 | .BR ' , |
ccc6cda3 JA |
2476 | and \^\f3"\fP\^ that did not result from one of the above |
2477 | expansions are removed. | |
726f6388 JA |
2478 | .SH REDIRECTION |
2479 | Before a command is executed, its input and output | |
2480 | may be | |
2481 | .I redirected | |
2482 | using a special notation interpreted by the shell. | |
2483 | Redirection may also be used to open and close files for the | |
2484 | current shell execution environment. The following redirection | |
2485 | operators may precede or appear anywhere within a | |
2486 | .I simple command | |
2487 | or may follow a | |
2488 | .IR command . | |
2489 | Redirections are processed in the order they appear, from | |
2490 | left to right. | |
2491 | .PP | |
2492 | In the following descriptions, if the file descriptor number is | |
2493 | omitted, and the first character of the redirection operator is | |
2494 | .BR < , | |
2495 | the redirection refers to the standard input (file descriptor | |
2496 | 0). If the first character of the redirection operator is | |
2497 | .BR > , | |
2498 | the redirection refers to the standard output (file descriptor | |
2499 | 1). | |
2500 | .PP | |
cce855bc JA |
2501 | The word following the redirection operator in the following |
2502 | descriptions, unless otherwise noted, is subjected to brace expansion, | |
2503 | tilde expansion, parameter expansion, command substitution, arithmetic | |
2504 | expansion, quote removal, and pathname expansion. | |
2505 | If it expands to more than one word, | |
726f6388 JA |
2506 | .B bash |
2507 | reports an error. | |
2508 | .PP | |
2509 | Note that the order of redirections is significant. For example, | |
2510 | the command | |
2511 | .RS | |
2512 | .PP | |
2513 | ls \fB>\fP dirlist 2\fB>&\fP1 | |
2514 | .RE | |
2515 | .PP | |
2516 | directs both standard output and standard error to the file | |
2517 | .IR dirlist , | |
2518 | while the command | |
2519 | .RS | |
2520 | .PP | |
2521 | ls 2\fB>&\fP1 \fB>\fP dirlist | |
2522 | .RE | |
2523 | .PP | |
2524 | directs only the standard output to file | |
2525 | .IR dirlist , | |
2526 | because the standard error was duplicated as standard output | |
2527 | before the standard output was redirected to | |
2528 | .IR dirlist . | |
cce855bc JA |
2529 | .PP |
2530 | A failure to open or create a file causes the redirection to fail. | |
726f6388 JA |
2531 | .SS Redirecting Input |
2532 | .PP | |
2533 | Redirection of input causes the file whose name results from | |
2534 | the expansion of | |
2535 | .I word | |
2536 | to be opened for reading on file descriptor | |
2537 | .IR n , | |
2538 | or the standard input (file descriptor 0) if | |
2539 | .I n | |
2540 | is not specified. | |
2541 | .PP | |
2542 | The general format for redirecting input is: | |
2543 | .RS | |
2544 | .PP | |
2545 | [\fIn\fP]\fB<\fP\fIword\fP | |
2546 | .RE | |
2547 | .SS Redirecting Output | |
2548 | .PP | |
2549 | Redirection of output causes the file whose name results from | |
2550 | the expansion of | |
2551 | .I word | |
2552 | to be opened for writing on file descriptor | |
2553 | .IR n , | |
2554 | or the standard output (file descriptor 1) if | |
2555 | .I n | |
2556 | is not specified. If the file does not exist it is created; | |
2557 | if it does exist it is truncated to zero size. | |
2558 | .PP | |
2559 | The general format for redirecting output is: | |
2560 | .RS | |
2561 | .PP | |
2562 | [\fIn\fP]\fB>\fP\fIword\fP | |
2563 | .RE | |
2564 | .PP | |
2565 | If the redirection operator is | |
ccc6cda3 JA |
2566 | .BR > , |
2567 | and the | |
cce855bc | 2568 | .B noclobber |
ccc6cda3 JA |
2569 | option to the |
2570 | .B set | |
2571 | builtin has been enabled, the redirection will fail if the filename | |
cce855bc JA |
2572 | whose name results from the expansion of \fIword\fP exists and is |
2573 | a regular file. | |
ccc6cda3 | 2574 | If the redirection operator is |
726f6388 | 2575 | .BR >| , |
cce855bc JA |
2576 | or the redirection operator is |
2577 | .B > | |
2578 | and the | |
2579 | .B noclobber | |
726f6388 JA |
2580 | option to the |
2581 | .B set | |
cce855bc | 2582 | builtin command is not enabled, the redirection is attempted even |
ccc6cda3 | 2583 | if the file named by \fIword\fP exists. |
726f6388 JA |
2584 | .SS Appending Redirected Output |
2585 | .PP | |
2586 | Redirection of output in this fashion | |
2587 | causes the file whose name results from | |
2588 | the expansion of | |
2589 | .I word | |
2590 | to be opened for appending on file descriptor | |
2591 | .IR n , | |
2592 | or the standard output (file descriptor 1) if | |
2593 | .I n | |
2594 | is not specified. If the file does not exist it is created. | |
2595 | .PP | |
2596 | The general format for appending output is: | |
2597 | .RS | |
2598 | .PP | |
2599 | [\fIn\fP]\fB>>\fP\fIword\fP | |
2600 | .RE | |
2601 | .PP | |
2602 | .SS Redirecting Standard Output and Standard Error | |
2603 | .PP | |
2604 | .B Bash | |
2605 | allows both the | |
2606 | standard output (file descriptor 1) and | |
2607 | the standard error output (file descriptor 2) | |
2608 | to be redirected to the file whose name is the | |
2609 | expansion of | |
2610 | .I word | |
2611 | with this construct. | |
2612 | .PP | |
2613 | There are two formats for redirecting standard output and | |
2614 | standard error: | |
2615 | .RS | |
2616 | .PP | |
2617 | \fB&>\fP\fIword\fP | |
2618 | .RE | |
2619 | and | |
2620 | .RS | |
2621 | \fB>&\fP\fIword\fP | |
2622 | .RE | |
2623 | .PP | |
2624 | Of the two forms, the first is preferred. | |
2625 | This is semantically equivalent to | |
2626 | .RS | |
2627 | .PP | |
2628 | \fB>\fP\fIword\fP 2\fB>&\fP1 | |
2629 | .RE | |
2630 | .SS Here Documents | |
2631 | .PP | |
2632 | This type of redirection instructs the shell to read input from the | |
2633 | current source until a line containing only | |
2634 | .I word | |
2635 | (with no trailing blanks) | |
2636 | is seen. All of | |
2637 | the lines read up to that point are then used as the standard | |
2638 | input for a command. | |
2639 | .PP | |
2640 | The format of here-documents is as follows: | |
2641 | .RS | |
2642 | .PP | |
2643 | .nf | |
2644 | \fB<<\fP[\fB\-\fP]\fIword\fP | |
ccc6cda3 | 2645 | \fIhere\-document\fP |
726f6388 JA |
2646 | \fIdelimiter\fP |
2647 | .fi | |
2648 | .RE | |
2649 | .PP | |
2650 | No parameter expansion, command substitution, pathname | |
2651 | expansion, or arithmetic expansion is performed on | |
2652 | .IR word . | |
2653 | If any characters in | |
2654 | .I word | |
2655 | are quoted, the | |
2656 | .I delimiter | |
2657 | is the result of quote removal on | |
2658 | .IR word , | |
cce855bc JA |
2659 | and the lines in the here-document are not expanded. |
2660 | If \fIword\fP is unquoted, | |
726f6388 JA |
2661 | all lines of the here-document are subjected to parameter expansion, |
2662 | command substitution, and arithmetic expansion. In the latter | |
2663 | case, the pair | |
2664 | .B \e<newline> | |
2665 | is ignored, and | |
2666 | .B \e | |
2667 | must be used to quote the characters | |
2668 | .BR \e , | |
2669 | .BR $ , | |
2670 | and | |
2671 | .BR ` . | |
2672 | .PP | |
2673 | If the redirection operator is | |
2674 | .BR <<\- , | |
2675 | then all leading tab characters are stripped from input lines and the | |
2676 | line containing | |
2677 | .IR delimiter . | |
2678 | This allows | |
2679 | here-documents within shell scripts to be indented in a | |
2680 | natural fashion. | |
2681 | .SS "Duplicating File Descriptors" | |
2682 | .PP | |
2683 | The redirection operator | |
2684 | .RS | |
2685 | .PP | |
2686 | [\fIn\fP]\fB<&\fP\fIword\fP | |
2687 | .RE | |
2688 | .PP | |
2689 | is used to duplicate input file descriptors. | |
2690 | If | |
2691 | .I word | |
2692 | expands to one or more digits, the file descriptor denoted by | |
2693 | .I n | |
cce855bc JA |
2694 | is made to be a copy of that file descriptor. |
2695 | If the digits in | |
2696 | .I word | |
2697 | do not specify a file descriptor open for input, a redirection error occurs. | |
2698 | If | |
726f6388 JA |
2699 | .I word |
2700 | evaluates to | |
2701 | .BR \- , | |
2702 | file descriptor | |
2703 | .I n | |
2704 | is closed. If | |
2705 | .I n | |
2706 | is not specified, the standard input (file descriptor 0) is used. | |
2707 | .PP | |
2708 | The operator | |
2709 | .RS | |
2710 | .PP | |
2711 | [\fIn\fP]\fB>&\fP\fIword\fP | |
2712 | .RE | |
2713 | .PP | |
2714 | is used similarly to duplicate output file descriptors. If | |
2715 | .I n | |
2716 | is not specified, the standard output (file descriptor 1) is used. | |
cce855bc JA |
2717 | If the digits in |
2718 | .I word | |
2719 | do not specify a file descriptor open for output, a redirection error occurs. | |
726f6388 JA |
2720 | As a special case, if \fIn\fP is omitted, and \fIword\fP does not |
2721 | expand to one or more digits, the standard output and standard | |
2722 | error are redirected as described previously. | |
2723 | .SS "Opening File Descriptors for Reading and Writing" | |
2724 | .PP | |
2725 | The redirection operator | |
2726 | .RS | |
2727 | .PP | |
2728 | [\fIn\fP]\fB<>\fP\fIword\fP | |
2729 | .RE | |
2730 | .PP | |
2731 | causes the file whose name is the expansion of | |
2732 | .I word | |
2733 | to be opened for both reading and writing on file descriptor | |
2734 | .IR n , | |
ccc6cda3 | 2735 | or on file descriptor 0 if |
726f6388 JA |
2736 | .I n |
2737 | is not specified. If the file does not exist, it is created. | |
726f6388 | 2738 | .SH ALIASES |
cce855bc JA |
2739 | Aliases allow a string to be substituted for a word when it is used |
2740 | as the first word of a simple command. | |
726f6388 JA |
2741 | The shell maintains a list of |
2742 | .I aliases | |
2743 | that may be set and unset with the | |
2744 | .B alias | |
2745 | and | |
2746 | .B unalias | |
2747 | builtin commands (see | |
2748 | .SM | |
2749 | .B SHELL BUILTIN COMMANDS | |
2750 | below). | |
2751 | The first word of each command, if unquoted, | |
2752 | is checked to see if it has an | |
2753 | alias. If so, that word is replaced by the text of the alias. | |
2754 | The alias name and the replacement text may contain any valid | |
2755 | shell input, including the | |
2756 | .I metacharacters | |
2757 | listed above, with the exception that the alias name may not | |
2758 | contain \fI=\fP. The first word of the replacement text is tested | |
2759 | for aliases, but a word that is identical to an alias being expanded | |
2760 | is not expanded a second time. This means that one may alias | |
2761 | .B ls | |
2762 | to | |
2763 | .BR "ls \-F" , | |
2764 | for instance, and | |
2765 | .B bash | |
2766 | does not try to recursively expand the replacement text. | |
2767 | If the last character of the alias value is a | |
2768 | .IR blank , | |
2769 | then the next command | |
2770 | word following the alias is also checked for alias expansion. | |
2771 | .PP | |
2772 | Aliases are created and listed with the | |
2773 | .B alias | |
2774 | command, and removed with the | |
2775 | .B unalias | |
2776 | command. | |
2777 | .PP | |
ccc6cda3 | 2778 | There is no mechanism for using arguments in the replacement text. |
726f6388 JA |
2779 | If arguments are needed, a shell function should be used. |
2780 | .PP | |
ccc6cda3 JA |
2781 | Aliases are not expanded when the shell is not interactive, unless |
2782 | the | |
2783 | .B expand_aliases | |
2784 | shell option is set using | |
2785 | .B shopt | |
2786 | (see the description of | |
2787 | .B shopt | |
2788 | under | |
2789 | .SM | |
2790 | \fBSHELL BUILTIN COMMANDS\fP | |
2791 | below). | |
726f6388 JA |
2792 | .PP |
2793 | The rules concerning the definition and use of aliases are | |
2794 | somewhat confusing. | |
2795 | .B Bash | |
2796 | always reads at least one complete line | |
2797 | of input before executing any | |
2798 | of the commands on that line. Aliases are expanded when a | |
2799 | command is read, not when it is executed. Therefore, an | |
2800 | alias definition appearing on the same line as another | |
2801 | command does not take effect until the next line of input is read. | |
ccc6cda3 | 2802 | The commands following the alias definition |
726f6388 JA |
2803 | on that line are not affected by the new alias. |
2804 | This behavior is also an issue when functions are executed. | |
cce855bc | 2805 | Aliases are expanded when a function definition is read, |
726f6388 JA |
2806 | not when the function is executed, because a function definition |
2807 | is itself a compound command. As a consequence, aliases | |
2808 | defined in a function are not available until after that | |
2809 | function is executed. To be safe, always put | |
2810 | alias definitions on a separate line, and do not use | |
2811 | .B alias | |
2812 | in compound commands. | |
2813 | .PP | |
cce855bc | 2814 | For almost every purpose, aliases are superseded by |
726f6388 | 2815 | shell functions. |
ccc6cda3 JA |
2816 | .SH FUNCTIONS |
2817 | A shell function, defined as described above under | |
2818 | .SM | |
2819 | .BR "SHELL GRAMMAR" , | |
2820 | stores a series of commands for later execution. | |
2821 | Functions are executed in the context of the | |
2822 | current shell; no new process is created to interpret | |
2823 | them (contrast this with the execution of a shell script). | |
2824 | When a function is executed, the arguments to the | |
2825 | function become the positional parameters | |
2826 | during its execution. The special parameter | |
2827 | .B # | |
2828 | is updated to reflect the change. Positional parameter 0 | |
2829 | is unchanged. All other aspects of the shell execution | |
2830 | environment are identical between a function and its caller | |
2831 | with the exception that the | |
2832 | .SM | |
2833 | .B DEBUG | |
2834 | trap (see the description of the | |
2835 | .B trap | |
2836 | builtin under | |
2837 | .SM | |
2838 | .B SHELL BUILTIN COMMANDS | |
2839 | below) is not inherited. | |
726f6388 | 2840 | .PP |
ccc6cda3 JA |
2841 | Variables local to the function may be declared with the |
2842 | .B local | |
2843 | builtin command. Ordinarily, variables and their values | |
2844 | are shared between the function and its caller. | |
726f6388 | 2845 | .PP |
ccc6cda3 JA |
2846 | If the builtin command |
2847 | .B return | |
2848 | is executed in a function, the function completes and | |
2849 | execution resumes with the next command after the function | |
2850 | call. When a function completes, the values of the | |
2851 | positional parameters and the special parameter | |
2852 | .B # | |
cce855bc | 2853 | are restored to the values they had prior to the function's |
ccc6cda3 | 2854 | execution. |
726f6388 | 2855 | .PP |
ccc6cda3 JA |
2856 | Function names and definitions may be listed with the |
2857 | .B \-f | |
726f6388 | 2858 | option to the |
ccc6cda3 JA |
2859 | .B declare |
2860 | or | |
2861 | .B typeset | |
2862 | builtin commands. The | |
2863 | .B \-F | |
2864 | option to | |
2865 | .B declare | |
2866 | or | |
2867 | .B typeset | |
2868 | will list the function names only. | |
2869 | Functions may be exported so that subshells | |
2870 | automatically have them defined with the | |
2871 | .B \-f | |
2872 | option to the | |
2873 | .B export | |
2874 | builtin. | |
726f6388 | 2875 | .PP |
ccc6cda3 JA |
2876 | Functions may be recursive. No limit is imposed on the number |
2877 | of recursive calls. | |
cce855bc JA |
2878 | .SH "ARITHMETIC EVALUATION" |
2879 | The shell allows arithmetic expressions to be evaluated, under | |
2880 | certain circumstances (see the \fBlet\fP builtin command and | |
2881 | \fBArithmetic Expansion\fP). | |
2882 | Evaluation is done in long integers with no check for overflow, | |
2883 | though division by 0 is trapped and flagged as an error. | |
2884 | The following list of operators is grouped into levels of | |
2885 | equal-precedence operators. | |
2886 | The levels are listed in order of decreasing precedence. | |
726f6388 | 2887 | .PP |
cce855bc JA |
2888 | .PD 0 |
2889 | .TP | |
2890 | .B \- + | |
2891 | unary minus and plus | |
2892 | .TP | |
2893 | .B ! ~ | |
2894 | logical and bitwise negation | |
2895 | .TP | |
2896 | .B ** | |
2897 | exponentiation | |
2898 | .TP | |
2899 | .B * / % | |
2900 | multiplication, division, remainder | |
2901 | .TP | |
2902 | .B + \- | |
2903 | addition, subtraction | |
2904 | .TP | |
2905 | .B << >> | |
2906 | left and right bitwise shifts | |
2907 | .TP | |
2908 | .B <= >= < > | |
2909 | comparison | |
2910 | .TP | |
2911 | .B == != | |
2912 | equality and inequality | |
2913 | .TP | |
2914 | .B & | |
2915 | bitwise AND | |
2916 | .TP | |
2917 | .B ^ | |
2918 | bitwise exclusive OR | |
2919 | .TP | |
2920 | .B | | |
2921 | bitwise OR | |
2922 | .TP | |
2923 | .B && | |
2924 | logical AND | |
2925 | .TP | |
2926 | .B || | |
2927 | logical OR | |
2928 | .TP | |
2929 | .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP | |
2930 | conditional evaluation | |
2931 | .TP | |
2932 | .B = *= /= %= += \-= <<= >>= &= ^= |= | |
2933 | assignment | |
2934 | .PD | |
ccc6cda3 | 2935 | .PP |
cce855bc JA |
2936 | Shell variables are allowed as operands; parameter expansion is |
2937 | performed before the expression is evaluated. | |
2938 | The value of a parameter is coerced to a long integer within | |
2939 | an expression. A shell variable need not have its integer attribute | |
2940 | turned on to be used in an expression. | |
ccc6cda3 | 2941 | .PP |
cce855bc JA |
2942 | Constants with a leading 0 are interpreted as octal numbers. |
2943 | A leading 0x or 0X denotes hexadecimal. | |
2944 | Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP | |
2945 | is a decimal number between 2 and 64 representing the arithmetic | |
2946 | base, and \fIn\fP is a number in that base. | |
2947 | If \fIbase\fP is omitted, then base 10 is used. | |
2948 | The digits greater than 9 are represented by the lowercase letters, | |
2949 | the uppercase letters, _, and @, in that order. | |
2950 | If \fIbase\fP is less than or equal to 36, lowercase and uppercase | |
2951 | letters may be used interchangably to represent numbers between 10 | |
2952 | and 35. | |
ccc6cda3 | 2953 | .PP |
cce855bc JA |
2954 | Operators are evaluated in order of precedence. Sub-expressions in |
2955 | parentheses are evaluated first and may override the precedence | |
2956 | rules above. | |
2957 | .SH "CONDITIONAL EXPRESSIONS" | |
2958 | Conditional expressions are used by the \fB[[\fP compound command and | |
2959 | the \fBtest\fP and \fB[\fP builtin commands to test file attributes | |
2960 | and perform string and arithmetic comparisons. | |
2961 | Expressions are formed from the following unary or binary primaries. | |
2962 | If any \fIfile\fP argument to one of the primaries is of the form | |
2963 | /dev/fd/\fIn\fP, then file descriptor \fIn\fP is checked. | |
2964 | .sp 1 | |
2965 | .PD 0 | |
2966 | .TP | |
2967 | .B \-a \fIfile\fP | |
2968 | True if \fIfile\fP exists. | |
2969 | .TP | |
2970 | .B \-b \fIfile\fP | |
2971 | True if \fIfile\fP exists and is a block special file. | |
2972 | .TP | |
2973 | .B \-c \fIfile\fP | |
2974 | True if \fIfile\fP exists and is a character special file. | |
2975 | .TP | |
2976 | .B \-d \fIfile\fP | |
2977 | True if \fIfile\fP exists and is a directory. | |
2978 | .TP | |
2979 | .B \-e \fIfile\fP | |
2980 | True if \fIfile\fP exists. | |
2981 | .TP | |
2982 | .B \-f \fIfile\fP | |
2983 | True if \fIfile\fP exists and is a regular file. | |
2984 | .TP | |
2985 | .B \-g \fIfile\fP | |
2986 | True if \fIfile\fP exists and is set-group-id. | |
2987 | .TP | |
2988 | .B \-k \fIfile\fP | |
2989 | True if \fIfile\fP exists and its ``sticky'' bit is set. | |
2990 | .TP | |
2991 | .B \-p \fIfile\fP | |
2992 | True if \fIfile\fP exists and is a named pipe (FIFO). | |
2993 | .TP | |
2994 | .B \-r \fIfile\fP | |
2995 | True if \fIfile\fP exists and is readable. | |
2996 | .TP | |
2997 | .B \-s \fIfile\fP | |
2998 | True if \fIfile\fP exists and has a size greater than zero. | |
2999 | .TP | |
3000 | .B \-t \fIfd\fP | |
3001 | True if file descriptor | |
3002 | .I fd | |
3003 | is open and refers to a terminal. | |
3004 | .TP | |
3005 | .B \-u \fIfile\fP | |
3006 | True if \fIfile\fP exists and its set-user-id bit is set. | |
3007 | .TP | |
3008 | .B \-w \fIfile\fP | |
3009 | True if \fIfile\fP exists and is writable. | |
3010 | .TP | |
3011 | .B \-x \fIfile\fP | |
3012 | True if \fIfile\fP exists and is executable. | |
3013 | .TP | |
3014 | .B \-O \fIfile\fP | |
3015 | True if \fIfile\fP exists and is owned by the effective user id. | |
3016 | .TP | |
3017 | .B \-G \fIfile\fP | |
3018 | True if \fIfile\fP exists and is owned by the effective group id. | |
3019 | .TP | |
3020 | .B \-L \fIfile\fP | |
3021 | True if \fIfile\fP exists and is a symbolic link. | |
3022 | .TP | |
3023 | .B \-S \fIfile\fP | |
3024 | True if \fIfile\fP exists and is a socket. | |
3025 | .TP | |
3026 | .B \-N \fIfile\fP | |
3027 | True if \fIfile\fP exists and has been modified since it was last read. | |
3028 | .TP | |
3029 | \fIfile1\fP \-\fBnt\fP \fIfile2\fP | |
3030 | True if \fIfile1\fP is newer (according to | |
3031 | modification date) than \fIfile2\fP. | |
3032 | .TP | |
3033 | \fIfile1\fP \-\fBot\fP \fIfile2\fP | |
3034 | True if \fIfile1\fP is older than \fIfile2\fP. | |
3035 | .TP | |
3036 | \fIfile1\fP \fB\-ef\fP \fIfile2\fP | |
3037 | True if \fIfile1\fP and \fIfile2\fP have the same device and | |
3038 | inode numbers. | |
3039 | .TP | |
3040 | .B \-o \fIoptname\fP | |
3041 | True if shell option | |
3042 | .I optname | |
3043 | is enabled. | |
3044 | See the list of options under the description of the | |
3045 | .B \-o | |
3046 | option to the | |
3047 | .B set | |
3048 | builtin below. | |
3049 | .TP | |
3050 | .B \-z \fIstring\fP | |
3051 | True if the length of \fIstring\fP is zero. | |
3052 | .TP | |
3053 | .B \-n \fIstring\fP | |
3054 | .TP | |
3055 | \fIstring\fP | |
3056 | True if the length of | |
3057 | .I string | |
3058 | is non-zero. | |
3059 | .TP | |
3060 | \fIstring1\fP \fB==\fP \fIstring2\fP | |
3061 | True if the strings are equal. \fB=\fP may be used in place of | |
3062 | \fB==\fP. | |
3063 | .TP | |
3064 | \fIstring1\fP \fB!=\fP \fIstring2\fP | |
3065 | True if the strings are not equal. | |
3066 | .TP | |
3067 | \fIstring1\fP \fB<\fP \fIstring2\fP | |
3068 | True if \fIstring1\fP sorts before \fIstring2\fP lexicographically | |
3069 | in the current locale. | |
3070 | .TP | |
3071 | \fIstring1\fP \fB>\fP \fIstring2\fP | |
3072 | True if \fIstring1\fP sorts after \fIstring2\fP lexicographically | |
3073 | in the current locale. | |
3074 | .TP | |
3075 | .I \fIarg1\fP \fBOP\fP \fIarg2\fP | |
3076 | .SM | |
3077 | .B OP | |
3078 | is one of | |
3079 | .BR \-eq , | |
3080 | .BR \-ne , | |
3081 | .BR \-lt , | |
3082 | .BR \-le , | |
3083 | .BR \-gt , | |
3084 | or | |
3085 | .BR \-ge . | |
3086 | These arithmetic binary operators return true if \fIarg1\fP | |
3087 | is equal to, not equal to, less than, less than or equal to, | |
3088 | greater than, or greater than or equal to \fIarg2\fP, respectively. | |
3089 | .I Arg1 | |
3090 | and | |
3091 | .I arg2 | |
3092 | may be positive or negative integers. | |
3093 | .PD | |
3094 | .SH "SIMPLE COMMAND EXPANSION" | |
3095 | When a simple command is executed, the shell performs the following | |
3096 | expansions, assignments, and redirections, from left to right. | |
3097 | .IP 1. | |
3098 | The words that the parser has marked as variable assignments (those | |
3099 | preceding the command name) and redirections are saved for later | |
3100 | processing. | |
3101 | .IP 2. | |
3102 | The words that are not variable assignments or redirections are | |
3103 | expanded. If any words remain after expansion, the first word | |
3104 | is taken to be the name of the command and the remaining words are | |
3105 | the arguments. | |
3106 | .IP 3. | |
3107 | Redirections are performed as described above under | |
3108 | .SM | |
3109 | .BR REDIRECTION . | |
3110 | .IP 4. | |
3111 | The text after the \fB=\fP in each variable assignment undergoes tilde | |
3112 | expansion, parameter expansion, command substitution, arithmetic expansion, | |
3113 | and quote removal before being assigned to the variable. | |
3114 | .PP | |
3115 | If no command name results, the variable assignments affect the current | |
3116 | shell environment. Otherwise, the variables are added to the environment | |
3117 | of the executed command and do not affect the current shell environment. | |
3118 | If any of the assignments attempts to assign a value to a readonly variable, | |
3119 | an error occurs, and the command exits with a non-zero status. | |
3120 | .PP | |
3121 | If no command name results, redirections are performed, but do not | |
3122 | affect the current shell environment. A redirection error causes the | |
3123 | command to exit with a non-zero status. | |
3124 | .PP | |
3125 | If there is a command name left after expansion, execution proceeds as | |
3126 | described below. Otherwise, the command exits. If one of the expansions | |
3127 | contained a command substitution, the exit status of the command is | |
3128 | the exit status of the last command substitution performed. If there | |
3129 | were no command substitutions, the command exits with a status of zero. | |
3130 | .SH "COMMAND EXECUTION" | |
3131 | After a command has been split into words, if it results in a | |
3132 | simple command and an optional list of arguments, the following | |
3133 | actions are taken. | |
3134 | .PP | |
3135 | If the command name contains no slashes, the shell attempts to | |
3136 | locate it. If there exists a shell function by that name, that | |
3137 | function is invoked as described above in | |
3138 | .SM | |
3139 | .BR FUNCTIONS . | |
3140 | If the name does not match a function, the shell searches for | |
3141 | it in the list of shell builtins. If a match is found, that | |
3142 | builtin is invoked. | |
3143 | .PP | |
3144 | If the name is neither a shell function nor a builtin, | |
3145 | and contains no slashes, | |
3146 | .B bash | |
3147 | searches each element of the | |
3148 | .SM | |
3149 | .B PATH | |
3150 | for a directory containing an executable file by that name. | |
3151 | .B Bash | |
3152 | uses a hash table to remember the full file names of executable | |
3153 | files (see | |
3154 | .B hash | |
3155 | under | |
3156 | .SM | |
3157 | .B "SHELL BUILTIN COMMANDS" | |
3158 | below). | |
3159 | A full search of the directories in | |
3160 | .SM | |
3161 | .B PATH | |
3162 | is performed only if the command is not found in the hash table. | |
3163 | If the search is unsuccessful, the shell prints an error | |
3164 | message and returns an exit status of 127. | |
3165 | .PP | |
3166 | If the search is successful, or if the command name contains | |
3167 | one or more slashes, the shell executes the named program in a | |
3168 | separate execution environment. | |
3169 | Argument 0 is set to the name given, and the remaining arguments | |
3170 | to the command are set to the arguments given, if any. | |
3171 | .PP | |
3172 | If this execution fails because the file is not in executable | |
3173 | format, and the file is not a directory, it is assumed to be | |
3174 | a \fIshell script\fP, a file | |
3175 | containing shell commands. A subshell is spawned to execute | |
3176 | it. This subshell reinitializes itself, so | |
3177 | that the effect is as if a new shell had been invoked | |
3178 | to handle the script, with the exception that the locations of | |
3179 | commands remembered by the parent (see | |
3180 | .B hash | |
3181 | below under | |
3182 | .SM | |
3183 | \fBSHELL BUILTIN COMMANDS\fP) | |
3184 | are retained by the child. | |
3185 | .PP | |
3186 | If the program is a file beginning with | |
3187 | .BR #! , | |
3188 | the remainder of the first line specifies an interpreter | |
3189 | for the program. The shell executes the | |
3190 | specified interpreter on operating systems that do not | |
3191 | handle this executable format themselves. The arguments to the | |
3192 | interpreter consist of a single optional argument following the | |
3193 | interpreter name on the first line of the program, followed | |
3194 | by the name of the program, followed by the command | |
3195 | arguments, if any. | |
3196 | .SH COMMAND EXECUTION ENVIRONMENT | |
3197 | The shell has an \fIexecution environment\fP, which consists of the | |
3198 | following: | |
3199 | .sp 1 | |
3200 | .IP \(bu | |
3201 | open files inherited by the shell at invocation, as modified by | |
3202 | redirections supplied to the \fBexec\fP builtin | |
3203 | .IP \(bu | |
3204 | the current working directory as set by \fBcd\fP, \fBpushd\fP, or | |
3205 | \fBpopd\fP, or inherited by the shell at invocation | |
3206 | .IP \(bu | |
3207 | the file creation mode mask as set by \fBumask\fP or inherited from | |
3208 | the shell's parent | |
3209 | .IP \(bu | |
3210 | current traps set by \fBtrap\fP | |
3211 | .IP \(bu | |
3212 | shell parameters that are set by variable assignment or with \fBset\fP | |
3213 | or inherited from the shell's parent in the environment | |
3214 | .IP \(bu | |
3215 | shell functions defined during execution or inherited from the shell's | |
3216 | parent in the environment | |
3217 | .IP \(bu | |
3218 | options enabled at invocation (either by default or with command-line | |
3219 | arguments) or by \fBset\fP | |
3220 | .IP \(bu | |
3221 | options enabled by \fBshopt\fP | |
3222 | .IP \(bu | |
3223 | shell aliases defined with \fBalias\fP | |
3224 | .IP \(bu | |
3225 | various process IDs, including those of background jobs, the value | |
3226 | of \fB$$\fP, and the value of \fB$PPID\fP | |
3227 | .PP | |
3228 | When a simple command other than a builtin or shell function | |
3229 | is to be executed, it | |
3230 | is invoked in a separate execution environment that consists of | |
3231 | the following. Unless otherwise noted, the values are inherited | |
3232 | from the shell. | |
3233 | .sp 1 | |
3234 | .IP \(bu | |
3235 | the shell's open files, plus any modifications and additions specified | |
3236 | by redirections to the command | |
3237 | .IP \(bu | |
3238 | the current working directory | |
3239 | .IP \(bu | |
3240 | the file creation mode mask | |
3241 | .IP \(bu | |
3242 | shell variables marked for export, along with variables exported for | |
3243 | the command, passed in the environment | |
3244 | .IP \(bu | |
3245 | traps caught by the shell are reset to the values the inherited | |
3246 | from the shell's parent, and traps ignored by the shell are ignored | |
3247 | .PP | |
3248 | A command invoked in this separate environment cannot affect the | |
3249 | shell's execution environment. | |
3250 | .PP | |
3251 | Command substitution and asynchronous commands are invoked in a | |
3252 | subshell environment that is a duplicate of the shell environment, | |
3253 | except that traps caught by the shell are reset to the values | |
3254 | that the shell inherited from its parent at invocation. Builtin | |
3255 | commands that are invoked as part of a pipeline are also executed in a | |
3256 | subshell environment. Changes made to the subshell environment | |
3257 | cannot affect the shell's execution environment. | |
3258 | .SH ENVIRONMENT | |
3259 | When a program is invoked it is given an array of strings | |
3260 | called the | |
3261 | .IR environment . | |
3262 | This is a list of | |
3263 | \fIname\fP\-\fIvalue\fP pairs, of the form | |
3264 | .IR "name\fR=\fPvalue" . | |
3265 | .PP | |
3266 | The shell allows you to manipulate the environment in several | |
3267 | ways. On invocation, the shell scans its own environment and | |
3268 | creates a parameter for each name found, automatically marking | |
3269 | it for | |
3270 | .I export | |
3271 | to child processes. Executed commands inherit the environment. | |
3272 | The | |
3273 | .B export | |
3274 | and | |
3275 | .B declare \-x | |
3276 | commands allow parameters and functions to be added to and | |
3277 | deleted from the environment. If the value of a parameter | |
3278 | in the environment is modified, the new value becomes part | |
3279 | of the environment, replacing the old. The environment | |
3280 | inherited by any executed command consists of the shell's | |
3281 | initial environment, whose values may be modified in the shell, | |
3282 | less any pairs removed by the | |
3283 | .B unset | |
3284 | command, plus any additions via the | |
3285 | .B export | |
3286 | and | |
3287 | .B declare \-x | |
3288 | commands. | |
3289 | .PP | |
3290 | The environment for any | |
3291 | .I simple command | |
3292 | or function may be augmented temporarily by prefixing it with | |
3293 | parameter assignments, as described above in | |
3294 | .SM | |
3295 | .BR PARAMETERS . | |
3296 | These assignment statements affect only the environment seen | |
3297 | by that command. | |
3298 | .PP | |
3299 | If the | |
3300 | .B \-k | |
3301 | option is set (see the | |
3302 | .B set | |
3303 | builtin command below), then | |
3304 | .I all | |
3305 | parameter assignments are placed in the environment for a command, | |
3306 | not just those that precede the command name. | |
3307 | .PP | |
3308 | When | |
3309 | .B bash | |
3310 | invokes an external command, the variable | |
3311 | .B _ | |
3312 | is set to the full file name of the command and passed to that | |
ccc6cda3 JA |
3313 | command in its environment. |
3314 | .SH "EXIT STATUS" | |
cce855bc | 3315 | For the shell's purposes, a command which exits with a |
ccc6cda3 JA |
3316 | zero exit status has succeeded. An exit status of zero |
3317 | indicates success. A non-zero exit status indicates failure. | |
3318 | When a command terminates on a fatal signal, \fBbash\fP uses | |
3319 | the value of 128+\fBsignal\fP as the exit status. | |
3320 | .PP | |
3321 | If a command is not found, the child process created to | |
3322 | execute it returns a status of 127. If a command is found | |
3323 | but is not executable, the return status is 126. | |
3324 | .PP | |
cce855bc JA |
3325 | If a command fails because of an error during expansion or redirection, |
3326 | the exit status is greater than zero. | |
3327 | .PP | |
ccc6cda3 JA |
3328 | Shell builtin commands return a status of 0 (\fItrue\fP) if |
3329 | successful, and non-zero (\fIfalse\fP) if an error occurs | |
3330 | while they execute. | |
3331 | All builtins return an exit status of 2 to indicate incorrect usage. | |
3332 | .PP | |
3333 | \fBBash\fP itself returns the exit status of the last command | |
3334 | executed, unless a syntax error occurs, in which case it exits | |
3335 | with a non-zero value. See also the \fBexit\fP builtin | |
3336 | command below. | |
3337 | .SH SIGNALS | |
cce855bc | 3338 | When \fBbash\fP is interactive, in the absence of any traps, it ignores |
ccc6cda3 JA |
3339 | .SM |
3340 | .B SIGTERM | |
3341 | (so that \fBkill 0\fP does not kill an interactive shell), | |
3342 | and | |
3343 | .SM | |
3344 | .B SIGINT | |
3345 | is caught and handled (so that the \fBwait\fP builtin is interruptible). | |
3346 | In all cases, \fBbash\fP ignores | |
3347 | .SM | |
3348 | .BR SIGQUIT . | |
3349 | If job control is in effect, | |
3350 | .B bash | |
3351 | ignores | |
3352 | .SM | |
3353 | .BR SIGTTIN , | |
3354 | .SM | |
3355 | .BR SIGTTOU , | |
3356 | and | |
3357 | .SM | |
3358 | .BR SIGTSTP . | |
3359 | .PP | |
cce855bc JA |
3360 | Synchronous jobs started by \fBbash\fP have signal handlers |
3361 | set to the values inherited by the shell from its parent. | |
3362 | When job control is not in effect, asynchronous commands | |
ccc6cda3 JA |
3363 | ignore |
3364 | .SM | |
3365 | .B SIGINT | |
3366 | and | |
3367 | .SM | |
cce855bc JA |
3368 | .B SIGQUIT |
3369 | as well. | |
ccc6cda3 JA |
3370 | Commands run as a result of command substitution ignore the |
3371 | keyboard-generated job control signals | |
3372 | .SM | |
3373 | .BR SIGTTIN , | |
3374 | .SM | |
3375 | .BR SIGTTOU , | |
3376 | and | |
3377 | .SM | |
3378 | .BR SIGTSTP . | |
3379 | .PP | |
3380 | The shell exits by default upon receipt of a | |
3381 | .SM | |
3382 | .BR SIGHUP . | |
3383 | Before exiting, it resends the | |
3384 | .SM | |
3385 | .B SIGHUP | |
cce855bc JA |
3386 | to all jobs, running or stopped. |
3387 | Stopped jobs are sent | |
3388 | .SM | |
3389 | .B SIGCONT | |
3390 | to ensure that they receive the | |
3391 | .SM | |
3392 | .BR SIGHUP . | |
3393 | To prevent the shell from | |
3394 | sending the signal to a particular job, it should be removed from the | |
ccc6cda3 JA |
3395 | jobs table with the |
3396 | .B disown | |
3397 | builtin (see | |
3398 | .SM | |
3399 | .B "SHELL BUILTIN COMMANDS" | |
cce855bc JA |
3400 | below) or marked |
3401 | to not receive | |
ccc6cda3 | 3402 | .SM |
cce855bc JA |
3403 | .B SIGHUP |
3404 | using | |
3405 | .BR "disown \-h" . | |
3406 | .PP | |
3407 | If the | |
3408 | .B huponexit | |
3409 | shell option has been set with | |
3410 | .BR shopt , | |
3411 | .B bash | |
3412 | sends a | |
3413 | .SM | |
3414 | .B SIGHUP | |
3415 | to all jobs when an interactive login shell exits. | |
3416 | .PP | |
3417 | When \fBbash\fP receives a signal for which a trap has been set while | |
3418 | waiting for a command to complete, the trap will not be executed until | |
3419 | the command completes. | |
3420 | When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP | |
3421 | builtin, the reception of a signal for which a trap has been set will | |
3422 | cause the \fBwait\fP builtin to return immediately with an exit status | |
3423 | greater than 128, immediately after which the trap is executed. | |
ccc6cda3 JA |
3424 | .SH "JOB CONTROL" |
3425 | .I Job control | |
3426 | refers to the ability to selectively stop (\fIsuspend\fP) | |
3427 | the execution of processes and continue (\fIresume\fP) | |
3428 | their execution at a later point. A user typically employs | |
3429 | this facility via an interactive interface supplied jointly | |
3430 | by the system's terminal driver and | |
3431 | .BR bash . | |
3432 | .PP | |
3433 | The shell associates a | |
3434 | .I job | |
3435 | with each pipeline. It keeps a table of currently executing | |
3436 | jobs, which may be listed with the | |
3437 | .B jobs | |
3438 | command. When | |
3439 | .B bash | |
3440 | starts a job asynchronously (in the | |
3441 | .IR background ), | |
3442 | it prints a line that looks like: | |
3443 | .RS | |
3444 | .PP | |
3445 | [1] 25647 | |
3446 | .RE | |
3447 | .PP | |
3448 | indicating that this job is job number 1 and that the process ID | |
3449 | of the last process in the pipeline associated with this job is 25647. | |
3450 | All of the processes in a single pipeline are members of the same job. | |
3451 | .B Bash | |
3452 | uses the | |
3453 | .I job | |
3454 | abstraction as the basis for job control. | |
3455 | .PP | |
3456 | To facilitate the implementation of the user interface to job | |
3457 | control, the system maintains the notion of a \fIcurrent terminal | |
3458 | process group ID\fP. Members of this process group (processes whose | |
3459 | process group ID is equal to the current terminal process group ID) | |
3460 | receive keyboard-generated signals such as | |
3461 | .SM | |
3462 | .BR SIGINT . | |
3463 | These processes are said to be in the | |
3464 | .IR foreground . | |
3465 | .I Background | |
3466 | processes are those whose process group ID differs from the terminal's; | |
3467 | such processes are immune to keyboard-generated signals. | |
3468 | Only foreground processes are allowed to read from or write to the | |
3469 | terminal. Background processes which attempt to read from (write to) the | |
3470 | terminal are sent a | |
3471 | .SM | |
3472 | .B SIGTTIN (SIGTTOU) | |
3473 | signal by the terminal driver, | |
3474 | which, unless caught, suspends the process. | |
3475 | .PP | |
3476 | If the operating system on which | |
3477 | .B bash | |
3478 | is running supports | |
3479 | job control, | |
3480 | .B bash | |
3481 | allows you to use it. | |
3482 | Typing the | |
3483 | .I suspend | |
3484 | character (typically | |
3485 | .BR ^Z , | |
3486 | Control-Z) while a process is running | |
3487 | causes that process to be stopped and returns you to | |
3488 | .BR bash . | |
3489 | Typing the | |
3490 | .I "delayed suspend" | |
3491 | character (typically | |
3492 | .BR ^Y , | |
3493 | Control-Y) causes the process to be stopped when it | |
3494 | attempts to read input from the terminal, and control to | |
3495 | be returned to | |
3496 | .BR bash . | |
cce855bc | 3497 | The user may then manipulate the state of this job, using the |
ccc6cda3 JA |
3498 | .B bg |
3499 | command to continue it in the background, the | |
3500 | .B fg | |
3501 | command to continue it in the foreground, or | |
3502 | the | |
3503 | .B kill | |
3504 | command to kill it. A \fB^Z\fP takes effect immediately, | |
3505 | and has the additional side effect of causing pending output | |
3506 | and typeahead to be discarded. | |
3507 | .PP | |
3508 | There are a number of ways to refer to a job in the shell. | |
3509 | The character | |
3510 | .B % | |
3511 | introduces a job name. Job number | |
3512 | .I n | |
3513 | may be referred to as | |
3514 | .BR %n . | |
3515 | A job may also be referred to using a prefix of the name used to | |
3516 | start it, or using a substring that appears in its command line. | |
3517 | For example, | |
3518 | .B %ce | |
3519 | refers to a stopped | |
3520 | .B ce | |
3521 | job. If a prefix matches more than one job, | |
3522 | .B bash | |
3523 | reports an error. Using | |
3524 | .BR %?ce , | |
3525 | on the other hand, refers to any job containing the string | |
3526 | .B ce | |
3527 | in its command line. If the substring matches more than one job, | |
3528 | .B bash | |
3529 | reports an error. The symbols | |
3530 | .B %% | |
3531 | and | |
3532 | .B %+ | |
3533 | refer to the shell's notion of the | |
3534 | .IR "current job" , | |
3535 | which is the last job stopped while it was in | |
cce855bc | 3536 | the foreground or started in the background. |
ccc6cda3 JA |
3537 | The |
3538 | .I "previous job" | |
3539 | may be referenced using | |
3540 | .BR %\- . | |
3541 | In output pertaining to jobs (e.g., the output of the | |
3542 | .B jobs | |
3543 | command), the current job is always flagged with a | |
3544 | .BR + , | |
3545 | and the previous job with a | |
3546 | .BR \- . | |
726f6388 | 3547 | .PP |
ccc6cda3 JA |
3548 | Simply naming a job can be used to bring it into the |
3549 | foreground: | |
3550 | .B %1 | |
3551 | is a synonym for | |
3552 | \fB``fg %1''\fP, | |
3553 | bringing job 1 from the background into the foreground. | |
3554 | Similarly, | |
3555 | .B ``%1 &'' | |
3556 | resumes job 1 in the background, equivalent to | |
3557 | \fB``bg %1''\fP. | |
726f6388 | 3558 | .PP |
ccc6cda3 JA |
3559 | The shell learns immediately whenever a job changes state. |
3560 | Normally, | |
3561 | .B bash | |
3562 | waits until it is about to print a prompt before reporting | |
3563 | changes in a job's status so as to not interrupt | |
3564 | any other output. If the | |
3565 | .B \-b | |
3566 | option to the | |
726f6388 | 3567 | .B set |
ccc6cda3 | 3568 | builtin command |
cce855bc | 3569 | is enabled, |
726f6388 | 3570 | .B bash |
ccc6cda3 | 3571 | reports such changes immediately. |
726f6388 | 3572 | .PP |
ccc6cda3 JA |
3573 | If an attempt to exit |
3574 | .B bash | |
3575 | is made while jobs are stopped, the shell prints a warning message. The | |
3576 | .B jobs | |
3577 | command may then be used to inspect their status. | |
3578 | If a second attempt to exit is made without an intervening command, | |
3579 | the shell does not print another warning, and the stopped | |
3580 | jobs are terminated. | |
726f6388 JA |
3581 | .SH PROMPTING |
3582 | When executing interactively, | |
3583 | .B bash | |
3584 | displays the primary prompt | |
3585 | .SM | |
3586 | .B PS1 | |
3587 | when it is ready to read a command, and the secondary prompt | |
3588 | .SM | |
3589 | .B PS2 | |
3590 | when it needs more input to complete a command. | |
3591 | .B Bash | |
3592 | allows these prompt strings to be customized by inserting a number of | |
3593 | backslash-escaped special characters that are decoded as follows: | |
3594 | .RS | |
3595 | .PD 0 | |
3596 | .TP | |
ccc6cda3 JA |
3597 | .B \ea |
3598 | an ASCII bell character (07) | |
726f6388 JA |
3599 | .TP |
3600 | .B \ed | |
3601 | the date in "Weekday Month Date" format (e.g., "Tue May 26") | |
3602 | .TP | |
ccc6cda3 JA |
3603 | .B \ee |
3604 | an ASCII escape character (033) | |
3605 | .TP | |
3606 | .B \eh | |
3607 | the hostname up to the first `.' | |
3608 | .TP | |
3609 | .B \eH | |
3610 | the hostname | |
3611 | .TP | |
726f6388 JA |
3612 | .B \en |
3613 | newline | |
3614 | .TP | |
cce855bc JA |
3615 | .B \er |
3616 | carriage return | |
3617 | .TP | |
726f6388 JA |
3618 | .B \es |
3619 | the name of the shell, the basename of | |
3620 | .B $0 | |
3621 | (the portion following the final slash) | |
3622 | .TP | |
ccc6cda3 JA |
3623 | .B \et |
3624 | the current time in 24-hour HH:MM:SS format | |
726f6388 | 3625 | .TP |
ccc6cda3 JA |
3626 | .B \eT |
3627 | the current time in 12-hour HH:MM:SS format | |
3628 | .TP | |
3629 | .B \e@ | |
3630 | the current time in 12-hour am/pm format | |
726f6388 JA |
3631 | .TP |
3632 | .B \eu | |
3633 | the username of the current user | |
3634 | .TP | |
ccc6cda3 JA |
3635 | .B \ev |
3636 | the version of \fBbash\fP (e.g., 2.00) | |
726f6388 | 3637 | .TP |
ccc6cda3 JA |
3638 | .B \eV |
3639 | the release of \fBbash\fP, version + patchlevel (e.g., 2.00.0) | |
3640 | .TP | |
3641 | .B \ew | |
3642 | the current working directory | |
3643 | .TP | |
3644 | .B \eW | |
3645 | the basename of the current working directory | |
726f6388 JA |
3646 | .TP |
3647 | .B \e! | |
3648 | the history number of this command | |
3649 | .TP | |
ccc6cda3 JA |
3650 | .B \e# |
3651 | the command number of this command | |
3652 | .TP | |
726f6388 JA |
3653 | .B \e$ |
3654 | if the effective UID is 0, a | |
3655 | .BR # , | |
3656 | otherwise a | |
3657 | .B $ | |
3658 | .TP | |
ccc6cda3 JA |
3659 | .B \e\fInnn\fP |
3660 | the character corresponding to the octal number \fInnn\fP | |
726f6388 JA |
3661 | .TP |
3662 | .B \e\e | |
3663 | a backslash | |
3664 | .TP | |
3665 | .B \e[ | |
3666 | begin a sequence of non-printing characters, which could be used to | |
3667 | embed a terminal control sequence into the prompt | |
3668 | .TP | |
3669 | .B \e] | |
3670 | end a sequence of non-printing characters | |
3671 | .PD | |
3672 | .RE | |
3673 | .PP | |
3674 | The command number and the history number are usually different: | |
3675 | the history number of a command is its position in the history | |
3676 | list, which may include commands restored from the history file | |
3677 | (see | |
3678 | .SM | |
3679 | .B HISTORY | |
3680 | below), while the command number is the position in the sequence | |
3681 | of commands executed during the current shell session. | |
3682 | After the string is decoded, it is expanded via | |
ccc6cda3 JA |
3683 | parameter expansion, command substitution, arithmetic expansion, |
3684 | string expansion, and quote removal, subject to the value of the | |
3685 | .B promptvars | |
3686 | shell option (see the description of the | |
3687 | .B shopt | |
3688 | command under | |
3689 | .SM | |
3690 | .B "SHELL BUILTIN COMMANDS" | |
3691 | below). | |
726f6388 JA |
3692 | .SH READLINE |
3693 | This is the library that handles reading input when using an interactive | |
3694 | shell, unless the | |
d166f048 | 3695 | .B \-\-noediting |
ccc6cda3 JA |
3696 | option is given at shell invocation. |
3697 | By default, the line editing commands are similar to those of emacs. | |
726f6388 | 3698 | A vi-style line editing interface is also available. |
ccc6cda3 JA |
3699 | To turn off line editing after the shell is running, use the |
3700 | .B +o emacs | |
3701 | or | |
3702 | .B +o vi | |
3703 | options to the | |
3704 | .B set | |
3705 | builtin (see | |
3706 | .SM | |
3707 | .B SHELL BUILTIN COMMANDS | |
3708 | below). | |
3709 | .SS "Readline Notation" | |
726f6388 JA |
3710 | .PP |
3711 | In this section, the emacs-style notation is used to denote | |
3712 | keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n | |
3713 | means Control\-N. Similarly, | |
3714 | .I meta | |
3715 | keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards | |
3716 | without a | |
3717 | .I meta | |
3718 | key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key | |
3719 | then the | |
3720 | .I x | |
3721 | key. This makes ESC the \fImeta prefix\fP. | |
3722 | The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP, | |
3723 | or press the Escape key | |
3724 | then hold the Control key while pressing the | |
3725 | .I x | |
3726 | key.) | |
3727 | .PP | |
ccc6cda3 JA |
3728 | Readline commands may be given numeric |
3729 | .IR arguments , | |
3730 | which normally act as a repeat count. | |
3731 | Sometimes, however, it is the sign of the argument that is significant. | |
3732 | Passing a negative argument to a command that acts in the forward | |
3733 | direction (e.g., \fBkill\-line\fP) causes that command to act in a | |
3734 | backward direction. | |
3735 | Commands whose behavior with arguments deviates from this are noted | |
3736 | below. | |
3737 | .PP | |
3738 | When a command is described as \fIkilling\fP text, the text | |
3739 | deleted is saved for possible future retrieval | |
3740 | (\fIyanking\fP). The killed text is saved in a | |
3741 | \fIkill ring\fP. Consecutive kills cause the text to be | |
3742 | accumulated into one unit, which can be yanked all at once. | |
3743 | Commands which do not kill text separate the chunks of text | |
3744 | on the kill ring. | |
3745 | .SS "Readline Initialization" | |
3746 | .PP | |
3747 | Readline is customized by putting commands in an initialization | |
3748 | file (the \fIinputrc\fP file). | |
3749 | The name of this file is taken from the value of the | |
726f6388 | 3750 | .SM |
ccc6cda3 JA |
3751 | .B INPUTRC |
3752 | variable. If that variable is unset, the default is | |
726f6388 | 3753 | .IR ~/.inputrc . |
ccc6cda3 JA |
3754 | When a program which uses the readline library starts up, the |
3755 | initialization file is read, and the key bindings and variables | |
3756 | are set. | |
3757 | There are only a few basic constructs allowed in the | |
3758 | readline initialization file. | |
3759 | Blank lines are ignored. | |
3760 | Lines beginning with a \fB#\fP are comments. | |
3761 | Lines beginning with a \fB$\fP indicate conditional constructs. | |
3762 | Other lines denote key bindings and variable settings. | |
3763 | .PP | |
3764 | The default key-bindings may be changed with an | |
3765 | .I inputrc | |
3766 | file. | |
726f6388 JA |
3767 | Other programs that use this library may add their own commands |
3768 | and bindings. | |
3769 | .PP | |
3770 | For example, placing | |
3771 | .RS | |
3772 | .PP | |
3773 | M\-Control\-u: universal\-argument | |
3774 | .RE | |
3775 | or | |
3776 | .RS | |
3777 | C\-Meta\-u: universal\-argument | |
3778 | .RE | |
3779 | into the | |
ccc6cda3 | 3780 | .I inputrc |
726f6388 JA |
3781 | would make M\-C\-u execute the readline command |
3782 | .IR universal\-argument . | |
3783 | .PP | |
3784 | The following symbolic character names are recognized: | |
3785 | .IR RUBOUT , | |
3786 | .IR DEL , | |
3787 | .IR ESC , | |
3788 | .IR LFD , | |
3789 | .IR NEWLINE , | |
3790 | .IR RET , | |
3791 | .IR RETURN , | |
3792 | .IR SPC , | |
3793 | .IR SPACE , | |
3794 | and | |
3795 | .IR TAB . | |
3796 | In addition to command names, readline allows keys to be bound | |
3797 | to a string that is inserted when the key is pressed (a \fImacro\fP). | |
ccc6cda3 | 3798 | .SS "Readline Key Bindings" |
726f6388 JA |
3799 | .PP |
3800 | The syntax for controlling key bindings in the | |
cce855bc | 3801 | .I inputrc |
726f6388 JA |
3802 | file is simple. All that is required is the name of the |
3803 | command or the text of a macro and a key sequence to which | |
3804 | it should be bound. The name may be specified in one of two ways: | |
ccc6cda3 | 3805 | as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP |
726f6388 | 3806 | prefixes, or as a key sequence. |
cce855bc | 3807 | When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP, |
726f6388 JA |
3808 | .I keyname |
3809 | is the name of a key spelled out in English. For example: | |
3810 | .sp | |
3811 | .RS | |
3812 | Control-u: universal\-argument | |
3813 | .br | |
3814 | Meta-Rubout: backward-kill-word | |
3815 | .br | |
ccc6cda3 | 3816 | Control-o: "> output" |
726f6388 JA |
3817 | .RE |
3818 | .LP | |
3819 | In the above example, | |
ccc6cda3 | 3820 | .I C\-u |
726f6388 JA |
3821 | is bound to the function |
3822 | .BR universal\-argument , | |
ccc6cda3 | 3823 | .I M\-DEL |
726f6388 JA |
3824 | is bound to the function |
3825 | .BR backward\-kill\-word , | |
3826 | and | |
ccc6cda3 | 3827 | .I C\-o |
726f6388 JA |
3828 | is bound to run the macro |
3829 | expressed on the right hand side (that is, to insert the text | |
ccc6cda3 | 3830 | .I "> output" |
726f6388 JA |
3831 | into the line). |
3832 | .PP | |
cce855bc | 3833 | In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP, |
726f6388 JA |
3834 | .B keyseq |
3835 | differs from | |
3836 | .B keyname | |
3837 | above in that strings denoting | |
3838 | an entire key sequence may be specified by placing the sequence | |
3839 | within double quotes. Some GNU Emacs style key escapes can be | |
3840 | used, as in the following example. | |
3841 | .sp | |
3842 | .RS | |
ccc6cda3 | 3843 | "\eC\-u": universal\-argument |
726f6388 | 3844 | .br |
ccc6cda3 | 3845 | "\eC\-x\eC\-r": re\-read\-init\-file |
726f6388 JA |
3846 | .br |
3847 | "\ee[11~": "Function Key 1" | |
3848 | .RE | |
3849 | .PP | |
3850 | In this example, | |
ccc6cda3 | 3851 | .I C\-u |
726f6388 JA |
3852 | is again bound to the function |
3853 | .BR universal\-argument . | |
ccc6cda3 | 3854 | .I "C\-x C\-r" |
726f6388 JA |
3855 | is bound to the function |
3856 | .BR re\-read\-init\-file , | |
3857 | and | |
3858 | .I "ESC [ 1 1 ~" | |
3859 | is bound to insert the text | |
3860 | .BR "Function Key 1" . | |
cce855bc | 3861 | The full set of GNU Emacs style escape sequences is |
726f6388 | 3862 | .RS |
cce855bc | 3863 | .PD 0 |
726f6388 JA |
3864 | .TP |
3865 | .B \eC\- | |
3866 | control prefix | |
3867 | .TP | |
ccc6cda3 | 3868 | .B \eM\- |
726f6388 JA |
3869 | meta prefix |
3870 | .TP | |
3871 | .B \ee | |
3872 | an escape character | |
3873 | .TP | |
3874 | .B \e\e | |
3875 | backslash | |
3876 | .TP | |
3877 | .B \e" | |
3878 | literal " | |
3879 | .TP | |
3880 | .B \e' | |
3881 | literal ' | |
3882 | .RE | |
cce855bc JA |
3883 | .PD |
3884 | .PP | |
3885 | In addition to the GNU Emacs style escape sequences, a second | |
3886 | set of backslash escapes is available: | |
3887 | .RS | |
3888 | .PD 0 | |
3889 | .TP | |
3890 | .B \ea | |
3891 | alert (bell) | |
3892 | .TP | |
3893 | .B \eb | |
3894 | backspace | |
3895 | .TP | |
3896 | .B \ed | |
3897 | delete | |
3898 | .TP | |
3899 | .B \ef | |
3900 | form feed | |
3901 | .TP | |
3902 | .B \en | |
3903 | newline | |
3904 | .TP | |
3905 | .B \er | |
3906 | carriage return | |
3907 | .TP | |
3908 | .B \et | |
3909 | horizontal tab | |
3910 | .TP | |
3911 | .B \ev | |
3912 | vertical tab | |
3913 | .TP | |
3914 | .B \e\fInnn\fP | |
3915 | the character whose ASCII code is the octal value \fInnn\fP | |
3916 | (one to three digits) | |
3917 | .TP | |
3918 | .B \ex\fInnn\fP | |
3919 | the character whose ASCII code is the hexadecimal value \fInnn\fP | |
3920 | (one to three digits) | |
3921 | .RE | |
3922 | .PD | |
726f6388 | 3923 | .PP |
cce855bc JA |
3924 | When entering the text of a macro, single or double quotes must |
3925 | be used to indicate a macro definition. | |
3926 | Unquoted text is assumed to be a function name. | |
3927 | In the macro body, the backslash escapes described above are expanded. | |
3928 | Backslash will quote any other character in the macro text, | |
3929 | including " and '. | |
726f6388 JA |
3930 | .PP |
3931 | .B Bash | |
3932 | allows the current readline key bindings to be displayed or modified | |
3933 | with the | |
3934 | .B bind | |
3935 | builtin command. The editing mode may be switched during interactive | |
3936 | use by using the | |
3937 | .B \-o | |
3938 | option to the | |
3939 | .B set | |
3940 | builtin command (see | |
3941 | .SM | |
3942 | .B SHELL BUILTIN COMMANDS | |
3943 | below). | |
ccc6cda3 | 3944 | .SS "Readline Variables" |
726f6388 JA |
3945 | .PP |
3946 | Readline has variables that can be used to further customize its | |
3947 | behavior. A variable may be set in the | |
3948 | .I inputrc | |
3949 | file with a statement of the form | |
3950 | .RS | |
3951 | .PP | |
3952 | \fBset\fP \fIvariable\-name\fP \fIvalue\fP | |
3953 | .RE | |
3954 | .PP | |
3955 | Except where noted, readline variables can take the values | |
3956 | .B On | |
3957 | or | |
3958 | .BR Off . | |
3959 | The variables and their default values are: | |
3960 | .PP | |
3961 | .PD 0 | |
3962 | .TP | |
726f6388 JA |
3963 | .B bell\-style (audible) |
3964 | Controls what happens when readline wants to ring the terminal bell. | |
3965 | If set to \fBnone\fP, readline never rings the bell. If set to | |
3966 | \fBvisible\fP, readline uses a visible bell if one is available. | |
3967 | If set to \fBaudible\fP, readline attempts to ring the terminal's bell. | |
3968 | .TP | |
3969 | .B comment\-begin (``#'') | |
ccc6cda3 JA |
3970 | The string that is inserted when the |
3971 | .B readline | |
3972 | .B insert\-comment | |
726f6388 | 3973 | command is executed. |
ccc6cda3 JA |
3974 | This command is bound to |
3975 | .B M\-# | |
3976 | in emacs mode and to | |
3977 | .B # | |
3978 | in vi command mode. | |
726f6388 | 3979 | .TP |
cce855bc JA |
3980 | .B completion\-ignore\-case (Off) |
3981 | If set to \fBOn\fP, readline performs filename matching and completion | |
3982 | in a case\-insensitive fashion. | |
3983 | .TP | |
726f6388 JA |
3984 | .B completion\-query\-items (100) |
3985 | This determines when the user is queried about viewing | |
3986 | the number of possible completions | |
3987 | generated by the \fBpossible\-completions\fP command. | |
3988 | It may be set to any integer value greater than or equal to | |
3989 | zero. If the number of possible completions is greater than | |
3990 | or equal to the value of this variable, the user is asked whether | |
3991 | or not he wishes to view them; otherwise they are simply listed | |
3992 | on the terminal. | |
3993 | .TP | |
ccc6cda3 JA |
3994 | .B convert\-meta (On) |
3995 | If set to \fBOn\fP, readline will convert characters with the | |
3996 | eighth bit set to an ASCII key sequence | |
3997 | by stripping the eighth bit and prepending an | |
3998 | escape character (in effect, using escape as the \fImeta prefix\fP). | |
3999 | .TP | |
4000 | .B disable\-completion (Off) | |
4001 | If set to \fBOn\fP, readline will inhibit word completion. Completion | |
4002 | characters will be inserted into the line as if they had been | |
4003 | mapped to \fBself-insert\fP. | |
4004 | .TP | |
4005 | .B editing\-mode (emacs) | |
4006 | Controls whether readline begins with a set of key bindings similar | |
4007 | to \fIemacs\fP or \fIvi\fP. | |
4008 | .B editing\-mode | |
4009 | can be set to either | |
4010 | .B emacs | |
4011 | or | |
4012 | .BR vi . | |
4013 | .TP | |
4014 | .B enable\-keypad (Off) | |
4015 | When set to \fBOn\fP, readline will try to enable the application | |
4016 | keypad when it is called. Some systems need this to enable the | |
4017 | arrow keys. | |
4018 | .TP | |
4019 | .B expand\-tilde (Off) | |
4020 | If set to \fBon\fP, tilde expansion is performed when readline | |
4021 | attempts word completion. | |
4022 | .TP | |
4023 | .B horizontal\-scroll\-mode (Off) | |
4024 | When set to \fBOn\fP, makes readline use a single line for display, | |
4025 | scrolling the input horizontally on a single screen line when it | |
4026 | becomes longer than the screen width rather than wrapping to a new line. | |
4027 | .TP | |
4028 | .B input\-meta (Off) | |
4029 | If set to \fBOn\fP, readline will enable eight-bit input (that is, | |
4030 | it will not strip the high bit from the characters it reads), | |
4031 | regardless of what the terminal claims it can support. The name | |
4032 | .B meta\-flag | |
4033 | is a synonym for this variable. | |
4034 | .TP | |
726f6388 | 4035 | .B keymap (emacs) |
cce855bc | 4036 | Set the current readline keymap. The set of valid keymap names is |
ccc6cda3 JA |
4037 | \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, |
4038 | vi\-command\fP, and | |
4039 | .IR vi\-insert . | |
4040 | \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is | |
4041 | equivalent to \fIemacs\-standard\fP. The default value is | |
726f6388 JA |
4042 | .IR emacs ; |
4043 | the value of | |
4044 | .B editing\-mode | |
4045 | also affects the default keymap. | |
4046 | .TP | |
ccc6cda3 JA |
4047 | .B mark\-directories (On) |
4048 | If set to \fBOn\fP, completed directory names have a slash | |
4049 | appended. | |
4050 | .TP | |
4051 | .B mark\-modified\-lines (Off) | |
4052 | If set to \fBOn\fP, history lines that have been modified are displayed | |
4053 | with a preceding asterisk (\fB*\fP). | |
4054 | .TP | |
4055 | .B output\-meta (Off) | |
4056 | If set to \fBOn\fP, readline will display characters with the | |
4057 | eighth bit set directly rather than as a meta-prefixed escape | |
4058 | sequence. | |
4059 | .TP | |
cce855bc JA |
4060 | .B print\-completions\-horizontally (Off) |
4061 | If set to \fBOn\fP, readline will display completions with matches | |
4062 | sorted horizontally in alphabetical order, rather than down the screen. | |
4063 | .TP | |
726f6388 JA |
4064 | .B show\-all\-if\-ambiguous (Off) |
4065 | This alters the default behavior of the completion functions. If | |
4066 | set to | |
4067 | .BR on , | |
4068 | words which have more than one possible completion cause the | |
4069 | matches to be listed immediately instead of ringing the bell. | |
4070 | .TP | |
ccc6cda3 JA |
4071 | .B visible\-stats (Off) |
4072 | If set to \fBOn\fP, a character denoting a file's type as reported | |
4073 | by \fIstat\fP(2) is appended to the filename when listing possible | |
4074 | completions. | |
726f6388 | 4075 | .PD |
ccc6cda3 | 4076 | .SS "Readline Conditional Constructs" |
726f6388 JA |
4077 | .PP |
4078 | Readline implements a facility similar in spirit to the conditional | |
4079 | compilation features of the C preprocessor which allows key | |
4080 | bindings and variable settings to be performed as the result | |
cce855bc | 4081 | of tests. There are four parser directives used. |
726f6388 JA |
4082 | .IP \fB$if\fP |
4083 | The | |
4084 | .B $if | |
4085 | construct allows bindings to be made based on the | |
4086 | editing mode, the terminal being used, or the application using | |
4087 | readline. The text of the test extends to the end of the line; | |
4088 | no characters are required to isolate it. | |
4089 | .RS | |
4090 | .IP \fBmode\fP | |
4091 | The \fBmode=\fP form of the \fB$if\fP directive is used to test | |
4092 | whether readline is in emacs or vi mode. | |
4093 | This may be used in conjunction | |
4094 | with the \fBset keymap\fP command, for instance, to set bindings in | |
ccc6cda3 | 4095 | the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if |
726f6388 JA |
4096 | readline is starting out in emacs mode. |
4097 | .IP \fBterm\fP | |
4098 | The \fBterm=\fP form may be used to include terminal-specific | |
4099 | key bindings, perhaps to bind the key sequences output by the | |
4100 | terminal's function keys. The word on the right side of the | |
4101 | .B = | |
cce855bc | 4102 | is tested against the both full name of the terminal and the portion |
726f6388 JA |
4103 | of the terminal name before the first \fB\-\fP. This allows |
4104 | .I sun | |
4105 | to match both | |
4106 | .I sun | |
4107 | and | |
4108 | .IR sun\-cmd , | |
4109 | for instance. | |
4110 | .IP \fBapplication\fP | |
4111 | The \fBapplication\fP construct is used to include | |
ccc6cda3 | 4112 | application-specific settings. Each program using the readline |
726f6388 JA |
4113 | library sets the \fIapplication name\fP, and an initialization |
4114 | file can test for a particular value. | |
4115 | This could be used to bind key sequences to functions useful for | |
4116 | a specific program. For instance, the following command adds a | |
4117 | key sequence that quotes the current or previous word in Bash: | |
cce855bc | 4118 | .sp 1 |
726f6388 JA |
4119 | .RS |
4120 | .nf | |
4121 | \fB$if\fP Bash | |
4122 | # Quote the current or previous word | |
ccc6cda3 | 4123 | "\eC\-xq": "\eeb\e"\eef\e"" |
726f6388 JA |
4124 | \fB$endif\fP |
4125 | .fi | |
4126 | .RE | |
4127 | .RE | |
4128 | .IP \fB$endif\fP | |
cce855bc | 4129 | This command, as seen in the previous example, terminates an |
726f6388 JA |
4130 | \fB$if\fP command. |
4131 | .IP \fB$else\fP | |
4132 | Commands in this branch of the \fB$if\fP directive are executed if | |
4133 | the test fails. | |
cce855bc JA |
4134 | .IP \fB$include\fP |
4135 | This directive takes a single filename as an argument and reads commands | |
4136 | and bindings from that file. For example, the following directive | |
4137 | would read \fI/etc/inputrc\fP: | |
4138 | .sp 1 | |
4139 | .RS | |
4140 | .nf | |
4141 | \fB$include\fP \^ \fI/etc/inputrc\fP | |
4142 | .fi | |
4143 | .RE | |
ccc6cda3 | 4144 | .SS Searching |
726f6388 | 4145 | .PP |
ccc6cda3 JA |
4146 | Readline provides commands for searching through the command history |
4147 | (see | |
4148 | .SM | |
4149 | .B HISTORY | |
4150 | below) for lines containing a specified string. | |
4151 | There are two search modes: | |
4152 | .I incremental | |
4153 | and | |
4154 | .IR non-incremental . | |
4155 | .PP | |
4156 | Incremental searches begin before the user has finished typing the | |
4157 | search string. | |
4158 | As each character of the search string is typed, readline displays | |
4159 | the next entry from the history matching the string typed so far. | |
4160 | An incremental search requires only as many characters as needed to | |
4161 | find the desired history entry. | |
4162 | The Escape character is used to terminate an incremental search. | |
4163 | Control-J will also terminate the search. | |
4164 | Control-G will abort an incremental search and restore the original | |
4165 | line. | |
4166 | When the search is terminated, the history entry containing the | |
4167 | search string becomes the current line. | |
4168 | To find other matching entries in the history list, type Control-S or | |
4169 | Control-R as appropriate. | |
4170 | This will search backward or forward in the history for the next | |
4171 | entry matching the search string typed so far. | |
4172 | Any other key sequence bound to a readline command will terminate | |
4173 | the search and execute that command. | |
4174 | For instance, a \fInewline\fP will terminate the search and accept | |
4175 | the line, thereby executing the command from the history list. | |
4176 | .PP | |
4177 | Non-incremental searches read the entire search string before starting | |
4178 | to search for matching history lines. The search string may be | |
cce855bc | 4179 | typed by the user or be part of the contents of the current line. |
ccc6cda3 | 4180 | .SS "Readline Command Names" |
726f6388 JA |
4181 | .PP |
4182 | The following is a list of the names of the commands and the default | |
4183 | key sequences to which they are bound. | |
ccc6cda3 | 4184 | Command names without an accompanying key sequence are unbound by default. |
726f6388 JA |
4185 | .SS Commands for Moving |
4186 | .PP | |
4187 | .PD 0 | |
4188 | .TP | |
4189 | .B beginning\-of\-line (C\-a) | |
4190 | Move to the start of the current line. | |
4191 | .TP | |
4192 | .B end\-of\-line (C\-e) | |
4193 | Move to the end of the line. | |
4194 | .TP | |
4195 | .B forward\-char (C\-f) | |
4196 | Move forward a character. | |
4197 | .TP | |
4198 | .B backward\-char (C\-b) | |
4199 | Move back a character. | |
4200 | .TP | |
4201 | .B forward\-word (M\-f) | |
4202 | Move forward to the end of the next word. Words are composed of | |
4203 | alphanumeric characters (letters and digits). | |
4204 | .TP | |
4205 | .B backward\-word (M\-b) | |
4206 | Move back to the start of this, or the previous, word. Words are | |
4207 | composed of alphanumeric characters (letters and digits). | |
4208 | .TP | |
4209 | .B clear\-screen (C\-l) | |
4210 | Clear the screen leaving the current line at the top of the screen. | |
4211 | With an argument, refresh the current line without clearing the | |
4212 | screen. | |
4213 | .TP | |
4214 | .B redraw\-current\-line | |
ccc6cda3 | 4215 | Refresh the current line. |
726f6388 JA |
4216 | .PD |
4217 | .SS Commands for Manipulating the History | |
4218 | .PP | |
4219 | .PD 0 | |
4220 | .TP | |
4221 | .B accept\-line (Newline, Return) | |
4222 | Accept the line regardless of where the cursor is. If this line is | |
ccc6cda3 | 4223 | non-empty, add it to the history list according to the state of the |
726f6388 JA |
4224 | .SM |
4225 | .B HISTCONTROL | |
4226 | variable. If the line is a modified history | |
4227 | line, then restore the history line to its original state. | |
4228 | .TP | |
4229 | .B previous\-history (C\-p) | |
4230 | Fetch the previous command from the history list, moving back in | |
4231 | the list. | |
4232 | .TP | |
4233 | .B next\-history (C\-n) | |
4234 | Fetch the next command from the history list, moving forward in the | |
4235 | list. | |
4236 | .TP | |
4237 | .B beginning\-of\-history (M\-<) | |
4238 | Move to the first line in the history. | |
4239 | .TP | |
4240 | .B end\-of\-history (M\->) | |
4241 | Move to the end of the input history, i.e., the line currently being | |
4242 | entered. | |
4243 | .TP | |
4244 | .B reverse\-search\-history (C\-r) | |
4245 | Search backward starting at the current line and moving `up' through | |
4246 | the history as necessary. This is an incremental search. | |
4247 | .TP | |
4248 | .B forward\-search\-history (C\-s) | |
4249 | Search forward starting at the current line and moving `down' through | |
4250 | the history as necessary. This is an incremental search. | |
4251 | .TP | |
4252 | .B non\-incremental\-reverse\-search\-history (M\-p) | |
4253 | Search backward through the history starting at the current line | |
ccc6cda3 | 4254 | using a non-incremental search for a string supplied by the user. |
726f6388 JA |
4255 | .TP |
4256 | .B non\-incremental\-forward\-search\-history (M\-n) | |
ccc6cda3 | 4257 | Search forward through the history using a non-incremental search for |
726f6388 JA |
4258 | a string supplied by the user. |
4259 | .TP | |
4260 | .B history\-search\-forward | |
4261 | Search forward through the history for the string of characters | |
ccc6cda3 JA |
4262 | between the start of the current line and the current cursor |
4263 | position (the \fIpoint\fP). | |
4264 | This is a non-incremental search. | |
726f6388 JA |
4265 | .TP |
4266 | .B history\-search\-backward | |
4267 | Search backward through the history for the string of characters | |
ccc6cda3 JA |
4268 | between the start of the current line and the point. |
4269 | This is a non-incremental search. | |
726f6388 JA |
4270 | .TP |
4271 | .B yank\-nth\-arg (M\-C\-y) | |
4272 | Insert the first argument to the previous command (usually | |
4273 | the second word on the previous line) at point (the current | |
4274 | cursor position). With an argument | |
4275 | .IR n , | |
4276 | insert the \fIn\fPth word from the previous command (the words | |
4277 | in the previous command begin with word 0). A negative argument | |
4278 | inserts the \fIn\fPth word from the end of the previous command. | |
4279 | .TP | |
4280 | .B | |
4281 | yank\-last\-arg (M\-.\^, M\-_\^) | |
ccc6cda3 JA |
4282 | Insert the last argument to the previous command (the last word of |
4283 | the previous history entry). With an argument, | |
4284 | behave exactly like \fByank\-nth\-arg\fP. | |
cce855bc JA |
4285 | Successive calls to \fByank\-last\-arg\fP move back through the history |
4286 | list, inserting the last argument of each line in turn. | |
726f6388 JA |
4287 | .TP |
4288 | .B shell\-expand\-line (M\-C\-e) | |
cce855bc | 4289 | Expand the line as the shell does. This |
726f6388 JA |
4290 | performs alias and history expansion as well as all of the shell |
4291 | word expansions. See | |
4292 | .SM | |
4293 | .B HISTORY EXPANSION | |
4294 | below for a description of history expansion. | |
4295 | .TP | |
4296 | .B history\-expand\-line (M\-^) | |
d166f048 JA |
4297 | Perform history expansion on the current line. |
4298 | See | |
726f6388 JA |
4299 | .SM |
4300 | .B HISTORY EXPANSION | |
4301 | below for a description of history expansion. | |
4302 | .TP | |
cce855bc JA |
4303 | .B magic\-space |
4304 | Perform history expansion on the current line and insert a space. | |
4305 | See | |
4306 | .SM | |
4307 | .B HISTORY EXPANSION | |
4308 | below for a description of history expansion. | |
4309 | .TP | |
d166f048 JA |
4310 | .B alias\-expand\-line |
4311 | Perform alias expansion on the current line. | |
4312 | See | |
4313 | .SM | |
4314 | .B ALIASES | |
4315 | above for a description of alias expansion. | |
4316 | .TP | |
4317 | .B history\-and\-alias\-expand\-line | |
4318 | Perform history and alias expansion on the current line. | |
4319 | .TP | |
726f6388 JA |
4320 | .B insert\-last\-argument (M\-.\^, M\-_\^) |
4321 | A synonym for \fByank\-last\-arg\fP. | |
4322 | .TP | |
ccc6cda3 | 4323 | .B operate\-and\-get\-next (C\-o) |
726f6388 JA |
4324 | Accept the current line for execution and fetch the next line |
4325 | relative to the current line from the history for editing. Any | |
4326 | argument is ignored. | |
4327 | .PD | |
4328 | .SS Commands for Changing Text | |
4329 | .PP | |
4330 | .PD 0 | |
4331 | .TP | |
4332 | .B delete\-char (C\-d) | |
4333 | Delete the character under the cursor. If point is at the | |
4334 | beginning of the line, there are no characters in the line, and | |
cce855bc | 4335 | the last character typed was not bound to \fBdelete\-char\fP, |
726f6388 JA |
4336 | then return |
4337 | .SM | |
4338 | .BR EOF . | |
4339 | .TP | |
4340 | .B backward\-delete\-char (Rubout) | |
4341 | Delete the character behind the cursor. When given a numeric argument, | |
ccc6cda3 | 4342 | save the deleted text on the kill ring. |
726f6388 JA |
4343 | .TP |
4344 | .B quoted\-insert (C\-q, C\-v) | |
cce855bc | 4345 | Add the next character typed to the line verbatim. This is |
726f6388 JA |
4346 | how to insert characters like \fBC\-q\fP, for example. |
4347 | .TP | |
ccc6cda3 | 4348 | .B tab\-insert (C\-v TAB) |
726f6388 JA |
4349 | Insert a tab character. |
4350 | .TP | |
4351 | .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...) | |
4352 | Insert the character typed. | |
4353 | .TP | |
4354 | .B transpose\-chars (C\-t) | |
4355 | Drag the character before point forward over the character at point. | |
4356 | Point moves forward as well. If point is at the end of the line, then | |
4357 | transpose the two characters before point. Negative arguments don't work. | |
4358 | .TP | |
4359 | .B transpose\-words (M\-t) | |
4360 | Drag the word behind the cursor past the word in front of the cursor | |
4361 | moving the cursor over that word as well. | |
4362 | .TP | |
4363 | .B upcase\-word (M\-u) | |
4364 | Uppercase the current (or following) word. With a negative argument, | |
cce855bc | 4365 | uppercase the previous word, but do not move point. |
726f6388 JA |
4366 | .TP |
4367 | .B downcase\-word (M\-l) | |
4368 | Lowercase the current (or following) word. With a negative argument, | |
cce855bc | 4369 | lowercase the previous word, but do not move point. |
726f6388 JA |
4370 | .TP |
4371 | .B capitalize\-word (M\-c) | |
4372 | Capitalize the current (or following) word. With a negative argument, | |
cce855bc | 4373 | capitalize the previous word, but do not move point. |
726f6388 JA |
4374 | .PD |
4375 | .SS Killing and Yanking | |
4376 | .PP | |
4377 | .PD 0 | |
4378 | .TP | |
4379 | .B kill\-line (C\-k) | |
4380 | Kill the text from the current cursor position to the end of the line. | |
4381 | .TP | |
ccc6cda3 | 4382 | .B backward\-kill\-line (C\-x Rubout) |
726f6388 JA |
4383 | Kill backward to the beginning of the line. |
4384 | .TP | |
4385 | .B unix\-line\-discard (C\-u) | |
4386 | Kill backward from point to the beginning of the line. | |
cce855bc JA |
4387 | The killed text is saved on the kill-ring. |
4388 | \" There is no real difference between this and backward-kill-line | |
726f6388 JA |
4389 | .TP |
4390 | .B kill\-whole\-line | |
4391 | Kill all characters on the current line, no matter where the | |
ccc6cda3 | 4392 | cursor is. |
726f6388 JA |
4393 | .TP |
4394 | .B kill\-word (M\-d) | |
4395 | Kill from the cursor to the end of the current word, or if between | |
4396 | words, to the end of the next word. Word boundaries are the same as | |
4397 | those used by \fBforward\-word\fP. | |
4398 | .TP | |
4399 | .B backward\-kill\-word (M\-Rubout) | |
4400 | Kill the word behind the cursor. Word boundaries are the same as | |
4401 | those used by \fBbackward\-word\fP. | |
4402 | .TP | |
4403 | .B unix\-word\-rubout (C\-w) | |
4404 | Kill the word behind the cursor, using white space as a word boundary. | |
ccc6cda3 JA |
4405 | The word boundaries are different from \fBbackward\-kill\-word\fP. |
4406 | .TP | |
4407 | .B delete\-horizontal\-space (M\-\e) | |
4408 | Delete all spaces and tabs around point. | |
4409 | .TP | |
4410 | .B kill\-region | |
4411 | Kill the text between the point and \fImark\fP (saved cursor position). | |
4412 | This text is referred to as the \fIregion\fP. | |
4413 | .TP | |
4414 | .B copy\-region\-as\-kill | |
4415 | Copy the text in the region to the kill buffer. | |
726f6388 | 4416 | .TP |
ccc6cda3 JA |
4417 | .B copy\-backward\-word |
4418 | Copy the word before point to the kill buffer. | |
cce855bc | 4419 | The word boundaries are the same as \fBbackward\-word\fP. |
ccc6cda3 JA |
4420 | .TP |
4421 | .B copy\-forward\-word | |
4422 | Copy the word following point to the kill buffer. | |
cce855bc | 4423 | The word boundaries are the same as \fBforward\-word\fP. |
726f6388 JA |
4424 | .TP |
4425 | .B yank (C\-y) | |
4426 | Yank the top of the kill ring into the buffer at the cursor. | |
4427 | .TP | |
4428 | .B yank\-pop (M\-y) | |
ccc6cda3 | 4429 | Rotate the kill ring, and yank the new top. Only works following |
726f6388 JA |
4430 | .B yank |
4431 | or | |
4432 | .BR yank\-pop . | |
4433 | .PD | |
4434 | .SS Numeric Arguments | |
4435 | .PP | |
4436 | .PD 0 | |
4437 | .TP | |
4438 | .B digit\-argument (M\-0, M\-1, ..., M\-\-) | |
4439 | Add this digit to the argument already accumulating, or start a new | |
4440 | argument. M\-\- starts a negative argument. | |
4441 | .TP | |
4442 | .B universal\-argument | |
d166f048 JA |
4443 | This is another way to specify an argument. |
4444 | If this command is followed by one or more digits, optionally with a | |
4445 | leading minus sign, those digits define the argument. | |
4446 | If the command is followed by digits, executing | |
4447 | .B universal\-argument | |
4448 | again ends the numeric argument, but is otherwise ignored. | |
4449 | As a special case, if this command is immediately followed by a | |
4450 | character that is neither a digit or minus sign, the argument count | |
4451 | for the next command is multiplied by four. | |
726f6388 | 4452 | The argument count is initially one, so executing this function the |
d166f048 JA |
4453 | first time makes the argument count four, a second time makes the |
4454 | argument count sixteen, and so on. | |
726f6388 JA |
4455 | .PD |
4456 | .SS Completing | |
4457 | .PP | |
4458 | .PD 0 | |
4459 | .TP | |
4460 | .B complete (TAB) | |
4461 | Attempt to perform completion on the text before point. | |
4462 | .B Bash | |
4463 | attempts completion treating the text as a variable (if the | |
4464 | text begins with \fB$\fP), username (if the text begins with | |
4465 | \fB~\fP), hostname (if the text begins with \fB@\fP), or | |
4466 | command (including aliases and functions) in turn. If none | |
4467 | of these produces a match, filename completion is attempted. | |
4468 | .TP | |
ccc6cda3 | 4469 | .B possible\-completions (M\-?) |
726f6388 JA |
4470 | List the possible completions of the text before point. |
4471 | .TP | |
ccc6cda3 | 4472 | .B insert\-completions (M\-*) |
726f6388 JA |
4473 | Insert all completions of the text before point |
4474 | that would have been generated by | |
ccc6cda3 | 4475 | \fBpossible\-completions\fP. |
726f6388 | 4476 | .TP |
cce855bc JA |
4477 | .B menu\-complete |
4478 | Similar to \fBcomplete\fP, but replaces the word to be completed | |
4479 | with a single match from the list of possible completions. | |
4480 | Repeated execution of \fBmenu\-complete\fP steps through the list | |
4481 | of possible completions, inserting each match in turn. | |
4482 | At the end of the list of completions, the bell is rung and the | |
4483 | original text is restored. | |
4484 | An argument of \fIn\fP moves \fIn\fP positions forward in the list | |
4485 | of matches; a negative argument may be used to move backward | |
4486 | through the list. | |
4487 | This command is intended to be bound to \fBTAB\fP, but is unbound | |
4488 | by default. | |
4489 | .TP | |
726f6388 JA |
4490 | .B complete\-filename (M\-/) |
4491 | Attempt filename completion on the text before point. | |
4492 | .TP | |
4493 | .B possible\-filename\-completions (C\-x /) | |
4494 | List the possible completions of the text before point, | |
4495 | treating it as a filename. | |
4496 | .TP | |
4497 | .B complete\-username (M\-~) | |
4498 | Attempt completion on the text before point, treating | |
4499 | it as a username. | |
4500 | .TP | |
4501 | .B possible\-username\-completions (C\-x ~) | |
4502 | List the possible completions of the text before point, | |
4503 | treating it as a username. | |
4504 | .TP | |
4505 | .B complete\-variable (M\-$) | |
4506 | Attempt completion on the text before point, treating | |
4507 | it as a shell variable. | |
4508 | .TP | |
4509 | .B possible\-variable\-completions (C\-x $) | |
4510 | List the possible completions of the text before point, | |
4511 | treating it as a shell variable. | |
4512 | .TP | |
4513 | .B complete\-hostname (M\-@) | |
4514 | Attempt completion on the text before point, treating | |
4515 | it as a hostname. | |
4516 | .TP | |
4517 | .B possible\-hostname\-completions (C\-x @) | |
4518 | List the possible completions of the text before point, | |
4519 | treating it as a hostname. | |
4520 | .TP | |
4521 | .B complete\-command (M\-!) | |
4522 | Attempt completion on the text before point, treating | |
4523 | it as a command name. Command completion attempts to | |
4524 | match the text against aliases, reserved words, shell | |
cce855bc | 4525 | functions, shell builtins, and finally executable filenames, |
726f6388 JA |
4526 | in that order. |
4527 | .TP | |
4528 | .B possible\-command\-completions (C\-x !) | |
4529 | List the possible completions of the text before point, | |
4530 | treating it as a command name. | |
4531 | .TP | |
ccc6cda3 | 4532 | .B dynamic\-complete\-history (M\-TAB) |
726f6388 JA |
4533 | Attempt completion on the text before point, comparing |
4534 | the text against lines from the history list for possible | |
4535 | completion matches. | |
4536 | .TP | |
4537 | .B complete\-into\-braces (M\-{) | |
4538 | Perform filename completion and return the list of possible completions | |
4539 | enclosed within braces so the list is available to the shell (see | |
4540 | .B Brace Expansion | |
4541 | above). | |
4542 | .PD | |
4543 | .SS Keyboard Macros | |
4544 | .PP | |
4545 | .PD 0 | |
4546 | .TP | |
ccc6cda3 | 4547 | .B start\-kbd\-macro (C\-x (\^) |
726f6388 JA |
4548 | Begin saving the characters typed into the current keyboard macro. |
4549 | .TP | |
ccc6cda3 | 4550 | .B end\-kbd\-macro (C\-x )\^) |
726f6388 | 4551 | Stop saving the characters typed into the current keyboard macro |
ccc6cda3 | 4552 | and store the definition. |
726f6388 | 4553 | .TP |
ccc6cda3 | 4554 | .B call\-last\-kbd\-macro (C\-x e) |
726f6388 JA |
4555 | Re-execute the last keyboard macro defined, by making the characters |
4556 | in the macro appear as if typed at the keyboard. | |
4557 | .PD | |
4558 | .SS Miscellaneous | |
4559 | .PP | |
4560 | .PD 0 | |
4561 | .TP | |
4562 | .B re\-read\-init\-file (C\-x C\-r) | |
ccc6cda3 | 4563 | Read in the contents of the \fIinputrc\fP file, and incorporate |
726f6388 JA |
4564 | any bindings or variable assignments found there. |
4565 | .TP | |
4566 | .B abort (C\-g) | |
4567 | Abort the current editing command and | |
4568 | ring the terminal's bell (subject to the setting of | |
4569 | .BR bell\-style ). | |
4570 | .TP | |
ccc6cda3 JA |
4571 | .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...) |
4572 | If the metafied character \fIx\fP is lowercase, run the command | |
4573 | that is bound to the corresponding uppercase character. | |
726f6388 JA |
4574 | .TP |
4575 | .B prefix\-meta (ESC) | |
4576 | Metafy the next character typed. | |
4577 | .SM | |
4578 | .B ESC | |
4579 | .B f | |
4580 | is equivalent to | |
4581 | .BR Meta\-f . | |
4582 | .TP | |
4583 | .B undo (C\-_, C\-x C\-u) | |
4584 | Incremental undo, separately remembered for each line. | |
4585 | .TP | |
4586 | .B revert\-line (M\-r) | |
cce855bc | 4587 | Undo all changes made to this line. This is like executing the |
726f6388 JA |
4588 | .B undo |
4589 | command enough times to return the line to its initial state. | |
4590 | .TP | |
4591 | .B tilde\-expand (M\-~) | |
4592 | Perform tilde expansion on the current word. | |
4593 | .TP | |
ccc6cda3 JA |
4594 | .B set\-mark (C\-@, M\-<space>) |
4595 | Set the mark to the current point. If a | |
4596 | numeric argument is supplied, the mark is set to that position. | |
4597 | .TP | |
4598 | .B exchange\-point\-and\-mark (C\-x C\-x) | |
4599 | Swap the point with the mark. The current cursor position is set to | |
4600 | the saved position, and the old cursor position is saved as the mark. | |
4601 | .TP | |
4602 | .B character\-search (C\-]) | |
4603 | A character is read and point is moved to the next occurrence of that | |
4604 | character. A negative count searches for previous occurrences. | |
4605 | .TP | |
4606 | .B character\-search\-backward (M\-C\-]) | |
4607 | A character is read and point is moved to the previous occurrence of that | |
4608 | character. A negative count searches for subsequent occurrences. | |
4609 | .TP | |
4610 | .B insert\-comment (M\-#) | |
4611 | The value of the | |
4612 | .B readline | |
4613 | .B comment\-begin | |
4614 | variable is inserted at the beginning of the current line, and the line | |
4615 | is accepted as if a newline had been typed. This makes the current line | |
4616 | a shell comment. | |
4617 | .TP | |
4618 | .B glob\-expand\-word (C\-x *) | |
4619 | The word before point is treated as a pattern for pathname expansion, | |
4620 | and the list of matching file names is inserted, replacing the word. | |
4621 | .TP | |
4622 | .B glob\-list\-expansions (C\-x g) | |
4623 | The list of expansions that would have been generated by | |
4624 | .B glob\-expand\-word | |
4625 | is displayed, and the line is redrawn. | |
4626 | .TP | |
726f6388 JA |
4627 | .B dump\-functions |
4628 | Print all of the functions and their key bindings to the | |
4629 | readline output stream. If a numeric argument is supplied, | |
4630 | the output is formatted in such a way that it can be made part | |
4631 | of an \fIinputrc\fP file. | |
4632 | .TP | |
ccc6cda3 JA |
4633 | .B dump\-variables |
4634 | Print all of the settable readline variables and their values to the | |
4635 | readline output stream. If a numeric argument is supplied, | |
4636 | the output is formatted in such a way that it can be made part | |
4637 | of an \fIinputrc\fP file. | |
4638 | .TP | |
4639 | .B dump\-macros | |
4640 | Print all of the readline key sequences bound to macros and the | |
4641 | strings they ouput. If a numeric argument is supplied, | |
4642 | the output is formatted in such a way that it can be made part | |
4643 | of an \fIinputrc\fP file. | |
4644 | .TP | |
726f6388 JA |
4645 | .B display\-shell\-version (C\-x C\-v) |
4646 | Display version information about the current instance of | |
4647 | .BR bash . | |
4648 | .PD | |
4649 | .SH HISTORY | |
ccc6cda3 | 4650 | When the |
d166f048 | 4651 | .B \-o history |
ccc6cda3 JA |
4652 | option to the |
4653 | .B set | |
4654 | builtin is enabled, the shell provides access to the | |
4655 | \fIcommand history\fP, | |
726f6388 JA |
4656 | the list of commands previously typed. The text of the last |
4657 | .SM | |
4658 | .B HISTSIZE | |
4659 | commands (default 500) is saved in a history list. The shell | |
4660 | stores each command in the history list prior to parameter and | |
4661 | variable expansion (see | |
4662 | .SM | |
4663 | .B EXPANSION | |
4664 | above) but after history expansion is performed, subject to the | |
4665 | values of the shell variables | |
ccc6cda3 JA |
4666 | .SM |
4667 | .B HISTIGNORE | |
726f6388 JA |
4668 | and |
4669 | .SM | |
4670 | .BR HISTCONTROL . | |
4671 | On startup, the history is initialized from the file named by | |
4672 | the variable | |
4673 | .SM | |
4674 | .B HISTFILE | |
4675 | (default \fI~/.bash_history\fP). | |
4676 | .SM | |
4677 | .B HISTFILE | |
4678 | is truncated, if necessary, to contain no more than | |
4679 | .SM | |
4680 | .B HISTFILESIZE | |
4681 | lines. | |
ccc6cda3 JA |
4682 | When an interactive shell exits, the last |
4683 | .SM | |
4684 | .B HISTSIZE | |
4685 | lines are copied from the history list to | |
4686 | .SM | |
4687 | .BR HISTFILE . | |
4688 | If the | |
4689 | .B histappend | |
4690 | shell option is enabled | |
4691 | (see the description of | |
4692 | .B shopt | |
4693 | under | |
4694 | .SM | |
4695 | .B "SHELL BUILTIN COMMANDS" | |
4696 | below), the lines are appended to the history file, | |
4697 | otherwise the history file is overwritten. | |
4698 | If | |
4699 | .SM | |
4700 | .B HISTFILE | |
4701 | is unset, or if the history file is unwritable, the history is | |
4702 | not saved. After saving the history, the history file is truncated | |
4703 | to contain no more than | |
4704 | .SM | |
4705 | .B HISTFILESIZE | |
4706 | lines. If | |
4707 | .SM | |
4708 | .B HISTFILESIZE | |
4709 | is not set, no truncation is performed. | |
4710 | .PP | |
726f6388 JA |
4711 | The builtin command |
4712 | .B fc | |
4713 | (see | |
4714 | .SM | |
4715 | .B SHELL BUILTIN COMMANDS | |
4716 | below) may be used to list or edit and re-execute a portion of | |
4717 | the history list. | |
4718 | The | |
4719 | .B history | |
ccc6cda3 JA |
4720 | builtin can be used to display or modify the history list and |
4721 | manipulate the history file. | |
4722 | When using the command-line editing, search commands | |
726f6388 | 4723 | are available in each editing mode that provide access to the |
ccc6cda3 JA |
4724 | history list. |
4725 | .PP | |
4726 | The shell allows control over which commands are saved on the history | |
4727 | list. The | |
726f6388 | 4728 | .SM |
ccc6cda3 JA |
4729 | .B HISTCONTROL |
4730 | and | |
726f6388 | 4731 | .SM |
ccc6cda3 JA |
4732 | .B HISTIGNORE |
4733 | variables may be set to cause the shell to save only a subset of the | |
4734 | commands entered. | |
4735 | The | |
4736 | .B cmdhist | |
4737 | shell option, if enabled, causes the shell to attempt to save each | |
4738 | line of a multi-line command in the same history entry, adding | |
4739 | semicolons where necessary to preserve syntactic correctness. | |
4740 | The | |
4741 | .B lithist | |
4742 | shell option causes the shell to save the command with embedded newlines | |
4743 | instead of semicolons. See the description of the | |
4744 | .B shopt | |
4745 | builtin below under | |
4746 | .SM | |
4747 | .B "SHELL BUILTIN COMMANDS" | |
4748 | for information on setting and unsetting shell options. | |
726f6388 JA |
4749 | .SH "HISTORY EXPANSION" |
4750 | .PP | |
4751 | The shell supports a history expansion feature that | |
4752 | is similar to the history expansion in | |
4753 | .BR csh. | |
4754 | This section describes what syntax features are available. This | |
4755 | feature is enabled by default for interactive shells, and can be | |
4756 | disabled using the | |
4757 | .B \+H | |
4758 | option to the | |
4759 | .B set | |
4760 | builtin command (see | |
4761 | .SM | |
4762 | .B SHELL BUILTIN COMMANDS | |
ccc6cda3 JA |
4763 | below). Non-interactive shells do not perform history expansion |
4764 | by default. | |
4765 | .PP | |
4766 | History expansions introduce words from the history list into | |
4767 | the input stream, making it easy to repeat commands, insert the | |
4768 | arguments to a previous command into the current input line, or | |
4769 | fix errors in previous commands quickly. | |
726f6388 JA |
4770 | .PP |
4771 | History expansion is performed immediately after a complete line | |
4772 | is read, before the shell breaks it into words. | |
ccc6cda3 | 4773 | It takes place in two parts. |
cce855bc | 4774 | The first is to determine which line from the history list |
ccc6cda3 JA |
4775 | to use during substitution. |
4776 | The second is to select portions of that line for inclusion into | |
4777 | the current one. | |
cce855bc | 4778 | The line selected from the history is the \fIevent\fP, |
ccc6cda3 JA |
4779 | and the portions of that line that are acted upon are \fIwords\fP. |
4780 | Various \fImodifiers\fP are available to manipulate the selected words. | |
4781 | The line is broken into words in the same fashion as when reading input, | |
4782 | so that several \fImetacharacter\fP-separated words surrounded by | |
cce855bc | 4783 | quotes are considered one word. |
ccc6cda3 JA |
4784 | History expansions are introduced by the appearance of the |
4785 | history expansion character, which is \^\fB!\fP\^ by default. | |
4786 | Only backslash (\^\fB\e\fP\^) and single quotes can quote | |
4787 | the history expansion character. | |
4788 | .PP | |
4789 | Several shell options settable with the | |
4790 | .B shopt | |
4791 | builtin may be used to tailor the behavior of history expansion. | |
4792 | If the | |
4793 | .B histverify | |
4794 | shell option is enabled (see the description of the | |
4795 | .B shopt | |
4796 | builtin), and | |
4797 | .B readline | |
4798 | is being used, history substitutions are not immediately passed to | |
4799 | the shell parser. | |
4800 | Instead, the expanded line is reloaded into the | |
4801 | .B readline | |
4802 | editing buffer for further modification. | |
4803 | If | |
4804 | .B readline | |
4805 | is being used, and the | |
4806 | .B histreedit | |
4807 | shell option is enabled, a failed history substitution will be reloaded | |
4808 | into the | |
4809 | .B readline | |
4810 | editing buffer for correction. | |
4811 | The | |
4812 | .B \-p | |
4813 | option to the | |
4814 | .B history | |
4815 | builtin command may be used to see what a history expansion will | |
4816 | do before using it. | |
4817 | The | |
4818 | .B \-s | |
4819 | option to the | |
4820 | .B history | |
4821 | builtin may be used to add commands to the end of the history list | |
4822 | without actually executing them, so that they are available for | |
4823 | subsequent recall. | |
726f6388 JA |
4824 | .PP |
4825 | The shell allows control of the various characters used by the | |
4826 | history expansion mechanism (see the description of | |
4827 | .B histchars | |
4828 | above under | |
4829 | .BR "Shell Variables" ). | |
4830 | .SS Event Designators | |
4831 | .PP | |
4832 | An event designator is a reference to a command line entry in the | |
4833 | history list. | |
4834 | .PP | |
4835 | .PD 0 | |
4836 | .TP | |
4837 | .B ! | |
4838 | Start a history substitution, except when followed by a | |
4839 | .BR blank , | |
4840 | newline, = or (. | |
4841 | .TP | |
726f6388 JA |
4842 | .B !\fIn\fR |
4843 | Refer to command line | |
4844 | .IR n . | |
4845 | .TP | |
4846 | .B !\-\fIn\fR | |
4847 | Refer to the current command line minus | |
4848 | .IR n . | |
4849 | .TP | |
ccc6cda3 JA |
4850 | .B !! |
4851 | Refer to the previous command. This is a synonym for `!\-1'. | |
4852 | .TP | |
726f6388 JA |
4853 | .B !\fIstring\fR |
4854 | Refer to the most recent command starting with | |
4855 | .IR string . | |
4856 | .TP | |
4857 | .B !?\fIstring\fR\fB[?]\fR | |
4858 | Refer to the most recent command containing | |
4859 | .IR string . | |
ccc6cda3 JA |
4860 | The trailing \fB?\fP may be omitted if |
4861 | .I string | |
4862 | is followed immediately by a newline. | |
726f6388 JA |
4863 | .TP |
4864 | .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u | |
4865 | Quick substitution. Repeat the last command, replacing | |
4866 | .I string1 | |
4867 | with | |
4868 | .IR string2 . | |
4869 | Equivalent to | |
4870 | ``!!:s/\fIstring1\fP/\fIstring2\fP/'' | |
4871 | (see \fBModifiers\fP below). | |
4872 | .TP | |
4873 | .B !# | |
4874 | The entire command line typed so far. | |
4875 | .PD | |
4876 | .SS Word Designators | |
4877 | .PP | |
ccc6cda3 | 4878 | Word designators are used to select desired words from the event. |
726f6388 JA |
4879 | A |
4880 | .B : | |
ccc6cda3 | 4881 | separates the event specification from the word designator. |
cce855bc | 4882 | It may be omitted if the word designator begins with a |
726f6388 JA |
4883 | .BR ^ , |
4884 | .BR $ , | |
4885 | .BR * , | |
ccc6cda3 | 4886 | .BR \- , |
726f6388 JA |
4887 | or |
4888 | .BR % . | |
4889 | Words are numbered from the beginning of the line, | |
ccc6cda3 JA |
4890 | with the first word being denoted by 0 (zero). |
4891 | Words are inserted into the current line separated by single spaces. | |
726f6388 JA |
4892 | .PP |
4893 | .PD 0 | |
4894 | .TP | |
4895 | .B 0 (zero) | |
4896 | The zeroth word. For the shell, this is the command | |
4897 | word. | |
4898 | .TP | |
4899 | .I n | |
4900 | The \fIn\fRth word. | |
4901 | .TP | |
4902 | .B ^ | |
4903 | The first argument. That is, word 1. | |
4904 | .TP | |
4905 | .B $ | |
4906 | The last argument. | |
4907 | .TP | |
4908 | .B % | |
4909 | The word matched by the most recent `?\fIstring\fR?' search. | |
4910 | .TP | |
4911 | .I x\fB\-\fPy | |
4912 | A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'. | |
4913 | .TP | |
4914 | .B * | |
4915 | All of the words but the zeroth. This is a synonym | |
4916 | for `\fI1\-$\fP'. It is not an error to use | |
4917 | .B * | |
4918 | if there is just one | |
4919 | word in the event; the empty string is returned in that case. | |
4920 | .TP | |
4921 | .B x* | |
4922 | Abbreviates \fIx\-$\fP. | |
4923 | .TP | |
4924 | .B x\- | |
4925 | Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word. | |
4926 | .PD | |
ccc6cda3 JA |
4927 | .PP |
4928 | If a word designator is supplied without an event specification, the | |
4929 | previous command is used as the event. | |
726f6388 JA |
4930 | .SS Modifiers |
4931 | .PP | |
ccc6cda3 JA |
4932 | After the optional word designator, there may appear a sequence of |
4933 | one or more of the following modifiers, each preceded by a `:'. | |
726f6388 JA |
4934 | .PP |
4935 | .PD 0 | |
4936 | .PP | |
4937 | .TP | |
4938 | .B h | |
ccc6cda3 JA |
4939 | Remove a trailing file name component, leaving only the head. |
4940 | .TP | |
4941 | .B t | |
4942 | Remove all leading file name components, leaving the tail. | |
726f6388 JA |
4943 | .TP |
4944 | .B r | |
4945 | Remove a trailing suffix of the form \fI.xxx\fP, leaving the | |
4946 | basename. | |
4947 | .TP | |
4948 | .B e | |
4949 | Remove all but the trailing suffix. | |
4950 | .TP | |
726f6388 JA |
4951 | .B p |
4952 | Print the new command but do not execute it. | |
4953 | .TP | |
4954 | .B q | |
4955 | Quote the substituted words, escaping further substitutions. | |
4956 | .TP | |
cce855bc JA |
4957 | .B x |
4958 | Quote the substituted words as with | |
4959 | .BR q , | |
4960 | but break into words at | |
4961 | .B blanks | |
4962 | and newlines. | |
726f6388 | 4963 | .TP |
cce855bc JA |
4964 | .B s/\fIold\fP/\fInew\fP/ |
4965 | Substitute | |
4966 | .I new | |
4967 | for the first occurrence of | |
4968 | .I old | |
4969 | in the event line. Any delimiter can be used in place of /. The | |
4970 | final delimiter is optional if it is the last character of the | |
4971 | event line. The delimiter may be quoted in | |
4972 | .I old | |
4973 | and | |
4974 | .I new | |
4975 | with a single backslash. If & appears in | |
4976 | .IR new , | |
4977 | it is replaced by | |
4978 | .IR old . | |
4979 | A single backslash will quote the &. If | |
4980 | .I old | |
4981 | is null, it is set to the last | |
4982 | .I old | |
4983 | substituted, or, if no previous history substitutions took place, | |
4984 | the last | |
4985 | .I string | |
4986 | in a | |
4987 | .B !?\fIstring\fR\fB[?]\fR | |
4988 | search. | |
ccc6cda3 | 4989 | .TP |
cce855bc JA |
4990 | .B & |
4991 | Repeat the previous substitution. | |
4992 | .TP | |
4993 | .B g | |
4994 | Cause changes to be applied over the entire event line. This is | |
4995 | used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR') | |
4996 | or `\fB:&\fP'. If used with | |
4997 | `\fB:s\fP', any delimiter can be used | |
4998 | in place of /, and the final delimiter is optional | |
4999 | if it is the last character of the event line. | |
726f6388 | 5000 | .PD |
726f6388 JA |
5001 | .SH "SHELL BUILTIN COMMANDS" |
5002 | .\" start of bash_builtins | |
5003 | .zZ | |
ccc6cda3 JA |
5004 | .PP |
5005 | Unless otherwise noted, each builtin command documented in this | |
5006 | section as accepting options preceded by | |
5007 | .B \- | |
5008 | accepts | |
5009 | .B \-\- | |
5010 | to signify the end of the options. | |
5011 | .sp .5 | |
726f6388 JA |
5012 | .PD 0 |
5013 | .TP | |
5014 | \fB:\fP [\fIarguments\fP] | |
5015 | .PD | |
5016 | No effect; the command does nothing beyond expanding | |
5017 | .I arguments | |
5018 | and performing any specified | |
5019 | redirections. A zero exit code is returned. | |
5020 | .TP | |
5021 | .PD 0 | |
5022 | \fB .\| \fP \fIfilename\fP [\fIarguments\fP] | |
5023 | .TP | |
5024 | \fBsource\fP \fIfilename\fP [\fIarguments\fP] | |
5025 | .PD | |
5026 | Read and execute commands from | |
5027 | .I filename | |
5028 | in the current | |
5029 | shell environment and return the exit status of the last command | |
5030 | executed from | |
5031 | .IR filename . | |
5032 | If | |
5033 | .I filename | |
ccc6cda3 | 5034 | does not contain a slash, file names in |
726f6388 JA |
5035 | .SM |
5036 | .B PATH | |
5037 | are used to find the directory containing | |
5038 | .IR filename . | |
5039 | The file searched for in | |
5040 | .SM | |
5041 | .B PATH | |
5042 | need not be executable. The current directory is | |
5043 | searched if no file is found in | |
5044 | .SM | |
5045 | .BR PATH . | |
ccc6cda3 JA |
5046 | If the |
5047 | .B sourcepath | |
5048 | option to the | |
5049 | .B shopt | |
5050 | builtin command is turned off, the | |
5051 | .SM | |
5052 | .B PATH | |
5053 | is not searched. | |
726f6388 | 5054 | If any \fIarguments\fP are supplied, they become the positional |
ccc6cda3 | 5055 | parameters when \fIfilename\fP is executed. Otherwise the positional |
726f6388 JA |
5056 | parameters are unchanged. |
5057 | The return status is the status of the last command exited within | |
5058 | the script (0 if no commands are executed), and false if | |
5059 | .I filename | |
cce855bc | 5060 | is not found or cannot be read. |
726f6388 | 5061 | .TP |
ccc6cda3 JA |
5062 | \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] |
5063 | \fBAlias\fP with no arguments or with the | |
5064 | .B \-p | |
5065 | option prints the list of aliases in the form | |
5066 | \fBalias\fP \fIname\fP=\fIvalue\fP on standard output. | |
5067 | When arguments are supplied, an alias is defined for | |
5068 | each \fIname\fP whose \fIvalue\fP is given. | |
5069 | A trailing space in \fIvalue\fP causes the next word to be | |
5070 | checked for alias substitution when the alias is expanded. | |
5071 | For each \fIname\fP in the argument list for which no \fIvalue\fP | |
5072 | is supplied, the name and value of the alias is printed. | |
5073 | \fBAlias\fP returns true unless a \fIname\fP is given for which | |
5074 | no alias has been defined. | |
726f6388 JA |
5075 | .TP |
5076 | \fBbg\fP [\fIjobspec\fP] | |
cce855bc JA |
5077 | Resume the suspended job \fIjobspec\fP in the background, as if it |
5078 | had been started with | |
726f6388 JA |
5079 | .BR & . |
5080 | If \fIjobspec\fP is not present, the shell's notion of the | |
5081 | \fIcurrent job\fP is used. | |
5082 | .B bg | |
5083 | .I jobspec | |
5084 | returns 0 unless run when job control is disabled or, when run with | |
5085 | job control enabled, if \fIjobspec\fP was not found or started without | |
5086 | job control. | |
5087 | .TP | |
5088 | .PD 0 | |
cce855bc JA |
5089 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP] |
5090 | .TP | |
5091 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP] | |
726f6388 | 5092 | .TP |
ccc6cda3 | 5093 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP |
726f6388 | 5094 | .TP |
ccc6cda3 | 5095 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP |
726f6388 JA |
5096 | .PD |
5097 | Display current | |
5098 | .B readline | |
5099 | key and function bindings, or bind a key sequence to a | |
5100 | .B readline | |
5101 | function or macro. The binding syntax accepted is identical to that of | |
5102 | .IR .inputrc , | |
5103 | but each binding must be passed as a separate argument; | |
ccc6cda3 | 5104 | e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. Options, if supplied, have the |
726f6388 JA |
5105 | following meanings: |
5106 | .RS | |
5107 | .PD 0 | |
5108 | .TP | |
5109 | .B \-m \fIkeymap\fP | |
5110 | Use | |
5111 | .I keymap | |
5112 | as the keymap to be affected by the subsequent bindings. | |
5113 | Acceptable | |
5114 | .I keymap | |
5115 | names are | |
ccc6cda3 JA |
5116 | \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, |
5117 | vi\-command\fP, and | |
5118 | .IR vi\-insert . | |
5119 | \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is | |
5120 | equivalent to \fIemacs\-standard\fP. | |
726f6388 JA |
5121 | .TP |
5122 | .B \-l | |
ccc6cda3 JA |
5123 | List the names of all \fBreadline\fP functions. |
5124 | .TP | |
5125 | .B \-p | |
5126 | Display \fBreadline\fP function names and bindings in such a way | |
5127 | that they can be re-read. | |
5128 | .TP | |
5129 | .B \-P | |
5130 | List current \fBreadline\fP function names and bindings. | |
726f6388 JA |
5131 | .TP |
5132 | .B \-v | |
ccc6cda3 JA |
5133 | Display \fBreadline\fP variable names and values in such a way that they |
5134 | can be re-read. | |
726f6388 | 5135 | .TP |
ccc6cda3 JA |
5136 | .B \-V |
5137 | List current \fBreadline\fP variable names and values. | |
5138 | .TP | |
5139 | .B \-s | |
5140 | Display \fBreadline\fP key sequences bound to macros and the strings | |
5141 | they output in such a way that they can be re-read. | |
5142 | .TP | |
5143 | .B \-S | |
5144 | Display \fBreadline\fP key sequences bound to macros and the strings | |
5145 | they output. | |
726f6388 JA |
5146 | .TP |
5147 | .B \-f \fIfilename\fP | |
ccc6cda3 | 5148 | Read key bindings from \fIfilename\fP. |
726f6388 JA |
5149 | .TP |
5150 | .B \-q \fIfunction\fP | |
ccc6cda3 JA |
5151 | Query about which keys invoke the named \fIfunction\fP. |
5152 | .TP | |
cce855bc JA |
5153 | .B \-u \fIfunction\fP |
5154 | Unbind all keys bound to the named \fIfunction\fP. | |
5155 | .TP | |
ccc6cda3 JA |
5156 | .B \-r \fIkeyseq\fP |
5157 | Remove any current binding for \fIkeyseq\fP. | |
726f6388 JA |
5158 | .PD |
5159 | .PP | |
5160 | The return value is 0 unless an unrecognized option is given or an | |
5161 | error occurred. | |
5162 | .RE | |
5163 | .TP | |
5164 | \fBbreak\fP [\fIn\fP] | |
5165 | Exit from within a | |
5166 | .BR for , | |
5167 | .BR while , | |
ccc6cda3 | 5168 | .BR until , |
726f6388 | 5169 | or |
ccc6cda3 | 5170 | .B select |
726f6388 JA |
5171 | loop. If \fIn\fP is specified, break \fIn\fP levels. |
5172 | .I n | |
5173 | must be \(>= 1. If | |
5174 | .I n | |
5175 | is greater than the number of enclosing loops, all enclosing loops | |
5176 | are exited. The return value is 0 unless the shell is not executing | |
5177 | a loop when | |
5178 | .B break | |
5179 | is executed. | |
5180 | .TP | |
5181 | \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP] | |
5182 | Execute the specified shell builtin, passing it | |
5183 | .IR arguments , | |
5184 | and return its exit status. | |
cce855bc | 5185 | This is useful when defining a |
726f6388 | 5186 | function whose name is the same as a shell builtin, |
cce855bc JA |
5187 | retaining the functionality of the builtin within the function. |
5188 | The \fBcd\fP builtin is commonly redefined this way. | |
5189 | The return status is false if | |
726f6388 JA |
5190 | .I shell\-builtin |
5191 | is not a shell builtin command. | |
5192 | .TP | |
ccc6cda3 | 5193 | \fBcd\fP [\fB\-LP\fP] [\fIdir\fP] |
726f6388 JA |
5194 | Change the current directory to \fIdir\fP. The variable |
5195 | .SM | |
5196 | .B HOME | |
5197 | is the | |
5198 | default | |
5199 | .IR dir . | |
5200 | The variable | |
5201 | .SM | |
5202 | .B CDPATH | |
ccc6cda3 | 5203 | defines the search path for the directory containing |
726f6388 | 5204 | .IR dir . |
ccc6cda3 JA |
5205 | Alternative directory names in |
5206 | .SM | |
5207 | .B CDPATH | |
5208 | are separated by a colon (:). A null directory name in | |
726f6388 JA |
5209 | .SM |
5210 | .B CDPATH | |
ccc6cda3 | 5211 | is the same as the current directory, i.e., ``\fB.\fP''. If |
726f6388 JA |
5212 | .I dir |
5213 | begins with a slash (/), | |
5214 | then | |
5215 | .SM | |
5216 | .B CDPATH | |
ccc6cda3 JA |
5217 | is not used. The |
5218 | .B \-P | |
5219 | option says to use the physical directory structure instead of | |
5220 | following symbolic links (see also the | |
5221 | .B \-P | |
5222 | option to the | |
5223 | .B set | |
5224 | builtin command); the | |
5225 | .B \-L | |
5226 | option forces symbolic links to be followed. An argument of | |
726f6388 JA |
5227 | .B \- |
5228 | is equivalent to | |
5229 | .SM | |
5230 | .BR $OLDPWD . | |
5231 | The return value is true if the directory was successfully changed; | |
5232 | false otherwise. | |
5233 | .TP | |
ccc6cda3 | 5234 | \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...] |
726f6388 JA |
5235 | Run |
5236 | .I command | |
5237 | with | |
5238 | .I args | |
5239 | suppressing the normal shell function lookup. Only builtin | |
5240 | commands or commands found in the | |
5241 | .SM | |
5242 | .B PATH | |
5243 | are executed. If the | |
5244 | .B \-p | |
5245 | option is given, the search for | |
5246 | .I command | |
5247 | is performed using a default value for | |
5248 | .B PATH | |
5249 | that is guaranteed to find all of the standard utilities. | |
5250 | If either the | |
5251 | .B \-V | |
5252 | or | |
5253 | .B \-v | |
5254 | option is supplied, a description of | |
5255 | .I command | |
5256 | is printed. The | |
5257 | .B \-v | |
ccc6cda3 | 5258 | option causes a single word indicating the command or file name |
726f6388 JA |
5259 | used to invoke |
5260 | .I command | |
cce855bc | 5261 | to be displayed; the |
726f6388 JA |
5262 | .B \-V |
5263 | option produces a more verbose description. | |
726f6388 JA |
5264 | If the |
5265 | .B \-V | |
5266 | or | |
5267 | .B \-v | |
5268 | option is supplied, the exit status is 0 if | |
5269 | .I command | |
5270 | was found, and 1 if not. If neither option is supplied and | |
5271 | an error occurred or | |
5272 | .I command | |
5273 | cannot be found, the exit status is 127. Otherwise, the exit status of the | |
5274 | .B command | |
5275 | builtin is the exit status of | |
5276 | .IR command . | |
5277 | .TP | |
5278 | \fBcontinue\fP [\fIn\fP] | |
5279 | Resume the next iteration of the enclosing | |
5280 | .BR for , | |
5281 | .BR while , | |
ccc6cda3 | 5282 | .BR until , |
726f6388 | 5283 | or |
ccc6cda3 | 5284 | .B select |
726f6388 JA |
5285 | loop. |
5286 | If | |
5287 | .I n | |
5288 | is specified, resume at the \fIn\fPth enclosing loop. | |
5289 | .I n | |
5290 | must be \(>= 1. If | |
5291 | .I n | |
5292 | is greater than the number of enclosing loops, the last enclosing loop | |
ccc6cda3 | 5293 | (the ``top-level'' loop) is resumed. The return value is 0 unless the |
726f6388 JA |
5294 | shell is not executing a loop when |
5295 | .B continue | |
5296 | is executed. | |
5297 | .TP | |
5298 | .PD 0 | |
ccc6cda3 | 5299 | \fBdeclare\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]] |
726f6388 | 5300 | .TP |
ccc6cda3 | 5301 | \fBtypeset\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]] |
726f6388 | 5302 | .PD |
ccc6cda3 JA |
5303 | Declare variables and/or give them attributes. |
5304 | If no \fIname\fPs are given then display the values of variables. | |
5305 | The | |
5306 | .B \-p | |
5307 | option will display the attributes and values of each | |
5308 | .IR name . | |
5309 | When | |
5310 | .B \-p | |
5311 | is used, additional options are ignored. | |
5312 | The | |
5313 | .B \-F | |
5314 | option inhibits the display of function definitions; only the | |
5315 | function name and attributes are printed. | |
5316 | The | |
5317 | .B \-F | |
5318 | option implies | |
5319 | .BR \-f . | |
5320 | The following options can | |
5321 | be used to restrict output to variables with the specified attribute or | |
5322 | to give variables attributes: | |
726f6388 JA |
5323 | .RS |
5324 | .PD 0 | |
5325 | .TP | |
ccc6cda3 JA |
5326 | .B \-a |
5327 | Each \fIname\fP is an array variable (see | |
5328 | .B Arrays | |
5329 | above). | |
5330 | .TP | |
726f6388 | 5331 | .B \-f |
ccc6cda3 JA |
5332 | Use function names only. |
5333 | .TP | |
5334 | .B \-i | |
5335 | The variable is treated as an integer; arithmetic evaluation (see | |
5336 | .SM | |
5337 | .B "ARITHMETIC EVALUATION" ") " | |
5338 | is performed when the variable is assigned a value. | |
726f6388 JA |
5339 | .TP |
5340 | .B \-r | |
5341 | Make \fIname\fPs readonly. These names cannot then be assigned values | |
cce855bc | 5342 | by subsequent assignment statements or unset. |
726f6388 JA |
5343 | .TP |
5344 | .B \-x | |
5345 | Mark \fIname\fPs for export to subsequent commands via the environment. | |
726f6388 JA |
5346 | .PD |
5347 | .PP | |
5348 | Using `+' instead of `\-' | |
ccc6cda3 JA |
5349 | turns off the attribute instead, with the exception that \fB+a\fP |
5350 | may not be used to destroy an array variable. When used in a function, | |
5351 | makes each | |
5352 | \fIname\fP local, as with the | |
726f6388 | 5353 | .B local |
cce855bc | 5354 | command. The return value is 0 unless an invalid option is encountered, |
ccc6cda3 JA |
5355 | an attempt is made to define a function using "\-f foo=bar", |
5356 | an attempt is made to assign a value to a readonly variable, | |
5357 | an attempt is made to assign a value to an array variable without | |
5358 | using the compound assignment syntax (see | |
5359 | .B Arrays | |
cce855bc | 5360 | above), one of the \fInames\fP is not a valid shell variable name, |
726f6388 | 5361 | an attempt is made to turn off readonly status for a readonly variable, |
ccc6cda3 JA |
5362 | an attempt is made to turn off array status for an array variable, |
5363 | or an attempt is made to display a non-existent function with \-f. | |
726f6388 JA |
5364 | .RE |
5365 | .TP | |
ccc6cda3 JA |
5366 | .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP] |
5367 | Without options, displays the list of currently remembered directories. | |
5368 | The default display is on a single line with directory names separated | |
5369 | by spaces. | |
5370 | Directories are added to the list with the | |
726f6388 JA |
5371 | .B pushd |
5372 | command; the | |
5373 | .B popd | |
ccc6cda3 | 5374 | command removes entries from the list. |
726f6388 JA |
5375 | .RS |
5376 | .PD 0 | |
5377 | .TP | |
ccc6cda3 JA |
5378 | \fB+\fP\fIn\fP |
5379 | Displays the \fIn\fPth entry counting from the left of the list | |
726f6388 JA |
5380 | shown by |
5381 | .B dirs | |
5382 | when invoked without options, starting with zero. | |
5383 | .TP | |
ccc6cda3 JA |
5384 | \fB\-\fP\fIn\fP |
5385 | Displays the \fIn\fPth entry counting from the right of the list | |
726f6388 JA |
5386 | shown by |
5387 | .B dirs | |
5388 | when invoked without options, starting with zero. | |
5389 | .TP | |
ccc6cda3 JA |
5390 | .B \-c |
5391 | Clears the directory stack by deleting all of the entries. | |
5392 | .TP | |
726f6388 | 5393 | .B \-l |
ccc6cda3 | 5394 | Produces a longer listing; the default listing format uses a |
726f6388 | 5395 | tilde to denote the home directory. |
ccc6cda3 JA |
5396 | .TP |
5397 | .B \-p | |
5398 | Print the directory stack with one entry per line. | |
5399 | .TP | |
5400 | .B \-v | |
5401 | Print the directory stack with one entry per line, | |
5402 | prefixing each entry with its index in the stack. | |
726f6388 JA |
5403 | .PD |
5404 | .PP | |
5405 | The return value is 0 unless an | |
cce855bc | 5406 | invalid option is supplied or \fIn\fP indexes beyond the end |
726f6388 JA |
5407 | of the directory stack. |
5408 | .RE | |
5409 | .TP | |
cce855bc | 5410 | \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...] |
ccc6cda3 JA |
5411 | Without options, each |
5412 | .I jobspec | |
5413 | is removed from the table of active jobs. | |
cce855bc JA |
5414 | If the \fB\-h\fP option is given, each |
5415 | .I jobspec | |
5416 | is not removed from the table, but is marked so that | |
ccc6cda3 JA |
5417 | .SM |
5418 | .B SIGHUP | |
5419 | is not sent to the job if the shell receives a | |
5420 | .SM | |
5421 | .BR SIGHUP . | |
5422 | If no | |
5423 | .I jobspec | |
cce855bc JA |
5424 | is present, and neither the |
5425 | .B \-a | |
5426 | nor the | |
5427 | .B \-r | |
5428 | option is supplied, the \fIcurrent job\fP is used. | |
5429 | If no | |
5430 | .I jobspec | |
5431 | is supplied, the | |
5432 | .B \-a | |
5433 | option means to remove or mark all jobs; the | |
5434 | .B \-r | |
5435 | option without a | |
5436 | .I jobspec | |
5437 | argument restricts operation to running jobs. | |
5438 | The return value is 0 unless a | |
ccc6cda3 JA |
5439 | .I jobspec |
5440 | does not specify a valid job. | |
5441 | .TP | |
726f6388 | 5442 | \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...] |
ccc6cda3 JA |
5443 | Output the \fIarg\fPs, separated by spaces, followed by a newline. |
5444 | The return status is always 0. | |
5445 | If \fB\-n\fP is specified, the trailing newline is | |
726f6388 JA |
5446 | suppressed. If the \fB\-e\fP option is given, interpretation of |
5447 | the following backslash-escaped characters is enabled. The | |
5448 | .B \-E | |
5449 | option disables the interpretation of these escape characters, | |
5450 | even on systems where they are interpreted by default. | |
ccc6cda3 JA |
5451 | .B echo |
5452 | does not interpret | |
5453 | .B \-\- | |
5454 | to mean the end of options. | |
5455 | .B echo | |
5456 | interprets the following escape sequences: | |
726f6388 JA |
5457 | .RS |
5458 | .PD 0 | |
5459 | .TP | |
5460 | .B \ea | |
5461 | alert (bell) | |
5462 | .TP | |
5463 | .B \eb | |
5464 | backspace | |
5465 | .TP | |
5466 | .B \ec | |
5467 | suppress trailing newline | |
5468 | .TP | |
ccc6cda3 JA |
5469 | .B \ee |
5470 | an escape character | |
5471 | .TP | |
726f6388 JA |
5472 | .B \ef |
5473 | form feed | |
5474 | .TP | |
5475 | .B \en | |
5476 | new line | |
5477 | .TP | |
5478 | .B \er | |
5479 | carriage return | |
5480 | .TP | |
5481 | .B \et | |
5482 | horizontal tab | |
5483 | .TP | |
5484 | .B \ev | |
5485 | vertical tab | |
5486 | .TP | |
5487 | .B \e\e | |
5488 | backslash | |
5489 | .TP | |
cce855bc JA |
5490 | .B \e\fInnn\fP |
5491 | the character whose ASCII code is the octal value \fInnn\fP | |
5492 | (one to three digits) | |
5493 | .TP | |
5494 | .B \ex\fInnn\fP | |
5495 | the character whose ASCII code is the hexadecimal value \fInnn\fP | |
5496 | (one to three digits) | |
726f6388 JA |
5497 | .PD |
5498 | .RE | |
5499 | .TP | |
ccc6cda3 | 5500 | \fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...] |
cce855bc JA |
5501 | Enable and disable builtin shell commands. |
5502 | Disabling a builtin allows a disk command which has the same name | |
5503 | as a shell builtin to be executed with specifying a full pathname, | |
5504 | even though the shell normally searches for builtins before disk commands. | |
726f6388 JA |
5505 | If \fB\-n\fP is used, each \fIname\fP |
5506 | is disabled; otherwise, | |
5507 | \fInames\fP are enabled. For example, to use the | |
5508 | .B test | |
5509 | binary found via the | |
5510 | .SM | |
5511 | .B PATH | |
ccc6cda3 JA |
5512 | instead of the shell builtin version, run |
5513 | \f(CWenable -n test\fP. | |
5514 | The | |
5515 | .B \-f | |
5516 | option means to load the new builtin command | |
5517 | .I name | |
5518 | from shared object | |
5519 | .IR filename , | |
5520 | on systems that support dynamic loading. The | |
5521 | .B \-d | |
5522 | option will delete a builtin previously loaded with | |
5523 | .BR \-f . | |
5524 | If no \fIname\fP arguments are given, or if the | |
5525 | .B \-p | |
5526 | option is supplied, a list of shell builtins is printed. | |
5527 | With no other option arguments, the list consists of all enabled | |
5528 | shell builtins. | |
5529 | If \fB\-n\fP is supplied, only disabled builtins are printed. | |
5530 | If \fB\-a\fP is supplied, the list printed includes all builtins, with an | |
726f6388 | 5531 | indication of whether or not each is enabled. |
ccc6cda3 JA |
5532 | If \fB\-s\fP is supplied, the output is restricted to the POSIX |
5533 | \fIspecial\fP builtins. | |
726f6388 JA |
5534 | The return value is 0 unless a |
5535 | .I name | |
ccc6cda3 JA |
5536 | is not a shell builtin or there is a problem loading a new builtin |
5537 | from a shared object. | |
726f6388 JA |
5538 | .TP |
5539 | \fBeval\fP [\fIarg\fP ...] | |
5540 | The \fIarg\fPs are read and concatenated together into a single | |
5541 | command. This command is then read and executed by the shell, and | |
ccc6cda3 JA |
5542 | its exit status is returned as the value of |
5543 | .BR eval . | |
5544 | If there are no | |
726f6388 JA |
5545 | .IR args , |
5546 | or only null arguments, | |
5547 | .B eval | |
ccc6cda3 | 5548 | returns 0. |
726f6388 | 5549 | .TP |
cce855bc | 5550 | \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]] |
726f6388 JA |
5551 | If |
5552 | .I command | |
5553 | is specified, it replaces the shell. | |
5554 | No new process is created. The | |
5555 | .I arguments | |
5556 | become the arguments to \fIcommand\fP. | |
ccc6cda3 JA |
5557 | If the |
5558 | .B \-l | |
5559 | option is supplied, | |
726f6388 JA |
5560 | the shell places a dash in the zeroth arg passed to |
5561 | .IR command . | |
ccc6cda3 JA |
5562 | This is what |
5563 | .IR login (1) | |
5564 | does. The | |
5565 | .B \-c | |
5566 | option causes | |
5567 | .I command | |
5568 | to be executed with an empty environment. If | |
5569 | .B \-a | |
5570 | is supplied, the shell passes | |
5571 | .I name | |
5572 | as the zeroth argument to the executed command. If | |
5573 | .I command | |
726f6388 | 5574 | cannot be executed for some reason, a non-interactive shell exits, |
ccc6cda3 JA |
5575 | unless the shell option |
5576 | .B execfail | |
5577 | is enabled, in which case it returns failure. | |
5578 | An interactive shell returns failure if the file cannot be executed. | |
726f6388 JA |
5579 | If |
5580 | .I command | |
5581 | is not specified, any redirections take effect in the current shell, | |
cce855bc JA |
5582 | and the return status is 0. If there is a redirection error, the |
5583 | return status is 1. | |
726f6388 JA |
5584 | .TP |
5585 | \fBexit\fP [\fIn\fP] | |
5586 | Cause the shell to exit | |
5587 | with a status of \fIn\fP. If | |
5588 | .I n | |
5589 | is omitted, the exit status | |
5590 | is that of the last command executed. | |
5591 | A trap on | |
5592 | .SM | |
5593 | .B EXIT | |
5594 | is executed before the shell terminates. | |
5595 | .TP | |
5596 | .PD 0 | |
ccc6cda3 | 5597 | \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ... |
726f6388 JA |
5598 | .TP |
5599 | .B export \-p | |
5600 | .PD | |
5601 | The supplied | |
5602 | .I names | |
5603 | are marked for automatic export to the environment of | |
5604 | subsequently executed commands. If the | |
5605 | .B \-f | |
5606 | option is given, | |
5607 | the | |
5608 | .I names | |
5609 | refer to functions. | |
5610 | If no | |
5611 | .I names | |
5612 | are given, or if the | |
5613 | .B \-p | |
5614 | option is supplied, a list | |
5615 | of all names that are exported in this shell is printed. | |
5616 | The | |
5617 | .B \-n | |
5618 | option causes the export property to be removed from the | |
ccc6cda3 | 5619 | named variables. |
726f6388 | 5620 | .B export |
cce855bc | 5621 | returns an exit status of 0 unless an invalid option is |
726f6388 | 5622 | encountered, |
cce855bc | 5623 | one of the \fInames\fP is not a valid shell variable name, or |
726f6388 JA |
5624 | .B \-f |
5625 | is supplied with a | |
5626 | .I name | |
5627 | that is not a function. | |
5628 | .TP | |
5629 | .PD 0 | |
5630 | \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP] | |
5631 | .TP | |
5632 | \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP] | |
5633 | .PD | |
5634 | Fix Command. In the first form, a range of commands from | |
5635 | .I first | |
5636 | to | |
5637 | .I last | |
5638 | is selected from the history list. | |
5639 | .I First | |
5640 | and | |
5641 | .I last | |
5642 | may be specified as a string (to locate the last command beginning | |
5643 | with that string) or as a number (an index into the history list, | |
5644 | where a negative number is used as an offset from the current | |
5645 | command number). If | |
5646 | .I last | |
5647 | is not specified it is set to | |
5648 | the current command for listing (so that | |
5649 | .B fc \-l \-10 | |
5650 | prints the last 10 commands) and to | |
5651 | .I first | |
5652 | otherwise. | |
5653 | If | |
5654 | .I first | |
5655 | is not specified it is set to the previous | |
5656 | command for editing and \-16 for listing. | |
5657 | .sp 1 | |
5658 | The | |
5659 | .B \-n | |
cce855bc | 5660 | option suppresses |
726f6388 JA |
5661 | the command numbers when listing. The |
5662 | .B \-r | |
cce855bc | 5663 | option reverses the order of |
726f6388 JA |
5664 | the commands. If the |
5665 | .B \-l | |
cce855bc | 5666 | option is given, |
726f6388 JA |
5667 | the commands are listed on |
5668 | standard output. Otherwise, the editor given by | |
5669 | .I ename | |
5670 | is invoked | |
5671 | on a file containing those commands. If | |
5672 | .I ename | |
5673 | is not given, the | |
5674 | value of the | |
5675 | .SM | |
5676 | .B FCEDIT | |
5677 | variable is used, and | |
5678 | the value of | |
5679 | .SM | |
5680 | .B EDITOR | |
5681 | if | |
5682 | .SM | |
5683 | .B FCEDIT | |
5684 | is not set. If neither variable is set, | |
5685 | .FN vi | |
5686 | is used. When editing is complete, the edited commands are | |
5687 | echoed and executed. | |
5688 | .sp 1 | |
5689 | In the second form, \fIcommand\fP is re-executed after each instance | |
5690 | of \fIpat\fP is replaced by \fIrep\fP. | |
ccc6cda3 JA |
5691 | A useful alias to use with this is |
5692 | .if n ``r=fc -s'', | |
5693 | .if t \f(CWr='fc \-s'\fP, | |
5694 | so that typing | |
5695 | .if n ``r cc'' | |
5696 | .if t \f(CWr cc\fP | |
5697 | runs the last command beginning with | |
5698 | .if n ``cc'' | |
5699 | .if t \f(CWcc\fP | |
5700 | and typing | |
5701 | .if n ``r'' | |
5702 | .if t \f(CWr\fP | |
726f6388 JA |
5703 | re-executes the last command. |
5704 | .sp 1 | |
cce855bc | 5705 | If the first form is used, the return value is 0 unless an invalid |
726f6388 JA |
5706 | option is encountered or |
5707 | .I first | |
5708 | or | |
5709 | .I last | |
5710 | specify history lines out of range. | |
5711 | If the | |
5712 | .B \-e | |
5713 | option is supplied, the return value is the value of the last | |
5714 | command executed or failure if an error occurs with the temporary | |
5715 | file of commands. If the second form is used, the return status | |
5716 | is that of the command re-executed, unless | |
5717 | .I cmd | |
5718 | does not specify a valid history line, in which case | |
5719 | .B fc | |
5720 | returns failure. | |
5721 | .TP | |
5722 | \fBfg\fP [\fIjobspec\fP] | |
cce855bc | 5723 | Resume |
726f6388 | 5724 | .I jobspec |
cce855bc JA |
5725 | in the foreground, and make it the current job. |
5726 | If | |
726f6388 JA |
5727 | .I jobspec |
5728 | is not present, the shell's notion of the \fIcurrent job\fP is used. | |
5729 | The return value is that of the command placed into the foreground, | |
5730 | or failure if run when job control is disabled or, when run with | |
5731 | job control enabled, if | |
5732 | .I jobspec | |
5733 | does not specify a valid job or | |
5734 | .I jobspec | |
5735 | specifies a job that was started without job control. | |
5736 | .TP | |
5737 | \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP] | |
5738 | .B getopts | |
5739 | is used by shell procedures to parse positional parameters. | |
5740 | .I optstring | |
5741 | contains the option letters to be recognized; if a letter | |
5742 | is followed by a colon, the option is expected to have an | |
5743 | argument, which should be separated from it by white space. | |
5744 | Each time it is invoked, | |
5745 | .B getopts | |
5746 | places the next option in the shell variable | |
5747 | .IR name , | |
5748 | initializing | |
5749 | .I name | |
5750 | if it does not exist, | |
5751 | and the index of the next argument to be processed into the | |
5752 | variable | |
5753 | .SM | |
5754 | .BR OPTIND . | |
5755 | .SM | |
5756 | .B OPTIND | |
5757 | is initialized to 1 each time the shell or a shell script | |
5758 | is invoked. When an option requires an argument, | |
5759 | .B getopts | |
5760 | places that argument into the variable | |
5761 | .SM | |
5762 | .BR OPTARG . | |
5763 | The shell does not reset | |
5764 | .SM | |
5765 | .B OPTIND | |
5766 | automatically; it must be manually reset between multiple | |
5767 | calls to | |
5768 | .B getopts | |
5769 | within the same shell invocation if a new set of parameters | |
5770 | is to be used. | |
5771 | .sp 1 | |
cce855bc JA |
5772 | When the end of options is encountered, \fBgetopts\fP exits with a |
5773 | return value greater than zero. | |
5774 | \fBOPTIND\fP is set to the index of the first non-option argument, | |
5775 | and \fBname\fP is set to ?. | |
5776 | .sp 1 | |
5777 | .B getopts | |
5778 | normally parses the positional parameters, but if more arguments are | |
5779 | given in | |
5780 | .IR args , | |
5781 | .B getopts | |
5782 | parses those instead. | |
5783 | .sp 1 | |
726f6388 JA |
5784 | .B getopts |
5785 | can report errors in two ways. If the first character of | |
5786 | .I optstring | |
5787 | is a colon, | |
5788 | .I silent | |
5789 | error reporting is used. In normal operation diagnostic messages | |
cce855bc | 5790 | are printed when invalid options or missing option arguments are |
726f6388 JA |
5791 | encountered. |
5792 | If the variable | |
5793 | .SM | |
5794 | .B OPTERR | |
cce855bc | 5795 | is set to 0, no error messages will be displayed, even if the first |
726f6388 JA |
5796 | character of |
5797 | .I optstring | |
5798 | is not a colon. | |
5799 | .sp 1 | |
cce855bc | 5800 | If an invalid option is seen, |
726f6388 JA |
5801 | .B getopts |
5802 | places ? into | |
5803 | .I name | |
5804 | and, if not silent, | |
5805 | prints an error message and unsets | |
5806 | .SM | |
5807 | .BR OPTARG . | |
5808 | If | |
5809 | .B getopts | |
5810 | is silent, | |
5811 | the option character found is placed in | |
5812 | .SM | |
5813 | .B OPTARG | |
5814 | and no diagnostic message is printed. | |
5815 | .sp 1 | |
5816 | If a required argument is not found, and | |
5817 | .B getopts | |
5818 | is not silent, | |
5819 | a question mark (\^\fB?\fP\^) is placed in | |
5820 | .IR name , | |
5821 | .B OPTARG | |
5822 | is unset, and a diagnostic message is printed. | |
5823 | If | |
5824 | .B getopts | |
5825 | is silent, then a colon (\^\fB:\fP\^) is placed in | |
5826 | .I name | |
5827 | and | |
5828 | .SM | |
5829 | .B OPTARG | |
5830 | is set to the option character found. | |
5831 | .sp 1 | |
5832 | .B getopts | |
726f6388 JA |
5833 | returns true if an option, specified or unspecified, is found. |
5834 | It returns false if the end of options is encountered or an | |
5835 | error occurs. | |
5836 | .TP | |
ccc6cda3 | 5837 | \fBhash\fP [\fB\-r\fP] [\fB\-p\fP \fIfilename\fP] [\fIname\fP] |
726f6388 JA |
5838 | For each |
5839 | .IR name , | |
ccc6cda3 JA |
5840 | the full file name of the command is determined by searching |
5841 | the directories in | |
5842 | .B $PATH | |
5843 | and remembered. | |
5844 | If the | |
5845 | .B \-p | |
5846 | option is supplied, no path search is performed, and | |
5847 | .I filename | |
5848 | is used as the full file name of the command. | |
5849 | The | |
726f6388 JA |
5850 | .B \-r |
5851 | option causes the shell to forget all | |
5852 | remembered locations. If no arguments are given, information | |
5853 | about remembered commands is printed. | |
ccc6cda3 | 5854 | The return status is true unless a |
726f6388 | 5855 | .I name |
cce855bc | 5856 | is not found or an invalid option is supplied. |
726f6388 JA |
5857 | .TP |
5858 | \fBhelp\fP [\fIpattern\fP] | |
5859 | Display helpful information about builtin commands. If | |
5860 | .I pattern | |
5861 | is specified, | |
5862 | .B help | |
5863 | gives detailed help on all commands matching | |
5864 | .IR pattern ; | |
ccc6cda3 JA |
5865 | otherwise help for all the builtins and shell control structures |
5866 | is printed. The return status is 0 unless no command matches | |
726f6388 JA |
5867 | .IR pattern . |
5868 | .TP | |
5869 | .PD 0 | |
ccc6cda3 JA |
5870 | \fBhistory\fP [\fB\-c\fP] [\fIn\fP] |
5871 | .TP | |
5872 | \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP] | |
726f6388 | 5873 | .TP |
ccc6cda3 JA |
5874 | \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP] |
5875 | .TP | |
5876 | \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP] | |
726f6388 JA |
5877 | .PD |
5878 | With no options, display the command | |
5879 | history list with line numbers. Lines listed | |
5880 | with a | |
5881 | .B * | |
5882 | have been modified. An argument of | |
5883 | .I n | |
5884 | lists only the last | |
5885 | .I n | |
ccc6cda3 | 5886 | lines. If \fIfilename\fP is supplied, it is used as the |
726f6388 JA |
5887 | name of the history file; if not, the value of |
5888 | .SM | |
5889 | .B HISTFILE | |
5890 | is used. Options, if supplied, have the following meanings: | |
5891 | .RS | |
5892 | .PD 0 | |
5893 | .TP | |
5894 | .B \-a | |
5895 | Append the ``new'' history lines (history lines entered since the | |
ccc6cda3 | 5896 | beginning of the current \fBbash\fP session) to the history file. |
726f6388 JA |
5897 | .TP |
5898 | .B \-n | |
5899 | Read the history lines not already read from the history | |
5900 | file into the current history list. These are lines | |
5901 | appended to the history file since the beginning of the | |
5902 | current \fBbash\fP session. | |
5903 | .TP | |
5904 | .B \-r | |
5905 | Read the contents of the history file | |
ccc6cda3 | 5906 | and use them as the current history. |
726f6388 JA |
5907 | .TP |
5908 | .B \-w | |
5909 | Write the current history to the history file, overwriting the | |
5910 | history file's contents. | |
ccc6cda3 JA |
5911 | .TP |
5912 | .B \-c | |
5913 | Clear the history list by deleting all the entries. | |
5914 | .TP | |
5915 | .B \-p | |
5916 | Perform history substitution on the following \fIargs\fP and display | |
5917 | the result on the standard output. | |
5918 | Does not store the results in the history list. | |
5919 | Each \fIarg\fP must be quoted to disable normal history expansion. | |
5920 | .TP | |
5921 | .B \-s | |
5922 | Store the | |
5923 | .I args | |
5924 | in the history list as a single entry. The last command in the | |
5925 | history list is removed before the | |
5926 | .I args | |
5927 | are added. | |
726f6388 JA |
5928 | .PD |
5929 | .PP | |
cce855bc | 5930 | The return value is 0 unless an invalid option is encountered or an |
726f6388 JA |
5931 | error occurs while reading or writing the history file. |
5932 | .RE | |
5933 | .TP | |
5934 | .PD 0 | |
ccc6cda3 | 5935 | \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ] |
726f6388 JA |
5936 | .TP |
5937 | \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ] | |
5938 | .PD | |
ccc6cda3 JA |
5939 | The first form lists the active jobs. The options have the following |
5940 | meanings: | |
5941 | .RS | |
5942 | .PD 0 | |
5943 | .TP | |
726f6388 | 5944 | .B \-l |
ccc6cda3 JA |
5945 | List process IDs |
5946 | in addition to the normal information. | |
5947 | .TP | |
726f6388 | 5948 | .B \-p |
ccc6cda3 JA |
5949 | List only the process ID of the job's process group |
5950 | leader. | |
5951 | .TP | |
726f6388 | 5952 | .B \-n |
ccc6cda3 JA |
5953 | Display information only about jobs that have changed status since |
5954 | the user was last notified of their status. | |
5955 | .TP | |
5956 | .B \-r | |
5957 | Restrict output to running jobs. | |
5958 | .TP | |
5959 | .B \-s | |
5960 | Restrict output to stopped jobs. | |
5961 | .PD | |
5962 | .PP | |
5963 | If | |
726f6388 JA |
5964 | .I jobspec |
5965 | is given, output is restricted to information about that job. | |
cce855bc JA |
5966 | The return status is 0 unless an invalid option is encountered |
5967 | or an invalid | |
726f6388 JA |
5968 | .I jobspec |
5969 | is supplied. | |
ccc6cda3 | 5970 | .PP |
726f6388 JA |
5971 | If the |
5972 | .B \-x | |
5973 | option is supplied, | |
5974 | .B jobs | |
5975 | replaces any | |
5976 | .I jobspec | |
5977 | found in | |
5978 | .I command | |
5979 | or | |
5980 | .I args | |
5981 | with the corresponding process group ID, and executes | |
5982 | .I command | |
5983 | passing it | |
5984 | .IR args , | |
5985 | returning its exit status. | |
ccc6cda3 | 5986 | .RE |
726f6388 JA |
5987 | .TP |
5988 | .PD 0 | |
ccc6cda3 | 5989 | \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ... |
726f6388 | 5990 | .TP |
cce855bc | 5991 | \fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP] |
726f6388 JA |
5992 | .PD |
5993 | Send the signal named by | |
5994 | .I sigspec | |
ccc6cda3 JA |
5995 | or |
5996 | .I signum | |
726f6388 JA |
5997 | to the processes named by |
5998 | .I pid | |
5999 | or | |
6000 | .IR jobspec . | |
6001 | .I sigspec | |
6002 | is either a signal name such as | |
6003 | .SM | |
6004 | .B SIGKILL | |
ccc6cda3 JA |
6005 | or a signal number; |
6006 | .I signum | |
6007 | is a signal number. If | |
726f6388 | 6008 | .I sigspec |
ccc6cda3 | 6009 | is a signal name, the name may be |
726f6388 JA |
6010 | given with or without the |
6011 | .SM | |
6012 | .B SIG | |
6013 | prefix. | |
6014 | If | |
6015 | .I sigspec | |
6016 | is not present, then | |
6017 | .SM | |
6018 | .B SIGTERM | |
cce855bc JA |
6019 | is assumed. |
6020 | An argument of | |
726f6388 | 6021 | .B \-l |
cce855bc JA |
6022 | lists the signal names. |
6023 | If any arguments are supplied when | |
726f6388 | 6024 | .B \-l |
cce855bc JA |
6025 | is given, the names of the signals corresponding to the arguments are |
6026 | listed, and the return status is 0. | |
6027 | The \fIexit_status\fP argument to | |
ccc6cda3 | 6028 | .B \-l |
cce855bc JA |
6029 | is a number specifying either a signal number or the exit status of |
6030 | a process terminated by a signal. | |
726f6388 JA |
6031 | .B kill |
6032 | returns true if at least one signal was successfully sent, or false | |
cce855bc | 6033 | if an error occurs or an invalid option is encountered. |
726f6388 JA |
6034 | .TP |
6035 | \fBlet\fP \fIarg\fP [\fIarg\fP ...] | |
6036 | Each | |
6037 | .I arg | |
6038 | is an arithmetic expression to be evaluated (see | |
6039 | .SM | |
6040 | .BR "ARITHMETIC EVALUATION" ). | |
6041 | If the last | |
6042 | .I arg | |
6043 | evaluates to 0, | |
6044 | .B let | |
6045 | returns 1; 0 is returned otherwise. | |
6046 | .TP | |
6047 | \fBlocal\fP [\fIname\fP[=\fIvalue\fP] ...] | |
cce855bc JA |
6048 | For each argument, a local variable named |
6049 | .I name | |
6050 | is created, and assigned | |
726f6388 JA |
6051 | .IR value . |
6052 | When | |
6053 | .B local | |
6054 | is used within a function, it causes the variable | |
6055 | .I name | |
6056 | to have a visible scope restricted to that function and its children. | |
6057 | With no operands, | |
6058 | .B local | |
6059 | writes a list of local variables to the standard output. It is | |
6060 | an error to use | |
6061 | .B local | |
6062 | when not within a function. The return status is 0 unless | |
6063 | .B local | |
cce855bc | 6064 | is used outside a function, or an invalid |
726f6388 JA |
6065 | .I name |
6066 | is supplied. | |
6067 | .TP | |
6068 | .B logout | |
6069 | Exit a login shell. | |
6070 | .TP | |
ccc6cda3 | 6071 | \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP] |
726f6388 JA |
6072 | Removes entries from the directory stack. With no arguments, |
6073 | removes the top directory from the stack, and performs a | |
6074 | .B cd | |
6075 | to the new top directory. | |
ccc6cda3 | 6076 | Arguments, if supplied, have the following meanings: |
726f6388 JA |
6077 | .RS |
6078 | .PD 0 | |
6079 | .TP | |
ccc6cda3 JA |
6080 | \fB+\fP\fIn\fP |
6081 | Removes the \fIn\fPth entry counting from the left of the list | |
726f6388 JA |
6082 | shown by |
6083 | .BR dirs , | |
6084 | starting with zero. For example: ``popd +0'' | |
6085 | removes the first directory, ``popd +1'' the second. | |
6086 | .TP | |
ccc6cda3 JA |
6087 | \fB\-\fP\fIn\fP |
6088 | Removes the \fIn\fPth entry counting from the right of the list | |
726f6388 JA |
6089 | shown by |
6090 | .BR dirs , | |
6091 | starting with zero. For example: ``popd -0'' | |
6092 | removes the last directory, ``popd -1'' the next to last. | |
ccc6cda3 JA |
6093 | .TP |
6094 | .B \-n | |
6095 | Suppresses the normal change of directory when removing directories | |
6096 | from the stack, so that only the stack is manipulated. | |
726f6388 JA |
6097 | .PD |
6098 | .PP | |
6099 | If the | |
6100 | .B popd | |
6101 | command is successful, a | |
6102 | .B dirs | |
6103 | is performed as well, and the return status is 0. | |
6104 | .B popd | |
cce855bc | 6105 | returns false if an invalid option is encountered, the directory stack |
726f6388 JA |
6106 | is empty, a non-existent directory stack entry is specified, or the |
6107 | directory change fails. | |
6108 | .RE | |
6109 | .TP | |
cce855bc JA |
6110 | \fBprintf\fP \fIformat\fP [\fIarguments\fP] |
6111 | Write the formatted \fIarguments\fP to the standard output under the | |
6112 | control of the \fIformat\fP. | |
6113 | The \fIformat\fP is a character string which contains three types of objects: | |
6114 | plain characters, which are simply copied to standard output, character | |
6115 | escape sequences, which are converted and copied to the standard output, and | |
6116 | format specifications, each of which causes printing of the next successive | |
6117 | \fIargument\fP. | |
6118 | In addition to the standard \fIprintf\fP(1) formats, %b causes | |
6119 | \fBprintf\fP to expand backslash escape sequences in the corresponding | |
6120 | \fIargument\fP, and %q causes \fBprintf\fP to output the corresponding | |
6121 | \fIargument\fP in a format that can be reused as shell input. | |
6122 | .sp 1 | |
6123 | The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP. | |
6124 | If the \fIformat\fP requires more \fIarguments\fP than are supplied, the | |
6125 | extra format specifications behave as if a zero value or null string, as | |
6126 | appropriate, had been supplied. | |
6127 | .TP | |
726f6388 | 6128 | .PD 0 |
ccc6cda3 | 6129 | \fBpushd\fP [\fB\-n\fP] [\fIdir\fP] |
726f6388 | 6130 | .TP |
ccc6cda3 | 6131 | \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP] |
726f6388 JA |
6132 | .PD |
6133 | Adds a directory to the top of the directory stack, or rotates | |
6134 | the stack, making the new top of the stack the current working | |
6135 | directory. With no arguments, exchanges the top two directories | |
6136 | and returns 0, unless the directory stack is empty. | |
ccc6cda3 | 6137 | Arguments, if supplied, have the following meanings: |
726f6388 JA |
6138 | .RS |
6139 | .PD 0 | |
6140 | .TP | |
ccc6cda3 | 6141 | \fB+\fP\fIn\fP |
726f6388 JA |
6142 | Rotates the stack so that the \fIn\fPth directory |
6143 | (counting from the left of the list shown by | |
d166f048 JA |
6144 | .BR dirs , |
6145 | starting with zero) | |
726f6388 JA |
6146 | is at the top. |
6147 | .TP | |
ccc6cda3 | 6148 | \fB\-\fP\fIn\fP |
726f6388 | 6149 | Rotates the stack so that the \fIn\fPth directory |
d166f048 JA |
6150 | (counting from the right of the list shown by |
6151 | .BR dirs , | |
6152 | starting with zero) is at the top. | |
726f6388 | 6153 | .TP |
ccc6cda3 JA |
6154 | .B \-n |
6155 | Suppresses the normal change of directory when adding directories | |
6156 | to the stack, so that only the stack is manipulated. | |
6157 | .TP | |
726f6388 | 6158 | .B dir |
ccc6cda3 | 6159 | Adds |
726f6388 JA |
6160 | .I dir |
6161 | to the directory stack at the top, making it the | |
6162 | new current working directory. | |
6163 | .PD | |
6164 | .PP | |
6165 | If the | |
6166 | .B pushd | |
6167 | command is successful, a | |
6168 | .B dirs | |
6169 | is performed as well. | |
6170 | If the first form is used, | |
6171 | .B pushd | |
6172 | returns 0 unless the cd to | |
6173 | .I dir | |
6174 | fails. With the second form, | |
6175 | .B pushd | |
6176 | returns 0 unless the directory stack is empty, | |
ccc6cda3 | 6177 | a non-existent directory stack element is specified, |
726f6388 JA |
6178 | or the directory change to the specified new current directory |
6179 | fails. | |
6180 | .RE | |
6181 | .TP | |
ccc6cda3 JA |
6182 | \fBpwd\fP [\fB\-LP\fP] |
6183 | Print the absolute file name of the current working directory. | |
6184 | The file name printed contains no symbolic links if the | |
726f6388 | 6185 | .B \-P |
ccc6cda3 JA |
6186 | option is supplied or the |
6187 | .B \-o physical | |
726f6388 JA |
6188 | option to the |
6189 | .B set | |
ccc6cda3 JA |
6190 | builtin command is enabled. |
6191 | If the | |
6192 | .B \-L | |
6193 | option is used, symbolic links are followed. | |
6194 | The return status is 0 unless an error occurs while | |
cce855bc JA |
6195 | reading the name of the current directory or an |
6196 | invalid option is supplied. | |
726f6388 | 6197 | .TP |
ccc6cda3 | 6198 | \fBread\fP [\fB\-er\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fIname\fP ...] |
726f6388 JA |
6199 | One line is read from the standard input, and the first word |
6200 | is assigned to the first | |
6201 | .IR name , | |
6202 | the second word to the second | |
6203 | .IR name , | |
cce855bc JA |
6204 | and so on, with leftover words and their intervening separators assigned |
6205 | to the last | |
726f6388 | 6206 | .IR name . |
cce855bc JA |
6207 | If there are fewer words read from the standard input than names, |
6208 | the remaining names are assigned empty values. | |
6209 | The characters in | |
726f6388 JA |
6210 | .SM |
6211 | .B IFS | |
cce855bc JA |
6212 | are used to split the line into words. |
6213 | Options, if supplied, have the following meanings: | |
ccc6cda3 JA |
6214 | .RS |
6215 | .PD 0 | |
6216 | .TP | |
6217 | .B \-r | |
6218 | A backslash-newline pair is not ignored, and | |
6219 | the backslash is considered to be part of the line. | |
6220 | .TP | |
6221 | .B \-p | |
6222 | Display \fIprompt\fP, without a | |
6223 | trailing newline, before attempting to read any input. The prompt | |
6224 | is displayed only if input is coming from a terminal. | |
6225 | .TP | |
6226 | .B \-a | |
6227 | The words are assigned to sequential indices | |
6228 | of the array variable | |
6229 | .IR aname , | |
6230 | starting at 0. | |
6231 | .I aname | |
6232 | is unset before any new values are assigned. | |
cce855bc | 6233 | Other \fIname\fP arguments are ignored. |
ccc6cda3 JA |
6234 | .TP |
6235 | .B \-e | |
6236 | If the standard input | |
6237 | is coming from a terminal, | |
6238 | .B readline | |
6239 | (see | |
6240 | .SM | |
6241 | .B READLINE | |
6242 | above) is used to obtain the line. | |
6243 | .PD | |
6244 | .PP | |
6245 | If no | |
726f6388 JA |
6246 | .I names |
6247 | are supplied, the line read is assigned to the variable | |
6248 | .SM | |
6249 | .BR REPLY . | |
ccc6cda3 JA |
6250 | The return code is zero, unless end-of-file is encountered. |
6251 | .RE | |
726f6388 | 6252 | .TP |
ccc6cda3 | 6253 | \fBreadonly\fP [\fB\-apf\fP] [\fIname\fP ...] |
726f6388 JA |
6254 | .PD |
6255 | The given | |
ccc6cda3 JA |
6256 | \fInames\fP are marked readonly; the values of these |
6257 | .I names | |
726f6388 JA |
6258 | may not be changed by subsequent assignment. |
6259 | If the | |
6260 | .B \-f | |
6261 | option is supplied, the functions corresponding to the | |
6262 | \fInames\fP are so | |
ccc6cda3 JA |
6263 | marked. |
6264 | The | |
6265 | .B \-a | |
6266 | option restricts the variables to arrays. | |
6267 | If no | |
6268 | .I name | |
6269 | arguments are given, or if the | |
726f6388 | 6270 | .B \-p |
ccc6cda3 | 6271 | option is supplied, a list of all readonly names is printed. |
cce855bc JA |
6272 | The |
6273 | .B \-p | |
6274 | option causes output to be displayed in a format thatmay be reused as input. | |
6275 | The return status is 0 unless an invalid option is encountered, | |
ccc6cda3 JA |
6276 | one of the |
6277 | .I names | |
cce855bc | 6278 | is not a valid shell variable name, or |
726f6388 JA |
6279 | .B \-f |
6280 | is supplied with a | |
6281 | .I name | |
6282 | that is not a function. | |
6283 | .TP | |
6284 | \fBreturn\fP [\fIn\fP] | |
6285 | Causes a function to exit with the return value specified by | |
6286 | .IR n . | |
6287 | If | |
6288 | .I n | |
6289 | is omitted, the return status is that of the last command | |
6290 | executed in the function body. If used outside a function, | |
6291 | but during execution of a script by the | |
6292 | .B . | |
6293 | (\fBsource\fP) command, it causes the shell to stop executing | |
6294 | that script and return either | |
6295 | .I n | |
6296 | or the exit status of the last command executed within the | |
6297 | script as the exit status of the script. If used outside a | |
6298 | function and not during execution of a script by \fB.\fP\^, | |
6299 | the return status is false. | |
6300 | .TP | |
ccc6cda3 JA |
6301 | \fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...] |
6302 | Without options, the name and value of each shell variable are displayed | |
cce855bc JA |
6303 | in a format that can be reused as input. |
6304 | The output is sorted according to the current locale. | |
ccc6cda3 JA |
6305 | When options are specified, they set or unset shell attributes. |
6306 | Any arguments remaining after the options are processed are treated | |
6307 | as values for the positional parameters and are assigned, in order, to | |
6308 | .BR $1 , | |
6309 | .BR $2 , | |
6310 | .B ... | |
6311 | .BR $\fIn\fP . | |
6312 | Options, if specified, have the following meanings: | |
726f6388 JA |
6313 | .RS |
6314 | .PD 0 | |
6315 | .TP 8 | |
6316 | .B \-a | |
6317 | Automatically mark variables which are modified or created for export | |
6318 | to the environment of subsequent commands. | |
6319 | .TP 8 | |
6320 | .B \-b | |
ccc6cda3 JA |
6321 | Report the status of terminated background jobs |
6322 | immediately, rather than before the next primary prompt. This is | |
6323 | effective only when job control is enabled. | |
726f6388 JA |
6324 | .TP 8 |
6325 | .B \-e | |
ccc6cda3 | 6326 | Exit immediately if a \fIsimple command\fP (see |
726f6388 JA |
6327 | .SM |
6328 | .B SHELL GRAMMAR | |
ccc6cda3 | 6329 | above) exits with a non-zero status. The shell does not exit if the |
726f6388 JA |
6330 | command that fails is part of an |
6331 | .I until | |
6332 | or | |
6333 | .I while | |
6334 | loop, | |
6335 | part of an | |
6336 | .I if | |
6337 | statement, part of a | |
6338 | .B && | |
6339 | or | |
ccc6cda3 | 6340 | .B \(bv\(bv |
726f6388 JA |
6341 | list, or if the command's return value is |
6342 | being inverted via | |
6343 | .BR ! . | |
6344 | .TP 8 | |
6345 | .B \-f | |
6346 | Disable pathname expansion. | |
6347 | .TP 8 | |
6348 | .B \-h | |
ccc6cda3 | 6349 | Remember the location of commands as they are looked up for execution. |
cce855bc | 6350 | This is enabled by default. |
726f6388 JA |
6351 | .TP 8 |
6352 | .B \-k | |
ccc6cda3 JA |
6353 | All arguments in the form of assignment statements |
6354 | are placed in the environment for a command, not just | |
6355 | those that precede the command name. | |
726f6388 JA |
6356 | .TP 8 |
6357 | .B \-m | |
cce855bc | 6358 | Monitor mode. Job control is enabled. This option is on |
726f6388 JA |
6359 | by default for interactive shells on systems that support |
6360 | it (see | |
6361 | .SM | |
6362 | .B JOB CONTROL | |
6363 | above). Background processes run in a separate process | |
6364 | group and a line containing their exit status is printed | |
6365 | upon their completion. | |
6366 | .TP 8 | |
6367 | .B \-n | |
6368 | Read commands but do not execute them. This may be used to | |
ccc6cda3 | 6369 | check a shell script for syntax errors. This is ignored by |
726f6388 JA |
6370 | interactive shells. |
6371 | .TP 8 | |
ccc6cda3 JA |
6372 | .B \-o \fIoption\-name\fP |
6373 | The \fIoption\-name\fP can be one of the following: | |
726f6388 JA |
6374 | .RS |
6375 | .TP 8 | |
6376 | .B allexport | |
6377 | Same as | |
6378 | .BR \-a . | |
6379 | .TP 8 | |
6380 | .B braceexpand | |
ccc6cda3 JA |
6381 | Same as |
6382 | .BR \-B . | |
726f6388 JA |
6383 | .TP 8 |
6384 | .B emacs | |
6385 | Use an emacs-style command line editing interface. This is enabled | |
6386 | by default when the shell is interactive, unless the shell is started | |
6387 | with the | |
ccc6cda3 | 6388 | .B \-\-noediting |
726f6388 JA |
6389 | option. |
6390 | .TP 8 | |
6391 | .B errexit | |
6392 | Same as | |
6393 | .BR \-e . | |
6394 | .TP 8 | |
ccc6cda3 JA |
6395 | .B hashall |
6396 | Same as | |
6397 | .BR \-h . | |
6398 | .TP 8 | |
726f6388 JA |
6399 | .B histexpand |
6400 | Same as | |
6401 | .BR \-H . | |
6402 | .TP 8 | |
ccc6cda3 JA |
6403 | .B history |
6404 | Enable command history, as described above under | |
6405 | .SM | |
6406 | .BR HISTORY . | |
6407 | This option is on by default in interactive shells. | |
6408 | .TP 8 | |
726f6388 | 6409 | .B ignoreeof |
ccc6cda3 | 6410 | The effect is as if the shell command \f(CWIGNOREEOF=10\fP had been executed |
726f6388 JA |
6411 | (see |
6412 | .B Shell Variables | |
6413 | above). | |
6414 | .TP 8 | |
ccc6cda3 JA |
6415 | .B keyword |
6416 | Same as | |
6417 | .BR \-k . | |
726f6388 JA |
6418 | .TP 8 |
6419 | .B monitor | |
6420 | Same as | |
6421 | .BR \-m . | |
6422 | .TP 8 | |
6423 | .B noclobber | |
6424 | Same as | |
6425 | .BR \-C . | |
6426 | .TP 8 | |
6427 | .B noexec | |
6428 | Same as | |
6429 | .BR \-n . | |
6430 | .TP 8 | |
6431 | .B noglob | |
6432 | Same as | |
6433 | .BR \-f . | |
6434 | .TP 8 | |
726f6388 JA |
6435 | .B notify |
6436 | Same as | |
6437 | .BR \-b . | |
6438 | .TP 8 | |
6439 | .B nounset | |
6440 | Same as | |
6441 | .BR \-u . | |
6442 | .TP 8 | |
ccc6cda3 JA |
6443 | .B onecmd |
6444 | Same as | |
6445 | .BR \-t . | |
6446 | .TP 8 | |
726f6388 JA |
6447 | .B physical |
6448 | Same as | |
6449 | .BR \-P . | |
6450 | .TP 8 | |
6451 | .B posix | |
ccc6cda3 JA |
6452 | Change the behavior of |
6453 | .B bash | |
6454 | where the default operation differs | |
6455 | from the POSIX 1003.2 standard to match the standard. | |
726f6388 JA |
6456 | .TP 8 |
6457 | .B privileged | |
6458 | Same as | |
6459 | .BR \-p . | |
6460 | .TP 8 | |
6461 | .B verbose | |
6462 | Same as | |
6463 | .BR \-v . | |
6464 | .TP 8 | |
6465 | .B vi | |
6466 | Use a vi-style command line editing interface. | |
6467 | .TP 8 | |
6468 | .B xtrace | |
6469 | Same as | |
6470 | .BR \-x . | |
ccc6cda3 | 6471 | .sp .5 |
726f6388 | 6472 | .PP |
ccc6cda3 JA |
6473 | If |
6474 | .B \-o | |
6475 | is supplied with no \fIoption\-name\fP, the values of the current options are | |
726f6388 | 6476 | printed. |
ccc6cda3 JA |
6477 | If |
6478 | .B +o | |
6479 | is supplied with no \fIoption\-name\fP, a series of | |
6480 | .B set | |
6481 | commands to recreate the current option settings is displayed on | |
6482 | the standard output. | |
726f6388 JA |
6483 | .RE |
6484 | .TP 8 | |
6485 | .B \-p | |
6486 | Turn on | |
6487 | .I privileged | |
6488 | mode. In this mode, the | |
6489 | .B $ENV | |
cce855bc JA |
6490 | file is not processed, shell functions are not inherited from the |
6491 | environment, and the variable | |
6492 | The \fBSHELLOPTS\fP variable, if it appears in the environment, is ignored. | |
6493 | This is enabled automatically on startup if the effective user (group) | |
6494 | id is not equal to the real user (group) id. | |
6495 | Turning this option off causes the effective user | |
726f6388 JA |
6496 | and group ids to be set to the real user and group ids. |
6497 | .TP 8 | |
6498 | .B \-t | |
6499 | Exit after reading and executing one command. | |
6500 | .TP 8 | |
6501 | .B \-u | |
6502 | Treat unset variables as an error when performing | |
6503 | parameter expansion. If expansion is attempted on an | |
6504 | unset variable, the shell prints an error message, and, | |
ccc6cda3 | 6505 | if not interactive, exits with a non-zero status. |
726f6388 JA |
6506 | .TP 8 |
6507 | .B \-v | |
6508 | Print shell input lines as they are read. | |
6509 | .TP 8 | |
6510 | .B \-x | |
ccc6cda3 JA |
6511 | After expanding each \fIsimple command\fP, |
6512 | display the expanded value of | |
726f6388 JA |
6513 | .SM |
6514 | .BR PS4 , | |
6515 | followed by the command and its expanded arguments. | |
6516 | .TP 8 | |
ccc6cda3 JA |
6517 | .B \-B |
6518 | The shell performs brace expansion (see | |
6519 | .B Brace Expansion | |
6520 | above). This is on by default. | |
726f6388 JA |
6521 | .TP 8 |
6522 | .B \-C | |
ccc6cda3 JA |
6523 | If set, |
6524 | .B bash | |
6525 | does not overwrite an existing file with the | |
6526 | .BR > , | |
6527 | .BR >& , | |
6528 | and | |
6529 | .B <> | |
6530 | redirection operators. This may be overridden when | |
6531 | creating output files by using the redirection operator | |
6532 | .B >| | |
6533 | instead of | |
6534 | .BR > . | |
726f6388 JA |
6535 | .TP 8 |
6536 | .B \-H | |
6537 | Enable | |
6538 | .B ! | |
cce855bc | 6539 | style history substitution. This option is on by |
726f6388 JA |
6540 | default when the shell is interactive. |
6541 | .TP 8 | |
6542 | .B \-P | |
ccc6cda3 JA |
6543 | If set, the shell does not follow symbolic links when executing |
6544 | commands such as | |
726f6388 | 6545 | .B cd |
ccc6cda3 JA |
6546 | that change the current working directory. It uses the |
6547 | physical directory structure instead. By default, | |
6548 | .B bash | |
6549 | follows the logical chain of directories when performing commands | |
6550 | which change the current directory. | |
726f6388 JA |
6551 | .TP 8 |
6552 | .B \-\- | |
cce855bc | 6553 | If no arguments follow this option, then the positional parameters are |
726f6388 JA |
6554 | unset. Otherwise, the positional parameters are set to the |
6555 | \fIarg\fPs, even if some of them begin with a | |
6556 | .BR \- . | |
6557 | .TP 8 | |
6558 | .B \- | |
6559 | Signal the end of options, cause all remaining \fIarg\fPs to be | |
6560 | assigned to the positional parameters. The | |
6561 | .B \-x | |
6562 | and | |
6563 | .B \-v | |
6564 | options are turned off. | |
6565 | If there are no \fIarg\fPs, | |
6566 | the positional parameters remain unchanged. | |
6567 | .PD | |
6568 | .PP | |
cce855bc JA |
6569 | The options are off by default unless otherwise noted. |
6570 | Using + rather than \- causes these options to be turned off. | |
6571 | The options can also be specified as arguments to an invocation of | |
6572 | the shell. | |
6573 | The current set of options may be found in | |
726f6388 | 6574 | .BR $\- . |
cce855bc | 6575 | The return status is always true unless an invalid option is encountered. |
726f6388 JA |
6576 | .RE |
6577 | .TP | |
6578 | \fBshift\fP [\fIn\fP] | |
6579 | The positional parameters from \fIn\fP+1 ... are renamed to | |
6580 | .B $1 | |
6581 | .B .... | |
6582 | Parameters represented by the numbers \fB$#\fP | |
6583 | down to \fB$#\fP\-\fIn\fP+1 are unset. | |
ccc6cda3 JA |
6584 | .I n |
6585 | must be a non-negative number less than or equal to \fB$#\fP. | |
726f6388 JA |
6586 | If |
6587 | .I n | |
6588 | is 0, no parameters are changed. | |
6589 | If | |
6590 | .I n | |
6591 | is not given, it is assumed to be 1. | |
726f6388 JA |
6592 | If |
6593 | .I n | |
6594 | is greater than \fB$#\fP, the positional parameters are not changed. | |
ccc6cda3 | 6595 | The return status is greater than zero if |
726f6388 JA |
6596 | .I n |
6597 | is greater than | |
6598 | .B $# | |
ccc6cda3 JA |
6599 | or less than zero; otherwise 0. |
6600 | .TP | |
6601 | \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...] | |
6602 | Toggle the values of variables controlling optional shell behavior. | |
6603 | With no options, or with the | |
6604 | .B \-p | |
6605 | option, a list of all settable options is displayed, with | |
cce855bc JA |
6606 | an indication of whether or not each is set. |
6607 | The \fB\-p\fP option causes output to be displayed in a form that | |
6608 | may be reused as input. | |
6609 | Other options have the following meanings: | |
ccc6cda3 JA |
6610 | .RS |
6611 | .PD 0 | |
6612 | .TP | |
6613 | .B \-s | |
6614 | Enable (set) each \fIoptname\fP. | |
6615 | .TP | |
6616 | .B \-u | |
6617 | Disable (unset) each \fIoptname\fP. | |
6618 | .TP | |
6619 | .B \-q | |
6620 | Suppresses normal output (quiet mode); the return status indicates | |
6621 | whether the \fIoptname\fP is set or unset. | |
6622 | If multiple \fIoptname\fP arguments are given with | |
6623 | .BR \-q , | |
6624 | the return status is zero if all \fIoptnames\fP are enabled; non-zero | |
6625 | otherwise. | |
6626 | .TP | |
6627 | .B \-o | |
6628 | Restricts the values of \fIoptname\fP to be those defined for the | |
6629 | .B \-o | |
6630 | option to the | |
6631 | .B set | |
6632 | builtin. | |
6633 | .PD | |
6634 | .PP | |
6635 | If either | |
6636 | .B \-s | |
6637 | or | |
6638 | .B \-u | |
6639 | is used with no \fIoptname\fP arguments, the display is limited to | |
6640 | those options which are set or unset, respectively. | |
6641 | Unless otherwise noted, the \fBshopt\fP options are disabled (unset) | |
6642 | by default. | |
6643 | .PP | |
6644 | The return status when listing options is zero if all \fIoptnames\fP | |
6645 | are enabled, non-zero otherwise. When setting or unsetting options, | |
cce855bc | 6646 | the return status is zero unless an \fIoptname\fP is not a valid shell |
ccc6cda3 JA |
6647 | option. |
6648 | .PP | |
6649 | The list of \fBshopt\fP options is: | |
6650 | .if t .sp .5v | |
6651 | .if n .sp 1v | |
6652 | .PD 0 | |
6653 | .TP 8 | |
6654 | .B cdable_vars | |
6655 | If set, an argument to the | |
6656 | .B cd | |
6657 | builtin command that | |
6658 | is not a directory is assumed to be the name of a variable whose | |
6659 | value is the directory to change to. | |
6660 | .TP 8 | |
6661 | .B cdspell | |
6662 | If set, minor errors in the spelling of a directory component in a | |
6663 | .B cd | |
6664 | command will be corrected. | |
6665 | The errors checked for are transposed characters, | |
6666 | a missing character, and one character too many. | |
6667 | If a correction is found, the corrected file name is printed, | |
6668 | and the command proceeds. | |
d166f048 | 6669 | This option is only used by interactive shells. |
ccc6cda3 JA |
6670 | .TP 8 |
6671 | .B checkhash | |
6672 | If set, \fBbash\fP checks that a command found in the hash | |
6673 | table exists before trying to execute it. If a hashed command no | |
6674 | longer exists, a normal path search is performed. | |
6675 | .TP 8 | |
6676 | .B checkwinsize | |
6677 | If set, \fBbash\fP checks the window size after each command | |
6678 | and, if necessary, updates the values of | |
6679 | .SM | |
6680 | .B LINES | |
6681 | and | |
6682 | .SM | |
6683 | .BR COLUMNS . | |
6684 | .TP 8 | |
6685 | .B cmdhist | |
6686 | If set, | |
6687 | .B bash | |
6688 | attempts to save all lines of a multiple-line | |
6689 | command in the same history entry. This allows | |
6690 | easy re-editing of multi-line commands. | |
6691 | .TP 8 | |
6692 | .B dotglob | |
6693 | If set, | |
6694 | .B bash | |
6695 | includes filenames beginning with a `.' in the results of pathname | |
6696 | expansion. | |
6697 | .TP 8 | |
6698 | .B execfail | |
6699 | If set, a non-interactive shell will not exit if | |
6700 | it cannot execute the file specified as an argument to the | |
6701 | .B exec | |
6702 | builtin command. An interactive shell does not exit if | |
6703 | .B exec | |
6704 | fails. | |
6705 | .TP 8 | |
6706 | .B expand_aliases | |
6707 | If set, aliases are expanded as described above under | |
6708 | .SM | |
6709 | .BR ALIASES . | |
6710 | This option is enabled by default for interactive shells. | |
6711 | .TP 8 | |
cce855bc JA |
6712 | .B extglob |
6713 | If set, the extended pattern matching features described above under | |
6714 | \fBPathname Expansion\fP are enabled. | |
6715 | .TP 8 | |
ccc6cda3 JA |
6716 | .B histappend |
6717 | If set, the history list is appended to the file named by the value | |
6718 | of the | |
6719 | .B HISTFILE | |
6720 | variable when the shell exits, rather than overwriting the file. | |
6721 | .TP 8 | |
6722 | .B histreedit | |
6723 | If set, and | |
6724 | .B readline | |
6725 | is being used, a user is given the opportunity to re-edit a | |
6726 | failed history substitution. | |
6727 | .TP 8 | |
6728 | .B histverify | |
6729 | If set, and | |
6730 | .B readline | |
6731 | is being used, the results of history substitution are not immediately | |
6732 | passed to the shell parser. Instead, the resulting line is loaded into | |
6733 | the \fBreadline\fP editing buffer, allowing further modification. | |
6734 | .TP 8 | |
6735 | .B hostcomplete | |
6736 | If set, and | |
6737 | .B readline | |
cce855bc JA |
6738 | is being used, \fBbash\fP will attempt to perform hostname completion when a |
6739 | word containing a \fB@\fP is being completed (see | |
ccc6cda3 JA |
6740 | .B Completing |
6741 | under | |
6742 | .SM | |
6743 | .B READLINE | |
6744 | above). | |
6745 | This is enabled by default. | |
6746 | .TP 8 | |
cce855bc JA |
6747 | .B huponexit |
6748 | If set, \fBbash\fP will send | |
6749 | .SM | |
6750 | .B SIGHUP | |
6751 | to all jobs when an interactive login shell exits. | |
6752 | .TP 8 | |
ccc6cda3 JA |
6753 | .B interactive_comments |
6754 | If set, allow a word beginning with | |
6755 | .B # | |
6756 | to cause that word and all remaining characters on that | |
6757 | line to be ignored in an interactive shell (see | |
6758 | .SM | |
6759 | .B COMMENTS | |
6760 | above). This option is enabled by default. | |
6761 | .TP 8 | |
6762 | .B lithist | |
6763 | If set, and the | |
6764 | .B cmdhist | |
6765 | option is enabled, multi-line commands are saved to the history with | |
6766 | embedded newlines rather than using semicolon separators where possible. | |
6767 | .TP 8 | |
6768 | .B mailwarn | |
6769 | If set, and a file that \fBbash\fP is checking for mail has been | |
6770 | accessed since the last time it was checked, the message ``The mail in | |
6771 | \fImailfile\fP has been read'' is displayed. | |
6772 | .TP 8 | |
cce855bc JA |
6773 | .B nocaseglob |
6774 | If set, | |
6775 | .B bash | |
6776 | matches filenames in a case\-insensitive fashion when performing pathname | |
6777 | expansion (see | |
6778 | .B Pathname Expansion | |
6779 | above). | |
6780 | .TP 8 | |
ccc6cda3 JA |
6781 | .B nullglob |
6782 | If set, | |
6783 | .B bash | |
6784 | allows patterns which match no | |
6785 | files (see | |
6786 | .B Pathname Expansion | |
6787 | above) | |
6788 | to expand to a null string, rather than themselves. | |
6789 | .TP 8 | |
6790 | .B promptvars | |
6791 | If set, prompt strings undergo variable and parameter expansion after | |
6792 | being expanded as described in | |
6793 | .SM | |
6794 | .B PROMPTING | |
6795 | above. This option is enabled by default. | |
6796 | .TP 8 | |
6797 | .B shift_verbose | |
6798 | If set, the | |
6799 | .B shift | |
6800 | builtin prints an error message when the shift count exceeds the | |
6801 | number of positional parameters. | |
6802 | .TP 8 | |
6803 | .B sourcepath | |
6804 | If set, the | |
6805 | \fBsource\fP (\fB.\fP) builtin uses the value of | |
6806 | .SM | |
6807 | .B PATH | |
6808 | to find the directory containing the file supplied as an argument. | |
cce855bc | 6809 | This option is enabled by default. |
ccc6cda3 | 6810 | .RE |
726f6388 JA |
6811 | .TP |
6812 | \fBsuspend\fP [\fB\-f\fP] | |
6813 | Suspend the execution of this shell until it receives a | |
6814 | .SM | |
6815 | .B SIGCONT | |
6816 | signal. The | |
6817 | .B \-f | |
6818 | option says not to complain if this is | |
6819 | a login shell; just suspend anyway. The return status is 0 unless | |
6820 | the shell is a login shell and | |
6821 | .B \-f | |
6822 | is not supplied, or if job control is not enabled. | |
6823 | .TP | |
6824 | .PD 0 | |
6825 | \fBtest\fP \fIexpr\fP | |
6826 | .TP | |
6827 | \fB[\fP \fIexpr\fP \fB]\fP | |
ccc6cda3 | 6828 | Return a status of 0 or 1 depending on |
726f6388 JA |
6829 | the evaluation of the conditional expression |
6830 | .IR expr . | |
cce855bc JA |
6831 | Each operator and operand must be a separate argument. |
6832 | Expressions are composed of the primaries described above under | |
6833 | .SM | |
6834 | .BR "CONDITIONAL EXPRESSIONS" . | |
6835 | .if t .sp 0.5 | |
6836 | .if n .sp 1 | |
6837 | Expressions may be combined using the following operators, listed | |
6838 | in decreasing order of precedence. | |
726f6388 JA |
6839 | .RS |
6840 | .PD 0 | |
6841 | .TP | |
726f6388 JA |
6842 | .B ! \fIexpr\fP |
6843 | True if | |
6844 | .I expr | |
6845 | is false. | |
6846 | .TP | |
cce855bc JA |
6847 | .B ( \fIexpr\fP ) |
6848 | Returns the value of \fIexpr\fP. | |
6849 | This may be used to override the normal precedence of operators. | |
6850 | .TP | |
726f6388 JA |
6851 | \fIexpr1\fP \-\fBa\fP \fIexpr2\fP |
6852 | True if both | |
6853 | .I expr1 | |
cce855bc | 6854 | and |
726f6388 JA |
6855 | .I expr2 |
6856 | are true. | |
6857 | .TP | |
6858 | \fIexpr1\fP \-\fBo\fP \fIexpr2\fP | |
6859 | True if either | |
6860 | .I expr1 | |
cce855bc | 6861 | or |
726f6388 JA |
6862 | .I expr2 |
6863 | is true. | |
cce855bc JA |
6864 | .PD |
6865 | .PP | |
6866 | \fBtest\fP and \fB[\fP evaluate conditional | |
6867 | expressions using a set of rules based on the number of arguments. | |
6868 | .if t .sp 0.5 | |
6869 | .if n .sp 1 | |
6870 | .PD 0 | |
726f6388 | 6871 | .TP |
cce855bc JA |
6872 | 0 arguments |
6873 | The expression is false. | |
6874 | .TP | |
6875 | 1 argument | |
6876 | The expression is true if and only if the argument is not null. | |
6877 | .TP | |
6878 | 2 arguments | |
6879 | If the first argument is \fB!\fP, the expression is true if and | |
6880 | only if the second argument is null. | |
6881 | If the first argument is one of the unary conditional operators listed above | |
6882 | under | |
726f6388 | 6883 | .SM |
cce855bc JA |
6884 | .BR "CONDITIONAL EXPRESSIONS" , |
6885 | the expression is true if the unary test is true. | |
6886 | If the first argument is not a valid unary conditional operator, the expression | |
6887 | is false. | |
6888 | .TP | |
6889 | 3 arguments | |
6890 | If the second argument is one of the binary conditional operators listed above | |
6891 | under | |
6892 | .SM | |
6893 | .BR "CONDITIONAL EXPRESSIONS" , | |
6894 | the result of the expression is the result of the binary test using | |
6895 | the first and third arguments as operands. | |
6896 | If the first argument is \fB!\fP, the value is the negation of | |
6897 | the two-argument test using the second and third arguments. | |
6898 | If the first argument is exactly \fB(\fP and the third argument is | |
6899 | exactly \fB)\fP, the result is the one-argument test of the second | |
6900 | argument. | |
6901 | Otherwise, the expression is false. | |
6902 | The \fB\-a\fP and \fB\-o\fP operators are considered binary operators | |
6903 | in this case. | |
6904 | .TP | |
6905 | 4 arguments | |
6906 | If the first argument is \fB!\fP, the result is the negation of | |
6907 | the three-argument expression composed of the remaining arguments. | |
6908 | Otherwise, the expression is parsed and evaluated according to | |
6909 | precedence using the rules listed above. | |
6910 | .TP | |
6911 | 5 or more arguments | |
6912 | The expression is parsed and evaluated according to precedence | |
6913 | using the rules listed above. | |
726f6388 | 6914 | .RE |
cce855bc | 6915 | .PD |
726f6388 JA |
6916 | .TP |
6917 | .B times | |
6918 | Print the accumulated user and system times for the shell and | |
6919 | for processes run from the shell. The return status is 0. | |
6920 | .TP | |
d166f048 | 6921 | \fBtrap\fP [\fB\-lp\fP] [\fIarg\fP] [\fIsigspec\fP ...] |
726f6388 JA |
6922 | The command |
6923 | .I arg | |
6924 | is to be read and executed when the shell receives | |
6925 | signal(s) | |
6926 | .IR sigspec . | |
6927 | If | |
6928 | .I arg | |
6929 | is absent or | |
6930 | .BR \- , | |
6931 | all specified signals are | |
6932 | reset to their original values (the values they had | |
d166f048 JA |
6933 | upon entrance to the shell). |
6934 | If | |
726f6388 | 6935 | .I arg |
d166f048 JA |
6936 | is the null string the signal specified by each |
6937 | .I sigspec | |
6938 | is ignored by the shell and by the commands it invokes. | |
ccc6cda3 JA |
6939 | If |
6940 | .I arg | |
6941 | is | |
6942 | .B \-p | |
6943 | then the trap commands associated with | |
6944 | each | |
6945 | .I sigspec | |
6946 | are displayed. If no arguments are supplied or if | |
6947 | only | |
6948 | .B \-p | |
6949 | is given, | |
6950 | .B trap | |
6951 | prints the list of commands associated with each signal number. | |
d166f048 | 6952 | Each |
726f6388 JA |
6953 | .I sigspec |
6954 | is either | |
d166f048 JA |
6955 | a signal name defined in <\fIsignal.h\fP>, or a signal number. |
6956 | If a | |
726f6388 JA |
6957 | .I sigspec |
6958 | is | |
6959 | .SM | |
6960 | .B EXIT | |
6961 | (0) the command | |
6962 | .I arg | |
d166f048 | 6963 | is executed on exit from the shell. If a |
ccc6cda3 JA |
6964 | .I sigspec |
6965 | is | |
6966 | .SM | |
6967 | .BR DEBUG , | |
6968 | the command | |
6969 | .I arg | |
6970 | is executed after every \fIsimple command\fP (see | |
6971 | .SM | |
6972 | .B SHELL GRAMMAR | |
6973 | above). | |
6974 | The | |
726f6388 | 6975 | .B \-l |
ccc6cda3 JA |
6976 | option causes the shell to print a list of signal names and |
6977 | their corresponding numbers. | |
726f6388 JA |
6978 | Signals ignored upon entry to the shell cannot be trapped or reset. |
6979 | Trapped signals are reset to their original values in a child | |
d166f048 JA |
6980 | process when it is created. |
6981 | The return status is false if any | |
ccc6cda3 JA |
6982 | .I sigspec |
6983 | is invalid; otherwise | |
726f6388 JA |
6984 | .B trap |
6985 | returns true. | |
6986 | .TP | |
cce855bc | 6987 | \fBtype\fP [\fB\-atp\fP] \fIname\fP [\fIname\fP ...] |
726f6388 JA |
6988 | With no options, |
6989 | indicate how each | |
6990 | .I name | |
6991 | would be interpreted if used as a command name. | |
6992 | If the | |
cce855bc JA |
6993 | .B \-t |
6994 | option is used, | |
726f6388 | 6995 | .B type |
ccc6cda3 | 6996 | prints a string which is one of |
726f6388 JA |
6997 | .IR alias , |
6998 | .IR keyword , | |
6999 | .IR function , | |
7000 | .IR builtin , | |
7001 | or | |
7002 | .I file | |
7003 | if | |
7004 | .I name | |
7005 | is an alias, shell reserved word, function, builtin, or disk file, | |
ccc6cda3 JA |
7006 | respectively. |
7007 | If the | |
7008 | .I name | |
7009 | is not found, then nothing is printed, and an exit status of false | |
7010 | is returned. | |
726f6388 | 7011 | If the |
cce855bc JA |
7012 | .B \-p |
7013 | option is used, | |
726f6388 JA |
7014 | .B type |
7015 | either returns the name of the disk file | |
7016 | that would be executed if | |
7017 | .I name | |
7018 | were specified as a command name, | |
cce855bc | 7019 | or nothing if \f(CWtype -t name\fP |
726f6388 JA |
7020 | would not return |
7021 | .IR file . | |
7022 | If a command is hashed, | |
cce855bc | 7023 | .B \-p |
726f6388 JA |
7024 | prints the hashed value, not necessarily the file that appears |
7025 | first in | |
7026 | .SM | |
7027 | .BR PATH . | |
7028 | If the | |
cce855bc JA |
7029 | .B \-a |
7030 | option is used, | |
726f6388 JA |
7031 | .B type |
7032 | prints all of the places that contain | |
7033 | an executable named | |
7034 | .IR name . | |
7035 | This includes aliases and functions, | |
7036 | if and only if the | |
cce855bc JA |
7037 | .B \-p |
7038 | option is not also used. | |
726f6388 JA |
7039 | The table of hashed commands is not consulted |
7040 | when using | |
cce855bc | 7041 | .BR \-a . |
726f6388 JA |
7042 | .B type |
7043 | returns true if any of the arguments are found, false if | |
7044 | none are found. | |
7045 | .TP | |
ccc6cda3 JA |
7046 | \fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]] |
7047 | Provides control over the resources available to the shell and to | |
726f6388 JA |
7048 | processes started by it, on systems that allow such control. The |
7049 | value of | |
7050 | .I limit | |
7051 | can be a number in the unit specified for the resource, or the | |
7052 | value | |
7053 | .BR unlimited . | |
ccc6cda3 | 7054 | The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is |
726f6388 JA |
7055 | set for the given resource. A hard limit cannot be increased once it |
7056 | is set; a soft limit may be increased up to the value of the hard limit. | |
ccc6cda3 JA |
7057 | If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard |
7058 | limits are set. | |
7059 | If | |
726f6388 JA |
7060 | .I limit |
7061 | is omitted, the current value of the soft limit of the resource is | |
ccc6cda3 JA |
7062 | printed, unless the \fB\-H\fP option is given. When more than one |
7063 | resource is specified, the limit name and unit are printed before the value. | |
726f6388 JA |
7064 | Other options are interpreted as follows: |
7065 | .RS | |
7066 | .PD 0 | |
7067 | .TP | |
7068 | .B \-a | |
ccc6cda3 | 7069 | All current limits are reported |
726f6388 JA |
7070 | .TP |
7071 | .B \-c | |
ccc6cda3 | 7072 | The maximum size of core files created |
726f6388 JA |
7073 | .TP |
7074 | .B \-d | |
ccc6cda3 | 7075 | The maximum size of a process's data segment |
726f6388 JA |
7076 | .TP |
7077 | .B \-f | |
ccc6cda3 | 7078 | The maximum size of files created by the shell |
726f6388 | 7079 | .TP |
ccc6cda3 JA |
7080 | .B \-l |
7081 | The maximum size that may be locked into memory | |
726f6388 | 7082 | .TP |
ccc6cda3 JA |
7083 | .B \-m |
7084 | The maximum resident set size | |
726f6388 | 7085 | .TP |
ccc6cda3 JA |
7086 | .B \-n |
7087 | The maximum number of open file descriptors (most systems do not | |
7088 | allow this value to be set) | |
726f6388 JA |
7089 | .TP |
7090 | .B \-p | |
ccc6cda3 | 7091 | The pipe size in 512-byte blocks (this may not be set) |
726f6388 | 7092 | .TP |
ccc6cda3 JA |
7093 | .B \-s |
7094 | The maximum stack size | |
7095 | .TP | |
7096 | .B \-t | |
7097 | The maximum amount of cpu time in seconds | |
726f6388 JA |
7098 | .TP |
7099 | .B \-u | |
ccc6cda3 | 7100 | The maximum number of processes available to a single user |
726f6388 JA |
7101 | .TP |
7102 | .B \-v | |
7103 | The maximum amount of virtual memory available to the shell | |
7104 | .PD | |
7105 | .PP | |
ccc6cda3 | 7106 | If |
726f6388 JA |
7107 | .I limit |
7108 | is given, it is the new value of the specified resource (the | |
7109 | .B \-a | |
7110 | option is display only). | |
7111 | If no option is given, then | |
7112 | .B \-f | |
7113 | is assumed. Values are in 1024-byte increments, except for | |
7114 | .BR \-t , | |
7115 | which is in seconds, | |
7116 | .BR \-p , | |
7117 | which is in units of 512-byte blocks, | |
7118 | and | |
7119 | .B \-n | |
7120 | and | |
7121 | .BR \-u , | |
7122 | which are unscaled values. The return status is 0 | |
cce855bc | 7123 | unless an invalid option is encountered, a non-numeric argument |
726f6388 JA |
7124 | other than \fBunlimited\fP is supplied as \fIlimit\fP, or an |
7125 | error occurs while setting a new limit. | |
7126 | .RE | |
7127 | .TP | |
cce855bc | 7128 | \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP] |
726f6388 JA |
7129 | The user file-creation mask is set to |
7130 | .IR mode . | |
7131 | If | |
7132 | .I mode | |
7133 | begins with a digit, it | |
7134 | is interpreted as an octal number; otherwise | |
7135 | it is interpreted as a symbolic mode mask similar | |
7136 | to that accepted by | |
7137 | .IR chmod (1). | |
7138 | If | |
7139 | .I mode | |
7140 | is omitted, or if the | |
7141 | .B \-S | |
7142 | option is supplied, the | |
ccc6cda3 JA |
7143 | current value of the mask is printed. |
7144 | The | |
726f6388 JA |
7145 | .B \-S |
7146 | option causes the mask to be printed in symbolic form; the | |
7147 | default output is an octal number. | |
cce855bc JA |
7148 | If the |
7149 | .B \-p | |
7150 | option is supplied, and | |
7151 | .I mode | |
7152 | is omitted, the output is in a form that may be reused as input. | |
ccc6cda3 | 7153 | The return status is 0 if the mode was successfully changed or if |
726f6388 JA |
7154 | no \fImode\fP argument was supplied, and false otherwise. |
7155 | .TP | |
7156 | \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...] | |
7157 | Remove \fIname\fPs from the list of defined aliases. If | |
7158 | .B \-a | |
7159 | is supplied, all alias definitions are removed. The return | |
7160 | value is true unless a supplied | |
7161 | .I name | |
7162 | is not a defined alias. | |
7163 | .TP | |
7164 | \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...] | |
7165 | For each | |
7166 | .IR name , | |
ccc6cda3 JA |
7167 | remove the corresponding variable or function. |
7168 | If no options are supplied, or the | |
7169 | .B \-v | |
7170 | option is given, each | |
7171 | .I name | |
7172 | refers to a shell variable. | |
7173 | Read-only variables may not be unset. | |
7174 | If | |
726f6388 | 7175 | .B \-f |
ccc6cda3 JA |
7176 | is specifed, |
7177 | each | |
7178 | .I name | |
7179 | refers to a shell function, and the function definition | |
7180 | is removed. | |
7181 | Each unset variable or function is removed from the environment | |
7182 | passed to subsequent commands. | |
7183 | If any of | |
726f6388 JA |
7184 | .SM |
7185 | .BR RANDOM , | |
7186 | .SM | |
7187 | .BR SECONDS , | |
7188 | .SM | |
7189 | .BR LINENO , | |
ccc6cda3 JA |
7190 | .SM |
7191 | .BR HISTCMD , | |
726f6388 JA |
7192 | or |
7193 | .SM | |
ccc6cda3 | 7194 | .B DIRSTACK |
726f6388 JA |
7195 | are unset, they lose their special properties, even if they are |
7196 | subsequently reset. The exit status is true unless a | |
7197 | .I name | |
ccc6cda3 | 7198 | does not exist or is readonly. |
726f6388 JA |
7199 | .TP |
7200 | \fBwait\fP [\fIn\fP] | |
7201 | Wait for the specified process and return its termination | |
7202 | status. | |
7203 | .I n | |
7204 | may be a process | |
7205 | ID or a job specification; if a job spec is given, all processes | |
7206 | in that job's pipeline are waited for. If | |
7207 | .I n | |
7208 | is not given, all currently active child processes | |
7209 | are waited for, and the return status is zero. If | |
7210 | .I n | |
ccc6cda3 | 7211 | specifies a non-existent process or job, the return status is |
726f6388 JA |
7212 | 127. Otherwise, the return status is the exit status of the last |
7213 | process or job waited for. | |
7214 | .\" bash_builtins | |
7215 | .if \n(zZ=1 .ig zZ | |
ccc6cda3 | 7216 | .SH "RESTRICTED SHELL" |
726f6388 | 7217 | .PP |
ccc6cda3 | 7218 | If |
726f6388 | 7219 | .B bash |
ccc6cda3 JA |
7220 | is started with the name |
7221 | .BR rbash , | |
7222 | or the | |
7223 | .B \-r | |
7224 | option is supplied at invocation, | |
7225 | the shell becomes restricted. | |
7226 | A restricted shell is used to | |
7227 | set up an environment more controlled than the standard shell. | |
7228 | It behaves identically to | |
7229 | .B bash | |
cce855bc | 7230 | with the exception that the following are disallowed or not performed: |
ccc6cda3 JA |
7231 | .IP \(bu |
7232 | changing directories with \fBcd\fP | |
7233 | .IP \(bu | |
7234 | setting or unsetting the values of | |
7235 | .B SHELL | |
7236 | or | |
7237 | .B PATH | |
7238 | .IP \(bu | |
7239 | specifying command names containing | |
7240 | .B / | |
7241 | .IP \(bu | |
7242 | specifying a file name containing a | |
7243 | .B / | |
7244 | as an argument to the | |
7245 | .B . | |
7246 | builtin command | |
7247 | .IP \(bu | |
7248 | importing function definitions from the shell environment at startup | |
7249 | .IP \(bu | |
cce855bc JA |
7250 | parsing the value of \fBSHELLOPTS\fP from the shell environment at startup |
7251 | .IP \(bu | |
ccc6cda3 JA |
7252 | redirecting output using the >, >|, <>, >&, &>, and >> redirection operators |
7253 | .IP \(bu | |
7254 | using the | |
7255 | .B exec | |
7256 | builtin command to replace the shell with another command | |
7257 | .IP \(bu | |
7258 | adding or deleting builtin commands with the | |
7259 | .B \-f | |
726f6388 | 7260 | and |
ccc6cda3 JA |
7261 | .B \-d |
7262 | options to the | |
7263 | .B enable | |
7264 | builtin command | |
7265 | .IP \(bu | |
7266 | specifying the | |
7267 | .B \-p | |
7268 | option to the | |
7269 | .B command | |
7270 | builtin command | |
7271 | .IP \(bu | |
7272 | turning off restricted mode with | |
cce855bc | 7273 | \fBset +r\fP or \fBset +o restricted\fP. |
726f6388 | 7274 | .PP |
ccc6cda3 JA |
7275 | These restrictions are enforced after any startup files are read. |
7276 | .PP | |
7277 | When a command that is found to be a shell script is executed (see | |
7278 | .SM | |
7279 | .B "COMMAND EXECUTION" | |
7280 | above), | |
7281 | .B rbash | |
7282 | turns off any restrictions in the shell spawned to execute the | |
7283 | script. | |
726f6388 JA |
7284 | .SH "SEE ALSO" |
7285 | .PD 0 | |
7286 | .TP | |
7287 | \fIBash Features\fP, Brian Fox and Chet Ramey | |
7288 | .TP | |
7289 | \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey | |
7290 | .TP | |
7291 | \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey | |
7292 | .TP | |
726f6388 JA |
7293 | \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE |
7294 | .TP | |
7295 | \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1) | |
7296 | .TP | |
7297 | \fIemacs\fP(1), \fIvi\fP(1) | |
7298 | .TP | |
7299 | \fIreadline\fP(3) | |
7300 | .PD | |
7301 | .SH FILES | |
7302 | .PD 0 | |
7303 | .TP | |
7304 | .FN /bin/bash | |
7305 | The \fBbash\fP executable | |
7306 | .TP | |
7307 | .FN /etc/profile | |
7308 | The systemwide initialization file, executed for login shells | |
7309 | .TP | |
7310 | .FN ~/.bash_profile | |
7311 | The personal initialization file, executed for login shells | |
7312 | .TP | |
7313 | .FN ~/.bashrc | |
7314 | The individual per-interactive-shell startup file | |
7315 | .TP | |
7316 | .FN ~/.inputrc | |
7317 | Individual \fIreadline\fP initialization file | |
7318 | .PD | |
7319 | .SH AUTHORS | |
ccc6cda3 | 7320 | Brian Fox, Free Software Foundation |
726f6388 | 7321 | .br |
ccc6cda3 | 7322 | bfox@gnu.ai.MIT.Edu |
726f6388 JA |
7323 | .PP |
7324 | Chet Ramey, Case Western Reserve University | |
7325 | .br | |
7326 | chet@ins.CWRU.Edu | |
7327 | .SH BUG REPORTS | |
7328 | If you find a bug in | |
7329 | .B bash, | |
7330 | you should report it. But first, you should | |
7331 | make sure that it really is a bug, and that it appears in the latest | |
7332 | version of | |
7333 | .B bash | |
7334 | that you have. | |
7335 | .PP | |
7336 | Once you have determined that a bug actually exists, use the | |
7337 | .I bashbug | |
7338 | command to submit a bug report. | |
d166f048 | 7339 | If you have a fix, you are encouraged to mail that as well! |
726f6388 | 7340 | Suggestions and `philosophical' bug reports may be mailed |
cce855bc | 7341 | to \fIbug-bash@gnu.org\fP or posted to the Usenet |
726f6388 JA |
7342 | newsgroup |
7343 | .BR gnu.bash.bug . | |
7344 | .PP | |
7345 | ALL bug reports should include: | |
7346 | .PP | |
7347 | .PD 0 | |
7348 | .TP 20 | |
7349 | The version number of \fBbash\fR | |
7350 | .TP | |
7351 | The hardware and operating system | |
7352 | .TP | |
7353 | The compiler used to compile | |
7354 | .TP | |
7355 | A description of the bug behaviour | |
7356 | .TP | |
7357 | A short script or `recipe' which exercises the bug | |
7358 | .PD | |
7359 | .PP | |
7360 | .I bashbug | |
7361 | inserts the first three items automatically into the template | |
7362 | it provides for filing a bug report. | |
7363 | .PP | |
7364 | Comments and bug reports concerning | |
7365 | this manual page should be directed to | |
7366 | .IR chet@ins.CWRU.Edu . | |
7367 | .SH BUGS | |
7368 | .PP | |
7369 | It's too big and too slow. | |
7370 | .PP | |
7371 | There are some subtle differences between | |
7372 | .B bash | |
7373 | and traditional versions of | |
7374 | .BR sh , | |
7375 | mostly because of the | |
7376 | .SM | |
7377 | .B POSIX | |
7378 | specification. | |
7379 | .PP | |
7380 | Aliases are confusing in some uses. | |
ccc6cda3 JA |
7381 | .PP |
7382 | Shell builtin commands and functions are not stoppable/restartable. | |
7383 | .PP | |
7384 | Compound commands and command sequences of the form `a ; b ; c' | |
7385 | are not handled gracefully when process suspension is attempted. | |
7386 | When a process is stopped, the shell immediately executes the next | |
7387 | command in the sequence. | |
7388 | It suffices to place the sequence of commands between | |
7389 | parentheses to force it into a subshell, which may be stopped as | |
7390 | a unit. | |
7391 | .PP | |
7392 | Commands inside of \fB$(\fP...\fB)\fP command substitution are not | |
7393 | parsed until substitution is attempted. This will delay error | |
7394 | reporting until some time after the command is entered. | |
7395 | .PP | |
7396 | Array variables may not (yet) be exported. | |
726f6388 | 7397 | .zZ |