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