]>
Commit | Line | Data |
---|---|---|
d3ad40de | 1 | .\" |
726f6388 JA |
2 | .\" MAN PAGE COMMENTS to |
3 | .\" | |
4 | .\" Chet Ramey | |
726f6388 | 5 | .\" Case Western Reserve University |
e225d5a9 | 6 | .\" chet@po.cwru.edu |
726f6388 | 7 | .\" |
1442f67c | 8 | .\" Last Change: Sat Jul 13 13:32:19 EDT 2013 |
726f6388 JA |
9 | .\" |
10 | .\" bash_builtins, strip all but Built-Ins section | |
11 | .if \n(zZ=1 .ig zZ | |
bb70624e | 12 | .if \n(zY=1 .ig zY |
1442f67c | 13 | .TH BASH 1 "2013 July 13" "GNU Bash 4.3" |
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] | |
e67d0029 | 51 | [command_string | file] |
726f6388 | 52 | .SH COPYRIGHT |
1b1fe467 CR |
53 | .if n Bash is Copyright (C) 1989-2013 by the Free Software Foundation, Inc. |
54 | .if t Bash is Copyright \(co 1989-2013 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 | |
ac18b312 CR |
64 | is intended to be a conformant implementation of the |
65 | Shell and Utilities portion of the IEEE POSIX specification | |
66 | (IEEE Standard 1003.1). | |
7790f917 CR |
67 | .B Bash |
68 | can be configured to be POSIX-conformant by default. | |
726f6388 | 69 | .SH OPTIONS |
3d8cce26 CR |
70 | All of the single-character shell options documented in the |
71 | description of the \fBset\fR builtin command can be used as options | |
72 | when the shell is invoked. | |
73 | In addition, \fBbash\fR | |
cce855bc | 74 | interprets the following options when it is invoked: |
726f6388 JA |
75 | .PP |
76 | .PD 0 | |
77 | .TP 10 | |
e67d0029 | 78 | .B \-c |
ccc6cda3 | 79 | If the |
726f6388 | 80 | .B \-c |
e67d0029 CR |
81 | option is present, then commands are read from the first non-option argument |
82 | .IR command_string . | |
726f6388 | 83 | If there are arguments after the |
e67d0029 | 84 | .IR command_string , |
726f6388 JA |
85 | they are assigned to the positional parameters, starting with |
86 | .BR $0 . | |
87 | .TP | |
7117c2d2 JA |
88 | .B \-i |
89 | If the | |
90 | .B \-i | |
91 | option is present, the shell is | |
92 | .IR interactive . | |
93 | .TP | |
94 | .B \-l | |
95 | Make | |
96 | .B bash | |
97 | act as if it had been invoked as a login shell (see | |
98 | .SM | |
99 | .B INVOCATION | |
100 | below). | |
101 | .TP | |
ccc6cda3 JA |
102 | .B \-r |
103 | If the | |
104 | .B \-r | |
cce855bc | 105 | option is present, the shell becomes |
ccc6cda3 JA |
106 | .I restricted |
107 | (see | |
108 | .SM | |
109 | .B "RESTRICTED SHELL" | |
110 | below). | |
111 | .TP | |
726f6388 JA |
112 | .B \-s |
113 | If the | |
114 | .B \-s | |
cce855bc | 115 | option is present, or if no arguments remain after option |
726f6388 JA |
116 | processing, then commands are read from the standard input. |
117 | This option allows the positional parameters to be set | |
118 | when invoking an interactive shell. | |
119 | .TP | |
ccc6cda3 JA |
120 | .B \-D |
121 | A list of all double-quoted strings preceded by \fB$\fP | |
22e63b05 | 122 | is printed on the standard output. |
ccc6cda3 JA |
123 | These are the strings that |
124 | are subject to language translation when the current locale | |
28ef6c31 | 125 | is not \fBC\fP or \fBPOSIX\fP. |
ccc6cda3 JA |
126 | This implies the \fB\-n\fP option; no commands will be executed. |
127 | .TP | |
f73dda09 JA |
128 | .B [\-+]O [\fIshopt_option\fP] |
129 | \fIshopt_option\fP is one of the shell options accepted by the | |
130 | \fBshopt\fP builtin (see | |
131 | .SM | |
132 | .B SHELL BUILTIN COMMANDS | |
133 | below). | |
134 | If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option; | |
135 | \fB+O\fP unsets it. | |
136 | If \fIshopt_option\fP is not supplied, the names and values of the shell | |
137 | options accepted by \fBshopt\fP are printed on the standard output. | |
138 | If the invocation option is \fB+O\fP, the output is displayed in a format | |
139 | that may be reused as input. | |
140 | .TP | |
ccc6cda3 JA |
141 | .B \-\- |
142 | A | |
143 | .B \-\- | |
726f6388 JA |
144 | signals the end of options and disables further option processing. |
145 | Any arguments after the | |
726f6388 | 146 | .B \-\- |
ccc6cda3 JA |
147 | are treated as filenames and arguments. An argument of |
148 | .B \- | |
149 | is equivalent to \fB\-\-\fP. | |
726f6388 JA |
150 | .PD |
151 | .PP | |
152 | .B Bash | |
ccc6cda3 JA |
153 | also interprets a number of multi-character options. |
154 | These options must appear on the command line before the | |
7117c2d2 | 155 | single-character options to be recognized. |
726f6388 JA |
156 | .PP |
157 | .PD 0 | |
726f6388 | 158 | .TP |
d3a24ed2 CR |
159 | .B \-\-debugger |
160 | Arrange for the debugger profile to be executed before the shell | |
2206f89a CR |
161 | starts. |
162 | Turns on extended debugging mode (see the description of the | |
d3a24ed2 CR |
163 | .B extdebug |
164 | option to the | |
165 | .B shopt | |
d3a24ed2 CR |
166 | builtin below). |
167 | .TP | |
cce855bc JA |
168 | .B \-\-dump\-po\-strings |
169 | Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP | |
170 | \fBpo\fP (portable object) file format. | |
171 | .TP | |
ccc6cda3 JA |
172 | .B \-\-dump\-strings |
173 | Equivalent to \fB\-D\fP. | |
174 | .TP | |
175 | .B \-\-help | |
176 | Display a usage message on standard output and exit successfully. | |
177 | .TP | |
28ef6c31 | 178 | \fB\-\-init\-file\fP \fIfile\fP |
7117c2d2 | 179 | .PD 0 |
28ef6c31 JA |
180 | .TP |
181 | \fB\-\-rcfile\fP \fIfile\fP | |
182 | .PD | |
183 | Execute commands from | |
184 | .I file | |
185 | instead of the standard personal initialization file | |
186 | .I ~/.bashrc | |
187 | if the shell is interactive (see | |
188 | .SM | |
189 | .B INVOCATION | |
190 | below). | |
191 | .TP | |
ccc6cda3 | 192 | .B \-\-login |
7117c2d2 | 193 | Equivalent to \fB\-l\fP. |
ccc6cda3 JA |
194 | .TP |
195 | .B \-\-noediting | |
196 | Do not use the GNU | |
197 | .B readline | |
bb70624e | 198 | library to read command lines when the shell is interactive. |
ccc6cda3 JA |
199 | .TP |
200 | .B \-\-noprofile | |
201 | Do not read either the system-wide startup file | |
726f6388 JA |
202 | .FN /etc/profile |
203 | or any of the personal initialization files | |
204 | .IR ~/.bash_profile , | |
205 | .IR ~/.bash_login , | |
206 | or | |
207 | .IR ~/.profile . | |
208 | By default, | |
209 | .B bash | |
ccc6cda3 | 210 | reads these files when it is invoked as a login shell (see |
726f6388 JA |
211 | .SM |
212 | .B INVOCATION | |
213 | below). | |
214 | .TP | |
ccc6cda3 JA |
215 | .B \-\-norc |
216 | Do not read and execute the personal initialization file | |
217 | .I ~/.bashrc | |
218 | if the shell is interactive. | |
219 | This option is on by default if the shell is invoked as | |
220 | .BR sh . | |
221 | .TP | |
222 | .B \-\-posix | |
223 | Change the behavior of \fBbash\fP where the default operation differs | |
ac18b312 | 224 | from the POSIX standard to match the standard (\fIposix mode\fP). |
c677e9e0 CR |
225 | See |
226 | .SM | |
227 | .B "SEE ALSO" | |
228 | below for a reference to a document that details how posix mode affects | |
229 | bash's behavior. | |
726f6388 | 230 | .TP |
ccc6cda3 JA |
231 | .B \-\-restricted |
232 | The shell becomes restricted (see | |
233 | .SM | |
234 | .B "RESTRICTED SHELL" | |
726f6388 JA |
235 | below). |
236 | .TP | |
ccc6cda3 JA |
237 | .B \-\-verbose |
238 | Equivalent to \fB\-v\fP. | |
726f6388 | 239 | .TP |
ccc6cda3 JA |
240 | .B \-\-version |
241 | Show version information for this instance of | |
242 | .B bash | |
243 | on the standard output and exit successfully. | |
726f6388 JA |
244 | .PD |
245 | .SH ARGUMENTS | |
246 | If arguments remain after option processing, and neither the | |
247 | .B \-c | |
248 | nor the | |
249 | .B \-s | |
250 | option has been supplied, the first argument is assumed to | |
ccc6cda3 JA |
251 | be the name of a file containing shell commands. |
252 | If | |
726f6388 JA |
253 | .B bash |
254 | is invoked in this fashion, | |
255 | .B $0 | |
256 | is set to the name of the file, and the positional parameters | |
257 | are set to the remaining arguments. | |
258 | .B Bash | |
259 | reads and executes commands from this file, then exits. | |
ccc6cda3 JA |
260 | \fBBash\fP's exit status is the exit status of the last command |
261 | executed in the script. | |
262 | If no commands are executed, the exit status is 0. | |
f73dda09 JA |
263 | An attempt is first made to open the file in the current directory, and, |
264 | if no file is found, then the shell searches the directories in | |
265 | .SM | |
266 | .B PATH | |
267 | for the script. | |
ccc6cda3 JA |
268 | .SH INVOCATION |
269 | A \fIlogin shell\fP is one whose first character of argument zero is a | |
270 | .BR \- , | |
271 | or one started with the | |
272 | .B \-\-login | |
273 | option. | |
274 | .PP | |
bb70624e JA |
275 | An \fIinteractive\fP shell is one started without non-option arguments |
276 | and without the | |
277 | .B \-c | |
278 | option | |
da5b17cd | 279 | whose standard input and error are |
ccc6cda3 JA |
280 | both connected to terminals (as determined by |
281 | .IR isatty (3)), | |
282 | or one started with the | |
283 | .B \-i | |
284 | option. | |
285 | .SM | |
286 | .B PS1 | |
287 | is set and | |
288 | .B $\- | |
289 | includes | |
290 | .B i | |
291 | if | |
292 | .B bash | |
293 | is interactive, | |
294 | allowing a shell script or a startup file to test this state. | |
295 | .PP | |
296 | The following paragraphs describe how | |
297 | .B bash | |
298 | executes its startup files. | |
299 | If any of the files exist but cannot be read, | |
300 | .B bash | |
301 | reports an error. | |
b28ff8c9 | 302 | Tildes are expanded in filenames as described below under |
ccc6cda3 JA |
303 | .B "Tilde Expansion" |
304 | in the | |
305 | .SM | |
306 | .B EXPANSION | |
307 | section. | |
308 | .PP | |
309 | When | |
310 | .B bash | |
b72432fd JA |
311 | is invoked as an interactive login shell, or as a non-interactive shell |
312 | with the \fB\-\-login\fP option, it first reads and | |
d166f048 JA |
313 | executes commands from the file \fI/etc/profile\fP, if that |
314 | file exists. | |
ccc6cda3 JA |
315 | After reading that file, it looks for \fI~/.bash_profile\fP, |
316 | \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads | |
317 | and executes commands from the first one that exists and is readable. | |
318 | The | |
319 | .B \-\-noprofile | |
320 | option may be used when the shell is started to inhibit this behavior. | |
321 | .PP | |
322 | When a login shell exits, | |
323 | .B bash | |
324 | reads and executes commands from the file \fI~/.bash_logout\fP, if it | |
325 | exists. | |
326 | .PP | |
327 | When an interactive shell that is not a login shell is started, | |
328 | .B bash | |
329 | reads and executes commands from \fI~/.bashrc\fP, if that file exists. | |
330 | This may be inhibited by using the | |
331 | .B \-\-norc | |
332 | option. | |
333 | The \fB\-\-rcfile\fP \fIfile\fP option will force | |
334 | .B bash | |
335 | to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP. | |
336 | .PP | |
337 | When | |
338 | .B bash | |
339 | is started non-interactively, to run a shell script, for example, it | |
340 | looks for the variable | |
341 | .SM | |
342 | .B BASH_ENV | |
343 | in the environment, expands its value if it appears there, and uses the | |
344 | expanded value as the name of a file to read and execute. | |
345 | .B Bash | |
346 | behaves as if the following command were executed: | |
347 | .sp .5 | |
348 | .RS | |
28ef6c31 JA |
349 | .if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP |
350 | .if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi | |
ccc6cda3 JA |
351 | .RE |
352 | .sp .5 | |
353 | but the value of the | |
354 | .SM | |
355 | .B PATH | |
b28ff8c9 | 356 | variable is not used to search for the filename. |
ccc6cda3 JA |
357 | .PP |
358 | If | |
359 | .B bash | |
360 | is invoked with the name | |
361 | .BR sh , | |
362 | it tries to mimic the startup behavior of historical versions of | |
363 | .B sh | |
364 | as closely as possible, | |
365 | while conforming to the POSIX standard as well. | |
b72432fd JA |
366 | When invoked as an interactive login shell, or a non-interactive |
367 | shell with the \fB\-\-login\fP option, it first attempts to | |
cce855bc | 368 | read and execute commands from |
ccc6cda3 JA |
369 | .I /etc/profile |
370 | and | |
371 | .IR ~/.profile , | |
372 | in that order. | |
373 | The | |
374 | .B \-\-noprofile | |
375 | option may be used to inhibit this behavior. | |
376 | When invoked as an interactive shell with the name | |
377 | .BR sh , | |
378 | .B bash | |
379 | looks for the variable | |
380 | .SM | |
381 | .BR ENV , | |
382 | expands its value if it is defined, and uses the | |
383 | expanded value as the name of a file to read and execute. | |
384 | Since a shell invoked as | |
385 | .B sh | |
386 | does not attempt to read and execute commands from any other startup | |
387 | files, the | |
388 | .B \-\-rcfile | |
389 | option has no effect. | |
390 | A non-interactive shell invoked with the name | |
391 | .B sh | |
b72432fd | 392 | does not attempt to read any other startup files. |
ccc6cda3 JA |
393 | When invoked as |
394 | .BR sh , | |
395 | .B bash | |
396 | enters | |
397 | .I posix | |
398 | mode after the startup files are read. | |
399 | .PP | |
400 | When | |
401 | .B bash | |
402 | is started in | |
403 | .I posix | |
404 | mode, as with the | |
405 | .B \-\-posix | |
406 | command line option, it follows the POSIX standard for startup files. | |
cce855bc | 407 | In this mode, interactive shells expand the |
ccc6cda3 JA |
408 | .SM |
409 | .B ENV | |
cce855bc | 410 | variable and commands are read and executed from the file |
ccc6cda3 JA |
411 | whose name is the expanded value. |
412 | No other startup files are read. | |
ccc6cda3 JA |
413 | .PP |
414 | .B Bash | |
866961ad | 415 | attempts to determine when it is being run with its standard input |
dc60d4e0 | 416 | connected to a network connection, as when executed by the remote shell |
866961ad | 417 | daemon, usually \fIrshd\fP, or the secure shell daemon \fIsshd\fP. |
ccc6cda3 JA |
418 | If |
419 | .B bash | |
866961ad | 420 | determines it is being run in this fashion, it reads and executes |
ccc6cda3 JA |
421 | commands from \fI~/.bashrc\fP, if that file exists and is readable. |
422 | It will not do this if invoked as \fBsh\fP. | |
423 | The | |
424 | .B \-\-norc | |
425 | option may be used to inhibit this behavior, and the | |
426 | .B \-\-rcfile | |
1442f67c CR |
427 | option may be used to force another file to be read, but neither |
428 | \fIrshd\fP nor \fIsshd\fP generally invoke the shell with those options | |
ccc6cda3 | 429 | or allow them to be specified. |
b72432fd JA |
430 | .PP |
431 | If the shell is started with the effective user (group) id not equal to the | |
432 | real user (group) id, and the \fB\-p\fP option is not supplied, no startup | |
f73dda09 JA |
433 | files are read, shell functions are not inherited from the environment, the |
434 | .SM | |
691aebcb | 435 | .BR SHELLOPTS , |
984a1947 | 436 | .SM |
691aebcb | 437 | .BR BASHOPTS , |
984a1947 | 438 | .SM |
691aebcb CR |
439 | .BR CDPATH , |
440 | and | |
984a1947 | 441 | .SM |
691aebcb CR |
442 | .B GLOBIGNORE |
443 | variables, if they appear in the environment, are ignored, | |
b72432fd JA |
444 | and the effective user id is set to the real user id. |
445 | If the \fB\-p\fP option is supplied at invocation, the startup behavior is | |
446 | the same, but the effective user id is not reset. | |
726f6388 | 447 | .SH DEFINITIONS |
ccc6cda3 JA |
448 | .PP |
449 | The following definitions are used throughout the rest of this | |
450 | document. | |
726f6388 JA |
451 | .PD 0 |
452 | .TP | |
453 | .B blank | |
454 | A space or tab. | |
455 | .TP | |
456 | .B word | |
457 | A sequence of characters considered as a single unit by the shell. | |
458 | Also known as a | |
459 | .BR token . | |
460 | .TP | |
461 | .B name | |
462 | A | |
463 | .I word | |
464 | consisting only of alphanumeric characters and underscores, and | |
465 | beginning with an alphabetic character or an underscore. Also | |
466 | referred to as an | |
467 | .BR identifier . | |
468 | .TP | |
469 | .B metacharacter | |
470 | A character that, when unquoted, separates words. One of the following: | |
471 | .br | |
472 | .RS | |
473 | .PP | |
474 | .if t \fB| & ; ( ) < > space tab\fP | |
475 | .if n \fB| & ; ( ) < > space tab\fP | |
476 | .RE | |
477 | .PP | |
478 | .TP | |
479 | .B control operator | |
480 | A \fItoken\fP that performs a control function. It is one of the following | |
481 | symbols: | |
482 | .RS | |
483 | .PP | |
adc6cff5 | 484 | .if t \fB|| & && ; ;; ( ) | |& <newline>\fP |
8943768b | 485 | .if n \fB|| & && ; ;; ( ) | |& <newline>\fP |
726f6388 JA |
486 | .RE |
487 | .PD | |
488 | .SH "RESERVED WORDS" | |
489 | \fIReserved words\fP are words that have a special meaning to the shell. | |
490 | The following words are recognized as reserved when unquoted and either | |
491 | the first word of a simple command (see | |
492 | .SM | |
493 | .B SHELL GRAMMAR | |
494 | below) or the third word of a | |
495 | .B case | |
496 | or | |
497 | .B for | |
498 | command: | |
499 | .if t .RS | |
500 | .PP | |
501 | .B | |
8360b906 CR |
502 | .if n ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] |
503 | .if t ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] | |
726f6388 | 504 | .if t .RE |
726f6388 JA |
505 | .SH "SHELL GRAMMAR" |
506 | .SS Simple Commands | |
507 | .PP | |
508 | A \fIsimple command\fP is a sequence of optional variable assignments | |
ccc6cda3 | 509 | followed by \fBblank\fP-separated words and redirections, and |
726f6388 | 510 | terminated by a \fIcontrol operator\fP. The first word |
f73dda09 JA |
511 | specifies the command to be executed, and is passed as argument zero. |
512 | The remaining words are passed as arguments to the invoked command. | |
726f6388 JA |
513 | .PP |
514 | The return value of a \fIsimple command\fP is its exit status, or | |
515 | 128+\fIn\^\fP if the command is terminated by signal | |
516 | .IR n . | |
517 | .SS Pipelines | |
518 | .PP | |
519 | A \fIpipeline\fP is a sequence of one or more commands separated by | |
8943768b CR |
520 | one of the control operators |
521 | .B | | |
522 | or \fB|&\fP. | |
726f6388 JA |
523 | The format for a pipeline is: |
524 | .RS | |
525 | .PP | |
8943768b | 526 | [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ [\fB|\fP\(bv\fB|&\fP] \fIcommand2\fP ... ] |
726f6388 JA |
527 | .RE |
528 | .PP | |
529 | The standard output of | |
530 | .I command | |
f73dda09 | 531 | is connected via a pipe to the standard input of |
726f6388 JA |
532 | .IR command2 . |
533 | This connection is performed before any redirections specified by the | |
534 | command (see | |
535 | .SM | |
536 | .B REDIRECTION | |
537 | below). | |
1442f67c CR |
538 | If \fB|&\fP is used, \fIcommand\fP's standard error, in addition to its |
539 | standard output, is connected to | |
c920c360 CR |
540 | \fIcommand2\fP's standard input through the pipe; |
541 | it is shorthand for \fB2>&1 |\fP. | |
1442f67c | 542 | This implicit redirection of the standard error to the standard output is |
c920c360 | 543 | performed after any redirections specified by the command. |
726f6388 | 544 | .PP |
d3a24ed2 CR |
545 | The return status of a pipeline is the exit status of the last |
546 | command, unless the \fBpipefail\fP option is enabled. | |
547 | If \fBpipefail\fP is enabled, the pipeline's return status is the | |
548 | value of the last (rightmost) command to exit with a non-zero status, | |
549 | or zero if all commands exit successfully. | |
726f6388 JA |
550 | If the reserved word |
551 | .B ! | |
d3a24ed2 CR |
552 | precedes a pipeline, the exit status of that pipeline is the logical |
553 | negation of the exit status as described above. | |
ccc6cda3 | 554 | The shell waits for all commands in the pipeline to |
726f6388 JA |
555 | terminate before returning a value. |
556 | .PP | |
ccc6cda3 JA |
557 | If the |
558 | .B time | |
559 | reserved word precedes a pipeline, the elapsed as well as user and | |
560 | system time consumed by its execution are reported when the pipeline | |
561 | terminates. | |
562 | The \fB\-p\fP option changes the output format to that specified by POSIX. | |
7d92f73f CR |
563 | When the shell is in \fIposix mode\fP, it does not recognize |
564 | \fBtime\fP as a reserved word if the next token begins with a `-'. | |
ccc6cda3 JA |
565 | The |
566 | .SM | |
567 | .B TIMEFORMAT | |
568 | variable may be set to a format string that specifies how the timing | |
569 | information should be displayed; see the description of | |
570 | .SM | |
571 | .B TIMEFORMAT | |
572 | under | |
573 | .B "Shell Variables" | |
574 | below. | |
575 | .PP | |
6faad625 CR |
576 | When the shell is in \fIposix mode\fP, \fBtime\fP |
577 | may be followed by a newline. In this case, the shell displays the | |
578 | total user and system time consumed by the shell and its children. | |
579 | The | |
580 | .SM | |
581 | .B TIMEFORMAT | |
582 | variable may be used to specify the format of | |
583 | the time information. | |
584 | .PP | |
726f6388 JA |
585 | Each command in a pipeline is executed as a separate process (i.e., in a |
586 | subshell). | |
587 | .SS Lists | |
588 | .PP | |
589 | A \fIlist\fP is a sequence of one or more pipelines separated by one | |
590 | of the operators | |
591 | .BR ; , | |
592 | .BR & , | |
593 | .BR && , | |
594 | or | |
adc6cff5 | 595 | .BR || , |
ccc6cda3 | 596 | and optionally terminated by one of |
726f6388 JA |
597 | .BR ; , |
598 | .BR & , | |
599 | or | |
600 | .BR <newline> . | |
601 | .PP | |
602 | Of these list operators, | |
603 | .B && | |
604 | and | |
adc6cff5 | 605 | .B || |
726f6388 JA |
606 | have equal precedence, followed by |
607 | .B ; | |
608 | and | |
b1a26c01 | 609 | .BR & , |
726f6388 JA |
610 | which have equal precedence. |
611 | .PP | |
7117c2d2 JA |
612 | A sequence of one or more newlines may appear in a \fIlist\fP instead |
613 | of a semicolon to delimit commands. | |
614 | .PP | |
726f6388 JA |
615 | If a command is terminated by the control operator |
616 | .BR & , | |
617 | the shell executes the command in the \fIbackground\fP | |
618 | in a subshell. The shell does not wait for the command to | |
619 | finish, and the return status is 0. Commands separated by a | |
620 | .B ; | |
621 | are executed sequentially; the shell waits for each | |
622 | command to terminate in turn. The return status is the | |
623 | exit status of the last command executed. | |
624 | .PP | |
6fbe7620 | 625 | AND and OR lists are sequences of one of more pipelines separated by the |
adc6cff5 | 626 | \fB&&\fP and \fB||\fP control operators, respectively. |
6fbe7620 | 627 | AND and OR lists are executed with left associativity. |
726f6388 JA |
628 | An AND list has the form |
629 | .RS | |
630 | .PP | |
bb70624e | 631 | \fIcommand1\fP \fB&&\fP \fIcommand2\fP |
726f6388 JA |
632 | .RE |
633 | .PP | |
634 | .I command2 | |
635 | is executed if, and only if, | |
bb70624e | 636 | .I command1 |
726f6388 JA |
637 | returns an exit status of zero. |
638 | .PP | |
639 | An OR list has the form | |
640 | .RS | |
641 | .PP | |
adc6cff5 | 642 | \fIcommand1\fP \fB||\fP \fIcommand2\fP |
726f6388 JA |
643 | .PP |
644 | .RE | |
645 | .PP | |
646 | .I command2 | |
647 | is executed if and only if | |
bb70624e | 648 | .I command1 |
6fbe7620 CR |
649 | returns a non-zero exit status. |
650 | The return status of | |
726f6388 JA |
651 | AND and OR lists is the exit status of the last command |
652 | executed in the list. | |
653 | .SS Compound Commands | |
654 | .PP | |
f4f5e1c2 CR |
655 | A \fIcompound command\fP is one of the following. |
656 | In most cases a \fIlist\fP in a command's description may be separated from | |
657 | the rest of the command by one or more newlines, and may be followed by a | |
658 | newline in place of a semicolon. | |
726f6388 JA |
659 | .TP |
660 | (\fIlist\fP) | |
d3a24ed2 CR |
661 | \fIlist\fP is executed in a subshell environment (see |
662 | .SM | |
663 | \fBCOMMAND EXECUTION ENVIRONMENT\fP | |
664 | below). | |
665 | Variable assignments and builtin | |
726f6388 JA |
666 | commands that affect the shell's environment do not remain in effect |
667 | after the command completes. The return status is the exit status of | |
668 | \fIlist\fP. | |
669 | .TP | |
670 | { \fIlist\fP; } | |
ccc6cda3 JA |
671 | \fIlist\fP is simply executed in the current shell environment. |
672 | \fIlist\fP must be terminated with a newline or semicolon. | |
673 | This is known as a \fIgroup command\fP. | |
674 | The return status is the exit status of | |
726f6388 | 675 | \fIlist\fP. |
d3a24ed2 | 676 | Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and |
f73dda09 JA |
677 | \fB}\fP are \fIreserved words\fP and must occur where a reserved |
678 | word is permitted to be recognized. Since they do not cause a word | |
641d8f00 CR |
679 | break, they must be separated from \fIlist\fP by whitespace or another |
680 | shell metacharacter. | |
726f6388 | 681 | .TP |
ccc6cda3 JA |
682 | ((\fIexpression\fP)) |
683 | The \fIexpression\fP is evaluated according to the rules described | |
684 | below under | |
685 | .SM | |
686 | .BR "ARITHMETIC EVALUATION" . | |
687 | If the value of the expression is non-zero, the return status is 0; | |
688 | otherwise the return status is 1. This is exactly equivalent to | |
689 | \fBlet "\fIexpression\fP"\fR. | |
690 | .TP | |
cce855bc JA |
691 | \fB[[\fP \fIexpression\fP \fB]]\fP |
692 | Return a status of 0 or 1 depending on the evaluation of | |
693 | the conditional expression \fIexpression\fP. | |
694 | Expressions are composed of the primaries described below under | |
695 | .SM | |
696 | .BR "CONDITIONAL EXPRESSIONS" . | |
697 | Word splitting and pathname expansion are not performed on the words | |
15825757 CR |
698 | between the \fB[[\fP and \fB]]\fP; tilde expansion, |
699 | parameter and variable expansion, | |
700 | arithmetic expansion, command substitution, process | |
cce855bc | 701 | substitution, and quote removal are performed. |
d3a24ed2 CR |
702 | Conditional operators such as \fB\-f\fP must be unquoted to be recognized |
703 | as primaries. | |
cce855bc JA |
704 | .if t .sp 0.5 |
705 | .if n .sp 1 | |
54a1fa7c | 706 | When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort |
a8fd3f3e CR |
707 | lexicographically using the current locale. |
708 | .if t .sp 0.5 | |
709 | .if n .sp 1 | |
cce855bc JA |
710 | When the \fB==\fP and \fB!=\fP operators are used, the string to the |
711 | right of the operator is considered a pattern and matched according | |
712 | to the rules described below under \fBPattern Matching\fP. | |
df0e4bfe | 713 | The \fB=\fP operator is equivalent to \fB==\fP. |
2206f89a CR |
714 | If the shell option |
715 | .B nocasematch | |
716 | is enabled, the match is performed without regard to the case | |
717 | of alphabetic characters. | |
dc8fbaf9 CR |
718 | The return value is 0 if the string matches (\fB==\fP) or does not match |
719 | (\fB!=\fP) the pattern, and 1 otherwise. | |
e192f341 CR |
720 | Any part of the pattern may be quoted to force the quoted portion |
721 | to be matched as a string. | |
cce855bc JA |
722 | .if t .sp 0.5 |
723 | .if n .sp 1 | |
d3a24ed2 CR |
724 | An additional binary operator, \fB=~\fP, is available, with the same |
725 | precedence as \fB==\fP and \fB!=\fP. | |
726 | When it is used, the string to the right of the operator is considered | |
727 | an extended regular expression and matched accordingly (as in \fIregex\fP(3)). | |
d7f49990 CR |
728 | The return value is 0 if the string matches |
729 | the pattern, and 1 otherwise. | |
d3a24ed2 CR |
730 | If the regular expression is syntactically incorrect, the conditional |
731 | expression's return value is 2. | |
732 | If the shell option | |
2206f89a | 733 | .B nocasematch |
d3a24ed2 CR |
734 | is enabled, the match is performed without regard to the case |
735 | of alphabetic characters. | |
e192f341 CR |
736 | Any part of the pattern may be quoted to force the quoted portion |
737 | to be matched as a string. | |
084c952b CR |
738 | Bracket expressions in regular expressions must be treated carefully, |
739 | since normal quoting characters lose their meanings between brackets. | |
740 | If the pattern is stored in a shell variable, quoting the variable | |
741 | expansion forces the entire pattern to be matched as a string. | |
d3a24ed2 | 742 | Substrings matched by parenthesized subexpressions within the regular |
984a1947 CR |
743 | expression are saved in the array variable |
744 | .SM | |
745 | .BR BASH_REMATCH . | |
746 | The element of | |
747 | .SM | |
748 | .B BASH_REMATCH | |
749 | with index 0 is the portion of the string | |
d3a24ed2 | 750 | matching the entire regular expression. |
984a1947 CR |
751 | The element of |
752 | .SM | |
753 | .B BASH_REMATCH | |
754 | with index \fIn\fP is the portion of the | |
d3a24ed2 CR |
755 | string matching the \fIn\fPth parenthesized subexpression. |
756 | .if t .sp 0.5 | |
757 | .if n .sp 1 | |
cce855bc JA |
758 | Expressions may be combined using the following operators, listed |
759 | in decreasing order of precedence: | |
760 | .if t .sp 0.5 | |
761 | .if n .sp 1 | |
762 | .RS | |
763 | .PD 0 | |
764 | .TP | |
765 | .B ( \fIexpression\fP ) | |
766 | Returns the value of \fIexpression\fP. | |
767 | This may be used to override the normal precedence of operators. | |
768 | .TP | |
769 | .B ! \fIexpression\fP | |
770 | True if | |
771 | .I expression | |
772 | is false. | |
773 | .TP | |
774 | \fIexpression1\fP \fB&&\fP \fIexpression2\fP | |
775 | True if both | |
776 | .I expression1 | |
777 | and | |
778 | .I expression2 | |
779 | are true. | |
780 | .TP | |
adc6cff5 | 781 | \fIexpression1\fP \fB||\fP \fIexpression2\fP |
cce855bc JA |
782 | True if either |
783 | .I expression1 | |
784 | or | |
785 | .I expression2 | |
786 | is true. | |
787 | .PD | |
cce855bc | 788 | .LP |
adc6cff5 | 789 | The \fB&&\fP and \fB||\fP |
7117c2d2 | 790 | operators do not evaluate \fIexpression2\fP if the value of |
cce855bc JA |
791 | \fIexpression1\fP is sufficient to determine the return value of |
792 | the entire conditional expression. | |
f73dda09 | 793 | .RE |
cce855bc | 794 | .TP |
0d8616ff | 795 | \fBfor\fP \fIname\fP [ [ \fBin\fP [ \fIword ...\fP ] ] ; ] \fBdo\fP \fIlist\fP ; \fBdone\fP |
726f6388 | 796 | The list of words following \fBin\fP is expanded, generating a list |
bb70624e JA |
797 | of items. |
798 | The variable \fIname\fP is set to each element of this list | |
799 | in turn, and \fIlist\fP is executed each time. | |
800 | If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes | |
801 | \fIlist\fP once for each positional parameter that is set (see | |
726f6388 JA |
802 | .SM |
803 | .B PARAMETERS | |
804 | below). | |
cce855bc JA |
805 | The return status is the exit status of the last command that executes. |
806 | If the expansion of the items following \fBin\fP results in an empty | |
807 | list, no commands are executed, and the return status is 0. | |
726f6388 | 808 | .TP |
bb70624e JA |
809 | \fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP |
810 | First, the arithmetic expression \fIexpr1\fP is evaluated according | |
811 | to the rules described below under | |
812 | .SM | |
813 | .BR "ARITHMETIC EVALUATION" . | |
814 | The arithmetic expression \fIexpr2\fP is then evaluated repeatedly | |
815 | until it evaluates to zero. | |
816 | Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is | |
817 | executed and the arithmetic expression \fIexpr3\fP is evaluated. | |
818 | If any expression is omitted, it behaves as if it evaluates to 1. | |
819 | The return value is the exit status of the last command in \fIlist\fP | |
820 | that is executed, or false if any of the expressions is invalid. | |
821 | .TP | |
b72432fd | 822 | \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP |
726f6388 JA |
823 | The list of words following \fBin\fP is expanded, generating a list |
824 | of items. The set of expanded words is printed on the standard | |
825 | error, each preceded by a number. If the \fBin\fP | |
826 | \fIword\fP is omitted, the positional parameters are printed (see | |
827 | .SM | |
828 | .B PARAMETERS | |
829 | below). The | |
984a1947 | 830 | .SM |
726f6388 JA |
831 | .B PS3 |
832 | prompt is then displayed and a line read from the standard input. | |
ccc6cda3 | 833 | If the line consists of a number corresponding to one of |
726f6388 JA |
834 | the displayed words, then the value of |
835 | .I name | |
836 | is set to that word. If the line is empty, the words and prompt | |
837 | are displayed again. If EOF is read, the command completes. Any | |
838 | other value read causes | |
839 | .I name | |
840 | to be set to null. The line read is saved in the variable | |
984a1947 | 841 | .SM |
726f6388 JA |
842 | .BR REPLY . |
843 | The | |
844 | .I list | |
845 | is executed after each selection until a | |
846 | .B break | |
726f6388 JA |
847 | command is executed. |
848 | The exit status of | |
849 | .B select | |
850 | is the exit status of the last command executed in | |
851 | .IR list , | |
852 | or zero if no commands were executed. | |
853 | .TP | |
bb70624e | 854 | \fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \ |
726f6388 JA |
855 | ... ) \fIlist\fP ;; ] ... \fBesac\fP |
856 | A \fBcase\fP command first expands \fIword\fP, and tries to match | |
857 | it against each \fIpattern\fP in turn, using the same matching rules | |
858 | as for pathname expansion (see | |
859 | .B Pathname Expansion | |
2206f89a | 860 | below). |
dc8fbaf9 | 861 | The \fIword\fP is expanded using tilde |
d3ad40de | 862 | expansion, parameter and variable expansion, arithmetic substitution, |
dc8fbaf9 CR |
863 | command substitution, process substitution and quote removal. |
864 | Each \fIpattern\fP examined is expanded using tilde | |
d3ad40de | 865 | expansion, parameter and variable expansion, arithmetic substitution, |
dc8fbaf9 | 866 | command substitution, and process substitution. |
2206f89a CR |
867 | If the shell option |
868 | .B nocasematch | |
869 | is enabled, the match is performed without regard to the case | |
870 | of alphabetic characters. | |
8943768b CR |
871 | When a match is found, the corresponding \fIlist\fP is executed. |
872 | If the \fB;;\fP operator is used, no subsequent matches are attempted after | |
873 | the first pattern match. | |
874 | Using \fB;&\fP in place of \fB;;\fP causes execution to continue with | |
875 | the \fIlist\fP associated with the next set of patterns. | |
876 | Using \fB;;&\fP in place of \fB;;\fP causes the shell to test the next | |
877 | pattern list in the statement, if any, and execute any associated \fIlist\fP | |
878 | on a successful match. | |
879 | The exit status is zero if no | |
ccc6cda3 | 880 | pattern matches. Otherwise, it is the exit status of the |
726f6388 JA |
881 | last command executed in \fIlist\fP. |
882 | .TP | |
ccc6cda3 JA |
883 | \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \ |
884 | [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \ | |
885 | [ \fBelse\fP \fIlist\fP; ] \fBfi\fP | |
726f6388 JA |
886 | The |
887 | .B if | |
888 | .I list | |
889 | is executed. If its exit status is zero, the | |
890 | \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP | |
891 | \fIlist\fP is executed in turn, and if its exit status is zero, | |
892 | the corresponding \fBthen\fP \fIlist\fP is executed and the | |
893 | command completes. Otherwise, the \fBelse\fP \fIlist\fP is | |
894 | executed, if present. The exit status is the exit status of the | |
895 | last command executed, or zero if no condition tested true. | |
896 | .TP | |
89c77bc7 | 897 | \fBwhile\fP \fIlist-1\fP; \fBdo\fP \fIlist-2\fP; \fBdone\fP |
7117c2d2 | 898 | .PD 0 |
726f6388 | 899 | .TP |
89c77bc7 | 900 | \fBuntil\fP \fIlist-1\fP; \fBdo\fP \fIlist-2\fP; \fBdone\fP |
726f6388 | 901 | .PD |
89c77bc7 CR |
902 | The \fBwhile\fP command continuously executes the list |
903 | \fIlist-2\fP as long as the last command in the list \fIlist-1\fP returns | |
726f6388 JA |
904 | an exit status of zero. The \fBuntil\fP command is identical |
905 | to the \fBwhile\fP command, except that the test is negated; | |
89c77bc7 | 906 | .I list-2 |
726f6388 | 907 | is executed as long as the last command in |
89c77bc7 | 908 | .I list-1 |
ccc6cda3 | 909 | returns a non-zero exit status. |
726f6388 JA |
910 | The exit status of the \fBwhile\fP and \fBuntil\fP commands |
911 | is the exit status | |
89c77bc7 | 912 | of the last command executed in \fIlist-2\fP, or zero if |
726f6388 | 913 | none was executed. |
09767ff0 CR |
914 | .SS Coprocesses |
915 | .PP | |
916 | A \fIcoprocess\fP is a shell command preceded by the \fBcoproc\fP reserved | |
917 | word. | |
918 | A coprocess is executed asynchronously in a subshell, as if the command | |
919 | had been terminated with the \fB&\fP control operator, with a two-way pipe | |
920 | established between the executing shell and the coprocess. | |
921 | .PP | |
922 | The format for a coprocess is: | |
923 | .RS | |
924 | .PP | |
925 | \fBcoproc\fP [\fINAME\fP] \fIcommand\fP [\fIredirections\fP] | |
926 | .RE | |
927 | .PP | |
928 | This creates a coprocess named \fINAME\fP. | |
f6da9f85 | 929 | If \fINAME\fP is not supplied, the default name is \fBCOPROC\fP. |
e141c35a CR |
930 | \fINAME\fP must not be supplied if \fIcommand\fP is a \fIsimple |
931 | command\fP (see above); otherwise, it is interpreted as the first word | |
932 | of the simple command. | |
b28ff8c9 | 933 | When the coprocess is executed, the shell creates an array variable (see |
09767ff0 CR |
934 | .B Arrays |
935 | below) named \fINAME\fP in the context of the executing shell. | |
936 | The standard output of | |
937 | .I command | |
938 | is connected via a pipe to a file descriptor in the executing shell, | |
939 | and that file descriptor is assigned to \fINAME\fP[0]. | |
940 | The standard input of | |
941 | .I command | |
942 | is connected via a pipe to a file descriptor in the executing shell, | |
943 | and that file descriptor is assigned to \fINAME\fP[1]. | |
944 | This pipe is established before any redirections specified by the | |
945 | command (see | |
946 | .SM | |
947 | .B REDIRECTION | |
948 | below). | |
949 | The file descriptors can be utilized as arguments to shell commands | |
950 | and redirections using standard word expansions. | |
8360b906 | 951 | The file descriptors are not available in subshells. |
dc60d4e0 | 952 | The process ID of the shell spawned to execute the coprocess is |
30915f17 CR |
953 | available as the value of the variable \fINAME\fP_PID. |
954 | The \fBwait\fP | |
955 | builtin command may be used to wait for the coprocess to terminate. | |
09767ff0 | 956 | .PP |
77b3aacb CR |
957 | Since the coprocess is created as an asynchronous command, |
958 | the \fBcoproc\fP command always returns success. | |
09767ff0 | 959 | The return status of a coprocess is the exit status of \fIcommand\fP. |
d3a24ed2 CR |
960 | .SS Shell Function Definitions |
961 | .PP | |
962 | A shell function is an object that is called like a simple command and | |
963 | executes a compound command with a new set of positional parameters. | |
964 | Shell functions are declared as follows: | |
965 | .TP | |
9ec5ed66 CR |
966 | \fIname\fP () \fIcompound\-command\fP [\fIredirection\fP] |
967 | .PD 0 | |
968 | .TP | |
969 | \fBfunction\fP \fIname\fP [()] \fIcompound\-command\fP [\fIredirection\fP] | |
970 | .PD | |
d3a24ed2 CR |
971 | This defines a function named \fIname\fP. |
972 | The reserved word \fBfunction\fP is optional. | |
973 | If the \fBfunction\fP reserved word is supplied, the parentheses are optional. | |
974 | The \fIbody\fP of the function is the compound command | |
975 | .I compound\-command | |
976 | (see \fBCompound Commands\fP above). | |
977 | That command is usually a \fIlist\fP of commands between { and }, but | |
978 | may be any command listed under \fBCompound Commands\fP above. | |
979 | \fIcompound\-command\fP is executed whenever \fIname\fP is specified as the | |
980 | name of a simple command. | |
b28ff8c9 CR |
981 | When in \fIposix mode\fP, \fIname\fP may not be the name of one of the |
982 | POSIX \fIspecial builtins\fP. | |
d3a24ed2 CR |
983 | Any redirections (see |
984 | .SM | |
985 | .B REDIRECTION | |
986 | below) specified when a function is defined are performed | |
987 | when the function is executed. | |
988 | The exit status of a function definition is zero unless a syntax error | |
989 | occurs or a readonly function with the same name already exists. | |
990 | When executed, the exit status of a function is the exit status of the | |
991 | last command executed in the body. (See | |
726f6388 JA |
992 | .SM |
993 | .B FUNCTIONS | |
994 | below.) | |
995 | .SH COMMENTS | |
ccc6cda3 JA |
996 | In a non-interactive shell, or an interactive shell in which the |
997 | .B interactive_comments | |
998 | option to the | |
999 | .B shopt | |
1000 | builtin is enabled (see | |
1001 | .SM | |
1002 | .B "SHELL BUILTIN COMMANDS" | |
1003 | below), a word beginning with | |
726f6388 JA |
1004 | .B # |
1005 | causes that word and all remaining characters on that line to | |
1006 | be ignored. An interactive shell without the | |
ccc6cda3 | 1007 | .B interactive_comments |
ccc6cda3 JA |
1008 | option enabled does not allow comments. The |
1009 | .B interactive_comments | |
1010 | option is on by default in interactive shells. | |
726f6388 JA |
1011 | .SH QUOTING |
1012 | \fIQuoting\fP is used to remove the special meaning of certain | |
1013 | characters or words to the shell. Quoting can be used to | |
1014 | disable special treatment for special characters, to prevent | |
1015 | reserved words from being recognized as such, and to prevent | |
1016 | parameter expansion. | |
1017 | .PP | |
1018 | Each of the \fImetacharacters\fP listed above under | |
1019 | .SM | |
1020 | .B DEFINITIONS | |
bb70624e JA |
1021 | has special meaning to the shell and must be quoted if it is to |
1022 | represent itself. | |
1023 | .PP | |
5c96a638 CR |
1024 | When the command history expansion facilities are being used |
1025 | (see | |
1026 | .SM | |
1027 | .B HISTORY EXPANSION | |
1028 | below), the | |
bb70624e JA |
1029 | \fIhistory expansion\fP character, usually \fB!\fP, must be quoted |
1030 | to prevent history expansion. | |
1031 | .PP | |
1032 | There are three quoting mechanisms: the | |
726f6388 JA |
1033 | .IR "escape character" , |
1034 | single quotes, and double quotes. | |
1035 | .PP | |
1036 | A non-quoted backslash (\fB\e\fP) is the | |
1037 | .IR "escape character" . | |
1038 | It preserves the literal value of the next character that follows, | |
1039 | with the exception of <newline>. If a \fB\e\fP<newline> pair | |
cce855bc JA |
1040 | appears, and the backslash is not itself quoted, the \fB\e\fP<newline> |
1041 | is treated as a line continuation (that is, it is removed from the | |
1042 | input stream and effectively ignored). | |
726f6388 JA |
1043 | .PP |
1044 | Enclosing characters in single quotes preserves the literal value | |
1045 | of each character within the quotes. A single quote may not occur | |
1046 | between single quotes, even when preceded by a backslash. | |
1047 | .PP | |
1048 | Enclosing characters in double quotes preserves the literal value | |
1049 | of all characters within the quotes, with the exception of | |
1050 | .BR $ , | |
3d4e09aa | 1051 | .BR \` , |
5c96a638 CR |
1052 | .BR \e , |
1053 | and, when history expansion is enabled, | |
1054 | .BR ! . | |
726f6388 JA |
1055 | The characters |
1056 | .B $ | |
1057 | and | |
3d4e09aa | 1058 | .B \` |
726f6388 JA |
1059 | retain their special meaning within double quotes. The backslash |
1060 | retains its special meaning only when followed by one of the following | |
1061 | characters: | |
1062 | .BR $ , | |
3d4e09aa | 1063 | .BR \` , |
726f6388 JA |
1064 | \^\fB"\fP\^, |
1065 | .BR \e , | |
1066 | or | |
1067 | .BR <newline> . | |
1068 | A double quote may be quoted within double quotes by preceding it with | |
1069 | a backslash. | |
5c96a638 CR |
1070 | If enabled, history expansion will be performed unless an |
1071 | .B ! | |
1072 | appearing in double quotes is escaped using a backslash. | |
1073 | The backslash preceding the | |
1074 | .B ! | |
1075 | is not removed. | |
726f6388 JA |
1076 | .PP |
1077 | The special parameters | |
1078 | .B * | |
1079 | and | |
1080 | .B @ | |
1081 | have special meaning when in double | |
1082 | quotes (see | |
1083 | .SM | |
1084 | .B PARAMETERS | |
1085 | below). | |
ccc6cda3 | 1086 | .PP |
20587658 | 1087 | Words of the form \fB$\fP\(aq\fIstring\fP\(aq are treated specially. The |
ccc6cda3 | 1088 | word expands to \fIstring\fP, with backslash-escaped characters replaced |
f75912ae | 1089 | as specified by the ANSI C standard. Backslash escape sequences, if |
ccc6cda3 JA |
1090 | present, are decoded as follows: |
1091 | .RS | |
1092 | .PD 0 | |
1093 | .TP | |
1094 | .B \ea | |
1095 | alert (bell) | |
1096 | .TP | |
1097 | .B \eb | |
1098 | backspace | |
1099 | .TP | |
1100 | .B \ee | |
a3143574 CR |
1101 | .TP |
1102 | .B \eE | |
ccc6cda3 JA |
1103 | an escape character |
1104 | .TP | |
1105 | .B \ef | |
1106 | form feed | |
1107 | .TP | |
1108 | .B \en | |
1109 | new line | |
1110 | .TP | |
1111 | .B \er | |
1112 | carriage return | |
1113 | .TP | |
1114 | .B \et | |
1115 | horizontal tab | |
1116 | .TP | |
1117 | .B \ev | |
1118 | vertical tab | |
1119 | .TP | |
1120 | .B \e\e | |
1121 | backslash | |
bb70624e | 1122 | .TP |
20587658 | 1123 | .B \e\(aq |
bb70624e | 1124 | single quote |
a3143574 CR |
1125 | .TP |
1126 | .B \e\(dq | |
1127 | double quote | |
ccc6cda3 JA |
1128 | .TP |
1129 | .B \e\fInnn\fP | |
f73dda09 | 1130 | the eight-bit character whose value is the octal value \fInnn\fP |
cce855bc JA |
1131 | (one to three digits) |
1132 | .TP | |
f73dda09 JA |
1133 | .B \ex\fIHH\fP |
1134 | the eight-bit character whose value is the hexadecimal value \fIHH\fP | |
1135 | (one or two hex digits) | |
7117c2d2 | 1136 | .TP |
eb0b2ad8 CR |
1137 | .B \eu\fIHHHH\fP |
1138 | the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value | |
1139 | \fIHHHH\fP (one to four hex digits) | |
1140 | .TP | |
1141 | .B \eU\fIHHHHHHHH\fP | |
1142 | the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value | |
1143 | \fIHHHHHHHH\fP (one to eight hex digits) | |
1144 | .TP | |
7117c2d2 JA |
1145 | .B \ec\fIx\fP |
1146 | a control-\fIx\fP character | |
ccc6cda3 JA |
1147 | .PD |
1148 | .RE | |
1149 | .LP | |
bb70624e | 1150 | The expanded result is single-quoted, as if the dollar sign had |
ccc6cda3 JA |
1151 | not been present. |
1152 | .PP | |
08e72d7a CR |
1153 | A double-quoted string preceded by a dollar sign (\fB$\fP\(dq\fIstring\fP\(dq) |
1154 | will cause the string to be translated according to the current locale. | |
ccc6cda3 JA |
1155 | If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign |
1156 | is ignored. | |
1157 | If the string is translated and replaced, the replacement is | |
1158 | double-quoted. | |
726f6388 JA |
1159 | .SH PARAMETERS |
1160 | A | |
1161 | .I parameter | |
ccc6cda3 JA |
1162 | is an entity that stores values. |
1163 | It can be a | |
726f6388 JA |
1164 | .IR name , |
1165 | a number, or one of the special characters listed below under | |
1166 | .BR "Special Parameters" . | |
d3a24ed2 | 1167 | A |
726f6388 JA |
1168 | .I variable |
1169 | is a parameter denoted by a | |
1170 | .IR name . | |
f73dda09 JA |
1171 | A variable has a \fIvalue\fP and zero or more \fIattributes\fP. |
1172 | Attributes are assigned using the | |
1173 | .B declare | |
1174 | builtin command (see | |
1175 | .B declare | |
1176 | below in | |
1177 | .SM | |
1178 | .BR "SHELL BUILTIN COMMANDS" ). | |
726f6388 JA |
1179 | .PP |
1180 | A parameter is set if it has been assigned a value. The null string is | |
1181 | a valid value. Once a variable is set, it may be unset only by using | |
1182 | the | |
1183 | .B unset | |
1184 | builtin command (see | |
1185 | .SM | |
1186 | .B SHELL BUILTIN COMMANDS | |
1187 | below). | |
1188 | .PP | |
1189 | A | |
1190 | .I variable | |
1191 | may be assigned to by a statement of the form | |
1192 | .RS | |
1193 | .PP | |
1194 | \fIname\fP=[\fIvalue\fP] | |
1195 | .RE | |
1196 | .PP | |
1197 | If | |
1198 | .I value | |
1199 | is not given, the variable is assigned the null string. All | |
1200 | .I values | |
bb70624e JA |
1201 | undergo tilde expansion, parameter and variable expansion, |
1202 | command substitution, arithmetic expansion, and quote | |
ccc6cda3 JA |
1203 | removal (see |
1204 | .SM | |
1205 | .B EXPANSION | |
1206 | below). If the variable has its | |
cce855bc | 1207 | .B integer |
f73dda09 | 1208 | attribute set, then |
726f6388 | 1209 | .I value |
d3a24ed2 | 1210 | is evaluated as an arithmetic expression even if the $((...)) expansion is |
cce855bc | 1211 | not used (see |
ccc6cda3 JA |
1212 | .B "Arithmetic Expansion" |
1213 | below). | |
1214 | Word splitting is not performed, with the exception | |
726f6388 JA |
1215 | of \fB"$@"\fP as explained below under |
1216 | .BR "Special Parameters" . | |
1217 | Pathname expansion is not performed. | |
f73dda09 | 1218 | Assignment statements may also appear as arguments to the |
5e13499c | 1219 | .BR alias , |
f73dda09 JA |
1220 | .BR declare , |
1221 | .BR typeset , | |
1222 | .BR export , | |
1223 | .BR readonly , | |
1224 | and | |
1225 | .B local | |
1226 | builtin commands. | |
19baff85 CR |
1227 | When in \fIposix mode\fP, these builtins may appear in a command after |
1228 | one or more instances of the \fBcommand\fP builtin and retain these | |
1229 | assignment statement properties. | |
d11b8b46 CR |
1230 | .PP |
1231 | In the context where an assignment statement is assigning a value | |
1232 | to a shell variable or array index, the += operator can be used to | |
1233 | append to or add to the variable's previous value. | |
dc60d4e0 | 1234 | When += is applied to a variable for which the \fIinteger\fP attribute has been |
d11b8b46 CR |
1235 | set, \fIvalue\fP is evaluated as an arithmetic expression and added to the |
1236 | variable's current value, which is also evaluated. | |
1237 | When += is applied to an array variable using compound assignment (see | |
1238 | .B Arrays | |
1239 | below), the | |
1240 | variable's value is not unset (as it is when using =), and new values are | |
fdf670ea CR |
1241 | appended to the array beginning at one greater than the array's maximum index |
1242 | (for indexed arrays) or added as additional key\-value pairs in an | |
1243 | associative array. | |
d11b8b46 CR |
1244 | When applied to a string-valued variable, \fIvalue\fP is expanded and |
1245 | appended to the variable's value. | |
87c1f4ec CR |
1246 | .PP |
1247 | A variable can be assigned the \fInameref\fP attribute using the | |
1248 | \fB\-n\fP option to the \fBdeclare\fP or \fBlocal\fP builtin commands | |
1249 | (see the descriptions of \fBdeclare\fP and \fBlocal\fP below) | |
1250 | to create a \fInameref\fP, or a reference to another variable. | |
1251 | This allows variables to be manipulated indirectly. | |
1252 | Whenever the nameref variable is referenced or assigned to, the operation | |
1253 | is actually performed on the variable specified by the nameref variable's | |
1254 | value. | |
1255 | A nameref is commonly used within shell functions to refer to a variable | |
1256 | whose name is passed as an argument to the function. | |
1257 | For instance, if a variable name is passed to a shell function as its first | |
1258 | argument, running | |
1259 | .sp .5 | |
1260 | .RS | |
1261 | .if t \f(CWdeclare -n ref=$1\fP | |
1262 | .if n declare -n ref=$1 | |
1263 | .RE | |
1264 | .sp .5 | |
1265 | inside the function creates a nameref variable \fBref\fP whose value is | |
1266 | the variable name passed as the first argument. | |
1267 | References and assignments to \fBref\fP are treated as references and | |
1268 | assignments to the variable whose name was passed as \fB$1\fP. | |
1269 | If the control variable in a \fBfor\fP loop has the nameref attribute, | |
1270 | the list of words can be a list of shell variables, and a name reference | |
1271 | will be established for each word in the list, in turn, when the loop is | |
1272 | executed. | |
1273 | Array variables cannot be given the \fB\-n\fP attribute. | |
1274 | However, nameref variables can reference array variables and subscripted | |
1275 | array variables. | |
1276 | Namerefs can be unset using the \fB\-n\fP option to the \fBunset\fP builtin. | |
1277 | Otherwise, if \fBunset\fP is executed with the name of a nameref variable | |
1278 | as an argument, the variable referenced by the nameref variable will be unset. | |
726f6388 JA |
1279 | .SS Positional Parameters |
1280 | .PP | |
1281 | A | |
1282 | .I positional parameter | |
1283 | is a parameter denoted by one or more | |
1284 | digits, other than the single digit 0. Positional parameters are | |
1285 | assigned from the shell's arguments when it is invoked, | |
1286 | and may be reassigned using the | |
1287 | .B set | |
1288 | builtin command. Positional parameters may not be assigned to | |
1289 | with assignment statements. The positional parameters are | |
1290 | temporarily replaced when a shell function is executed (see | |
1291 | .SM | |
1292 | .B FUNCTIONS | |
1293 | below). | |
1294 | .PP | |
1295 | When a positional parameter consisting of more than a single | |
1296 | digit is expanded, it must be enclosed in braces (see | |
1297 | .SM | |
1298 | .B EXPANSION | |
1299 | below). | |
1300 | .SS Special Parameters | |
1301 | .PP | |
1302 | The shell treats several parameters specially. These parameters may | |
1303 | only be referenced; assignment to them is not allowed. | |
1304 | .PD 0 | |
1305 | .TP | |
1306 | .B * | |
1307 | Expands to the positional parameters, starting from one. When the | |
1308 | expansion occurs within double quotes, it expands to a single word | |
1309 | with the value of each parameter separated by the first character | |
1310 | of the | |
1311 | .SM | |
1312 | .B IFS | |
cce855bc JA |
1313 | special variable. That is, "\fB$*\fP" is equivalent |
1314 | to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where | |
726f6388 JA |
1315 | .I c |
1316 | is the first character of the value of the | |
1317 | .SM | |
1318 | .B IFS | |
1319 | variable. If | |
1320 | .SM | |
1321 | .B IFS | |
d166f048 JA |
1322 | is unset, the parameters are separated by spaces. |
1323 | If | |
1324 | .SM | |
1325 | .B IFS | |
1326 | is null, the parameters are joined without intervening separators. | |
726f6388 JA |
1327 | .TP |
1328 | .B @ | |
1329 | Expands to the positional parameters, starting from one. When the | |
cce855bc JA |
1330 | expansion occurs within double quotes, each parameter expands to a |
1331 | separate word. That is, "\fB$@\fP" is equivalent to | |
1332 | "\fB$1\fP" "\fB$2\fP" ... | |
be7d8f2d CR |
1333 | If the double-quoted expansion occurs within a word, the expansion of |
1334 | the first parameter is joined with the beginning part of the original | |
1335 | word, and the expansion of the last parameter is joined with the last | |
1336 | part of the original word. | |
cce855bc | 1337 | When there are no positional parameters, "\fB$@\fP" and |
726f6388 JA |
1338 | .B $@ |
1339 | expand to nothing (i.e., they are removed). | |
1340 | .TP | |
1341 | .B # | |
1342 | Expands to the number of positional parameters in decimal. | |
1343 | .TP | |
1344 | .B ? | |
e882163b | 1345 | Expands to the exit status of the most recently executed foreground |
726f6388 JA |
1346 | pipeline. |
1347 | .TP | |
1348 | .B \- | |
1349 | Expands to the current option flags as specified upon invocation, | |
1350 | by the | |
1351 | .B set | |
1352 | builtin command, or those set by the shell itself | |
1353 | (such as the | |
1354 | .B \-i | |
cce855bc | 1355 | option). |
726f6388 JA |
1356 | .TP |
1357 | .B $ | |
1358 | Expands to the process ID of the shell. In a () subshell, it | |
1359 | expands to the process ID of the current shell, not the | |
1360 | subshell. | |
1361 | .TP | |
1362 | .B ! | |
1363 | Expands to the process ID of the most recently executed background | |
1364 | (asynchronous) command. | |
1365 | .TP | |
1366 | .B 0 | |
1367 | Expands to the name of the shell or shell script. This is set at | |
1368 | shell initialization. If | |
1369 | .B bash | |
1370 | is invoked with a file of commands, | |
1371 | .B $0 | |
1372 | is set to the name of that file. If | |
1373 | .B bash | |
1374 | is started with the | |
1375 | .B \-c | |
1376 | option, then | |
1377 | .B $0 | |
1378 | is set to the first argument after the string to be | |
1379 | executed, if one is present. Otherwise, it is set | |
b28ff8c9 | 1380 | to the filename used to invoke |
726f6388 JA |
1381 | .BR bash , |
1382 | as given by argument zero. | |
1383 | .TP | |
1384 | .B _ | |
cc87ba64 CR |
1385 | At shell startup, set to the absolute pathname used to invoke the |
1386 | shell or shell script being executed as passed in the environment | |
1387 | or argument list. | |
ccc6cda3 JA |
1388 | Subsequently, expands to the last argument to the previous command, |
1389 | after expansion. | |
cc87ba64 CR |
1390 | Also set to the full pathname used to invoke each command executed |
1391 | and placed in the environment exported to that command. | |
ccc6cda3 JA |
1392 | When checking mail, this parameter holds the name of the mail file |
1393 | currently being checked. | |
726f6388 JA |
1394 | .PD |
1395 | .SS Shell Variables | |
1396 | .PP | |
1397 | The following variables are set by the shell: | |
1398 | .PP | |
1399 | .PD 0 | |
1400 | .TP | |
726f6388 | 1401 | .B BASH |
b28ff8c9 | 1402 | Expands to the full filename used to invoke this instance of |
726f6388 JA |
1403 | .BR bash . |
1404 | .TP | |
691aebcb CR |
1405 | .B BASHOPTS |
1406 | A colon-separated list of enabled shell options. Each word in | |
1407 | the list is a valid argument for the | |
1408 | .B \-s | |
1409 | option to the | |
1410 | .B shopt | |
1411 | builtin command (see | |
1412 | .SM | |
1413 | .B "SHELL BUILTIN COMMANDS" | |
1414 | below). The options appearing in | |
1415 | .SM | |
1416 | .B BASHOPTS | |
1417 | are those reported as | |
1418 | .I on | |
1419 | by \fBshopt\fP. | |
1420 | If this variable is in the environment when | |
1421 | .B bash | |
1422 | starts up, each shell option in the list will be enabled before | |
1423 | reading any startup files. | |
1424 | This variable is read-only. | |
1425 | .TP | |
d3ad40de | 1426 | .B BASHPID |
dc60d4e0 | 1427 | Expands to the process ID of the current \fBbash\fP process. |
d3ad40de | 1428 | This differs from \fB$$\fP under certain circumstances, such as subshells |
29d25b54 | 1429 | that do not require \fBbash\fP to be re-initialized. |
d3ad40de | 1430 | .TP |
fdf670ea CR |
1431 | .B BASH_ALIASES |
1432 | An associative array variable whose members correspond to the internal | |
5cdaaf76 | 1433 | list of aliases as maintained by the \fBalias\fP builtin. |
fdf670ea CR |
1434 | Elements added to this array appear in the alias list; unsetting array |
1435 | elements cause aliases to be removed from the alias list. | |
1436 | .TP | |
d3a24ed2 CR |
1437 | .B BASH_ARGC |
1438 | An array variable whose values are the number of parameters in each | |
29d25b54 | 1439 | frame of the current \fBbash\fP execution call stack. |
2206f89a | 1440 | The number of |
d3a24ed2 | 1441 | parameters to the current subroutine (shell function or script executed |
2206f89a CR |
1442 | with \fB.\fP or \fBsource\fP) is at the top of the stack. |
1443 | When a subroutine is executed, the number of parameters passed is pushed onto | |
984a1947 CR |
1444 | .SM |
1445 | .BR BASH_ARGC . | |
1446 | The shell sets | |
1447 | .SM | |
1448 | .B BASH_ARGC | |
1449 | only when in extended debugging mode (see the description of the | |
2206f89a CR |
1450 | .B extdebug |
1451 | option to the | |
1452 | .B shopt | |
1453 | builtin below) | |
d3a24ed2 CR |
1454 | .TP |
1455 | .B BASH_ARGV | |
29d25b54 | 1456 | An array variable containing all of the parameters in the current \fBbash\fP |
d3a24ed2 CR |
1457 | execution call stack. The final parameter of the last subroutine call |
1458 | is at the top of the stack; the first parameter of the initial call is | |
1459 | at the bottom. When a subroutine is executed, the parameters supplied | |
984a1947 CR |
1460 | are pushed onto |
1461 | .SM | |
1462 | .BR BASH_ARGV . | |
1463 | The shell sets | |
1464 | .SM | |
1465 | .B BASH_ARGV | |
1466 | only when in extended debugging mode | |
2206f89a CR |
1467 | (see the description of the |
1468 | .B extdebug | |
1469 | option to the | |
1470 | .B shopt | |
1471 | builtin below) | |
d3a24ed2 | 1472 | .TP |
fdf670ea CR |
1473 | .B BASH_CMDS |
1474 | An associative array variable whose members correspond to the internal | |
1475 | hash table of commands as maintained by the \fBhash\fP builtin. | |
1476 | Elements added to this array appear in the hash table; unsetting array | |
1477 | elements cause commands to be removed from the hash table. | |
1478 | .TP | |
d3a24ed2 CR |
1479 | .B BASH_COMMAND |
1480 | The command currently being executed or about to be executed, unless the | |
1481 | shell is executing a command as the result of a trap, | |
1482 | in which case it is the command executing at the time of the trap. | |
1483 | .TP | |
1484 | .B BASH_EXECUTION_STRING | |
1485 | The command argument to the \fB\-c\fP invocation option. | |
1486 | .TP | |
1487 | .B BASH_LINENO | |
1488 | An array variable whose members are the line numbers in source files | |
7d92f73f | 1489 | where each corresponding member of |
984a1947 | 1490 | .SM |
7d92f73f CR |
1491 | .B FUNCNAME |
1492 | was invoked. | |
d3a24ed2 | 1493 | \fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source |
7d92f73f CR |
1494 | file (\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP) where |
1495 | \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called | |
3d4e09aa CR |
1496 | (or \fB${BASH_LINENO[\fP\fI$i-1\fP\fB]}\fP if referenced within another |
1497 | shell function). | |
984a1947 CR |
1498 | Use |
1499 | .SM | |
1500 | .B LINENO | |
1501 | to obtain the current line number. | |
d3a24ed2 CR |
1502 | .TP |
1503 | .B BASH_REMATCH | |
1504 | An array variable whose members are assigned by the \fB=~\fP binary | |
1505 | operator to the \fB[[\fP conditional command. | |
1506 | The element with index 0 is the portion of the string | |
1507 | matching the entire regular expression. | |
1508 | The element with index \fIn\fP is the portion of the | |
1509 | string matching the \fIn\fPth parenthesized subexpression. | |
1510 | This variable is read-only. | |
1511 | .TP | |
1512 | .B BASH_SOURCE | |
7d92f73f CR |
1513 | An array variable whose members are the source filenames |
1514 | where the corresponding shell function names in the | |
984a1947 CR |
1515 | .SM |
1516 | .B FUNCNAME | |
7d92f73f CR |
1517 | array variable are defined. |
1518 | The shell function | |
1519 | \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP is defined in the file | |
1520 | \fB${BASH_SOURCE[\fP\fI$i\fP\fB]}\fP and called from | |
1521 | \fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP. | |
d3a24ed2 CR |
1522 | .TP |
1523 | .B BASH_SUBSHELL | |
c1854f2d CR |
1524 | Incremented by one within each subshell or subshell environment when |
1525 | the shell begins executing in that environment. | |
d3a24ed2 CR |
1526 | The initial value is 0. |
1527 | .TP | |
ccc6cda3 | 1528 | .B BASH_VERSINFO |
cce855bc JA |
1529 | A readonly array variable whose members hold version information for |
1530 | this instance of | |
ccc6cda3 JA |
1531 | .BR bash . |
1532 | The values assigned to the array members are as follows: | |
1533 | .sp .5 | |
1534 | .RS | |
ccc6cda3 JA |
1535 | .TP 24 |
1536 | .B BASH_VERSINFO[\fR0\fP] | |
1537 | The major version number (the \fIrelease\fP). | |
1538 | .TP | |
1539 | .B BASH_VERSINFO[\fR1\fP] | |
1540 | The minor version number (the \fIversion\fP). | |
1541 | .TP | |
1542 | .B BASH_VERSINFO[\fR2\fP] | |
1543 | The patch level. | |
1544 | .TP | |
1545 | .B BASH_VERSINFO[\fR3\fP] | |
1546 | The build version. | |
1547 | .TP | |
1548 | .B BASH_VERSINFO[\fR4\fP] | |
1549 | The release status (e.g., \fIbeta1\fP). | |
1550 | .TP | |
1551 | .B BASH_VERSINFO[\fR5\fP] | |
984a1947 CR |
1552 | The value of |
1553 | .SM | |
1554 | .BR MACHTYPE . | |
ccc6cda3 JA |
1555 | .RE |
1556 | .TP | |
f73dda09 JA |
1557 | .B BASH_VERSION |
1558 | Expands to a string describing the version of this instance of | |
1559 | .BR bash . | |
726f6388 | 1560 | .TP |
f73dda09 JA |
1561 | .B COMP_CWORD |
1562 | An index into \fB${COMP_WORDS}\fP of the word containing the current | |
1563 | cursor position. | |
1564 | This variable is available only in shell functions invoked by the | |
1565 | programmable completion facilities (see \fBProgrammable Completion\fP | |
1566 | below). | |
1567 | .TP | |
d3ad40de CR |
1568 | .B COMP_KEY |
1569 | The key (or final key of a key sequence) used to invoke the current | |
1570 | completion function. | |
1571 | .TP | |
f73dda09 JA |
1572 | .B COMP_LINE |
1573 | The current command line. | |
1574 | This variable is available only in shell functions and external | |
1575 | commands invoked by the | |
1576 | programmable completion facilities (see \fBProgrammable Completion\fP | |
1577 | below). | |
1578 | .TP | |
1579 | .B COMP_POINT | |
1580 | The index of the current cursor position relative to the beginning of | |
1581 | the current command. | |
1582 | If the current cursor position is at the end of the current command, | |
1583 | the value of this variable is equal to \fB${#COMP_LINE}\fP. | |
1584 | This variable is available only in shell functions and external | |
1585 | commands invoked by the | |
1586 | programmable completion facilities (see \fBProgrammable Completion\fP | |
1587 | below). | |
1588 | .TP | |
d3ad40de CR |
1589 | .B COMP_TYPE |
1590 | Set to an integer value corresponding to the type of completion attempted | |
1591 | that caused a completion function to be called: | |
1592 | \fITAB\fP, for normal completion, | |
1593 | \fI?\fP, for listing completions after successive tabs, | |
1594 | \fI!\fP, for listing alternatives on partial word completion, | |
1595 | \fI@\fP, to list completions if the word is not unmodified, | |
1596 | or | |
1597 | \fI%\fP, for menu completion. | |
1598 | This variable is available only in shell functions and external | |
1599 | commands invoked by the | |
1600 | programmable completion facilities (see \fBProgrammable Completion\fP | |
1601 | below). | |
1602 | .TP | |
d3a24ed2 | 1603 | .B COMP_WORDBREAKS |
db31fb26 | 1604 | The set of characters that the \fBreadline\fP library treats as word |
d3a24ed2 CR |
1605 | separators when performing word completion. |
1606 | If | |
1607 | .SM | |
1608 | .B COMP_WORDBREAKS | |
1609 | is unset, it loses its special properties, even if it is | |
1610 | subsequently reset. | |
1611 | .TP | |
f73dda09 JA |
1612 | .B COMP_WORDS |
1613 | An array variable (see \fBArrays\fP below) consisting of the individual | |
1614 | words in the current command line. | |
db31fb26 | 1615 | The line is split into words as \fBreadline\fP would split it, using |
984a1947 CR |
1616 | .SM |
1617 | .B COMP_WORDBREAKS | |
1618 | as described above. | |
f73dda09 JA |
1619 | This variable is available only in shell functions invoked by the |
1620 | programmable completion facilities (see \fBProgrammable Completion\fP | |
1621 | below). | |
1622 | .TP | |
5cdaaf76 CR |
1623 | .B COPROC |
1624 | An array variable (see \fBArrays\fP below) created to hold the file descriptors | |
1625 | for output from and input to an unnamed coprocess (see \fBCoprocesses\fP | |
1626 | above). | |
1627 | .TP | |
f73dda09 JA |
1628 | .B DIRSTACK |
1629 | An array variable (see | |
1630 | .B Arrays | |
1631 | below) containing the current contents of the directory stack. | |
1632 | Directories appear in the stack in the order they are displayed by the | |
1633 | .B dirs | |
1634 | builtin. | |
1635 | Assigning to members of this array variable may be used to modify | |
1636 | directories already in the stack, but the | |
1637 | .B pushd | |
1638 | and | |
1639 | .B popd | |
1640 | builtins must be used to add and remove directories. | |
1641 | Assignment to this variable will not change the current directory. | |
726f6388 JA |
1642 | If |
1643 | .SM | |
f73dda09 | 1644 | .B DIRSTACK |
726f6388 JA |
1645 | is unset, it loses its special properties, even if it is |
1646 | subsequently reset. | |
1647 | .TP | |
f73dda09 JA |
1648 | .B EUID |
1649 | Expands to the effective user ID of the current user, initialized at | |
1650 | shell startup. This variable is readonly. | |
1651 | .TP | |
1652 | .B FUNCNAME | |
d3a24ed2 CR |
1653 | An array variable containing the names of all shell functions |
1654 | currently in the execution call stack. | |
1655 | The element with index 0 is the name of any currently-executing | |
1656 | shell function. | |
7d92f73f | 1657 | The bottom-most element (the one with the highest index) is |
d3ad40de CR |
1658 | .if t \f(CW"main"\fP. |
1659 | .if n "main". | |
f73dda09 JA |
1660 | This variable exists only when a shell function is executing. |
1661 | Assignments to | |
726f6388 | 1662 | .SM |
f73dda09 JA |
1663 | .B FUNCNAME |
1664 | have no effect and return an error status. | |
726f6388 JA |
1665 | If |
1666 | .SM | |
f73dda09 | 1667 | .B FUNCNAME |
726f6388 JA |
1668 | is unset, it loses its special properties, even if it is |
1669 | subsequently reset. | |
7d92f73f CR |
1670 | .if t .sp 0.5 |
1671 | .if n .sp 1 | |
1672 | This variable can be used with \fBBASH_LINENO\fP and \fBBASH_SOURCE\fP. | |
1673 | Each element of \fBFUNCNAME\fP has corresponding elements in | |
1674 | \fBBASH_LINENO\fP and \fBBASH_SOURCE\fP to describe the call stack. | |
1675 | For instance, \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called from the file | |
1676 | \fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP at line number | |
1677 | \fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP. | |
1678 | The \fBcaller\fP builtin displays the current call stack using this | |
1679 | information. | |
726f6388 | 1680 | .TP |
f73dda09 JA |
1681 | .B GROUPS |
1682 | An array variable containing the list of groups of which the current | |
1683 | user is a member. | |
1684 | Assignments to | |
1685 | .SM | |
1686 | .B GROUPS | |
1687 | have no effect and return an error status. | |
726f6388 JA |
1688 | If |
1689 | .SM | |
f73dda09 | 1690 | .B GROUPS |
726f6388 JA |
1691 | is unset, it loses its special properties, even if it is |
1692 | subsequently reset. | |
1693 | .TP | |
1694 | .B HISTCMD | |
1695 | The history number, or index in the history list, of the current | |
ccc6cda3 JA |
1696 | command. |
1697 | If | |
726f6388 JA |
1698 | .SM |
1699 | .B HISTCMD | |
1700 | is unset, it loses its special properties, even if it is | |
1701 | subsequently reset. | |
1702 | .TP | |
f73dda09 JA |
1703 | .B HOSTNAME |
1704 | Automatically set to the name of the current host. | |
bb70624e | 1705 | .TP |
f73dda09 JA |
1706 | .B HOSTTYPE |
1707 | Automatically set to a string that uniquely | |
1708 | describes the type of machine on which | |
1709 | .B bash | |
1710 | is executing. | |
1711 | The default is system-dependent. | |
1712 | .TP | |
1713 | .B LINENO | |
1714 | Each time this parameter is referenced, the shell substitutes | |
1715 | a decimal number representing the current sequential line number | |
1716 | (starting with 1) within a script or function. When not in a | |
1717 | script or function, the value substituted is not guaranteed to | |
1718 | be meaningful. | |
ccc6cda3 JA |
1719 | If |
1720 | .SM | |
f73dda09 | 1721 | .B LINENO |
ccc6cda3 JA |
1722 | is unset, it loses its special properties, even if it is |
1723 | subsequently reset. | |
1724 | .TP | |
f73dda09 JA |
1725 | .B MACHTYPE |
1726 | Automatically set to a string that fully describes the system | |
1727 | type on which | |
1728 | .B bash | |
1729 | is executing, in the standard GNU \fIcpu-company-system\fP format. | |
1730 | The default is system-dependent. | |
1731 | .TP | |
5cdaaf76 CR |
1732 | .B MAPFILE |
1733 | An array variable (see \fBArrays\fP below) created to hold the text | |
1734 | read by the \fBmapfile\fP builtin when no variable name is supplied. | |
1735 | .TP | |
f73dda09 JA |
1736 | .B OLDPWD |
1737 | The previous working directory as set by the | |
1738 | .B cd | |
1739 | command. | |
ccc6cda3 | 1740 | .TP |
726f6388 JA |
1741 | .B OPTARG |
1742 | The value of the last option argument processed by the | |
1743 | .B getopts | |
1744 | builtin command (see | |
1745 | .SM | |
1746 | .B SHELL BUILTIN COMMANDS | |
1747 | below). | |
1748 | .TP | |
1749 | .B OPTIND | |
1750 | The index of the next argument to be processed by the | |
1751 | .B getopts | |
1752 | builtin command (see | |
1753 | .SM | |
1754 | .B SHELL BUILTIN COMMANDS | |
1755 | below). | |
1756 | .TP | |
726f6388 JA |
1757 | .B OSTYPE |
1758 | Automatically set to a string that | |
1759 | describes the operating system on which | |
1760 | .B bash | |
ccc6cda3 JA |
1761 | is executing. |
1762 | The default is system-dependent. | |
1763 | .TP | |
f73dda09 JA |
1764 | .B PIPESTATUS |
1765 | An array variable (see | |
1766 | .B Arrays | |
1767 | below) containing a list of exit status values from the processes | |
1768 | in the most-recently-executed foreground pipeline (which may | |
1769 | contain only a single command). | |
ccc6cda3 | 1770 | .TP |
f73dda09 JA |
1771 | .B PPID |
1772 | The process ID of the shell's parent. This variable is readonly. | |
1773 | .TP | |
1774 | .B PWD | |
1775 | The current working directory as set by the | |
1776 | .B cd | |
1777 | command. | |
1778 | .TP | |
1779 | .B RANDOM | |
1780 | Each time this parameter is referenced, a random integer between | |
1781 | 0 and 32767 is | |
1782 | generated. The sequence of random numbers may be initialized by assigning | |
1783 | a value to | |
1784 | .SM | |
1785 | .BR RANDOM . | |
1786 | If | |
1787 | .SM | |
1788 | .B RANDOM | |
1789 | is unset, it loses its special properties, even if it is | |
1790 | subsequently reset. | |
1791 | .TP | |
5cdaaf76 CR |
1792 | .B READLINE_LINE |
1793 | The contents of the | |
1794 | .B readline | |
1795 | line buffer, for use with | |
1796 | .if t \f(CWbind -x\fP | |
1797 | .if n "bind -x" | |
1798 | (see | |
1799 | .SM | |
1800 | .B "SHELL BUILTIN COMMANDS" | |
1801 | below). | |
1802 | .TP | |
1803 | .B READLINE_POINT | |
1804 | The position of the insertion point in the | |
1805 | .B readline | |
1806 | line buffer, for use with | |
1807 | .if t \f(CWbind -x\fP | |
1808 | .if n "bind -x" | |
1809 | (see | |
1810 | .SM | |
1811 | .B "SHELL BUILTIN COMMANDS" | |
1812 | below). | |
1813 | .TP | |
f73dda09 JA |
1814 | .B REPLY |
1815 | Set to the line of input read by the | |
1816 | .B read | |
1817 | builtin command when no arguments are supplied. | |
1818 | .TP | |
1819 | .B SECONDS | |
1820 | Each time this parameter is | |
1821 | referenced, the number of seconds since shell invocation is returned. If a | |
1822 | value is assigned to | |
1823 | .SM | |
1824 | .BR SECONDS , | |
1825 | the value returned upon subsequent | |
1826 | references is | |
1827 | the number of seconds since the assignment plus the value assigned. | |
1828 | If | |
1829 | .SM | |
1830 | .B SECONDS | |
1831 | is unset, it loses its special properties, even if it is | |
1832 | subsequently reset. | |
1833 | .TP | |
1834 | .B SHELLOPTS | |
1835 | A colon-separated list of enabled shell options. Each word in | |
1836 | the list is a valid argument for the | |
1837 | .B \-o | |
1838 | option to the | |
1839 | .B set | |
1840 | builtin command (see | |
1841 | .SM | |
1842 | .B "SHELL BUILTIN COMMANDS" | |
1843 | below). The options appearing in | |
ccc6cda3 JA |
1844 | .SM |
1845 | .B SHELLOPTS | |
1846 | are those reported as | |
1847 | .I on | |
1848 | by \fBset \-o\fP. | |
1849 | If this variable is in the environment when | |
1850 | .B bash | |
1851 | starts up, each shell option in the list will be enabled before | |
1852 | reading any startup files. | |
1853 | This variable is read-only. | |
bb70624e | 1854 | .TP |
f73dda09 JA |
1855 | .B SHLVL |
1856 | Incremented by one each time an instance of | |
1857 | .B bash | |
1858 | is started. | |
bb70624e | 1859 | .TP |
f73dda09 JA |
1860 | .B UID |
1861 | Expands to the user ID of the current user, initialized at shell startup. | |
1862 | This variable is readonly. | |
726f6388 JA |
1863 | .PD |
1864 | .PP | |
1865 | The following variables are used by the shell. In some cases, | |
1866 | .B bash | |
1867 | assigns a default value to a variable; these cases are noted | |
1868 | below. | |
1869 | .PP | |
1870 | .PD 0 | |
1871 | .TP | |
7175a77f CR |
1872 | .B BASH_COMPAT |
1873 | The value is used to set the shell's compatibility level. | |
1442f67c CR |
1874 | See the description of the \fBshopt\fP builtin below under |
1875 | \fBSHELL BUILTIN COMMANDS\fP | |
1876 | for a description of the various compatibility | |
7175a77f CR |
1877 | levels and their effects. |
1878 | The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42) | |
1879 | corresponding to the desired compatibility level. | |
1880 | If \fBBASH_COMPAT\fP is unset or set to the empty string, the compatibility | |
1881 | level is set to the default for the current version. | |
1882 | If \fBBASH_COMPAT\fP is set to a value that is not one of the valid | |
1883 | compatibility levels, the shell prints an error message and sets the | |
1884 | compatibility level to the default for the current version. | |
1885 | The valid compatibility levels correspond to the compatibility options | |
1886 | accepted by the \fBshopt\fP builtin described below (for example, | |
1887 | \fBcompat42\fP means that 4.2 and 42 are valid values). | |
1888 | The current version is also a valid value. | |
1889 | .TP | |
d166f048 | 1890 | .B BASH_ENV |
726f6388 JA |
1891 | If this parameter is set when \fBbash\fP is executing a shell script, |
1892 | its value is interpreted as a filename containing commands to | |
1893 | initialize the shell, as in | |
cce855bc | 1894 | .IR ~/.bashrc . |
726f6388 JA |
1895 | The value of |
1896 | .SM | |
d166f048 | 1897 | .B BASH_ENV |
726f6388 | 1898 | is subjected to parameter expansion, command substitution, and arithmetic |
b28ff8c9 | 1899 | expansion before being interpreted as a filename. |
726f6388 JA |
1900 | .SM |
1901 | .B PATH | |
b28ff8c9 | 1902 | is not used to search for the resultant filename. |
726f6388 | 1903 | .TP |
8f714a7c CR |
1904 | .B BASH_XTRACEFD |
1905 | If set to an integer corresponding to a valid file descriptor, \fBbash\fP | |
1906 | will write the trace output generated when | |
1907 | .if t \f(CWset -x\fP | |
1908 | .if n \fIset -x\fP | |
1909 | is enabled to that file descriptor. | |
984a1947 CR |
1910 | The file descriptor is closed when |
1911 | .SM | |
1912 | .B BASH_XTRACEFD | |
1913 | is unset or assigned a new value. | |
1914 | Unsetting | |
1915 | .SM | |
1916 | .B BASH_XTRACEFD | |
1917 | or assigning it the empty string causes the | |
8f714a7c | 1918 | trace output to be sent to the standard error. |
984a1947 CR |
1919 | Note that setting |
1920 | .SM | |
1921 | .B BASH_XTRACEFD | |
1922 | to 2 (the standard error file | |
8f714a7c CR |
1923 | descriptor) and then unsetting it will result in the standard error |
1924 | being closed. | |
1925 | .TP | |
5cdaaf76 CR |
1926 | .B CDPATH |
1927 | The search path for the | |
1928 | .B cd | |
1929 | command. | |
1930 | This is a colon-separated list of directories in which the shell looks | |
1931 | for destination directories specified by the | |
1932 | .B cd | |
1933 | command. | |
1934 | A sample value is | |
1935 | .if t \f(CW".:~:/usr"\fP. | |
1936 | .if n ".:~:/usr". | |
1937 | .TP | |
a7ad477f CR |
1938 | .B CHILD_MAX |
1939 | Set the number of exited child status values for the shell to remember. | |
c677e9e0 | 1940 | Bash will not allow this value to be decreased below a POSIX-mandated |
a7ad477f CR |
1941 | minimum, and there is a maximum value (currently 8192) that this may |
1942 | not exceed. | |
1943 | The minimum value is system-dependent. | |
1944 | .TP | |
f73dda09 | 1945 | .B COLUMNS |
54a1fa7c | 1946 | Used by the \fBselect\fP compound command to determine the terminal width |
ad4aef08 CR |
1947 | when printing selection lists. |
1948 | Automatically set if the | |
1949 | .B checkwinsize | |
1950 | option is enabled or in an interactive shell upon receipt of a | |
9c7f20c7 CR |
1951 | .SM |
1952 | .BR SIGWINCH . | |
726f6388 | 1953 | .TP |
f73dda09 JA |
1954 | .B COMPREPLY |
1955 | An array variable from which \fBbash\fP reads the possible completions | |
1956 | generated by a shell function invoked by the programmable completion | |
1957 | facility (see \fBProgrammable Completion\fP below). | |
ba4ab055 | 1958 | Each array element contains one possible completion. |
726f6388 | 1959 | .TP |
d3a24ed2 CR |
1960 | .B EMACS |
1961 | If \fBbash\fP finds this variable in the environment when the shell starts | |
1962 | with value | |
1963 | .if t \f(CWt\fP, | |
1964 | .if n "t", | |
5f8cde23 | 1965 | it assumes that the shell is running in an Emacs shell buffer and disables |
d3a24ed2 CR |
1966 | line editing. |
1967 | .TP | |
5cdaaf76 CR |
1968 | .B ENV |
1969 | Similar to | |
1970 | .SM | |
1971 | .BR BASH_ENV ; | |
1972 | used when the shell is invoked in POSIX mode. | |
1973 | .TP | |
f73dda09 JA |
1974 | .B FCEDIT |
1975 | The default editor for the | |
1976 | .B fc | |
1977 | builtin command. | |
726f6388 | 1978 | .TP |
f73dda09 JA |
1979 | .B FIGNORE |
1980 | A colon-separated list of suffixes to ignore when performing | |
1981 | filename completion (see | |
726f6388 | 1982 | .SM |
f73dda09 JA |
1983 | .B READLINE |
1984 | below). | |
1985 | A filename whose suffix matches one of the entries in | |
726f6388 | 1986 | .SM |
f73dda09 JA |
1987 | .B FIGNORE |
1988 | is excluded from the list of matched filenames. | |
7117c2d2 JA |
1989 | A sample value is |
1990 | .if t \f(CW".o:~"\fP. | |
1991 | .if n ".o:~". | |
ccc6cda3 | 1992 | .TP |
6faad625 CR |
1993 | .B FUNCNEST |
1994 | If set to a numeric value greater than 0, defines a maximum function | |
1995 | nesting level. Function invocations that exceed this nesting level | |
1996 | will cause the current command to abort. | |
1997 | .TP | |
f73dda09 JA |
1998 | .B GLOBIGNORE |
1999 | A colon-separated list of patterns defining the set of filenames to | |
2000 | be ignored by pathname expansion. | |
2001 | If a filename matched by a pathname expansion pattern also matches one | |
2002 | of the patterns in | |
726f6388 | 2003 | .SM |
f73dda09 JA |
2004 | .BR GLOBIGNORE , |
2005 | it is removed from the list of matches. | |
2006 | .TP | |
2007 | .B HISTCONTROL | |
d3a24ed2 CR |
2008 | A colon-separated list of values controlling how commands are saved on |
2009 | the history list. | |
2010 | If the list of values includes | |
f73dda09 JA |
2011 | .IR ignorespace , |
2012 | lines which begin with a | |
2013 | .B space | |
d3a24ed2 CR |
2014 | character are not saved in the history list. |
2015 | A value of | |
2016 | .I ignoredups | |
2017 | causes lines matching the previous history entry to not be saved. | |
f73dda09 JA |
2018 | A value of |
2019 | .I ignoreboth | |
d3a24ed2 CR |
2020 | is shorthand for \fIignorespace\fP and \fIignoredups\fP. |
2021 | A value of | |
2022 | .IR erasedups | |
2023 | causes all previous lines matching the current line to be removed from | |
2024 | the history list before that line is saved. | |
2025 | Any value not in the above list is ignored. | |
984a1947 CR |
2026 | If |
2027 | .SM | |
2028 | .B HISTCONTROL | |
2029 | is unset, or does not include a valid value, | |
d3a24ed2 CR |
2030 | all lines read by the shell parser are saved on the history list, |
2031 | subject to the value of | |
984a1947 | 2032 | .SM |
f73dda09 JA |
2033 | .BR HISTIGNORE . |
2034 | The second and subsequent lines of a multi-line compound command are | |
2035 | not tested, and are added to the history regardless of the value of | |
984a1947 | 2036 | .SM |
f73dda09 | 2037 | .BR HISTCONTROL . |
726f6388 JA |
2038 | .TP |
2039 | .B HISTFILE | |
ccc6cda3 | 2040 | The name of the file in which command history is saved (see |
726f6388 JA |
2041 | .SM |
2042 | .B HISTORY | |
ccc6cda3 | 2043 | below). The default value is \fI~/.bash_history\fP. If unset, the |
ed3f3b6c | 2044 | command history is not saved when a shell exits. |
726f6388 JA |
2045 | .TP |
2046 | .B HISTFILESIZE | |
2047 | The maximum number of lines contained in the history file. When this | |
2048 | variable is assigned a value, the history file is truncated, if | |
4b82d1cd CR |
2049 | necessary, |
2050 | to contain no more than that number of lines by removing the oldest entries. | |
2051 | The history file is also truncated to this size after | |
ed3f3b6c | 2052 | writing it when a shell exits. |
4b82d1cd | 2053 | If the value is 0, the history file is truncated to zero size. |
e67d0029 | 2054 | Non-numeric values and numeric values less than zero inhibit truncation. |
4b82d1cd CR |
2055 | The shell sets the default value to the value of \fBHISTSIZE\fP |
2056 | after reading any startup files. | |
726f6388 | 2057 | .TP |
f73dda09 JA |
2058 | .B HISTIGNORE |
2059 | A colon-separated list of patterns used to decide which command lines | |
2060 | should be saved on the history list. Each pattern is anchored at the | |
2061 | beginning of the line and must match the complete line (no implicit | |
2062 | `\fB*\fP' is appended). Each pattern is tested against the line | |
2063 | after the checks specified by | |
984a1947 | 2064 | .SM |
f73dda09 JA |
2065 | .B HISTCONTROL |
2066 | are applied. | |
2067 | In addition to the normal shell pattern matching characters, `\fB&\fP' | |
2068 | matches the previous history line. `\fB&\fP' may be escaped using a | |
2069 | backslash; the backslash is removed before attempting a match. | |
2070 | The second and subsequent lines of a multi-line compound command are | |
2071 | not tested, and are added to the history regardless of the value of | |
984a1947 | 2072 | .SM |
f73dda09 JA |
2073 | .BR HISTIGNORE . |
2074 | .TP | |
2075 | .B HISTSIZE | |
2076 | The number of commands to remember in the command history (see | |
2077 | .SM | |
2078 | .B HISTORY | |
4b82d1cd CR |
2079 | below). |
2080 | If the value is 0, commands are not saved in the history list. | |
2081 | Numeric values less than zero result in every command being saved | |
2082 | on the history list (there is no limit). | |
2083 | The shell sets the default value to 500 after reading any startup files. | |
f73dda09 | 2084 | .TP |
d3a24ed2 CR |
2085 | .B HISTTIMEFORMAT |
2086 | If this variable is set and not null, its value is used as a format string | |
2087 | for \fIstrftime\fP(3) to print the time stamp associated with each history | |
2088 | entry displayed by the \fBhistory\fP builtin. | |
2089 | If this variable is set, time stamps are written to the history file so | |
2090 | they may be preserved across shell sessions. | |
d3ad40de CR |
2091 | This uses the history comment character to distinguish timestamps from |
2092 | other history lines. | |
d3a24ed2 | 2093 | .TP |
f73dda09 JA |
2094 | .B HOME |
2095 | The home directory of the current user; the default argument for the | |
2096 | \fBcd\fP builtin command. | |
2097 | The value of this variable is also used when performing tilde expansion. | |
2098 | .TP | |
2099 | .B HOSTFILE | |
2100 | Contains the name of a file in the same format as | |
2101 | .FN /etc/hosts | |
2102 | that should be read when the shell needs to complete a | |
2103 | hostname. | |
2104 | The list of possible hostname completions may be changed while the | |
2105 | shell is running; | |
2106 | the next time hostname completion is attempted after the | |
2107 | value is changed, | |
726f6388 | 2108 | .B bash |
f73dda09 JA |
2109 | adds the contents of the new file to the existing list. |
2110 | If | |
726f6388 | 2111 | .SM |
f73dda09 | 2112 | .B HOSTFILE |
9dd88db7 CR |
2113 | is set, but has no value, or does not name a readable file, |
2114 | \fBbash\fP attempts to read | |
f73dda09 JA |
2115 | .FN /etc/hosts |
2116 | to obtain the list of possible hostname completions. | |
2117 | When | |
726f6388 | 2118 | .SM |
f73dda09 JA |
2119 | .B HOSTFILE |
2120 | is unset, the hostname list is cleared. | |
2121 | .TP | |
2122 | .B IFS | |
2123 | The | |
2124 | .I Internal Field Separator | |
2125 | that is used | |
2126 | for word splitting after expansion and to | |
2127 | split lines into words with the | |
2128 | .B read | |
2129 | builtin command. The default value is | |
2130 | ``<space><tab><newline>''. | |
2131 | .TP | |
2132 | .B IGNOREEOF | |
2133 | Controls the | |
2134 | action of an interactive shell on receipt of an | |
2135 | .SM | |
2136 | .B EOF | |
2137 | character as the sole input. If set, the value is the number of | |
2138 | consecutive | |
2139 | .SM | |
2140 | .B EOF | |
2141 | characters which must be | |
2142 | typed as the first characters on an input line before | |
2143 | .B bash | |
2144 | exits. If the variable exists but does not have a numeric value, or | |
2145 | has no value, the default value is 10. If it does not exist, | |
2146 | .SM | |
2147 | .B EOF | |
2148 | signifies the end of input to the shell. | |
2149 | .TP | |
2150 | .B INPUTRC | |
2151 | The filename for the | |
2152 | .B readline | |
2153 | startup file, overriding the default of | |
2154 | .FN ~/.inputrc | |
2155 | (see | |
2156 | .SM | |
2157 | .B READLINE | |
2158 | below). | |
726f6388 | 2159 | .TP |
ccc6cda3 JA |
2160 | .B LANG |
2161 | Used to determine the locale category for any category not specifically | |
2162 | selected with a variable starting with \fBLC_\fP. | |
2163 | .TP | |
2164 | .B LC_ALL | |
984a1947 CR |
2165 | This variable overrides the value of |
2166 | .SM | |
2167 | .B LANG | |
2168 | and any other | |
ccc6cda3 JA |
2169 | \fBLC_\fP variable specifying a locale category. |
2170 | .TP | |
2171 | .B LC_COLLATE | |
2172 | This variable determines the collation order used when sorting the | |
cce855bc JA |
2173 | results of pathname expansion, and determines the behavior of range |
2174 | expressions, equivalence classes, and collating sequences within | |
2175 | pathname expansion and pattern matching. | |
2176 | .TP | |
2177 | .B LC_CTYPE | |
2178 | This variable determines the interpretation of characters and the | |
2179 | behavior of character classes within pathname expansion and pattern | |
2180 | matching. | |
ccc6cda3 JA |
2181 | .TP |
2182 | .B LC_MESSAGES | |
2183 | This variable determines the locale used to translate double-quoted | |
2184 | strings preceded by a \fB$\fP. | |
2185 | .TP | |
bb70624e JA |
2186 | .B LC_NUMERIC |
2187 | This variable determines the locale category used for number formatting. | |
2188 | .TP | |
28ef6c31 | 2189 | .B LINES |
54a1fa7c | 2190 | Used by the \fBselect\fP compound command to determine the column length |
ad4aef08 CR |
2191 | for printing selection lists. |
2192 | Automatically set if the | |
2193 | .B checkwinsize | |
2194 | option is enabled or in an interactive shell upon receipt of a | |
984a1947 CR |
2195 | .SM |
2196 | .BR SIGWINCH . | |
28ef6c31 | 2197 | .TP |
f73dda09 | 2198 | .B MAIL |
9ec5ed66 | 2199 | If this parameter is set to a file or directory name and the |
726f6388 | 2200 | .SM |
f73dda09 JA |
2201 | .B MAILPATH |
2202 | variable is not set, | |
726f6388 | 2203 | .B bash |
9ec5ed66 CR |
2204 | informs the user of the arrival of mail in the specified file or |
2205 | Maildir-format directory. | |
726f6388 | 2206 | .TP |
f73dda09 JA |
2207 | .B MAILCHECK |
2208 | Specifies how | |
2209 | often (in seconds) | |
2210 | .B bash | |
2211 | checks for mail. The default is 60 seconds. When it is time to check | |
2212 | for mail, the shell does so before displaying the primary prompt. | |
2213 | If this variable is unset, or set to a value that is not a number | |
2214 | greater than or equal to zero, the shell disables mail checking. | |
726f6388 | 2215 | .TP |
f73dda09 | 2216 | .B MAILPATH |
b28ff8c9 | 2217 | A colon-separated list of filenames to be checked for mail. |
f73dda09 | 2218 | The message to be printed when mail arrives in a particular file |
b28ff8c9 | 2219 | may be specified by separating the filename from the message with a `?'. |
f73dda09 JA |
2220 | When used in the text of the message, \fB$_\fP expands to the name of |
2221 | the current mailfile. | |
2222 | Example: | |
2223 | .RS | |
2224 | .PP | |
20587658 | 2225 | \fBMAILPATH\fP=\(aq/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"\(aq |
f73dda09 JA |
2226 | .PP |
2227 | .B Bash | |
2228 | supplies a default value for this variable, but the location of the user | |
2229 | mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP). | |
2230 | .RE | |
726f6388 | 2231 | .TP |
f73dda09 JA |
2232 | .B OPTERR |
2233 | If set to the value 1, | |
2234 | .B bash | |
2235 | displays error messages generated by the | |
2236 | .B getopts | |
2237 | builtin command (see | |
726f6388 | 2238 | .SM |
f73dda09 | 2239 | .B SHELL BUILTIN COMMANDS |
ccc6cda3 | 2240 | below). |
726f6388 | 2241 | .SM |
f73dda09 JA |
2242 | .B OPTERR |
2243 | is initialized to 1 each time the shell is invoked or a shell | |
2244 | script is executed. | |
ccc6cda3 | 2245 | .TP |
f73dda09 JA |
2246 | .B PATH |
2247 | The search path for commands. It | |
2248 | is a colon-separated list of directories in which | |
2249 | the shell looks for commands (see | |
ccc6cda3 | 2250 | .SM |
f73dda09 | 2251 | .B COMMAND EXECUTION |
d3a24ed2 | 2252 | below). |
984a1947 CR |
2253 | A zero-length (null) directory name in the value of |
2254 | .SM | |
2255 | .B PATH | |
2256 | indicates the current directory. | |
d3a24ed2 CR |
2257 | A null directory name may appear as two adjacent colons, or as an initial |
2258 | or trailing colon. | |
2259 | The default path is system-dependent, | |
f73dda09 JA |
2260 | and is set by the administrator who installs |
2261 | .BR bash . | |
2262 | A common value is | |
f6da9f85 CR |
2263 | .if t \f(CW/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin\fP. |
2264 | .if n ``/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''. | |
726f6388 | 2265 | .TP |
f73dda09 JA |
2266 | .B POSIXLY_CORRECT |
2267 | If this variable is in the environment when \fBbash\fP starts, the shell | |
2268 | enters \fIposix mode\fP before reading the startup files, as if the | |
2269 | .B \-\-posix | |
2270 | invocation option had been supplied. If it is set while the shell is | |
2271 | running, \fBbash\fP enables \fIposix mode\fP, as if the command | |
2272 | .if t \f(CWset -o posix\fP | |
2273 | .if n \fIset -o posix\fP | |
2274 | had been executed. | |
726f6388 | 2275 | .TP |
f73dda09 JA |
2276 | .B PROMPT_COMMAND |
2277 | If set, the value is executed as a command prior to issuing each primary | |
2278 | prompt. | |
ccc6cda3 | 2279 | .TP |
ed35cb4a CR |
2280 | .B PROMPT_DIRTRIM |
2281 | If set to a number greater than zero, the value is used as the number of | |
d0ca3503 | 2282 | trailing directory components to retain when expanding the \fB\ew\fP and |
ed35cb4a CR |
2283 | \fB\eW\fP prompt string escapes (see |
2284 | .SM | |
2285 | .B PROMPTING | |
2286 | below). Characters removed are replaced with an ellipsis. | |
2287 | .TP | |
f73dda09 JA |
2288 | .B PS1 |
2289 | The value of this parameter is expanded (see | |
2290 | .SM | |
2291 | .B PROMPTING | |
2292 | below) and used as the primary prompt string. The default value is | |
2293 | ``\fB\es\-\ev\e$ \fP''. | |
726f6388 | 2294 | .TP |
f73dda09 JA |
2295 | .B PS2 |
2296 | The value of this parameter is expanded as with | |
984a1947 | 2297 | .SM |
f73dda09 JA |
2298 | .B PS1 |
2299 | and used as the secondary prompt string. The default is | |
2300 | ``\fB> \fP''. | |
2301 | .TP | |
2302 | .B PS3 | |
2303 | The value of this parameter is used as the prompt for the | |
2304 | .B select | |
2305 | command (see | |
726f6388 | 2306 | .SM |
f73dda09 JA |
2307 | .B SHELL GRAMMAR |
2308 | above). | |
726f6388 | 2309 | .TP |
f73dda09 JA |
2310 | .B PS4 |
2311 | The value of this parameter is expanded as with | |
984a1947 | 2312 | .SM |
f73dda09 JA |
2313 | .B PS1 |
2314 | and the value is printed before each command | |
726f6388 | 2315 | .B bash |
f73dda09 | 2316 | displays during an execution trace. The first character of |
bb70624e | 2317 | .SM |
f73dda09 JA |
2318 | .B PS4 |
2319 | is replicated multiple times, as necessary, to indicate multiple | |
2320 | levels of indirection. The default is ``\fB+ \fP''. | |
2321 | .TP | |
61deeb13 CR |
2322 | .B SHELL |
2323 | The full pathname to the shell is kept in this environment variable. | |
2324 | If it is not set when the shell starts, | |
2325 | .B bash | |
2326 | assigns to it the full pathname of the current user's login shell. | |
2327 | .TP | |
f73dda09 JA |
2328 | .B TIMEFORMAT |
2329 | The value of this parameter is used as a format string specifying | |
2330 | how the timing information for pipelines prefixed with the | |
2331 | .B time | |
2332 | reserved word should be displayed. | |
2333 | The \fB%\fP character introduces an escape sequence that is | |
2334 | expanded to a time value or other information. | |
2335 | The escape sequences and their meanings are as follows; the | |
2336 | braces denote optional portions. | |
2337 | .sp .5 | |
2338 | .RS | |
2339 | .PD 0 | |
2340 | .TP 10 | |
2341 | .B %% | |
2342 | A literal \fB%\fP. | |
2343 | .TP | |
2344 | .B %[\fIp\fP][l]R | |
2345 | The elapsed time in seconds. | |
2346 | .TP | |
2347 | .B %[\fIp\fP][l]U | |
2348 | The number of CPU seconds spent in user mode. | |
2349 | .TP | |
2350 | .B %[\fIp\fP][l]S | |
2351 | The number of CPU seconds spent in system mode. | |
2352 | .TP | |
2353 | .B %P | |
2354 | The CPU percentage, computed as (%U + %S) / %R. | |
2355 | .PD | |
2356 | .RE | |
2357 | .IP | |
2358 | The optional \fIp\fP is a digit specifying the \fIprecision\fP, | |
2359 | the number of fractional digits after a decimal point. | |
2360 | A value of 0 causes no decimal point or fraction to be output. | |
2361 | At most three places after the decimal point may be specified; | |
2362 | values of \fIp\fP greater than 3 are changed to 3. | |
2363 | If \fIp\fP is not specified, the value 3 is used. | |
2364 | .IP | |
2365 | The optional \fBl\fP specifies a longer format, including | |
2366 | minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs. | |
2367 | The value of \fIp\fP determines whether or not the fraction is | |
2368 | included. | |
2369 | .IP | |
2370 | If this variable is not set, \fBbash\fP acts as if it had the | |
5e4c7191 | 2371 | value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\e\t%3lS\(aq\fP. |
f73dda09 JA |
2372 | If the value is null, no timing information is displayed. |
2373 | A trailing newline is added when the format string is displayed. | |
54a1fa7c | 2374 | .PD 0 |
f73dda09 JA |
2375 | .TP |
2376 | .B TMOUT | |
984a1947 CR |
2377 | If set to a value greater than zero, |
2378 | .SM | |
2379 | .B TMOUT | |
2380 | is treated as the | |
7117c2d2 JA |
2381 | default timeout for the \fBread\fP builtin. |
2382 | The \fBselect\fP command terminates if input does not arrive | |
984a1947 CR |
2383 | after |
2384 | .SM | |
2385 | .B TMOUT | |
2386 | seconds when input is coming from a terminal. | |
7117c2d2 | 2387 | In an interactive shell, the value is interpreted as the |
ed3f3b6c CR |
2388 | number of seconds to wait for a line of input after issuing the |
2389 | primary prompt. | |
f73dda09 | 2390 | .B Bash |
ed3f3b6c CR |
2391 | terminates after waiting for that number of seconds if a complete |
2392 | line of input does not arrive. | |
726f6388 | 2393 | .TP |
1569c106 | 2394 | .B TMPDIR |
5f8cde23 CR |
2395 | If set, \fBbash\fP uses its value as the name of a directory in which |
2396 | \fBbash\fP creates temporary files for the shell's use. | |
1569c106 | 2397 | .TP |
726f6388 JA |
2398 | .B auto_resume |
2399 | This variable controls how the shell interacts with the user and | |
2400 | job control. If this variable is set, single word simple | |
2401 | commands without redirections are treated as candidates for resumption | |
2402 | of an existing stopped job. There is no ambiguity allowed; if there is | |
2403 | more than one job beginning with the string typed, the job most recently | |
2404 | accessed is selected. The | |
2405 | .I name | |
2406 | of a stopped job, in this context, is the command line used to | |
2407 | start it. | |
2408 | If set to the value | |
2409 | .IR exact , | |
2410 | the string supplied must match the name of a stopped job exactly; | |
2411 | if set to | |
2412 | .IR substring , | |
2413 | the string supplied needs to match a substring of the name of a | |
2414 | stopped job. The | |
2415 | .I substring | |
2416 | value provides functionality analogous to the | |
2417 | .B %? | |
ccc6cda3 | 2418 | job identifier (see |
726f6388 JA |
2419 | .SM |
2420 | .B JOB CONTROL | |
2421 | below). If set to any other value, the supplied string must | |
2422 | be a prefix of a stopped job's name; this provides functionality | |
22e63b05 | 2423 | analogous to the \fB%\fP\fIstring\fP job identifier. |
bb70624e | 2424 | .TP |
f73dda09 JA |
2425 | .B histchars |
2426 | The two or three characters which control history expansion | |
2427 | and tokenization (see | |
2428 | .SM | |
2429 | .B HISTORY EXPANSION | |
2430 | below). The first character is the \fIhistory expansion\fP character, | |
2431 | the character which signals the start of a history | |
2432 | expansion, normally `\fB!\fP'. | |
2433 | The second character is the \fIquick substitution\fP | |
2434 | character, which is used as shorthand for re-running the previous | |
2435 | command entered, substituting one string for another in the command. | |
2436 | The default is `\fB^\fP'. | |
2437 | The optional third character is the character | |
2438 | which indicates that the remainder of the line is a comment when found | |
2439 | as the first character of a word, normally `\fB#\fP'. The history | |
2440 | comment character causes history substitution to be skipped for the | |
2441 | remaining words on the line. It does not necessarily cause the shell | |
2442 | parser to treat the rest of the line as a comment. | |
726f6388 | 2443 | .PD |
ccc6cda3 JA |
2444 | .SS Arrays |
2445 | .B Bash | |
fdf670ea | 2446 | provides one-dimensional indexed and associative array variables. |
09767ff0 | 2447 | Any variable may be used as an indexed array; the |
ccc6cda3 | 2448 | .B declare |
fdf670ea CR |
2449 | builtin will explicitly declare an array. |
2450 | There is no maximum | |
ccc6cda3 | 2451 | limit on the size of an array, nor any requirement that members |
fdf670ea CR |
2452 | be indexed or assigned contiguously. |
2453 | Indexed arrays are referenced using integers (including arithmetic | |
09767ff0 CR |
2454 | expressions) and are zero-based; associative arrays are referenced |
2455 | using arbitrary strings. | |
861a1900 | 2456 | Unless otherwise noted, indexed array indices must be non-negative integers. |
ccc6cda3 | 2457 | .PP |
fdf670ea CR |
2458 | An indexed array is created automatically if any variable is assigned to |
2459 | using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The | |
ccc6cda3 | 2460 | .I subscript |
67362c60 | 2461 | is treated as an arithmetic expression that must evaluate to a number. |
67362c60 | 2462 | To explicitly declare an indexed array, use |
ccc6cda3 JA |
2463 | .B declare \-a \fIname\fP |
2464 | (see | |
2465 | .SM | |
2466 | .B SHELL BUILTIN COMMANDS | |
2467 | below). | |
2468 | .B declare \-a \fIname\fP[\fIsubscript\fP] | |
09767ff0 CR |
2469 | is also accepted; the \fIsubscript\fP is ignored. |
2470 | .PP | |
2471 | Associative arrays are created using | |
2472 | .BR "declare \-A \fIname\fP" . | |
2473 | .PP | |
2474 | Attributes may be | |
ccc6cda3 JA |
2475 | specified for an array variable using the |
2476 | .B declare | |
2477 | and | |
2478 | .B readonly | |
2479 | builtins. Each attribute applies to all members of an array. | |
2480 | .PP | |
2481 | Arrays are assigned to using compound assignments of the form | |
2482 | \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each | |
09767ff0 | 2483 | \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. |
b28ff8c9 | 2484 | Indexed array assignments do not require anything but \fIstring\fP. |
09767ff0 CR |
2485 | When assigning to indexed arrays, if the optional brackets and subscript |
2486 | are supplied, that index is assigned to; | |
ccc6cda3 JA |
2487 | otherwise the index of the element assigned is the last index assigned |
2488 | to by the statement plus one. Indexing starts at zero. | |
fdf670ea CR |
2489 | .PP |
2490 | When assigning to an associative array, the subscript is required. | |
2491 | .PP | |
ccc6cda3 JA |
2492 | This syntax is also accepted by the |
2493 | .B declare | |
2494 | builtin. Individual array elements may be assigned to using the | |
2495 | \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above. | |
a7ad477f CR |
2496 | When assigning to an indexed array, if |
2497 | .I name | |
2498 | is subscripted by a negative number, that number is | |
2499 | interpreted as relative to one greater than the maximum index of | |
2500 | \fIname\fP, so negative indices count back from the end of the | |
2501 | array, and an index of \-1 references the last element. | |
ccc6cda3 JA |
2502 | .PP |
2503 | Any element of an array may be referenced using | |
2504 | ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid | |
2505 | conflicts with pathname expansion. If | |
2506 | \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to | |
2507 | all members of \fIname\fP. These subscripts differ only when the | |
2508 | word appears within double quotes. If the word is double-quoted, | |
2509 | ${\fIname\fP[*]} expands to a single | |
2510 | word with the value of each array member separated by the first | |
2511 | character of the | |
2512 | .SM | |
2513 | .B IFS | |
2514 | special variable, and ${\fIname\fP[@]} expands each element of | |
2515 | \fIname\fP to a separate word. When there are no array members, | |
be7d8f2d CR |
2516 | ${\fIname\fP[@]} expands to nothing. |
2517 | If the double-quoted expansion occurs within a word, the expansion of | |
2518 | the first parameter is joined with the beginning part of the original | |
2519 | word, and the expansion of the last parameter is joined with the last | |
2520 | part of the original word. | |
2521 | This is analogous to the expansion | |
ccc6cda3 JA |
2522 | of the special parameters \fB*\fP and \fB@\fP (see |
2523 | .B Special Parameters | |
2524 | above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of | |
2525 | ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or | |
2526 | \fB@\fP, the expansion is the number of elements in the array. | |
2527 | Referencing an array variable without a subscript is equivalent to | |
fdf670ea | 2528 | referencing the array with a subscript of 0. |
d9e1f41e CR |
2529 | If the |
2530 | .I subscript | |
2531 | used to reference an element of an indexed array | |
a7ad477f CR |
2532 | evaluates to a number less than zero, it is |
2533 | interpreted as relative to one greater than the maximum index of the array, | |
2534 | so negative indices count back from the end of the | |
2535 | array, and an index of \-1 references the last element. | |
ccc6cda3 | 2536 | .PP |
94a5513e CR |
2537 | An array variable is considered set if a subscript has been assigned a |
2538 | value. The null string is a valid value. | |
2539 | .PP | |
1442f67c CR |
2540 | It is possible to obtain the keys (indices) of an array as well as the values. |
2541 | ${\fB!\fP\fIname\fP[\fI@\fP]} and ${\fB!\fP\fIname\fP[\fI*\fP]} | |
2542 | expand to the indices assigned in array variable \fIname\fP. | |
2543 | The treatment when in double quotes is similar to the expansion of the | |
2544 | special parameters \fI@\fP and \fI*\fP within double quotes. | |
2545 | .PP | |
ccc6cda3 JA |
2546 | The |
2547 | .B unset | |
bb70624e | 2548 | builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP] |
ccc6cda3 | 2549 | destroys the array element at index \fIsubscript\fP. |
a7ad477f | 2550 | Negative subscripts to indexed arrays are interpreted as described above. |
d0ca3503 CR |
2551 | Care must be taken to avoid unwanted side effects caused by pathname |
2552 | expansion. | |
ccc6cda3 JA |
2553 | \fBunset\fP \fIname\fP, where \fIname\fP is an array, or |
2554 | \fBunset\fP \fIname\fP[\fIsubscript\fP], where | |
2555 | \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array. | |
2556 | .PP | |
2557 | The | |
2558 | .BR declare , | |
2559 | .BR local , | |
2560 | and | |
2561 | .B readonly | |
2562 | builtins each accept a | |
2563 | .B \-a | |
fdf670ea CR |
2564 | option to specify an indexed array and a |
2565 | .B \-A | |
2566 | option to specify an associative array. | |
54a1fa7c CR |
2567 | If both options are supplied, |
2568 | .B \-A | |
2569 | takes precedence. | |
fdf670ea | 2570 | The |
ccc6cda3 JA |
2571 | .B read |
2572 | builtin accepts a | |
2573 | .B \-a | |
2574 | option to assign a list of words read from the standard input | |
2575 | to an array. The | |
2576 | .B set | |
2577 | and | |
2578 | .B declare | |
2579 | builtins display array values in a way that allows them to be | |
2580 | reused as assignments. | |
726f6388 JA |
2581 | .SH EXPANSION |
2582 | Expansion is performed on the command line after it has been split into | |
2583 | words. There are seven kinds of expansion performed: | |
2584 | .IR "brace expansion" , | |
2585 | .IR "tilde expansion" , | |
2586 | .IR "parameter and variable expansion" , | |
2587 | .IR "command substitution" , | |
2588 | .IR "arithmetic expansion" , | |
2589 | .IR "word splitting" , | |
2590 | and | |
2591 | .IR "pathname expansion" . | |
2592 | .PP | |
2593 | The order of expansions is: brace expansion, tilde expansion, | |
ccc6cda3 JA |
2594 | parameter, variable and arithmetic expansion and |
2595 | command substitution | |
2596 | (done in a left-to-right fashion), word splitting, and pathname | |
726f6388 JA |
2597 | expansion. |
2598 | .PP | |
2599 | On systems that can support it, there is an additional expansion | |
2600 | available: \fIprocess substitution\fP. | |
2601 | .PP | |
2602 | Only brace expansion, word splitting, and pathname expansion | |
2603 | can change the number of words of the expansion; other expansions | |
2604 | expand a single word to a single word. | |
ccc6cda3 | 2605 | The only exceptions to this are the expansions of |
cce855bc | 2606 | "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP" |
ccc6cda3 | 2607 | as explained above (see |
726f6388 JA |
2608 | .SM |
2609 | .BR PARAMETERS ). | |
2610 | .SS Brace Expansion | |
2611 | .PP | |
2612 | .I "Brace expansion" | |
2613 | is a mechanism by which arbitrary strings | |
2614 | may be generated. This mechanism is similar to | |
2615 | \fIpathname expansion\fP, but the filenames generated | |
2616 | need not exist. Patterns to be brace expanded take | |
2617 | the form of an optional | |
2618 | .IR preamble , | |
d3a24ed2 CR |
2619 | followed by either a series of comma-separated strings or |
2620 | a sequence expression between a pair of braces, followed by | |
2621 | an optional | |
cce855bc | 2622 | .IR postscript . |
ccc6cda3 | 2623 | The preamble is prefixed to each string contained |
cce855bc | 2624 | within the braces, and the postscript is then appended |
726f6388 JA |
2625 | to each resulting string, expanding left to right. |
2626 | .PP | |
2627 | Brace expansions may be nested. The results of each expanded | |
2628 | string are not sorted; left to right order is preserved. | |
2629 | For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'. | |
2630 | .PP | |
8943768b | 2631 | A sequence expression takes the form |
36211029 | 2632 | \fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB[..\fP\fIincr\fP\fB]}\fP, |
8943768b CR |
2633 | where \fIx\fP and \fIy\fP are either integers or single characters, |
2634 | and \fIincr\fP, an optional increment, is an integer. | |
d3a24ed2 CR |
2635 | When integers are supplied, the expression expands to each number between |
2636 | \fIx\fP and \fIy\fP, inclusive. | |
8943768b | 2637 | Supplied integers may be prefixed with \fI0\fP to force each term to have the |
47b599dc CR |
2638 | same width. |
2639 | When either \fIx\fP or \fPy\fP begins with a zero, the shell | |
8943768b CR |
2640 | attempts to force all generated terms to contain the same number of digits, |
2641 | zero-padding where necessary. | |
d3a24ed2 | 2642 | When characters are supplied, the expression expands to each character |
47b599dc CR |
2643 | lexicographically between \fIx\fP and \fIy\fP, inclusive, |
2644 | using the default C locale. | |
2645 | Note that both \fIx\fP and \fIy\fP must be of the same type. | |
8943768b CR |
2646 | When the increment is supplied, it is used as the difference between |
2647 | each term. The default increment is 1 or -1 as appropriate. | |
d3a24ed2 | 2648 | .PP |
726f6388 JA |
2649 | Brace expansion is performed before any other expansions, |
2650 | and any characters special to other expansions are preserved | |
2651 | in the result. It is strictly textual. | |
2652 | .B Bash | |
2653 | does not apply any syntactic interpretation to the context of the | |
2654 | expansion or the text between the braces. | |
2655 | .PP | |
2656 | A correctly-formed brace expansion must contain unquoted opening | |
d3a24ed2 CR |
2657 | and closing braces, and at least one unquoted comma or a valid |
2658 | sequence expression. | |
726f6388 | 2659 | Any incorrectly formed brace expansion is left unchanged. |
ccc6cda3 JA |
2660 | A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its |
2661 | being considered part of a brace expression. | |
bb70624e JA |
2662 | To avoid conflicts with parameter expansion, the string \fB${\fP |
2663 | is not considered eligible for brace expansion. | |
726f6388 JA |
2664 | .PP |
2665 | This construct is typically used as shorthand when the common | |
2666 | prefix of the strings to be generated is longer than in the | |
2667 | above example: | |
2668 | .RS | |
2669 | .PP | |
2670 | mkdir /usr/local/src/bash/{old,new,dist,bugs} | |
2671 | .RE | |
2672 | or | |
2673 | .RS | |
2674 | chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} | |
2675 | .RE | |
2676 | .PP | |
2677 | Brace expansion introduces a slight incompatibility with | |
ccc6cda3 JA |
2678 | historical versions of |
2679 | .BR sh . | |
726f6388 JA |
2680 | .B sh |
2681 | does not treat opening or closing braces specially when they | |
2682 | appear as part of a word, and preserves them in the output. | |
2683 | .B Bash | |
2684 | removes braces from words as a consequence of brace | |
2685 | expansion. For example, a word entered to | |
2686 | .B sh | |
2687 | as \fIfile{1,2}\fP | |
2688 | appears identically in the output. The same word is | |
2689 | output as | |
2690 | .I file1 file2 | |
2691 | after expansion by | |
2692 | .BR bash . | |
2693 | If strict compatibility with | |
2694 | .B sh | |
2695 | is desired, start | |
2696 | .B bash | |
2697 | with the | |
ccc6cda3 JA |
2698 | .B +B |
2699 | option or disable brace expansion with the | |
2700 | .B +B | |
726f6388 JA |
2701 | option to the |
2702 | .B set | |
2703 | command (see | |
2704 | .SM | |
2705 | .B SHELL BUILTIN COMMANDS | |
2706 | below). | |
2707 | .SS Tilde Expansion | |
2708 | .PP | |
cce855bc JA |
2709 | If a word begins with an unquoted tilde character (`\fB~\fP'), all of |
2710 | the characters preceding the first unquoted slash (or all characters, | |
2711 | if there is no unquoted slash) are considered a \fItilde-prefix\fP. | |
2712 | If none of the characters in the tilde-prefix are quoted, the | |
2713 | characters in the tilde-prefix following the tilde are treated as a | |
2714 | possible \fIlogin name\fP. | |
2715 | If this login name is the null string, the tilde is replaced with the | |
2716 | value of the shell parameter | |
726f6388 JA |
2717 | .SM |
2718 | .BR HOME . | |
2719 | If | |
2720 | .SM | |
2721 | .B HOME | |
cce855bc JA |
2722 | is unset, the home directory of the user executing the shell is |
2723 | substituted instead. | |
2724 | Otherwise, the tilde-prefix is replaced with the home directory | |
2725 | associated with the specified login name. | |
726f6388 | 2726 | .PP |
cce855bc | 2727 | If the tilde-prefix is a `~+', the value of the shell variable |
726f6388 JA |
2728 | .SM |
2729 | .B PWD | |
cce855bc JA |
2730 | replaces the tilde-prefix. |
2731 | If the tilde-prefix is a `~\-', the value of the shell variable | |
2732 | .SM | |
2733 | .BR OLDPWD , | |
2734 | if it is set, is substituted. | |
2735 | If the characters following the tilde in the tilde-prefix consist | |
2736 | of a number \fIN\fP, optionally prefixed | |
2737 | by a `+' or a `\-', the tilde-prefix is replaced with the corresponding | |
2738 | element from the directory stack, as it would be displayed by the | |
2739 | .B dirs | |
2740 | builtin invoked with the tilde-prefix as an argument. | |
2741 | If the characters following the tilde in the tilde-prefix consist of a | |
2742 | number without a leading `+' or `\-', `+' is assumed. | |
2743 | .PP | |
2744 | If the login name is invalid, or the tilde expansion fails, the word | |
2745 | is unchanged. | |
726f6388 | 2746 | .PP |
cce855bc JA |
2747 | Each variable assignment is checked for unquoted tilde-prefixes immediately |
2748 | following a | |
726f6388 | 2749 | .B : |
43df7bbb | 2750 | or the first |
726f6388 | 2751 | .BR = . |
cce855bc | 2752 | In these cases, tilde expansion is also performed. |
b28ff8c9 | 2753 | Consequently, one may use filenames with tildes in assignments to |
726f6388 JA |
2754 | .SM |
2755 | .BR PATH , | |
2756 | .SM | |
2757 | .BR MAILPATH , | |
2758 | and | |
2759 | .SM | |
2760 | .BR CDPATH , | |
2761 | and the shell assigns the expanded value. | |
2762 | .SS Parameter Expansion | |
2763 | .PP | |
2764 | The `\fB$\fP' character introduces parameter expansion, | |
2765 | command substitution, or arithmetic expansion. The parameter name | |
2766 | or symbol to be expanded may be enclosed in braces, which | |
2767 | are optional but serve to protect the variable to be expanded from | |
2768 | characters immediately following it which could be | |
2769 | interpreted as part of the name. | |
2770 | .PP | |
cce855bc JA |
2771 | When braces are used, the matching ending brace is the first `\fB}\fP' |
2772 | not escaped by a backslash or within a quoted string, and not within an | |
f75912ae | 2773 | embedded arithmetic expansion, command substitution, or parameter |
cce855bc JA |
2774 | expansion. |
2775 | .PP | |
726f6388 JA |
2776 | .PD 0 |
2777 | .TP | |
2778 | ${\fIparameter\fP} | |
2779 | The value of \fIparameter\fP is substituted. The braces are required | |
2780 | when | |
2781 | .I parameter | |
2782 | is a positional parameter with more than one digit, | |
2783 | or when | |
2784 | .I parameter | |
2785 | is followed by a character which is not to be | |
2786 | interpreted as part of its name. | |
348a457e CR |
2787 | The \fIparameter\fP is a shell parameter as described above |
2788 | \fBPARAMETERS\fP) or an array reference (\fBArrays\fP). | |
726f6388 JA |
2789 | .PD |
2790 | .PP | |
08e72d7a | 2791 | If the first character of \fIparameter\fP is an exclamation point (\fB!\fP), |
348a457e | 2792 | it introduces a level of variable indirection. |
ccc6cda3 JA |
2793 | \fBBash\fP uses the value of the variable formed from the rest of |
2794 | \fIparameter\fP as the name of the variable; this variable is then | |
bb70624e | 2795 | expanded and that value is used in the rest of the substitution, rather |
ccc6cda3 JA |
2796 | than the value of \fIparameter\fP itself. |
2797 | This is known as \fIindirect expansion\fP. | |
54a1fa7c | 2798 | The exceptions to this are the expansions of ${\fB!\fP\fIprefix\fP\fB*\fP} and |
d3a24ed2 CR |
2799 | ${\fB!\fP\fIname\fP[\fI@\fP]} described below. |
2800 | The exclamation point must immediately follow the left brace in order to | |
2801 | introduce indirection. | |
ccc6cda3 | 2802 | .PP |
726f6388 JA |
2803 | In each of the cases below, \fIword\fP is subject to tilde expansion, |
2804 | parameter expansion, command substitution, and arithmetic expansion. | |
e141c35a | 2805 | .PP |
348a457e CR |
2806 | When not performing substring expansion, using the forms documented below |
2807 | (e.g., \fB:-\fP), | |
e141c35a CR |
2808 | \fBbash\fP tests for a parameter that is unset or null. Omitting the colon |
2809 | results in a test only for a parameter that is unset. | |
726f6388 JA |
2810 | .PP |
2811 | .PD 0 | |
2812 | .TP | |
2813 | ${\fIparameter\fP\fB:\-\fP\fIword\fP} | |
2814 | \fBUse Default Values\fP. If | |
2815 | .I parameter | |
2816 | is unset or null, the expansion of | |
2817 | .I word | |
2818 | is substituted. Otherwise, the value of | |
2819 | .I parameter | |
2820 | is substituted. | |
2821 | .TP | |
2822 | ${\fIparameter\fP\fB:=\fP\fIword\fP} | |
2823 | \fBAssign Default Values\fP. | |
2824 | If | |
2825 | .I parameter | |
2826 | is unset or null, the expansion of | |
2827 | .I word | |
2828 | is assigned to | |
2829 | .IR parameter . | |
2830 | The value of | |
2831 | .I parameter | |
2832 | is then substituted. Positional parameters and special parameters may | |
2833 | not be assigned to in this way. | |
2834 | .TP | |
2835 | ${\fIparameter\fP\fB:?\fP\fIword\fP} | |
2836 | \fBDisplay Error if Null or Unset\fP. | |
2837 | If | |
2838 | .I parameter | |
2839 | is null or unset, the expansion of \fIword\fP (or a message to that effect | |
2840 | if | |
2841 | .I word | |
2842 | is not present) is written to the standard error and the shell, if it | |
2843 | is not interactive, exits. Otherwise, the value of \fIparameter\fP is | |
2844 | substituted. | |
2845 | .TP | |
2846 | ${\fIparameter\fP\fB:+\fP\fIword\fP} | |
2847 | \fBUse Alternate Value\fP. | |
2848 | If | |
2849 | .I parameter | |
2850 | is null or unset, nothing is substituted, otherwise the expansion of | |
2851 | .I word | |
2852 | is substituted. | |
2853 | .TP | |
ccc6cda3 | 2854 | ${\fIparameter\fP\fB:\fP\fIoffset\fP} |
7117c2d2 | 2855 | .PD 0 |
ccc6cda3 JA |
2856 | .TP |
2857 | ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP} | |
2858 | .PD | |
dc60d4e0 | 2859 | \fBSubstring Expansion\fP. |
348a457e | 2860 | Expands to up to \fIlength\fP characters of the value of \fIparameter\fP |
bb70624e | 2861 | starting at the character specified by \fIoffset\fP. |
348a457e CR |
2862 | If \fIparameter\fP is \fB@\fP, an indexed array subscripted by |
2863 | \fB@\fP or \fB*\fP, or an associative array name, the results differ as | |
2864 | described below. | |
2865 | If \fIlength\fP is omitted, expands to the substring of the value of | |
2866 | \fIparameter\fP starting at the character specified by \fIoffset\fP | |
2867 | and extending to the end of the value. | |
ccc6cda3 JA |
2868 | \fIlength\fP and \fIoffset\fP are arithmetic expressions (see |
2869 | .SM | |
2870 | .B | |
2871 | ARITHMETIC EVALUATION | |
2872 | below). | |
348a457e | 2873 | .sp 1 |
ccc6cda3 | 2874 | If \fIoffset\fP evaluates to a number less than zero, the value |
348a457e CR |
2875 | is used as an offset in characters |
2876 | from the end of the value of \fIparameter\fP. | |
2877 | If \fIlength\fP evaluates to a number less than zero, | |
2878 | it is interpreted as an offset in characters | |
2879 | from the end of the value of \fIparameter\fP rather than | |
2880 | a number of characters, and the expansion is the characters between | |
2881 | \fIoffset\fP and that result. | |
2882 | Note that a negative offset must be separated from the colon by at least | |
2883 | one space to avoid being confused with the \fB:-\fP expansion. | |
2884 | .sp 1 | |
ccc6cda3 JA |
2885 | If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional |
2886 | parameters beginning at \fIoffset\fP. | |
348a457e CR |
2887 | A negative \fIoffset\fP is taken relative to one greater than the greatest |
2888 | positional parameter, so an offset of -1 evaluates to the last positional | |
2889 | parameter. | |
2890 | It is an expansion error if \fIlength\fP evaluates to a number less than | |
2891 | zero. | |
2892 | .sp 1 | |
09767ff0 | 2893 | If \fIparameter\fP is an indexed array name subscripted by @ or *, |
ccc6cda3 JA |
2894 | the result is the \fIlength\fP |
2895 | members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}. | |
ec2199bd CR |
2896 | A negative \fIoffset\fP is taken relative to one greater than the maximum |
2897 | index of the specified array. | |
348a457e CR |
2898 | It is an expansion error if \fIlength\fP evaluates to a number less than |
2899 | zero. | |
2900 | .sp 1 | |
09767ff0 CR |
2901 | Substring expansion applied to an associative array produces undefined |
2902 | results. | |
348a457e | 2903 | .sp 1 |
cce855bc | 2904 | Substring indexing is zero-based unless the positional parameters |
d3ad40de CR |
2905 | are used, in which case the indexing starts at 1 by default. |
2906 | If \fIoffset\fP is 0, and the positional parameters are used, \fB$0\fP is | |
2907 | prefixed to the list. | |
ccc6cda3 | 2908 | .TP |
bb70624e | 2909 | ${\fB!\fP\fIprefix\fP\fB*\fP} |
d3a24ed2 CR |
2910 | .PD 0 |
2911 | .TP | |
2912 | ${\fB!\fP\fIprefix\fP\fB@\fP} | |
2913 | .PD | |
dc60d4e0 | 2914 | \fBNames matching prefix\fP. |
bb70624e JA |
2915 | Expands to the names of variables whose names begin with \fIprefix\fP, |
2916 | separated by the first character of the | |
2917 | .SM | |
2918 | .B IFS | |
2919 | special variable. | |
d3ad40de CR |
2920 | When \fI@\fP is used and the expansion appears within double quotes, each |
2921 | variable name expands to a separate word. | |
bb70624e | 2922 | .TP |
d3a24ed2 CR |
2923 | ${\fB!\fP\fIname\fP[\fI@\fP]} |
2924 | .PD 0 | |
2925 | .TP | |
2926 | ${\fB!\fP\fIname\fP[\fI*\fP]} | |
2927 | .PD | |
dc60d4e0 | 2928 | \fBList of array keys\fP. |
d3a24ed2 CR |
2929 | If \fIname\fP is an array variable, expands to the list of array indices |
2930 | (keys) assigned in \fIname\fP. | |
2931 | If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null | |
2932 | otherwise. | |
2933 | When \fI@\fP is used and the expansion appears within double quotes, each | |
2934 | key expands to a separate word. | |
2935 | .TP | |
726f6388 | 2936 | ${\fB#\fP\fIparameter\fP} |
dc60d4e0 | 2937 | \fBParameter length\fP. |
726f6388 | 2938 | The length in characters of the value of \fIparameter\fP is substituted. |
ccc6cda3 JA |
2939 | If |
2940 | .I parameter | |
2941 | is | |
726f6388 JA |
2942 | .B * |
2943 | or | |
2944 | .BR @ , | |
cce855bc | 2945 | the value substituted is the number of positional parameters. |
ccc6cda3 JA |
2946 | If |
2947 | .I parameter | |
2948 | is an array name subscripted by | |
726f6388 | 2949 | .B * |
ccc6cda3 JA |
2950 | or |
2951 | .BR @ , | |
cce855bc | 2952 | the value substituted is the number of elements in the array. |
a7ad477f CR |
2953 | If |
2954 | .I parameter | |
2955 | is an indexed array name subscripted by a negative number, that number is | |
2956 | interpreted as relative to one greater than the maximum index of | |
2957 | \fIparameter\fP, so negative indices count back from the end of the | |
2958 | array, and an index of \-1 references the last element. | |
726f6388 | 2959 | .TP |
726f6388 | 2960 | ${\fIparameter\fP\fB#\fP\fIword\fP} |
7117c2d2 | 2961 | .PD 0 |
726f6388 JA |
2962 | .TP |
2963 | ${\fIparameter\fP\fB##\fP\fIword\fP} | |
2964 | .PD | |
dc60d4e0 | 2965 | \fBRemove matching prefix pattern\fP. |
726f6388 JA |
2966 | The |
2967 | .I word | |
2968 | is expanded to produce a pattern just as in pathname | |
2969 | expansion. If the pattern matches the beginning of | |
2970 | the value of | |
2971 | .IR parameter , | |
cce855bc | 2972 | then the result of the expansion is the expanded value of |
726f6388 | 2973 | .I parameter |
ccc6cda3 JA |
2974 | with the shortest matching pattern (the ``\fB#\fP'' case) or the |
2975 | longest matching pattern (the ``\fB##\fP'' case) deleted. | |
2976 | If | |
2977 | .I parameter | |
2978 | is | |
2979 | .B @ | |
2980 | or | |
2981 | .BR * , | |
2982 | the pattern removal operation is applied to each positional | |
2983 | parameter in turn, and the expansion is the resultant list. | |
2984 | If | |
2985 | .I parameter | |
2986 | is an array variable subscripted with | |
2987 | .B @ | |
2988 | or | |
2989 | .BR * , | |
2990 | the pattern removal operation is applied to each member of the | |
2991 | array in turn, and the expansion is the resultant list. | |
726f6388 | 2992 | .TP |
726f6388 | 2993 | ${\fIparameter\fP\fB%\fP\fIword\fP} |
7117c2d2 | 2994 | .PD 0 |
726f6388 JA |
2995 | .TP |
2996 | ${\fIparameter\fP\fB%%\fP\fIword\fP} | |
2997 | .PD | |
dc60d4e0 | 2998 | \fBRemove matching suffix pattern\fP. |
726f6388 | 2999 | The \fIword\fP is expanded to produce a pattern just as in |
ccc6cda3 | 3000 | pathname expansion. |
cce855bc | 3001 | If the pattern matches a trailing portion of the expanded value of |
726f6388 | 3002 | .IR parameter , |
cce855bc | 3003 | then the result of the expansion is the expanded value of |
726f6388 | 3004 | .I parameter |
ccc6cda3 JA |
3005 | with the shortest matching pattern (the ``\fB%\fP'' case) or the |
3006 | longest matching pattern (the ``\fB%%\fP'' case) deleted. | |
3007 | If | |
3008 | .I parameter | |
3009 | is | |
3010 | .B @ | |
3011 | or | |
3012 | .BR * , | |
3013 | the pattern removal operation is applied to each positional | |
3014 | parameter in turn, and the expansion is the resultant list. | |
3015 | If | |
3016 | .I parameter | |
3017 | is an array variable subscripted with | |
3018 | .B @ | |
3019 | or | |
3020 | .BR * , | |
3021 | the pattern removal operation is applied to each member of the | |
3022 | array in turn, and the expansion is the resultant list. | |
3023 | .TP | |
ccc6cda3 | 3024 | ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP} |
dc60d4e0 | 3025 | \fBPattern substitution\fP. |
ccc6cda3 JA |
3026 | The \fIpattern\fP is expanded to produce a pattern just as in |
3027 | pathname expansion. | |
3028 | \fIParameter\fP is expanded and the longest match of \fIpattern\fP | |
3029 | against its value is replaced with \fIstring\fP. | |
e6598ba4 | 3030 | If \fIpattern\fP begins with \fB/\fP, all matches of \fIpattern\fP are |
dc8fbaf9 | 3031 | replaced with \fIstring\fP. Normally only the first match is replaced. |
ccc6cda3 | 3032 | If \fIpattern\fP begins with \fB#\fP, it must match at the beginning |
b72432fd | 3033 | of the expanded value of \fIparameter\fP. |
ccc6cda3 | 3034 | If \fIpattern\fP begins with \fB%\fP, it must match at the end |
b72432fd | 3035 | of the expanded value of \fIparameter\fP. |
ccc6cda3 JA |
3036 | If \fIstring\fP is null, matches of \fIpattern\fP are deleted |
3037 | and the \fB/\fP following \fIpattern\fP may be omitted. | |
3038 | If | |
3039 | .I parameter | |
3040 | is | |
3041 | .B @ | |
3042 | or | |
3043 | .BR * , | |
3044 | the substitution operation is applied to each positional | |
3045 | parameter in turn, and the expansion is the resultant list. | |
3046 | If | |
3047 | .I parameter | |
3048 | is an array variable subscripted with | |
3049 | .B @ | |
3050 | or | |
3051 | .BR * , | |
3052 | the substitution operation is applied to each member of the | |
3053 | array in turn, and the expansion is the resultant list. | |
09767ff0 CR |
3054 | .TP |
3055 | ${\fIparameter\fP\fB^\fP\fIpattern\fP} | |
3056 | .PD 0 | |
3057 | .TP | |
3058 | ${\fIparameter\fP\fB^^\fP\fIpattern\fP} | |
3059 | .TP | |
3060 | ${\fIparameter\fP\fB,\fP\fIpattern\fP} | |
3061 | .TP | |
3062 | ${\fIparameter\fP\fB,,\fP\fIpattern\fP} | |
3063 | .PD | |
dc60d4e0 | 3064 | \fBCase modification\fP. |
09767ff0 CR |
3065 | This expansion modifies the case of alphabetic characters in \fIparameter\fP. |
3066 | The \fIpattern\fP is expanded to produce a pattern just as in | |
3067 | pathname expansion. | |
45c0f7f8 CR |
3068 | Each character in the expanded value of \fIparameter\fP is tested against |
3069 | \fIpattern\fP, and, if it matches the pattern, its case is converted. | |
3070 | The pattern should not attempt to match more than one character. | |
09767ff0 CR |
3071 | The \fB^\fP operator converts lowercase letters matching \fIpattern\fP |
3072 | to uppercase; the \fB,\fP operator converts matching uppercase letters | |
3073 | to lowercase. | |
3074 | The \fB^^\fP and \fB,,\fP expansions convert each matched character in the | |
3075 | expanded value; the \fB^\fP and \fB,\fP expansions match and convert only | |
5cdaaf76 | 3076 | the first character in the expanded value. |
09767ff0 CR |
3077 | If \fIpattern\fP is omitted, it is treated like a \fB?\fP, which matches |
3078 | every character. | |
3079 | If | |
3080 | .I parameter | |
3081 | is | |
3082 | .B @ | |
3083 | or | |
3084 | .BR * , | |
3085 | the case modification operation is applied to each positional | |
3086 | parameter in turn, and the expansion is the resultant list. | |
3087 | If | |
3088 | .I parameter | |
3089 | is an array variable subscripted with | |
3090 | .B @ | |
3091 | or | |
3092 | .BR * , | |
3093 | the case modification operation is applied to each member of the | |
3094 | array in turn, and the expansion is the resultant list. | |
726f6388 JA |
3095 | .SS Command Substitution |
3096 | .PP | |
cce855bc | 3097 | \fICommand substitution\fP allows the output of a command to replace |
726f6388 | 3098 | the command name. There are two forms: |
726f6388 JA |
3099 | .RS |
3100 | .PP | |
3101 | \fB$(\fP\fIcommand\fP\|\fB)\fP | |
3102 | .RE | |
3103 | or | |
3104 | .RS | |
3d4e09aa | 3105 | \fB\`\fP\fIcommand\fP\fB\`\fP |
726f6388 JA |
3106 | .RE |
3107 | .PP | |
ccc6cda3 | 3108 | .B Bash |
726f6388 JA |
3109 | performs the expansion by executing \fIcommand\fP and |
3110 | replacing the command substitution with the standard output of the | |
3111 | command, with any trailing newlines deleted. | |
cce855bc JA |
3112 | Embedded newlines are not deleted, but they may be removed during |
3113 | word splitting. | |
3114 | The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by | |
3115 | the equivalent but faster \fB$(< \fIfile\fP)\fR. | |
726f6388 | 3116 | .PP |
ccc6cda3 | 3117 | When the old-style backquote form of substitution is used, |
726f6388 JA |
3118 | backslash retains its literal meaning except when followed by |
3119 | .BR $ , | |
3d4e09aa | 3120 | .BR \` , |
726f6388 JA |
3121 | or |
3122 | .BR \e . | |
cce855bc JA |
3123 | The first backquote not preceded by a backslash terminates the |
3124 | command substitution. | |
726f6388 JA |
3125 | When using the $(\^\fIcommand\fP\|) form, all characters between the |
3126 | parentheses make up the command; none are treated specially. | |
3127 | .PP | |
cce855bc | 3128 | Command substitutions may be nested. To nest when using the backquoted form, |
726f6388 JA |
3129 | escape the inner backquotes with backslashes. |
3130 | .PP | |
3131 | If the substitution appears within double quotes, word splitting and | |
3132 | pathname expansion are not performed on the results. | |
3133 | .SS Arithmetic Expansion | |
3134 | .PP | |
3135 | Arithmetic expansion allows the evaluation of an arithmetic expression | |
ccc6cda3 | 3136 | and the substitution of the result. The format for arithmetic expansion is: |
726f6388 JA |
3137 | .RS |
3138 | .PP | |
726f6388 JA |
3139 | \fB$((\fP\fIexpression\fP\fB))\fP |
3140 | .RE | |
3141 | .PP | |
3142 | The | |
3143 | .I expression | |
3144 | is treated as if it were within double quotes, but a double quote | |
ccc6cda3 | 3145 | inside the parentheses is not treated specially. |
1442f67c CR |
3146 | All tokens in the expression undergo parameter and variable expansion, |
3147 | command substitution, and quote removal. | |
3148 | The result is treated as the arithmetic expression to be evaluated. | |
d3a24ed2 | 3149 | Arithmetic expansions may be nested. |
726f6388 JA |
3150 | .PP |
3151 | The evaluation is performed according to the rules listed below under | |
3152 | .SM | |
3153 | .BR "ARITHMETIC EVALUATION" . | |
3154 | If | |
3155 | .I expression | |
3156 | is invalid, | |
3157 | .B bash | |
3158 | prints a message indicating failure and no substitution occurs. | |
3159 | .SS Process Substitution | |
3160 | .PP | |
3161 | \fIProcess substitution\fP is supported on systems that support named | |
3162 | pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files. | |
3163 | It takes the form of | |
3164 | \fB<(\fP\fIlist\^\fP\fB)\fP | |
3165 | or | |
3166 | \fB>(\fP\fIlist\^\fP\fB)\fP. | |
3167 | The process \fIlist\fP is run with its input or output connected to a | |
3168 | \fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is | |
3169 | passed as an argument to the current command as the result of the | |
3170 | expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to | |
3171 | the file will provide input for \fIlist\fP. If the | |
3172 | \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an | |
3173 | argument should be read to obtain the output of \fIlist\fP. | |
3174 | .PP | |
bb70624e | 3175 | When available, process substitution is performed |
ccc6cda3 JA |
3176 | simultaneously with parameter and variable expansion, |
3177 | command substitution, | |
3178 | and arithmetic expansion. | |
726f6388 JA |
3179 | .SS Word Splitting |
3180 | .PP | |
3181 | The shell scans the results of | |
3182 | parameter expansion, | |
3183 | command substitution, | |
3184 | and | |
3185 | arithmetic expansion | |
3186 | that did not occur within double quotes for | |
3187 | .IR "word splitting" . | |
3188 | .PP | |
3189 | The shell treats each character of | |
3190 | .SM | |
3191 | .B IFS | |
3192 | as a delimiter, and splits the results of the other | |
ccc6cda3 | 3193 | expansions into words on these characters. If |
726f6388 JA |
3194 | .SM |
3195 | .B IFS | |
ccc6cda3 JA |
3196 | is unset, or its |
3197 | value is exactly | |
726f6388 JA |
3198 | .BR <space><tab><newline> , |
3199 | the default, then | |
d3ad40de CR |
3200 | sequences of |
3201 | .BR <space> , | |
3202 | .BR <tab> , | |
3203 | and | |
3204 | .B <newline> | |
3205 | at the beginning and end of the results of the previous | |
3206 | expansions are ignored, and | |
726f6388 JA |
3207 | any sequence of |
3208 | .SM | |
3209 | .B IFS | |
d3ad40de CR |
3210 | characters not at the beginning or end serves to delimit words. |
3211 | If | |
726f6388 JA |
3212 | .SM |
3213 | .B IFS | |
3214 | has a value other than the default, then sequences of | |
3215 | the whitespace characters | |
3216 | .B space | |
3217 | and | |
3218 | .B tab | |
3219 | are ignored at the beginning and end of the | |
3220 | word, as long as the whitespace character is in the | |
3221 | value of | |
3222 | .SM | |
3223 | .BR IFS | |
3224 | (an | |
3225 | .SM | |
3226 | .B IFS | |
3227 | whitespace character). | |
3228 | Any character in | |
3229 | .SM | |
3230 | .B IFS | |
3231 | that is not | |
3232 | .SM | |
3233 | .B IFS | |
3234 | whitespace, along with any adjacent | |
3235 | .SM | |
3236 | .B IFS | |
3237 | whitespace characters, delimits a field. | |
3238 | A sequence of | |
3239 | .SM | |
3240 | .B IFS | |
3241 | whitespace characters is also treated as a delimiter. | |
3242 | If the value of | |
3243 | .SM | |
3244 | .B IFS | |
3245 | is null, no word splitting occurs. | |
726f6388 | 3246 | .PP |
20587658 | 3247 | Explicit null arguments (\^\f3"\^"\fP or \^\f3\(aq\^\(aq\fP\^) are retained. |
ccc6cda3 | 3248 | Unquoted implicit null arguments, resulting from the expansion of |
bb70624e | 3249 | parameters that have no values, are removed. |
ccc6cda3 JA |
3250 | If a parameter with no value is expanded within double quotes, a |
3251 | null argument results and is retained. | |
726f6388 JA |
3252 | .PP |
3253 | Note that if no expansion occurs, no splitting | |
3254 | is performed. | |
3255 | .SS Pathname Expansion | |
3256 | .PP | |
3257 | After word splitting, | |
3258 | unless the | |
3259 | .B \-f | |
3260 | option has been set, | |
3261 | .B bash | |
ccc6cda3 | 3262 | scans each word for the characters |
726f6388 JA |
3263 | .BR * , |
3264 | .BR ? , | |
3265 | and | |
3266 | .BR [ . | |
3267 | If one of these characters appears, then the word is | |
3268 | regarded as a | |
3269 | .IR pattern , | |
3270 | and replaced with an alphabetically sorted list of | |
b28ff8c9 | 3271 | filenames matching the pattern |
bfd181e7 CR |
3272 | (see |
3273 | .SM | |
3274 | .B "Pattern Matching" | |
3275 | below). | |
b28ff8c9 | 3276 | If no matching filenames are found, |
ccc6cda3 JA |
3277 | and the shell option |
3278 | .B nullglob | |
57a3f689 | 3279 | is not enabled, the word is left unchanged. |
cce855bc JA |
3280 | If the |
3281 | .B nullglob | |
3282 | option is set, and no matches are found, | |
726f6388 | 3283 | the word is removed. |
d3a24ed2 CR |
3284 | If the |
3285 | .B failglob | |
3286 | shell option is set, and no matches are found, an error message | |
3287 | is printed and the command is not executed. | |
cce855bc JA |
3288 | If the shell option |
3289 | .B nocaseglob | |
3290 | is enabled, the match is performed without regard to the case | |
3291 | of alphabetic characters. | |
ccc6cda3 | 3292 | When a pattern is used for pathname expansion, |
726f6388 JA |
3293 | the character |
3294 | .B ``.'' | |
3295 | at the start of a name or immediately following a slash | |
ccc6cda3 JA |
3296 | must be matched explicitly, unless the shell option |
3297 | .B dotglob | |
3298 | is set. | |
cce855bc JA |
3299 | When matching a pathname, the slash character must always be |
3300 | matched explicitly. | |
ccc6cda3 | 3301 | In other cases, the |
726f6388 JA |
3302 | .B ``.'' |
3303 | character is not treated specially. | |
ccc6cda3 JA |
3304 | See the description of |
3305 | .B shopt | |
3306 | below under | |
3307 | .SM | |
3308 | .B SHELL BUILTIN COMMANDS | |
3309 | for a description of the | |
cce855bc JA |
3310 | .BR nocaseglob , |
3311 | .BR nullglob , | |
d3a24ed2 | 3312 | .BR failglob , |
ccc6cda3 JA |
3313 | and |
3314 | .B dotglob | |
3315 | shell options. | |
3316 | .PP | |
3317 | The | |
3318 | .SM | |
3319 | .B GLOBIGNORE | |
b28ff8c9 | 3320 | shell variable may be used to restrict the set of filenames matching a |
ccc6cda3 JA |
3321 | .IR pattern . |
3322 | If | |
3323 | .SM | |
3324 | .B GLOBIGNORE | |
b28ff8c9 | 3325 | is set, each matching filename that also matches one of the patterns in |
ccc6cda3 JA |
3326 | .SM |
3327 | .B GLOBIGNORE | |
3328 | is removed from the list of matches. | |
b28ff8c9 | 3329 | The filenames |
ccc6cda3 JA |
3330 | .B ``.'' |
3331 | and | |
3332 | .B ``..'' | |
d3a24ed2 | 3333 | are always ignored when |
ccc6cda3 JA |
3334 | .SM |
3335 | .B GLOBIGNORE | |
d3a24ed2 | 3336 | is set and not null. However, setting |
ccc6cda3 JA |
3337 | .SM |
3338 | .B GLOBIGNORE | |
d3a24ed2 | 3339 | to a non-null value has the effect of enabling the |
ccc6cda3 | 3340 | .B dotglob |
b28ff8c9 | 3341 | shell option, so all other filenames beginning with a |
ccc6cda3 JA |
3342 | .B ``.'' |
3343 | will match. | |
b28ff8c9 | 3344 | To get the old behavior of ignoring filenames beginning with a |
ccc6cda3 JA |
3345 | .BR ``.'' , |
3346 | make | |
3347 | .B ``.*'' | |
3348 | one of the patterns in | |
3349 | .SM | |
3350 | .BR GLOBIGNORE . | |
3351 | The | |
3352 | .B dotglob | |
3353 | option is disabled when | |
3354 | .SM | |
3355 | .B GLOBIGNORE | |
3356 | is unset. | |
726f6388 | 3357 | .PP |
cce855bc JA |
3358 | \fBPattern Matching\fP |
3359 | .PP | |
3360 | Any character that appears in a pattern, other than the special pattern | |
3361 | characters described below, matches itself. The NUL character may not | |
d3a24ed2 CR |
3362 | occur in a pattern. A backslash escapes the following character; the |
3363 | escaping backslash is discarded when matching. | |
3364 | The special pattern characters must be quoted if | |
cce855bc JA |
3365 | they are to be matched literally. |
3366 | .PP | |
726f6388 JA |
3367 | The special pattern characters have the following meanings: |
3368 | .PP | |
3369 | .PD 0 | |
89c77bc7 | 3370 | .RS |
726f6388 JA |
3371 | .TP |
3372 | .B * | |
3373 | Matches any string, including the null string. | |
4ac1ff98 | 3374 | When the \fBglobstar\fP shell option is enabled, and \fB*\fP is used in |
d0ca3503 | 3375 | a pathname expansion context, two adjacent \fB*\fPs used as a single |
4ac1ff98 CR |
3376 | pattern will match all files and zero or more directories and |
3377 | subdirectories. | |
3378 | If followed by a \fB/\fP, two adjacent \fB*\fPs will match only directories | |
3379 | and subdirectories. | |
726f6388 JA |
3380 | .TP |
3381 | .B ? | |
3382 | Matches any single character. | |
3383 | .TP | |
3384 | .B [...] | |
3385 | Matches any one of the enclosed characters. A pair of characters | |
28ef6c31 JA |
3386 | separated by a hyphen denotes a |
3387 | \fIrange expression\fP; | |
47b599dc | 3388 | any character that falls between those two characters, inclusive, |
28ef6c31 | 3389 | using the current locale's collating sequence and character set, |
726f6388 JA |
3390 | is matched. If the first character following the |
3391 | .B [ | |
3392 | is a | |
3393 | .B ! | |
3394 | or a | |
3395 | .B ^ | |
ccc6cda3 | 3396 | then any character not enclosed is matched. |
28ef6c31 | 3397 | The sorting order of characters in range expressions is determined by |
3443670e | 3398 | the current locale and the values of the |
984a1947 CR |
3399 | .SM |
3400 | .B LC_COLLATE | |
3443670e CR |
3401 | or |
3402 | .SM | |
3403 | .B LC_ALL | |
3404 | shell variables, if set. | |
3405 | To obtain the traditional interpretation of range expressions, where | |
3406 | .B [a\-d] | |
3407 | is equivalent to | |
3408 | .BR [abcd] , | |
3409 | set value of the | |
3410 | .B LC_ALL | |
3411 | shell variable to | |
74d0116b CR |
3412 | .BR C , |
3413 | or enable the | |
3414 | .B globasciiranges | |
3415 | shell option. | |
ccc6cda3 | 3416 | A |
726f6388 | 3417 | .B \- |
726f6388 JA |
3418 | may be matched by including it as the first or last character |
3419 | in the set. | |
ccc6cda3 JA |
3420 | A |
3421 | .B ] | |
3422 | may be matched by including it as the first character | |
3423 | in the set. | |
cce855bc JA |
3424 | .br |
3425 | .if t .sp 0.5 | |
3426 | .if n .sp 1 | |
3427 | Within | |
3428 | .B [ | |
3429 | and | |
3430 | .BR ] , | |
3431 | \fIcharacter classes\fP can be specified using the syntax | |
3432 | \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the | |
ac18b312 | 3433 | following classes defined in the POSIX standard: |
cce855bc JA |
3434 | .PP |
3435 | .RS | |
3436 | .B | |
7117c2d2 JA |
3437 | .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit |
3438 | .if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit | |
cce855bc JA |
3439 | .br |
3440 | A character class matches any character belonging to that class. | |
7117c2d2 | 3441 | The \fBword\fP character class matches letters, digits, and the character _. |
cce855bc JA |
3442 | .br |
3443 | .if t .sp 0.5 | |
3444 | .if n .sp 1 | |
3445 | Within | |
3446 | .B [ | |
3447 | and | |
3448 | .BR ] , | |
3449 | an \fIequivalence class\fP can be specified using the syntax | |
3450 | \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the | |
3451 | same collation weight (as defined by the current locale) as | |
3452 | the character \fIc\fP. | |
3453 | .br | |
3454 | .if t .sp 0.5 | |
3455 | .if n .sp 1 | |
3456 | Within | |
3457 | .B [ | |
3458 | and | |
3459 | .BR ] , | |
3460 | the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol | |
3461 | \fIsymbol\fP. | |
3462 | .RE | |
89c77bc7 | 3463 | .RE |
cce855bc JA |
3464 | .PD |
3465 | .PP | |
3466 | If the \fBextglob\fP shell option is enabled using the \fBshopt\fP | |
3467 | builtin, several extended pattern matching operators are recognized. | |
bb70624e | 3468 | In the following description, a \fIpattern-list\fP is a list of one |
cce855bc JA |
3469 | or more patterns separated by a \fB|\fP. |
3470 | Composite patterns may be formed using one or more of the following | |
3471 | sub-patterns: | |
3472 | .sp 1 | |
3473 | .PD 0 | |
3474 | .RS | |
3475 | .TP | |
3476 | \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP | |
3477 | Matches zero or one occurrence of the given patterns | |
3478 | .TP | |
3479 | \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP | |
3480 | Matches zero or more occurrences of the given patterns | |
3481 | .TP | |
3482 | \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP | |
3483 | Matches one or more occurrences of the given patterns | |
3484 | .TP | |
3485 | \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP | |
43df7bbb | 3486 | Matches one of the given patterns |
cce855bc JA |
3487 | .TP |
3488 | \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP | |
3489 | Matches anything except one of the given patterns | |
3490 | .RE | |
726f6388 JA |
3491 | .PD |
3492 | .SS Quote Removal | |
3493 | .PP | |
3494 | After the preceding expansions, all unquoted occurrences of the | |
3495 | characters | |
3496 | .BR \e , | |
20587658 | 3497 | .BR \(aq , |
ccc6cda3 JA |
3498 | and \^\f3"\fP\^ that did not result from one of the above |
3499 | expansions are removed. | |
726f6388 JA |
3500 | .SH REDIRECTION |
3501 | Before a command is executed, its input and output | |
3502 | may be | |
3503 | .I redirected | |
3504 | using a special notation interpreted by the shell. | |
c31d56a7 CR |
3505 | Redirection allows commands' file handles to be |
3506 | duplicated, opened, closed, | |
3507 | made to refer to different files, | |
3508 | and can change the files the command reads from and writes to. | |
3509 | Redirection may also be used to modify file handles in the | |
3510 | current shell execution environment. | |
3511 | The following redirection | |
726f6388 JA |
3512 | operators may precede or appear anywhere within a |
3513 | .I simple command | |
3514 | or may follow a | |
3515 | .IR command . | |
3516 | Redirections are processed in the order they appear, from | |
3517 | left to right. | |
3518 | .PP | |
a8fd3f3e CR |
3519 | Each redirection that may be preceded by a file descriptor number |
3520 | may instead be preceded by a word of the form {\fIvarname\fP}. | |
3521 | In this case, for each redirection operator except | |
3522 | >&- and <&-, the shell will allocate a file descriptor greater | |
19baff85 CR |
3523 | than or equal to 10 and assign it to \fIvarname\fP. |
3524 | If >&- or <&- is preceded | |
a8fd3f3e CR |
3525 | by {\fIvarname\fP}, the value of \fIvarname\fP defines the file |
3526 | descriptor to close. | |
3527 | .PP | |
726f6388 JA |
3528 | In the following descriptions, if the file descriptor number is |
3529 | omitted, and the first character of the redirection operator is | |
3530 | .BR < , | |
3531 | the redirection refers to the standard input (file descriptor | |
3532 | 0). If the first character of the redirection operator is | |
3533 | .BR > , | |
3534 | the redirection refers to the standard output (file descriptor | |
3535 | 1). | |
3536 | .PP | |
cce855bc | 3537 | The word following the redirection operator in the following |
7610e0c5 CR |
3538 | descriptions, unless otherwise noted, is subjected to |
3539 | brace expansion, tilde expansion, parameter and variable expansion, | |
3540 | command substitution, arithmetic expansion, quote removal, | |
3541 | pathname expansion, and word splitting. | |
cce855bc | 3542 | If it expands to more than one word, |
726f6388 JA |
3543 | .B bash |
3544 | reports an error. | |
3545 | .PP | |
3546 | Note that the order of redirections is significant. For example, | |
3547 | the command | |
3548 | .RS | |
3549 | .PP | |
3550 | ls \fB>\fP dirlist 2\fB>&\fP1 | |
3551 | .RE | |
3552 | .PP | |
3553 | directs both standard output and standard error to the file | |
3554 | .IR dirlist , | |
3555 | while the command | |
3556 | .RS | |
3557 | .PP | |
3558 | ls 2\fB>&\fP1 \fB>\fP dirlist | |
3559 | .RE | |
3560 | .PP | |
3561 | directs only the standard output to file | |
3562 | .IR dirlist , | |
db31fb26 | 3563 | because the standard error was duplicated from the standard output |
726f6388 JA |
3564 | before the standard output was redirected to |
3565 | .IR dirlist . | |
cce855bc | 3566 | .PP |
bb70624e JA |
3567 | \fBBash\fP handles several filenames specially when they are used in |
3568 | redirections, as described in the following table: | |
3569 | .RS | |
3570 | .PP | |
3571 | .PD 0 | |
3572 | .TP | |
3573 | .B /dev/fd/\fIfd\fP | |
3574 | If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated. | |
3575 | .TP | |
3576 | .B /dev/stdin | |
3577 | File descriptor 0 is duplicated. | |
3578 | .TP | |
3579 | .B /dev/stdout | |
3580 | File descriptor 1 is duplicated. | |
3581 | .TP | |
3582 | .B /dev/stderr | |
3583 | File descriptor 2 is duplicated. | |
3584 | .TP | |
3585 | .B /dev/tcp/\fIhost\fP/\fIport\fP | |
3586 | If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP | |
f73dda09 | 3587 | is an integer port number or service name, \fBbash\fP attempts to open |
e107650c | 3588 | the corresponding TCP socket. |
bb70624e JA |
3589 | .TP |
3590 | .B /dev/udp/\fIhost\fP/\fIport\fP | |
3591 | If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP | |
f73dda09 | 3592 | is an integer port number or service name, \fBbash\fP attempts to open |
e107650c | 3593 | the corresponding UDP socket. |
bb70624e JA |
3594 | .PD |
3595 | .RE | |
3596 | .PP | |
cce855bc | 3597 | A failure to open or create a file causes the redirection to fail. |
cac4cdbf CR |
3598 | .PP |
3599 | Redirections using file descriptors greater than 9 should be used with | |
3600 | care, as they may conflict with file descriptors the shell uses | |
3601 | internally. | |
726f6388 JA |
3602 | .SS Redirecting Input |
3603 | .PP | |
3604 | Redirection of input causes the file whose name results from | |
3605 | the expansion of | |
3606 | .I word | |
3607 | to be opened for reading on file descriptor | |
3608 | .IR n , | |
3609 | or the standard input (file descriptor 0) if | |
3610 | .I n | |
3611 | is not specified. | |
3612 | .PP | |
3613 | The general format for redirecting input is: | |
3614 | .RS | |
3615 | .PP | |
3616 | [\fIn\fP]\fB<\fP\fIword\fP | |
3617 | .RE | |
3618 | .SS Redirecting Output | |
3619 | .PP | |
3620 | Redirection of output causes the file whose name results from | |
3621 | the expansion of | |
3622 | .I word | |
3623 | to be opened for writing on file descriptor | |
3624 | .IR n , | |
3625 | or the standard output (file descriptor 1) if | |
3626 | .I n | |
3627 | is not specified. If the file does not exist it is created; | |
3628 | if it does exist it is truncated to zero size. | |
3629 | .PP | |
3630 | The general format for redirecting output is: | |
3631 | .RS | |
3632 | .PP | |
3633 | [\fIn\fP]\fB>\fP\fIword\fP | |
3634 | .RE | |
3635 | .PP | |
3636 | If the redirection operator is | |
ccc6cda3 JA |
3637 | .BR > , |
3638 | and the | |
cce855bc | 3639 | .B noclobber |
ccc6cda3 JA |
3640 | option to the |
3641 | .B set | |
bb70624e | 3642 | builtin has been enabled, the redirection will fail if the file |
cce855bc JA |
3643 | whose name results from the expansion of \fIword\fP exists and is |
3644 | a regular file. | |
ccc6cda3 | 3645 | If the redirection operator is |
726f6388 | 3646 | .BR >| , |
cce855bc JA |
3647 | or the redirection operator is |
3648 | .B > | |
3649 | and the | |
3650 | .B noclobber | |
726f6388 JA |
3651 | option to the |
3652 | .B set | |
cce855bc | 3653 | builtin command is not enabled, the redirection is attempted even |
ccc6cda3 | 3654 | if the file named by \fIword\fP exists. |
726f6388 JA |
3655 | .SS Appending Redirected Output |
3656 | .PP | |
3657 | Redirection of output in this fashion | |
3658 | causes the file whose name results from | |
3659 | the expansion of | |
3660 | .I word | |
3661 | to be opened for appending on file descriptor | |
3662 | .IR n , | |
3663 | or the standard output (file descriptor 1) if | |
3664 | .I n | |
3665 | is not specified. If the file does not exist it is created. | |
3666 | .PP | |
3667 | The general format for appending output is: | |
3668 | .RS | |
3669 | .PP | |
3670 | [\fIn\fP]\fB>>\fP\fIword\fP | |
3671 | .RE | |
3672 | .PP | |
3673 | .SS Redirecting Standard Output and Standard Error | |
3674 | .PP | |
8943768b | 3675 | This construct allows both the |
726f6388 JA |
3676 | standard output (file descriptor 1) and |
3677 | the standard error output (file descriptor 2) | |
3678 | to be redirected to the file whose name is the | |
3679 | expansion of | |
8943768b | 3680 | .IR word . |
726f6388 JA |
3681 | .PP |
3682 | There are two formats for redirecting standard output and | |
3683 | standard error: | |
3684 | .RS | |
3685 | .PP | |
3686 | \fB&>\fP\fIword\fP | |
3687 | .RE | |
3688 | and | |
3689 | .RS | |
3690 | \fB>&\fP\fIword\fP | |
3691 | .RE | |
3692 | .PP | |
3693 | Of the two forms, the first is preferred. | |
3694 | This is semantically equivalent to | |
3695 | .RS | |
3696 | .PP | |
3697 | \fB>\fP\fIword\fP 2\fB>&\fP1 | |
3698 | .RE | |
8943768b | 3699 | .PP |
c5402025 CR |
3700 | When using the second form, \fIword\fP may not expand to a number or |
3701 | \fB\-\fP. If it does, other redirection operators apply | |
3702 | (see \fBDuplicating File Descriptors\fP below) for compatibility | |
3703 | reasons. | |
8943768b CR |
3704 | .SS Appending Standard Output and Standard Error |
3705 | .PP | |
3706 | This construct allows both the | |
3707 | standard output (file descriptor 1) and | |
3708 | the standard error output (file descriptor 2) | |
3709 | to be appended to the file whose name is the | |
3710 | expansion of | |
3711 | .IR word . | |
3712 | .PP | |
3713 | The format for appending standard output and standard error is: | |
3714 | .RS | |
3715 | .PP | |
3716 | \fB&>>\fP\fIword\fP | |
3717 | .RE | |
3718 | .PP | |
3719 | This is semantically equivalent to | |
3720 | .RS | |
3721 | .PP | |
3722 | \fB>>\fP\fIword\fP 2\fB>&\fP1 | |
3723 | .RE | |
f6da9f85 CR |
3724 | .PP |
3725 | (see \fBDuplicating File Descriptors\fP below). | |
726f6388 JA |
3726 | .SS Here Documents |
3727 | .PP | |
3728 | This type of redirection instructs the shell to read input from the | |
3729 | current source until a line containing only | |
626d0694 | 3730 | .I delimiter |
726f6388 JA |
3731 | (with no trailing blanks) |
3732 | is seen. All of | |
3733 | the lines read up to that point are then used as the standard | |
3734 | input for a command. | |
3735 | .PP | |
7117c2d2 | 3736 | The format of here-documents is: |
726f6388 JA |
3737 | .RS |
3738 | .PP | |
3739 | .nf | |
3740 | \fB<<\fP[\fB\-\fP]\fIword\fP | |
f73dda09 | 3741 | \fIhere-document\fP |
726f6388 JA |
3742 | \fIdelimiter\fP |
3743 | .fi | |
3744 | .RE | |
3745 | .PP | |
7610e0c5 CR |
3746 | No parameter and variable expansion, command substitution, |
3747 | arithmetic expansion, or pathname expansion is performed on | |
726f6388 JA |
3748 | .IR word . |
3749 | If any characters in | |
3750 | .I word | |
3751 | are quoted, the | |
3752 | .I delimiter | |
3753 | is the result of quote removal on | |
3754 | .IR word , | |
cce855bc JA |
3755 | and the lines in the here-document are not expanded. |
3756 | If \fIword\fP is unquoted, | |
e73012f1 CR |
3757 | all lines of the here-document are subjected to |
3758 | parameter expansion, command substitution, and arithmetic expansion, | |
3759 | the character sequence | |
726f6388 JA |
3760 | .B \e<newline> |
3761 | is ignored, and | |
3762 | .B \e | |
3763 | must be used to quote the characters | |
3764 | .BR \e , | |
3765 | .BR $ , | |
3766 | and | |
3d4e09aa | 3767 | .BR \` . |
726f6388 JA |
3768 | .PP |
3769 | If the redirection operator is | |
3770 | .BR <<\- , | |
3771 | then all leading tab characters are stripped from input lines and the | |
3772 | line containing | |
3773 | .IR delimiter . | |
3774 | This allows | |
3775 | here-documents within shell scripts to be indented in a | |
3776 | natural fashion. | |
7117c2d2 JA |
3777 | .SS "Here Strings" |
3778 | A variant of here documents, the format is: | |
3779 | .RS | |
3780 | .PP | |
3781 | .nf | |
3782 | \fB<<<\fP\fIword\fP | |
3783 | .fi | |
3784 | .RE | |
3785 | .PP | |
7610e0c5 CR |
3786 | The \fIword\fP undergoes |
3787 | brace expansion, tilde expansion, parameter and variable expansion, | |
3788 | command substitution, arithmetic expansion, and quote removal. | |
e73012f1 | 3789 | Pathname expansion and word splitting are not performed. |
7610e0c5 CR |
3790 | The result is supplied as a single string to the command on its |
3791 | standard input. | |
726f6388 JA |
3792 | .SS "Duplicating File Descriptors" |
3793 | .PP | |
3794 | The redirection operator | |
3795 | .RS | |
3796 | .PP | |
3797 | [\fIn\fP]\fB<&\fP\fIword\fP | |
3798 | .RE | |
3799 | .PP | |
3800 | is used to duplicate input file descriptors. | |
3801 | If | |
3802 | .I word | |
3803 | expands to one or more digits, the file descriptor denoted by | |
3804 | .I n | |
cce855bc JA |
3805 | is made to be a copy of that file descriptor. |
3806 | If the digits in | |
3807 | .I word | |
3808 | do not specify a file descriptor open for input, a redirection error occurs. | |
3809 | If | |
726f6388 JA |
3810 | .I word |
3811 | evaluates to | |
3812 | .BR \- , | |
3813 | file descriptor | |
3814 | .I n | |
3815 | is closed. If | |
3816 | .I n | |
3817 | is not specified, the standard input (file descriptor 0) is used. | |
3818 | .PP | |
3819 | The operator | |
3820 | .RS | |
3821 | .PP | |
3822 | [\fIn\fP]\fB>&\fP\fIword\fP | |
3823 | .RE | |
3824 | .PP | |
3825 | is used similarly to duplicate output file descriptors. If | |
3826 | .I n | |
3827 | is not specified, the standard output (file descriptor 1) is used. | |
cce855bc JA |
3828 | If the digits in |
3829 | .I word | |
3830 | do not specify a file descriptor open for output, a redirection error occurs. | |
c5402025 CR |
3831 | If |
3832 | .I word | |
3833 | evaluates to | |
3834 | .BR \- , | |
3835 | file descriptor | |
3836 | .I n | |
3837 | is closed. | |
726f6388 | 3838 | As a special case, if \fIn\fP is omitted, and \fIword\fP does not |
c5402025 | 3839 | expand to one or more digits or \fB\-\fP, the standard output and standard |
726f6388 | 3840 | error are redirected as described previously. |
7117c2d2 JA |
3841 | .SS "Moving File Descriptors" |
3842 | .PP | |
3843 | The redirection operator | |
3844 | .RS | |
3845 | .PP | |
3846 | [\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP | |
3847 | .RE | |
3848 | .PP | |
3849 | moves the file descriptor \fIdigit\fP to file descriptor | |
3850 | .IR n , | |
3851 | or the standard input (file descriptor 0) if \fIn\fP is not specified. | |
3852 | \fIdigit\fP is closed after being duplicated to \fIn\fP. | |
3853 | .PP | |
3854 | Similarly, the redirection operator | |
3855 | .RS | |
3856 | .PP | |
3857 | [\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP | |
3858 | .RE | |
3859 | .PP | |
3860 | moves the file descriptor \fIdigit\fP to file descriptor | |
3861 | .IR n , | |
3862 | or the standard output (file descriptor 1) if \fIn\fP is not specified. | |
726f6388 JA |
3863 | .SS "Opening File Descriptors for Reading and Writing" |
3864 | .PP | |
3865 | The redirection operator | |
3866 | .RS | |
3867 | .PP | |
3868 | [\fIn\fP]\fB<>\fP\fIword\fP | |
3869 | .RE | |
3870 | .PP | |
3871 | causes the file whose name is the expansion of | |
3872 | .I word | |
3873 | to be opened for both reading and writing on file descriptor | |
3874 | .IR n , | |
ccc6cda3 | 3875 | or on file descriptor 0 if |
726f6388 JA |
3876 | .I n |
3877 | is not specified. If the file does not exist, it is created. | |
726f6388 | 3878 | .SH ALIASES |
bb70624e | 3879 | \fIAliases\fP allow a string to be substituted for a word when it is used |
cce855bc | 3880 | as the first word of a simple command. |
bb70624e | 3881 | The shell maintains a list of aliases that may be set and unset with the |
726f6388 JA |
3882 | .B alias |
3883 | and | |
3884 | .B unalias | |
3885 | builtin commands (see | |
3886 | .SM | |
3887 | .B SHELL BUILTIN COMMANDS | |
3888 | below). | |
de8913bd | 3889 | The first word of each simple command, if unquoted, |
726f6388 JA |
3890 | is checked to see if it has an |
3891 | alias. If so, that word is replaced by the text of the alias. | |
3d4e09aa | 3892 | The characters \fB/\fP, \fB$\fP, \fB\`\fP, and \fB=\fP and |
de8913bd CR |
3893 | any of the shell \fImetacharacters\fP or quoting characters |
3894 | listed above may not appear in an alias name. | |
3895 | The replacement text may contain any valid shell input, | |
3896 | including shell metacharacters. | |
3897 | The first word of the replacement text is tested | |
726f6388 | 3898 | for aliases, but a word that is identical to an alias being expanded |
de8913bd CR |
3899 | is not expanded a second time. |
3900 | This means that one may alias | |
726f6388 JA |
3901 | .B ls |
3902 | to | |
3903 | .BR "ls \-F" , | |
3904 | for instance, and | |
3905 | .B bash | |
3906 | does not try to recursively expand the replacement text. | |
3907 | If the last character of the alias value is a | |
3908 | .IR blank , | |
3909 | then the next command | |
3910 | word following the alias is also checked for alias expansion. | |
3911 | .PP | |
3912 | Aliases are created and listed with the | |
3913 | .B alias | |
3914 | command, and removed with the | |
3915 | .B unalias | |
3916 | command. | |
3917 | .PP | |
ccc6cda3 | 3918 | There is no mechanism for using arguments in the replacement text. |
bb70624e JA |
3919 | If arguments are needed, a shell function should be used (see |
3920 | .SM | |
3921 | .B FUNCTIONS | |
3922 | below). | |
726f6388 | 3923 | .PP |
ccc6cda3 JA |
3924 | Aliases are not expanded when the shell is not interactive, unless |
3925 | the | |
3926 | .B expand_aliases | |
3927 | shell option is set using | |
3928 | .B shopt | |
3929 | (see the description of | |
3930 | .B shopt | |
3931 | under | |
3932 | .SM | |
3933 | \fBSHELL BUILTIN COMMANDS\fP | |
3934 | below). | |
726f6388 JA |
3935 | .PP |
3936 | The rules concerning the definition and use of aliases are | |
3937 | somewhat confusing. | |
3938 | .B Bash | |
3939 | always reads at least one complete line | |
3940 | of input before executing any | |
3941 | of the commands on that line. Aliases are expanded when a | |
3942 | command is read, not when it is executed. Therefore, an | |
3943 | alias definition appearing on the same line as another | |
3944 | command does not take effect until the next line of input is read. | |
ccc6cda3 | 3945 | The commands following the alias definition |
726f6388 JA |
3946 | on that line are not affected by the new alias. |
3947 | This behavior is also an issue when functions are executed. | |
cce855bc | 3948 | Aliases are expanded when a function definition is read, |
726f6388 JA |
3949 | not when the function is executed, because a function definition |
3950 | is itself a compound command. As a consequence, aliases | |
3951 | defined in a function are not available until after that | |
3952 | function is executed. To be safe, always put | |
3953 | alias definitions on a separate line, and do not use | |
3954 | .B alias | |
3955 | in compound commands. | |
3956 | .PP | |
cce855bc | 3957 | For almost every purpose, aliases are superseded by |
726f6388 | 3958 | shell functions. |
ccc6cda3 JA |
3959 | .SH FUNCTIONS |
3960 | A shell function, defined as described above under | |
3961 | .SM | |
3962 | .BR "SHELL GRAMMAR" , | |
3963 | stores a series of commands for later execution. | |
bb70624e JA |
3964 | When the name of a shell function is used as a simple command name, |
3965 | the list of commands associated with that function name is executed. | |
ccc6cda3 JA |
3966 | Functions are executed in the context of the |
3967 | current shell; no new process is created to interpret | |
3968 | them (contrast this with the execution of a shell script). | |
3969 | When a function is executed, the arguments to the | |
3970 | function become the positional parameters | |
bb70624e JA |
3971 | during its execution. |
3972 | The special parameter | |
ccc6cda3 | 3973 | .B # |
dc60d4e0 | 3974 | is updated to reflect the change. Special parameter \fB0\fP |
bb70624e | 3975 | is unchanged. |
d3a24ed2 | 3976 | The first element of the |
bb70624e JA |
3977 | .SM |
3978 | .B FUNCNAME | |
3979 | variable is set to the name of the function while the function | |
3980 | is executing. | |
4301bca7 | 3981 | .PP |
bb70624e | 3982 | All other aspects of the shell execution |
ccc6cda3 | 3983 | environment are identical between a function and its caller |
4301bca7 | 3984 | with these exceptions: the |
ccc6cda3 JA |
3985 | .SM |
3986 | .B DEBUG | |
76a8d78d CR |
3987 | and |
3988 | .B RETURN | |
3989 | traps (see the description of the | |
ccc6cda3 JA |
3990 | .B trap |
3991 | builtin under | |
3992 | .SM | |
3993 | .B SHELL BUILTIN COMMANDS | |
76a8d78d | 3994 | below) are not inherited unless the function has been given the |
7117c2d2 JA |
3995 | \fBtrace\fP attribute (see the description of the |
3996 | .SM | |
3997 | .B declare | |
d3a24ed2 CR |
3998 | builtin below) or the |
3999 | \fB\-o functrace\fP shell option has been enabled with | |
4000 | the \fBset\fP builtin | |
4301bca7 CR |
4001 | (in which case all functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps), |
4002 | and the | |
4003 | .SM | |
4004 | .B ERR | |
4005 | trap is not inherited unless the \fB\-o errtrace\fP shell option has | |
4006 | been enabled. | |
726f6388 | 4007 | .PP |
ccc6cda3 JA |
4008 | Variables local to the function may be declared with the |
4009 | .B local | |
4010 | builtin command. Ordinarily, variables and their values | |
4011 | are shared between the function and its caller. | |
726f6388 | 4012 | .PP |
6faad625 CR |
4013 | The \fBFUNCNEST\fP variable, if set to a numeric value greater |
4014 | than 0, defines a maximum function nesting level. Function | |
4015 | invocations that exceed the limit cause the entire command to | |
4016 | abort. | |
4017 | .PP | |
ccc6cda3 JA |
4018 | If the builtin command |
4019 | .B return | |
4020 | is executed in a function, the function completes and | |
4021 | execution resumes with the next command after the function | |
d3a24ed2 CR |
4022 | call. |
4023 | Any command associated with the \fBRETURN\fP trap is executed | |
4024 | before execution resumes. | |
4025 | When a function completes, the values of the | |
ccc6cda3 JA |
4026 | positional parameters and the special parameter |
4027 | .B # | |
cce855bc | 4028 | are restored to the values they had prior to the function's |
ccc6cda3 | 4029 | execution. |
726f6388 | 4030 | .PP |
ccc6cda3 JA |
4031 | Function names and definitions may be listed with the |
4032 | .B \-f | |
726f6388 | 4033 | option to the |
ccc6cda3 JA |
4034 | .B declare |
4035 | or | |
4036 | .B typeset | |
4037 | builtin commands. The | |
4038 | .B \-F | |
4039 | option to | |
4040 | .B declare | |
4041 | or | |
4042 | .B typeset | |
d3a24ed2 CR |
4043 | will list the function names only |
4044 | (and optionally the source file and line number, if the \fBextdebug\fP | |
4045 | shell option is enabled). | |
ccc6cda3 JA |
4046 | Functions may be exported so that subshells |
4047 | automatically have them defined with the | |
4048 | .B \-f | |
4049 | option to the | |
4050 | .B export | |
4051 | builtin. | |
11a6f9a9 CR |
4052 | A function definition may be deleted using the \fB\-f\fP option to |
4053 | the | |
4054 | .B unset | |
4055 | builtin. | |
d3a24ed2 CR |
4056 | Note that shell functions and variables with the same name may result |
4057 | in multiple identically-named entries in the environment passed to the | |
4058 | shell's children. | |
4059 | Care should be taken in cases where this may cause a problem. | |
726f6388 | 4060 | .PP |
7d92f73f CR |
4061 | Functions may be recursive. |
4062 | The \fBFUNCNEST\fP variable may be used to limit the depth of the | |
4063 | function call stack and restrict the number of function invocations. | |
4064 | By default, no limit is imposed on the number of recursive calls. | |
cce855bc JA |
4065 | .SH "ARITHMETIC EVALUATION" |
4066 | The shell allows arithmetic expressions to be evaluated, under | |
d3a24ed2 CR |
4067 | certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin |
4068 | commands and \fBArithmetic Expansion\fP). | |
7117c2d2 | 4069 | Evaluation is done in fixed-width integers with no check for overflow, |
cce855bc | 4070 | though division by 0 is trapped and flagged as an error. |
d3a24ed2 CR |
4071 | The operators and their precedence, associativity, and values |
4072 | are the same as in the C language. | |
cce855bc JA |
4073 | The following list of operators is grouped into levels of |
4074 | equal-precedence operators. | |
4075 | The levels are listed in order of decreasing precedence. | |
726f6388 | 4076 | .PP |
cce855bc JA |
4077 | .PD 0 |
4078 | .TP | |
bb70624e JA |
4079 | .B \fIid\fP++ \fIid\fP\-\- |
4080 | variable post-increment and post-decrement | |
4081 | .TP | |
4082 | .B ++\fIid\fP \-\-\fIid\fP | |
4083 | variable pre-increment and pre-decrement | |
4084 | .TP | |
cce855bc JA |
4085 | .B \- + |
4086 | unary minus and plus | |
4087 | .TP | |
4088 | .B ! ~ | |
4089 | logical and bitwise negation | |
4090 | .TP | |
4091 | .B ** | |
4092 | exponentiation | |
4093 | .TP | |
4094 | .B * / % | |
4095 | multiplication, division, remainder | |
4096 | .TP | |
4097 | .B + \- | |
4098 | addition, subtraction | |
4099 | .TP | |
4100 | .B << >> | |
4101 | left and right bitwise shifts | |
4102 | .TP | |
4103 | .B <= >= < > | |
4104 | comparison | |
4105 | .TP | |
4106 | .B == != | |
4107 | equality and inequality | |
4108 | .TP | |
4109 | .B & | |
4110 | bitwise AND | |
4111 | .TP | |
4112 | .B ^ | |
4113 | bitwise exclusive OR | |
4114 | .TP | |
4115 | .B | | |
4116 | bitwise OR | |
4117 | .TP | |
4118 | .B && | |
4119 | logical AND | |
4120 | .TP | |
4121 | .B || | |
4122 | logical OR | |
4123 | .TP | |
4124 | .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP | |
d3a24ed2 | 4125 | conditional operator |
cce855bc JA |
4126 | .TP |
4127 | .B = *= /= %= += \-= <<= >>= &= ^= |= | |
4128 | assignment | |
bb70624e JA |
4129 | .TP |
4130 | .B \fIexpr1\fP , \fIexpr2\fP | |
4131 | comma | |
cce855bc | 4132 | .PD |
ccc6cda3 | 4133 | .PP |
cce855bc | 4134 | Shell variables are allowed as operands; parameter expansion is |
bb70624e JA |
4135 | performed before the expression is evaluated. |
4136 | Within an expression, shell variables may also be referenced by name | |
4137 | without using the parameter expansion syntax. | |
d3a24ed2 CR |
4138 | A shell variable that is null or unset evaluates to 0 when referenced |
4139 | by name without using the parameter expansion syntax. | |
bb70624e | 4140 | The value of a variable is evaluated as an arithmetic expression |
d3a24ed2 CR |
4141 | when it is referenced, or when a variable which has been given the |
4142 | \fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value. | |
4143 | A null value evaluates to 0. | |
dc60d4e0 | 4144 | A shell variable need not have its \fIinteger\fP attribute |
cce855bc | 4145 | turned on to be used in an expression. |
ccc6cda3 | 4146 | .PP |
cce855bc JA |
4147 | Constants with a leading 0 are interpreted as octal numbers. |
4148 | A leading 0x or 0X denotes hexadecimal. | |
1b13a290 | 4149 | Otherwise, numbers take the form [\fIbase#\fP]n, where the optional \fIbase\fP |
cce855bc JA |
4150 | is a decimal number between 2 and 64 representing the arithmetic |
4151 | base, and \fIn\fP is a number in that base. | |
bb70624e | 4152 | If \fIbase#\fP is omitted, then base 10 is used. |
c31d56a7 CR |
4153 | When specifying \fIn\fP, |
4154 | the digits greater< than 9 are represented by the lowercase letters, | |
f73dda09 | 4155 | the uppercase letters, @, and _, in that order. |
cce855bc | 4156 | If \fIbase\fP is less than or equal to 36, lowercase and uppercase |
f75912ae | 4157 | letters may be used interchangeably to represent numbers between 10 |
cce855bc | 4158 | and 35. |
ccc6cda3 | 4159 | .PP |
cce855bc JA |
4160 | Operators are evaluated in order of precedence. Sub-expressions in |
4161 | parentheses are evaluated first and may override the precedence | |
4162 | rules above. | |
4163 | .SH "CONDITIONAL EXPRESSIONS" | |
4164 | Conditional expressions are used by the \fB[[\fP compound command and | |
4165 | the \fBtest\fP and \fB[\fP builtin commands to test file attributes | |
4166 | and perform string and arithmetic comparisons. | |
4167 | Expressions are formed from the following unary or binary primaries. | |
4168 | If any \fIfile\fP argument to one of the primaries is of the form | |
bb70624e JA |
4169 | \fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked. |
4170 | If the \fIfile\fP argument to one of the primaries is one of | |
4171 | \fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file | |
4172 | descriptor 0, 1, or 2, respectively, is checked. | |
be7d8f2d CR |
4173 | .PP |
4174 | Unless otherwise specified, primaries that operate on files follow symbolic | |
4175 | links and operate on the target of the link, rather than the link itself. | |
6bf8a8a7 CR |
4176 | .if t .sp 0.5 |
4177 | .if n .sp 1 | |
54a1fa7c | 4178 | When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort |
6bf8a8a7 | 4179 | lexicographically using the current locale. |
54a1fa7c | 4180 | The \fBtest\fP command sorts using ASCII ordering. |
cce855bc JA |
4181 | .sp 1 |
4182 | .PD 0 | |
4183 | .TP | |
4184 | .B \-a \fIfile\fP | |
4185 | True if \fIfile\fP exists. | |
4186 | .TP | |
4187 | .B \-b \fIfile\fP | |
4188 | True if \fIfile\fP exists and is a block special file. | |
4189 | .TP | |
4190 | .B \-c \fIfile\fP | |
4191 | True if \fIfile\fP exists and is a character special file. | |
4192 | .TP | |
4193 | .B \-d \fIfile\fP | |
4194 | True if \fIfile\fP exists and is a directory. | |
4195 | .TP | |
4196 | .B \-e \fIfile\fP | |
4197 | True if \fIfile\fP exists. | |
4198 | .TP | |
4199 | .B \-f \fIfile\fP | |
4200 | True if \fIfile\fP exists and is a regular file. | |
4201 | .TP | |
4202 | .B \-g \fIfile\fP | |
4203 | True if \fIfile\fP exists and is set-group-id. | |
4204 | .TP | |
b72432fd JA |
4205 | .B \-h \fIfile\fP |
4206 | True if \fIfile\fP exists and is a symbolic link. | |
4207 | .TP | |
cce855bc JA |
4208 | .B \-k \fIfile\fP |
4209 | True if \fIfile\fP exists and its ``sticky'' bit is set. | |
4210 | .TP | |
4211 | .B \-p \fIfile\fP | |
4212 | True if \fIfile\fP exists and is a named pipe (FIFO). | |
4213 | .TP | |
4214 | .B \-r \fIfile\fP | |
4215 | True if \fIfile\fP exists and is readable. | |
4216 | .TP | |
4217 | .B \-s \fIfile\fP | |
4218 | True if \fIfile\fP exists and has a size greater than zero. | |
4219 | .TP | |
4220 | .B \-t \fIfd\fP | |
4221 | True if file descriptor | |
4222 | .I fd | |
4223 | is open and refers to a terminal. | |
4224 | .TP | |
4225 | .B \-u \fIfile\fP | |
4226 | True if \fIfile\fP exists and its set-user-id bit is set. | |
4227 | .TP | |
4228 | .B \-w \fIfile\fP | |
4229 | True if \fIfile\fP exists and is writable. | |
4230 | .TP | |
4231 | .B \-x \fIfile\fP | |
4232 | True if \fIfile\fP exists and is executable. | |
4233 | .TP | |
cce855bc JA |
4234 | .B \-G \fIfile\fP |
4235 | True if \fIfile\fP exists and is owned by the effective group id. | |
4236 | .TP | |
4237 | .B \-L \fIfile\fP | |
4238 | True if \fIfile\fP exists and is a symbolic link. | |
4239 | .TP | |
5cdaaf76 CR |
4240 | .B \-N \fIfile\fP |
4241 | True if \fIfile\fP exists and has been modified since it was last read. | |
4242 | .TP | |
4243 | .B \-O \fIfile\fP | |
4244 | True if \fIfile\fP exists and is owned by the effective user id. | |
4245 | .TP | |
cce855bc JA |
4246 | .B \-S \fIfile\fP |
4247 | True if \fIfile\fP exists and is a socket. | |
4248 | .TP | |
5cdaaf76 CR |
4249 | \fIfile1\fP \fB\-ef\fP \fIfile2\fP |
4250 | True if \fIfile1\fP and \fIfile2\fP refer to the same device and | |
4251 | inode numbers. | |
cce855bc JA |
4252 | .TP |
4253 | \fIfile1\fP \-\fBnt\fP \fIfile2\fP | |
7117c2d2 JA |
4254 | True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP, |
4255 | or if \fIfile1\fP exists and \fPfile2\fP does not. | |
cce855bc JA |
4256 | .TP |
4257 | \fIfile1\fP \-\fBot\fP \fIfile2\fP | |
7117c2d2 JA |
4258 | True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists |
4259 | and \fIfile1\fP does not. | |
cce855bc | 4260 | .TP |
cce855bc | 4261 | .B \-o \fIoptname\fP |
6faad625 | 4262 | True if the shell option |
cce855bc JA |
4263 | .I optname |
4264 | is enabled. | |
4265 | See the list of options under the description of the | |
4266 | .B \-o | |
4267 | option to the | |
4268 | .B set | |
4269 | builtin below. | |
4270 | .TP | |
6faad625 CR |
4271 | .B \-v \fIvarname\fP |
4272 | True if the shell variable | |
4273 | .I varname | |
4274 | is set (has been assigned a value). | |
4275 | .TP | |
15623760 CR |
4276 | .B \-R \fIvarname\fP |
4277 | True if the shell variable | |
4278 | .I varname | |
4279 | is set and is a name reference. | |
4280 | .TP | |
cce855bc JA |
4281 | .B \-z \fIstring\fP |
4282 | True if the length of \fIstring\fP is zero. | |
4283 | .TP | |
cce855bc | 4284 | \fIstring\fP |
f085a21f CR |
4285 | .PD 0 |
4286 | .TP | |
4287 | .B \-n \fIstring\fP | |
4288 | .PD | |
cce855bc JA |
4289 | True if the length of |
4290 | .I string | |
4291 | is non-zero. | |
4292 | .TP | |
4293 | \fIstring1\fP \fB==\fP \fIstring2\fP | |
a3143574 CR |
4294 | .PD 0 |
4295 | .TP | |
4296 | \fIstring1\fP \fB=\fP \fIstring2\fP | |
4297 | .PD | |
4298 | True if the strings are equal. \fB=\fP should be used | |
4299 | with the \fBtest\fP command for POSIX conformance. | |
df0e4bfe CR |
4300 | When used with the \fB[[\fP command, this performs pattern matching as |
4301 | described above (\fBCompound Commands\fP). | |
cce855bc JA |
4302 | .TP |
4303 | \fIstring1\fP \fB!=\fP \fIstring2\fP | |
4304 | True if the strings are not equal. | |
4305 | .TP | |
4306 | \fIstring1\fP \fB<\fP \fIstring2\fP | |
0d8616ff | 4307 | True if \fIstring1\fP sorts before \fIstring2\fP lexicographically. |
cce855bc JA |
4308 | .TP |
4309 | \fIstring1\fP \fB>\fP \fIstring2\fP | |
0d8616ff | 4310 | True if \fIstring1\fP sorts after \fIstring2\fP lexicographically. |
cce855bc JA |
4311 | .TP |
4312 | .I \fIarg1\fP \fBOP\fP \fIarg2\fP | |
4313 | .SM | |
4314 | .B OP | |
4315 | is one of | |
4316 | .BR \-eq , | |
4317 | .BR \-ne , | |
4318 | .BR \-lt , | |
4319 | .BR \-le , | |
4320 | .BR \-gt , | |
4321 | or | |
4322 | .BR \-ge . | |
4323 | These arithmetic binary operators return true if \fIarg1\fP | |
4324 | is equal to, not equal to, less than, less than or equal to, | |
4325 | greater than, or greater than or equal to \fIarg2\fP, respectively. | |
4326 | .I Arg1 | |
4327 | and | |
4328 | .I arg2 | |
4329 | may be positive or negative integers. | |
4330 | .PD | |
4331 | .SH "SIMPLE COMMAND EXPANSION" | |
4332 | When a simple command is executed, the shell performs the following | |
4333 | expansions, assignments, and redirections, from left to right. | |
4334 | .IP 1. | |
4335 | The words that the parser has marked as variable assignments (those | |
4336 | preceding the command name) and redirections are saved for later | |
4337 | processing. | |
4338 | .IP 2. | |
4339 | The words that are not variable assignments or redirections are | |
4340 | expanded. If any words remain after expansion, the first word | |
4341 | is taken to be the name of the command and the remaining words are | |
4342 | the arguments. | |
4343 | .IP 3. | |
4344 | Redirections are performed as described above under | |
4345 | .SM | |
4346 | .BR REDIRECTION . | |
4347 | .IP 4. | |
4348 | The text after the \fB=\fP in each variable assignment undergoes tilde | |
4349 | expansion, parameter expansion, command substitution, arithmetic expansion, | |
4350 | and quote removal before being assigned to the variable. | |
4351 | .PP | |
4352 | If no command name results, the variable assignments affect the current | |
4353 | shell environment. Otherwise, the variables are added to the environment | |
4354 | of the executed command and do not affect the current shell environment. | |
4355 | If any of the assignments attempts to assign a value to a readonly variable, | |
4356 | an error occurs, and the command exits with a non-zero status. | |
4357 | .PP | |
4358 | If no command name results, redirections are performed, but do not | |
4359 | affect the current shell environment. A redirection error causes the | |
4360 | command to exit with a non-zero status. | |
4361 | .PP | |
4362 | If there is a command name left after expansion, execution proceeds as | |
4363 | described below. Otherwise, the command exits. If one of the expansions | |
4364 | contained a command substitution, the exit status of the command is | |
4365 | the exit status of the last command substitution performed. If there | |
4366 | were no command substitutions, the command exits with a status of zero. | |
4367 | .SH "COMMAND EXECUTION" | |
4368 | After a command has been split into words, if it results in a | |
4369 | simple command and an optional list of arguments, the following | |
4370 | actions are taken. | |
4371 | .PP | |
4372 | If the command name contains no slashes, the shell attempts to | |
4373 | locate it. If there exists a shell function by that name, that | |
4374 | function is invoked as described above in | |
4375 | .SM | |
4376 | .BR FUNCTIONS . | |
4377 | If the name does not match a function, the shell searches for | |
4378 | it in the list of shell builtins. If a match is found, that | |
4379 | builtin is invoked. | |
4380 | .PP | |
4381 | If the name is neither a shell function nor a builtin, | |
4382 | and contains no slashes, | |
4383 | .B bash | |
4384 | searches each element of the | |
4385 | .SM | |
4386 | .B PATH | |
4387 | for a directory containing an executable file by that name. | |
4388 | .B Bash | |
bb70624e | 4389 | uses a hash table to remember the full pathnames of executable |
cce855bc JA |
4390 | files (see |
4391 | .B hash | |
4392 | under | |
4393 | .SM | |
4394 | .B "SHELL BUILTIN COMMANDS" | |
4395 | below). | |
4396 | A full search of the directories in | |
4397 | .SM | |
4398 | .B PATH | |
4399 | is performed only if the command is not found in the hash table. | |
245a493c CR |
4400 | If the search is unsuccessful, the shell searches for a defined shell |
4401 | function named \fBcommand_not_found_handle\fP. | |
4402 | If that function exists, it is invoked with the original command and | |
4403 | the original command's arguments as its arguments, and the function's | |
4404 | exit status becomes the exit status of the shell. | |
4405 | If that function is not defined, the shell prints an error | |
cce855bc JA |
4406 | message and returns an exit status of 127. |
4407 | .PP | |
4408 | If the search is successful, or if the command name contains | |
4409 | one or more slashes, the shell executes the named program in a | |
4410 | separate execution environment. | |
4411 | Argument 0 is set to the name given, and the remaining arguments | |
4412 | to the command are set to the arguments given, if any. | |
4413 | .PP | |
4414 | If this execution fails because the file is not in executable | |
4415 | format, and the file is not a directory, it is assumed to be | |
4416 | a \fIshell script\fP, a file | |
4417 | containing shell commands. A subshell is spawned to execute | |
4418 | it. This subshell reinitializes itself, so | |
4419 | that the effect is as if a new shell had been invoked | |
4420 | to handle the script, with the exception that the locations of | |
4421 | commands remembered by the parent (see | |
4422 | .B hash | |
4423 | below under | |
4424 | .SM | |
4425 | \fBSHELL BUILTIN COMMANDS\fP) | |
4426 | are retained by the child. | |
4427 | .PP | |
4428 | If the program is a file beginning with | |
4429 | .BR #! , | |
4430 | the remainder of the first line specifies an interpreter | |
4431 | for the program. The shell executes the | |
4432 | specified interpreter on operating systems that do not | |
4433 | handle this executable format themselves. The arguments to the | |
4434 | interpreter consist of a single optional argument following the | |
4435 | interpreter name on the first line of the program, followed | |
4436 | by the name of the program, followed by the command | |
4437 | arguments, if any. | |
4438 | .SH COMMAND EXECUTION ENVIRONMENT | |
4439 | The shell has an \fIexecution environment\fP, which consists of the | |
4440 | following: | |
cce855bc JA |
4441 | .IP \(bu |
4442 | open files inherited by the shell at invocation, as modified by | |
4443 | redirections supplied to the \fBexec\fP builtin | |
4444 | .IP \(bu | |
4445 | the current working directory as set by \fBcd\fP, \fBpushd\fP, or | |
4446 | \fBpopd\fP, or inherited by the shell at invocation | |
4447 | .IP \(bu | |
4448 | the file creation mode mask as set by \fBumask\fP or inherited from | |
4449 | the shell's parent | |
4450 | .IP \(bu | |
4451 | current traps set by \fBtrap\fP | |
4452 | .IP \(bu | |
4453 | shell parameters that are set by variable assignment or with \fBset\fP | |
4454 | or inherited from the shell's parent in the environment | |
4455 | .IP \(bu | |
4456 | shell functions defined during execution or inherited from the shell's | |
4457 | parent in the environment | |
4458 | .IP \(bu | |
4459 | options enabled at invocation (either by default or with command-line | |
4460 | arguments) or by \fBset\fP | |
4461 | .IP \(bu | |
4462 | options enabled by \fBshopt\fP | |
4463 | .IP \(bu | |
4464 | shell aliases defined with \fBalias\fP | |
4465 | .IP \(bu | |
4466 | various process IDs, including those of background jobs, the value | |
984a1947 CR |
4467 | of \fB$$\fP, and the value of |
4468 | .SM | |
4469 | .B PPID | |
cce855bc JA |
4470 | .PP |
4471 | When a simple command other than a builtin or shell function | |
4472 | is to be executed, it | |
4473 | is invoked in a separate execution environment that consists of | |
4474 | the following. Unless otherwise noted, the values are inherited | |
4475 | from the shell. | |
984a1947 | 4476 | .if n .sp 1 |
cce855bc JA |
4477 | .IP \(bu |
4478 | the shell's open files, plus any modifications and additions specified | |
4479 | by redirections to the command | |
4480 | .IP \(bu | |
4481 | the current working directory | |
4482 | .IP \(bu | |
4483 | the file creation mode mask | |
4484 | .IP \(bu | |
d3a24ed2 CR |
4485 | shell variables and functions marked for export, along with variables |
4486 | exported for the command, passed in the environment | |
cce855bc | 4487 | .IP \(bu |
d3a24ed2 CR |
4488 | traps caught by the shell are reset to the values inherited from the |
4489 | shell's parent, and traps ignored by the shell are ignored | |
cce855bc JA |
4490 | .PP |
4491 | A command invoked in this separate environment cannot affect the | |
4492 | shell's execution environment. | |
4493 | .PP | |
d3a24ed2 CR |
4494 | Command substitution, commands grouped with parentheses, |
4495 | and asynchronous commands are invoked in a | |
cce855bc JA |
4496 | subshell environment that is a duplicate of the shell environment, |
4497 | except that traps caught by the shell are reset to the values | |
4498 | that the shell inherited from its parent at invocation. Builtin | |
4499 | commands that are invoked as part of a pipeline are also executed in a | |
4500 | subshell environment. Changes made to the subshell environment | |
4501 | cannot affect the shell's execution environment. | |
f73dda09 | 4502 | .PP |
012bac39 | 4503 | Subshells spawned to execute command substitutions inherit the value of |
dc60d4e0 CR |
4504 | the \fB\-e\fP option from the parent shell. When not in \fIposix\fP mode, |
4505 | \fBbash\fP clears the \fB\-e\fP option in such subshells. | |
012bac39 | 4506 | .PP |
f73dda09 JA |
4507 | If a command is followed by a \fB&\fP and job control is not active, the |
4508 | default standard input for the command is the empty file \fI/dev/null\fP. | |
4509 | Otherwise, the invoked command inherits the file descriptors of the calling | |
4510 | shell as modified by redirections. | |
cce855bc JA |
4511 | .SH ENVIRONMENT |
4512 | When a program is invoked it is given an array of strings | |
4513 | called the | |
4514 | .IR environment . | |
4515 | This is a list of | |
4516 | \fIname\fP\-\fIvalue\fP pairs, of the form | |
4517 | .IR "name\fR=\fPvalue" . | |
4518 | .PP | |
bb70624e JA |
4519 | The shell provides several ways to manipulate the environment. |
4520 | On invocation, the shell scans its own environment and | |
cce855bc JA |
4521 | creates a parameter for each name found, automatically marking |
4522 | it for | |
4523 | .I export | |
4524 | to child processes. Executed commands inherit the environment. | |
4525 | The | |
4526 | .B export | |
4527 | and | |
4528 | .B declare \-x | |
4529 | commands allow parameters and functions to be added to and | |
4530 | deleted from the environment. If the value of a parameter | |
4531 | in the environment is modified, the new value becomes part | |
4532 | of the environment, replacing the old. The environment | |
4533 | inherited by any executed command consists of the shell's | |
4534 | initial environment, whose values may be modified in the shell, | |
4535 | less any pairs removed by the | |
4536 | .B unset | |
4537 | command, plus any additions via the | |
4538 | .B export | |
4539 | and | |
4540 | .B declare \-x | |
4541 | commands. | |
4542 | .PP | |
4543 | The environment for any | |
4544 | .I simple command | |
4545 | or function may be augmented temporarily by prefixing it with | |
4546 | parameter assignments, as described above in | |
4547 | .SM | |
4548 | .BR PARAMETERS . | |
4549 | These assignment statements affect only the environment seen | |
4550 | by that command. | |
4551 | .PP | |
4552 | If the | |
4553 | .B \-k | |
4554 | option is set (see the | |
4555 | .B set | |
4556 | builtin command below), then | |
4557 | .I all | |
4558 | parameter assignments are placed in the environment for a command, | |
4559 | not just those that precede the command name. | |
4560 | .PP | |
4561 | When | |
4562 | .B bash | |
4563 | invokes an external command, the variable | |
4564 | .B _ | |
b28ff8c9 | 4565 | is set to the full filename of the command and passed to that |
ccc6cda3 JA |
4566 | command in its environment. |
4567 | .SH "EXIT STATUS" | |
35ee8ea0 CR |
4568 | .PP |
4569 | The exit status of an executed command is the value returned by the | |
4570 | \fIwaitpid\fP system call or equivalent function. Exit statuses | |
4571 | fall between 0 and 255, though, as explained below, the shell may | |
4572 | use values above 125 specially. Exit statuses from shell builtins and | |
4573 | compound commands are also limited to this range. Under certain | |
4574 | circumstances, the shell will use special values to indicate specific | |
4575 | failure modes. | |
4576 | .PP | |
cce855bc | 4577 | For the shell's purposes, a command which exits with a |
ccc6cda3 JA |
4578 | zero exit status has succeeded. An exit status of zero |
4579 | indicates success. A non-zero exit status indicates failure. | |
bb70624e JA |
4580 | When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses |
4581 | the value of 128+\fIN\fP as the exit status. | |
ccc6cda3 JA |
4582 | .PP |
4583 | If a command is not found, the child process created to | |
4584 | execute it returns a status of 127. If a command is found | |
4585 | but is not executable, the return status is 126. | |
4586 | .PP | |
cce855bc JA |
4587 | If a command fails because of an error during expansion or redirection, |
4588 | the exit status is greater than zero. | |
4589 | .PP | |
ccc6cda3 JA |
4590 | Shell builtin commands return a status of 0 (\fItrue\fP) if |
4591 | successful, and non-zero (\fIfalse\fP) if an error occurs | |
4592 | while they execute. | |
4593 | All builtins return an exit status of 2 to indicate incorrect usage. | |
4594 | .PP | |
4595 | \fBBash\fP itself returns the exit status of the last command | |
4596 | executed, unless a syntax error occurs, in which case it exits | |
4597 | with a non-zero value. See also the \fBexit\fP builtin | |
4598 | command below. | |
4599 | .SH SIGNALS | |
cce855bc | 4600 | When \fBbash\fP is interactive, in the absence of any traps, it ignores |
ccc6cda3 JA |
4601 | .SM |
4602 | .B SIGTERM | |
4603 | (so that \fBkill 0\fP does not kill an interactive shell), | |
4604 | and | |
4605 | .SM | |
4606 | .B SIGINT | |
4607 | is caught and handled (so that the \fBwait\fP builtin is interruptible). | |
4608 | In all cases, \fBbash\fP ignores | |
4609 | .SM | |
4610 | .BR SIGQUIT . | |
4611 | If job control is in effect, | |
4612 | .B bash | |
4613 | ignores | |
4614 | .SM | |
4615 | .BR SIGTTIN , | |
4616 | .SM | |
4617 | .BR SIGTTOU , | |
4618 | and | |
4619 | .SM | |
4620 | .BR SIGTSTP . | |
4621 | .PP | |
5e13499c | 4622 | Non-builtin commands run by \fBbash\fP have signal handlers |
cce855bc JA |
4623 | set to the values inherited by the shell from its parent. |
4624 | When job control is not in effect, asynchronous commands | |
ccc6cda3 JA |
4625 | ignore |
4626 | .SM | |
4627 | .B SIGINT | |
4628 | and | |
4629 | .SM | |
cce855bc | 4630 | .B SIGQUIT |
5e13499c | 4631 | in addition to these inherited handlers. |
ccc6cda3 JA |
4632 | Commands run as a result of command substitution ignore the |
4633 | keyboard-generated job control signals | |
4634 | .SM | |
4635 | .BR SIGTTIN , | |
4636 | .SM | |
4637 | .BR SIGTTOU , | |
4638 | and | |
4639 | .SM | |
4640 | .BR SIGTSTP . | |
4641 | .PP | |
4642 | The shell exits by default upon receipt of a | |
4643 | .SM | |
4644 | .BR SIGHUP . | |
f73dda09 | 4645 | Before exiting, an interactive shell resends the |
ccc6cda3 JA |
4646 | .SM |
4647 | .B SIGHUP | |
cce855bc JA |
4648 | to all jobs, running or stopped. |
4649 | Stopped jobs are sent | |
4650 | .SM | |
4651 | .B SIGCONT | |
4652 | to ensure that they receive the | |
4653 | .SM | |
4654 | .BR SIGHUP . | |
4655 | To prevent the shell from | |
4656 | sending the signal to a particular job, it should be removed from the | |
ccc6cda3 JA |
4657 | jobs table with the |
4658 | .B disown | |
4659 | builtin (see | |
4660 | .SM | |
4661 | .B "SHELL BUILTIN COMMANDS" | |
cce855bc JA |
4662 | below) or marked |
4663 | to not receive | |
ccc6cda3 | 4664 | .SM |
cce855bc JA |
4665 | .B SIGHUP |
4666 | using | |
4667 | .BR "disown \-h" . | |
4668 | .PP | |
4669 | If the | |
4670 | .B huponexit | |
4671 | shell option has been set with | |
4672 | .BR shopt , | |
4673 | .B bash | |
4674 | sends a | |
4675 | .SM | |
4676 | .B SIGHUP | |
4677 | to all jobs when an interactive login shell exits. | |
4678 | .PP | |
b66cc816 | 4679 | If \fBbash\fP is waiting for a command to complete and receives a signal |
5e13499c CR |
4680 | for which a trap has been set, the trap will not be executed until |
4681 | the command completes. | |
cce855bc JA |
4682 | When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP |
4683 | builtin, the reception of a signal for which a trap has been set will | |
4684 | cause the \fBwait\fP builtin to return immediately with an exit status | |
4685 | greater than 128, immediately after which the trap is executed. | |
ccc6cda3 JA |
4686 | .SH "JOB CONTROL" |
4687 | .I Job control | |
4688 | refers to the ability to selectively stop (\fIsuspend\fP) | |
4689 | the execution of processes and continue (\fIresume\fP) | |
4690 | their execution at a later point. A user typically employs | |
4691 | this facility via an interactive interface supplied jointly | |
602bb739 | 4692 | by the operating system kernel's terminal driver and |
ccc6cda3 JA |
4693 | .BR bash . |
4694 | .PP | |
4695 | The shell associates a | |
4696 | .I job | |
4697 | with each pipeline. It keeps a table of currently executing | |
4698 | jobs, which may be listed with the | |
4699 | .B jobs | |
4700 | command. When | |
4701 | .B bash | |
4702 | starts a job asynchronously (in the | |
4703 | .IR background ), | |
4704 | it prints a line that looks like: | |
4705 | .RS | |
4706 | .PP | |
4707 | [1] 25647 | |
4708 | .RE | |
4709 | .PP | |
4710 | indicating that this job is job number 1 and that the process ID | |
4711 | of the last process in the pipeline associated with this job is 25647. | |
4712 | All of the processes in a single pipeline are members of the same job. | |
4713 | .B Bash | |
4714 | uses the | |
4715 | .I job | |
4716 | abstraction as the basis for job control. | |
4717 | .PP | |
4718 | To facilitate the implementation of the user interface to job | |
bb70624e | 4719 | control, the operating system maintains the notion of a \fIcurrent terminal |
ccc6cda3 JA |
4720 | process group ID\fP. Members of this process group (processes whose |
4721 | process group ID is equal to the current terminal process group ID) | |
4722 | receive keyboard-generated signals such as | |
4723 | .SM | |
4724 | .BR SIGINT . | |
4725 | These processes are said to be in the | |
4726 | .IR foreground . | |
4727 | .I Background | |
4728 | processes are those whose process group ID differs from the terminal's; | |
4729 | such processes are immune to keyboard-generated signals. | |
602bb739 CR |
4730 | Only foreground processes are allowed to read from or, if the |
4731 | user so specifies with \f(CWstty tostop\fP, write to the | |
4732 | terminal. | |
4733 | Background processes which attempt to read from (write to when | |
4734 | \f(CWstty tostop\fP is in effect) the | |
ccc6cda3 JA |
4735 | terminal are sent a |
4736 | .SM | |
4737 | .B SIGTTIN (SIGTTOU) | |
602bb739 | 4738 | signal by the kernel's terminal driver, |
ccc6cda3 JA |
4739 | which, unless caught, suspends the process. |
4740 | .PP | |
4741 | If the operating system on which | |
4742 | .B bash | |
4743 | is running supports | |
4744 | job control, | |
4745 | .B bash | |
bb70624e | 4746 | contains facilities to use it. |
ccc6cda3 JA |
4747 | Typing the |
4748 | .I suspend | |
4749 | character (typically | |
4750 | .BR ^Z , | |
4751 | Control-Z) while a process is running | |
bb70624e | 4752 | causes that process to be stopped and returns control to |
ccc6cda3 JA |
4753 | .BR bash . |
4754 | Typing the | |
4755 | .I "delayed suspend" | |
4756 | character (typically | |
4757 | .BR ^Y , | |
4758 | Control-Y) causes the process to be stopped when it | |
4759 | attempts to read input from the terminal, and control to | |
4760 | be returned to | |
4761 | .BR bash . | |
cce855bc | 4762 | The user may then manipulate the state of this job, using the |
ccc6cda3 JA |
4763 | .B bg |
4764 | command to continue it in the background, the | |
4765 | .B fg | |
4766 | command to continue it in the foreground, or | |
4767 | the | |
4768 | .B kill | |
4769 | command to kill it. A \fB^Z\fP takes effect immediately, | |
4770 | and has the additional side effect of causing pending output | |
4771 | and typeahead to be discarded. | |
4772 | .PP | |
4773 | There are a number of ways to refer to a job in the shell. | |
4774 | The character | |
4775 | .B % | |
8e1a6eaa | 4776 | introduces a job specification (\fIjobspec\fP). Job number |
ccc6cda3 JA |
4777 | .I n |
4778 | may be referred to as | |
4779 | .BR %n . | |
4780 | A job may also be referred to using a prefix of the name used to | |
4781 | start it, or using a substring that appears in its command line. | |
4782 | For example, | |
4783 | .B %ce | |
4784 | refers to a stopped | |
4785 | .B ce | |
4786 | job. If a prefix matches more than one job, | |
4787 | .B bash | |
4788 | reports an error. Using | |
4789 | .BR %?ce , | |
4790 | on the other hand, refers to any job containing the string | |
4791 | .B ce | |
4792 | in its command line. If the substring matches more than one job, | |
4793 | .B bash | |
4794 | reports an error. The symbols | |
4795 | .B %% | |
4796 | and | |
4797 | .B %+ | |
4798 | refer to the shell's notion of the | |
4799 | .IR "current job" , | |
4800 | which is the last job stopped while it was in | |
cce855bc | 4801 | the foreground or started in the background. |
ccc6cda3 JA |
4802 | The |
4803 | .I "previous job" | |
4804 | may be referenced using | |
4805 | .BR %\- . | |
e33f2203 CR |
4806 | If there is only a single job, \fB%+\fP and \fB%\-\fP can both be used |
4807 | to refer to that job. | |
ccc6cda3 JA |
4808 | In output pertaining to jobs (e.g., the output of the |
4809 | .B jobs | |
4810 | command), the current job is always flagged with a | |
4811 | .BR + , | |
4812 | and the previous job with a | |
4813 | .BR \- . | |
43df7bbb CR |
4814 | A single % (with no accompanying job specification) also refers to the |
4815 | current job. | |
726f6388 | 4816 | .PP |
ccc6cda3 JA |
4817 | Simply naming a job can be used to bring it into the |
4818 | foreground: | |
4819 | .B %1 | |
4820 | is a synonym for | |
4821 | \fB``fg %1''\fP, | |
4822 | bringing job 1 from the background into the foreground. | |
4823 | Similarly, | |
4824 | .B ``%1 &'' | |
4825 | resumes job 1 in the background, equivalent to | |
4826 | \fB``bg %1''\fP. | |
726f6388 | 4827 | .PP |
ccc6cda3 JA |
4828 | The shell learns immediately whenever a job changes state. |
4829 | Normally, | |
4830 | .B bash | |
4831 | waits until it is about to print a prompt before reporting | |
4832 | changes in a job's status so as to not interrupt | |
4833 | any other output. If the | |
4834 | .B \-b | |
4835 | option to the | |
726f6388 | 4836 | .B set |
ccc6cda3 | 4837 | builtin command |
cce855bc | 4838 | is enabled, |
726f6388 | 4839 | .B bash |
ccc6cda3 | 4840 | reports such changes immediately. |
f73dda09 JA |
4841 | Any trap on |
4842 | .SM | |
4843 | .B SIGCHLD | |
4844 | is executed for each child that exits. | |
726f6388 | 4845 | .PP |
ccc6cda3 JA |
4846 | If an attempt to exit |
4847 | .B bash | |
d3ad40de CR |
4848 | is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has |
4849 | been enabled using the \fBshopt\fP builtin, running), the shell prints a | |
4850 | warning message, and, if the \fBcheckjobs\fP option is enabled, lists the | |
4851 | jobs and their statuses. | |
4852 | The | |
ccc6cda3 | 4853 | .B jobs |
d3ad40de | 4854 | command may then be used to inspect their status. |
ccc6cda3 | 4855 | If a second attempt to exit is made without an intervening command, |
d3ad40de | 4856 | the shell does not print another warning, and any stopped |
ccc6cda3 | 4857 | jobs are terminated. |
726f6388 JA |
4858 | .SH PROMPTING |
4859 | When executing interactively, | |
4860 | .B bash | |
4861 | displays the primary prompt | |
4862 | .SM | |
4863 | .B PS1 | |
4864 | when it is ready to read a command, and the secondary prompt | |
4865 | .SM | |
4866 | .B PS2 | |
4867 | when it needs more input to complete a command. | |
4868 | .B Bash | |
4869 | allows these prompt strings to be customized by inserting a number of | |
4870 | backslash-escaped special characters that are decoded as follows: | |
4871 | .RS | |
4872 | .PD 0 | |
4873 | .TP | |
ccc6cda3 JA |
4874 | .B \ea |
4875 | an ASCII bell character (07) | |
726f6388 JA |
4876 | .TP |
4877 | .B \ed | |
4878 | the date in "Weekday Month Date" format (e.g., "Tue May 26") | |
4879 | .TP | |
7117c2d2 JA |
4880 | .B \eD{\fIformat\fP} |
4881 | the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted | |
4882 | into the prompt string; an empty \fIformat\fP results in a locale-specific | |
4883 | time representation. The braces are required | |
4884 | .TP | |
ccc6cda3 JA |
4885 | .B \ee |
4886 | an ASCII escape character (033) | |
4887 | .TP | |
4888 | .B \eh | |
4889 | the hostname up to the first `.' | |
4890 | .TP | |
4891 | .B \eH | |
4892 | the hostname | |
4893 | .TP | |
bb70624e JA |
4894 | .B \ej |
4895 | the number of jobs currently managed by the shell | |
4896 | .TP | |
4897 | .B \el | |
4898 | the basename of the shell's terminal device name | |
4899 | .TP | |
726f6388 JA |
4900 | .B \en |
4901 | newline | |
4902 | .TP | |
cce855bc JA |
4903 | .B \er |
4904 | carriage return | |
4905 | .TP | |
726f6388 JA |
4906 | .B \es |
4907 | the name of the shell, the basename of | |
4908 | .B $0 | |
4909 | (the portion following the final slash) | |
4910 | .TP | |
ccc6cda3 JA |
4911 | .B \et |
4912 | the current time in 24-hour HH:MM:SS format | |
726f6388 | 4913 | .TP |
ccc6cda3 JA |
4914 | .B \eT |
4915 | the current time in 12-hour HH:MM:SS format | |
4916 | .TP | |
4917 | .B \e@ | |
4918 | the current time in 12-hour am/pm format | |
726f6388 | 4919 | .TP |
f73dda09 JA |
4920 | .B \eA |
4921 | the current time in 24-hour HH:MM format | |
4922 | .TP | |
726f6388 JA |
4923 | .B \eu |
4924 | the username of the current user | |
4925 | .TP | |
ccc6cda3 JA |
4926 | .B \ev |
4927 | the version of \fBbash\fP (e.g., 2.00) | |
726f6388 | 4928 | .TP |
ccc6cda3 | 4929 | .B \eV |
a5e25162 | 4930 | the release of \fBbash\fP, version + patch level (e.g., 2.00.0) |
ccc6cda3 JA |
4931 | .TP |
4932 | .B \ew | |
984a1947 CR |
4933 | the current working directory, with |
4934 | .SM | |
4935 | .B $HOME | |
4936 | abbreviated with a tilde | |
4937 | (uses the value of the | |
4938 | .SM | |
4939 | .B PROMPT_DIRTRIM | |
4940 | variable) | |
ccc6cda3 JA |
4941 | .TP |
4942 | .B \eW | |
984a1947 CR |
4943 | the basename of the current working directory, with |
4944 | .SM | |
4945 | .B $HOME | |
12d937f9 | 4946 | abbreviated with a tilde |
726f6388 JA |
4947 | .TP |
4948 | .B \e! | |
4949 | the history number of this command | |
4950 | .TP | |
ccc6cda3 JA |
4951 | .B \e# |
4952 | the command number of this command | |
4953 | .TP | |
726f6388 JA |
4954 | .B \e$ |
4955 | if the effective UID is 0, a | |
4956 | .BR # , | |
4957 | otherwise a | |
4958 | .B $ | |
4959 | .TP | |
ccc6cda3 JA |
4960 | .B \e\fInnn\fP |
4961 | the character corresponding to the octal number \fInnn\fP | |
726f6388 JA |
4962 | .TP |
4963 | .B \e\e | |
4964 | a backslash | |
4965 | .TP | |
4966 | .B \e[ | |
4967 | begin a sequence of non-printing characters, which could be used to | |
4968 | embed a terminal control sequence into the prompt | |
4969 | .TP | |
4970 | .B \e] | |
4971 | end a sequence of non-printing characters | |
4972 | .PD | |
4973 | .RE | |
4974 | .PP | |
4975 | The command number and the history number are usually different: | |
4976 | the history number of a command is its position in the history | |
4977 | list, which may include commands restored from the history file | |
4978 | (see | |
4979 | .SM | |
4980 | .B HISTORY | |
4981 | below), while the command number is the position in the sequence | |
4982 | of commands executed during the current shell session. | |
4983 | After the string is decoded, it is expanded via | |
bb70624e JA |
4984 | parameter expansion, command substitution, arithmetic |
4985 | expansion, and quote removal, subject to the value of the | |
ccc6cda3 JA |
4986 | .B promptvars |
4987 | shell option (see the description of the | |
4988 | .B shopt | |
4989 | command under | |
4990 | .SM | |
4991 | .B "SHELL BUILTIN COMMANDS" | |
4992 | below). | |
726f6388 JA |
4993 | .SH READLINE |
4994 | This is the library that handles reading input when using an interactive | |
4995 | shell, unless the | |
d166f048 | 4996 | .B \-\-noediting |
ccc6cda3 | 4997 | option is given at shell invocation. |
14e8b2a7 CR |
4998 | Line editing is also used when using the \fB\-e\fP option to the |
4999 | \fBread\fP builtin. | |
dc60d4e0 | 5000 | By default, the line editing commands are similar to those of Emacs. |
726f6388 | 5001 | A vi-style line editing interface is also available. |
14e8b2a7 CR |
5002 | Line editing can be enabled at any time using the |
5003 | .B \-o emacs | |
ccc6cda3 | 5004 | or |
14e8b2a7 | 5005 | .B \-o vi |
ccc6cda3 JA |
5006 | options to the |
5007 | .B set | |
5008 | builtin (see | |
5009 | .SM | |
5010 | .B SHELL BUILTIN COMMANDS | |
5011 | below). | |
14e8b2a7 CR |
5012 | To turn off line editing after the shell is running, use the |
5013 | .B +o emacs | |
5014 | or | |
5015 | .B +o vi | |
5016 | options to the | |
5017 | .B set | |
5018 | builtin. | |
ccc6cda3 | 5019 | .SS "Readline Notation" |
726f6388 | 5020 | .PP |
dc60d4e0 | 5021 | In this section, the Emacs-style notation is used to denote |
726f6388 JA |
5022 | keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n |
5023 | means Control\-N. Similarly, | |
5024 | .I meta | |
5025 | keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards | |
5026 | without a | |
5027 | .I meta | |
5028 | key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key | |
5029 | then the | |
5030 | .I x | |
5031 | key. This makes ESC the \fImeta prefix\fP. | |
5032 | The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP, | |
5033 | or press the Escape key | |
5034 | then hold the Control key while pressing the | |
5035 | .I x | |
5036 | key.) | |
5037 | .PP | |
ccc6cda3 JA |
5038 | Readline commands may be given numeric |
5039 | .IR arguments , | |
5040 | which normally act as a repeat count. | |
5041 | Sometimes, however, it is the sign of the argument that is significant. | |
5042 | Passing a negative argument to a command that acts in the forward | |
5043 | direction (e.g., \fBkill\-line\fP) causes that command to act in a | |
5044 | backward direction. | |
5045 | Commands whose behavior with arguments deviates from this are noted | |
5046 | below. | |
5047 | .PP | |
5048 | When a command is described as \fIkilling\fP text, the text | |
5049 | deleted is saved for possible future retrieval | |
5050 | (\fIyanking\fP). The killed text is saved in a | |
5051 | \fIkill ring\fP. Consecutive kills cause the text to be | |
5052 | accumulated into one unit, which can be yanked all at once. | |
5053 | Commands which do not kill text separate the chunks of text | |
5054 | on the kill ring. | |
5055 | .SS "Readline Initialization" | |
5056 | .PP | |
5057 | Readline is customized by putting commands in an initialization | |
5058 | file (the \fIinputrc\fP file). | |
5059 | The name of this file is taken from the value of the | |
726f6388 | 5060 | .SM |
ccc6cda3 JA |
5061 | .B INPUTRC |
5062 | variable. If that variable is unset, the default is | |
726f6388 | 5063 | .IR ~/.inputrc . |
ccc6cda3 JA |
5064 | When a program which uses the readline library starts up, the |
5065 | initialization file is read, and the key bindings and variables | |
5066 | are set. | |
5067 | There are only a few basic constructs allowed in the | |
5068 | readline initialization file. | |
5069 | Blank lines are ignored. | |
5070 | Lines beginning with a \fB#\fP are comments. | |
5071 | Lines beginning with a \fB$\fP indicate conditional constructs. | |
5072 | Other lines denote key bindings and variable settings. | |
5073 | .PP | |
5074 | The default key-bindings may be changed with an | |
5075 | .I inputrc | |
5076 | file. | |
726f6388 JA |
5077 | Other programs that use this library may add their own commands |
5078 | and bindings. | |
5079 | .PP | |
5080 | For example, placing | |
5081 | .RS | |
5082 | .PP | |
5083 | M\-Control\-u: universal\-argument | |
5084 | .RE | |
5085 | or | |
5086 | .RS | |
5087 | C\-Meta\-u: universal\-argument | |
5088 | .RE | |
5089 | into the | |
ccc6cda3 | 5090 | .I inputrc |
726f6388 JA |
5091 | would make M\-C\-u execute the readline command |
5092 | .IR universal\-argument . | |
5093 | .PP | |
5094 | The following symbolic character names are recognized: | |
5095 | .IR RUBOUT , | |
5096 | .IR DEL , | |
5097 | .IR ESC , | |
5098 | .IR LFD , | |
5099 | .IR NEWLINE , | |
5100 | .IR RET , | |
5101 | .IR RETURN , | |
5102 | .IR SPC , | |
5103 | .IR SPACE , | |
5104 | and | |
5105 | .IR TAB . | |
bb70624e | 5106 | .PP |
726f6388 JA |
5107 | In addition to command names, readline allows keys to be bound |
5108 | to a string that is inserted when the key is pressed (a \fImacro\fP). | |
ccc6cda3 | 5109 | .SS "Readline Key Bindings" |
726f6388 JA |
5110 | .PP |
5111 | The syntax for controlling key bindings in the | |
cce855bc | 5112 | .I inputrc |
726f6388 JA |
5113 | file is simple. All that is required is the name of the |
5114 | command or the text of a macro and a key sequence to which | |
5115 | it should be bound. The name may be specified in one of two ways: | |
ccc6cda3 | 5116 | as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP |
726f6388 | 5117 | prefixes, or as a key sequence. |
28ef6c31 | 5118 | .PP |
cce855bc | 5119 | When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP, |
726f6388 JA |
5120 | .I keyname |
5121 | is the name of a key spelled out in English. For example: | |
5122 | .sp | |
5123 | .RS | |
5124 | Control-u: universal\-argument | |
5125 | .br | |
5126 | Meta-Rubout: backward-kill-word | |
5127 | .br | |
ccc6cda3 | 5128 | Control-o: "> output" |
726f6388 JA |
5129 | .RE |
5130 | .LP | |
5131 | In the above example, | |
ccc6cda3 | 5132 | .I C\-u |
726f6388 JA |
5133 | is bound to the function |
5134 | .BR universal\-argument , | |
ccc6cda3 | 5135 | .I M\-DEL |
726f6388 JA |
5136 | is bound to the function |
5137 | .BR backward\-kill\-word , | |
5138 | and | |
ccc6cda3 | 5139 | .I C\-o |
726f6388 JA |
5140 | is bound to run the macro |
5141 | expressed on the right hand side (that is, to insert the text | |
28ef6c31 JA |
5142 | .if t \f(CW> output\fP |
5143 | .if n ``> output'' | |
726f6388 JA |
5144 | into the line). |
5145 | .PP | |
cce855bc | 5146 | In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP, |
726f6388 JA |
5147 | .B keyseq |
5148 | differs from | |
5149 | .B keyname | |
5150 | above in that strings denoting | |
5151 | an entire key sequence may be specified by placing the sequence | |
5152 | within double quotes. Some GNU Emacs style key escapes can be | |
28ef6c31 JA |
5153 | used, as in the following example, but the symbolic character names |
5154 | are not recognized. | |
726f6388 JA |
5155 | .sp |
5156 | .RS | |
ccc6cda3 | 5157 | "\eC\-u": universal\-argument |
726f6388 | 5158 | .br |
ccc6cda3 | 5159 | "\eC\-x\eC\-r": re\-read\-init\-file |
726f6388 JA |
5160 | .br |
5161 | "\ee[11~": "Function Key 1" | |
5162 | .RE | |
5163 | .PP | |
5164 | In this example, | |
ccc6cda3 | 5165 | .I C\-u |
726f6388 JA |
5166 | is again bound to the function |
5167 | .BR universal\-argument . | |
ccc6cda3 | 5168 | .I "C\-x C\-r" |
726f6388 JA |
5169 | is bound to the function |
5170 | .BR re\-read\-init\-file , | |
5171 | and | |
5172 | .I "ESC [ 1 1 ~" | |
5173 | is bound to insert the text | |
28ef6c31 JA |
5174 | .if t \f(CWFunction Key 1\fP. |
5175 | .if n ``Function Key 1''. | |
5176 | .PP | |
cce855bc | 5177 | The full set of GNU Emacs style escape sequences is |
726f6388 | 5178 | .RS |
cce855bc | 5179 | .PD 0 |
726f6388 JA |
5180 | .TP |
5181 | .B \eC\- | |
5182 | control prefix | |
5183 | .TP | |
ccc6cda3 | 5184 | .B \eM\- |
726f6388 JA |
5185 | meta prefix |
5186 | .TP | |
5187 | .B \ee | |
5188 | an escape character | |
5189 | .TP | |
5190 | .B \e\e | |
5191 | backslash | |
5192 | .TP | |
5193 | .B \e" | |
5194 | literal " | |
5195 | .TP | |
20587658 CR |
5196 | .B \e\(aq |
5197 | literal \(aq | |
726f6388 | 5198 | .RE |
cce855bc JA |
5199 | .PD |
5200 | .PP | |
5201 | In addition to the GNU Emacs style escape sequences, a second | |
5202 | set of backslash escapes is available: | |
5203 | .RS | |
5204 | .PD 0 | |
5205 | .TP | |
5206 | .B \ea | |
5207 | alert (bell) | |
5208 | .TP | |
5209 | .B \eb | |
5210 | backspace | |
5211 | .TP | |
5212 | .B \ed | |
5213 | delete | |
5214 | .TP | |
5215 | .B \ef | |
5216 | form feed | |
5217 | .TP | |
5218 | .B \en | |
5219 | newline | |
5220 | .TP | |
5221 | .B \er | |
5222 | carriage return | |
5223 | .TP | |
5224 | .B \et | |
5225 | horizontal tab | |
5226 | .TP | |
5227 | .B \ev | |
5228 | vertical tab | |
5229 | .TP | |
5230 | .B \e\fInnn\fP | |
f73dda09 | 5231 | the eight-bit character whose value is the octal value \fInnn\fP |
cce855bc JA |
5232 | (one to three digits) |
5233 | .TP | |
f73dda09 JA |
5234 | .B \ex\fIHH\fP |
5235 | the eight-bit character whose value is the hexadecimal value \fIHH\fP | |
5236 | (one or two hex digits) | |
cce855bc JA |
5237 | .RE |
5238 | .PD | |
726f6388 | 5239 | .PP |
cce855bc JA |
5240 | When entering the text of a macro, single or double quotes must |
5241 | be used to indicate a macro definition. | |
5242 | Unquoted text is assumed to be a function name. | |
5243 | In the macro body, the backslash escapes described above are expanded. | |
5244 | Backslash will quote any other character in the macro text, | |
20587658 | 5245 | including " and \(aq. |
726f6388 JA |
5246 | .PP |
5247 | .B Bash | |
5248 | allows the current readline key bindings to be displayed or modified | |
5249 | with the | |
5250 | .B bind | |
5251 | builtin command. The editing mode may be switched during interactive | |
5252 | use by using the | |
5253 | .B \-o | |
5254 | option to the | |
5255 | .B set | |
5256 | builtin command (see | |
5257 | .SM | |
5258 | .B SHELL BUILTIN COMMANDS | |
5259 | below). | |
ccc6cda3 | 5260 | .SS "Readline Variables" |
726f6388 JA |
5261 | .PP |
5262 | Readline has variables that can be used to further customize its | |
5263 | behavior. A variable may be set in the | |
5264 | .I inputrc | |
5265 | file with a statement of the form | |
5266 | .RS | |
5267 | .PP | |
5268 | \fBset\fP \fIvariable\-name\fP \fIvalue\fP | |
5269 | .RE | |
5270 | .PP | |
5271 | Except where noted, readline variables can take the values | |
5272 | .B On | |
5273 | or | |
ff247e74 CR |
5274 | .B Off |
5275 | (without regard to case). | |
5276 | Unrecognized variable names are ignored. | |
5277 | When a variable value is read, empty or null values, "on" (case-insensitive), | |
5278 | and "1" are equivalent to \fBOn\fP. All other values are equivalent to | |
5279 | \fBOff\fP. | |
726f6388 JA |
5280 | The variables and their default values are: |
5281 | .PP | |
5282 | .PD 0 | |
5283 | .TP | |
726f6388 JA |
5284 | .B bell\-style (audible) |
5285 | Controls what happens when readline wants to ring the terminal bell. | |
5286 | If set to \fBnone\fP, readline never rings the bell. If set to | |
5287 | \fBvisible\fP, readline uses a visible bell if one is available. | |
5288 | If set to \fBaudible\fP, readline attempts to ring the terminal's bell. | |
5289 | .TP | |
453f278a CR |
5290 | .B bind\-tty\-special\-chars (On) |
5291 | If set to \fBOn\fP, readline attempts to bind the control characters | |
5292 | treated specially by the kernel's terminal driver to their readline | |
5293 | equivalents. | |
5294 | .TP | |
5a318736 CR |
5295 | .B colored\-stats (Off) |
5296 | If set to \fBOn\fP, readline displays possible completions using different | |
5297 | colors to indicate their file type. | |
5298 | The color definitions are taken from the value of the \fBLS_COLORS\fP | |
5299 | environment variable. | |
5300 | .TP | |
726f6388 | 5301 | .B comment\-begin (``#'') |
bb70624e | 5302 | The string that is inserted when the readline |
ccc6cda3 | 5303 | .B insert\-comment |
726f6388 | 5304 | command is executed. |
ccc6cda3 JA |
5305 | This command is bound to |
5306 | .B M\-# | |
5307 | in emacs mode and to | |
5308 | .B # | |
5309 | in vi command mode. | |
726f6388 | 5310 | .TP |
cce855bc JA |
5311 | .B completion\-ignore\-case (Off) |
5312 | If set to \fBOn\fP, readline performs filename matching and completion | |
5313 | in a case\-insensitive fashion. | |
5314 | .TP | |
f13513ff CR |
5315 | .B completion\-prefix\-display\-length (0) |
5316 | The length in characters of the common prefix of a list of possible | |
5317 | completions that is displayed without modification. When set to a | |
5318 | value greater than zero, common prefixes longer than this value are | |
5319 | replaced with an ellipsis when displaying possible completions. | |
5320 | .TP | |
726f6388 JA |
5321 | .B completion\-query\-items (100) |
5322 | This determines when the user is queried about viewing | |
5323 | the number of possible completions | |
5324 | generated by the \fBpossible\-completions\fP command. | |
5325 | It may be set to any integer value greater than or equal to | |
5326 | zero. If the number of possible completions is greater than | |
5327 | or equal to the value of this variable, the user is asked whether | |
5328 | or not he wishes to view them; otherwise they are simply listed | |
5329 | on the terminal. | |
5330 | .TP | |
ccc6cda3 JA |
5331 | .B convert\-meta (On) |
5332 | If set to \fBOn\fP, readline will convert characters with the | |
5333 | eighth bit set to an ASCII key sequence | |
bb70624e | 5334 | by stripping the eighth bit and prefixing an |
ccc6cda3 JA |
5335 | escape character (in effect, using escape as the \fImeta prefix\fP). |
5336 | .TP | |
5337 | .B disable\-completion (Off) | |
5338 | If set to \fBOn\fP, readline will inhibit word completion. Completion | |
5339 | characters will be inserted into the line as if they had been | |
5340 | mapped to \fBself-insert\fP. | |
5341 | .TP | |
5342 | .B editing\-mode (emacs) | |
5343 | Controls whether readline begins with a set of key bindings similar | |
dc60d4e0 | 5344 | to \fIEmacs\fP or \fIvi\fP. |
ccc6cda3 JA |
5345 | .B editing\-mode |
5346 | can be set to either | |
5347 | .B emacs | |
5348 | or | |
5349 | .BR vi . | |
5350 | .TP | |
824dfe68 CR |
5351 | .B echo\-control\-characters (On) |
5352 | When set to \fBOn\fP, on operating systems that indicate they support it, | |
5353 | readline echoes a character corresponding to a signal generated from the | |
5354 | keyboard. | |
5355 | .TP | |
ccc6cda3 JA |
5356 | .B enable\-keypad (Off) |
5357 | When set to \fBOn\fP, readline will try to enable the application | |
5358 | keypad when it is called. Some systems need this to enable the | |
5359 | arrow keys. | |
5360 | .TP | |
08e72d7a CR |
5361 | .B enable\-meta\-key (On) |
5362 | When set to \fBOn\fP, readline will try to enable any meta modifier | |
5363 | key the terminal claims to support when it is called. On many terminals, | |
5364 | the meta key is used to send eight-bit characters. | |
5365 | .TP | |
ccc6cda3 | 5366 | .B expand\-tilde (Off) |
dc60d4e0 | 5367 | If set to \fBOn\fP, tilde expansion is performed when readline |
ccc6cda3 JA |
5368 | attempts word completion. |
5369 | .TP | |
cdb32d45 | 5370 | .B history\-preserve\-point (Off) |
dc60d4e0 | 5371 | If set to \fBOn\fP, the history code attempts to place point at the |
f75912ae | 5372 | same location on each history line retrieved with \fBprevious-history\fP |
f73dda09 JA |
5373 | or \fBnext-history\fP. |
5374 | .TP | |
1d0e1a34 | 5375 | .B history\-size (0) |
0500de0b CR |
5376 | Set the maximum number of history entries saved in the history list. |
5377 | If set to zero, any existing history entries are deleted and no new entries | |
5378 | are saved. | |
5379 | If set to a value less than zero, the number of history entries is not | |
5380 | limited. | |
5381 | By default, the number of history entries is not limited. | |
1d0e1a34 | 5382 | .TP |
ccc6cda3 JA |
5383 | .B horizontal\-scroll\-mode (Off) |
5384 | When set to \fBOn\fP, makes readline use a single line for display, | |
5385 | scrolling the input horizontally on a single screen line when it | |
5386 | becomes longer than the screen width rather than wrapping to a new line. | |
5387 | .TP | |
5388 | .B input\-meta (Off) | |
5389 | If set to \fBOn\fP, readline will enable eight-bit input (that is, | |
5390 | it will not strip the high bit from the characters it reads), | |
5391 | regardless of what the terminal claims it can support. The name | |
5392 | .B meta\-flag | |
5393 | is a synonym for this variable. | |
5394 | .TP | |
b72432fd JA |
5395 | .B isearch\-terminators (``C\-[C\-J'') |
5396 | The string of characters that should terminate an incremental | |
5397 | search without subsequently executing the character as a command. | |
5398 | If this variable has not been given a value, the characters | |
5399 | \fIESC\fP and \fIC\-J\fP will terminate an incremental search. | |
5400 | .TP | |
726f6388 | 5401 | .B keymap (emacs) |
cce855bc | 5402 | Set the current readline keymap. The set of valid keymap names is |
ccc6cda3 JA |
5403 | \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, |
5404 | vi\-command\fP, and | |
5405 | .IR vi\-insert . | |
5406 | \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is | |
5407 | equivalent to \fIemacs\-standard\fP. The default value is | |
726f6388 JA |
5408 | .IR emacs ; |
5409 | the value of | |
5410 | .B editing\-mode | |
5411 | also affects the default keymap. | |
5412 | .TP | |
abe2eb5b CR |
5413 | .B keyseq\-timeout (500) |
5414 | Specifies the duration \fIreadline\fP will wait for a character when reading an | |
5415 | ambiguous key sequence (one that can form a complete key sequence using | |
5416 | the input read so far, or can take additional input to complete a longer | |
5417 | key sequence). | |
5418 | If no input is received within the timeout, \fIreadline\fP will use the shorter | |
5419 | but complete key sequence. | |
5420 | The value is specified in milliseconds, so a value of 1000 means that | |
5421 | \fIreadline\fP will wait one second for additional input. | |
5422 | If this variable is set to a value less than or equal to zero, or to a | |
5423 | non-numeric value, \fIreadline\fP will wait until another key is pressed to | |
5424 | decide which key sequence to complete. | |
5425 | .TP | |
ccc6cda3 JA |
5426 | .B mark\-directories (On) |
5427 | If set to \fBOn\fP, completed directory names have a slash | |
5428 | appended. | |
5429 | .TP | |
5430 | .B mark\-modified\-lines (Off) | |
5431 | If set to \fBOn\fP, history lines that have been modified are displayed | |
5432 | with a preceding asterisk (\fB*\fP). | |
5433 | .TP | |
7117c2d2 JA |
5434 | .B mark\-symlinked\-directories (Off) |
5435 | If set to \fBOn\fP, completed names which are symbolic links to directories | |
5436 | have a slash appended (subject to the value of | |
5437 | \fBmark\-directories\fP). | |
5438 | .TP | |
f73dda09 JA |
5439 | .B match\-hidden\-files (On) |
5440 | This variable, when set to \fBOn\fP, causes readline to match files whose | |
5441 | names begin with a `.' (hidden files) when performing filename | |
112ff2a6 CR |
5442 | completion. |
5443 | If set to \fBOff\fP, the leading `.' must be | |
f73dda09 JA |
5444 | supplied by the user in the filename to be completed. |
5445 | .TP | |
d7c725b5 CR |
5446 | .B menu\-complete\-display\-prefix (Off) |
5447 | If set to \fBOn\fP, menu completion displays the common prefix of the | |
5448 | list of possible completions (which may be empty) before cycling through | |
5449 | the list. | |
5450 | .TP | |
ccc6cda3 JA |
5451 | .B output\-meta (Off) |
5452 | If set to \fBOn\fP, readline will display characters with the | |
5453 | eighth bit set directly rather than as a meta-prefixed escape | |
5454 | sequence. | |
5455 | .TP | |
7117c2d2 JA |
5456 | .B page\-completions (On) |
5457 | If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager | |
5458 | to display a screenful of possible completions at a time. | |
5459 | .TP | |
cce855bc JA |
5460 | .B print\-completions\-horizontally (Off) |
5461 | If set to \fBOn\fP, readline will display completions with matches | |
5462 | sorted horizontally in alphabetical order, rather than down the screen. | |
f13513ff CR |
5463 | .TP |
5464 | .B revert\-all\-at\-newline (Off) | |
dc60d4e0 | 5465 | If set to \fBOn\fP, readline will undo all changes to history lines |
f13513ff CR |
5466 | before returning when \fBaccept\-line\fP is executed. By default, |
5467 | history lines may be modified and retain individual undo lists across | |
5468 | calls to \fBreadline\fP. | |
cce855bc | 5469 | .TP |
726f6388 JA |
5470 | .B show\-all\-if\-ambiguous (Off) |
5471 | This alters the default behavior of the completion functions. If | |
5472 | set to | |
dc60d4e0 | 5473 | .BR On , |
726f6388 JA |
5474 | words which have more than one possible completion cause the |
5475 | matches to be listed immediately instead of ringing the bell. | |
5476 | .TP | |
d3a24ed2 CR |
5477 | .B show\-all\-if\-unmodified (Off) |
5478 | This alters the default behavior of the completion functions in | |
5479 | a fashion similar to \fBshow\-all\-if\-ambiguous\fP. | |
5480 | If set to | |
dc60d4e0 | 5481 | .BR On , |
d3a24ed2 CR |
5482 | words which have more than one possible completion without any |
5483 | possible partial completion (the possible completions don't share | |
5484 | a common prefix) cause the matches to be listed immediately instead | |
5485 | of ringing the bell. | |
5486 | .TP | |
a7ad477f CR |
5487 | .B show\-mode\-in\-prompt (Off) |
5488 | If set to \fBOn\fP, add a character to the beginning of the prompt | |
5489 | indicating the editing mode: emacs (@), vi command (:) or vi | |
5490 | insertion (+). | |
5491 | .TP | |
8f714a7c CR |
5492 | .B skip\-completed\-text (Off) |
5493 | If set to \fBOn\fP, this alters the default completion behavior when | |
5494 | inserting a single match into the line. It's only active when | |
5495 | performing completion in the middle of a word. If enabled, readline | |
5496 | does not insert characters from the completion that match characters | |
5497 | after point in the word being completed, so portions of the word | |
5498 | following the cursor are not duplicated. | |
5499 | .TP | |
ccc6cda3 JA |
5500 | .B visible\-stats (Off) |
5501 | If set to \fBOn\fP, a character denoting a file's type as reported | |
5502 | by \fIstat\fP(2) is appended to the filename when listing possible | |
5503 | completions. | |
726f6388 | 5504 | .PD |
ccc6cda3 | 5505 | .SS "Readline Conditional Constructs" |
726f6388 JA |
5506 | .PP |
5507 | Readline implements a facility similar in spirit to the conditional | |
5508 | compilation features of the C preprocessor which allows key | |
5509 | bindings and variable settings to be performed as the result | |
cce855bc | 5510 | of tests. There are four parser directives used. |
726f6388 JA |
5511 | .IP \fB$if\fP |
5512 | The | |
5513 | .B $if | |
5514 | construct allows bindings to be made based on the | |
5515 | editing mode, the terminal being used, or the application using | |
5516 | readline. The text of the test extends to the end of the line; | |
5517 | no characters are required to isolate it. | |
5518 | .RS | |
5519 | .IP \fBmode\fP | |
5520 | The \fBmode=\fP form of the \fB$if\fP directive is used to test | |
5521 | whether readline is in emacs or vi mode. | |
5522 | This may be used in conjunction | |
5523 | with the \fBset keymap\fP command, for instance, to set bindings in | |
ccc6cda3 | 5524 | the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if |
726f6388 JA |
5525 | readline is starting out in emacs mode. |
5526 | .IP \fBterm\fP | |
5527 | The \fBterm=\fP form may be used to include terminal-specific | |
5528 | key bindings, perhaps to bind the key sequences output by the | |
5529 | terminal's function keys. The word on the right side of the | |
5530 | .B = | |
cce855bc | 5531 | is tested against the both full name of the terminal and the portion |
726f6388 JA |
5532 | of the terminal name before the first \fB\-\fP. This allows |
5533 | .I sun | |
5534 | to match both | |
5535 | .I sun | |
5536 | and | |
5537 | .IR sun\-cmd , | |
5538 | for instance. | |
5539 | .IP \fBapplication\fP | |
5540 | The \fBapplication\fP construct is used to include | |
ccc6cda3 | 5541 | application-specific settings. Each program using the readline |
726f6388 JA |
5542 | library sets the \fIapplication name\fP, and an initialization |
5543 | file can test for a particular value. | |
5544 | This could be used to bind key sequences to functions useful for | |
5545 | a specific program. For instance, the following command adds a | |
dc60d4e0 | 5546 | key sequence that quotes the current or previous word in \fBbash\fP: |
cce855bc | 5547 | .sp 1 |
726f6388 JA |
5548 | .RS |
5549 | .nf | |
5550 | \fB$if\fP Bash | |
5551 | # Quote the current or previous word | |
ccc6cda3 | 5552 | "\eC\-xq": "\eeb\e"\eef\e"" |
726f6388 JA |
5553 | \fB$endif\fP |
5554 | .fi | |
5555 | .RE | |
5556 | .RE | |
5557 | .IP \fB$endif\fP | |
cce855bc | 5558 | This command, as seen in the previous example, terminates an |
726f6388 JA |
5559 | \fB$if\fP command. |
5560 | .IP \fB$else\fP | |
5561 | Commands in this branch of the \fB$if\fP directive are executed if | |
5562 | the test fails. | |
cce855bc JA |
5563 | .IP \fB$include\fP |
5564 | This directive takes a single filename as an argument and reads commands | |
5565 | and bindings from that file. For example, the following directive | |
5566 | would read \fI/etc/inputrc\fP: | |
5567 | .sp 1 | |
5568 | .RS | |
5569 | .nf | |
5570 | \fB$include\fP \^ \fI/etc/inputrc\fP | |
5571 | .fi | |
5572 | .RE | |
ccc6cda3 | 5573 | .SS Searching |
726f6388 | 5574 | .PP |
ccc6cda3 JA |
5575 | Readline provides commands for searching through the command history |
5576 | (see | |
5577 | .SM | |
5578 | .B HISTORY | |
5579 | below) for lines containing a specified string. | |
5580 | There are two search modes: | |
5581 | .I incremental | |
5582 | and | |
5583 | .IR non-incremental . | |
5584 | .PP | |
5585 | Incremental searches begin before the user has finished typing the | |
5586 | search string. | |
5587 | As each character of the search string is typed, readline displays | |
5588 | the next entry from the history matching the string typed so far. | |
5589 | An incremental search requires only as many characters as needed to | |
5590 | find the desired history entry. | |
bb70624e | 5591 | The characters present in the value of the \fBisearch-terminators\fP |
b72432fd JA |
5592 | variable are used to terminate an incremental search. |
5593 | If that variable has not been assigned a value the Escape and | |
5594 | Control-J characters will terminate an incremental search. | |
ccc6cda3 JA |
5595 | Control-G will abort an incremental search and restore the original |
5596 | line. | |
5597 | When the search is terminated, the history entry containing the | |
5598 | search string becomes the current line. | |
bb70624e | 5599 | .PP |
ccc6cda3 JA |
5600 | To find other matching entries in the history list, type Control-S or |
5601 | Control-R as appropriate. | |
5602 | This will search backward or forward in the history for the next | |
5603 | entry matching the search string typed so far. | |
5604 | Any other key sequence bound to a readline command will terminate | |
5605 | the search and execute that command. | |
5606 | For instance, a \fInewline\fP will terminate the search and accept | |
5607 | the line, thereby executing the command from the history list. | |
5608 | .PP | |
f73dda09 JA |
5609 | Readline remembers the last incremental search string. If two |
5610 | Control-Rs are typed without any intervening characters defining a | |
5611 | new search string, any remembered search string is used. | |
5612 | .PP | |
ccc6cda3 JA |
5613 | Non-incremental searches read the entire search string before starting |
5614 | to search for matching history lines. The search string may be | |
cce855bc | 5615 | typed by the user or be part of the contents of the current line. |
ccc6cda3 | 5616 | .SS "Readline Command Names" |
726f6388 JA |
5617 | .PP |
5618 | The following is a list of the names of the commands and the default | |
5619 | key sequences to which they are bound. | |
ccc6cda3 | 5620 | Command names without an accompanying key sequence are unbound by default. |
bb70624e JA |
5621 | In the following descriptions, \fIpoint\fP refers to the current cursor |
5622 | position, and \fImark\fP refers to a cursor position saved by the | |
5623 | \fBset\-mark\fP command. | |
5624 | The text between the point and mark is referred to as the \fIregion\fP. | |
726f6388 JA |
5625 | .SS Commands for Moving |
5626 | .PP | |
5627 | .PD 0 | |
5628 | .TP | |
5629 | .B beginning\-of\-line (C\-a) | |
5630 | Move to the start of the current line. | |
5631 | .TP | |
5632 | .B end\-of\-line (C\-e) | |
5633 | Move to the end of the line. | |
5634 | .TP | |
5635 | .B forward\-char (C\-f) | |
5636 | Move forward a character. | |
5637 | .TP | |
5638 | .B backward\-char (C\-b) | |
5639 | Move back a character. | |
5640 | .TP | |
5641 | .B forward\-word (M\-f) | |
5642 | Move forward to the end of the next word. Words are composed of | |
5643 | alphanumeric characters (letters and digits). | |
5644 | .TP | |
5645 | .B backward\-word (M\-b) | |
8c2fef19 CR |
5646 | Move back to the start of the current or previous word. |
5647 | Words are composed of alphanumeric characters (letters and digits). | |
5648 | .TP | |
5649 | .B shell\-forward\-word | |
5650 | Move forward to the end of the next word. | |
5651 | Words are delimited by non-quoted shell metacharacters. | |
5652 | .TP | |
5653 | .B shell\-backward\-word | |
5654 | Move back to the start of the current or previous word. | |
5655 | Words are delimited by non-quoted shell metacharacters. | |
726f6388 JA |
5656 | .TP |
5657 | .B clear\-screen (C\-l) | |
5658 | Clear the screen leaving the current line at the top of the screen. | |
5659 | With an argument, refresh the current line without clearing the | |
5660 | screen. | |
5661 | .TP | |
5662 | .B redraw\-current\-line | |
ccc6cda3 | 5663 | Refresh the current line. |
726f6388 JA |
5664 | .PD |
5665 | .SS Commands for Manipulating the History | |
5666 | .PP | |
5667 | .PD 0 | |
5668 | .TP | |
5669 | .B accept\-line (Newline, Return) | |
5670 | Accept the line regardless of where the cursor is. If this line is | |
ccc6cda3 | 5671 | non-empty, add it to the history list according to the state of the |
726f6388 JA |
5672 | .SM |
5673 | .B HISTCONTROL | |
5674 | variable. If the line is a modified history | |
5675 | line, then restore the history line to its original state. | |
5676 | .TP | |
5677 | .B previous\-history (C\-p) | |
5678 | Fetch the previous command from the history list, moving back in | |
5679 | the list. | |
5680 | .TP | |
5681 | .B next\-history (C\-n) | |
5682 | Fetch the next command from the history list, moving forward in the | |
5683 | list. | |
5684 | .TP | |
5685 | .B beginning\-of\-history (M\-<) | |
5686 | Move to the first line in the history. | |
5687 | .TP | |
5688 | .B end\-of\-history (M\->) | |
5689 | Move to the end of the input history, i.e., the line currently being | |
5690 | entered. | |
5691 | .TP | |
5692 | .B reverse\-search\-history (C\-r) | |
5693 | Search backward starting at the current line and moving `up' through | |
5694 | the history as necessary. This is an incremental search. | |
5695 | .TP | |
5696 | .B forward\-search\-history (C\-s) | |
5697 | Search forward starting at the current line and moving `down' through | |
5698 | the history as necessary. This is an incremental search. | |
5699 | .TP | |
5700 | .B non\-incremental\-reverse\-search\-history (M\-p) | |
5701 | Search backward through the history starting at the current line | |
ccc6cda3 | 5702 | using a non-incremental search for a string supplied by the user. |
726f6388 JA |
5703 | .TP |
5704 | .B non\-incremental\-forward\-search\-history (M\-n) | |
ccc6cda3 | 5705 | Search forward through the history using a non-incremental search for |
726f6388 JA |
5706 | a string supplied by the user. |
5707 | .TP | |
5708 | .B history\-search\-forward | |
5709 | Search forward through the history for the string of characters | |
bb70624e | 5710 | between the start of the current line and the point. |
ccc6cda3 | 5711 | This is a non-incremental search. |
726f6388 JA |
5712 | .TP |
5713 | .B history\-search\-backward | |
5714 | Search backward through the history for the string of characters | |
ccc6cda3 JA |
5715 | between the start of the current line and the point. |
5716 | This is a non-incremental search. | |
726f6388 JA |
5717 | .TP |
5718 | .B yank\-nth\-arg (M\-C\-y) | |
5719 | Insert the first argument to the previous command (usually | |
28ef6c31 JA |
5720 | the second word on the previous line) at point. |
5721 | With an argument | |
726f6388 JA |
5722 | .IR n , |
5723 | insert the \fIn\fPth word from the previous command (the words | |
5724 | in the previous command begin with word 0). A negative argument | |
5725 | inserts the \fIn\fPth word from the end of the previous command. | |
eb2bb562 CR |
5726 | Once the argument \fIn\fP is computed, the argument is extracted |
5727 | as if the "!\fIn\fP" history expansion had been specified. | |
726f6388 JA |
5728 | .TP |
5729 | .B | |
5730 | yank\-last\-arg (M\-.\^, M\-_\^) | |
ccc6cda3 | 5731 | Insert the last argument to the previous command (the last word of |
adc6cff5 CR |
5732 | the previous history entry). |
5733 | With a numeric argument, behave exactly like \fByank\-nth\-arg\fP. | |
cce855bc | 5734 | Successive calls to \fByank\-last\-arg\fP move back through the history |
adc6cff5 CR |
5735 | list, inserting the last word (or the word specified by the argument to |
5736 | the first call) of each line in turn. | |
5737 | Any numeric argument supplied to these successive calls determines | |
5738 | the direction to move through the history. A negative argument switches | |
5739 | the direction through the history (back or forward). | |
1442f67c | 5740 | The history expansion facilities are used to extract the last word, |
eb2bb562 | 5741 | as if the "!$" history expansion had been specified. |
726f6388 JA |
5742 | .TP |
5743 | .B shell\-expand\-line (M\-C\-e) | |
cce855bc | 5744 | Expand the line as the shell does. This |
726f6388 JA |
5745 | performs alias and history expansion as well as all of the shell |
5746 | word expansions. See | |
5747 | .SM | |
5748 | .B HISTORY EXPANSION | |
5749 | below for a description of history expansion. | |
5750 | .TP | |
5751 | .B history\-expand\-line (M\-^) | |
d166f048 JA |
5752 | Perform history expansion on the current line. |
5753 | See | |
726f6388 JA |
5754 | .SM |
5755 | .B HISTORY EXPANSION | |
5756 | below for a description of history expansion. | |
5757 | .TP | |
cce855bc JA |
5758 | .B magic\-space |
5759 | Perform history expansion on the current line and insert a space. | |
5760 | See | |
5761 | .SM | |
5762 | .B HISTORY EXPANSION | |
5763 | below for a description of history expansion. | |
5764 | .TP | |
d166f048 JA |
5765 | .B alias\-expand\-line |
5766 | Perform alias expansion on the current line. | |
5767 | See | |
5768 | .SM | |
5769 | .B ALIASES | |
5770 | above for a description of alias expansion. | |
5771 | .TP | |
5772 | .B history\-and\-alias\-expand\-line | |
5773 | Perform history and alias expansion on the current line. | |
5774 | .TP | |
726f6388 JA |
5775 | .B insert\-last\-argument (M\-.\^, M\-_\^) |
5776 | A synonym for \fByank\-last\-arg\fP. | |
5777 | .TP | |
ccc6cda3 | 5778 | .B operate\-and\-get\-next (C\-o) |
726f6388 JA |
5779 | Accept the current line for execution and fetch the next line |
5780 | relative to the current line from the history for editing. Any | |
5781 | argument is ignored. | |
7117c2d2 JA |
5782 | .TP |
5783 | .B edit\-and\-execute\-command (C\-xC\-e) | |
5784 | Invoke an editor on the current command line, and execute the result as shell | |
5785 | commands. | |
5786 | \fBBash\fP attempts to invoke | |
5787 | .SM | |
dd4f3dd8 | 5788 | .BR $VISUAL , |
7117c2d2 JA |
5789 | .SM |
5790 | .BR $EDITOR , | |
5791 | and \fIemacs\fP as the editor, in that order. | |
726f6388 JA |
5792 | .PD |
5793 | .SS Commands for Changing Text | |
5794 | .PP | |
5795 | .PD 0 | |
5796 | .TP | |
5797 | .B delete\-char (C\-d) | |
28ef6c31 | 5798 | Delete the character at point. If point is at the |
726f6388 | 5799 | beginning of the line, there are no characters in the line, and |
cce855bc | 5800 | the last character typed was not bound to \fBdelete\-char\fP, |
726f6388 JA |
5801 | then return |
5802 | .SM | |
5803 | .BR EOF . | |
5804 | .TP | |
5805 | .B backward\-delete\-char (Rubout) | |
5806 | Delete the character behind the cursor. When given a numeric argument, | |
ccc6cda3 | 5807 | save the deleted text on the kill ring. |
726f6388 | 5808 | .TP |
b72432fd JA |
5809 | .B forward\-backward\-delete\-char |
5810 | Delete the character under the cursor, unless the cursor is at the | |
5811 | end of the line, in which case the character behind the cursor is | |
f73dda09 | 5812 | deleted. |
b72432fd | 5813 | .TP |
726f6388 | 5814 | .B quoted\-insert (C\-q, C\-v) |
cce855bc | 5815 | Add the next character typed to the line verbatim. This is |
726f6388 JA |
5816 | how to insert characters like \fBC\-q\fP, for example. |
5817 | .TP | |
ccc6cda3 | 5818 | .B tab\-insert (C\-v TAB) |
726f6388 JA |
5819 | Insert a tab character. |
5820 | .TP | |
5821 | .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...) | |
5822 | Insert the character typed. | |
5823 | .TP | |
5824 | .B transpose\-chars (C\-t) | |
28ef6c31 JA |
5825 | Drag the character before point forward over the character at point, |
5826 | moving point forward as well. | |
5827 | If point is at the end of the line, then this transposes | |
5828 | the two characters before point. | |
bb70624e | 5829 | Negative arguments have no effect. |
726f6388 JA |
5830 | .TP |
5831 | .B transpose\-words (M\-t) | |
bb70624e | 5832 | Drag the word before point past the word after point, |
28ef6c31 | 5833 | moving point over that word as well. |
f73dda09 JA |
5834 | If point is at the end of the line, this transposes |
5835 | the last two words on the line. | |
726f6388 JA |
5836 | .TP |
5837 | .B upcase\-word (M\-u) | |
5838 | Uppercase the current (or following) word. With a negative argument, | |
cce855bc | 5839 | uppercase the previous word, but do not move point. |
726f6388 JA |
5840 | .TP |
5841 | .B downcase\-word (M\-l) | |
5842 | Lowercase the current (or following) word. With a negative argument, | |
cce855bc | 5843 | lowercase the previous word, but do not move point. |
726f6388 JA |
5844 | .TP |
5845 | .B capitalize\-word (M\-c) | |
5846 | Capitalize the current (or following) word. With a negative argument, | |
cce855bc | 5847 | capitalize the previous word, but do not move point. |
7117c2d2 JA |
5848 | .TP |
5849 | .B overwrite\-mode | |
5850 | Toggle overwrite mode. With an explicit positive numeric argument, | |
5851 | switches to overwrite mode. With an explicit non-positive numeric | |
5852 | argument, switches to insert mode. This command affects only | |
5853 | \fBemacs\fP mode; \fBvi\fP mode does overwrite differently. | |
5854 | Each call to \fIreadline()\fP starts in insert mode. | |
5855 | In overwrite mode, characters bound to \fBself\-insert\fP replace | |
5856 | the text at point rather than pushing the text to the right. | |
5857 | Characters bound to \fBbackward\-delete\-char\fP replace the character | |
5858 | before point with a space. By default, this command is unbound. | |
726f6388 JA |
5859 | .PD |
5860 | .SS Killing and Yanking | |
5861 | .PP | |
5862 | .PD 0 | |
5863 | .TP | |
5864 | .B kill\-line (C\-k) | |
bb70624e | 5865 | Kill the text from point to the end of the line. |
726f6388 | 5866 | .TP |
ccc6cda3 | 5867 | .B backward\-kill\-line (C\-x Rubout) |
726f6388 JA |
5868 | Kill backward to the beginning of the line. |
5869 | .TP | |
5870 | .B unix\-line\-discard (C\-u) | |
5871 | Kill backward from point to the beginning of the line. | |
cce855bc | 5872 | The killed text is saved on the kill-ring. |
bb70624e | 5873 | .\" There is no real difference between this and backward-kill-line |
726f6388 JA |
5874 | .TP |
5875 | .B kill\-whole\-line | |
bb70624e | 5876 | Kill all characters on the current line, no matter where point is. |
726f6388 JA |
5877 | .TP |
5878 | .B kill\-word (M\-d) | |
bb70624e JA |
5879 | Kill from point to the end of the current word, or if between |
5880 | words, to the end of the next word. | |
5881 | Word boundaries are the same as those used by \fBforward\-word\fP. | |
726f6388 JA |
5882 | .TP |
5883 | .B backward\-kill\-word (M\-Rubout) | |
bb70624e JA |
5884 | Kill the word behind point. |
5885 | Word boundaries are the same as those used by \fBbackward\-word\fP. | |
726f6388 | 5886 | .TP |
8c2fef19 CR |
5887 | .B shell\-kill\-word (M\-d) |
5888 | Kill from point to the end of the current word, or if between | |
5889 | words, to the end of the next word. | |
5890 | Word boundaries are the same as those used by \fBshell\-forward\-word\fP. | |
5891 | .TP | |
5892 | .B shell\-backward\-kill\-word (M\-Rubout) | |
5893 | Kill the word behind point. | |
5894 | Word boundaries are the same as those used by \fBshell\-backward\-word\fP. | |
5895 | .TP | |
726f6388 | 5896 | .B unix\-word\-rubout (C\-w) |
bb70624e | 5897 | Kill the word behind point, using white space as a word boundary. |
bb70624e | 5898 | The killed text is saved on the kill-ring. |
113d85a4 CR |
5899 | .TP |
5900 | .B unix\-filename\-rubout | |
5901 | Kill the word behind point, using white space and the slash character | |
5902 | as the word boundaries. | |
5903 | The killed text is saved on the kill-ring. | |
ccc6cda3 JA |
5904 | .TP |
5905 | .B delete\-horizontal\-space (M\-\e) | |
5906 | Delete all spaces and tabs around point. | |
5907 | .TP | |
5908 | .B kill\-region | |
bb70624e | 5909 | Kill the text in the current region. |
ccc6cda3 JA |
5910 | .TP |
5911 | .B copy\-region\-as\-kill | |
5912 | Copy the text in the region to the kill buffer. | |
726f6388 | 5913 | .TP |
ccc6cda3 JA |
5914 | .B copy\-backward\-word |
5915 | Copy the word before point to the kill buffer. | |
cce855bc | 5916 | The word boundaries are the same as \fBbackward\-word\fP. |
ccc6cda3 JA |
5917 | .TP |
5918 | .B copy\-forward\-word | |
5919 | Copy the word following point to the kill buffer. | |
cce855bc | 5920 | The word boundaries are the same as \fBforward\-word\fP. |
726f6388 JA |
5921 | .TP |
5922 | .B yank (C\-y) | |
28ef6c31 | 5923 | Yank the top of the kill ring into the buffer at point. |
726f6388 JA |
5924 | .TP |
5925 | .B yank\-pop (M\-y) | |
ccc6cda3 | 5926 | Rotate the kill ring, and yank the new top. Only works following |
726f6388 JA |
5927 | .B yank |
5928 | or | |
5929 | .BR yank\-pop . | |
5930 | .PD | |
5931 | .SS Numeric Arguments | |
5932 | .PP | |
5933 | .PD 0 | |
5934 | .TP | |
5935 | .B digit\-argument (M\-0, M\-1, ..., M\-\-) | |
5936 | Add this digit to the argument already accumulating, or start a new | |
5937 | argument. M\-\- starts a negative argument. | |
5938 | .TP | |
5939 | .B universal\-argument | |
d166f048 JA |
5940 | This is another way to specify an argument. |
5941 | If this command is followed by one or more digits, optionally with a | |
5942 | leading minus sign, those digits define the argument. | |
5943 | If the command is followed by digits, executing | |
5944 | .B universal\-argument | |
5945 | again ends the numeric argument, but is otherwise ignored. | |
5946 | As a special case, if this command is immediately followed by a | |
5947 | character that is neither a digit or minus sign, the argument count | |
5948 | for the next command is multiplied by four. | |
726f6388 | 5949 | The argument count is initially one, so executing this function the |
d166f048 JA |
5950 | first time makes the argument count four, a second time makes the |
5951 | argument count sixteen, and so on. | |
726f6388 JA |
5952 | .PD |
5953 | .SS Completing | |
5954 | .PP | |
5955 | .PD 0 | |
5956 | .TP | |
5957 | .B complete (TAB) | |
5958 | Attempt to perform completion on the text before point. | |
5959 | .B Bash | |
5960 | attempts completion treating the text as a variable (if the | |
5961 | text begins with \fB$\fP), username (if the text begins with | |
5962 | \fB~\fP), hostname (if the text begins with \fB@\fP), or | |
5963 | command (including aliases and functions) in turn. If none | |
5964 | of these produces a match, filename completion is attempted. | |
5965 | .TP | |
ccc6cda3 | 5966 | .B possible\-completions (M\-?) |
726f6388 JA |
5967 | List the possible completions of the text before point. |
5968 | .TP | |
ccc6cda3 | 5969 | .B insert\-completions (M\-*) |
726f6388 JA |
5970 | Insert all completions of the text before point |
5971 | that would have been generated by | |
ccc6cda3 | 5972 | \fBpossible\-completions\fP. |
726f6388 | 5973 | .TP |
cce855bc JA |
5974 | .B menu\-complete |
5975 | Similar to \fBcomplete\fP, but replaces the word to be completed | |
5976 | with a single match from the list of possible completions. | |
5977 | Repeated execution of \fBmenu\-complete\fP steps through the list | |
5978 | of possible completions, inserting each match in turn. | |
28ef6c31 | 5979 | At the end of the list of completions, the bell is rung |
f73dda09 | 5980 | (subject to the setting of \fBbell\-style\fP) |
28ef6c31 | 5981 | and the original text is restored. |
cce855bc JA |
5982 | An argument of \fIn\fP moves \fIn\fP positions forward in the list |
5983 | of matches; a negative argument may be used to move backward | |
5984 | through the list. | |
5985 | This command is intended to be bound to \fBTAB\fP, but is unbound | |
5986 | by default. | |
5987 | .TP | |
dc60d4e0 | 5988 | .B menu\-complete\-backward |
9dd88db7 CR |
5989 | Identical to \fBmenu\-complete\fP, but moves backward through the list |
5990 | of possible completions, as if \fBmenu\-complete\fP had been given a | |
5991 | negative argument. This command is unbound by default. | |
5992 | .TP | |
b72432fd JA |
5993 | .B delete\-char\-or\-list |
5994 | Deletes the character under the cursor if not at the beginning or | |
bb70624e | 5995 | end of the line (like \fBdelete\-char\fP). |
b72432fd | 5996 | If at the end of the line, behaves identically to |
bb70624e | 5997 | \fBpossible\-completions\fP. |
b72432fd JA |
5998 | This command is unbound by default. |
5999 | .TP | |
726f6388 JA |
6000 | .B complete\-filename (M\-/) |
6001 | Attempt filename completion on the text before point. | |
6002 | .TP | |
6003 | .B possible\-filename\-completions (C\-x /) | |
6004 | List the possible completions of the text before point, | |
6005 | treating it as a filename. | |
6006 | .TP | |
6007 | .B complete\-username (M\-~) | |
6008 | Attempt completion on the text before point, treating | |
6009 | it as a username. | |
6010 | .TP | |
6011 | .B possible\-username\-completions (C\-x ~) | |
6012 | List the possible completions of the text before point, | |
6013 | treating it as a username. | |
6014 | .TP | |
6015 | .B complete\-variable (M\-$) | |
6016 | Attempt completion on the text before point, treating | |
6017 | it as a shell variable. | |
6018 | .TP | |
6019 | .B possible\-variable\-completions (C\-x $) | |
6020 | List the possible completions of the text before point, | |
6021 | treating it as a shell variable. | |
6022 | .TP | |
6023 | .B complete\-hostname (M\-@) | |
6024 | Attempt completion on the text before point, treating | |
6025 | it as a hostname. | |
6026 | .TP | |
6027 | .B possible\-hostname\-completions (C\-x @) | |
6028 | List the possible completions of the text before point, | |
6029 | treating it as a hostname. | |
6030 | .TP | |
6031 | .B complete\-command (M\-!) | |
6032 | Attempt completion on the text before point, treating | |
6033 | it as a command name. Command completion attempts to | |
6034 | match the text against aliases, reserved words, shell | |
cce855bc | 6035 | functions, shell builtins, and finally executable filenames, |
726f6388 JA |
6036 | in that order. |
6037 | .TP | |
6038 | .B possible\-command\-completions (C\-x !) | |
6039 | List the possible completions of the text before point, | |
6040 | treating it as a command name. | |
6041 | .TP | |
ccc6cda3 | 6042 | .B dynamic\-complete\-history (M\-TAB) |
726f6388 JA |
6043 | Attempt completion on the text before point, comparing |
6044 | the text against lines from the history list for possible | |
6045 | completion matches. | |
6046 | .TP | |
8943768b CR |
6047 | .B dabbrev\-expand |
6048 | Attempt menu completion on the text before point, comparing | |
6049 | the text against lines from the history list for possible | |
6050 | completion matches. | |
6051 | .TP | |
726f6388 | 6052 | .B complete\-into\-braces (M\-{) |
bb70624e | 6053 | Perform filename completion and insert the list of possible completions |
726f6388 JA |
6054 | enclosed within braces so the list is available to the shell (see |
6055 | .B Brace Expansion | |
6056 | above). | |
6057 | .PD | |
6058 | .SS Keyboard Macros | |
6059 | .PP | |
6060 | .PD 0 | |
6061 | .TP | |
ccc6cda3 | 6062 | .B start\-kbd\-macro (C\-x (\^) |
726f6388 JA |
6063 | Begin saving the characters typed into the current keyboard macro. |
6064 | .TP | |
ccc6cda3 | 6065 | .B end\-kbd\-macro (C\-x )\^) |
726f6388 | 6066 | Stop saving the characters typed into the current keyboard macro |
ccc6cda3 | 6067 | and store the definition. |
726f6388 | 6068 | .TP |
ccc6cda3 | 6069 | .B call\-last\-kbd\-macro (C\-x e) |
726f6388 JA |
6070 | Re-execute the last keyboard macro defined, by making the characters |
6071 | in the macro appear as if typed at the keyboard. | |
ba4ab055 CR |
6072 | .B print\-last\-kbd\-macro () |
6073 | Print the last keyboard macro defined in a format suitable for the | |
6074 | \fIinputrc\fP file. | |
726f6388 JA |
6075 | .PD |
6076 | .SS Miscellaneous | |
6077 | .PP | |
6078 | .PD 0 | |
6079 | .TP | |
6080 | .B re\-read\-init\-file (C\-x C\-r) | |
ccc6cda3 | 6081 | Read in the contents of the \fIinputrc\fP file, and incorporate |
726f6388 JA |
6082 | any bindings or variable assignments found there. |
6083 | .TP | |
6084 | .B abort (C\-g) | |
6085 | Abort the current editing command and | |
6086 | ring the terminal's bell (subject to the setting of | |
6087 | .BR bell\-style ). | |
6088 | .TP | |
ccc6cda3 JA |
6089 | .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...) |
6090 | If the metafied character \fIx\fP is lowercase, run the command | |
6091 | that is bound to the corresponding uppercase character. | |
726f6388 JA |
6092 | .TP |
6093 | .B prefix\-meta (ESC) | |
6094 | Metafy the next character typed. | |
6095 | .SM | |
6096 | .B ESC | |
6097 | .B f | |
6098 | is equivalent to | |
6099 | .BR Meta\-f . | |
6100 | .TP | |
6101 | .B undo (C\-_, C\-x C\-u) | |
6102 | Incremental undo, separately remembered for each line. | |
6103 | .TP | |
6104 | .B revert\-line (M\-r) | |
cce855bc | 6105 | Undo all changes made to this line. This is like executing the |
726f6388 JA |
6106 | .B undo |
6107 | command enough times to return the line to its initial state. | |
6108 | .TP | |
b72432fd | 6109 | .B tilde\-expand (M\-&) |
726f6388 JA |
6110 | Perform tilde expansion on the current word. |
6111 | .TP | |
ccc6cda3 | 6112 | .B set\-mark (C\-@, M\-<space>) |
28ef6c31 | 6113 | Set the mark to the point. If a |
ccc6cda3 JA |
6114 | numeric argument is supplied, the mark is set to that position. |
6115 | .TP | |
6116 | .B exchange\-point\-and\-mark (C\-x C\-x) | |
6117 | Swap the point with the mark. The current cursor position is set to | |
6118 | the saved position, and the old cursor position is saved as the mark. | |
6119 | .TP | |
6120 | .B character\-search (C\-]) | |
6121 | A character is read and point is moved to the next occurrence of that | |
6122 | character. A negative count searches for previous occurrences. | |
6123 | .TP | |
6124 | .B character\-search\-backward (M\-C\-]) | |
6125 | A character is read and point is moved to the previous occurrence of that | |
6126 | character. A negative count searches for subsequent occurrences. | |
6127 | .TP | |
dc60d4e0 | 6128 | .B skip\-csi\-sequence |
691aebcb CR |
6129 | Read enough characters to consume a multi-key sequence such as those |
6130 | defined for keys like Home and End. Such sequences begin with a | |
6131 | Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is | |
6132 | bound to "\e[", keys producing such sequences will have no effect | |
6133 | unless explicitly bound to a readline command, instead of inserting | |
6134 | stray characters into the editing buffer. This is unbound by default, | |
6135 | but usually bound to ESC\-[. | |
6136 | .TP | |
ccc6cda3 | 6137 | .B insert\-comment (M\-#) |
7117c2d2 | 6138 | Without a numeric argument, the value of the readline |
ccc6cda3 | 6139 | .B comment\-begin |
7117c2d2 JA |
6140 | variable is inserted at the beginning of the current line. |
6141 | If a numeric argument is supplied, this command acts as a toggle: if | |
6142 | the characters at the beginning of the line do not match the value | |
6143 | of \fBcomment\-begin\fP, the value is inserted, otherwise | |
db31fb26 | 6144 | the characters in \fBcomment\-begin\fP are deleted from the beginning of |
7117c2d2 JA |
6145 | the line. |
6146 | In either case, the line is accepted as if a newline had been typed. | |
6147 | The default value of | |
bb70624e | 6148 | \fBcomment\-begin\fP causes this command to make the current line |
ccc6cda3 | 6149 | a shell comment. |
7117c2d2 JA |
6150 | If a numeric argument causes the comment character to be removed, the line |
6151 | will be executed by the shell. | |
6152 | .TP | |
6153 | .B glob\-complete\-word (M\-g) | |
6154 | The word before point is treated as a pattern for pathname expansion, | |
6155 | with an asterisk implicitly appended. This pattern is used to | |
b28ff8c9 | 6156 | generate a list of matching filenames for possible completions. |
ccc6cda3 JA |
6157 | .TP |
6158 | .B glob\-expand\-word (C\-x *) | |
6159 | The word before point is treated as a pattern for pathname expansion, | |
b28ff8c9 | 6160 | and the list of matching filenames is inserted, replacing the word. |
7117c2d2 JA |
6161 | If a numeric argument is supplied, an asterisk is appended before |
6162 | pathname expansion. | |
ccc6cda3 JA |
6163 | .TP |
6164 | .B glob\-list\-expansions (C\-x g) | |
6165 | The list of expansions that would have been generated by | |
6166 | .B glob\-expand\-word | |
6167 | is displayed, and the line is redrawn. | |
7117c2d2 JA |
6168 | If a numeric argument is supplied, an asterisk is appended before |
6169 | pathname expansion. | |
ccc6cda3 | 6170 | .TP |
726f6388 JA |
6171 | .B dump\-functions |
6172 | Print all of the functions and their key bindings to the | |
6173 | readline output stream. If a numeric argument is supplied, | |
6174 | the output is formatted in such a way that it can be made part | |
6175 | of an \fIinputrc\fP file. | |
6176 | .TP | |
ccc6cda3 JA |
6177 | .B dump\-variables |
6178 | Print all of the settable readline variables and their values to the | |
6179 | readline output stream. If a numeric argument is supplied, | |
6180 | the output is formatted in such a way that it can be made part | |
6181 | of an \fIinputrc\fP file. | |
6182 | .TP | |
6183 | .B dump\-macros | |
6184 | Print all of the readline key sequences bound to macros and the | |
22e63b05 | 6185 | strings they output. If a numeric argument is supplied, |
ccc6cda3 JA |
6186 | the output is formatted in such a way that it can be made part |
6187 | of an \fIinputrc\fP file. | |
6188 | .TP | |
726f6388 JA |
6189 | .B display\-shell\-version (C\-x C\-v) |
6190 | Display version information about the current instance of | |
6191 | .BR bash . | |
6192 | .PD | |
bb70624e JA |
6193 | .SS Programmable Completion |
6194 | .PP | |
6195 | When word completion is attempted for an argument to a command for | |
6196 | which a completion specification (a \fIcompspec\fP) has been defined | |
6197 | using the \fBcomplete\fP builtin (see | |
6198 | .SM | |
6199 | .B "SHELL BUILTIN COMMANDS" | |
6200 | below), the programmable completion facilities are invoked. | |
6201 | .PP | |
6202 | First, the command name is identified. | |
3eb2d94a CR |
6203 | If the command word is the empty string (completion attempted at the |
6204 | beginning of an empty line), any compspec defined with | |
6205 | the \fB\-E\fP option to \fBcomplete\fP is used. | |
bb70624e JA |
6206 | If a compspec has been defined for that command, the |
6207 | compspec is used to generate the list of possible completions for the word. | |
6208 | If the command word is a full pathname, a compspec for the full | |
6209 | pathname is searched for first. | |
6210 | If no compspec is found for the full pathname, an attempt is made to | |
6211 | find a compspec for the portion following the final slash. | |
dc60d4e0 | 6212 | If those searches do not result in a compspec, any compspec defined with |
3eb2d94a | 6213 | the \fB\-D\fP option to \fBcomplete\fP is used as the default. |
bb70624e JA |
6214 | .PP |
6215 | Once a compspec has been found, it is used to generate the list of | |
6216 | matching words. | |
6217 | If a compspec is not found, the default \fBbash\fP completion as | |
6218 | described above under \fBCompleting\fP is performed. | |
6219 | .PP | |
6220 | First, the actions specified by the compspec are used. | |
6221 | Only matches which are prefixed by the word being completed are | |
6222 | returned. | |
6223 | When the | |
6224 | .B \-f | |
6225 | or | |
6226 | .B \-d | |
6227 | option is used for filename or directory name completion, the shell | |
6228 | variable | |
6229 | .SM | |
6230 | .B FIGNORE | |
6231 | is used to filter the matches. | |
6232 | .PP | |
d0ca3503 | 6233 | Any completions specified by a pathname expansion pattern to the |
bb70624e JA |
6234 | \fB\-G\fP option are generated next. |
6235 | The words generated by the pattern need not match the word | |
6236 | being completed. | |
6237 | The | |
6238 | .SM | |
6239 | .B GLOBIGNORE | |
6240 | shell variable is not used to filter the matches, but the | |
6241 | .SM | |
6242 | .B FIGNORE | |
6243 | variable is used. | |
6244 | .PP | |
6245 | Next, the string specified as the argument to the \fB\-W\fP option | |
6246 | is considered. | |
6247 | The string is first split using the characters in the | |
6248 | .SM | |
6249 | .B IFS | |
6250 | special variable as delimiters. | |
6251 | Shell quoting is honored. | |
6252 | Each word is then expanded using | |
6253 | brace expansion, tilde expansion, parameter and variable expansion, | |
6e70dbff | 6254 | command substitution, and arithmetic expansion, |
bb70624e JA |
6255 | as described above under |
6256 | .SM | |
6257 | .BR EXPANSION . | |
6258 | The results are split using the rules described above under | |
6259 | \fBWord Splitting\fP. | |
6260 | The results of the expansion are prefix-matched against the word being | |
6261 | completed, and the matching words become the possible completions. | |
6262 | .PP | |
6263 | After these matches have been generated, any shell function or command | |
6264 | specified with the \fB\-F\fP and \fB\-C\fP options is invoked. | |
6265 | When the command or function is invoked, the | |
6266 | .SM | |
d3ad40de CR |
6267 | .BR COMP_LINE , |
6268 | .SM | |
6269 | .BR COMP_POINT , | |
6270 | .SM | |
6271 | .BR COMP_KEY , | |
bb70624e JA |
6272 | and |
6273 | .SM | |
d3ad40de | 6274 | .B COMP_TYPE |
bb70624e JA |
6275 | variables are assigned values as described above under |
6276 | \fBShell Variables\fP. | |
6277 | If a shell function is being invoked, the | |
6278 | .SM | |
6279 | .B COMP_WORDS | |
6280 | and | |
6281 | .SM | |
6282 | .B COMP_CWORD | |
6283 | variables are also set. | |
ba4ab055 CR |
6284 | When the function or command is invoked, |
6285 | the first argument (\fB$1\fP) is the name of the command whose arguments are | |
6286 | being completed, | |
6287 | the second argument (\fB$2\fP) is the word being completed, | |
6288 | and the third argument (\fB$3\fP) is the word preceding the word being | |
6289 | completed on the current command line. | |
bb70624e JA |
6290 | No filtering of the generated completions against the word being completed |
6291 | is performed; the function or command has complete freedom in generating | |
6292 | the matches. | |
6293 | .PP | |
6294 | Any function specified with \fB\-F\fP is invoked first. | |
6295 | The function may use any of the shell facilities, including the | |
6296 | \fBcompgen\fP builtin described below, to generate the matches. | |
6297 | It must put the possible completions in the | |
6298 | .SM | |
6299 | .B COMPREPLY | |
ba4ab055 | 6300 | array variable, one per array element. |
bb70624e JA |
6301 | .PP |
6302 | Next, any command specified with the \fB\-C\fP option is invoked | |
6303 | in an environment equivalent to command substitution. | |
6304 | It should print a list of completions, one per line, to the | |
6305 | standard output. | |
6306 | Backslash may be used to escape a newline, if necessary. | |
6307 | .PP | |
6308 | After all of the possible completions are generated, any filter | |
6309 | specified with the \fB\-X\fP option is applied to the list. | |
6310 | The filter is a pattern as used for pathname expansion; a \fB&\fP | |
6311 | in the pattern is replaced with the text of the word being completed. | |
6312 | A literal \fB&\fP may be escaped with a backslash; the backslash | |
6313 | is removed before attempting a match. | |
6314 | Any completion that matches the pattern will be removed from the list. | |
6315 | A leading \fB!\fP negates the pattern; in this case any completion | |
6316 | not matching the pattern will be removed. | |
6317 | .PP | |
6318 | Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP | |
6319 | options are added to each member of the completion list, and the result is | |
6320 | returned to the readline completion code as the list of possible | |
6321 | completions. | |
6322 | .PP | |
28ef6c31 JA |
6323 | If the previously-applied actions do not generate any matches, and the |
6324 | \fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the | |
6325 | compspec was defined, directory name completion is attempted. | |
6326 | .PP | |
d3a24ed2 CR |
6327 | If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the |
6328 | compspec was defined, directory name completion is attempted and any | |
6329 | matches are added to the results of the other actions. | |
6330 | .PP | |
28ef6c31 JA |
6331 | By default, if a compspec is found, whatever it generates is returned |
6332 | to the completion code as the full set of possible completions. | |
bb70624e JA |
6333 | The default \fBbash\fP completions are not attempted, and the readline |
6334 | default of filename completion is disabled. | |
d3a24ed2 CR |
6335 | If the \fB\-o bashdefault\fP option was supplied to \fBcomplete\fP when |
6336 | the compspec was defined, the \fBbash\fP default completions are attempted | |
28ef6c31 | 6337 | if the compspec generates no matches. |
d3a24ed2 CR |
6338 | If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the |
6339 | compspec was defined, readline's default completion will be performed | |
6340 | if the compspec (and, if attempted, the default \fBbash\fP completions) | |
6341 | generate no matches. | |
7117c2d2 JA |
6342 | .PP |
6343 | When a compspec indicates that directory name completion is desired, | |
6344 | the programmable completion functions force readline to append a slash | |
6345 | to completed names which are symbolic links to directories, subject to | |
6346 | the value of the \fBmark\-directories\fP readline variable, regardless | |
6347 | of the setting of the \fBmark-symlinked\-directories\fP readline variable. | |
3eb2d94a CR |
6348 | .PP |
6349 | There is some support for dynamically modifying completions. This is | |
6350 | most useful when used in combination with a default completion specified | |
6351 | with \fBcomplete -D\fP. | |
6352 | It's possible for shell functions executed as completion | |
6353 | handlers to indicate that completion should be retried by returning an | |
6354 | exit status of 124. If a shell function returns 124, and changes | |
6355 | the compspec associated with the command on which completion is being | |
6356 | attempted (supplied as the first argument when the function is executed), | |
6357 | programmable completion restarts from the beginning, with an | |
3d8cce26 | 6358 | attempt to find a new compspec for that command. This allows a set of |
3eb2d94a CR |
6359 | completions to be built dynamically as completion is attempted, rather than |
6360 | being loaded all at once. | |
6361 | .PP | |
6362 | For instance, assuming that there is a library of compspecs, each kept in a | |
6363 | file corresponding to the name of the command, the following default | |
6364 | completion function would load completions dynamically: | |
6365 | .PP | |
6366 | \f(CW_completion_loader() | |
6367 | .br | |
6368 | { | |
6369 | .br | |
6370 | . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 | |
6371 | .br | |
6372 | } | |
6373 | .br | |
6374 | complete -D -F _completion_loader | |
6375 | .br | |
6376 | \fP | |
726f6388 | 6377 | .SH HISTORY |
ccc6cda3 | 6378 | When the |
d166f048 | 6379 | .B \-o history |
ccc6cda3 JA |
6380 | option to the |
6381 | .B set | |
6382 | builtin is enabled, the shell provides access to the | |
6383 | \fIcommand history\fP, | |
bb70624e | 6384 | the list of commands previously typed. |
984a1947 CR |
6385 | The value of the |
6386 | .SM | |
6387 | .B HISTSIZE | |
6388 | variable is used as the | |
bb70624e JA |
6389 | number of commands to save in a history list. |
6390 | The text of the last | |
726f6388 JA |
6391 | .SM |
6392 | .B HISTSIZE | |
bb70624e | 6393 | commands (default 500) is saved. The shell |
726f6388 JA |
6394 | stores each command in the history list prior to parameter and |
6395 | variable expansion (see | |
6396 | .SM | |
6397 | .B EXPANSION | |
6398 | above) but after history expansion is performed, subject to the | |
6399 | values of the shell variables | |
ccc6cda3 JA |
6400 | .SM |
6401 | .B HISTIGNORE | |
726f6388 JA |
6402 | and |
6403 | .SM | |
6404 | .BR HISTCONTROL . | |
bb70624e | 6405 | .PP |
726f6388 JA |
6406 | On startup, the history is initialized from the file named by |
6407 | the variable | |
6408 | .SM | |
6409 | .B HISTFILE | |
6410 | (default \fI~/.bash_history\fP). | |
bb70624e | 6411 | The file named by the value of |
726f6388 JA |
6412 | .SM |
6413 | .B HISTFILE | |
6414 | is truncated, if necessary, to contain no more than | |
bb70624e | 6415 | the number of lines specified by the value of |
726f6388 | 6416 | .SM |
bb70624e | 6417 | .BR HISTFILESIZE . |
4b82d1cd CR |
6418 | If \fBHISTFILESIZE\fP is unset, or set to null, a non-numeric value, |
6419 | or a numeric value less than zero, the history file is not truncated. | |
d3ad40de CR |
6420 | When the history file is read, |
6421 | lines beginning with the history comment character followed immediately | |
6422 | by a digit are interpreted as timestamps for the preceding history line. | |
6423 | These timestamps are optionally displayed depending on the value of the | |
6424 | .SM | |
6425 | .B HISTTIMEFORMAT | |
6426 | variable. | |
ed3f3b6c | 6427 | When a shell with history enabled exits, the last |
ccc6cda3 | 6428 | .SM |
bb70624e | 6429 | .B $HISTSIZE |
ccc6cda3 JA |
6430 | lines are copied from the history list to |
6431 | .SM | |
bb70624e | 6432 | .BR $HISTFILE . |
ccc6cda3 JA |
6433 | If the |
6434 | .B histappend | |
6435 | shell option is enabled | |
6436 | (see the description of | |
6437 | .B shopt | |
6438 | under | |
6439 | .SM | |
6440 | .B "SHELL BUILTIN COMMANDS" | |
6441 | below), the lines are appended to the history file, | |
6442 | otherwise the history file is overwritten. | |
6443 | If | |
6444 | .SM | |
6445 | .B HISTFILE | |
6446 | is unset, or if the history file is unwritable, the history is | |
d3ad40de CR |
6447 | not saved. |
6448 | If the | |
6449 | .SM | |
984a1947 | 6450 | .B HISTTIMEFORMAT |
d3ad40de CR |
6451 | variable is set, time stamps are written to the history file, marked |
6452 | with the history comment character, so | |
6453 | they may be preserved across shell sessions. | |
6454 | This uses the history comment character to distinguish timestamps from | |
6455 | other history lines. | |
6456 | After saving the history, the history file is truncated | |
ccc6cda3 JA |
6457 | to contain no more than |
6458 | .SM | |
6459 | .B HISTFILESIZE | |
6460 | lines. If | |
6461 | .SM | |
6462 | .B HISTFILESIZE | |
e67d0029 CR |
6463 | is unset, or set to null, a non-numeric value, |
6464 | or a numeric value less than zero, the history file is not truncated. | |
ccc6cda3 | 6465 | .PP |
726f6388 JA |
6466 | The builtin command |
6467 | .B fc | |
6468 | (see | |
6469 | .SM | |
6470 | .B SHELL BUILTIN COMMANDS | |
6471 | below) may be used to list or edit and re-execute a portion of | |
6472 | the history list. | |
6473 | The | |
6474 | .B history | |
bb70624e | 6475 | builtin may be used to display or modify the history list and |
ccc6cda3 | 6476 | manipulate the history file. |
bb70624e | 6477 | When using command-line editing, search commands |
726f6388 | 6478 | are available in each editing mode that provide access to the |
ccc6cda3 JA |
6479 | history list. |
6480 | .PP | |
6481 | The shell allows control over which commands are saved on the history | |
6482 | list. The | |
726f6388 | 6483 | .SM |
ccc6cda3 JA |
6484 | .B HISTCONTROL |
6485 | and | |
726f6388 | 6486 | .SM |
ccc6cda3 JA |
6487 | .B HISTIGNORE |
6488 | variables may be set to cause the shell to save only a subset of the | |
6489 | commands entered. | |
6490 | The | |
6491 | .B cmdhist | |
6492 | shell option, if enabled, causes the shell to attempt to save each | |
6493 | line of a multi-line command in the same history entry, adding | |
6494 | semicolons where necessary to preserve syntactic correctness. | |
6495 | The | |
6496 | .B lithist | |
6497 | shell option causes the shell to save the command with embedded newlines | |
6498 | instead of semicolons. See the description of the | |
6499 | .B shopt | |
6500 | builtin below under | |
6501 | .SM | |
6502 | .B "SHELL BUILTIN COMMANDS" | |
6503 | for information on setting and unsetting shell options. | |
726f6388 JA |
6504 | .SH "HISTORY EXPANSION" |
6505 | .PP | |
6506 | The shell supports a history expansion feature that | |
6507 | is similar to the history expansion in | |
6508 | .BR csh. | |
6509 | This section describes what syntax features are available. This | |
6510 | feature is enabled by default for interactive shells, and can be | |
6511 | disabled using the | |
863d31ae | 6512 | .B +H |
726f6388 JA |
6513 | option to the |
6514 | .B set | |
6515 | builtin command (see | |
6516 | .SM | |
6517 | .B SHELL BUILTIN COMMANDS | |
ccc6cda3 JA |
6518 | below). Non-interactive shells do not perform history expansion |
6519 | by default. | |
6520 | .PP | |
6521 | History expansions introduce words from the history list into | |
6522 | the input stream, making it easy to repeat commands, insert the | |
6523 | arguments to a previous command into the current input line, or | |
6524 | fix errors in previous commands quickly. | |
726f6388 JA |
6525 | .PP |
6526 | History expansion is performed immediately after a complete line | |
6527 | is read, before the shell breaks it into words. | |
ccc6cda3 | 6528 | It takes place in two parts. |
cce855bc | 6529 | The first is to determine which line from the history list |
ccc6cda3 JA |
6530 | to use during substitution. |
6531 | The second is to select portions of that line for inclusion into | |
6532 | the current one. | |
cce855bc | 6533 | The line selected from the history is the \fIevent\fP, |
ccc6cda3 JA |
6534 | and the portions of that line that are acted upon are \fIwords\fP. |
6535 | Various \fImodifiers\fP are available to manipulate the selected words. | |
6536 | The line is broken into words in the same fashion as when reading input, | |
6537 | so that several \fImetacharacter\fP-separated words surrounded by | |
cce855bc | 6538 | quotes are considered one word. |
ccc6cda3 JA |
6539 | History expansions are introduced by the appearance of the |
6540 | history expansion character, which is \^\fB!\fP\^ by default. | |
6541 | Only backslash (\^\fB\e\fP\^) and single quotes can quote | |
6542 | the history expansion character. | |
6543 | .PP | |
d3a24ed2 CR |
6544 | Several characters inhibit history expansion if found immediately |
6545 | following the history expansion character, even if it is unquoted: | |
6546 | space, tab, newline, carriage return, and \fB=\fP. | |
6547 | If the \fBextglob\fP shell option is enabled, \fB(\fP will also | |
6548 | inhibit expansion. | |
6549 | .PP | |
ccc6cda3 JA |
6550 | Several shell options settable with the |
6551 | .B shopt | |
6552 | builtin may be used to tailor the behavior of history expansion. | |
6553 | If the | |
6554 | .B histverify | |
6555 | shell option is enabled (see the description of the | |
6556 | .B shopt | |
984a1947 | 6557 | builtin below), and |
ccc6cda3 JA |
6558 | .B readline |
6559 | is being used, history substitutions are not immediately passed to | |
6560 | the shell parser. | |
6561 | Instead, the expanded line is reloaded into the | |
6562 | .B readline | |
6563 | editing buffer for further modification. | |
6564 | If | |
6565 | .B readline | |
6566 | is being used, and the | |
6567 | .B histreedit | |
6568 | shell option is enabled, a failed history substitution will be reloaded | |
6569 | into the | |
6570 | .B readline | |
6571 | editing buffer for correction. | |
6572 | The | |
6573 | .B \-p | |
6574 | option to the | |
6575 | .B history | |
6576 | builtin command may be used to see what a history expansion will | |
6577 | do before using it. | |
6578 | The | |
6579 | .B \-s | |
6580 | option to the | |
6581 | .B history | |
6582 | builtin may be used to add commands to the end of the history list | |
6583 | without actually executing them, so that they are available for | |
6584 | subsequent recall. | |
726f6388 JA |
6585 | .PP |
6586 | The shell allows control of the various characters used by the | |
6587 | history expansion mechanism (see the description of | |
6588 | .B histchars | |
6589 | above under | |
6590 | .BR "Shell Variables" ). | |
d3ad40de CR |
6591 | The shell uses |
6592 | the history comment character to mark history timestamps when | |
6593 | writing the history file. | |
726f6388 JA |
6594 | .SS Event Designators |
6595 | .PP | |
6596 | An event designator is a reference to a command line entry in the | |
6597 | history list. | |
5f8cde23 CR |
6598 | Unless the reference is absolute, events are relative to the current |
6599 | position in the history list. | |
726f6388 JA |
6600 | .PP |
6601 | .PD 0 | |
6602 | .TP | |
6603 | .B ! | |
6604 | Start a history substitution, except when followed by a | |
6605 | .BR blank , | |
d3a24ed2 CR |
6606 | newline, carriage return, = |
6607 | or ( (when the \fBextglob\fP shell option is enabled using | |
6608 | the \fBshopt\fP builtin). | |
726f6388 | 6609 | .TP |
726f6388 JA |
6610 | .B !\fIn\fR |
6611 | Refer to command line | |
6612 | .IR n . | |
6613 | .TP | |
6614 | .B !\-\fIn\fR | |
5f8cde23 | 6615 | Refer to the current command minus |
726f6388 JA |
6616 | .IR n . |
6617 | .TP | |
ccc6cda3 JA |
6618 | .B !! |
6619 | Refer to the previous command. This is a synonym for `!\-1'. | |
6620 | .TP | |
726f6388 | 6621 | .B !\fIstring\fR |
5f8cde23 CR |
6622 | Refer to the most recent command preceding the current position in the |
6623 | history list starting with | |
726f6388 JA |
6624 | .IR string . |
6625 | .TP | |
6626 | .B !?\fIstring\fR\fB[?]\fR | |
e3db237e | 6627 | Refer to the most recent command preceding the current position in the |
5f8cde23 | 6628 | history list containing |
726f6388 | 6629 | .IR string . |
ccc6cda3 JA |
6630 | The trailing \fB?\fP may be omitted if |
6631 | .I string | |
6632 | is followed immediately by a newline. | |
726f6388 JA |
6633 | .TP |
6634 | .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u | |
5f8cde23 | 6635 | Quick substitution. Repeat the previous command, replacing |
726f6388 JA |
6636 | .I string1 |
6637 | with | |
6638 | .IR string2 . | |
6639 | Equivalent to | |
6640 | ``!!:s/\fIstring1\fP/\fIstring2\fP/'' | |
6641 | (see \fBModifiers\fP below). | |
6642 | .TP | |
6643 | .B !# | |
6644 | The entire command line typed so far. | |
6645 | .PD | |
6646 | .SS Word Designators | |
6647 | .PP | |
ccc6cda3 | 6648 | Word designators are used to select desired words from the event. |
726f6388 JA |
6649 | A |
6650 | .B : | |
ccc6cda3 | 6651 | separates the event specification from the word designator. |
cce855bc | 6652 | It may be omitted if the word designator begins with a |
726f6388 JA |
6653 | .BR ^ , |
6654 | .BR $ , | |
6655 | .BR * , | |
ccc6cda3 | 6656 | .BR \- , |
726f6388 JA |
6657 | or |
6658 | .BR % . | |
6659 | Words are numbered from the beginning of the line, | |
ccc6cda3 JA |
6660 | with the first word being denoted by 0 (zero). |
6661 | Words are inserted into the current line separated by single spaces. | |
726f6388 JA |
6662 | .PP |
6663 | .PD 0 | |
6664 | .TP | |
6665 | .B 0 (zero) | |
6666 | The zeroth word. For the shell, this is the command | |
6667 | word. | |
6668 | .TP | |
6669 | .I n | |
6670 | The \fIn\fRth word. | |
6671 | .TP | |
6672 | .B ^ | |
6673 | The first argument. That is, word 1. | |
6674 | .TP | |
6675 | .B $ | |
1442f67c CR |
6676 | The last word. This is usually the last argument, but will expand to the |
6677 | zeroth word if there is only one word in the line. | |
726f6388 JA |
6678 | .TP |
6679 | .B % | |
6680 | The word matched by the most recent `?\fIstring\fR?' search. | |
6681 | .TP | |
6682 | .I x\fB\-\fPy | |
6683 | A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'. | |
6684 | .TP | |
6685 | .B * | |
6686 | All of the words but the zeroth. This is a synonym | |
6687 | for `\fI1\-$\fP'. It is not an error to use | |
6688 | .B * | |
6689 | if there is just one | |
6690 | word in the event; the empty string is returned in that case. | |
6691 | .TP | |
6692 | .B x* | |
6693 | Abbreviates \fIx\-$\fP. | |
6694 | .TP | |
6695 | .B x\- | |
6696 | Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word. | |
6697 | .PD | |
ccc6cda3 JA |
6698 | .PP |
6699 | If a word designator is supplied without an event specification, the | |
6700 | previous command is used as the event. | |
726f6388 JA |
6701 | .SS Modifiers |
6702 | .PP | |
ccc6cda3 JA |
6703 | After the optional word designator, there may appear a sequence of |
6704 | one or more of the following modifiers, each preceded by a `:'. | |
726f6388 JA |
6705 | .PP |
6706 | .PD 0 | |
6707 | .PP | |
6708 | .TP | |
6709 | .B h | |
b28ff8c9 | 6710 | Remove a trailing filename component, leaving only the head. |
ccc6cda3 JA |
6711 | .TP |
6712 | .B t | |
b28ff8c9 | 6713 | Remove all leading filename components, leaving the tail. |
726f6388 JA |
6714 | .TP |
6715 | .B r | |
6716 | Remove a trailing suffix of the form \fI.xxx\fP, leaving the | |
6717 | basename. | |
6718 | .TP | |
6719 | .B e | |
6720 | Remove all but the trailing suffix. | |
6721 | .TP | |
726f6388 JA |
6722 | .B p |
6723 | Print the new command but do not execute it. | |
6724 | .TP | |
6725 | .B q | |
6726 | Quote the substituted words, escaping further substitutions. | |
6727 | .TP | |
cce855bc JA |
6728 | .B x |
6729 | Quote the substituted words as with | |
6730 | .BR q , | |
6731 | but break into words at | |
6732 | .B blanks | |
6733 | and newlines. | |
726f6388 | 6734 | .TP |
cce855bc JA |
6735 | .B s/\fIold\fP/\fInew\fP/ |
6736 | Substitute | |
6737 | .I new | |
6738 | for the first occurrence of | |
6739 | .I old | |
6740 | in the event line. Any delimiter can be used in place of /. The | |
6741 | final delimiter is optional if it is the last character of the | |
6742 | event line. The delimiter may be quoted in | |
6743 | .I old | |
6744 | and | |
6745 | .I new | |
6746 | with a single backslash. If & appears in | |
6747 | .IR new , | |
6748 | it is replaced by | |
6749 | .IR old . | |
6750 | A single backslash will quote the &. If | |
6751 | .I old | |
6752 | is null, it is set to the last | |
6753 | .I old | |
6754 | substituted, or, if no previous history substitutions took place, | |
6755 | the last | |
6756 | .I string | |
6757 | in a | |
6758 | .B !?\fIstring\fR\fB[?]\fR | |
6759 | search. | |
ccc6cda3 | 6760 | .TP |
cce855bc JA |
6761 | .B & |
6762 | Repeat the previous substitution. | |
6763 | .TP | |
6764 | .B g | |
6765 | Cause changes to be applied over the entire event line. This is | |
6766 | used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR') | |
6767 | or `\fB:&\fP'. If used with | |
6768 | `\fB:s\fP', any delimiter can be used | |
6769 | in place of /, and the final delimiter is optional | |
6770 | if it is the last character of the event line. | |
d3a24ed2 CR |
6771 | An \fBa\fP may be used as a synonym for \fBg\fP. |
6772 | .TP | |
6773 | .B G | |
6774 | Apply the following `\fBs\fP' modifier once to each word in the event line. | |
726f6388 | 6775 | .PD |
726f6388 JA |
6776 | .SH "SHELL BUILTIN COMMANDS" |
6777 | .\" start of bash_builtins | |
6778 | .zZ | |
ccc6cda3 JA |
6779 | .PP |
6780 | Unless otherwise noted, each builtin command documented in this | |
6781 | section as accepting options preceded by | |
6782 | .B \- | |
6783 | accepts | |
6784 | .B \-\- | |
6785 | to signify the end of the options. | |
6932f7f5 CR |
6786 | The \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP builtins |
6787 | do not accept options and do not treat \fB\-\-\fP specially. | |
6788 | The \fBexit\fP, \fBlogout\fP, \fBbreak\fP, \fBcontinue\fP, \fBlet\fP, | |
6789 | and \fBshift\fP builtins accept and process arguments beginning with | |
6790 | \fB\-\fP without requiring \fB\-\-\fP. | |
6791 | Other builtins that accept arguments but are not specified as accepting | |
6792 | options interpret arguments beginning with \fB\-\fP as invalid options and | |
6793 | require \fB\-\-\fP to prevent this interpretation. | |
ccc6cda3 | 6794 | .sp .5 |
726f6388 JA |
6795 | .PD 0 |
6796 | .TP | |
6797 | \fB:\fP [\fIarguments\fP] | |
6798 | .PD | |
6799 | No effect; the command does nothing beyond expanding | |
6800 | .I arguments | |
6801 | and performing any specified | |
6802 | redirections. A zero exit code is returned. | |
6803 | .TP | |
726f6388 | 6804 | \fB .\| \fP \fIfilename\fP [\fIarguments\fP] |
7117c2d2 | 6805 | .PD 0 |
726f6388 JA |
6806 | .TP |
6807 | \fBsource\fP \fIfilename\fP [\fIarguments\fP] | |
6808 | .PD | |
6809 | Read and execute commands from | |
6810 | .I filename | |
6811 | in the current | |
6812 | shell environment and return the exit status of the last command | |
6813 | executed from | |
6814 | .IR filename . | |
6815 | If | |
6816 | .I filename | |
b28ff8c9 | 6817 | does not contain a slash, filenames in |
726f6388 JA |
6818 | .SM |
6819 | .B PATH | |
6820 | are used to find the directory containing | |
6821 | .IR filename . | |
6822 | The file searched for in | |
6823 | .SM | |
6824 | .B PATH | |
28ef6c31 JA |
6825 | need not be executable. |
6826 | When \fBbash\fP is not in \fIposix mode\fP, the current directory is | |
726f6388 JA |
6827 | searched if no file is found in |
6828 | .SM | |
6829 | .BR PATH . | |
ccc6cda3 JA |
6830 | If the |
6831 | .B sourcepath | |
6832 | option to the | |
6833 | .B shopt | |
6834 | builtin command is turned off, the | |
6835 | .SM | |
6836 | .B PATH | |
6837 | is not searched. | |
726f6388 | 6838 | If any \fIarguments\fP are supplied, they become the positional |
ccc6cda3 | 6839 | parameters when \fIfilename\fP is executed. Otherwise the positional |
726f6388 JA |
6840 | parameters are unchanged. |
6841 | The return status is the status of the last command exited within | |
6842 | the script (0 if no commands are executed), and false if | |
6843 | .I filename | |
cce855bc | 6844 | is not found or cannot be read. |
726f6388 | 6845 | .TP |
ccc6cda3 JA |
6846 | \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] |
6847 | \fBAlias\fP with no arguments or with the | |
6848 | .B \-p | |
6849 | option prints the list of aliases in the form | |
6850 | \fBalias\fP \fIname\fP=\fIvalue\fP on standard output. | |
6851 | When arguments are supplied, an alias is defined for | |
6852 | each \fIname\fP whose \fIvalue\fP is given. | |
6853 | A trailing space in \fIvalue\fP causes the next word to be | |
6854 | checked for alias substitution when the alias is expanded. | |
6855 | For each \fIname\fP in the argument list for which no \fIvalue\fP | |
6856 | is supplied, the name and value of the alias is printed. | |
6857 | \fBAlias\fP returns true unless a \fIname\fP is given for which | |
6858 | no alias has been defined. | |
726f6388 | 6859 | .TP |
de3341d1 CR |
6860 | \fBbg\fP [\fIjobspec\fP ...] |
6861 | Resume each suspended job \fIjobspec\fP in the background, as if it | |
cce855bc | 6862 | had been started with |
726f6388 | 6863 | .BR & . |
d3ad40de CR |
6864 | If |
6865 | .I jobspec | |
6866 | is not present, the shell's notion of the \fIcurrent job\fP is used. | |
726f6388 JA |
6867 | .B bg |
6868 | .I jobspec | |
6869 | returns 0 unless run when job control is disabled or, when run with | |
ff247e74 CR |
6870 | job control enabled, any specified \fIjobspec\fP was not found |
6871 | or was started without job control. | |
726f6388 | 6872 | .TP |
ba4ab055 | 6873 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSVX\fP] |
7117c2d2 | 6874 | .PD 0 |
cce855bc JA |
6875 | .TP |
6876 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP] | |
726f6388 | 6877 | .TP |
ccc6cda3 | 6878 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP |
726f6388 | 6879 | .TP |
bb70624e JA |
6880 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP |
6881 | .TP | |
ccc6cda3 | 6882 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP |
7117c2d2 JA |
6883 | .TP |
6884 | \fBbind\fP \fIreadline\-command\fP | |
726f6388 JA |
6885 | .PD |
6886 | Display current | |
6887 | .B readline | |
7117c2d2 | 6888 | key and function bindings, bind a key sequence to a |
726f6388 | 6889 | .B readline |
7117c2d2 JA |
6890 | function or macro, or set a |
6891 | .B readline | |
6892 | variable. | |
6893 | Each non-option argument is a command as it would appear in | |
726f6388 | 6894 | .IR .inputrc , |
7117c2d2 JA |
6895 | but each binding or command must be passed as a separate argument; |
6896 | e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. | |
6897 | Options, if supplied, have the following meanings: | |
726f6388 JA |
6898 | .RS |
6899 | .PD 0 | |
6900 | .TP | |
6901 | .B \-m \fIkeymap\fP | |
6902 | Use | |
6903 | .I keymap | |
6904 | as the keymap to be affected by the subsequent bindings. | |
6905 | Acceptable | |
6906 | .I keymap | |
6907 | names are | |
ccc6cda3 | 6908 | \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, |
28ef6c31 | 6909 | vi\-move, vi\-command\fP, and |
ccc6cda3 JA |
6910 | .IR vi\-insert . |
6911 | \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is | |
6912 | equivalent to \fIemacs\-standard\fP. | |
726f6388 JA |
6913 | .TP |
6914 | .B \-l | |
ccc6cda3 JA |
6915 | List the names of all \fBreadline\fP functions. |
6916 | .TP | |
6917 | .B \-p | |
6918 | Display \fBreadline\fP function names and bindings in such a way | |
6919 | that they can be re-read. | |
6920 | .TP | |
6921 | .B \-P | |
6922 | List current \fBreadline\fP function names and bindings. | |
726f6388 | 6923 | .TP |
ccc6cda3 JA |
6924 | .B \-s |
6925 | Display \fBreadline\fP key sequences bound to macros and the strings | |
6926 | they output in such a way that they can be re-read. | |
6927 | .TP | |
6928 | .B \-S | |
6929 | Display \fBreadline\fP key sequences bound to macros and the strings | |
6930 | they output. | |
726f6388 | 6931 | .TP |
d3ad40de CR |
6932 | .B \-v |
6933 | Display \fBreadline\fP variable names and values in such a way that they | |
6934 | can be re-read. | |
6935 | .TP | |
6936 | .B \-V | |
6937 | List current \fBreadline\fP variable names and values. | |
6938 | .TP | |
726f6388 | 6939 | .B \-f \fIfilename\fP |
ccc6cda3 | 6940 | Read key bindings from \fIfilename\fP. |
726f6388 JA |
6941 | .TP |
6942 | .B \-q \fIfunction\fP | |
ccc6cda3 JA |
6943 | Query about which keys invoke the named \fIfunction\fP. |
6944 | .TP | |
cce855bc JA |
6945 | .B \-u \fIfunction\fP |
6946 | Unbind all keys bound to the named \fIfunction\fP. | |
6947 | .TP | |
ccc6cda3 JA |
6948 | .B \-r \fIkeyseq\fP |
6949 | Remove any current binding for \fIkeyseq\fP. | |
bb70624e JA |
6950 | .TP |
6951 | .B \-x \fIkeyseq\fP:\fIshell\-command\fP | |
6952 | Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is | |
6953 | entered. | |
8943768b | 6954 | When \fIshell\-command\fP is executed, the shell sets the |
984a1947 | 6955 | .SM |
8943768b CR |
6956 | .B READLINE_LINE |
6957 | variable to the contents of the \fBreadline\fP line buffer and the | |
984a1947 | 6958 | .SM |
8943768b CR |
6959 | .B READLINE_POINT |
6960 | variable to the current location of the insertion point. | |
6961 | If the executed command changes the value of | |
984a1947 | 6962 | .SM |
8943768b CR |
6963 | .B READLINE_LINE |
6964 | or | |
984a1947 | 6965 | .SM |
8943768b CR |
6966 | .BR READLINE_POINT , |
6967 | those new values will be reflected in the editing state. | |
ba4ab055 CR |
6968 | .TP |
6969 | .B \-X | |
6970 | List all key sequences bound to shell commands and the associated commands | |
6971 | in a format that can be reused as input. | |
726f6388 JA |
6972 | .PD |
6973 | .PP | |
6974 | The return value is 0 unless an unrecognized option is given or an | |
6975 | error occurred. | |
6976 | .RE | |
6977 | .TP | |
6978 | \fBbreak\fP [\fIn\fP] | |
6979 | Exit from within a | |
6980 | .BR for , | |
6981 | .BR while , | |
ccc6cda3 | 6982 | .BR until , |
726f6388 | 6983 | or |
ccc6cda3 | 6984 | .B select |
726f6388 JA |
6985 | loop. If \fIn\fP is specified, break \fIn\fP levels. |
6986 | .I n | |
6987 | must be \(>= 1. If | |
6988 | .I n | |
6989 | is greater than the number of enclosing loops, all enclosing loops | |
33fe8777 CR |
6990 | are exited. |
6991 | The return value is 0 unless \fIn\fP is not greater than or equal to 1. | |
726f6388 JA |
6992 | .TP |
6993 | \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP] | |
6994 | Execute the specified shell builtin, passing it | |
6995 | .IR arguments , | |
6996 | and return its exit status. | |
cce855bc | 6997 | This is useful when defining a |
726f6388 | 6998 | function whose name is the same as a shell builtin, |
cce855bc JA |
6999 | retaining the functionality of the builtin within the function. |
7000 | The \fBcd\fP builtin is commonly redefined this way. | |
7001 | The return status is false if | |
726f6388 JA |
7002 | .I shell\-builtin |
7003 | is not a shell builtin command. | |
7004 | .TP | |
6a8fd0ed CR |
7005 | \fBcaller\fP [\fIexpr\fP] |
7006 | Returns the context of any active subroutine call (a shell function or | |
5cdaaf76 | 7007 | a script executed with the \fB.\fP or \fBsource\fP builtins). |
6a8fd0ed CR |
7008 | Without \fIexpr\fP, \fBcaller\fP displays the line number and source |
7009 | filename of the current subroutine call. | |
7010 | If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP | |
7011 | displays the line number, subroutine name, and source file corresponding | |
7012 | to that position in the current execution call stack. This extra | |
7013 | information may be used, for example, to print a stack trace. The | |
7014 | current frame is frame 0. | |
7015 | The return value is 0 unless the shell is not executing a subroutine | |
7016 | call or \fIexpr\fP does not correspond to a valid position in the | |
7017 | call stack. | |
7018 | .TP | |
220537f2 | 7019 | \fBcd\fP [\fB\-L\fP|[\fB\-P\fP [\fB\-e\fP]]] [\fIdir\fP] |
2dead0c4 CR |
7020 | Change the current directory to \fIdir\fP. |
7021 | if \fIdir\fP is not supplied, the value of the | |
726f6388 JA |
7022 | .SM |
7023 | .B HOME | |
2dead0c4 CR |
7024 | shell variable is the default. |
7025 | Any additional arguments following \fIdir\fP are ignored. | |
726f6388 JA |
7026 | The variable |
7027 | .SM | |
7028 | .B CDPATH | |
ccc6cda3 | 7029 | defines the search path for the directory containing |
45c0f7f8 CR |
7030 | .IR dir : |
7031 | each directory name in | |
7032 | .SM | |
7033 | .B CDPATH | |
7034 | is searched for \fIdir\fP. | |
ccc6cda3 JA |
7035 | Alternative directory names in |
7036 | .SM | |
7037 | .B CDPATH | |
7038 | are separated by a colon (:). A null directory name in | |
726f6388 JA |
7039 | .SM |
7040 | .B CDPATH | |
ccc6cda3 | 7041 | is the same as the current directory, i.e., ``\fB.\fP''. If |
726f6388 JA |
7042 | .I dir |
7043 | begins with a slash (/), | |
7044 | then | |
7045 | .SM | |
7046 | .B CDPATH | |
ccc6cda3 JA |
7047 | is not used. The |
7048 | .B \-P | |
45c0f7f8 CR |
7049 | option causes \fBcd\fP to use the physical directory structure |
7050 | by resolving symbolic links while traversing \fIdir\fP and | |
7051 | before processing instances of \fI..\fP in \fIdir\fP (see also the | |
ccc6cda3 JA |
7052 | .B \-P |
7053 | option to the | |
7054 | .B set | |
7055 | builtin command); the | |
7056 | .B \-L | |
45c0f7f8 CR |
7057 | option forces symbolic links to be followed by resolving the link |
7058 | after processing instances of \fI..\fP in \fIdir\fP. | |
7059 | If \fI..\fP appears in \fIdir\fP, it is processed by removing the | |
7060 | immediately previous pathname component from \fIdir\fP, back to a slash | |
7061 | or the beginning of \fIdir\fP. | |
220537f2 CR |
7062 | If the |
7063 | .B \-e | |
7064 | option is supplied with | |
7065 | .BR \-P , | |
7066 | and the current working directory cannot be successfully determined | |
7067 | after a successful directory change, \fBcd\fP will return an unsuccessful | |
7068 | status. | |
7069 | An argument of | |
726f6388 | 7070 | .B \- |
19baff85 | 7071 | is converted to |
726f6388 | 7072 | .SM |
19baff85 CR |
7073 | .B $OLDPWD |
7074 | before the directory change is attempted. | |
984a1947 CR |
7075 | If a non-empty directory name from |
7076 | .SM | |
7077 | .B CDPATH | |
7078 | is used, or if | |
d3a24ed2 CR |
7079 | \fB\-\fP is the first argument, and the directory change is |
7080 | successful, the absolute pathname of the new working directory is | |
7081 | written to the standard output. | |
726f6388 JA |
7082 | The return value is true if the directory was successfully changed; |
7083 | false otherwise. | |
7084 | .TP | |
ccc6cda3 | 7085 | \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...] |
726f6388 JA |
7086 | Run |
7087 | .I command | |
7088 | with | |
7089 | .I args | |
7090 | suppressing the normal shell function lookup. Only builtin | |
7091 | commands or commands found in the | |
7092 | .SM | |
7093 | .B PATH | |
7094 | are executed. If the | |
7095 | .B \-p | |
7096 | option is given, the search for | |
7097 | .I command | |
7098 | is performed using a default value for | |
984a1947 | 7099 | .SM |
726f6388 JA |
7100 | .B PATH |
7101 | that is guaranteed to find all of the standard utilities. | |
7102 | If either the | |
7103 | .B \-V | |
7104 | or | |
7105 | .B \-v | |
7106 | option is supplied, a description of | |
7107 | .I command | |
7108 | is printed. The | |
7109 | .B \-v | |
b28ff8c9 | 7110 | option causes a single word indicating the command or filename |
726f6388 JA |
7111 | used to invoke |
7112 | .I command | |
cce855bc | 7113 | to be displayed; the |
726f6388 JA |
7114 | .B \-V |
7115 | option produces a more verbose description. | |
726f6388 JA |
7116 | If the |
7117 | .B \-V | |
7118 | or | |
7119 | .B \-v | |
7120 | option is supplied, the exit status is 0 if | |
7121 | .I command | |
7122 | was found, and 1 if not. If neither option is supplied and | |
7123 | an error occurred or | |
7124 | .I command | |
7125 | cannot be found, the exit status is 127. Otherwise, the exit status of the | |
7126 | .B command | |
7127 | builtin is the exit status of | |
7128 | .IR command . | |
7129 | .TP | |
bb70624e JA |
7130 | \fBcompgen\fP [\fIoption\fP] [\fIword\fP] |
7131 | Generate possible completion matches for \fIword\fP according to | |
7132 | the \fIoption\fPs, which may be any option accepted by the | |
7133 | .B complete | |
7134 | builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write | |
7135 | the matches to the standard output. | |
7136 | When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables | |
7137 | set by the programmable completion facilities, while available, will not | |
7138 | have useful values. | |
7139 | .sp 1 | |
7140 | The matches will be generated in the same way as if the programmable | |
7141 | completion code had generated them directly from a completion specification | |
7142 | with the same flags. | |
7143 | If \fIword\fP is specified, only those completions matching \fIword\fP | |
7144 | will be displayed. | |
7145 | .sp 1 | |
7146 | The return value is true unless an invalid option is supplied, or no | |
7147 | matches were generated. | |
7148 | .TP | |
3eb2d94a | 7149 | \fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-DE\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] |
bb70624e | 7150 | .br |
d3ad40de | 7151 | [\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname ...\fP] |
7117c2d2 | 7152 | .PD 0 |
bb70624e | 7153 | .TP |
3eb2d94a | 7154 | \fBcomplete\fP \fB\-pr\fP [\fB\-DE\fP] [\fIname\fP ...] |
bb70624e JA |
7155 | .PD |
7156 | Specify how arguments to each \fIname\fP should be completed. | |
7157 | If the \fB\-p\fP option is supplied, or if no options are supplied, | |
7158 | existing completion specifications are printed in a way that allows | |
7159 | them to be reused as input. | |
7160 | The \fB\-r\fP option removes a completion specification for | |
7161 | each \fIname\fP, or, if no \fIname\fPs are supplied, all | |
7162 | completion specifications. | |
3eb2d94a CR |
7163 | The \fB\-D\fP option indicates that the remaining options and actions should |
7164 | apply to the ``default'' command completion; that is, completion attempted | |
7165 | on a command for which no completion has previously been defined. | |
6a8fd0ed CR |
7166 | The \fB\-E\fP option indicates that the remaining options and actions should |
7167 | apply to ``empty'' command completion; that is, completion attempted on a | |
7168 | blank line. | |
bb70624e JA |
7169 | .sp 1 |
7170 | The process of applying these completion specifications when word completion | |
7171 | is attempted is described above under \fBProgrammable Completion\fP. | |
7172 | .sp 1 | |
7173 | Other options, if specified, have the following meanings. | |
7174 | The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options | |
7175 | (and, if necessary, the \fB\-P\fP and \fB\-S\fP options) | |
7176 | should be quoted to protect them from expansion before the | |
7177 | .B complete | |
7178 | builtin is invoked. | |
7179 | .RS | |
7180 | .PD 0 | |
7181 | .TP 8 | |
28ef6c31 JA |
7182 | \fB\-o\fP \fIcomp-option\fP |
7183 | The \fIcomp-option\fP controls several aspects of the compspec's behavior | |
7184 | beyond the simple generation of completions. | |
7185 | \fIcomp-option\fP may be one of: | |
7186 | .RS | |
7187 | .TP 8 | |
d3a24ed2 CR |
7188 | .B bashdefault |
7189 | Perform the rest of the default \fBbash\fP completions if the compspec | |
7190 | generates no matches. | |
7191 | .TP 8 | |
28ef6c31 | 7192 | .B default |
7117c2d2 JA |
7193 | Use readline's default filename completion if the compspec generates |
7194 | no matches. | |
28ef6c31 JA |
7195 | .TP 8 |
7196 | .B dirnames | |
7197 | Perform directory name completion if the compspec generates no matches. | |
7198 | .TP 8 | |
7199 | .B filenames | |
7200 | Tell readline that the compspec generates filenames, so it can perform any | |
e77a3058 CR |
7201 | filename\-specific processing (like adding a slash to directory names, |
7202 | quoting special characters, or suppressing trailing spaces). | |
7203 | Intended to be used with shell functions. | |
7117c2d2 | 7204 | .TP 8 |
084c952b CR |
7205 | .B noquote |
7206 | Tell readline not to quote the completed words if they are filenames | |
7207 | (quoting filenames is the default). | |
7208 | .TP 8 | |
7117c2d2 JA |
7209 | .B nospace |
7210 | Tell readline not to append a space (the default) to words completed at | |
7211 | the end of the line. | |
301e2142 CR |
7212 | .TP 8 |
7213 | .B plusdirs | |
7214 | After any matches defined by the compspec are generated, | |
7215 | directory name completion is attempted and any | |
7216 | matches are added to the results of the other actions. | |
28ef6c31 JA |
7217 | .RE |
7218 | .TP 8 | |
bb70624e JA |
7219 | \fB\-A\fP \fIaction\fP |
7220 | The \fIaction\fP may be one of the following to generate a list of possible | |
7221 | completions: | |
7222 | .RS | |
7223 | .TP 8 | |
7224 | .B alias | |
7225 | Alias names. May also be specified as \fB\-a\fP. | |
7226 | .TP 8 | |
7227 | .B arrayvar | |
7228 | Array variable names. | |
7229 | .TP 8 | |
7230 | .B binding | |
7231 | \fBReadline\fP key binding names. | |
7232 | .TP 8 | |
7233 | .B builtin | |
7234 | Names of shell builtin commands. May also be specified as \fB\-b\fP. | |
7235 | .TP 8 | |
7236 | .B command | |
7237 | Command names. May also be specified as \fB\-c\fP. | |
7238 | .TP 8 | |
7239 | .B directory | |
7240 | Directory names. May also be specified as \fB\-d\fP. | |
7241 | .TP 8 | |
7242 | .B disabled | |
7243 | Names of disabled shell builtins. | |
7244 | .TP 8 | |
7245 | .B enabled | |
7246 | Names of enabled shell builtins. | |
7247 | .TP 8 | |
7248 | .B export | |
7249 | Names of exported shell variables. May also be specified as \fB\-e\fP. | |
7250 | .TP 8 | |
7251 | .B file | |
7252 | File names. May also be specified as \fB\-f\fP. | |
7253 | .TP 8 | |
7254 | .B function | |
7255 | Names of shell functions. | |
7256 | .TP 8 | |
f73dda09 JA |
7257 | .B group |
7258 | Group names. May also be specified as \fB\-g\fP. | |
7259 | .TP 8 | |
bb70624e JA |
7260 | .B helptopic |
7261 | Help topics as accepted by the \fBhelp\fP builtin. | |
7262 | .TP 8 | |
7263 | .B hostname | |
7264 | Hostnames, as taken from the file specified by the | |
7265 | .SM | |
7266 | .B HOSTFILE | |
7267 | shell variable. | |
7268 | .TP 8 | |
7269 | .B job | |
7270 | Job names, if job control is active. May also be specified as \fB\-j\fP. | |
7271 | .TP 8 | |
7272 | .B keyword | |
7273 | Shell reserved words. May also be specified as \fB\-k\fP. | |
7274 | .TP 8 | |
7275 | .B running | |
7276 | Names of running jobs, if job control is active. | |
7277 | .TP 8 | |
7117c2d2 JA |
7278 | .B service |
7279 | Service names. May also be specified as \fB\-s\fP. | |
7280 | .TP 8 | |
bb70624e JA |
7281 | .B setopt |
7282 | Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin. | |
7283 | .TP 8 | |
7284 | .B shopt | |
7285 | Shell option names as accepted by the \fBshopt\fP builtin. | |
7286 | .TP 8 | |
7287 | .B signal | |
7288 | Signal names. | |
7289 | .TP 8 | |
7290 | .B stopped | |
7291 | Names of stopped jobs, if job control is active. | |
7292 | .TP 8 | |
7293 | .B user | |
7294 | User names. May also be specified as \fB\-u\fP. | |
7295 | .TP 8 | |
7296 | .B variable | |
7297 | Names of all shell variables. May also be specified as \fB\-v\fP. | |
7298 | .RE | |
7299 | .TP 8 | |
bb70624e JA |
7300 | \fB\-C\fP \fIcommand\fP |
7301 | \fIcommand\fP is executed in a subshell environment, and its output is | |
7302 | used as the possible completions. | |
7303 | .TP 8 | |
7304 | \fB\-F\fP \fIfunction\fP | |
7305 | The shell function \fIfunction\fP is executed in the current shell | |
7306 | environment. | |
ba4ab055 CR |
7307 | When the function is executed, |
7308 | the first argument (\fB$1\fP) is the name of the command whose arguments are | |
7309 | being completed, | |
7310 | the second argument (\fB$2\fP) is the word being completed, | |
7311 | and the third argument (\fB$3\fP) is the word preceding the word being | |
7312 | completed on the current command line. | |
bb70624e JA |
7313 | When it finishes, the possible completions are retrieved from the value |
7314 | of the | |
7315 | .SM | |
7316 | .B COMPREPLY | |
7317 | array variable. | |
7318 | .TP 8 | |
5cdaaf76 CR |
7319 | \fB\-G\fP \fIglobpat\fP |
7320 | The pathname expansion pattern \fIglobpat\fP is expanded to generate | |
7321 | the possible completions. | |
bb70624e JA |
7322 | .TP 8 |
7323 | \fB\-P\fP \fIprefix\fP | |
7324 | \fIprefix\fP is added at the beginning of each possible completion | |
7325 | after all other options have been applied. | |
7326 | .TP 8 | |
7327 | \fB\-S\fP \fIsuffix\fP | |
7328 | \fIsuffix\fP is appended to each possible completion | |
7329 | after all other options have been applied. | |
5cdaaf76 CR |
7330 | .TP 8 |
7331 | \fB\-W\fP \fIwordlist\fP | |
7332 | The \fIwordlist\fP is split using the characters in the | |
7333 | .SM | |
7334 | .B IFS | |
7335 | special variable as delimiters, and each resultant word is expanded. | |
7336 | The possible completions are the members of the resultant list which | |
7337 | match the word being completed. | |
7338 | .TP 8 | |
7339 | \fB\-X\fP \fIfilterpat\fP | |
7340 | \fIfilterpat\fP is a pattern as used for pathname expansion. | |
7341 | It is applied to the list of possible completions generated by the | |
7342 | preceding options and arguments, and each completion matching | |
7343 | \fIfilterpat\fP is removed from the list. | |
7344 | A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this | |
7345 | case, any completion not matching \fIfilterpat\fP is removed. | |
bb70624e JA |
7346 | .PD |
7347 | .PP | |
7348 | The return value is true unless an invalid option is supplied, an option | |
7349 | other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP | |
7350 | argument, an attempt is made to remove a completion specification for | |
7351 | a \fIname\fP for which no specification exists, or | |
7352 | an error occurs adding a completion specification. | |
7353 | .RE | |
7354 | .TP | |
3eb2d94a | 7355 | \fBcompopt\fP [\fB\-o\fP \fIoption\fP] [\fB\-DE\fP] [\fB+o\fP \fIoption\fP] [\fIname\fP] |
6fbe7620 CR |
7356 | Modify completion options for each \fIname\fP according to the |
7357 | \fIoption\fPs, or for the | |
5cdaaf76 | 7358 | currently-executing completion if no \fIname\fPs are supplied. |
6fbe7620 CR |
7359 | If no \fIoption\fPs are given, display the completion options for each |
7360 | \fIname\fP or the current completion. | |
7361 | The possible values of \fIoption\fP are those valid for the \fBcomplete\fP | |
7362 | builtin described above. | |
3eb2d94a CR |
7363 | The \fB\-D\fP option indicates that the remaining options should |
7364 | apply to the ``default'' command completion; that is, completion attempted | |
7365 | on a command for which no completion has previously been defined. | |
7366 | The \fB\-E\fP option indicates that the remaining options should | |
7367 | apply to ``empty'' command completion; that is, completion attempted on a | |
7368 | blank line. | |
9c7f20c7 | 7369 | .sp 1 |
6fbe7620 CR |
7370 | The return value is true unless an invalid option is supplied, an attempt |
7371 | is made to modify the options for a \fIname\fP for which no completion | |
7372 | specification exists, or an output error occurs. | |
7373 | .TP | |
726f6388 JA |
7374 | \fBcontinue\fP [\fIn\fP] |
7375 | Resume the next iteration of the enclosing | |
7376 | .BR for , | |
7377 | .BR while , | |
ccc6cda3 | 7378 | .BR until , |
726f6388 | 7379 | or |
ccc6cda3 | 7380 | .B select |
726f6388 JA |
7381 | loop. |
7382 | If | |
7383 | .I n | |
7384 | is specified, resume at the \fIn\fPth enclosing loop. | |
7385 | .I n | |
7386 | must be \(>= 1. If | |
7387 | .I n | |
7388 | is greater than the number of enclosing loops, the last enclosing loop | |
33fe8777 CR |
7389 | (the ``top-level'' loop) is resumed. |
7390 | The return value is 0 unless \fIn\fP is not greater than or equal to 1. | |
726f6388 | 7391 | .TP |
87c1f4ec | 7392 | \fBdeclare\fP [\fB\-aAfFgilnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] |
726f6388 | 7393 | .PD 0 |
726f6388 | 7394 | .TP |
87c1f4ec | 7395 | \fBtypeset\fP [\fB\-aAfFgilnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] |
726f6388 | 7396 | .PD |
ccc6cda3 JA |
7397 | Declare variables and/or give them attributes. |
7398 | If no \fIname\fPs are given then display the values of variables. | |
7399 | The | |
7400 | .B \-p | |
7401 | option will display the attributes and values of each | |
7402 | .IR name . | |
7403 | When | |
7404 | .B \-p | |
1442f67c CR |
7405 | is used with \fIname\fP arguments, additional options, |
7406 | other than \fB\-f\fP and \fB\-F\fP, are ignored. | |
6fbe7620 CR |
7407 | When |
7408 | .B \-p | |
7409 | is supplied without \fIname\fP arguments, it will display the attributes | |
7410 | and values of all variables having the attributes specified by the | |
7411 | additional options. | |
7412 | If no other options are supplied with \fB\-p\fP, \fBdeclare\fP will display | |
7413 | the attributes and values of all shell variables. The \fB\-f\fP option | |
7414 | will restrict the display to shell functions. | |
ccc6cda3 JA |
7415 | The |
7416 | .B \-F | |
7417 | option inhibits the display of function definitions; only the | |
7418 | function name and attributes are printed. | |
d3a24ed2 CR |
7419 | If the \fBextdebug\fP shell option is enabled using \fBshopt\fP, |
7420 | the source file name and line number where the function is defined | |
7421 | are displayed as well. The | |
ccc6cda3 JA |
7422 | .B \-F |
7423 | option implies | |
7424 | .BR \-f . | |
6faad625 CR |
7425 | The |
7426 | .B \-g | |
7427 | option forces variables to be created or modified at the global scope, | |
7428 | even when \fBdeclare\fP is executed in a shell function. | |
7429 | It is ignored in all other cases. | |
ccc6cda3 JA |
7430 | The following options can |
7431 | be used to restrict output to variables with the specified attribute or | |
7432 | to give variables attributes: | |
726f6388 JA |
7433 | .RS |
7434 | .PD 0 | |
7435 | .TP | |
ccc6cda3 | 7436 | .B \-a |
fdf670ea CR |
7437 | Each \fIname\fP is an indexed array variable (see |
7438 | .B Arrays | |
7439 | above). | |
7440 | .TP | |
7441 | .B \-A | |
7442 | Each \fIname\fP is an associative array variable (see | |
ccc6cda3 JA |
7443 | .B Arrays |
7444 | above). | |
7445 | .TP | |
726f6388 | 7446 | .B \-f |
ccc6cda3 JA |
7447 | Use function names only. |
7448 | .TP | |
7449 | .B \-i | |
7450 | The variable is treated as an integer; arithmetic evaluation (see | |
7451 | .SM | |
984a1947 CR |
7452 | .B "ARITHMETIC EVALUATION" |
7453 | above) is performed when the variable is assigned a value. | |
726f6388 | 7454 | .TP |
09767ff0 CR |
7455 | .B \-l |
7456 | When the variable is assigned a value, all upper-case characters are | |
7457 | converted to lower-case. | |
7458 | The upper-case attribute is disabled. | |
7459 | .TP | |
87c1f4ec CR |
7460 | .B \-n |
7461 | Give each \fIname\fP the \fInameref\fP attribute, making | |
7462 | it a name reference to another variable. | |
7463 | That other variable is defined by the value of \fIname\fP. | |
7464 | All references and assignments to \fIname\fP, except for changing the | |
7465 | \fB\-n\fP attribute itself, are performed on the variable referenced by | |
7466 | \fIname\fP's value. | |
7467 | The \fB\-n\fP attribute cannot be applied to array variables. | |
7468 | .TP | |
726f6388 JA |
7469 | .B \-r |
7470 | Make \fIname\fPs readonly. These names cannot then be assigned values | |
cce855bc | 7471 | by subsequent assignment statements or unset. |
726f6388 | 7472 | .TP |
7117c2d2 JA |
7473 | .B \-t |
7474 | Give each \fIname\fP the \fItrace\fP attribute. | |
76a8d78d CR |
7475 | Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from |
7476 | the calling shell. | |
7117c2d2 JA |
7477 | The trace attribute has no special meaning for variables. |
7478 | .TP | |
09767ff0 CR |
7479 | .B \-u |
7480 | When the variable is assigned a value, all lower-case characters are | |
7481 | converted to upper-case. | |
7482 | The lower-case attribute is disabled. | |
7483 | .TP | |
726f6388 JA |
7484 | .B \-x |
7485 | Mark \fIname\fPs for export to subsequent commands via the environment. | |
726f6388 JA |
7486 | .PD |
7487 | .PP | |
7488 | Using `+' instead of `\-' | |
d3ad40de CR |
7489 | turns off the attribute instead, |
7490 | with the exceptions that \fB+a\fP | |
984a1947 | 7491 | may not be used to destroy an array variable and \fB+r\fP will not |
d3ad40de | 7492 | remove the readonly attribute. |
b28ff8c9 CR |
7493 | When used in a function, |
7494 | .B declare | |
7495 | and | |
7496 | .B typeset | |
7497 | make each | |
54a1fa7c | 7498 | \fIname\fP local, as with the |
726f6388 | 7499 | .B local |
6faad625 | 7500 | command, |
b28ff8c9 | 7501 | unless the \fB\-g\fP option is supplied. |
d3a24ed2 CR |
7502 | If a variable name is followed by =\fIvalue\fP, the value of |
7503 | the variable is set to \fIvalue\fP. | |
7504 | The return value is 0 unless an invalid option is encountered, | |
bb70624e JA |
7505 | an attempt is made to define a function using |
7506 | .if n ``\-f foo=bar'', | |
7507 | .if t \f(CW\-f foo=bar\fP, | |
ccc6cda3 JA |
7508 | an attempt is made to assign a value to a readonly variable, |
7509 | an attempt is made to assign a value to an array variable without | |
7510 | using the compound assignment syntax (see | |
7511 | .B Arrays | |
cce855bc | 7512 | above), one of the \fInames\fP is not a valid shell variable name, |
726f6388 | 7513 | an attempt is made to turn off readonly status for a readonly variable, |
ccc6cda3 | 7514 | an attempt is made to turn off array status for an array variable, |
bb70624e | 7515 | or an attempt is made to display a non-existent function with \fB\-f\fP. |
726f6388 JA |
7516 | .RE |
7517 | .TP | |
b28ff8c9 | 7518 | .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP] |
ccc6cda3 JA |
7519 | Without options, displays the list of currently remembered directories. |
7520 | The default display is on a single line with directory names separated | |
7521 | by spaces. | |
7522 | Directories are added to the list with the | |
726f6388 JA |
7523 | .B pushd |
7524 | command; the | |
7525 | .B popd | |
ccc6cda3 | 7526 | command removes entries from the list. |
726f6388 JA |
7527 | .RS |
7528 | .PD 0 | |
7529 | .TP | |
ccc6cda3 JA |
7530 | .B \-c |
7531 | Clears the directory stack by deleting all of the entries. | |
7532 | .TP | |
726f6388 | 7533 | .B \-l |
b28ff8c9 CR |
7534 | Produces a listing using full pathnames; |
7535 | the default listing format uses a tilde to denote the home directory. | |
ccc6cda3 JA |
7536 | .TP |
7537 | .B \-p | |
7538 | Print the directory stack with one entry per line. | |
7539 | .TP | |
7540 | .B \-v | |
7541 | Print the directory stack with one entry per line, | |
7542 | prefixing each entry with its index in the stack. | |
b28ff8c9 CR |
7543 | .TP |
7544 | \fB+\fP\fIn\fP | |
7545 | Displays the \fIn\fPth entry counting from the left of the list | |
7546 | shown by | |
7547 | .B dirs | |
7548 | when invoked without options, starting with zero. | |
7549 | .TP | |
7550 | \fB\-\fP\fIn\fP | |
7551 | Displays the \fIn\fPth entry counting from the right of the list | |
7552 | shown by | |
7553 | .B dirs | |
7554 | when invoked without options, starting with zero. | |
726f6388 JA |
7555 | .PD |
7556 | .PP | |
7557 | The return value is 0 unless an | |
cce855bc | 7558 | invalid option is supplied or \fIn\fP indexes beyond the end |
726f6388 JA |
7559 | of the directory stack. |
7560 | .RE | |
7561 | .TP | |
cce855bc | 7562 | \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...] |
b28ff8c9 | 7563 | Without options, remove each |
ccc6cda3 | 7564 | .I jobspec |
b28ff8c9 | 7565 | from the table of active jobs. |
d3ad40de CR |
7566 | If |
7567 | .I jobspec | |
984a1947 | 7568 | is not present, and neither \fB\-a\fP nor \fB\-r\fP is supplied, |
d3ad40de | 7569 | the shell's notion of the \fIcurrent job\fP is used. |
cce855bc JA |
7570 | If the \fB\-h\fP option is given, each |
7571 | .I jobspec | |
7572 | is not removed from the table, but is marked so that | |
ccc6cda3 JA |
7573 | .SM |
7574 | .B SIGHUP | |
7575 | is not sent to the job if the shell receives a | |
7576 | .SM | |
7577 | .BR SIGHUP . | |
7578 | If no | |
7579 | .I jobspec | |
cce855bc JA |
7580 | is present, and neither the |
7581 | .B \-a | |
7582 | nor the | |
7583 | .B \-r | |
7584 | option is supplied, the \fIcurrent job\fP is used. | |
7585 | If no | |
7586 | .I jobspec | |
7587 | is supplied, the | |
7588 | .B \-a | |
7589 | option means to remove or mark all jobs; the | |
7590 | .B \-r | |
7591 | option without a | |
7592 | .I jobspec | |
7593 | argument restricts operation to running jobs. | |
7594 | The return value is 0 unless a | |
ccc6cda3 JA |
7595 | .I jobspec |
7596 | does not specify a valid job. | |
7597 | .TP | |
726f6388 | 7598 | \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...] |
ccc6cda3 | 7599 | Output the \fIarg\fPs, separated by spaces, followed by a newline. |
f6da9f85 | 7600 | The return status is 0 unless a write error occurs. |
ccc6cda3 | 7601 | If \fB\-n\fP is specified, the trailing newline is |
726f6388 JA |
7602 | suppressed. If the \fB\-e\fP option is given, interpretation of |
7603 | the following backslash-escaped characters is enabled. The | |
7604 | .B \-E | |
7605 | option disables the interpretation of these escape characters, | |
7606 | even on systems where they are interpreted by default. | |
28ef6c31 | 7607 | The \fBxpg_echo\fP shell option may be used to |
bb70624e JA |
7608 | dynamically determine whether or not \fBecho\fP expands these |
7609 | escape characters by default. | |
ccc6cda3 | 7610 | .B echo |
3ffb039a | 7611 | does not interpret \fB\-\-\fP to mean the end of options. |
ccc6cda3 JA |
7612 | .B echo |
7613 | interprets the following escape sequences: | |
726f6388 JA |
7614 | .RS |
7615 | .PD 0 | |
7616 | .TP | |
7617 | .B \ea | |
7618 | alert (bell) | |
7619 | .TP | |
7620 | .B \eb | |
7621 | backspace | |
7622 | .TP | |
7623 | .B \ec | |
2e4498b3 | 7624 | suppress further output |
726f6388 | 7625 | .TP |
ccc6cda3 | 7626 | .B \ee |
9ec5ed66 CR |
7627 | .TP |
7628 | .B \eE | |
ccc6cda3 JA |
7629 | an escape character |
7630 | .TP | |
726f6388 JA |
7631 | .B \ef |
7632 | form feed | |
7633 | .TP | |
7634 | .B \en | |
7635 | new line | |
7636 | .TP | |
7637 | .B \er | |
7638 | carriage return | |
7639 | .TP | |
7640 | .B \et | |
7641 | horizontal tab | |
7642 | .TP | |
7643 | .B \ev | |
7644 | vertical tab | |
7645 | .TP | |
7646 | .B \e\e | |
7647 | backslash | |
7648 | .TP | |
7117c2d2 JA |
7649 | .B \e0\fInnn\fP |
7650 | the eight-bit character whose value is the octal value \fInnn\fP | |
7651 | (zero to three octal digits) | |
7652 | .TP | |
f73dda09 JA |
7653 | .B \ex\fIHH\fP |
7654 | the eight-bit character whose value is the hexadecimal value \fIHH\fP | |
7655 | (one or two hex digits) | |
eb0b2ad8 CR |
7656 | .TP |
7657 | .B \eu\fIHHHH\fP | |
7658 | the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value | |
7659 | \fIHHHH\fP (one to four hex digits) | |
7660 | .TP | |
7661 | .B \eU\fIHHHHHHHH\fP | |
7662 | the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value | |
7663 | \fIHHHHHHHH\fP (one to eight hex digits) | |
726f6388 JA |
7664 | .PD |
7665 | .RE | |
7666 | .TP | |
d3ad40de | 7667 | \fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...] |
cce855bc JA |
7668 | Enable and disable builtin shell commands. |
7669 | Disabling a builtin allows a disk command which has the same name | |
bb70624e | 7670 | as a shell builtin to be executed without specifying a full pathname, |
cce855bc | 7671 | even though the shell normally searches for builtins before disk commands. |
726f6388 JA |
7672 | If \fB\-n\fP is used, each \fIname\fP |
7673 | is disabled; otherwise, | |
7674 | \fInames\fP are enabled. For example, to use the | |
7675 | .B test | |
7676 | binary found via the | |
7677 | .SM | |
7678 | .B PATH | |
ccc6cda3 | 7679 | instead of the shell builtin version, run |
28ef6c31 JA |
7680 | .if t \f(CWenable -n test\fP. |
7681 | .if n ``enable -n test''. | |
ccc6cda3 JA |
7682 | The |
7683 | .B \-f | |
7684 | option means to load the new builtin command | |
7685 | .I name | |
7686 | from shared object | |
7687 | .IR filename , | |
7688 | on systems that support dynamic loading. The | |
7689 | .B \-d | |
7690 | option will delete a builtin previously loaded with | |
7691 | .BR \-f . | |
7692 | If no \fIname\fP arguments are given, or if the | |
7693 | .B \-p | |
7694 | option is supplied, a list of shell builtins is printed. | |
7695 | With no other option arguments, the list consists of all enabled | |
7696 | shell builtins. | |
7697 | If \fB\-n\fP is supplied, only disabled builtins are printed. | |
7698 | If \fB\-a\fP is supplied, the list printed includes all builtins, with an | |
726f6388 | 7699 | indication of whether or not each is enabled. |
ccc6cda3 JA |
7700 | If \fB\-s\fP is supplied, the output is restricted to the POSIX |
7701 | \fIspecial\fP builtins. | |
726f6388 JA |
7702 | The return value is 0 unless a |
7703 | .I name | |
bb70624e | 7704 | is not a shell builtin or there is an error loading a new builtin |
ccc6cda3 | 7705 | from a shared object. |
726f6388 JA |
7706 | .TP |
7707 | \fBeval\fP [\fIarg\fP ...] | |
7708 | The \fIarg\fPs are read and concatenated together into a single | |
7709 | command. This command is then read and executed by the shell, and | |
ccc6cda3 JA |
7710 | its exit status is returned as the value of |
7711 | .BR eval . | |
7712 | If there are no | |
726f6388 JA |
7713 | .IR args , |
7714 | or only null arguments, | |
7715 | .B eval | |
ccc6cda3 | 7716 | returns 0. |
726f6388 | 7717 | .TP |
cce855bc | 7718 | \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]] |
726f6388 JA |
7719 | If |
7720 | .I command | |
7721 | is specified, it replaces the shell. | |
7722 | No new process is created. The | |
7723 | .I arguments | |
7724 | become the arguments to \fIcommand\fP. | |
ccc6cda3 JA |
7725 | If the |
7726 | .B \-l | |
7727 | option is supplied, | |
d3ad40de | 7728 | the shell places a dash at the beginning of the zeroth argument passed to |
726f6388 | 7729 | .IR command . |
ccc6cda3 JA |
7730 | This is what |
7731 | .IR login (1) | |
7732 | does. The | |
7733 | .B \-c | |
7734 | option causes | |
7735 | .I command | |
7736 | to be executed with an empty environment. If | |
7737 | .B \-a | |
7738 | is supplied, the shell passes | |
7739 | .I name | |
b28ff8c9 CR |
7740 | as the zeroth argument to the executed command. |
7741 | If | |
ccc6cda3 | 7742 | .I command |
726f6388 | 7743 | cannot be executed for some reason, a non-interactive shell exits, |
b28ff8c9 | 7744 | unless the |
ccc6cda3 | 7745 | .B execfail |
b28ff8c9 CR |
7746 | shell option |
7747 | is enabled. In that case, it returns failure. | |
ccc6cda3 | 7748 | An interactive shell returns failure if the file cannot be executed. |
726f6388 JA |
7749 | If |
7750 | .I command | |
7751 | is not specified, any redirections take effect in the current shell, | |
cce855bc JA |
7752 | and the return status is 0. If there is a redirection error, the |
7753 | return status is 1. | |
726f6388 JA |
7754 | .TP |
7755 | \fBexit\fP [\fIn\fP] | |
7756 | Cause the shell to exit | |
7757 | with a status of \fIn\fP. If | |
7758 | .I n | |
7759 | is omitted, the exit status | |
7760 | is that of the last command executed. | |
7761 | A trap on | |
7762 | .SM | |
7763 | .B EXIT | |
7764 | is executed before the shell terminates. | |
7765 | .TP | |
ccc6cda3 | 7766 | \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ... |
7117c2d2 | 7767 | .PD 0 |
726f6388 JA |
7768 | .TP |
7769 | .B export \-p | |
7770 | .PD | |
7771 | The supplied | |
7772 | .I names | |
7773 | are marked for automatic export to the environment of | |
7774 | subsequently executed commands. If the | |
7775 | .B \-f | |
7776 | option is given, | |
7777 | the | |
7778 | .I names | |
7779 | refer to functions. | |
7780 | If no | |
7781 | .I names | |
7782 | are given, or if the | |
7783 | .B \-p | |
7784 | option is supplied, a list | |
b28ff8c9 | 7785 | of names of all exported variables is printed. |
726f6388 JA |
7786 | The |
7787 | .B \-n | |
5e13499c CR |
7788 | option causes the export property to be removed from each |
7789 | \fIname\fP. | |
d3a24ed2 CR |
7790 | If a variable name is followed by =\fIword\fP, the value of |
7791 | the variable is set to \fIword\fP. | |
726f6388 | 7792 | .B export |
cce855bc | 7793 | returns an exit status of 0 unless an invalid option is |
726f6388 | 7794 | encountered, |
cce855bc | 7795 | one of the \fInames\fP is not a valid shell variable name, or |
726f6388 JA |
7796 | .B \-f |
7797 | is supplied with a | |
7798 | .I name | |
7799 | that is not a function. | |
7800 | .TP | |
d3ad40de | 7801 | \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP] |
7117c2d2 | 7802 | .PD 0 |
726f6388 JA |
7803 | .TP |
7804 | \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP] | |
7805 | .PD | |
b28ff8c9 | 7806 | The first form selects a range of commands from |
726f6388 JA |
7807 | .I first |
7808 | to | |
7809 | .I last | |
b28ff8c9 | 7810 | from the history list and displays or edits and re-executes them. |
726f6388 JA |
7811 | .I First |
7812 | and | |
7813 | .I last | |
7814 | may be specified as a string (to locate the last command beginning | |
7815 | with that string) or as a number (an index into the history list, | |
7816 | where a negative number is used as an offset from the current | |
7817 | command number). If | |
7818 | .I last | |
7819 | is not specified it is set to | |
7820 | the current command for listing (so that | |
bb70624e JA |
7821 | .if n ``fc \-l \-10'' |
7822 | .if t \f(CWfc \-l \-10\fP | |
726f6388 JA |
7823 | prints the last 10 commands) and to |
7824 | .I first | |
7825 | otherwise. | |
7826 | If | |
7827 | .I first | |
7828 | is not specified it is set to the previous | |
7829 | command for editing and \-16 for listing. | |
7830 | .sp 1 | |
7831 | The | |
7832 | .B \-n | |
cce855bc | 7833 | option suppresses |
726f6388 JA |
7834 | the command numbers when listing. The |
7835 | .B \-r | |
cce855bc | 7836 | option reverses the order of |
726f6388 JA |
7837 | the commands. If the |
7838 | .B \-l | |
cce855bc | 7839 | option is given, |
726f6388 JA |
7840 | the commands are listed on |
7841 | standard output. Otherwise, the editor given by | |
7842 | .I ename | |
7843 | is invoked | |
7844 | on a file containing those commands. If | |
7845 | .I ename | |
7846 | is not given, the | |
7847 | value of the | |
7848 | .SM | |
7849 | .B FCEDIT | |
7850 | variable is used, and | |
7851 | the value of | |
7852 | .SM | |
7853 | .B EDITOR | |
7854 | if | |
7855 | .SM | |
7856 | .B FCEDIT | |
7857 | is not set. If neither variable is set, | |
7858 | .FN vi | |
7859 | is used. When editing is complete, the edited commands are | |
7860 | echoed and executed. | |
7861 | .sp 1 | |
7862 | In the second form, \fIcommand\fP is re-executed after each instance | |
7863 | of \fIpat\fP is replaced by \fIrep\fP. | |
b28ff8c9 | 7864 | \fICommand\fP is intepreted the same as \fIfirst\fP above. |
ccc6cda3 | 7865 | A useful alias to use with this is |
d3a24ed2 | 7866 | .if n ``r="fc -s"'', |
ccc6cda3 JA |
7867 | .if t \f(CWr='fc \-s'\fP, |
7868 | so that typing | |
7869 | .if n ``r cc'' | |
7870 | .if t \f(CWr cc\fP | |
7871 | runs the last command beginning with | |
7872 | .if n ``cc'' | |
7873 | .if t \f(CWcc\fP | |
7874 | and typing | |
7875 | .if n ``r'' | |
7876 | .if t \f(CWr\fP | |
726f6388 JA |
7877 | re-executes the last command. |
7878 | .sp 1 | |
cce855bc | 7879 | If the first form is used, the return value is 0 unless an invalid |
726f6388 JA |
7880 | option is encountered or |
7881 | .I first | |
7882 | or | |
7883 | .I last | |
7884 | specify history lines out of range. | |
7885 | If the | |
7886 | .B \-e | |
7887 | option is supplied, the return value is the value of the last | |
7888 | command executed or failure if an error occurs with the temporary | |
7889 | file of commands. If the second form is used, the return status | |
7890 | is that of the command re-executed, unless | |
7891 | .I cmd | |
7892 | does not specify a valid history line, in which case | |
7893 | .B fc | |
7894 | returns failure. | |
7895 | .TP | |
7896 | \fBfg\fP [\fIjobspec\fP] | |
cce855bc | 7897 | Resume |
726f6388 | 7898 | .I jobspec |
cce855bc JA |
7899 | in the foreground, and make it the current job. |
7900 | If | |
726f6388 JA |
7901 | .I jobspec |
7902 | is not present, the shell's notion of the \fIcurrent job\fP is used. | |
7903 | The return value is that of the command placed into the foreground, | |
7904 | or failure if run when job control is disabled or, when run with | |
7905 | job control enabled, if | |
7906 | .I jobspec | |
7907 | does not specify a valid job or | |
7908 | .I jobspec | |
7909 | specifies a job that was started without job control. | |
7910 | .TP | |
7911 | \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP] | |
7912 | .B getopts | |
7913 | is used by shell procedures to parse positional parameters. | |
7914 | .I optstring | |
bb70624e | 7915 | contains the option characters to be recognized; if a character |
726f6388 JA |
7916 | is followed by a colon, the option is expected to have an |
7917 | argument, which should be separated from it by white space. | |
bb70624e JA |
7918 | The colon and question mark characters may not be used as |
7919 | option characters. | |
726f6388 JA |
7920 | Each time it is invoked, |
7921 | .B getopts | |
7922 | places the next option in the shell variable | |
7923 | .IR name , | |
7924 | initializing | |
7925 | .I name | |
7926 | if it does not exist, | |
7927 | and the index of the next argument to be processed into the | |
7928 | variable | |
7929 | .SM | |
7930 | .BR OPTIND . | |
7931 | .SM | |
7932 | .B OPTIND | |
7933 | is initialized to 1 each time the shell or a shell script | |
7934 | is invoked. When an option requires an argument, | |
7935 | .B getopts | |
7936 | places that argument into the variable | |
7937 | .SM | |
7938 | .BR OPTARG . | |
7939 | The shell does not reset | |
7940 | .SM | |
7941 | .B OPTIND | |
7942 | automatically; it must be manually reset between multiple | |
7943 | calls to | |
7944 | .B getopts | |
7945 | within the same shell invocation if a new set of parameters | |
7946 | is to be used. | |
7947 | .sp 1 | |
cce855bc JA |
7948 | When the end of options is encountered, \fBgetopts\fP exits with a |
7949 | return value greater than zero. | |
984a1947 CR |
7950 | .SM |
7951 | .B OPTIND | |
7952 | is set to the index of the first non-option argument, | |
dc60d4e0 | 7953 | and \fIname\fP is set to ?. |
cce855bc JA |
7954 | .sp 1 |
7955 | .B getopts | |
7956 | normally parses the positional parameters, but if more arguments are | |
7957 | given in | |
7958 | .IR args , | |
7959 | .B getopts | |
7960 | parses those instead. | |
7961 | .sp 1 | |
726f6388 JA |
7962 | .B getopts |
7963 | can report errors in two ways. If the first character of | |
7964 | .I optstring | |
7965 | is a colon, | |
7966 | .I silent | |
b28ff8c9 | 7967 | error reporting is used. In normal operation, diagnostic messages |
cce855bc | 7968 | are printed when invalid options or missing option arguments are |
726f6388 JA |
7969 | encountered. |
7970 | If the variable | |
7971 | .SM | |
7972 | .B OPTERR | |
cce855bc | 7973 | is set to 0, no error messages will be displayed, even if the first |
726f6388 JA |
7974 | character of |
7975 | .I optstring | |
7976 | is not a colon. | |
7977 | .sp 1 | |
cce855bc | 7978 | If an invalid option is seen, |
726f6388 JA |
7979 | .B getopts |
7980 | places ? into | |
7981 | .I name | |
7982 | and, if not silent, | |
7983 | prints an error message and unsets | |
7984 | .SM | |
7985 | .BR OPTARG . | |
7986 | If | |
7987 | .B getopts | |
7988 | is silent, | |
7989 | the option character found is placed in | |
7990 | .SM | |
7991 | .B OPTARG | |
7992 | and no diagnostic message is printed. | |
7993 | .sp 1 | |
7994 | If a required argument is not found, and | |
7995 | .B getopts | |
7996 | is not silent, | |
7997 | a question mark (\^\fB?\fP\^) is placed in | |
7998 | .IR name , | |
f73dda09 | 7999 | .SM |
726f6388 JA |
8000 | .B OPTARG |
8001 | is unset, and a diagnostic message is printed. | |
8002 | If | |
8003 | .B getopts | |
8004 | is silent, then a colon (\^\fB:\fP\^) is placed in | |
8005 | .I name | |
8006 | and | |
8007 | .SM | |
8008 | .B OPTARG | |
8009 | is set to the option character found. | |
8010 | .sp 1 | |
8011 | .B getopts | |
726f6388 JA |
8012 | returns true if an option, specified or unspecified, is found. |
8013 | It returns false if the end of options is encountered or an | |
8014 | error occurs. | |
8015 | .TP | |
7117c2d2 | 8016 | \fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP] |
4691dc6b CR |
8017 | Each time \fBhash\fP is invoked, |
8018 | the full pathname of the command | |
8019 | .I name | |
8020 | is determined by searching | |
ccc6cda3 JA |
8021 | the directories in |
8022 | .B $PATH | |
4691dc6b | 8023 | and remembered. Any previously-remembered pathname is discarded. |
ccc6cda3 JA |
8024 | If the |
8025 | .B \-p | |
8026 | option is supplied, no path search is performed, and | |
8027 | .I filename | |
b28ff8c9 | 8028 | is used as the full filename of the command. |
ccc6cda3 | 8029 | The |
726f6388 JA |
8030 | .B \-r |
8031 | option causes the shell to forget all | |
f73dda09 | 8032 | remembered locations. |
7117c2d2 JA |
8033 | The |
8034 | .B \-d | |
8035 | option causes the shell to forget the remembered location of each \fIname\fP. | |
f73dda09 JA |
8036 | If the |
8037 | .B \-t | |
8038 | option is supplied, the full pathname to which each \fIname\fP corresponds | |
8039 | is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP, | |
8040 | the \fIname\fP is printed before the hashed full pathname. | |
7117c2d2 JA |
8041 | The |
8042 | .B \-l | |
8043 | option causes output to be displayed in a format that may be reused as input. | |
8044 | If no arguments are given, or if only \fB\-l\fP is supplied, | |
8045 | information about remembered commands is printed. | |
ccc6cda3 | 8046 | The return status is true unless a |
726f6388 | 8047 | .I name |
cce855bc | 8048 | is not found or an invalid option is supplied. |
726f6388 | 8049 | .TP |
6a8fd0ed | 8050 | \fBhelp\fP [\fB\-dms\fP] [\fIpattern\fP] |
726f6388 JA |
8051 | Display helpful information about builtin commands. If |
8052 | .I pattern | |
8053 | is specified, | |
8054 | .B help | |
8055 | gives detailed help on all commands matching | |
8056 | .IR pattern ; | |
ccc6cda3 | 8057 | otherwise help for all the builtins and shell control structures |
bb70624e | 8058 | is printed. |
6a8fd0ed CR |
8059 | .RS |
8060 | .PD 0 | |
8061 | .TP | |
8062 | .B \-d | |
8063 | Display a short description of each \fIpattern\fP | |
8064 | .TP | |
6932f7f5 | 8065 | .B \-m |
6a8fd0ed CR |
8066 | Display the description of each \fIpattern\fP in a manpage-like format |
8067 | .TP | |
8068 | .B \-s | |
8069 | Display only a short usage synopsis for each \fIpattern\fP | |
8070 | .PD | |
54a1fa7c | 8071 | .PP |
bb70624e | 8072 | The return status is 0 unless no command matches |
726f6388 | 8073 | .IR pattern . |
54a1fa7c | 8074 | .RE |
726f6388 | 8075 | .TP |
bb70624e | 8076 | \fBhistory [\fIn\fP] |
7117c2d2 | 8077 | .PD 0 |
bb70624e JA |
8078 | .TP |
8079 | \fBhistory\fP \fB\-c\fP | |
8080 | .TP | |
8081 | \fBhistory \-d\fP \fIoffset\fP | |
ccc6cda3 JA |
8082 | .TP |
8083 | \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP] | |
726f6388 | 8084 | .TP |
ccc6cda3 JA |
8085 | \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP] |
8086 | .TP | |
8087 | \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP] | |
726f6388 JA |
8088 | .PD |
8089 | With no options, display the command | |
8090 | history list with line numbers. Lines listed | |
8091 | with a | |
8092 | .B * | |
8093 | have been modified. An argument of | |
8094 | .I n | |
8095 | lists only the last | |
8096 | .I n | |
d3a24ed2 | 8097 | lines. |
984a1947 CR |
8098 | If the shell variable |
8099 | .SM | |
8100 | .B HISTTIMEFORMAT | |
8101 | is set and not null, | |
d3a24ed2 CR |
8102 | it is used as a format string for \fIstrftime\fP(3) to display |
8103 | the time stamp associated with each displayed history entry. | |
8104 | No intervening blank is printed between the formatted time stamp | |
8105 | and the history line. | |
8106 | If \fIfilename\fP is supplied, it is used as the | |
726f6388 JA |
8107 | name of the history file; if not, the value of |
8108 | .SM | |
8109 | .B HISTFILE | |
8110 | is used. Options, if supplied, have the following meanings: | |
8111 | .RS | |
8112 | .PD 0 | |
8113 | .TP | |
bb70624e JA |
8114 | .B \-c |
8115 | Clear the history list by deleting all the entries. | |
8116 | .TP | |
8117 | \fB\-d\fP \fIoffset\fP | |
8118 | Delete the history entry at position \fIoffset\fP. | |
8119 | .TP | |
726f6388 JA |
8120 | .B \-a |
8121 | Append the ``new'' history lines (history lines entered since the | |
ccc6cda3 | 8122 | beginning of the current \fBbash\fP session) to the history file. |
726f6388 JA |
8123 | .TP |
8124 | .B \-n | |
8125 | Read the history lines not already read from the history | |
8126 | file into the current history list. These are lines | |
8127 | appended to the history file since the beginning of the | |
8128 | current \fBbash\fP session. | |
8129 | .TP | |
8130 | .B \-r | |
8131 | Read the contents of the history file | |
b28ff8c9 | 8132 | and append them to the current history list. |
726f6388 JA |
8133 | .TP |
8134 | .B \-w | |
b28ff8c9 | 8135 | Write the current history list to the history file, overwriting the |
726f6388 | 8136 | history file's contents. |
ccc6cda3 | 8137 | .TP |
ccc6cda3 JA |
8138 | .B \-p |
8139 | Perform history substitution on the following \fIargs\fP and display | |
8140 | the result on the standard output. | |
8141 | Does not store the results in the history list. | |
8142 | Each \fIarg\fP must be quoted to disable normal history expansion. | |
8143 | .TP | |
8144 | .B \-s | |
8145 | Store the | |
8146 | .I args | |
8147 | in the history list as a single entry. The last command in the | |
8148 | history list is removed before the | |
8149 | .I args | |
8150 | are added. | |
726f6388 JA |
8151 | .PD |
8152 | .PP | |
984a1947 CR |
8153 | If the |
8154 | .SM | |
8155 | .B HISTTIMEFORMAT | |
8156 | variable is set, the time stamp information | |
d3ad40de CR |
8157 | associated with each history entry is written to the history file, |
8158 | marked with the history comment character. | |
8159 | When the history file is read, lines beginning with the history | |
8160 | comment character followed immediately by a digit are interpreted | |
8161 | as timestamps for the previous history line. | |
bb70624e JA |
8162 | The return value is 0 unless an invalid option is encountered, an |
8163 | error occurs while reading or writing the history file, an invalid | |
8164 | \fIoffset\fP is supplied as an argument to \fB\-d\fP, or the | |
8165 | history expansion supplied as an argument to \fB\-p\fP fails. | |
726f6388 JA |
8166 | .RE |
8167 | .TP | |
ccc6cda3 | 8168 | \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ] |
7117c2d2 | 8169 | .PD 0 |
726f6388 JA |
8170 | .TP |
8171 | \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ] | |
8172 | .PD | |
ccc6cda3 JA |
8173 | The first form lists the active jobs. The options have the following |
8174 | meanings: | |
8175 | .RS | |
8176 | .PD 0 | |
8177 | .TP | |
726f6388 | 8178 | .B \-l |
ccc6cda3 JA |
8179 | List process IDs |
8180 | in addition to the normal information. | |
8181 | .TP | |
726f6388 | 8182 | .B \-n |
ccc6cda3 JA |
8183 | Display information only about jobs that have changed status since |
8184 | the user was last notified of their status. | |
8185 | .TP | |
5cdaaf76 CR |
8186 | .B \-p |
8187 | List only the process ID of the job's process group | |
8188 | leader. | |
8189 | .TP | |
ccc6cda3 | 8190 | .B \-r |
b28ff8c9 | 8191 | Display only running jobs. |
ccc6cda3 JA |
8192 | .TP |
8193 | .B \-s | |
b28ff8c9 | 8194 | Display only stopped jobs. |
ccc6cda3 JA |
8195 | .PD |
8196 | .PP | |
8197 | If | |
726f6388 JA |
8198 | .I jobspec |
8199 | is given, output is restricted to information about that job. | |
cce855bc JA |
8200 | The return status is 0 unless an invalid option is encountered |
8201 | or an invalid | |
726f6388 JA |
8202 | .I jobspec |
8203 | is supplied. | |
ccc6cda3 | 8204 | .PP |
726f6388 JA |
8205 | If the |
8206 | .B \-x | |
8207 | option is supplied, | |
8208 | .B jobs | |
8209 | replaces any | |
8210 | .I jobspec | |
8211 | found in | |
8212 | .I command | |
8213 | or | |
8214 | .I args | |
8215 | with the corresponding process group ID, and executes | |
8216 | .I command | |
8217 | passing it | |
8218 | .IR args , | |
8219 | returning its exit status. | |
ccc6cda3 | 8220 | .RE |
726f6388 | 8221 | .TP |
ccc6cda3 | 8222 | \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ... |
7117c2d2 | 8223 | .PD 0 |
726f6388 | 8224 | .TP |
cce855bc | 8225 | \fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP] |
726f6388 JA |
8226 | .PD |
8227 | Send the signal named by | |
8228 | .I sigspec | |
ccc6cda3 JA |
8229 | or |
8230 | .I signum | |
726f6388 JA |
8231 | to the processes named by |
8232 | .I pid | |
8233 | or | |
8234 | .IR jobspec . | |
8235 | .I sigspec | |
61deeb13 | 8236 | is either a case-insensitive signal name such as |
726f6388 JA |
8237 | .SM |
8238 | .B SIGKILL | |
61deeb13 | 8239 | (with or without the |
726f6388 JA |
8240 | .SM |
8241 | .B SIG | |
61deeb13 CR |
8242 | prefix) or a signal number; |
8243 | .I signum | |
8244 | is a signal number. | |
726f6388 JA |
8245 | If |
8246 | .I sigspec | |
8247 | is not present, then | |
8248 | .SM | |
8249 | .B SIGTERM | |
cce855bc JA |
8250 | is assumed. |
8251 | An argument of | |
726f6388 | 8252 | .B \-l |
cce855bc JA |
8253 | lists the signal names. |
8254 | If any arguments are supplied when | |
726f6388 | 8255 | .B \-l |
cce855bc JA |
8256 | is given, the names of the signals corresponding to the arguments are |
8257 | listed, and the return status is 0. | |
8258 | The \fIexit_status\fP argument to | |
ccc6cda3 | 8259 | .B \-l |
cce855bc JA |
8260 | is a number specifying either a signal number or the exit status of |
8261 | a process terminated by a signal. | |
726f6388 JA |
8262 | .B kill |
8263 | returns true if at least one signal was successfully sent, or false | |
cce855bc | 8264 | if an error occurs or an invalid option is encountered. |
726f6388 JA |
8265 | .TP |
8266 | \fBlet\fP \fIarg\fP [\fIarg\fP ...] | |
8267 | Each | |
8268 | .I arg | |
8269 | is an arithmetic expression to be evaluated (see | |
8270 | .SM | |
984a1947 CR |
8271 | .B "ARITHMETIC EVALUATION" |
8272 | above). | |
726f6388 JA |
8273 | If the last |
8274 | .I arg | |
8275 | evaluates to 0, | |
8276 | .B let | |
8277 | returns 1; 0 is returned otherwise. | |
8278 | .TP | |
bb70624e | 8279 | \fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ...] |
cce855bc JA |
8280 | For each argument, a local variable named |
8281 | .I name | |
8282 | is created, and assigned | |
726f6388 | 8283 | .IR value . |
bb70624e | 8284 | The \fIoption\fP can be any of the options accepted by \fBdeclare\fP. |
726f6388 JA |
8285 | When |
8286 | .B local | |
8287 | is used within a function, it causes the variable | |
8288 | .I name | |
8289 | to have a visible scope restricted to that function and its children. | |
8290 | With no operands, | |
8291 | .B local | |
8292 | writes a list of local variables to the standard output. It is | |
8293 | an error to use | |
8294 | .B local | |
8295 | when not within a function. The return status is 0 unless | |
8296 | .B local | |
bb70624e | 8297 | is used outside a function, an invalid |
726f6388 | 8298 | .I name |
bb70624e JA |
8299 | is supplied, or |
8300 | \fIname\fP is a readonly variable. | |
726f6388 JA |
8301 | .TP |
8302 | .B logout | |
8303 | Exit a login shell. | |
8304 | .TP | |
09767ff0 | 8305 | \fBmapfile\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] |
e141c35a CR |
8306 | .PD 0 |
8307 | .TP | |
8308 | \fBreadarray\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] | |
8309 | .PD | |
e1e48bba | 8310 | Read lines from the standard input into the indexed array variable |
6a8fd0ed CR |
8311 | .IR array , |
8312 | or from file descriptor | |
8313 | .IR fd | |
8314 | if the | |
8315 | .B \-u | |
8316 | option is supplied. | |
984a1947 CR |
8317 | The variable |
8318 | .SM | |
8319 | .B MAPFILE | |
8320 | is the default \fIarray\fP. | |
6a8fd0ed CR |
8321 | Options, if supplied, have the following meanings: |
8322 | .RS | |
8323 | .PD 0 | |
8324 | .TP | |
8325 | .B \-n | |
8326 | Copy at most | |
8327 | .I count | |
8328 | lines. If \fIcount\fP is 0, all lines are copied. | |
8329 | .TP | |
8330 | .B \-O | |
8331 | Begin assigning to | |
8332 | .I array | |
8333 | at index | |
8334 | .IR origin . | |
8335 | The default index is 0. | |
8336 | .TP | |
8337 | .B \-s | |
8338 | Discard the first \fIcount\fP lines read. | |
8339 | .TP | |
8340 | .B \-t | |
984a1947 | 8341 | Remove a trailing newline from each line read. |
6a8fd0ed CR |
8342 | .TP |
8343 | .B \-u | |
8344 | Read lines from file descriptor \fIfd\fP instead of the standard input. | |
8345 | .TP | |
8346 | .B \-C | |
8347 | Evaluate | |
8348 | .I callback | |
8349 | each time \fIquantum\fP lines are read. The \fB\-c\fP option specifies | |
8350 | .IR quantum . | |
8351 | .TP | |
8352 | .B \-c | |
8353 | Specify the number of lines read between each call to | |
8354 | .IR callback . | |
8355 | .PD | |
8356 | .PP | |
8357 | If | |
8358 | .B \-C | |
8359 | is specified without | |
8360 | .BR \-c , | |
8361 | the default quantum is 5000. | |
e141c35a | 8362 | When \fIcallback\fP is evaluated, it is supplied the index of the next |
6faad625 CR |
8363 | array element to be assigned and the line to be assigned to that element |
8364 | as additional arguments. | |
e141c35a CR |
8365 | \fIcallback\fP is evaluated after the line is read but before the |
8366 | array element is assigned. | |
6a8fd0ed CR |
8367 | .PP |
8368 | If not supplied with an explicit origin, \fBmapfile\fP will clear \fIarray\fP | |
8369 | before assigning to it. | |
8370 | .PP | |
8371 | \fBmapfile\fP returns successfully unless an invalid option or option | |
e1e48bba CR |
8372 | argument is supplied, \fIarray\fP is invalid or unassignable, or if |
8373 | \fIarray\fP is not an indexed array. | |
6a8fd0ed CR |
8374 | .RE |
8375 | .TP | |
ccc6cda3 | 8376 | \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP] |
726f6388 JA |
8377 | Removes entries from the directory stack. With no arguments, |
8378 | removes the top directory from the stack, and performs a | |
8379 | .B cd | |
8380 | to the new top directory. | |
ccc6cda3 | 8381 | Arguments, if supplied, have the following meanings: |
726f6388 JA |
8382 | .RS |
8383 | .PD 0 | |
8384 | .TP | |
d3ad40de CR |
8385 | .B \-n |
8386 | Suppresses the normal change of directory when removing directories | |
8387 | from the stack, so that only the stack is manipulated. | |
8388 | .TP | |
ccc6cda3 JA |
8389 | \fB+\fP\fIn\fP |
8390 | Removes the \fIn\fPth entry counting from the left of the list | |
726f6388 JA |
8391 | shown by |
8392 | .BR dirs , | |
bb70624e JA |
8393 | starting with zero. For example: |
8394 | .if n ``popd +0'' | |
8395 | .if t \f(CWpopd +0\fP | |
8396 | removes the first directory, | |
8397 | .if n ``popd +1'' | |
8398 | .if t \f(CWpopd +1\fP | |
8399 | the second. | |
726f6388 | 8400 | .TP |
ccc6cda3 JA |
8401 | \fB\-\fP\fIn\fP |
8402 | Removes the \fIn\fPth entry counting from the right of the list | |
726f6388 JA |
8403 | shown by |
8404 | .BR dirs , | |
bb70624e JA |
8405 | starting with zero. For example: |
8406 | .if n ``popd -0'' | |
8407 | .if t \f(CWpopd -0\fP | |
8408 | removes the last directory, | |
8409 | .if n ``popd -1'' | |
8410 | .if t \f(CWpopd -1\fP | |
8411 | the next to last. | |
726f6388 JA |
8412 | .PD |
8413 | .PP | |
8414 | If the | |
8415 | .B popd | |
8416 | command is successful, a | |
8417 | .B dirs | |
8418 | is performed as well, and the return status is 0. | |
8419 | .B popd | |
cce855bc | 8420 | returns false if an invalid option is encountered, the directory stack |
726f6388 JA |
8421 | is empty, a non-existent directory stack entry is specified, or the |
8422 | directory change fails. | |
8423 | .RE | |
8424 | .TP | |
3ee6b87d | 8425 | \fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP] |
cce855bc JA |
8426 | Write the formatted \fIarguments\fP to the standard output under the |
8427 | control of the \fIformat\fP. | |
6faad625 CR |
8428 | The \fB\-v\fP option causes the output to be assigned to the variable |
8429 | \fIvar\fP rather than being printed to the standard output. | |
8430 | .sp 1 | |
cce855bc JA |
8431 | The \fIformat\fP is a character string which contains three types of objects: |
8432 | plain characters, which are simply copied to standard output, character | |
8433 | escape sequences, which are converted and copied to the standard output, and | |
8434 | format specifications, each of which causes printing of the next successive | |
8435 | \fIargument\fP. | |
6faad625 CR |
8436 | In addition to the standard \fIprintf\fP(1) format specifications, |
8437 | \fBprintf\fP interprets the following extensions: | |
8438 | .RS | |
8439 | .PD 0 | |
8440 | .TP | |
8441 | .B %b | |
8442 | causes | |
cce855bc | 8443 | \fBprintf\fP to expand backslash escape sequences in the corresponding |
5e13499c | 8444 | \fIargument\fP (except that \fB\ec\fP terminates output, backslashes in |
20587658 | 8445 | \fB\e\(aq\fP, \fB\e"\fP, and \fB\e?\fP are not removed, and octal escapes |
6faad625 CR |
8446 | beginning with \fB\e0\fP may contain up to four digits). |
8447 | .TP | |
8448 | .B %q | |
8449 | causes \fBprintf\fP to output the corresponding | |
cce855bc | 8450 | \fIargument\fP in a format that can be reused as shell input. |
6faad625 CR |
8451 | .TP |
8452 | .B %(\fIdatefmt\fP)T | |
8453 | causes \fBprintf\fP to output the date-time string resulting from using | |
77b3aacb CR |
8454 | \fIdatefmt\fP as a format string for \fIstrftime\fP(3). |
8455 | The corresponding \fIargument\fP is an integer representing the number of | |
8456 | seconds since the epoch. | |
8457 | Two special argument values may be used: -1 represents the current | |
6faad625 | 8458 | time, and -2 represents the time the shell was invoked. |
77b3aacb CR |
8459 | If no argument is specified, conversion behaves as if -1 had been given. |
8460 | This is an exception to the usual \fBprintf\fP behavior. | |
6faad625 CR |
8461 | .PD |
8462 | .PP | |
112ff2a6 CR |
8463 | Arguments to non-string format specifiers are treated as C constants, |
8464 | except that a leading plus or minus sign is allowed, and if the leading | |
8465 | character is a single or double quote, the value is the ASCII value of | |
8466 | the following character. | |
6faad625 | 8467 | .PP |
cce855bc JA |
8468 | The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP. |
8469 | If the \fIformat\fP requires more \fIarguments\fP than are supplied, the | |
8470 | extra format specifications behave as if a zero value or null string, as | |
6faad625 CR |
8471 | appropriate, had been supplied. |
8472 | The return value is zero on success, non-zero on failure. | |
8473 | .RE | |
cce855bc | 8474 | .TP |
d3ad40de | 8475 | \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP] |
7117c2d2 | 8476 | .PD 0 |
726f6388 | 8477 | .TP |
d3ad40de | 8478 | \fBpushd\fP [\fB\-n\fP] [\fIdir\fP] |
726f6388 JA |
8479 | .PD |
8480 | Adds a directory to the top of the directory stack, or rotates | |
8481 | the stack, making the new top of the stack the current working | |
8482 | directory. With no arguments, exchanges the top two directories | |
8483 | and returns 0, unless the directory stack is empty. | |
ccc6cda3 | 8484 | Arguments, if supplied, have the following meanings: |
726f6388 JA |
8485 | .RS |
8486 | .PD 0 | |
8487 | .TP | |
d3ad40de CR |
8488 | .B \-n |
8489 | Suppresses the normal change of directory when adding directories | |
8490 | to the stack, so that only the stack is manipulated. | |
8491 | .TP | |
ccc6cda3 | 8492 | \fB+\fP\fIn\fP |
726f6388 JA |
8493 | Rotates the stack so that the \fIn\fPth directory |
8494 | (counting from the left of the list shown by | |
d166f048 JA |
8495 | .BR dirs , |
8496 | starting with zero) | |
726f6388 JA |
8497 | is at the top. |
8498 | .TP | |
ccc6cda3 | 8499 | \fB\-\fP\fIn\fP |
726f6388 | 8500 | Rotates the stack so that the \fIn\fPth directory |
d166f048 JA |
8501 | (counting from the right of the list shown by |
8502 | .BR dirs , | |
8503 | starting with zero) is at the top. | |
726f6388 | 8504 | .TP |
bb70624e | 8505 | .I dir |
ccc6cda3 | 8506 | Adds |
726f6388 JA |
8507 | .I dir |
8508 | to the directory stack at the top, making it the | |
19baff85 CR |
8509 | new current working directory as if it had been supplied as the argument |
8510 | to the \fBcd\fP builtin. | |
726f6388 JA |
8511 | .PD |
8512 | .PP | |
8513 | If the | |
8514 | .B pushd | |
8515 | command is successful, a | |
8516 | .B dirs | |
8517 | is performed as well. | |
8518 | If the first form is used, | |
8519 | .B pushd | |
8520 | returns 0 unless the cd to | |
8521 | .I dir | |
8522 | fails. With the second form, | |
8523 | .B pushd | |
8524 | returns 0 unless the directory stack is empty, | |
ccc6cda3 | 8525 | a non-existent directory stack element is specified, |
726f6388 JA |
8526 | or the directory change to the specified new current directory |
8527 | fails. | |
8528 | .RE | |
8529 | .TP | |
ccc6cda3 | 8530 | \fBpwd\fP [\fB\-LP\fP] |
bb70624e JA |
8531 | Print the absolute pathname of the current working directory. |
8532 | The pathname printed contains no symbolic links if the | |
726f6388 | 8533 | .B \-P |
ccc6cda3 JA |
8534 | option is supplied or the |
8535 | .B \-o physical | |
726f6388 JA |
8536 | option to the |
8537 | .B set | |
ccc6cda3 JA |
8538 | builtin command is enabled. |
8539 | If the | |
8540 | .B \-L | |
bb70624e | 8541 | option is used, the pathname printed may contain symbolic links. |
ccc6cda3 | 8542 | The return status is 0 unless an error occurs while |
cce855bc JA |
8543 | reading the name of the current directory or an |
8544 | invalid option is supplied. | |
726f6388 | 8545 | .TP |
08e72d7a | 8546 | \fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fB\-i\fP \fItext\fP] [\fB\-n\fP \fInchars\fP] [\fB\-N\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...] |
7117c2d2 JA |
8547 | One line is read from the standard input, or from the file descriptor |
8548 | \fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word | |
726f6388 JA |
8549 | is assigned to the first |
8550 | .IR name , | |
8551 | the second word to the second | |
8552 | .IR name , | |
cce855bc JA |
8553 | and so on, with leftover words and their intervening separators assigned |
8554 | to the last | |
726f6388 | 8555 | .IR name . |
7117c2d2 | 8556 | If there are fewer words read from the input stream than names, |
cce855bc JA |
8557 | the remaining names are assigned empty values. |
8558 | The characters in | |
726f6388 JA |
8559 | .SM |
8560 | .B IFS | |
c677e9e0 CR |
8561 | are used to split the line into words using the same rules the shell |
8562 | uses for expansion (described above under \fBWord Splitting\fP). | |
b72432fd JA |
8563 | The backslash character (\fB\e\fP) may be used to remove any special |
8564 | meaning for the next character read and for line continuation. | |
cce855bc | 8565 | Options, if supplied, have the following meanings: |
ccc6cda3 JA |
8566 | .RS |
8567 | .PD 0 | |
8568 | .TP | |
bb70624e | 8569 | .B \-a \fIaname\fP |
ccc6cda3 JA |
8570 | The words are assigned to sequential indices |
8571 | of the array variable | |
8572 | .IR aname , | |
8573 | starting at 0. | |
8574 | .I aname | |
8575 | is unset before any new values are assigned. | |
cce855bc | 8576 | Other \fIname\fP arguments are ignored. |
ccc6cda3 | 8577 | .TP |
bb70624e JA |
8578 | .B \-d \fIdelim\fP |
8579 | The first character of \fIdelim\fP is used to terminate the input line, | |
8580 | rather than newline. | |
8581 | .TP | |
ccc6cda3 JA |
8582 | .B \-e |
8583 | If the standard input | |
8584 | is coming from a terminal, | |
8585 | .B readline | |
8586 | (see | |
8587 | .SM | |
8588 | .B READLINE | |
8589 | above) is used to obtain the line. | |
14e8b2a7 CR |
8590 | Readline uses the current (or default, if line editing was not previously |
8591 | active) editing settings. | |
bb70624e | 8592 | .TP |
1d0e1a34 CR |
8593 | .B \-i \fItext\fP |
8594 | If | |
8595 | .B readline | |
8596 | is being used to read the line, \fItext\fP is placed into the editing | |
8597 | buffer before editing begins. | |
8598 | .TP | |
bb70624e JA |
8599 | .B \-n \fInchars\fP |
8600 | \fBread\fP returns after reading \fInchars\fP characters rather than | |
08e72d7a CR |
8601 | waiting for a complete line of input, but honor a delimiter if fewer |
8602 | than \fInchars\fP characters are read before the delimiter. | |
8603 | .TP | |
8604 | .B \-N \fInchars\fP | |
8605 | \fBread\fP returns after reading exactly \fInchars\fP characters rather | |
8606 | than waiting for a complete line of input, unless EOF is encountered or | |
a3143574 CR |
8607 | \fBread\fP times out. |
8608 | Delimiter characters encountered in the input are | |
8609 | not treated specially and do not cause \fBread\fP to return until | |
8610 | \fInchars\fP characters are read. | |
bb70624e JA |
8611 | .TP |
8612 | .B \-p \fIprompt\fP | |
f73dda09 | 8613 | Display \fIprompt\fP on standard error, without a |
bb70624e JA |
8614 | trailing newline, before attempting to read any input. The prompt |
8615 | is displayed only if input is coming from a terminal. | |
8616 | .TP | |
8617 | .B \-r | |
8618 | Backslash does not act as an escape character. | |
8619 | The backslash is considered to be part of the line. | |
8620 | In particular, a backslash-newline pair may not be used as a line | |
8621 | continuation. | |
8622 | .TP | |
8623 | .B \-s | |
8624 | Silent mode. If input is coming from a terminal, characters are | |
8625 | not echoed. | |
8626 | .TP | |
8627 | .B \-t \fItimeout\fP | |
8628 | Cause \fBread\fP to time out and return failure if a complete line of | |
77b3aacb CR |
8629 | input (or a specified number of characters) |
8630 | is not read within \fItimeout\fP seconds. | |
4ac1ff98 CR |
8631 | \fItimeout\fP may be a decimal number with a fractional portion following |
8632 | the decimal point. | |
e33f2203 CR |
8633 | This option is only effective if \fBread\fP is reading input from a |
8634 | terminal, pipe, or other special file; it has no effect when reading | |
8635 | from regular files. | |
77b3aacb CR |
8636 | If \fBread\fP times out, \fBread\fP saves any partial input read into |
8637 | the specified variable \fIname\fP. | |
b13b8a87 | 8638 | If \fItimeout\fP is 0, \fBread\fP returns immediately, without trying to |
77b3aacb | 8639 | read any data. The exit status is 0 if input is available on |
b13b8a87 | 8640 | the specified file descriptor, non-zero otherwise. |
e33f2203 | 8641 | The exit status is greater than 128 if the timeout is exceeded. |
7117c2d2 | 8642 | .TP |
0f445e6c | 8643 | .B \-u \fIfd\fP |
7117c2d2 | 8644 | Read input from file descriptor \fIfd\fP. |
ccc6cda3 JA |
8645 | .PD |
8646 | .PP | |
8647 | If no | |
726f6388 JA |
8648 | .I names |
8649 | are supplied, the line read is assigned to the variable | |
8650 | .SM | |
8651 | .BR REPLY . | |
7117c2d2 | 8652 | The return code is zero, unless end-of-file is encountered, \fBread\fP |
ba4ab055 CR |
8653 | times out (in which case the return code is greater than 128), |
8654 | a variable assignment error (such as assigning to a readonly variable) occurs, | |
8655 | or an invalid file descriptor is supplied as the argument to \fB\-u\fP. | |
ccc6cda3 | 8656 | .RE |
726f6388 | 8657 | .TP |
54a1fa7c | 8658 | \fBreadonly\fP [\fB\-aAf\fP] [\fB\-p\fP] [\fIname\fP[=\fIword\fP] ...] |
726f6388 JA |
8659 | .PD |
8660 | The given | |
ccc6cda3 JA |
8661 | \fInames\fP are marked readonly; the values of these |
8662 | .I names | |
726f6388 JA |
8663 | may not be changed by subsequent assignment. |
8664 | If the | |
8665 | .B \-f | |
8666 | option is supplied, the functions corresponding to the | |
8667 | \fInames\fP are so | |
ccc6cda3 JA |
8668 | marked. |
8669 | The | |
8670 | .B \-a | |
fdf670ea CR |
8671 | option restricts the variables to indexed arrays; the |
8672 | .B \-A | |
8673 | option restricts the variables to associative arrays. | |
54a1fa7c CR |
8674 | If both options are supplied, |
8675 | .B \-A | |
8676 | takes precedence. | |
ccc6cda3 JA |
8677 | If no |
8678 | .I name | |
8679 | arguments are given, or if the | |
726f6388 | 8680 | .B \-p |
ccc6cda3 | 8681 | option is supplied, a list of all readonly names is printed. |
54a1fa7c CR |
8682 | The other options may be used to restrict the output to a subset of |
8683 | the set of readonly names. | |
cce855bc JA |
8684 | The |
8685 | .B \-p | |
bb70624e JA |
8686 | option causes output to be displayed in a format that |
8687 | may be reused as input. | |
d3a24ed2 CR |
8688 | If a variable name is followed by =\fIword\fP, the value of |
8689 | the variable is set to \fIword\fP. | |
cce855bc | 8690 | The return status is 0 unless an invalid option is encountered, |
ccc6cda3 JA |
8691 | one of the |
8692 | .I names | |
cce855bc | 8693 | is not a valid shell variable name, or |
726f6388 JA |
8694 | .B \-f |
8695 | is supplied with a | |
8696 | .I name | |
8697 | that is not a function. | |
8698 | .TP | |
8699 | \fBreturn\fP [\fIn\fP] | |
b28ff8c9 CR |
8700 | Causes a function to stop executing and return the value specified by |
8701 | .I n | |
8702 | to its caller. | |
726f6388 JA |
8703 | If |
8704 | .I n | |
8705 | is omitted, the return status is that of the last command | |
b28ff8c9 CR |
8706 | executed in the function body. If |
8707 | .B return | |
8708 | is used outside a function, | |
726f6388 JA |
8709 | but during execution of a script by the |
8710 | .B . | |
8711 | (\fBsource\fP) command, it causes the shell to stop executing | |
8712 | that script and return either | |
8713 | .I n | |
8714 | or the exit status of the last command executed within the | |
b28ff8c9 | 8715 | script as the exit status of the script. |
3d4f66ca CR |
8716 | If \fIn\fP is supplied, the return value is its least significant |
8717 | 8 bits. | |
b28ff8c9 CR |
8718 | The return status is non-zero if |
8719 | .B return | |
3d4f66ca | 8720 | is supplied a non-numeric argument, or |
b28ff8c9 CR |
8721 | is used outside a |
8722 | function and not during execution of a script by \fB.\fP\^ or \fBsource\fP. | |
d3a24ed2 CR |
8723 | Any command associated with the \fBRETURN\fP trap is executed |
8724 | before execution resumes after the function or script. | |
726f6388 | 8725 | .TP |
dc60d4e0 | 8726 | \fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\-name\fP] [\fIarg\fP ...] |
d3ad40de CR |
8727 | .PD 0 |
8728 | .TP | |
dc60d4e0 | 8729 | \fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\-name\fP] [\fIarg\fP ...] |
d3ad40de | 8730 | .PD |
ccc6cda3 | 8731 | Without options, the name and value of each shell variable are displayed |
54cdd75a CR |
8732 | in a format that can be reused as input |
8733 | for setting or resetting the currently-set variables. | |
8734 | Read-only variables cannot be reset. | |
c677e9e0 | 8735 | In \fIposix\fP mode, only shell variables are listed. |
cce855bc | 8736 | The output is sorted according to the current locale. |
ccc6cda3 | 8737 | When options are specified, they set or unset shell attributes. |
626d0694 | 8738 | Any arguments remaining after option processing are treated |
ccc6cda3 JA |
8739 | as values for the positional parameters and are assigned, in order, to |
8740 | .BR $1 , | |
8741 | .BR $2 , | |
8742 | .B ... | |
8743 | .BR $\fIn\fP . | |
8744 | Options, if specified, have the following meanings: | |
726f6388 JA |
8745 | .RS |
8746 | .PD 0 | |
8747 | .TP 8 | |
8748 | .B \-a | |
5e13499c CR |
8749 | Automatically mark variables and functions which are modified or |
8750 | created for export to the environment of subsequent commands. | |
726f6388 JA |
8751 | .TP 8 |
8752 | .B \-b | |
ccc6cda3 JA |
8753 | Report the status of terminated background jobs |
8754 | immediately, rather than before the next primary prompt. This is | |
8755 | effective only when job control is enabled. | |
726f6388 JA |
8756 | .TP 8 |
8757 | .B \-e | |
15825757 CR |
8758 | Exit immediately if a |
8759 | \fIpipeline\fP (which may consist of a single \fIsimple command\fP), | |
8760 | a \fIlist\fP, | |
8761 | or a \fIcompound command\fP | |
8762 | (see | |
726f6388 JA |
8763 | .SM |
8764 | .B SHELL GRAMMAR | |
15825757 | 8765 | above), exits with a non-zero status. |
d3a24ed2 CR |
8766 | The shell does not exit if the |
8767 | command that fails is part of the command list immediately following a | |
8768 | .B while | |
726f6388 | 8769 | or |
d3a24ed2 CR |
8770 | .B until |
8771 | keyword, | |
4b9cc222 | 8772 | part of the test following the |
d3ad40de | 8773 | .B if |
4b9cc222 CR |
8774 | or |
8775 | .B elif | |
8776 | reserved words, part of any command executed in a | |
726f6388 JA |
8777 | .B && |
8778 | or | |
adc6cff5 CR |
8779 | .B || |
8780 | list except the command following the final \fB&&\fP or \fB||\fP, | |
d3ad40de CR |
8781 | any command in a pipeline but the last, |
8782 | or if the command's return value is | |
a05a1337 | 8783 | being inverted with |
726f6388 | 8784 | .BR ! . |
15825757 CR |
8785 | If a compound command other than a subshell |
8786 | returns a non-zero status because a command failed | |
8787 | while \fB\-e\fP was being ignored, the shell does not exit. | |
f73dda09 | 8788 | A trap on \fBERR\fP, if set, is executed before the shell exits. |
a05a1337 CR |
8789 | This option applies to the shell environment and each subshell environment |
8790 | separately (see | |
984a1947 | 8791 | .SM |
a05a1337 CR |
8792 | .B "COMMAND EXECUTION ENVIRONMENT" |
8793 | above), and may cause | |
8794 | subshells to exit before executing all the commands in the subshell. | |
1b1fe467 CR |
8795 | .if t .sp 0.5 |
8796 | .if n .sp 1 | |
8797 | If a compound command or shell function executes in a context | |
8798 | where \fB\-e\fP is being ignored, | |
8799 | none of the commands executed within the compound command or function body | |
8800 | will be affected by the \fB\-e\fP setting, even if \fB\-e\fP is set | |
8801 | and a command returns a failure status. | |
8802 | If a compound command or shell function sets \fB\-e\fP while executing in | |
8803 | a context where \fB\-e\fP is ignored, that setting will not have any | |
8804 | effect until the compound command or the command containing the function | |
8805 | call completes. | |
726f6388 JA |
8806 | .TP 8 |
8807 | .B \-f | |
8808 | Disable pathname expansion. | |
8809 | .TP 8 | |
8810 | .B \-h | |
ccc6cda3 | 8811 | Remember the location of commands as they are looked up for execution. |
cce855bc | 8812 | This is enabled by default. |
726f6388 JA |
8813 | .TP 8 |
8814 | .B \-k | |
ccc6cda3 JA |
8815 | All arguments in the form of assignment statements |
8816 | are placed in the environment for a command, not just | |
8817 | those that precede the command name. | |
726f6388 JA |
8818 | .TP 8 |
8819 | .B \-m | |
cce855bc | 8820 | Monitor mode. Job control is enabled. This option is on |
726f6388 JA |
8821 | by default for interactive shells on systems that support |
8822 | it (see | |
8823 | .SM | |
8824 | .B JOB CONTROL | |
f6da9f85 CR |
8825 | above). |
8826 | All processes run in a separate process group. | |
8827 | When a background job completes, the shell prints a line | |
8828 | containing its exit status. | |
726f6388 JA |
8829 | .TP 8 |
8830 | .B \-n | |
8831 | Read commands but do not execute them. This may be used to | |
ccc6cda3 | 8832 | check a shell script for syntax errors. This is ignored by |
726f6388 JA |
8833 | interactive shells. |
8834 | .TP 8 | |
ccc6cda3 JA |
8835 | .B \-o \fIoption\-name\fP |
8836 | The \fIoption\-name\fP can be one of the following: | |
726f6388 JA |
8837 | .RS |
8838 | .TP 8 | |
8839 | .B allexport | |
8840 | Same as | |
8841 | .BR \-a . | |
8842 | .TP 8 | |
8843 | .B braceexpand | |
ccc6cda3 JA |
8844 | Same as |
8845 | .BR \-B . | |
726f6388 JA |
8846 | .TP 8 |
8847 | .B emacs | |
8848 | Use an emacs-style command line editing interface. This is enabled | |
8849 | by default when the shell is interactive, unless the shell is started | |
8850 | with the | |
ccc6cda3 | 8851 | .B \-\-noediting |
726f6388 | 8852 | option. |
10a4e415 | 8853 | This also affects the editing interface used for \fBread \-e\fP. |
726f6388 | 8854 | .TP 8 |
a3143574 CR |
8855 | .B errexit |
8856 | Same as | |
8857 | .BR \-e . | |
8858 | .TP 8 | |
d3a24ed2 CR |
8859 | .B errtrace |
8860 | Same as | |
8861 | .BR \-E . | |
8862 | .TP 8 | |
8863 | .B functrace | |
8864 | Same as | |
8865 | .BR \-T . | |
8866 | .TP 8 | |
ccc6cda3 JA |
8867 | .B hashall |
8868 | Same as | |
8869 | .BR \-h . | |
8870 | .TP 8 | |
726f6388 JA |
8871 | .B histexpand |
8872 | Same as | |
8873 | .BR \-H . | |
8874 | .TP 8 | |
ccc6cda3 JA |
8875 | .B history |
8876 | Enable command history, as described above under | |
8877 | .SM | |
8878 | .BR HISTORY . | |
8879 | This option is on by default in interactive shells. | |
8880 | .TP 8 | |
726f6388 | 8881 | .B ignoreeof |
28ef6c31 JA |
8882 | The effect is as if the shell command |
8883 | .if t \f(CWIGNOREEOF=10\fP | |
8884 | .if n ``IGNOREEOF=10'' | |
8885 | had been executed | |
726f6388 JA |
8886 | (see |
8887 | .B Shell Variables | |
8888 | above). | |
8889 | .TP 8 | |
ccc6cda3 JA |
8890 | .B keyword |
8891 | Same as | |
8892 | .BR \-k . | |
726f6388 JA |
8893 | .TP 8 |
8894 | .B monitor | |
8895 | Same as | |
8896 | .BR \-m . | |
8897 | .TP 8 | |
8898 | .B noclobber | |
8899 | Same as | |
8900 | .BR \-C . | |
8901 | .TP 8 | |
8902 | .B noexec | |
8903 | Same as | |
8904 | .BR \-n . | |
8905 | .TP 8 | |
8906 | .B noglob | |
8907 | Same as | |
8908 | .BR \-f . | |
57a3f689 | 8909 | .TP 8 |
f73dda09 JA |
8910 | .B nolog |
8911 | Currently ignored. | |
726f6388 | 8912 | .TP 8 |
726f6388 JA |
8913 | .B notify |
8914 | Same as | |
8915 | .BR \-b . | |
8916 | .TP 8 | |
8917 | .B nounset | |
8918 | Same as | |
8919 | .BR \-u . | |
8920 | .TP 8 | |
ccc6cda3 JA |
8921 | .B onecmd |
8922 | Same as | |
8923 | .BR \-t . | |
8924 | .TP 8 | |
726f6388 JA |
8925 | .B physical |
8926 | Same as | |
8927 | .BR \-P . | |
8928 | .TP 8 | |
d3a24ed2 CR |
8929 | .B pipefail |
8930 | If set, the return value of a pipeline is the value of the last | |
8931 | (rightmost) command to exit with a non-zero status, or zero if all | |
8932 | commands in the pipeline exit successfully. | |
8933 | This option is disabled by default. | |
8934 | .TP 8 | |
726f6388 | 8935 | .B posix |
ccc6cda3 JA |
8936 | Change the behavior of |
8937 | .B bash | |
8938 | where the default operation differs | |
ac18b312 | 8939 | from the POSIX standard to match the standard (\fIposix mode\fP). |
c677e9e0 CR |
8940 | See |
8941 | .SM | |
8942 | .B "SEE ALSO" | |
8943 | below for a reference to a document that details how posix mode affects | |
8944 | bash's behavior. | |
726f6388 JA |
8945 | .TP 8 |
8946 | .B privileged | |
8947 | Same as | |
8948 | .BR \-p . | |
8949 | .TP 8 | |
8950 | .B verbose | |
8951 | Same as | |
8952 | .BR \-v . | |
8953 | .TP 8 | |
8954 | .B vi | |
8955 | Use a vi-style command line editing interface. | |
10a4e415 | 8956 | This also affects the editing interface used for \fBread \-e\fP. |
726f6388 JA |
8957 | .TP 8 |
8958 | .B xtrace | |
8959 | Same as | |
8960 | .BR \-x . | |
ccc6cda3 | 8961 | .sp .5 |
726f6388 | 8962 | .PP |
ccc6cda3 JA |
8963 | If |
8964 | .B \-o | |
8965 | is supplied with no \fIoption\-name\fP, the values of the current options are | |
726f6388 | 8966 | printed. |
ccc6cda3 JA |
8967 | If |
8968 | .B +o | |
8969 | is supplied with no \fIoption\-name\fP, a series of | |
8970 | .B set | |
8971 | commands to recreate the current option settings is displayed on | |
8972 | the standard output. | |
726f6388 JA |
8973 | .RE |
8974 | .TP 8 | |
8975 | .B \-p | |
8976 | Turn on | |
8977 | .I privileged | |
8978 | mode. In this mode, the | |
bb70624e | 8979 | .SM |
726f6388 | 8980 | .B $ENV |
b72432fd | 8981 | and |
bb70624e | 8982 | .SM |
b72432fd JA |
8983 | .B $BASH_ENV |
8984 | files are not processed, shell functions are not inherited from the | |
bb70624e JA |
8985 | environment, and the |
8986 | .SM | |
e77a3058 | 8987 | .BR SHELLOPTS , |
984a1947 | 8988 | .SM |
691aebcb | 8989 | .BR BASHOPTS , |
984a1947 | 8990 | .SM |
e77a3058 CR |
8991 | .BR CDPATH , |
8992 | and | |
984a1947 | 8993 | .SM |
e77a3058 CR |
8994 | .B GLOBIGNORE |
8995 | variables, if they appear in the environment, are ignored. | |
b72432fd JA |
8996 | If the shell is started with the effective user (group) id not equal to the |
8997 | real user (group) id, and the \fB\-p\fP option is not supplied, these actions | |
8998 | are taken and the effective user id is set to the real user id. | |
8999 | If the \fB\-p\fP option is supplied at startup, the effective user id is | |
9000 | not reset. | |
cce855bc | 9001 | Turning this option off causes the effective user |
726f6388 JA |
9002 | and group ids to be set to the real user and group ids. |
9003 | .TP 8 | |
9004 | .B \-t | |
9005 | Exit after reading and executing one command. | |
9006 | .TP 8 | |
9007 | .B \-u | |
2c471a92 CR |
9008 | Treat unset variables and parameters other than the special |
9009 | parameters "@" and "*" as an error when performing | |
726f6388 | 9010 | parameter expansion. If expansion is attempted on an |
2c471a92 | 9011 | unset variable or parameter, the shell prints an error message, and, |
ccc6cda3 | 9012 | if not interactive, exits with a non-zero status. |
726f6388 JA |
9013 | .TP 8 |
9014 | .B \-v | |
9015 | Print shell input lines as they are read. | |
9016 | .TP 8 | |
9017 | .B \-x | |
ccc6cda3 | 9018 | After expanding each \fIsimple command\fP, |
d3a24ed2 CR |
9019 | \fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or |
9020 | arithmetic \fBfor\fP command, display the expanded value of | |
726f6388 JA |
9021 | .SM |
9022 | .BR PS4 , | |
d3a24ed2 CR |
9023 | followed by the command and its expanded arguments |
9024 | or associated word list. | |
726f6388 | 9025 | .TP 8 |
ccc6cda3 JA |
9026 | .B \-B |
9027 | The shell performs brace expansion (see | |
9028 | .B Brace Expansion | |
9029 | above). This is on by default. | |
726f6388 JA |
9030 | .TP 8 |
9031 | .B \-C | |
ccc6cda3 JA |
9032 | If set, |
9033 | .B bash | |
9034 | does not overwrite an existing file with the | |
9035 | .BR > , | |
9036 | .BR >& , | |
9037 | and | |
9038 | .B <> | |
9039 | redirection operators. This may be overridden when | |
9040 | creating output files by using the redirection operator | |
9041 | .B >| | |
9042 | instead of | |
9043 | .BR > . | |
726f6388 | 9044 | .TP 8 |
d3a24ed2 CR |
9045 | .B \-E |
9046 | If set, any trap on \fBERR\fP is inherited by shell functions, command | |
9047 | substitutions, and commands executed in a subshell environment. | |
9048 | The \fBERR\fP trap is normally not inherited in such cases. | |
9049 | .TP 8 | |
726f6388 JA |
9050 | .B \-H |
9051 | Enable | |
9052 | .B ! | |
cce855bc | 9053 | style history substitution. This option is on by |
726f6388 JA |
9054 | default when the shell is interactive. |
9055 | .TP 8 | |
9056 | .B \-P | |
45c0f7f8 | 9057 | If set, the shell does not resolve symbolic links when executing |
ccc6cda3 | 9058 | commands such as |
726f6388 | 9059 | .B cd |
ccc6cda3 JA |
9060 | that change the current working directory. It uses the |
9061 | physical directory structure instead. By default, | |
9062 | .B bash | |
9063 | follows the logical chain of directories when performing commands | |
9064 | which change the current directory. | |
726f6388 | 9065 | .TP 8 |
d3a24ed2 | 9066 | .B \-T |
76a8d78d CR |
9067 | If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell |
9068 | functions, command substitutions, and commands executed in a | |
9069 | subshell environment. | |
9070 | The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited | |
9071 | in such cases. | |
d3a24ed2 | 9072 | .TP 8 |
726f6388 | 9073 | .B \-\- |
cce855bc | 9074 | If no arguments follow this option, then the positional parameters are |
726f6388 JA |
9075 | unset. Otherwise, the positional parameters are set to the |
9076 | \fIarg\fPs, even if some of them begin with a | |
9077 | .BR \- . | |
9078 | .TP 8 | |
9079 | .B \- | |
9080 | Signal the end of options, cause all remaining \fIarg\fPs to be | |
9081 | assigned to the positional parameters. The | |
9082 | .B \-x | |
9083 | and | |
9084 | .B \-v | |
9085 | options are turned off. | |
9086 | If there are no \fIarg\fPs, | |
9087 | the positional parameters remain unchanged. | |
9088 | .PD | |
9089 | .PP | |
cce855bc JA |
9090 | The options are off by default unless otherwise noted. |
9091 | Using + rather than \- causes these options to be turned off. | |
9092 | The options can also be specified as arguments to an invocation of | |
9093 | the shell. | |
9094 | The current set of options may be found in | |
726f6388 | 9095 | .BR $\- . |
cce855bc | 9096 | The return status is always true unless an invalid option is encountered. |
726f6388 JA |
9097 | .RE |
9098 | .TP | |
9099 | \fBshift\fP [\fIn\fP] | |
9100 | The positional parameters from \fIn\fP+1 ... are renamed to | |
9101 | .B $1 | |
9102 | .B .... | |
9103 | Parameters represented by the numbers \fB$#\fP | |
9104 | down to \fB$#\fP\-\fIn\fP+1 are unset. | |
ccc6cda3 JA |
9105 | .I n |
9106 | must be a non-negative number less than or equal to \fB$#\fP. | |
726f6388 JA |
9107 | If |
9108 | .I n | |
9109 | is 0, no parameters are changed. | |
9110 | If | |
9111 | .I n | |
9112 | is not given, it is assumed to be 1. | |
726f6388 JA |
9113 | If |
9114 | .I n | |
9115 | is greater than \fB$#\fP, the positional parameters are not changed. | |
ccc6cda3 | 9116 | The return status is greater than zero if |
726f6388 JA |
9117 | .I n |
9118 | is greater than | |
9119 | .B $# | |
ccc6cda3 JA |
9120 | or less than zero; otherwise 0. |
9121 | .TP | |
9122 | \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...] | |
1442f67c CR |
9123 | Toggle the values of settings controlling optional shell behavior. |
9124 | The settings can be either those listed below, or, if the | |
9125 | .B \-o | |
9126 | option is used, those available with the | |
9127 | .B \-o | |
9128 | option to the \fBset\fP builtin command. | |
ccc6cda3 JA |
9129 | With no options, or with the |
9130 | .B \-p | |
9131 | option, a list of all settable options is displayed, with | |
cce855bc JA |
9132 | an indication of whether or not each is set. |
9133 | The \fB\-p\fP option causes output to be displayed in a form that | |
9134 | may be reused as input. | |
9135 | Other options have the following meanings: | |
ccc6cda3 JA |
9136 | .RS |
9137 | .PD 0 | |
9138 | .TP | |
9139 | .B \-s | |
9140 | Enable (set) each \fIoptname\fP. | |
9141 | .TP | |
9142 | .B \-u | |
9143 | Disable (unset) each \fIoptname\fP. | |
9144 | .TP | |
9145 | .B \-q | |
9146 | Suppresses normal output (quiet mode); the return status indicates | |
9147 | whether the \fIoptname\fP is set or unset. | |
9148 | If multiple \fIoptname\fP arguments are given with | |
9149 | .BR \-q , | |
9150 | the return status is zero if all \fIoptnames\fP are enabled; non-zero | |
9151 | otherwise. | |
9152 | .TP | |
9153 | .B \-o | |
9154 | Restricts the values of \fIoptname\fP to be those defined for the | |
9155 | .B \-o | |
9156 | option to the | |
9157 | .B set | |
9158 | builtin. | |
9159 | .PD | |
9160 | .PP | |
9161 | If either | |
9162 | .B \-s | |
9163 | or | |
9164 | .B \-u | |
b28ff8c9 CR |
9165 | is used with no \fIoptname\fP arguments, |
9166 | .B shopt | |
9167 | shows only those options which are set or unset, respectively. | |
ccc6cda3 JA |
9168 | Unless otherwise noted, the \fBshopt\fP options are disabled (unset) |
9169 | by default. | |
9170 | .PP | |
9171 | The return status when listing options is zero if all \fIoptnames\fP | |
9172 | are enabled, non-zero otherwise. When setting or unsetting options, | |
cce855bc | 9173 | the return status is zero unless an \fIoptname\fP is not a valid shell |
ccc6cda3 JA |
9174 | option. |
9175 | .PP | |
9176 | The list of \fBshopt\fP options is: | |
9177 | .if t .sp .5v | |
9178 | .if n .sp 1v | |
9179 | .PD 0 | |
9180 | .TP 8 | |
d3ad40de CR |
9181 | .B autocd |
9182 | If set, a command name that is the name of a directory is executed as if | |
9183 | it were the argument to the \fBcd\fP command. | |
9184 | This option is only used by interactive shells. | |
9185 | .TP 8 | |
ccc6cda3 JA |
9186 | .B cdable_vars |
9187 | If set, an argument to the | |
9188 | .B cd | |
9189 | builtin command that | |
9190 | is not a directory is assumed to be the name of a variable whose | |
9191 | value is the directory to change to. | |
9192 | .TP 8 | |
9193 | .B cdspell | |
9194 | If set, minor errors in the spelling of a directory component in a | |
9195 | .B cd | |
9196 | command will be corrected. | |
9197 | The errors checked for are transposed characters, | |
9198 | a missing character, and one character too many. | |
b28ff8c9 | 9199 | If a correction is found, the corrected filename is printed, |
ccc6cda3 | 9200 | and the command proceeds. |
d166f048 | 9201 | This option is only used by interactive shells. |
ccc6cda3 JA |
9202 | .TP 8 |
9203 | .B checkhash | |
9204 | If set, \fBbash\fP checks that a command found in the hash | |
9205 | table exists before trying to execute it. If a hashed command no | |
9206 | longer exists, a normal path search is performed. | |
9207 | .TP 8 | |
d3ad40de | 9208 | .B checkjobs |
29d25b54 | 9209 | If set, \fBbash\fP lists the status of any stopped and running jobs before |
d3ad40de CR |
9210 | exiting an interactive shell. If any jobs are running, this causes |
9211 | the exit to be deferred until a second exit is attempted without an | |
984a1947 CR |
9212 | intervening command (see |
9213 | .SM | |
9214 | .B "JOB CONTROL" | |
9215 | above). The shell always | |
d3ad40de CR |
9216 | postpones exiting if any jobs are stopped. |
9217 | .TP 8 | |
ccc6cda3 | 9218 | .B checkwinsize |
51f7ea36 | 9219 | If set, \fBbash\fP checks the window size after each command |
ccc6cda3 JA |
9220 | and, if necessary, updates the values of |
9221 | .SM | |
9222 | .B LINES | |
9223 | and | |
9224 | .SM | |
9225 | .BR COLUMNS . | |
9226 | .TP 8 | |
9227 | .B cmdhist | |
9228 | If set, | |
9229 | .B bash | |
9230 | attempts to save all lines of a multiple-line | |
9231 | command in the same history entry. This allows | |
9232 | easy re-editing of multi-line commands. | |
9233 | .TP 8 | |
35ee8ea0 CR |
9234 | .B compat31 |
9235 | If set, | |
9236 | .B bash | |
9237 | changes its behavior to that of version 3.1 with respect to quoted | |
5a318736 CR |
9238 | arguments to the \fB[[\fP conditional command's \fB=~\fP operator |
9239 | and locale-specific string comparison when using the \fB[[\fP | |
54a1fa7c CR |
9240 | conditional command's \fB<\fP and \fB>\fP operators. |
9241 | Bash versions prior to bash-4.1 use ASCII collation and | |
9242 | .IR strcmp (3); | |
5a318736 | 9243 | bash-4.1 and later use the current locale's collation sequence and |
54a1fa7c | 9244 | .IR strcoll (3). |
cd0ef727 | 9245 | .TP 8 |
5a318736 CR |
9246 | .B compat32 |
9247 | If set, | |
9248 | .B bash | |
9249 | changes its behavior to that of version 3.2 with respect to | |
9250 | locale-specific string comparison when using the \fB[[\fP | |
9251 | conditional command's \fB<\fP and \fB>\fP operators (see previous item). | |
9252 | .TP 8 | |
cd0ef727 CR |
9253 | .B compat40 |
9254 | If set, | |
9255 | .B bash | |
9256 | changes its behavior to that of version 4.0 with respect to locale-specific | |
54a1fa7c | 9257 | string comparison when using the \fB[[\fP |
5a318736 CR |
9258 | conditional command's \fB<\fP and \fB>\fP operators (see description of |
9259 | \fBcompat31\fP) | |
54a1fa7c | 9260 | and the effect of interrupting a command list. |
5a318736 CR |
9261 | Bash versions 4.0 and later interrupt the list as if the shell received the |
9262 | interrupt; previous versions continue with the next command in the list. | |
cd0ef727 | 9263 | .TP 8 |
67362c60 | 9264 | .B compat41 |
67362c60 CR |
9265 | If set, |
9266 | .BR bash , | |
c677e9e0 | 9267 | when in \fIposix\fP mode, treats a single quote in a double-quoted |
67362c60 CR |
9268 | parameter expansion as a special character. The single quotes must match |
9269 | (an even number) and the characters between the single quotes are considered | |
9270 | quoted. This is the behavior of posix mode through version 4.1. | |
9271 | The default bash behavior remains as in previous versions. | |
9272 | .TP 8 | |
7175a77f CR |
9273 | .B compat42 |
9274 | If set, | |
9275 | .B bash | |
9276 | does not process the replacement string in the pattern substitution word | |
9277 | expansion using quote removal. | |
9278 | .TP 8 | |
ddef12ff CR |
9279 | .B complete_fullquote |
9280 | If set, | |
9281 | .B bash | |
9282 | quotes all shell metacharacters in filenames and directory names when | |
9283 | performing completion. | |
9284 | If not set, | |
9285 | .B bash | |
9286 | removes metacharacters such as the dollar sign from the set of | |
9287 | characters that will be quoted in completed filenames | |
9288 | when these metacharacters appear in shell variable references in words to be | |
9289 | completed. | |
9290 | This means that dollar signs in variable names that expand to directories | |
9291 | will not be quoted; | |
9292 | however, any dollar signs appearing in filenames will not be quoted, either. | |
9293 | This is active only when bash is using backslashes to quote completed | |
9294 | filenames. | |
9295 | This variable is set by default, which is the default bash behavior in | |
9296 | versions through 4.2. | |
9297 | .TP 8 | |
74d0116b CR |
9298 | .B direxpand |
9299 | If set, | |
9300 | .B bash | |
9301 | replaces directory names with the results of word expansion when performing | |
9302 | filename completion. This changes the contents of the readline editing | |
9303 | buffer. | |
9304 | If not set, | |
9305 | .B bash | |
9306 | attempts to preserve what the user typed. | |
9307 | .TP 8 | |
4ac1ff98 CR |
9308 | .B dirspell |
9309 | If set, | |
9310 | .B bash | |
9311 | attempts spelling correction on directory names during word completion | |
9312 | if the directory name initially supplied does not exist. | |
9313 | .TP 8 | |
ccc6cda3 JA |
9314 | .B dotglob |
9315 | If set, | |
9316 | .B bash | |
9317 | includes filenames beginning with a `.' in the results of pathname | |
9318 | expansion. | |
9319 | .TP 8 | |
9320 | .B execfail | |
9321 | If set, a non-interactive shell will not exit if | |
9322 | it cannot execute the file specified as an argument to the | |
9323 | .B exec | |
9324 | builtin command. An interactive shell does not exit if | |
9325 | .B exec | |
9326 | fails. | |
9327 | .TP 8 | |
9328 | .B expand_aliases | |
9329 | If set, aliases are expanded as described above under | |
9330 | .SM | |
9331 | .BR ALIASES . | |
9332 | This option is enabled by default for interactive shells. | |
9333 | .TP 8 | |
d3a24ed2 CR |
9334 | .B extdebug |
9335 | If set, behavior intended for use by debuggers is enabled: | |
9336 | .RS | |
9337 | .TP | |
9338 | .B 1. | |
9339 | The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source | |
9340 | file name and line number corresponding to each function name supplied | |
9341 | as an argument. | |
9342 | .TP | |
9343 | .B 2. | |
9344 | If the command run by the \fBDEBUG\fP trap returns a non-zero value, the | |
9345 | next command is skipped and not executed. | |
9346 | .TP | |
9347 | .B 3. | |
9348 | If the command run by the \fBDEBUG\fP trap returns a value of 2, and the | |
9349 | shell is executing in a subroutine (a shell function or a shell script | |
9350 | executed by the \fB.\fP or \fBsource\fP builtins), a call to | |
9351 | \fBreturn\fP is simulated. | |
2206f89a CR |
9352 | .TP |
9353 | .B 4. | |
984a1947 CR |
9354 | .SM |
9355 | .B BASH_ARGC | |
9356 | and | |
9357 | .SM | |
9358 | .B BASH_ARGV | |
9359 | are updated as described in their descriptions above. | |
2206f89a CR |
9360 | .TP |
9361 | .B 5. | |
9362 | Function tracing is enabled: command substitution, shell functions, and | |
9363 | subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the | |
9364 | \fBDEBUG\fP and \fBRETURN\fP traps. | |
9365 | .TP | |
9366 | .B 6. | |
9367 | Error tracing is enabled: command substitution, shell functions, and | |
9368 | subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the | |
5cdaaf76 | 9369 | \fBERR\fP trap. |
d3a24ed2 CR |
9370 | .RE |
9371 | .TP 8 | |
cce855bc JA |
9372 | .B extglob |
9373 | If set, the extended pattern matching features described above under | |
9374 | \fBPathname Expansion\fP are enabled. | |
9375 | .TP 8 | |
d3a24ed2 | 9376 | .B extquote |
20587658 | 9377 | If set, \fB$\fP\(aq\fIstring\fP\(aq and \fB$\fP"\fIstring\fP" quoting is |
d3a24ed2 CR |
9378 | performed within \fB${\fP\fIparameter\fP\fB}\fP expansions |
9379 | enclosed in double quotes. This option is enabled by default. | |
9380 | .TP 8 | |
9381 | .B failglob | |
9382 | If set, patterns which fail to match filenames during pathname expansion | |
9383 | result in an expansion error. | |
9384 | .TP 8 | |
9385 | .B force_fignore | |
984a1947 CR |
9386 | If set, the suffixes specified by the |
9387 | .SM | |
9388 | .B FIGNORE | |
9389 | shell variable | |
d3a24ed2 CR |
9390 | cause words to be ignored when performing word completion even if |
9391 | the ignored words are the only possible completions. | |
9392 | See | |
9393 | .SM | |
9394 | \fBSHELL VARIABLES\fP | |
984a1947 CR |
9395 | above for a description of |
9396 | .SM | |
9397 | .BR FIGNORE . | |
d3a24ed2 CR |
9398 | This option is enabled by default. |
9399 | .TP 8 | |
74d0116b | 9400 | .B globasciiranges |
1442f67c | 9401 | If set, range expressions used in pattern matching bracket expressions (see |
74d0116b CR |
9402 | .SM |
9403 | .B Pattern Matching | |
9404 | above) behave as if in the traditional C locale when performing | |
9405 | comparisons. That is, the current locale's collating sequence | |
9406 | is not taken into account, so | |
9407 | .B b | |
9408 | will not collate between | |
9409 | .B A | |
9410 | and | |
9411 | .BR B , | |
9412 | and upper-case and lower-case ASCII characters will collate together. | |
9413 | .TP 8 | |
4ac1ff98 | 9414 | .B globstar |
d0ca3503 | 9415 | If set, the pattern \fB**\fP used in a pathname expansion context will |
54a1fa7c | 9416 | match all files and zero or more directories and subdirectories. |
4ac1ff98 CR |
9417 | If the pattern is followed by a \fB/\fP, only directories and |
9418 | subdirectories match. | |
9419 | .TP 8 | |
d3a24ed2 CR |
9420 | .B gnu_errfmt |
9421 | If set, shell error messages are written in the standard GNU error | |
9422 | message format. | |
9423 | .TP 8 | |
ccc6cda3 JA |
9424 | .B histappend |
9425 | If set, the history list is appended to the file named by the value | |
9426 | of the | |
984a1947 | 9427 | .SM |
ccc6cda3 JA |
9428 | .B HISTFILE |
9429 | variable when the shell exits, rather than overwriting the file. | |
9430 | .TP 8 | |
9431 | .B histreedit | |
9432 | If set, and | |
9433 | .B readline | |
9434 | is being used, a user is given the opportunity to re-edit a | |
9435 | failed history substitution. | |
9436 | .TP 8 | |
9437 | .B histverify | |
9438 | If set, and | |
9439 | .B readline | |
9440 | is being used, the results of history substitution are not immediately | |
9441 | passed to the shell parser. Instead, the resulting line is loaded into | |
9442 | the \fBreadline\fP editing buffer, allowing further modification. | |
9443 | .TP 8 | |
9444 | .B hostcomplete | |
9445 | If set, and | |
9446 | .B readline | |
cce855bc JA |
9447 | is being used, \fBbash\fP will attempt to perform hostname completion when a |
9448 | word containing a \fB@\fP is being completed (see | |
ccc6cda3 JA |
9449 | .B Completing |
9450 | under | |
9451 | .SM | |
9452 | .B READLINE | |
9453 | above). | |
9454 | This is enabled by default. | |
9455 | .TP 8 | |
cce855bc JA |
9456 | .B huponexit |
9457 | If set, \fBbash\fP will send | |
9458 | .SM | |
9459 | .B SIGHUP | |
9460 | to all jobs when an interactive login shell exits. | |
9461 | .TP 8 | |
ccc6cda3 JA |
9462 | .B interactive_comments |
9463 | If set, allow a word beginning with | |
9464 | .B # | |
9465 | to cause that word and all remaining characters on that | |
9466 | line to be ignored in an interactive shell (see | |
9467 | .SM | |
9468 | .B COMMENTS | |
9469 | above). This option is enabled by default. | |
9470 | .TP 8 | |
7d92f73f CR |
9471 | .B lastpipe |
9472 | If set, and job control is not active, the shell runs the last command of | |
9473 | a pipeline not executed in the background in the current shell environment. | |
9474 | .TP 8 | |
ccc6cda3 JA |
9475 | .B lithist |
9476 | If set, and the | |
9477 | .B cmdhist | |
9478 | option is enabled, multi-line commands are saved to the history with | |
9479 | embedded newlines rather than using semicolon separators where possible. | |
9480 | .TP 8 | |
f73dda09 JA |
9481 | .B login_shell |
9482 | The shell sets this option if it is started as a login shell (see | |
9483 | .SM | |
9484 | .B "INVOCATION" | |
9485 | above). | |
9486 | The value may not be changed. | |
9487 | .TP 8 | |
ccc6cda3 JA |
9488 | .B mailwarn |
9489 | If set, and a file that \fBbash\fP is checking for mail has been | |
9490 | accessed since the last time it was checked, the message ``The mail in | |
9491 | \fImailfile\fP has been read'' is displayed. | |
9492 | .TP 8 | |
bb70624e JA |
9493 | .B no_empty_cmd_completion |
9494 | If set, and | |
9495 | .B readline | |
9496 | is being used, | |
9497 | .B bash | |
984a1947 CR |
9498 | will not attempt to search the |
9499 | .SM | |
9500 | .B PATH | |
9501 | for possible completions when | |
bb70624e JA |
9502 | completion is attempted on an empty line. |
9503 | .TP 8 | |
cce855bc JA |
9504 | .B nocaseglob |
9505 | If set, | |
9506 | .B bash | |
9507 | matches filenames in a case\-insensitive fashion when performing pathname | |
9508 | expansion (see | |
9509 | .B Pathname Expansion | |
9510 | above). | |
9511 | .TP 8 | |
2206f89a CR |
9512 | .B nocasematch |
9513 | If set, | |
9514 | .B bash | |
9515 | matches patterns in a case\-insensitive fashion when performing matching | |
9516 | while executing \fBcase\fP or \fB[[\fP conditional commands. | |
9517 | .TP 8 | |
ccc6cda3 JA |
9518 | .B nullglob |
9519 | If set, | |
9520 | .B bash | |
9521 | allows patterns which match no | |
9522 | files (see | |
9523 | .B Pathname Expansion | |
9524 | above) | |
9525 | to expand to a null string, rather than themselves. | |
9526 | .TP 8 | |
bb70624e JA |
9527 | .B progcomp |
9528 | If set, the programmable completion facilities (see | |
9529 | \fBProgrammable Completion\fP above) are enabled. | |
9530 | This option is enabled by default. | |
9531 | .TP 8 | |
ccc6cda3 | 9532 | .B promptvars |
d3a24ed2 CR |
9533 | If set, prompt strings undergo |
9534 | parameter expansion, command substitution, arithmetic | |
9535 | expansion, and quote removal after being expanded as described in | |
ccc6cda3 JA |
9536 | .SM |
9537 | .B PROMPTING | |
9538 | above. This option is enabled by default. | |
9539 | .TP 8 | |
b72432fd JA |
9540 | .B restricted_shell |
9541 | The shell sets this option if it is started in restricted mode (see | |
9542 | .SM | |
9543 | .B "RESTRICTED SHELL" | |
9544 | below). | |
9545 | The value may not be changed. | |
9546 | This is not reset when the startup files are executed, allowing | |
9547 | the startup files to discover whether or not a shell is restricted. | |
9548 | .TP 8 | |
ccc6cda3 JA |
9549 | .B shift_verbose |
9550 | If set, the | |
9551 | .B shift | |
9552 | builtin prints an error message when the shift count exceeds the | |
9553 | number of positional parameters. | |
9554 | .TP 8 | |
9555 | .B sourcepath | |
9556 | If set, the | |
9557 | \fBsource\fP (\fB.\fP) builtin uses the value of | |
9558 | .SM | |
9559 | .B PATH | |
9560 | to find the directory containing the file supplied as an argument. | |
cce855bc | 9561 | This option is enabled by default. |
bb70624e JA |
9562 | .TP 8 |
9563 | .B xpg_echo | |
9564 | If set, the \fBecho\fP builtin expands backslash-escape sequences | |
9565 | by default. | |
ccc6cda3 | 9566 | .RE |
54a1fa7c | 9567 | .PD |
726f6388 JA |
9568 | .TP |
9569 | \fBsuspend\fP [\fB\-f\fP] | |
9570 | Suspend the execution of this shell until it receives a | |
9571 | .SM | |
9572 | .B SIGCONT | |
09767ff0 | 9573 | signal. A login shell cannot be suspended; the |
726f6388 | 9574 | .B \-f |
09767ff0 CR |
9575 | option can be used to override this and force the suspension. |
9576 | The return status is 0 unless the shell is a login shell and | |
726f6388 JA |
9577 | .B \-f |
9578 | is not supplied, or if job control is not enabled. | |
9579 | .TP | |
726f6388 | 9580 | \fBtest\fP \fIexpr\fP |
7117c2d2 | 9581 | .PD 0 |
726f6388 JA |
9582 | .TP |
9583 | \fB[\fP \fIexpr\fP \fB]\fP | |
b28ff8c9 | 9584 | Return a status of 0 (true) or 1 (false) depending on |
726f6388 JA |
9585 | the evaluation of the conditional expression |
9586 | .IR expr . | |
cce855bc JA |
9587 | Each operator and operand must be a separate argument. |
9588 | Expressions are composed of the primaries described above under | |
9589 | .SM | |
9590 | .BR "CONDITIONAL EXPRESSIONS" . | |
3ffb039a CR |
9591 | \fBtest\fP does not accept any options, nor does it accept and ignore |
9592 | an argument of \fB\-\-\fP as signifying the end of options. | |
cce855bc JA |
9593 | .if t .sp 0.5 |
9594 | .if n .sp 1 | |
9595 | Expressions may be combined using the following operators, listed | |
9596 | in decreasing order of precedence. | |
641d8f00 | 9597 | The evaluation depends on the number of arguments; see below. |
06dff54a | 9598 | Operator precedence is used when there are five or more arguments. |
726f6388 JA |
9599 | .RS |
9600 | .PD 0 | |
9601 | .TP | |
726f6388 JA |
9602 | .B ! \fIexpr\fP |
9603 | True if | |
9604 | .I expr | |
9605 | is false. | |
9606 | .TP | |
cce855bc JA |
9607 | .B ( \fIexpr\fP ) |
9608 | Returns the value of \fIexpr\fP. | |
9609 | This may be used to override the normal precedence of operators. | |
9610 | .TP | |
726f6388 JA |
9611 | \fIexpr1\fP \-\fBa\fP \fIexpr2\fP |
9612 | True if both | |
9613 | .I expr1 | |
cce855bc | 9614 | and |
726f6388 JA |
9615 | .I expr2 |
9616 | are true. | |
9617 | .TP | |
9618 | \fIexpr1\fP \-\fBo\fP \fIexpr2\fP | |
9619 | True if either | |
9620 | .I expr1 | |
cce855bc | 9621 | or |
726f6388 JA |
9622 | .I expr2 |
9623 | is true. | |
cce855bc JA |
9624 | .PD |
9625 | .PP | |
9626 | \fBtest\fP and \fB[\fP evaluate conditional | |
9627 | expressions using a set of rules based on the number of arguments. | |
9628 | .if t .sp 0.5 | |
9629 | .if n .sp 1 | |
9630 | .PD 0 | |
726f6388 | 9631 | .TP |
cce855bc JA |
9632 | 0 arguments |
9633 | The expression is false. | |
9634 | .TP | |
9635 | 1 argument | |
9636 | The expression is true if and only if the argument is not null. | |
9637 | .TP | |
9638 | 2 arguments | |
9639 | If the first argument is \fB!\fP, the expression is true if and | |
9640 | only if the second argument is null. | |
9641 | If the first argument is one of the unary conditional operators listed above | |
9642 | under | |
726f6388 | 9643 | .SM |
cce855bc JA |
9644 | .BR "CONDITIONAL EXPRESSIONS" , |
9645 | the expression is true if the unary test is true. | |
9646 | If the first argument is not a valid unary conditional operator, the expression | |
9647 | is false. | |
9648 | .TP | |
9649 | 3 arguments | |
adc6cff5 | 9650 | The following conditions are applied in the order listed. |
cce855bc JA |
9651 | If the second argument is one of the binary conditional operators listed above |
9652 | under | |
9653 | .SM | |
9654 | .BR "CONDITIONAL EXPRESSIONS" , | |
9655 | the result of the expression is the result of the binary test using | |
9656 | the first and third arguments as operands. | |
641d8f00 CR |
9657 | The \fB\-a\fP and \fB\-o\fP operators are considered binary operators |
9658 | when there are three arguments. | |
cce855bc JA |
9659 | If the first argument is \fB!\fP, the value is the negation of |
9660 | the two-argument test using the second and third arguments. | |
9661 | If the first argument is exactly \fB(\fP and the third argument is | |
9662 | exactly \fB)\fP, the result is the one-argument test of the second | |
9663 | argument. | |
9664 | Otherwise, the expression is false. | |
cce855bc JA |
9665 | .TP |
9666 | 4 arguments | |
9667 | If the first argument is \fB!\fP, the result is the negation of | |
9668 | the three-argument expression composed of the remaining arguments. | |
9669 | Otherwise, the expression is parsed and evaluated according to | |
9670 | precedence using the rules listed above. | |
9671 | .TP | |
9672 | 5 or more arguments | |
9673 | The expression is parsed and evaluated according to precedence | |
9674 | using the rules listed above. | |
54a1fa7c CR |
9675 | .if t .sp 0.5 |
9676 | .if n .sp 1 | |
9677 | .LP | |
9678 | When used with \fBtest\fP or \fB[\fP, the \fB<\fP and \fB>\fP operators | |
9679 | sort lexicographically using ASCII ordering. | |
726f6388 | 9680 | .RE |
cce855bc | 9681 | .PD |
726f6388 JA |
9682 | .TP |
9683 | .B times | |
9684 | Print the accumulated user and system times for the shell and | |
9685 | for processes run from the shell. The return status is 0. | |
9686 | .TP | |
61deeb13 | 9687 | \fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...] |
726f6388 JA |
9688 | The command |
9689 | .I arg | |
9690 | is to be read and executed when the shell receives | |
9691 | signal(s) | |
9692 | .IR sigspec . | |
9693 | If | |
9694 | .I arg | |
61deeb13 | 9695 | is absent (and there is a single \fIsigspec\fP) or |
726f6388 | 9696 | .BR \- , |
61deeb13 CR |
9697 | each specified signal is |
9698 | reset to its original disposition (the value it had | |
d166f048 JA |
9699 | upon entrance to the shell). |
9700 | If | |
726f6388 | 9701 | .I arg |
d166f048 JA |
9702 | is the null string the signal specified by each |
9703 | .I sigspec | |
9704 | is ignored by the shell and by the commands it invokes. | |
ccc6cda3 JA |
9705 | If |
9706 | .I arg | |
bb70624e | 9707 | is not present and |
ccc6cda3 | 9708 | .B \-p |
bb70624e | 9709 | has been supplied, then the trap commands associated with each |
ccc6cda3 | 9710 | .I sigspec |
bb70624e JA |
9711 | are displayed. |
9712 | If no arguments are supplied or if only | |
ccc6cda3 JA |
9713 | .B \-p |
9714 | is given, | |
9715 | .B trap | |
61deeb13 | 9716 | prints the list of commands associated with each signal. |
d3a24ed2 CR |
9717 | The |
9718 | .B \-l | |
9719 | option causes the shell to print a list of signal names and | |
9720 | their corresponding numbers. | |
d166f048 | 9721 | Each |
726f6388 JA |
9722 | .I sigspec |
9723 | is either | |
d166f048 | 9724 | a signal name defined in <\fIsignal.h\fP>, or a signal number. |
9c7f20c7 CR |
9725 | Signal names are case insensitive and the |
9726 | .SM | |
9727 | .B SIG | |
9728 | prefix is optional. | |
4301bca7 CR |
9729 | .if t .sp 0.5 |
9730 | .if n .sp 1 | |
d166f048 | 9731 | If a |
726f6388 JA |
9732 | .I sigspec |
9733 | is | |
9734 | .SM | |
9735 | .B EXIT | |
9736 | (0) the command | |
9737 | .I arg | |
f73dda09 JA |
9738 | is executed on exit from the shell. |
9739 | If a | |
ccc6cda3 JA |
9740 | .I sigspec |
9741 | is | |
9742 | .SM | |
9743 | .BR DEBUG , | |
9744 | the command | |
9745 | .I arg | |
d3a24ed2 CR |
9746 | is executed before every \fIsimple command\fP, \fIfor\fP command, |
9747 | \fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP | |
9748 | command, and before the first command executes in a shell function (see | |
ccc6cda3 JA |
9749 | .SM |
9750 | .B SHELL GRAMMAR | |
9751 | above). | |
40b074c6 | 9752 | Refer to the description of the \fBextdebug\fP option to the |
d3a24ed2 | 9753 | \fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap. |
f73dda09 JA |
9754 | If a |
9755 | .I sigspec | |
9756 | is | |
9757 | .SM | |
4301bca7 CR |
9758 | .BR RETURN , |
9759 | the command | |
9760 | .I arg | |
e05be32d CR |
9761 | is executed each time a shell function or a script executed with |
9762 | the \fB.\fP or \fBsource\fP builtins finishes executing. | |
4301bca7 CR |
9763 | .if t .sp 0.5 |
9764 | .if n .sp 1 | |
9765 | If a | |
9766 | .I sigspec | |
9767 | is | |
9768 | .SM | |
f73dda09 JA |
9769 | .BR ERR , |
9770 | the command | |
9771 | .I arg | |
1b1fe467 CR |
9772 | is executed whenever a |
9773 | a pipeline (which may consist of a single simple | |
9774 | command), a list, or a compound command returns a | |
9775 | non\-zero exit status, | |
5e13499c | 9776 | subject to the following conditions. |
f73dda09 JA |
9777 | The |
9778 | .SM | |
d3a24ed2 CR |
9779 | .B ERR |
9780 | trap is not executed if the failed | |
9781 | command is part of the command list immediately following a | |
9782 | .B while | |
f73dda09 | 9783 | or |
d3a24ed2 CR |
9784 | .B until |
9785 | keyword, | |
9786 | part of the test in an | |
f73dda09 | 9787 | .I if |
9d85af6d | 9788 | statement, part of a command executed in a |
f73dda09 JA |
9789 | .B && |
9790 | or | |
adc6cff5 | 9791 | .B || |
1b1fe467 CR |
9792 | list except the command following the final \fB&&\fP or \fB||\fP, |
9793 | any command in a pipeline but the last, | |
9794 | or if the command's return value is | |
9795 | being inverted using | |
f73dda09 | 9796 | .BR ! . |
1b1fe467 | 9797 | These are the same conditions obeyed by the \fBerrexit\fP (\fB\-e\fP) option. |
4301bca7 CR |
9798 | .if t .sp 0.5 |
9799 | .if n .sp 1 | |
726f6388 | 9800 | Signals ignored upon entry to the shell cannot be trapped or reset. |
d3ad40de | 9801 | Trapped signals that are not being ignored are reset to their original |
4301bca7 | 9802 | values in a subshell or subshell environment when one is created. |
d166f048 | 9803 | The return status is false if any |
ccc6cda3 JA |
9804 | .I sigspec |
9805 | is invalid; otherwise | |
726f6388 JA |
9806 | .B trap |
9807 | returns true. | |
9808 | .TP | |
7117c2d2 | 9809 | \fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...] |
726f6388 JA |
9810 | With no options, |
9811 | indicate how each | |
9812 | .I name | |
9813 | would be interpreted if used as a command name. | |
9814 | If the | |
cce855bc JA |
9815 | .B \-t |
9816 | option is used, | |
726f6388 | 9817 | .B type |
ccc6cda3 | 9818 | prints a string which is one of |
726f6388 JA |
9819 | .IR alias , |
9820 | .IR keyword , | |
9821 | .IR function , | |
9822 | .IR builtin , | |
9823 | or | |
9824 | .I file | |
9825 | if | |
9826 | .I name | |
9827 | is an alias, shell reserved word, function, builtin, or disk file, | |
ccc6cda3 JA |
9828 | respectively. |
9829 | If the | |
9830 | .I name | |
9831 | is not found, then nothing is printed, and an exit status of false | |
9832 | is returned. | |
726f6388 | 9833 | If the |
cce855bc JA |
9834 | .B \-p |
9835 | option is used, | |
726f6388 JA |
9836 | .B type |
9837 | either returns the name of the disk file | |
9838 | that would be executed if | |
9839 | .I name | |
9840 | were specified as a command name, | |
28ef6c31 JA |
9841 | or nothing if |
9842 | .if t \f(CWtype -t name\fP | |
9843 | .if n ``type -t name'' | |
726f6388 JA |
9844 | would not return |
9845 | .IR file . | |
7117c2d2 JA |
9846 | The |
9847 | .B \-P | |
9848 | option forces a | |
9849 | .SM | |
9850 | .B PATH | |
9851 | search for each \fIname\fP, even if | |
9852 | .if t \f(CWtype -t name\fP | |
9853 | .if n ``type -t name'' | |
9854 | would not return | |
9855 | .IR file . | |
726f6388 | 9856 | If a command is hashed, |
cce855bc | 9857 | .B \-p |
7117c2d2 JA |
9858 | and |
9859 | .B \-P | |
b28ff8c9 | 9860 | print the hashed value, which is not necessarily the file that appears |
726f6388 JA |
9861 | first in |
9862 | .SM | |
9863 | .BR PATH . | |
9864 | If the | |
cce855bc JA |
9865 | .B \-a |
9866 | option is used, | |
726f6388 JA |
9867 | .B type |
9868 | prints all of the places that contain | |
9869 | an executable named | |
9870 | .IR name . | |
9871 | This includes aliases and functions, | |
9872 | if and only if the | |
cce855bc JA |
9873 | .B \-p |
9874 | option is not also used. | |
726f6388 JA |
9875 | The table of hashed commands is not consulted |
9876 | when using | |
cce855bc | 9877 | .BR \-a . |
7117c2d2 JA |
9878 | The |
9879 | .B \-f | |
9880 | option suppresses shell function lookup, as with the \fBcommand\fP builtin. | |
726f6388 | 9881 | .B type |
6a8fd0ed CR |
9882 | returns true if all of the arguments are found, false if |
9883 | any are not found. | |
726f6388 | 9884 | .TP |
6fbe7620 | 9885 | \fBulimit\fP [\fB\-HSTabcdefilmnpqrstuvx\fP [\fIlimit\fP]] |
ccc6cda3 | 9886 | Provides control over the resources available to the shell and to |
f73dda09 | 9887 | processes started by it, on systems that allow such control. |
ccc6cda3 | 9888 | The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is |
79e6c7dc CR |
9889 | set for the given resource. |
9890 | A hard limit cannot be increased by a non-root user once it is set; | |
9891 | a soft limit may be increased up to the value of the hard limit. | |
ccc6cda3 JA |
9892 | If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard |
9893 | limits are set. | |
f73dda09 JA |
9894 | The value of |
9895 | .I limit | |
9896 | can be a number in the unit specified for the resource | |
9897 | or one of the special values | |
9898 | .BR hard , | |
9899 | .BR soft , | |
9900 | or | |
9901 | .BR unlimited , | |
9902 | which stand for the current hard limit, the current soft limit, and | |
9903 | no limit, respectively. | |
ccc6cda3 | 9904 | If |
726f6388 JA |
9905 | .I limit |
9906 | is omitted, the current value of the soft limit of the resource is | |
ccc6cda3 JA |
9907 | printed, unless the \fB\-H\fP option is given. When more than one |
9908 | resource is specified, the limit name and unit are printed before the value. | |
726f6388 JA |
9909 | Other options are interpreted as follows: |
9910 | .RS | |
9911 | .PD 0 | |
9912 | .TP | |
9913 | .B \-a | |
ccc6cda3 | 9914 | All current limits are reported |
726f6388 | 9915 | .TP |
6fbe7620 CR |
9916 | .B \-b |
9917 | The maximum socket buffer size | |
9918 | .TP | |
726f6388 | 9919 | .B \-c |
ccc6cda3 | 9920 | The maximum size of core files created |
726f6388 JA |
9921 | .TP |
9922 | .B \-d | |
ccc6cda3 | 9923 | The maximum size of a process's data segment |
726f6388 | 9924 | .TP |
dc8fbaf9 CR |
9925 | .B \-e |
9926 | The maximum scheduling priority ("nice") | |
9927 | .TP | |
726f6388 | 9928 | .B \-f |
d3ad40de | 9929 | The maximum size of files written by the shell and its children |
726f6388 | 9930 | .TP |
af12dacd CR |
9931 | .B \-i |
9932 | The maximum number of pending signals | |
9933 | .TP | |
ccc6cda3 JA |
9934 | .B \-l |
9935 | The maximum size that may be locked into memory | |
726f6388 | 9936 | .TP |
ccc6cda3 | 9937 | .B \-m |
db31fb26 | 9938 | The maximum resident set size (many systems do not honor this limit) |
726f6388 | 9939 | .TP |
ccc6cda3 JA |
9940 | .B \-n |
9941 | The maximum number of open file descriptors (most systems do not | |
9942 | allow this value to be set) | |
726f6388 JA |
9943 | .TP |
9944 | .B \-p | |
ccc6cda3 | 9945 | The pipe size in 512-byte blocks (this may not be set) |
726f6388 | 9946 | .TP |
af12dacd CR |
9947 | .B \-q |
9948 | The maximum number of bytes in POSIX message queues | |
9949 | .TP | |
dc8fbaf9 CR |
9950 | .B \-r |
9951 | The maximum real-time scheduling priority | |
9952 | .TP | |
ccc6cda3 JA |
9953 | .B \-s |
9954 | The maximum stack size | |
9955 | .TP | |
9956 | .B \-t | |
9957 | The maximum amount of cpu time in seconds | |
726f6388 JA |
9958 | .TP |
9959 | .B \-u | |
ccc6cda3 | 9960 | The maximum number of processes available to a single user |
726f6388 JA |
9961 | .TP |
9962 | .B \-v | |
68dfe178 CR |
9963 | The maximum amount of virtual memory available to the shell and, on |
9964 | some systems, to its children | |
af12dacd CR |
9965 | .TP |
9966 | .B \-x | |
9967 | The maximum number of file locks | |
6fbe7620 CR |
9968 | .TP |
9969 | .B \-T | |
9970 | The maximum number of threads | |
726f6388 JA |
9971 | .PD |
9972 | .PP | |
ccc6cda3 | 9973 | If |
726f6388 | 9974 | .I limit |
b28ff8c9 | 9975 | is given, and the |
726f6388 | 9976 | .B \-a |
b28ff8c9 CR |
9977 | option is not used, |
9978 | \fIlimit\fP is the new value of the specified resource. | |
726f6388 JA |
9979 | If no option is given, then |
9980 | .B \-f | |
9981 | is assumed. Values are in 1024-byte increments, except for | |
9982 | .BR \-t , | |
b28ff8c9 | 9983 | which is in seconds; |
726f6388 | 9984 | .BR \-p , |
b28ff8c9 | 9985 | which is in units of 512-byte blocks; |
726f6388 | 9986 | and |
6fbe7620 CR |
9987 | .BR \-T , |
9988 | .BR \-b , | |
9989 | .BR \-n , | |
726f6388 JA |
9990 | and |
9991 | .BR \-u , | |
f73dda09 JA |
9992 | which are unscaled values. |
9993 | The return status is 0 unless an invalid option or argument is supplied, | |
9994 | or an error occurs while setting a new limit. | |
726f6388 JA |
9995 | .RE |
9996 | .TP | |
cce855bc | 9997 | \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP] |
726f6388 JA |
9998 | The user file-creation mask is set to |
9999 | .IR mode . | |
10000 | If | |
10001 | .I mode | |
10002 | begins with a digit, it | |
10003 | is interpreted as an octal number; otherwise | |
10004 | it is interpreted as a symbolic mode mask similar | |
10005 | to that accepted by | |
10006 | .IR chmod (1). | |
10007 | If | |
10008 | .I mode | |
bb70624e | 10009 | is omitted, the current value of the mask is printed. |
ccc6cda3 | 10010 | The |
726f6388 JA |
10011 | .B \-S |
10012 | option causes the mask to be printed in symbolic form; the | |
10013 | default output is an octal number. | |
cce855bc JA |
10014 | If the |
10015 | .B \-p | |
10016 | option is supplied, and | |
10017 | .I mode | |
10018 | is omitted, the output is in a form that may be reused as input. | |
ccc6cda3 | 10019 | The return status is 0 if the mode was successfully changed or if |
726f6388 JA |
10020 | no \fImode\fP argument was supplied, and false otherwise. |
10021 | .TP | |
10022 | \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...] | |
bb70624e | 10023 | Remove each \fIname\fP from the list of defined aliases. If |
726f6388 JA |
10024 | .B \-a |
10025 | is supplied, all alias definitions are removed. The return | |
10026 | value is true unless a supplied | |
10027 | .I name | |
10028 | is not a defined alias. | |
10029 | .TP | |
87c1f4ec | 10030 | \fBunset\fP [\-\fBfv\fP] [\-\fBn\fP] [\fIname\fP ...] |
726f6388 JA |
10031 | For each |
10032 | .IR name , | |
ccc6cda3 | 10033 | remove the corresponding variable or function. |
276cb932 | 10034 | If the |
ccc6cda3 JA |
10035 | .B \-v |
10036 | option is given, each | |
10037 | .I name | |
276cb932 | 10038 | refers to a shell variable, and that variable is removed. |
ccc6cda3 JA |
10039 | Read-only variables may not be unset. |
10040 | If | |
726f6388 | 10041 | .B \-f |
f75912ae | 10042 | is specified, each |
ccc6cda3 JA |
10043 | .I name |
10044 | refers to a shell function, and the function definition | |
10045 | is removed. | |
87c1f4ec CR |
10046 | If the |
10047 | .B \-n | |
10048 | option is supplied, and \fIname\fP is a variable with the \fInameref\fP | |
10049 | attribute, \fIname\fP will be unset rather than the variable it | |
10050 | references. | |
10051 | \fB\-n\fP has no effect if the \fB\-f\fP option is supplied. | |
276cb932 CR |
10052 | If no options are supplied, each \fIname\fP refers to a variable; if |
10053 | there is no variable by that name, any function with that name is | |
10054 | unset. | |
ccc6cda3 JA |
10055 | Each unset variable or function is removed from the environment |
10056 | passed to subsequent commands. | |
10057 | If any of | |
726f6388 | 10058 | .SM |
984a1947 CR |
10059 | .BR COMP_WORDBREAKS , |
10060 | .SM | |
726f6388 JA |
10061 | .BR RANDOM , |
10062 | .SM | |
10063 | .BR SECONDS , | |
10064 | .SM | |
10065 | .BR LINENO , | |
ccc6cda3 JA |
10066 | .SM |
10067 | .BR HISTCMD , | |
bb70624e JA |
10068 | .SM |
10069 | .BR FUNCNAME , | |
10070 | .SM | |
10071 | .BR GROUPS , | |
726f6388 JA |
10072 | or |
10073 | .SM | |
ccc6cda3 | 10074 | .B DIRSTACK |
726f6388 JA |
10075 | are unset, they lose their special properties, even if they are |
10076 | subsequently reset. The exit status is true unless a | |
10077 | .I name | |
d3a24ed2 | 10078 | is readonly. |
726f6388 | 10079 | .TP |
3087e51c | 10080 | \fBwait\fP [\fB\--n\fP] [\fIn ...\fP] |
1442f67c | 10081 | Wait for each specified child process and return its termination status. |
d90269dd | 10082 | Each |
726f6388 JA |
10083 | .I n |
10084 | may be a process | |
10085 | ID or a job specification; if a job spec is given, all processes | |
10086 | in that job's pipeline are waited for. If | |
10087 | .I n | |
10088 | is not given, all currently active child processes | |
3087e51c CR |
10089 | are waited for, and the return status is zero. |
10090 | If the \fB\--n\fP option is supplied, \fBwait\fP waits for any job to | |
10091 | terminate and returns its exit status. | |
10092 | If | |
726f6388 | 10093 | .I n |
ccc6cda3 | 10094 | specifies a non-existent process or job, the return status is |
726f6388 JA |
10095 | 127. Otherwise, the return status is the exit status of the last |
10096 | process or job waited for. | |
10097 | .\" bash_builtins | |
10098 | .if \n(zZ=1 .ig zZ | |
ccc6cda3 | 10099 | .SH "RESTRICTED SHELL" |
bb70624e JA |
10100 | .\" rbash.1 |
10101 | .zY | |
726f6388 | 10102 | .PP |
ccc6cda3 | 10103 | If |
726f6388 | 10104 | .B bash |
ccc6cda3 JA |
10105 | is started with the name |
10106 | .BR rbash , | |
10107 | or the | |
10108 | .B \-r | |
10109 | option is supplied at invocation, | |
10110 | the shell becomes restricted. | |
10111 | A restricted shell is used to | |
10112 | set up an environment more controlled than the standard shell. | |
10113 | It behaves identically to | |
10114 | .B bash | |
cce855bc | 10115 | with the exception that the following are disallowed or not performed: |
ccc6cda3 JA |
10116 | .IP \(bu |
10117 | changing directories with \fBcd\fP | |
10118 | .IP \(bu | |
10119 | setting or unsetting the values of | |
984a1947 | 10120 | .SM |
b72432fd | 10121 | .BR SHELL , |
984a1947 | 10122 | .SM |
b72432fd | 10123 | .BR PATH , |
984a1947 | 10124 | .SM |
b72432fd | 10125 | .BR ENV , |
ccc6cda3 | 10126 | or |
984a1947 | 10127 | .SM |
b72432fd | 10128 | .B BASH_ENV |
ccc6cda3 JA |
10129 | .IP \(bu |
10130 | specifying command names containing | |
10131 | .B / | |
10132 | .IP \(bu | |
b28ff8c9 | 10133 | specifying a filename containing a |
ccc6cda3 JA |
10134 | .B / |
10135 | as an argument to the | |
10136 | .B . | |
10137 | builtin command | |
10138 | .IP \(bu | |
dc60d4e0 | 10139 | specifying a filename containing a slash as an argument to the |
bb70624e JA |
10140 | .B \-p |
10141 | option to the | |
10142 | .B hash | |
10143 | builtin command | |
10144 | .IP \(bu | |
ccc6cda3 JA |
10145 | importing function definitions from the shell environment at startup |
10146 | .IP \(bu | |
984a1947 CR |
10147 | parsing the value of |
10148 | .SM | |
10149 | .B SHELLOPTS | |
10150 | from the shell environment at startup | |
cce855bc | 10151 | .IP \(bu |
ccc6cda3 JA |
10152 | redirecting output using the >, >|, <>, >&, &>, and >> redirection operators |
10153 | .IP \(bu | |
10154 | using the | |
10155 | .B exec | |
10156 | builtin command to replace the shell with another command | |
10157 | .IP \(bu | |
10158 | adding or deleting builtin commands with the | |
10159 | .B \-f | |
726f6388 | 10160 | and |
ccc6cda3 JA |
10161 | .B \-d |
10162 | options to the | |
10163 | .B enable | |
10164 | builtin command | |
10165 | .IP \(bu | |
dc60d4e0 | 10166 | using the \fBenable\fP builtin command to enable disabled shell builtins |
7117c2d2 | 10167 | .IP \(bu |
ccc6cda3 JA |
10168 | specifying the |
10169 | .B \-p | |
10170 | option to the | |
10171 | .B command | |
10172 | builtin command | |
10173 | .IP \(bu | |
10174 | turning off restricted mode with | |
cce855bc | 10175 | \fBset +r\fP or \fBset +o restricted\fP. |
726f6388 | 10176 | .PP |
ccc6cda3 JA |
10177 | These restrictions are enforced after any startup files are read. |
10178 | .PP | |
61deeb13 CR |
10179 | .ie \n(zY=1 When a command that is found to be a shell script is executed, |
10180 | .el \{ When a command that is found to be a shell script is executed | |
10181 | (see | |
ccc6cda3 JA |
10182 | .SM |
10183 | .B "COMMAND EXECUTION" | |
10184 | above), | |
61deeb13 | 10185 | \} |
ccc6cda3 JA |
10186 | .B rbash |
10187 | turns off any restrictions in the shell spawned to execute the | |
10188 | script. | |
bb70624e JA |
10189 | .\" end of rbash.1 |
10190 | .if \n(zY=1 .ig zY | |
726f6388 JA |
10191 | .SH "SEE ALSO" |
10192 | .PD 0 | |
10193 | .TP | |
bb70624e | 10194 | \fIBash Reference Manual\fP, Brian Fox and Chet Ramey |
726f6388 JA |
10195 | .TP |
10196 | \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey | |
10197 | .TP | |
10198 | \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey | |
10199 | .TP | |
1442f67c CR |
10200 | \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE -- |
10201 | http://pubs.opengroup.org/onlinepubs/9699919799/ | |
726f6388 | 10202 | .TP |
c677e9e0 CR |
10203 | http://tiswww.case.edu/~chet/bash/POSIX -- a description of posix mode |
10204 | .TP | |
726f6388 JA |
10205 | \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1) |
10206 | .TP | |
10207 | \fIemacs\fP(1), \fIvi\fP(1) | |
10208 | .TP | |
10209 | \fIreadline\fP(3) | |
10210 | .PD | |
10211 | .SH FILES | |
10212 | .PD 0 | |
10213 | .TP | |
10214 | .FN /bin/bash | |
10215 | The \fBbash\fP executable | |
10216 | .TP | |
10217 | .FN /etc/profile | |
10218 | The systemwide initialization file, executed for login shells | |
10219 | .TP | |
10220 | .FN ~/.bash_profile | |
10221 | The personal initialization file, executed for login shells | |
10222 | .TP | |
10223 | .FN ~/.bashrc | |
10224 | The individual per-interactive-shell startup file | |
10225 | .TP | |
b72432fd JA |
10226 | .FN ~/.bash_logout |
10227 | The individual login shell cleanup file, executed when a login shell exits | |
10228 | .TP | |
726f6388 JA |
10229 | .FN ~/.inputrc |
10230 | Individual \fIreadline\fP initialization file | |
10231 | .PD | |
10232 | .SH AUTHORS | |
ccc6cda3 | 10233 | Brian Fox, Free Software Foundation |
726f6388 | 10234 | .br |
bb70624e | 10235 | bfox@gnu.org |
726f6388 JA |
10236 | .PP |
10237 | Chet Ramey, Case Western Reserve University | |
10238 | .br | |
db31fb26 | 10239 | chet.ramey@case.edu |
726f6388 JA |
10240 | .SH BUG REPORTS |
10241 | If you find a bug in | |
10242 | .B bash, | |
10243 | you should report it. But first, you should | |
10244 | make sure that it really is a bug, and that it appears in the latest | |
10245 | version of | |
d3a24ed2 CR |
10246 | .BR bash . |
10247 | The latest version is always available from | |
9c7f20c7 | 10248 | \fIftp://ftp.gnu.org/pub/gnu/bash/\fP. |
726f6388 JA |
10249 | .PP |
10250 | Once you have determined that a bug actually exists, use the | |
10251 | .I bashbug | |
10252 | command to submit a bug report. | |
d166f048 | 10253 | If you have a fix, you are encouraged to mail that as well! |
726f6388 | 10254 | Suggestions and `philosophical' bug reports may be mailed |
cce855bc | 10255 | to \fIbug-bash@gnu.org\fP or posted to the Usenet |
726f6388 JA |
10256 | newsgroup |
10257 | .BR gnu.bash.bug . | |
10258 | .PP | |
10259 | ALL bug reports should include: | |
10260 | .PP | |
10261 | .PD 0 | |
10262 | .TP 20 | |
10263 | The version number of \fBbash\fR | |
10264 | .TP | |
10265 | The hardware and operating system | |
10266 | .TP | |
10267 | The compiler used to compile | |
10268 | .TP | |
10269 | A description of the bug behaviour | |
10270 | .TP | |
10271 | A short script or `recipe' which exercises the bug | |
10272 | .PD | |
10273 | .PP | |
10274 | .I bashbug | |
10275 | inserts the first three items automatically into the template | |
10276 | it provides for filing a bug report. | |
10277 | .PP | |
10278 | Comments and bug reports concerning | |
10279 | this manual page should be directed to | |
54a1fa7c | 10280 | .IR chet.ramey@case.edu . |
726f6388 JA |
10281 | .SH BUGS |
10282 | .PP | |
10283 | It's too big and too slow. | |
10284 | .PP | |
10285 | There are some subtle differences between | |
10286 | .B bash | |
10287 | and traditional versions of | |
10288 | .BR sh , | |
10289 | mostly because of the | |
10290 | .SM | |
10291 | .B POSIX | |
10292 | specification. | |
10293 | .PP | |
10294 | Aliases are confusing in some uses. | |
ccc6cda3 JA |
10295 | .PP |
10296 | Shell builtin commands and functions are not stoppable/restartable. | |
10297 | .PP | |
10298 | Compound commands and command sequences of the form `a ; b ; c' | |
10299 | are not handled gracefully when process suspension is attempted. | |
10300 | When a process is stopped, the shell immediately executes the next | |
10301 | command in the sequence. | |
10302 | It suffices to place the sequence of commands between | |
10303 | parentheses to force it into a subshell, which may be stopped as | |
10304 | a unit. | |
10305 | .PP | |
ccc6cda3 | 10306 | Array variables may not (yet) be exported. |
09767ff0 CR |
10307 | .PP |
10308 | There may be only one active coprocess at a time. | |
726f6388 | 10309 | .zZ |
bb70624e | 10310 | .zY |