1 | \"
|
---|
2 | .\" MAN PAGE COMMENTS to
|
---|
3 | .\"
|
---|
4 | .\" Chet Ramey
|
---|
5 | .\" Information Network Services
|
---|
6 | .\" Case Western Reserve University
|
---|
7 | .\" chet@po.cwru.edu
|
---|
8 | .\"
|
---|
9 | .\" Last Change: Wed Dec 28 19:58:45 EST 2005
|
---|
10 | .\"
|
---|
11 | .\" bash_builtins, strip all but Built-Ins section
|
---|
12 | .if \n(zZ=1 .ig zZ
|
---|
13 | .if \n(zY=1 .ig zY
|
---|
14 | .TH BASH 1 "2005 Dec 28" "GNU Bash-3.1"
|
---|
15 | .\"
|
---|
16 | .\" There's some problem with having a `@'
|
---|
17 | .\" in a tagged paragraph with the BSD man macros.
|
---|
18 | .\" It has to do with `@' appearing in the }1 macro.
|
---|
19 | .\" This is a problem on 4.3 BSD and Ultrix, but Sun
|
---|
20 | .\" appears to have fixed it.
|
---|
21 | .\" If you're seeing the characters
|
---|
22 | .\" `@u-3p' appearing before the lines reading
|
---|
23 | .\" `possible-hostname-completions
|
---|
24 | .\" and `complete-hostname' down in READLINE,
|
---|
25 | .\" then uncomment this redefinition.
|
---|
26 | .\"
|
---|
27 | .de }1
|
---|
28 | .ds ]X \&\\*(]B\\
|
---|
29 | .nr )E 0
|
---|
30 | .if !"\\$1"" .nr )I \\$1n
|
---|
31 | .}f
|
---|
32 | .ll \\n(LLu
|
---|
33 | .in \\n()Ru+\\n(INu+\\n()Iu
|
---|
34 | .ti \\n(INu
|
---|
35 | .ie !\\n()Iu+\\n()Ru-\w\\*(]Xu-3p \{\\*(]X
|
---|
36 | .br\}
|
---|
37 | .el \\*(]X\h|\\n()Iu+\\n()Ru\c
|
---|
38 | .}f
|
---|
39 | ..
|
---|
40 | .\"
|
---|
41 | .\" File Name macro. This used to be `.PN', for Path Name,
|
---|
42 | .\" but Sun doesn't seem to like that very much.
|
---|
43 | .\"
|
---|
44 | .de FN
|
---|
45 | \fI\|\\$1\|\fP
|
---|
46 | ..
|
---|
47 | .SH NAME
|
---|
48 | bash \- GNU Bourne-Again SHell
|
---|
49 | .SH SYNOPSIS
|
---|
50 | .B bash
|
---|
51 | [options]
|
---|
52 | [file]
|
---|
53 | .SH COPYRIGHT
|
---|
54 | .if n Bash is Copyright (C) 1989-2005 by the Free Software Foundation, Inc.
|
---|
55 | .if t Bash is Copyright \(co 1989-2005 by the Free Software Foundation, Inc.
|
---|
56 | .SH DESCRIPTION
|
---|
57 | .B Bash
|
---|
58 | is an \fBsh\fR-compatible command language interpreter that
|
---|
59 | executes commands read from the standard input or from a file.
|
---|
60 | .B Bash
|
---|
61 | also incorporates useful features from the \fIKorn\fP and \fIC\fP
|
---|
62 | shells (\fBksh\fP and \fBcsh\fP).
|
---|
63 | .PP
|
---|
64 | .B Bash
|
---|
65 | is intended to be a conformant implementation of the IEEE
|
---|
66 | POSIX Shell and Tools specification (IEEE Working Group 1003\.2).
|
---|
67 | .B Bash
|
---|
68 | can be configured to be POSIX-conformant by default.
|
---|
69 | .SH OPTIONS
|
---|
70 | In addition to the single-character shell options documented in the
|
---|
71 | description of the \fBset\fR builtin command, \fBbash\fR
|
---|
72 | interprets the following options when it is invoked:
|
---|
73 | .PP
|
---|
74 | .PD 0
|
---|
75 | .TP 10
|
---|
76 | .BI \-c "\| string\^"
|
---|
77 | If the
|
---|
78 | .B \-c
|
---|
79 | option is present, then commands are read from
|
---|
80 | .IR string .
|
---|
81 | If there are arguments after the
|
---|
82 | .IR string ,
|
---|
83 | they are assigned to the positional parameters, starting with
|
---|
84 | .BR $0 .
|
---|
85 | .TP
|
---|
86 | .B \-i
|
---|
87 | If the
|
---|
88 | .B \-i
|
---|
89 | option is present, the shell is
|
---|
90 | .IR interactive .
|
---|
91 | .TP
|
---|
92 | .B \-l
|
---|
93 | Make
|
---|
94 | .B bash
|
---|
95 | act as if it had been invoked as a login shell (see
|
---|
96 | .SM
|
---|
97 | .B INVOCATION
|
---|
98 | below).
|
---|
99 | .TP
|
---|
100 | .B \-r
|
---|
101 | If the
|
---|
102 | .B \-r
|
---|
103 | option is present, the shell becomes
|
---|
104 | .I restricted
|
---|
105 | (see
|
---|
106 | .SM
|
---|
107 | .B "RESTRICTED SHELL"
|
---|
108 | below).
|
---|
109 | .TP
|
---|
110 | .B \-s
|
---|
111 | If the
|
---|
112 | .B \-s
|
---|
113 | option is present, or if no arguments remain after option
|
---|
114 | processing, then commands are read from the standard input.
|
---|
115 | This option allows the positional parameters to be set
|
---|
116 | when invoking an interactive shell.
|
---|
117 | .TP
|
---|
118 | .B \-D
|
---|
119 | A list of all double-quoted strings preceded by \fB$\fP
|
---|
120 | is printed on the standard output.
|
---|
121 | These are the strings that
|
---|
122 | are subject to language translation when the current locale
|
---|
123 | is not \fBC\fP or \fBPOSIX\fP.
|
---|
124 | This implies the \fB\-n\fP option; no commands will be executed.
|
---|
125 | .TP
|
---|
126 | .B [\-+]O [\fIshopt_option\fP]
|
---|
127 | \fIshopt_option\fP is one of the shell options accepted by the
|
---|
128 | \fBshopt\fP builtin (see
|
---|
129 | .SM
|
---|
130 | .B SHELL BUILTIN COMMANDS
|
---|
131 | below).
|
---|
132 | If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option;
|
---|
133 | \fB+O\fP unsets it.
|
---|
134 | If \fIshopt_option\fP is not supplied, the names and values of the shell
|
---|
135 | options accepted by \fBshopt\fP are printed on the standard output.
|
---|
136 | If the invocation option is \fB+O\fP, the output is displayed in a format
|
---|
137 | that may be reused as input.
|
---|
138 | .TP
|
---|
139 | .B \-\-
|
---|
140 | A
|
---|
141 | .B \-\-
|
---|
142 | signals the end of options and disables further option processing.
|
---|
143 | Any arguments after the
|
---|
144 | .B \-\-
|
---|
145 | are treated as filenames and arguments. An argument of
|
---|
146 | .B \-
|
---|
147 | is equivalent to \fB\-\-\fP.
|
---|
148 | .PD
|
---|
149 | .PP
|
---|
150 | .B Bash
|
---|
151 | also interprets a number of multi-character options.
|
---|
152 | These options must appear on the command line before the
|
---|
153 | single-character options to be recognized.
|
---|
154 | .PP
|
---|
155 | .PD 0
|
---|
156 | .TP
|
---|
157 | .B \-\-debugger
|
---|
158 | Arrange for the debugger profile to be executed before the shell
|
---|
159 | starts.
|
---|
160 | Turns on extended debugging mode (see the description of the
|
---|
161 | .B extdebug
|
---|
162 | option to the
|
---|
163 | .B shopt
|
---|
164 | builtin below)
|
---|
165 | and shell function tracing (see the description of the
|
---|
166 | \fB\-o functrace\fP option to the
|
---|
167 | .B set
|
---|
168 | builtin below).
|
---|
169 | .TP
|
---|
170 | .B \-\-dump\-po\-strings
|
---|
171 | Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP
|
---|
172 | \fBpo\fP (portable object) file format.
|
---|
173 | .TP
|
---|
174 | .B \-\-dump\-strings
|
---|
175 | Equivalent to \fB\-D\fP.
|
---|
176 | .TP
|
---|
177 | .B \-\-help
|
---|
178 | Display a usage message on standard output and exit successfully.
|
---|
179 | .TP
|
---|
180 | \fB\-\-init\-file\fP \fIfile\fP
|
---|
181 | .PD 0
|
---|
182 | .TP
|
---|
183 | \fB\-\-rcfile\fP \fIfile\fP
|
---|
184 | .PD
|
---|
185 | Execute commands from
|
---|
186 | .I file
|
---|
187 | instead of the standard personal initialization file
|
---|
188 | .I ~/.bashrc
|
---|
189 | if the shell is interactive (see
|
---|
190 | .SM
|
---|
191 | .B INVOCATION
|
---|
192 | below).
|
---|
193 | .TP
|
---|
194 | .B \-\-login
|
---|
195 | Equivalent to \fB\-l\fP.
|
---|
196 | .TP
|
---|
197 | .B \-\-noediting
|
---|
198 | Do not use the GNU
|
---|
199 | .B readline
|
---|
200 | library to read command lines when the shell is interactive.
|
---|
201 | .TP
|
---|
202 | .B \-\-noprofile
|
---|
203 | Do not read either the system-wide startup file
|
---|
204 | .FN /etc/profile
|
---|
205 | or any of the personal initialization files
|
---|
206 | .IR ~/.bash_profile ,
|
---|
207 | .IR ~/.bash_login ,
|
---|
208 | or
|
---|
209 | .IR ~/.profile .
|
---|
210 | By default,
|
---|
211 | .B bash
|
---|
212 | reads these files when it is invoked as a login shell (see
|
---|
213 | .SM
|
---|
214 | .B INVOCATION
|
---|
215 | below).
|
---|
216 | .TP
|
---|
217 | .B \-\-norc
|
---|
218 | Do not read and execute the personal initialization file
|
---|
219 | .I ~/.bashrc
|
---|
220 | if the shell is interactive.
|
---|
221 | This option is on by default if the shell is invoked as
|
---|
222 | .BR sh .
|
---|
223 | .TP
|
---|
224 | .B \-\-posix
|
---|
225 | Change the behavior of \fBbash\fP where the default operation differs
|
---|
226 | from the POSIX 1003.2 standard to match the standard (\fIposix mode\fP).
|
---|
227 | .TP
|
---|
228 | .B \-\-restricted
|
---|
229 | The shell becomes restricted (see
|
---|
230 | .SM
|
---|
231 | .B "RESTRICTED SHELL"
|
---|
232 | below).
|
---|
233 | .TP
|
---|
234 | .B \-\-verbose
|
---|
235 | Equivalent to \fB\-v\fP.
|
---|
236 | .TP
|
---|
237 | .B \-\-version
|
---|
238 | Show version information for this instance of
|
---|
239 | .B bash
|
---|
240 | on the standard output and exit successfully.
|
---|
241 | .PD
|
---|
242 | .SH ARGUMENTS
|
---|
243 | If arguments remain after option processing, and neither the
|
---|
244 | .B \-c
|
---|
245 | nor the
|
---|
246 | .B \-s
|
---|
247 | option has been supplied, the first argument is assumed to
|
---|
248 | be the name of a file containing shell commands.
|
---|
249 | If
|
---|
250 | .B bash
|
---|
251 | is invoked in this fashion,
|
---|
252 | .B $0
|
---|
253 | is set to the name of the file, and the positional parameters
|
---|
254 | are set to the remaining arguments.
|
---|
255 | .B Bash
|
---|
256 | reads and executes commands from this file, then exits.
|
---|
257 | \fBBash\fP's exit status is the exit status of the last command
|
---|
258 | executed in the script.
|
---|
259 | If no commands are executed, the exit status is 0.
|
---|
260 | An attempt is first made to open the file in the current directory, and,
|
---|
261 | if no file is found, then the shell searches the directories in
|
---|
262 | .SM
|
---|
263 | .B PATH
|
---|
264 | for the script.
|
---|
265 | .SH INVOCATION
|
---|
266 | A \fIlogin shell\fP is one whose first character of argument zero is a
|
---|
267 | .BR \- ,
|
---|
268 | or one started with the
|
---|
269 | .B \-\-login
|
---|
270 | option.
|
---|
271 | .PP
|
---|
272 | An \fIinteractive\fP shell is one started without non-option arguments
|
---|
273 | and without the
|
---|
274 | .B \-c
|
---|
275 | option
|
---|
276 | whose standard input and error are
|
---|
277 | both connected to terminals (as determined by
|
---|
278 | .IR isatty (3)),
|
---|
279 | or one started with the
|
---|
280 | .B \-i
|
---|
281 | option.
|
---|
282 | .SM
|
---|
283 | .B PS1
|
---|
284 | is set and
|
---|
285 | .B $\-
|
---|
286 | includes
|
---|
287 | .B i
|
---|
288 | if
|
---|
289 | .B bash
|
---|
290 | is interactive,
|
---|
291 | allowing a shell script or a startup file to test this state.
|
---|
292 | .PP
|
---|
293 | The following paragraphs describe how
|
---|
294 | .B bash
|
---|
295 | executes its startup files.
|
---|
296 | If any of the files exist but cannot be read,
|
---|
297 | .B bash
|
---|
298 | reports an error.
|
---|
299 | Tildes are expanded in file names as described below under
|
---|
300 | .B "Tilde Expansion"
|
---|
301 | in the
|
---|
302 | .SM
|
---|
303 | .B EXPANSION
|
---|
304 | section.
|
---|
305 | .PP
|
---|
306 | When
|
---|
307 | .B bash
|
---|
308 | is invoked as an interactive login shell, or as a non-interactive shell
|
---|
309 | with the \fB\-\-login\fP option, it first reads and
|
---|
310 | executes commands from the file \fI/etc/profile\fP, if that
|
---|
311 | file exists.
|
---|
312 | After reading that file, it looks for \fI~/.bash_profile\fP,
|
---|
313 | \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
|
---|
314 | and executes commands from the first one that exists and is readable.
|
---|
315 | The
|
---|
316 | .B \-\-noprofile
|
---|
317 | option may be used when the shell is started to inhibit this behavior.
|
---|
318 | .PP
|
---|
319 | When a login shell exits,
|
---|
320 | .B bash
|
---|
321 | reads and executes commands from the file \fI~/.bash_logout\fP, if it
|
---|
322 | exists.
|
---|
323 | .PP
|
---|
324 | When an interactive shell that is not a login shell is started,
|
---|
325 | .B bash
|
---|
326 | reads and executes commands from \fI~/.bashrc\fP, if that file exists.
|
---|
327 | This may be inhibited by using the
|
---|
328 | .B \-\-norc
|
---|
329 | option.
|
---|
330 | The \fB\-\-rcfile\fP \fIfile\fP option will force
|
---|
331 | .B bash
|
---|
332 | to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
|
---|
333 | .PP
|
---|
334 | When
|
---|
335 | .B bash
|
---|
336 | is started non-interactively, to run a shell script, for example, it
|
---|
337 | looks for the variable
|
---|
338 | .SM
|
---|
339 | .B BASH_ENV
|
---|
340 | in the environment, expands its value if it appears there, and uses the
|
---|
341 | expanded value as the name of a file to read and execute.
|
---|
342 | .B Bash
|
---|
343 | behaves as if the following command were executed:
|
---|
344 | .sp .5
|
---|
345 | .RS
|
---|
346 | .if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
|
---|
347 | .if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
|
---|
348 | .RE
|
---|
349 | .sp .5
|
---|
350 | but the value of the
|
---|
351 | .SM
|
---|
352 | .B PATH
|
---|
353 | variable is not used to search for the file name.
|
---|
354 | .PP
|
---|
355 | If
|
---|
356 | .B bash
|
---|
357 | is invoked with the name
|
---|
358 | .BR sh ,
|
---|
359 | it tries to mimic the startup behavior of historical versions of
|
---|
360 | .B sh
|
---|
361 | as closely as possible,
|
---|
362 | while conforming to the POSIX standard as well.
|
---|
363 | When invoked as an interactive login shell, or a non-interactive
|
---|
364 | shell with the \fB\-\-login\fP option, it first attempts to
|
---|
365 | read and execute commands from
|
---|
366 | .I /etc/profile
|
---|
367 | and
|
---|
368 | .IR ~/.profile ,
|
---|
369 | in that order.
|
---|
370 | The
|
---|
371 | .B \-\-noprofile
|
---|
372 | option may be used to inhibit this behavior.
|
---|
373 | When invoked as an interactive shell with the name
|
---|
374 | .BR sh ,
|
---|
375 | .B bash
|
---|
376 | looks for the variable
|
---|
377 | .SM
|
---|
378 | .BR ENV ,
|
---|
379 | expands its value if it is defined, and uses the
|
---|
380 | expanded value as the name of a file to read and execute.
|
---|
381 | Since a shell invoked as
|
---|
382 | .B sh
|
---|
383 | does not attempt to read and execute commands from any other startup
|
---|
384 | files, the
|
---|
385 | .B \-\-rcfile
|
---|
386 | option has no effect.
|
---|
387 | A non-interactive shell invoked with the name
|
---|
388 | .B sh
|
---|
389 | does not attempt to read any other startup files.
|
---|
390 | When invoked as
|
---|
391 | .BR sh ,
|
---|
392 | .B bash
|
---|
393 | enters
|
---|
394 | .I posix
|
---|
395 | mode after the startup files are read.
|
---|
396 | .PP
|
---|
397 | When
|
---|
398 | .B bash
|
---|
399 | is started in
|
---|
400 | .I posix
|
---|
401 | mode, as with the
|
---|
402 | .B \-\-posix
|
---|
403 | command line option, it follows the POSIX standard for startup files.
|
---|
404 | In this mode, interactive shells expand the
|
---|
405 | .SM
|
---|
406 | .B ENV
|
---|
407 | variable and commands are read and executed from the file
|
---|
408 | whose name is the expanded value.
|
---|
409 | No other startup files are read.
|
---|
410 | .PP
|
---|
411 | .B Bash
|
---|
412 | attempts to determine when it is being run by the remote shell
|
---|
413 | daemon, usually \fIrshd\fP.
|
---|
414 | If
|
---|
415 | .B bash
|
---|
416 | determines it is being run by \fIrshd\fP, it reads and executes
|
---|
417 | commands from \fI~/.bashrc\fP, if that file exists and is readable.
|
---|
418 | It will not do this if invoked as \fBsh\fP.
|
---|
419 | The
|
---|
420 | .B \-\-norc
|
---|
421 | option may be used to inhibit this behavior, and the
|
---|
422 | .B \-\-rcfile
|
---|
423 | option may be used to force another file to be read, but
|
---|
424 | \fIrshd\fP does not generally invoke the shell with those options
|
---|
425 | or allow them to be specified.
|
---|
426 | .PP
|
---|
427 | If the shell is started with the effective user (group) id not equal to the
|
---|
428 | real user (group) id, and the \fB\-p\fP option is not supplied, no startup
|
---|
429 | files are read, shell functions are not inherited from the environment, the
|
---|
430 | .SM
|
---|
431 | .B SHELLOPTS
|
---|
432 | variable, if it appears in the environment, is ignored,
|
---|
433 | and the effective user id is set to the real user id.
|
---|
434 | If the \fB\-p\fP option is supplied at invocation, the startup behavior is
|
---|
435 | the same, but the effective user id is not reset.
|
---|
436 | .SH DEFINITIONS
|
---|
437 | .PP
|
---|
438 | The following definitions are used throughout the rest of this
|
---|
439 | document.
|
---|
440 | .PD 0
|
---|
441 | .TP
|
---|
442 | .B blank
|
---|
443 | A space or tab.
|
---|
444 | .TP
|
---|
445 | .B word
|
---|
446 | A sequence of characters considered as a single unit by the shell.
|
---|
447 | Also known as a
|
---|
448 | .BR token .
|
---|
449 | .TP
|
---|
450 | .B name
|
---|
451 | A
|
---|
452 | .I word
|
---|
453 | consisting only of alphanumeric characters and underscores, and
|
---|
454 | beginning with an alphabetic character or an underscore. Also
|
---|
455 | referred to as an
|
---|
456 | .BR identifier .
|
---|
457 | .TP
|
---|
458 | .B metacharacter
|
---|
459 | A character that, when unquoted, separates words. One of the following:
|
---|
460 | .br
|
---|
461 | .RS
|
---|
462 | .PP
|
---|
463 | .if t \fB| & ; ( ) < > space tab\fP
|
---|
464 | .if n \fB| & ; ( ) < > space tab\fP
|
---|
465 | .RE
|
---|
466 | .PP
|
---|
467 | .TP
|
---|
468 | .B control operator
|
---|
469 | A \fItoken\fP that performs a control function. It is one of the following
|
---|
470 | symbols:
|
---|
471 | .RS
|
---|
472 | .PP
|
---|
473 | .if t \fB\(bv\(bv & && ; ;; ( ) | <newline>\fP
|
---|
474 | .if n \fB|| & && ; ;; ( ) | <newline>\fP
|
---|
475 | .RE
|
---|
476 | .PD
|
---|
477 | .SH "RESERVED WORDS"
|
---|
478 | \fIReserved words\fP are words that have a special meaning to the shell.
|
---|
479 | The following words are recognized as reserved when unquoted and either
|
---|
480 | the first word of a simple command (see
|
---|
481 | .SM
|
---|
482 | .B SHELL GRAMMAR
|
---|
483 | below) or the third word of a
|
---|
484 | .B case
|
---|
485 | or
|
---|
486 | .B for
|
---|
487 | command:
|
---|
488 | .if t .RS
|
---|
489 | .PP
|
---|
490 | .B
|
---|
491 | .if n ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
|
---|
492 | .if t ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
|
---|
493 | .if t .RE
|
---|
494 | .SH "SHELL GRAMMAR"
|
---|
495 | .SS Simple Commands
|
---|
496 | .PP
|
---|
497 | A \fIsimple command\fP is a sequence of optional variable assignments
|
---|
498 | followed by \fBblank\fP-separated words and redirections, and
|
---|
499 | terminated by a \fIcontrol operator\fP. The first word
|
---|
500 | specifies the command to be executed, and is passed as argument zero.
|
---|
501 | The remaining words are passed as arguments to the invoked command.
|
---|
502 | .PP
|
---|
503 | The return value of a \fIsimple command\fP is its exit status, or
|
---|
504 | 128+\fIn\^\fP if the command is terminated by signal
|
---|
505 | .IR n .
|
---|
506 | .SS Pipelines
|
---|
507 | .PP
|
---|
508 | A \fIpipeline\fP is a sequence of one or more commands separated by
|
---|
509 | the character
|
---|
510 | .BR | .
|
---|
511 | The format for a pipeline is:
|
---|
512 | .RS
|
---|
513 | .PP
|
---|
514 | [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ]
|
---|
515 | .RE
|
---|
516 | .PP
|
---|
517 | The standard output of
|
---|
518 | .I command
|
---|
519 | is connected via a pipe to the standard input of
|
---|
520 | .IR command2 .
|
---|
521 | This connection is performed before any redirections specified by the
|
---|
522 | command (see
|
---|
523 | .SM
|
---|
524 | .B REDIRECTION
|
---|
525 | below).
|
---|
526 | .PP
|
---|
527 | The return status of a pipeline is the exit status of the last
|
---|
528 | command, unless the \fBpipefail\fP option is enabled.
|
---|
529 | If \fBpipefail\fP is enabled, the pipeline's return status is the
|
---|
530 | value of the last (rightmost) command to exit with a non-zero status,
|
---|
531 | or zero if all commands exit successfully.
|
---|
532 | If the reserved word
|
---|
533 | .B !
|
---|
534 | precedes a pipeline, the exit status of that pipeline is the logical
|
---|
535 | negation of the exit status as described above.
|
---|
536 | The shell waits for all commands in the pipeline to
|
---|
537 | terminate before returning a value.
|
---|
538 | .PP
|
---|
539 | If the
|
---|
540 | .B time
|
---|
541 | reserved word precedes a pipeline, the elapsed as well as user and
|
---|
542 | system time consumed by its execution are reported when the pipeline
|
---|
543 | terminates.
|
---|
544 | The \fB\-p\fP option changes the output format to that specified by POSIX.
|
---|
545 | The
|
---|
546 | .SM
|
---|
547 | .B TIMEFORMAT
|
---|
548 | variable may be set to a format string that specifies how the timing
|
---|
549 | information should be displayed; see the description of
|
---|
550 | .SM
|
---|
551 | .B TIMEFORMAT
|
---|
552 | under
|
---|
553 | .B "Shell Variables"
|
---|
554 | below.
|
---|
555 | .PP
|
---|
556 | Each command in a pipeline is executed as a separate process (i.e., in a
|
---|
557 | subshell).
|
---|
558 | .SS Lists
|
---|
559 | .PP
|
---|
560 | A \fIlist\fP is a sequence of one or more pipelines separated by one
|
---|
561 | of the operators
|
---|
562 | .BR ; ,
|
---|
563 | .BR & ,
|
---|
564 | .BR && ,
|
---|
565 | or
|
---|
566 | .BR \(bv\(bv ,
|
---|
567 | and optionally terminated by one of
|
---|
568 | .BR ; ,
|
---|
569 | .BR & ,
|
---|
570 | or
|
---|
571 | .BR <newline> .
|
---|
572 | .PP
|
---|
573 | Of these list operators,
|
---|
574 | .B &&
|
---|
575 | and
|
---|
576 | .B \(bv\(bv
|
---|
577 | have equal precedence, followed by
|
---|
578 | .B ;
|
---|
579 | and
|
---|
580 | .BR &,
|
---|
581 | which have equal precedence.
|
---|
582 | .PP
|
---|
583 | A sequence of one or more newlines may appear in a \fIlist\fP instead
|
---|
584 | of a semicolon to delimit commands.
|
---|
585 | .PP
|
---|
586 | If a command is terminated by the control operator
|
---|
587 | .BR & ,
|
---|
588 | the shell executes the command in the \fIbackground\fP
|
---|
589 | in a subshell. The shell does not wait for the command to
|
---|
590 | finish, and the return status is 0. Commands separated by a
|
---|
591 | .B ;
|
---|
592 | are executed sequentially; the shell waits for each
|
---|
593 | command to terminate in turn. The return status is the
|
---|
594 | exit status of the last command executed.
|
---|
595 | .PP
|
---|
596 | The control operators
|
---|
597 | .B &&
|
---|
598 | and
|
---|
599 | .B \(bv\(bv
|
---|
600 | denote AND lists and OR lists, respectively.
|
---|
601 | An AND list has the form
|
---|
602 | .RS
|
---|
603 | .PP
|
---|
604 | \fIcommand1\fP \fB&&\fP \fIcommand2\fP
|
---|
605 | .RE
|
---|
606 | .PP
|
---|
607 | .I command2
|
---|
608 | is executed if, and only if,
|
---|
609 | .I command1
|
---|
610 | returns an exit status of zero.
|
---|
611 | .PP
|
---|
612 | An OR list has the form
|
---|
613 | .RS
|
---|
614 | .PP
|
---|
615 | \fIcommand1\fP \fB\(bv\(bv\fP \fIcommand2\fP
|
---|
616 | .PP
|
---|
617 | .RE
|
---|
618 | .PP
|
---|
619 | .I command2
|
---|
620 | is executed if and only if
|
---|
621 | .I command1
|
---|
622 | returns a non-zero exit status. The return status of
|
---|
623 | AND and OR lists is the exit status of the last command
|
---|
624 | executed in the list.
|
---|
625 | .SS Compound Commands
|
---|
626 | .PP
|
---|
627 | A \fIcompound command\fP is one of the following:
|
---|
628 | .TP
|
---|
629 | (\fIlist\fP)
|
---|
630 | \fIlist\fP is executed in a subshell environment (see
|
---|
631 | .SM
|
---|
632 | \fBCOMMAND EXECUTION ENVIRONMENT\fP
|
---|
633 | below).
|
---|
634 | Variable assignments and builtin
|
---|
635 | commands that affect the shell's environment do not remain in effect
|
---|
636 | after the command completes. The return status is the exit status of
|
---|
637 | \fIlist\fP.
|
---|
638 | .TP
|
---|
639 | { \fIlist\fP; }
|
---|
640 | \fIlist\fP is simply executed in the current shell environment.
|
---|
641 | \fIlist\fP must be terminated with a newline or semicolon.
|
---|
642 | This is known as a \fIgroup command\fP.
|
---|
643 | The return status is the exit status of
|
---|
644 | \fIlist\fP.
|
---|
645 | Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and
|
---|
646 | \fB}\fP are \fIreserved words\fP and must occur where a reserved
|
---|
647 | word is permitted to be recognized. Since they do not cause a word
|
---|
648 | break, they must be separated from \fIlist\fP by whitespace.
|
---|
649 | .TP
|
---|
650 | ((\fIexpression\fP))
|
---|
651 | The \fIexpression\fP is evaluated according to the rules described
|
---|
652 | below under
|
---|
653 | .SM
|
---|
654 | .BR "ARITHMETIC EVALUATION" .
|
---|
655 | If the value of the expression is non-zero, the return status is 0;
|
---|
656 | otherwise the return status is 1. This is exactly equivalent to
|
---|
657 | \fBlet "\fIexpression\fP"\fR.
|
---|
658 | .TP
|
---|
659 | \fB[[\fP \fIexpression\fP \fB]]\fP
|
---|
660 | Return a status of 0 or 1 depending on the evaluation of
|
---|
661 | the conditional expression \fIexpression\fP.
|
---|
662 | Expressions are composed of the primaries described below under
|
---|
663 | .SM
|
---|
664 | .BR "CONDITIONAL EXPRESSIONS" .
|
---|
665 | Word splitting and pathname expansion are not performed on the words
|
---|
666 | between the \fB[[\fP and \fB]]\fP; tilde expansion, parameter and
|
---|
667 | variable expansion, arithmetic expansion, command substitution, process
|
---|
668 | substitution, and quote removal are performed.
|
---|
669 | Conditional operators such as \fB\-f\fP must be unquoted to be recognized
|
---|
670 | as primaries.
|
---|
671 | .if t .sp 0.5
|
---|
672 | .if n .sp 1
|
---|
673 | When the \fB==\fP and \fB!=\fP operators are used, the string to the
|
---|
674 | right of the operator is considered a pattern and matched according
|
---|
675 | to the rules described below under \fBPattern Matching\fP.
|
---|
676 | If the shell option
|
---|
677 | .B nocasematch
|
---|
678 | is enabled, the match is performed without regard to the case
|
---|
679 | of alphabetic characters.
|
---|
680 | The return value is 0 if the string matches (\fB==\fP) or does not match
|
---|
681 | (\fB!=\fP) the pattern, and 1 otherwise.
|
---|
682 | Any part of the pattern may be quoted to force it to be matched as a
|
---|
683 | string.
|
---|
684 | .if t .sp 0.5
|
---|
685 | .if n .sp 1
|
---|
686 | An additional binary operator, \fB=~\fP, is available, with the same
|
---|
687 | precedence as \fB==\fP and \fB!=\fP.
|
---|
688 | When it is used, the string to the right of the operator is considered
|
---|
689 | an extended regular expression and matched accordingly (as in \fIregex\fP(3)).
|
---|
690 | The return value is 0 if the string matches
|
---|
691 | the pattern, and 1 otherwise.
|
---|
692 | If the regular expression is syntactically incorrect, the conditional
|
---|
693 | expression's return value is 2.
|
---|
694 | If the shell option
|
---|
695 | .B nocasematch
|
---|
696 | is enabled, the match is performed without regard to the case
|
---|
697 | of alphabetic characters.
|
---|
698 | Substrings matched by parenthesized subexpressions within the regular
|
---|
699 | expression are saved in the array variable \fBBASH_REMATCH\fP.
|
---|
700 | The element of \fBBASH_REMATCH\fP with index 0 is the portion of the string
|
---|
701 | matching the entire regular expression.
|
---|
702 | The element of \fBBASH_REMATCH\fP with index \fIn\fP is the portion of the
|
---|
703 | string matching the \fIn\fPth parenthesized subexpression.
|
---|
704 | .if t .sp 0.5
|
---|
705 | .if n .sp 1
|
---|
706 | Expressions may be combined using the following operators, listed
|
---|
707 | in decreasing order of precedence:
|
---|
708 | .if t .sp 0.5
|
---|
709 | .if n .sp 1
|
---|
710 | .RS
|
---|
711 | .PD 0
|
---|
712 | .TP
|
---|
713 | .B ( \fIexpression\fP )
|
---|
714 | Returns the value of \fIexpression\fP.
|
---|
715 | This may be used to override the normal precedence of operators.
|
---|
716 | .TP
|
---|
717 | .B ! \fIexpression\fP
|
---|
718 | True if
|
---|
719 | .I expression
|
---|
720 | is false.
|
---|
721 | .TP
|
---|
722 | \fIexpression1\fP \fB&&\fP \fIexpression2\fP
|
---|
723 | True if both
|
---|
724 | .I expression1
|
---|
725 | and
|
---|
726 | .I expression2
|
---|
727 | are true.
|
---|
728 | .TP
|
---|
729 | .if t \fIexpression1\fP \fB\(bv\(bv\fP \fIexpression2\fP
|
---|
730 | .if n \fIexpression1\fP \fB||\fP \fIexpression2\fP
|
---|
731 | True if either
|
---|
732 | .I expression1
|
---|
733 | or
|
---|
734 | .I expression2
|
---|
735 | is true.
|
---|
736 | .PD
|
---|
737 | .LP
|
---|
738 | The \fB&&\fP and
|
---|
739 | .if t \fB\(bv\(bv\fP
|
---|
740 | .if n \fB||\fP
|
---|
741 | operators do not evaluate \fIexpression2\fP if the value of
|
---|
742 | \fIexpression1\fP is sufficient to determine the return value of
|
---|
743 | the entire conditional expression.
|
---|
744 | .RE
|
---|
745 | .TP
|
---|
746 | \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
|
---|
747 | The list of words following \fBin\fP is expanded, generating a list
|
---|
748 | of items.
|
---|
749 | The variable \fIname\fP is set to each element of this list
|
---|
750 | in turn, and \fIlist\fP is executed each time.
|
---|
751 | If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes
|
---|
752 | \fIlist\fP once for each positional parameter that is set (see
|
---|
753 | .SM
|
---|
754 | .B PARAMETERS
|
---|
755 | below).
|
---|
756 | The return status is the exit status of the last command that executes.
|
---|
757 | If the expansion of the items following \fBin\fP results in an empty
|
---|
758 | list, no commands are executed, and the return status is 0.
|
---|
759 | .TP
|
---|
760 | \fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP
|
---|
761 | First, the arithmetic expression \fIexpr1\fP is evaluated according
|
---|
762 | to the rules described below under
|
---|
763 | .SM
|
---|
764 | .BR "ARITHMETIC EVALUATION" .
|
---|
765 | The arithmetic expression \fIexpr2\fP is then evaluated repeatedly
|
---|
766 | until it evaluates to zero.
|
---|
767 | Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is
|
---|
768 | executed and the arithmetic expression \fIexpr3\fP is evaluated.
|
---|
769 | If any expression is omitted, it behaves as if it evaluates to 1.
|
---|
770 | The return value is the exit status of the last command in \fIlist\fP
|
---|
771 | that is executed, or false if any of the expressions is invalid.
|
---|
772 | .TP
|
---|
773 | \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
|
---|
774 | The list of words following \fBin\fP is expanded, generating a list
|
---|
775 | of items. The set of expanded words is printed on the standard
|
---|
776 | error, each preceded by a number. If the \fBin\fP
|
---|
777 | \fIword\fP is omitted, the positional parameters are printed (see
|
---|
778 | .SM
|
---|
779 | .B PARAMETERS
|
---|
780 | below). The
|
---|
781 | .B PS3
|
---|
782 | prompt is then displayed and a line read from the standard input.
|
---|
783 | If the line consists of a number corresponding to one of
|
---|
784 | the displayed words, then the value of
|
---|
785 | .I name
|
---|
786 | is set to that word. If the line is empty, the words and prompt
|
---|
787 | are displayed again. If EOF is read, the command completes. Any
|
---|
788 | other value read causes
|
---|
789 | .I name
|
---|
790 | to be set to null. The line read is saved in the variable
|
---|
791 | .BR REPLY .
|
---|
792 | The
|
---|
793 | .I list
|
---|
794 | is executed after each selection until a
|
---|
795 | .B break
|
---|
796 | command is executed.
|
---|
797 | The exit status of
|
---|
798 | .B select
|
---|
799 | is the exit status of the last command executed in
|
---|
800 | .IR list ,
|
---|
801 | or zero if no commands were executed.
|
---|
802 | .TP
|
---|
803 | \fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
|
---|
804 | ... ) \fIlist\fP ;; ] ... \fBesac\fP
|
---|
805 | A \fBcase\fP command first expands \fIword\fP, and tries to match
|
---|
806 | it against each \fIpattern\fP in turn, using the same matching rules
|
---|
807 | as for pathname expansion (see
|
---|
808 | .B Pathname Expansion
|
---|
809 | below).
|
---|
810 | The \fIword\fP is expanded using tilde
|
---|
811 | expansion, parameter and variable expansion, arithmetic substituion,
|
---|
812 | command substitution, process substitution and quote removal.
|
---|
813 | Each \fIpattern\fP examined is expanded using tilde
|
---|
814 | expansion, parameter and variable expansion, arithmetic substituion,
|
---|
815 | command substitution, and process substitution.
|
---|
816 | If the shell option
|
---|
817 | .B nocasematch
|
---|
818 | is enabled, the match is performed without regard to the case
|
---|
819 | of alphabetic characters.
|
---|
820 | When a match is found, the
|
---|
821 | corresponding \fIlist\fP is executed. After the first match, no
|
---|
822 | subsequent matches are attempted. The exit status is zero if no
|
---|
823 | pattern matches. Otherwise, it is the exit status of the
|
---|
824 | last command executed in \fIlist\fP.
|
---|
825 | .TP
|
---|
826 | \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
|
---|
827 | [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
|
---|
828 | [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
|
---|
829 | The
|
---|
830 | .B if
|
---|
831 | .I list
|
---|
832 | is executed. If its exit status is zero, the
|
---|
833 | \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP
|
---|
834 | \fIlist\fP is executed in turn, and if its exit status is zero,
|
---|
835 | the corresponding \fBthen\fP \fIlist\fP is executed and the
|
---|
836 | command completes. Otherwise, the \fBelse\fP \fIlist\fP is
|
---|
837 | executed, if present. The exit status is the exit status of the
|
---|
838 | last command executed, or zero if no condition tested true.
|
---|
839 | .TP
|
---|
840 | \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
|
---|
841 | .PD 0
|
---|
842 | .TP
|
---|
843 | \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
|
---|
844 | .PD
|
---|
845 | The \fBwhile\fP command continuously executes the \fBdo\fP
|
---|
846 | \fIlist\fP as long as the last command in \fIlist\fP returns
|
---|
847 | an exit status of zero. The \fBuntil\fP command is identical
|
---|
848 | to the \fBwhile\fP command, except that the test is negated;
|
---|
849 | the
|
---|
850 | .B do
|
---|
851 | .I list
|
---|
852 | is executed as long as the last command in
|
---|
853 | .I list
|
---|
854 | returns a non-zero exit status.
|
---|
855 | The exit status of the \fBwhile\fP and \fBuntil\fP commands
|
---|
856 | is the exit status
|
---|
857 | of the last \fBdo\fP \fIlist\fP command executed, or zero if
|
---|
858 | none was executed.
|
---|
859 | .SS Shell Function Definitions
|
---|
860 | .PP
|
---|
861 | A shell function is an object that is called like a simple command and
|
---|
862 | executes a compound command with a new set of positional parameters.
|
---|
863 | Shell functions are declared as follows:
|
---|
864 | .TP
|
---|
865 | [ \fBfunction\fP ] \fIname\fP () \fIcompound\-command\fP [\fIredirection\fP]
|
---|
866 | This defines a function named \fIname\fP.
|
---|
867 | The reserved word \fBfunction\fP is optional.
|
---|
868 | If the \fBfunction\fP reserved word is supplied, the parentheses are optional.
|
---|
869 | The \fIbody\fP of the function is the compound command
|
---|
870 | .I compound\-command
|
---|
871 | (see \fBCompound Commands\fP above).
|
---|
872 | That command is usually a \fIlist\fP of commands between { and }, but
|
---|
873 | may be any command listed under \fBCompound Commands\fP above.
|
---|
874 | \fIcompound\-command\fP is executed whenever \fIname\fP is specified as the
|
---|
875 | name of a simple command.
|
---|
876 | Any redirections (see
|
---|
877 | .SM
|
---|
878 | .B REDIRECTION
|
---|
879 | below) specified when a function is defined are performed
|
---|
880 | when the function is executed.
|
---|
881 | The exit status of a function definition is zero unless a syntax error
|
---|
882 | occurs or a readonly function with the same name already exists.
|
---|
883 | When executed, the exit status of a function is the exit status of the
|
---|
884 | last command executed in the body. (See
|
---|
885 | .SM
|
---|
886 | .B FUNCTIONS
|
---|
887 | below.)
|
---|
888 | .SH COMMENTS
|
---|
889 | In a non-interactive shell, or an interactive shell in which the
|
---|
890 | .B interactive_comments
|
---|
891 | option to the
|
---|
892 | .B shopt
|
---|
893 | builtin is enabled (see
|
---|
894 | .SM
|
---|
895 | .B "SHELL BUILTIN COMMANDS"
|
---|
896 | below), a word beginning with
|
---|
897 | .B #
|
---|
898 | causes that word and all remaining characters on that line to
|
---|
899 | be ignored. An interactive shell without the
|
---|
900 | .B interactive_comments
|
---|
901 | option enabled does not allow comments. The
|
---|
902 | .B interactive_comments
|
---|
903 | option is on by default in interactive shells.
|
---|
904 | .SH QUOTING
|
---|
905 | \fIQuoting\fP is used to remove the special meaning of certain
|
---|
906 | characters or words to the shell. Quoting can be used to
|
---|
907 | disable special treatment for special characters, to prevent
|
---|
908 | reserved words from being recognized as such, and to prevent
|
---|
909 | parameter expansion.
|
---|
910 | .PP
|
---|
911 | Each of the \fImetacharacters\fP listed above under
|
---|
912 | .SM
|
---|
913 | .B DEFINITIONS
|
---|
914 | has special meaning to the shell and must be quoted if it is to
|
---|
915 | represent itself.
|
---|
916 | .PP
|
---|
917 | When the command history expansion facilities are being used
|
---|
918 | (see
|
---|
919 | .SM
|
---|
920 | .B HISTORY EXPANSION
|
---|
921 | below), the
|
---|
922 | \fIhistory expansion\fP character, usually \fB!\fP, must be quoted
|
---|
923 | to prevent history expansion.
|
---|
924 | .PP
|
---|
925 | There are three quoting mechanisms: the
|
---|
926 | .IR "escape character" ,
|
---|
927 | single quotes, and double quotes.
|
---|
928 | .PP
|
---|
929 | A non-quoted backslash (\fB\e\fP) is the
|
---|
930 | .IR "escape character" .
|
---|
931 | It preserves the literal value of the next character that follows,
|
---|
932 | with the exception of <newline>. If a \fB\e\fP<newline> pair
|
---|
933 | appears, and the backslash is not itself quoted, the \fB\e\fP<newline>
|
---|
934 | is treated as a line continuation (that is, it is removed from the
|
---|
935 | input stream and effectively ignored).
|
---|
936 | .PP
|
---|
937 | Enclosing characters in single quotes preserves the literal value
|
---|
938 | of each character within the quotes. A single quote may not occur
|
---|
939 | between single quotes, even when preceded by a backslash.
|
---|
940 | .PP
|
---|
941 | Enclosing characters in double quotes preserves the literal value
|
---|
942 | of all characters within the quotes, with the exception of
|
---|
943 | .BR $ ,
|
---|
944 | .BR ` ,
|
---|
945 | .BR \e ,
|
---|
946 | and, when history expansion is enabled,
|
---|
947 | .BR ! .
|
---|
948 | The characters
|
---|
949 | .B $
|
---|
950 | and
|
---|
951 | .B `
|
---|
952 | retain their special meaning within double quotes. The backslash
|
---|
953 | retains its special meaning only when followed by one of the following
|
---|
954 | characters:
|
---|
955 | .BR $ ,
|
---|
956 | .BR ` ,
|
---|
957 | \^\fB"\fP\^,
|
---|
958 | .BR \e ,
|
---|
959 | or
|
---|
960 | .BR <newline> .
|
---|
961 | A double quote may be quoted within double quotes by preceding it with
|
---|
962 | a backslash.
|
---|
963 | If enabled, history expansion will be performed unless an
|
---|
964 | .B !
|
---|
965 | appearing in double quotes is escaped using a backslash.
|
---|
966 | The backslash preceding the
|
---|
967 | .B !
|
---|
968 | is not removed.
|
---|
969 | .PP
|
---|
970 | The special parameters
|
---|
971 | .B *
|
---|
972 | and
|
---|
973 | .B @
|
---|
974 | have special meaning when in double
|
---|
975 | quotes (see
|
---|
976 | .SM
|
---|
977 | .B PARAMETERS
|
---|
978 | below).
|
---|
979 | .PP
|
---|
980 | Words of the form \fB$\fP'\fIstring\fP' are treated specially. The
|
---|
981 | word expands to \fIstring\fP, with backslash-escaped characters replaced
|
---|
982 | as specified by the ANSI C standard. Backslash escape sequences, if
|
---|
983 | present, are decoded as follows:
|
---|
984 | .RS
|
---|
985 | .PD 0
|
---|
986 | .TP
|
---|
987 | .B \ea
|
---|
988 | alert (bell)
|
---|
989 | .TP
|
---|
990 | .B \eb
|
---|
991 | backspace
|
---|
992 | .TP
|
---|
993 | .B \ee
|
---|
994 | an escape character
|
---|
995 | .TP
|
---|
996 | .B \ef
|
---|
997 | form feed
|
---|
998 | .TP
|
---|
999 | .B \en
|
---|
1000 | new line
|
---|
1001 | .TP
|
---|
1002 | .B \er
|
---|
1003 | carriage return
|
---|
1004 | .TP
|
---|
1005 | .B \et
|
---|
1006 | horizontal tab
|
---|
1007 | .TP
|
---|
1008 | .B \ev
|
---|
1009 | vertical tab
|
---|
1010 | .TP
|
---|
1011 | .B \e\e
|
---|
1012 | backslash
|
---|
1013 | .TP
|
---|
1014 | .B \e'
|
---|
1015 | single quote
|
---|
1016 | .TP
|
---|
1017 | .B \e\fInnn\fP
|
---|
1018 | the eight-bit character whose value is the octal value \fInnn\fP
|
---|
1019 | (one to three digits)
|
---|
1020 | .TP
|
---|
1021 | .B \ex\fIHH\fP
|
---|
1022 | the eight-bit character whose value is the hexadecimal value \fIHH\fP
|
---|
1023 | (one or two hex digits)
|
---|
1024 | .TP
|
---|
1025 | .B \ec\fIx\fP
|
---|
1026 | a control-\fIx\fP character
|
---|
1027 | .PD
|
---|
1028 | .RE
|
---|
1029 | .LP
|
---|
1030 | The expanded result is single-quoted, as if the dollar sign had
|
---|
1031 | not been present.
|
---|
1032 | .PP
|
---|
1033 | A double-quoted string preceded by a dollar sign (\fB$\fP) will cause
|
---|
1034 | the string to be translated according to the current locale.
|
---|
1035 | If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
|
---|
1036 | is ignored.
|
---|
1037 | If the string is translated and replaced, the replacement is
|
---|
1038 | double-quoted.
|
---|
1039 | .SH PARAMETERS
|
---|
1040 | A
|
---|
1041 | .I parameter
|
---|
1042 | is an entity that stores values.
|
---|
1043 | It can be a
|
---|
1044 | .IR name ,
|
---|
1045 | a number, or one of the special characters listed below under
|
---|
1046 | .BR "Special Parameters" .
|
---|
1047 | A
|
---|
1048 | .I variable
|
---|
1049 | is a parameter denoted by a
|
---|
1050 | .IR name .
|
---|
1051 | A variable has a \fIvalue\fP and zero or more \fIattributes\fP.
|
---|
1052 | Attributes are assigned using the
|
---|
1053 | .B declare
|
---|
1054 | builtin command (see
|
---|
1055 | .B declare
|
---|
1056 | below in
|
---|
1057 | .SM
|
---|
1058 | .BR "SHELL BUILTIN COMMANDS" ).
|
---|
1059 | .PP
|
---|
1060 | A parameter is set if it has been assigned a value. The null string is
|
---|
1061 | a valid value. Once a variable is set, it may be unset only by using
|
---|
1062 | the
|
---|
1063 | .B unset
|
---|
1064 | builtin command (see
|
---|
1065 | .SM
|
---|
1066 | .B SHELL BUILTIN COMMANDS
|
---|
1067 | below).
|
---|
1068 | .PP
|
---|
1069 | A
|
---|
1070 | .I variable
|
---|
1071 | may be assigned to by a statement of the form
|
---|
1072 | .RS
|
---|
1073 | .PP
|
---|
1074 | \fIname\fP=[\fIvalue\fP]
|
---|
1075 | .RE
|
---|
1076 | .PP
|
---|
1077 | If
|
---|
1078 | .I value
|
---|
1079 | is not given, the variable is assigned the null string. All
|
---|
1080 | .I values
|
---|
1081 | undergo tilde expansion, parameter and variable expansion,
|
---|
1082 | command substitution, arithmetic expansion, and quote
|
---|
1083 | removal (see
|
---|
1084 | .SM
|
---|
1085 | .B EXPANSION
|
---|
1086 | below). If the variable has its
|
---|
1087 | .B integer
|
---|
1088 | attribute set, then
|
---|
1089 | .I value
|
---|
1090 | is evaluated as an arithmetic expression even if the $((...)) expansion is
|
---|
1091 | not used (see
|
---|
1092 | .B "Arithmetic Expansion"
|
---|
1093 | below).
|
---|
1094 | Word splitting is not performed, with the exception
|
---|
1095 | of \fB"$@"\fP as explained below under
|
---|
1096 | .BR "Special Parameters" .
|
---|
1097 | Pathname expansion is not performed.
|
---|
1098 | Assignment statements may also appear as arguments to the
|
---|
1099 | .BR alias ,
|
---|
1100 | .BR declare ,
|
---|
1101 | .BR typeset ,
|
---|
1102 | .BR export ,
|
---|
1103 | .BR readonly ,
|
---|
1104 | and
|
---|
1105 | .B local
|
---|
1106 | builtin commands.
|
---|
1107 | .PP
|
---|
1108 | In the context where an assignment statement is assigning a value
|
---|
1109 | to a shell variable or array index, the += operator can be used to
|
---|
1110 | append to or add to the variable's previous value.
|
---|
1111 | When += is applied to a variable for which the integer attribute has been
|
---|
1112 | set, \fIvalue\fP is evaluated as an arithmetic expression and added to the
|
---|
1113 | variable's current value, which is also evaluated.
|
---|
1114 | When += is applied to an array variable using compound assignment (see
|
---|
1115 | .B Arrays
|
---|
1116 | below), the
|
---|
1117 | variable's value is not unset (as it is when using =), and new values are
|
---|
1118 | appended to the array beginning at one greater than the array's maximum index.
|
---|
1119 | When applied to a string-valued variable, \fIvalue\fP is expanded and
|
---|
1120 | appended to the variable's value.
|
---|
1121 | .SS Positional Parameters
|
---|
1122 | .PP
|
---|
1123 | A
|
---|
1124 | .I positional parameter
|
---|
1125 | is a parameter denoted by one or more
|
---|
1126 | digits, other than the single digit 0. Positional parameters are
|
---|
1127 | assigned from the shell's arguments when it is invoked,
|
---|
1128 | and may be reassigned using the
|
---|
1129 | .B set
|
---|
1130 | builtin command. Positional parameters may not be assigned to
|
---|
1131 | with assignment statements. The positional parameters are
|
---|
1132 | temporarily replaced when a shell function is executed (see
|
---|
1133 | .SM
|
---|
1134 | .B FUNCTIONS
|
---|
1135 | below).
|
---|
1136 | .PP
|
---|
1137 | When a positional parameter consisting of more than a single
|
---|
1138 | digit is expanded, it must be enclosed in braces (see
|
---|
1139 | .SM
|
---|
1140 | .B EXPANSION
|
---|
1141 | below).
|
---|
1142 | .SS Special Parameters
|
---|
1143 | .PP
|
---|
1144 | The shell treats several parameters specially. These parameters may
|
---|
1145 | only be referenced; assignment to them is not allowed.
|
---|
1146 | .PD 0
|
---|
1147 | .TP
|
---|
1148 | .B *
|
---|
1149 | Expands to the positional parameters, starting from one. When the
|
---|
1150 | expansion occurs within double quotes, it expands to a single word
|
---|
1151 | with the value of each parameter separated by the first character
|
---|
1152 | of the
|
---|
1153 | .SM
|
---|
1154 | .B IFS
|
---|
1155 | special variable. That is, "\fB$*\fP" is equivalent
|
---|
1156 | to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where
|
---|
1157 | .I c
|
---|
1158 | is the first character of the value of the
|
---|
1159 | .SM
|
---|
1160 | .B IFS
|
---|
1161 | variable. If
|
---|
1162 | .SM
|
---|
1163 | .B IFS
|
---|
1164 | is unset, the parameters are separated by spaces.
|
---|
1165 | If
|
---|
1166 | .SM
|
---|
1167 | .B IFS
|
---|
1168 | is null, the parameters are joined without intervening separators.
|
---|
1169 | .TP
|
---|
1170 | .B @
|
---|
1171 | Expands to the positional parameters, starting from one. When the
|
---|
1172 | expansion occurs within double quotes, each parameter expands to a
|
---|
1173 | separate word. That is, "\fB$@\fP" is equivalent to
|
---|
1174 | "\fB$1\fP" "\fB$2\fP" ...
|
---|
1175 | If the double-quoted expansion occurs within a word, the expansion of
|
---|
1176 | the first parameter is joined with the beginning part of the original
|
---|
1177 | word, and the expansion of the last parameter is joined with the last
|
---|
1178 | part of the original word.
|
---|
1179 | When there are no positional parameters, "\fB$@\fP" and
|
---|
1180 | .B $@
|
---|
1181 | expand to nothing (i.e., they are removed).
|
---|
1182 | .TP
|
---|
1183 | .B #
|
---|
1184 | Expands to the number of positional parameters in decimal.
|
---|
1185 | .TP
|
---|
1186 | .B ?
|
---|
1187 | Expands to the status of the most recently executed foreground
|
---|
1188 | pipeline.
|
---|
1189 | .TP
|
---|
1190 | .B \-
|
---|
1191 | Expands to the current option flags as specified upon invocation,
|
---|
1192 | by the
|
---|
1193 | .B set
|
---|
1194 | builtin command, or those set by the shell itself
|
---|
1195 | (such as the
|
---|
1196 | .B \-i
|
---|
1197 | option).
|
---|
1198 | .TP
|
---|
1199 | .B $
|
---|
1200 | Expands to the process ID of the shell. In a () subshell, it
|
---|
1201 | expands to the process ID of the current shell, not the
|
---|
1202 | subshell.
|
---|
1203 | .TP
|
---|
1204 | .B !
|
---|
1205 | Expands to the process ID of the most recently executed background
|
---|
1206 | (asynchronous) command.
|
---|
1207 | .TP
|
---|
1208 | .B 0
|
---|
1209 | Expands to the name of the shell or shell script. This is set at
|
---|
1210 | shell initialization. If
|
---|
1211 | .B bash
|
---|
1212 | is invoked with a file of commands,
|
---|
1213 | .B $0
|
---|
1214 | is set to the name of that file. If
|
---|
1215 | .B bash
|
---|
1216 | is started with the
|
---|
1217 | .B \-c
|
---|
1218 | option, then
|
---|
1219 | .B $0
|
---|
1220 | is set to the first argument after the string to be
|
---|
1221 | executed, if one is present. Otherwise, it is set
|
---|
1222 | to the file name used to invoke
|
---|
1223 | .BR bash ,
|
---|
1224 | as given by argument zero.
|
---|
1225 | .TP
|
---|
1226 | .B _
|
---|
1227 | At shell startup, set to the absolute pathname used to invoke the
|
---|
1228 | shell or shell script being executed as passed in the environment
|
---|
1229 | or argument list.
|
---|
1230 | Subsequently, expands to the last argument to the previous command,
|
---|
1231 | after expansion.
|
---|
1232 | Also set to the full pathname used to invoke each command executed
|
---|
1233 | and placed in the environment exported to that command.
|
---|
1234 | When checking mail, this parameter holds the name of the mail file
|
---|
1235 | currently being checked.
|
---|
1236 | .PD
|
---|
1237 | .SS Shell Variables
|
---|
1238 | .PP
|
---|
1239 | The following variables are set by the shell:
|
---|
1240 | .PP
|
---|
1241 | .PD 0
|
---|
1242 | .TP
|
---|
1243 | .B BASH
|
---|
1244 | Expands to the full file name used to invoke this instance of
|
---|
1245 | .BR bash .
|
---|
1246 | .TP
|
---|
1247 | .B BASH_ARGC
|
---|
1248 | An array variable whose values are the number of parameters in each
|
---|
1249 | frame of the current bash execution call stack.
|
---|
1250 | The number of
|
---|
1251 | parameters to the current subroutine (shell function or script executed
|
---|
1252 | with \fB.\fP or \fBsource\fP) is at the top of the stack.
|
---|
1253 | When a subroutine is executed, the number of parameters passed is pushed onto
|
---|
1254 | \fBBASH_ARGC\fP.
|
---|
1255 | The shell sets \fBBASH_ARGC\fP only when in extended debugging mode
|
---|
1256 | (see the description of the
|
---|
1257 | .B extdebug
|
---|
1258 | option to the
|
---|
1259 | .B shopt
|
---|
1260 | builtin below)
|
---|
1261 | .TP
|
---|
1262 | .B BASH_ARGV
|
---|
1263 | An array variable containing all of the parameters in the current bash
|
---|
1264 | execution call stack. The final parameter of the last subroutine call
|
---|
1265 | is at the top of the stack; the first parameter of the initial call is
|
---|
1266 | at the bottom. When a subroutine is executed, the parameters supplied
|
---|
1267 | are pushed onto \fBBASH_ARGV\fP.
|
---|
1268 | The shell sets \fBBASH_ARGV\fP only when in extended debugging mode
|
---|
1269 | (see the description of the
|
---|
1270 | .B extdebug
|
---|
1271 | option to the
|
---|
1272 | .B shopt
|
---|
1273 | builtin below)
|
---|
1274 | .TP
|
---|
1275 | .B BASH_COMMAND
|
---|
1276 | The command currently being executed or about to be executed, unless the
|
---|
1277 | shell is executing a command as the result of a trap,
|
---|
1278 | in which case it is the command executing at the time of the trap.
|
---|
1279 | .TP
|
---|
1280 | .B BASH_EXECUTION_STRING
|
---|
1281 | The command argument to the \fB\-c\fP invocation option.
|
---|
1282 | .TP
|
---|
1283 | .B BASH_LINENO
|
---|
1284 | An array variable whose members are the line numbers in source files
|
---|
1285 | corresponding to each member of \fBFUNCNAME\fP.
|
---|
1286 | \fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source
|
---|
1287 | file where \fB${FUNCNAME[\fP\fI$ifP\fB]}\fP was called.
|
---|
1288 | The corresponding source file name is \fB${BASH_SOURCE[\fP\fI$i\fP\fB]}\fB.
|
---|
1289 | Use \fBLINENO\fP to obtain the current line number.
|
---|
1290 | .TP
|
---|
1291 | .B BASH_REMATCH
|
---|
1292 | An array variable whose members are assigned by the \fB=~\fP binary
|
---|
1293 | operator to the \fB[[\fP conditional command.
|
---|
1294 | The element with index 0 is the portion of the string
|
---|
1295 | matching the entire regular expression.
|
---|
1296 | The element with index \fIn\fP is the portion of the
|
---|
1297 | string matching the \fIn\fPth parenthesized subexpression.
|
---|
1298 | This variable is read-only.
|
---|
1299 | .TP
|
---|
1300 | .B BASH_SOURCE
|
---|
1301 | An array variable whose members are the source filenames corresponding
|
---|
1302 | to the elements in the \fBFUNCNAME\fP array variable.
|
---|
1303 | .TP
|
---|
1304 | .B BASH_SUBSHELL
|
---|
1305 | Incremented by one each time a subshell or subshell environment is spawned.
|
---|
1306 | The initial value is 0.
|
---|
1307 | .TP
|
---|
1308 | .B BASH_VERSINFO
|
---|
1309 | A readonly array variable whose members hold version information for
|
---|
1310 | this instance of
|
---|
1311 | .BR bash .
|
---|
1312 | The values assigned to the array members are as follows:
|
---|
1313 | .sp .5
|
---|
1314 | .RS
|
---|
1315 | .PD 0
|
---|
1316 | .TP 24
|
---|
1317 | .B BASH_VERSINFO[\fR0\fP]
|
---|
1318 | The major version number (the \fIrelease\fP).
|
---|
1319 | .TP
|
---|
1320 | .B BASH_VERSINFO[\fR1\fP]
|
---|
1321 | The minor version number (the \fIversion\fP).
|
---|
1322 | .TP
|
---|
1323 | .B BASH_VERSINFO[\fR2\fP]
|
---|
1324 | The patch level.
|
---|
1325 | .TP
|
---|
1326 | .B BASH_VERSINFO[\fR3\fP]
|
---|
1327 | The build version.
|
---|
1328 | .TP
|
---|
1329 | .B BASH_VERSINFO[\fR4\fP]
|
---|
1330 | The release status (e.g., \fIbeta1\fP).
|
---|
1331 | .TP
|
---|
1332 | .B BASH_VERSINFO[\fR5\fP]
|
---|
1333 | The value of \fBMACHTYPE\fP.
|
---|
1334 | .PD
|
---|
1335 | .RE
|
---|
1336 | .TP
|
---|
1337 | .B BASH_VERSION
|
---|
1338 | Expands to a string describing the version of this instance of
|
---|
1339 | .BR bash .
|
---|
1340 | .TP
|
---|
1341 | .B COMP_CWORD
|
---|
1342 | An index into \fB${COMP_WORDS}\fP of the word containing the current
|
---|
1343 | cursor position.
|
---|
1344 | This variable is available only in shell functions invoked by the
|
---|
1345 | programmable completion facilities (see \fBProgrammable Completion\fP
|
---|
1346 | below).
|
---|
1347 | .TP
|
---|
1348 | .B COMP_LINE
|
---|
1349 | The current command line.
|
---|
1350 | This variable is available only in shell functions and external
|
---|
1351 | commands invoked by the
|
---|
1352 | programmable completion facilities (see \fBProgrammable Completion\fP
|
---|
1353 | below).
|
---|
1354 | .TP
|
---|
1355 | .B COMP_POINT
|
---|
1356 | The index of the current cursor position relative to the beginning of
|
---|
1357 | the current command.
|
---|
1358 | If the current cursor position is at the end of the current command,
|
---|
1359 | the value of this variable is equal to \fB${#COMP_LINE}\fP.
|
---|
1360 | This variable is available only in shell functions and external
|
---|
1361 | commands invoked by the
|
---|
1362 | programmable completion facilities (see \fBProgrammable Completion\fP
|
---|
1363 | below).
|
---|
1364 | .TP
|
---|
1365 | .B COMP_WORDBREAKS
|
---|
1366 | The set of characters that the Readline library treats as word
|
---|
1367 | separators when performing word completion.
|
---|
1368 | If
|
---|
1369 | .SM
|
---|
1370 | .B COMP_WORDBREAKS
|
---|
1371 | is unset, it loses its special properties, even if it is
|
---|
1372 | subsequently reset.
|
---|
1373 | .TP
|
---|
1374 | .B COMP_WORDS
|
---|
1375 | An array variable (see \fBArrays\fP below) consisting of the individual
|
---|
1376 | words in the current command line.
|
---|
1377 | This variable is available only in shell functions invoked by the
|
---|
1378 | programmable completion facilities (see \fBProgrammable Completion\fP
|
---|
1379 | below).
|
---|
1380 | .TP
|
---|
1381 | .B DIRSTACK
|
---|
1382 | An array variable (see
|
---|
1383 | .B Arrays
|
---|
1384 | below) containing the current contents of the directory stack.
|
---|
1385 | Directories appear in the stack in the order they are displayed by the
|
---|
1386 | .B dirs
|
---|
1387 | builtin.
|
---|
1388 | Assigning to members of this array variable may be used to modify
|
---|
1389 | directories already in the stack, but the
|
---|
1390 | .B pushd
|
---|
1391 | and
|
---|
1392 | .B popd
|
---|
1393 | builtins must be used to add and remove directories.
|
---|
1394 | Assignment to this variable will not change the current directory.
|
---|
1395 | If
|
---|
1396 | .SM
|
---|
1397 | .B DIRSTACK
|
---|
1398 | is unset, it loses its special properties, even if it is
|
---|
1399 | subsequently reset.
|
---|
1400 | .TP
|
---|
1401 | .B EUID
|
---|
1402 | Expands to the effective user ID of the current user, initialized at
|
---|
1403 | shell startup. This variable is readonly.
|
---|
1404 | .TP
|
---|
1405 | .B FUNCNAME
|
---|
1406 | An array variable containing the names of all shell functions
|
---|
1407 | currently in the execution call stack.
|
---|
1408 | The element with index 0 is the name of any currently-executing
|
---|
1409 | shell function.
|
---|
1410 | The bottom-most element is "main".
|
---|
1411 | This variable exists only when a shell function is executing.
|
---|
1412 | Assignments to
|
---|
1413 | .SM
|
---|
1414 | .B FUNCNAME
|
---|
1415 | have no effect and return an error status.
|
---|
1416 | If
|
---|
1417 | .SM
|
---|
1418 | .B FUNCNAME
|
---|
1419 | is unset, it loses its special properties, even if it is
|
---|
1420 | subsequently reset.
|
---|
1421 | .TP
|
---|
1422 | .B GROUPS
|
---|
1423 | An array variable containing the list of groups of which the current
|
---|
1424 | user is a member.
|
---|
1425 | Assignments to
|
---|
1426 | .SM
|
---|
1427 | .B GROUPS
|
---|
1428 | have no effect and return an error status.
|
---|
1429 | If
|
---|
1430 | .SM
|
---|
1431 | .B GROUPS
|
---|
1432 | is unset, it loses its special properties, even if it is
|
---|
1433 | subsequently reset.
|
---|
1434 | .TP
|
---|
1435 | .B HISTCMD
|
---|
1436 | The history number, or index in the history list, of the current
|
---|
1437 | command.
|
---|
1438 | If
|
---|
1439 | .SM
|
---|
1440 | .B HISTCMD
|
---|
1441 | is unset, it loses its special properties, even if it is
|
---|
1442 | subsequently reset.
|
---|
1443 | .TP
|
---|
1444 | .B HOSTNAME
|
---|
1445 | Automatically set to the name of the current host.
|
---|
1446 | .TP
|
---|
1447 | .B HOSTTYPE
|
---|
1448 | Automatically set to a string that uniquely
|
---|
1449 | describes the type of machine on which
|
---|
1450 | .B bash
|
---|
1451 | is executing.
|
---|
1452 | The default is system-dependent.
|
---|
1453 | .TP
|
---|
1454 | .B LINENO
|
---|
1455 | Each time this parameter is referenced, the shell substitutes
|
---|
1456 | a decimal number representing the current sequential line number
|
---|
1457 | (starting with 1) within a script or function. When not in a
|
---|
1458 | script or function, the value substituted is not guaranteed to
|
---|
1459 | be meaningful.
|
---|
1460 | If
|
---|
1461 | .SM
|
---|
1462 | .B LINENO
|
---|
1463 | is unset, it loses its special properties, even if it is
|
---|
1464 | subsequently reset.
|
---|
1465 | .TP
|
---|
1466 | .B MACHTYPE
|
---|
1467 | Automatically set to a string that fully describes the system
|
---|
1468 | type on which
|
---|
1469 | .B bash
|
---|
1470 | is executing, in the standard GNU \fIcpu-company-system\fP format.
|
---|
1471 | The default is system-dependent.
|
---|
1472 | .TP
|
---|
1473 | .B OLDPWD
|
---|
1474 | The previous working directory as set by the
|
---|
1475 | .B cd
|
---|
1476 | command.
|
---|
1477 | .TP
|
---|
1478 | .B OPTARG
|
---|
1479 | The value of the last option argument processed by the
|
---|
1480 | .B getopts
|
---|
1481 | builtin command (see
|
---|
1482 | .SM
|
---|
1483 | .B SHELL BUILTIN COMMANDS
|
---|
1484 | below).
|
---|
1485 | .TP
|
---|
1486 | .B OPTIND
|
---|
1487 | The index of the next argument to be processed by the
|
---|
1488 | .B getopts
|
---|
1489 | builtin command (see
|
---|
1490 | .SM
|
---|
1491 | .B SHELL BUILTIN COMMANDS
|
---|
1492 | below).
|
---|
1493 | .TP
|
---|
1494 | .B OSTYPE
|
---|
1495 | Automatically set to a string that
|
---|
1496 | describes the operating system on which
|
---|
1497 | .B bash
|
---|
1498 | is executing.
|
---|
1499 | The default is system-dependent.
|
---|
1500 | .TP
|
---|
1501 | .B PIPESTATUS
|
---|
1502 | An array variable (see
|
---|
1503 | .B Arrays
|
---|
1504 | below) containing a list of exit status values from the processes
|
---|
1505 | in the most-recently-executed foreground pipeline (which may
|
---|
1506 | contain only a single command).
|
---|
1507 | .TP
|
---|
1508 | .B PPID
|
---|
1509 | The process ID of the shell's parent. This variable is readonly.
|
---|
1510 | .TP
|
---|
1511 | .B PWD
|
---|
1512 | The current working directory as set by the
|
---|
1513 | .B cd
|
---|
1514 | command.
|
---|
1515 | .TP
|
---|
1516 | .B RANDOM
|
---|
1517 | Each time this parameter is referenced, a random integer between
|
---|
1518 | 0 and 32767 is
|
---|
1519 | generated. The sequence of random numbers may be initialized by assigning
|
---|
1520 | a value to
|
---|
1521 | .SM
|
---|
1522 | .BR RANDOM .
|
---|
1523 | If
|
---|
1524 | .SM
|
---|
1525 | .B RANDOM
|
---|
1526 | is unset, it loses its special properties, even if it is
|
---|
1527 | subsequently reset.
|
---|
1528 | .TP
|
---|
1529 | .B REPLY
|
---|
1530 | Set to the line of input read by the
|
---|
1531 | .B read
|
---|
1532 | builtin command when no arguments are supplied.
|
---|
1533 | .TP
|
---|
1534 | .B SECONDS
|
---|
1535 | Each time this parameter is
|
---|
1536 | referenced, the number of seconds since shell invocation is returned. If a
|
---|
1537 | value is assigned to
|
---|
1538 | .SM
|
---|
1539 | .BR SECONDS ,
|
---|
1540 | the value returned upon subsequent
|
---|
1541 | references is
|
---|
1542 | the number of seconds since the assignment plus the value assigned.
|
---|
1543 | If
|
---|
1544 | .SM
|
---|
1545 | .B SECONDS
|
---|
1546 | is unset, it loses its special properties, even if it is
|
---|
1547 | subsequently reset.
|
---|
1548 | .TP
|
---|
1549 | .B SHELLOPTS
|
---|
1550 | A colon-separated list of enabled shell options. Each word in
|
---|
1551 | the list is a valid argument for the
|
---|
1552 | .B \-o
|
---|
1553 | option to the
|
---|
1554 | .B set
|
---|
1555 | builtin command (see
|
---|
1556 | .SM
|
---|
1557 | .B "SHELL BUILTIN COMMANDS"
|
---|
1558 | below). The options appearing in
|
---|
1559 | .SM
|
---|
1560 | .B SHELLOPTS
|
---|
1561 | are those reported as
|
---|
1562 | .I on
|
---|
1563 | by \fBset \-o\fP.
|
---|
1564 | If this variable is in the environment when
|
---|
1565 | .B bash
|
---|
1566 | starts up, each shell option in the list will be enabled before
|
---|
1567 | reading any startup files.
|
---|
1568 | This variable is read-only.
|
---|
1569 | .TP
|
---|
1570 | .B SHLVL
|
---|
1571 | Incremented by one each time an instance of
|
---|
1572 | .B bash
|
---|
1573 | is started.
|
---|
1574 | .TP
|
---|
1575 | .B UID
|
---|
1576 | Expands to the user ID of the current user, initialized at shell startup.
|
---|
1577 | This variable is readonly.
|
---|
1578 | .PD
|
---|
1579 | .PP
|
---|
1580 | The following variables are used by the shell. In some cases,
|
---|
1581 | .B bash
|
---|
1582 | assigns a default value to a variable; these cases are noted
|
---|
1583 | below.
|
---|
1584 | .PP
|
---|
1585 | .PD 0
|
---|
1586 | .TP
|
---|
1587 | .B BASH_ENV
|
---|
1588 | If this parameter is set when \fBbash\fP is executing a shell script,
|
---|
1589 | its value is interpreted as a filename containing commands to
|
---|
1590 | initialize the shell, as in
|
---|
1591 | .IR ~/.bashrc .
|
---|
1592 | The value of
|
---|
1593 | .SM
|
---|
1594 | .B BASH_ENV
|
---|
1595 | is subjected to parameter expansion, command substitution, and arithmetic
|
---|
1596 | expansion before being interpreted as a file name.
|
---|
1597 | .SM
|
---|
1598 | .B PATH
|
---|
1599 | is not used to search for the resultant file name.
|
---|
1600 | .TP
|
---|
1601 | .B CDPATH
|
---|
1602 | The search path for the
|
---|
1603 | .B cd
|
---|
1604 | command.
|
---|
1605 | This is a colon-separated list of directories in which the shell looks
|
---|
1606 | for destination directories specified by the
|
---|
1607 | .B cd
|
---|
1608 | command.
|
---|
1609 | A sample value is
|
---|
1610 | .if t \f(CW".:~:/usr"\fP.
|
---|
1611 | .if n ".:~:/usr".
|
---|
1612 | .TP
|
---|
1613 | .B COLUMNS
|
---|
1614 | Used by the \fBselect\fP builtin command to determine the terminal width
|
---|
1615 | when printing selection lists. Automatically set upon receipt of a SIGWINCH.
|
---|
1616 | .TP
|
---|
1617 | .B COMPREPLY
|
---|
1618 | An array variable from which \fBbash\fP reads the possible completions
|
---|
1619 | generated by a shell function invoked by the programmable completion
|
---|
1620 | facility (see \fBProgrammable Completion\fP below).
|
---|
1621 | .TP
|
---|
1622 | .B EMACS
|
---|
1623 | If \fBbash\fP finds this variable in the environment when the shell starts
|
---|
1624 | with value
|
---|
1625 | .if t \f(CWt\fP,
|
---|
1626 | .if n "t",
|
---|
1627 | it assumes that the shell is running in an emacs shell buffer and disables
|
---|
1628 | line editing.
|
---|
1629 | .TP
|
---|
1630 | .B FCEDIT
|
---|
1631 | The default editor for the
|
---|
1632 | .B fc
|
---|
1633 | builtin command.
|
---|
1634 | .TP
|
---|
1635 | .B FIGNORE
|
---|
1636 | A colon-separated list of suffixes to ignore when performing
|
---|
1637 | filename completion (see
|
---|
1638 | .SM
|
---|
1639 | .B READLINE
|
---|
1640 | below).
|
---|
1641 | A filename whose suffix matches one of the entries in
|
---|
1642 | .SM
|
---|
1643 | .B FIGNORE
|
---|
1644 | is excluded from the list of matched filenames.
|
---|
1645 | A sample value is
|
---|
1646 | .if t \f(CW".o:~"\fP.
|
---|
1647 | .if n ".o:~".
|
---|
1648 | .TP
|
---|
1649 | .B GLOBIGNORE
|
---|
1650 | A colon-separated list of patterns defining the set of filenames to
|
---|
1651 | be ignored by pathname expansion.
|
---|
1652 | If a filename matched by a pathname expansion pattern also matches one
|
---|
1653 | of the patterns in
|
---|
1654 | .SM
|
---|
1655 | .BR GLOBIGNORE ,
|
---|
1656 | it is removed from the list of matches.
|
---|
1657 | .TP
|
---|
1658 | .B HISTCONTROL
|
---|
1659 | A colon-separated list of values controlling how commands are saved on
|
---|
1660 | the history list.
|
---|
1661 | If the list of values includes
|
---|
1662 | .IR ignorespace ,
|
---|
1663 | lines which begin with a
|
---|
1664 | .B space
|
---|
1665 | character are not saved in the history list.
|
---|
1666 | A value of
|
---|
1667 | .I ignoredups
|
---|
1668 | causes lines matching the previous history entry to not be saved.
|
---|
1669 | A value of
|
---|
1670 | .I ignoreboth
|
---|
1671 | is shorthand for \fIignorespace\fP and \fIignoredups\fP.
|
---|
1672 | A value of
|
---|
1673 | .IR erasedups
|
---|
1674 | causes all previous lines matching the current line to be removed from
|
---|
1675 | the history list before that line is saved.
|
---|
1676 | Any value not in the above list is ignored.
|
---|
1677 | If \fBHISTCONTROL\fP is unset, or does not include a valid value,
|
---|
1678 | all lines read by the shell parser are saved on the history list,
|
---|
1679 | subject to the value of
|
---|
1680 | .BR HISTIGNORE .
|
---|
1681 | The second and subsequent lines of a multi-line compound command are
|
---|
1682 | not tested, and are added to the history regardless of the value of
|
---|
1683 | .BR HISTCONTROL .
|
---|
1684 | .TP
|
---|
1685 | .B HISTFILE
|
---|
1686 | The name of the file in which command history is saved (see
|
---|
1687 | .SM
|
---|
1688 | .B HISTORY
|
---|
1689 | below). The default value is \fI~/.bash_history\fP. If unset, the
|
---|
1690 | command history is not saved when an interactive shell exits.
|
---|
1691 | .TP
|
---|
1692 | .B HISTFILESIZE
|
---|
1693 | The maximum number of lines contained in the history file. When this
|
---|
1694 | variable is assigned a value, the history file is truncated, if
|
---|
1695 | necessary, to contain no more than that number of lines. The default
|
---|
1696 | value is 500. The history file is also truncated to this size after
|
---|
1697 | writing it when an interactive shell exits.
|
---|
1698 | .TP
|
---|
1699 | .B HISTIGNORE
|
---|
1700 | A colon-separated list of patterns used to decide which command lines
|
---|
1701 | should be saved on the history list. Each pattern is anchored at the
|
---|
1702 | beginning of the line and must match the complete line (no implicit
|
---|
1703 | `\fB*\fP' is appended). Each pattern is tested against the line
|
---|
1704 | after the checks specified by
|
---|
1705 | .B HISTCONTROL
|
---|
1706 | are applied.
|
---|
1707 | In addition to the normal shell pattern matching characters, `\fB&\fP'
|
---|
1708 | matches the previous history line. `\fB&\fP' may be escaped using a
|
---|
1709 | backslash; the backslash is removed before attempting a match.
|
---|
1710 | The second and subsequent lines of a multi-line compound command are
|
---|
1711 | not tested, and are added to the history regardless of the value of
|
---|
1712 | .BR HISTIGNORE .
|
---|
1713 | .TP
|
---|
1714 | .B HISTSIZE
|
---|
1715 | The number of commands to remember in the command history (see
|
---|
1716 | .SM
|
---|
1717 | .B HISTORY
|
---|
1718 | below). The default value is 500.
|
---|
1719 | .TP
|
---|
1720 | .B HISTTIMEFORMAT
|
---|
1721 | If this variable is set and not null, its value is used as a format string
|
---|
1722 | for \fIstrftime\fP(3) to print the time stamp associated with each history
|
---|
1723 | entry displayed by the \fBhistory\fP builtin.
|
---|
1724 | If this variable is set, time stamps are written to the history file so
|
---|
1725 | they may be preserved across shell sessions.
|
---|
1726 | .TP
|
---|
1727 | .B HOME
|
---|
1728 | The home directory of the current user; the default argument for the
|
---|
1729 | \fBcd\fP builtin command.
|
---|
1730 | The value of this variable is also used when performing tilde expansion.
|
---|
1731 | .TP
|
---|
1732 | .B HOSTFILE
|
---|
1733 | Contains the name of a file in the same format as
|
---|
1734 | .FN /etc/hosts
|
---|
1735 | that should be read when the shell needs to complete a
|
---|
1736 | hostname.
|
---|
1737 | The list of possible hostname completions may be changed while the
|
---|
1738 | shell is running;
|
---|
1739 | the next time hostname completion is attempted after the
|
---|
1740 | value is changed,
|
---|
1741 | .B bash
|
---|
1742 | adds the contents of the new file to the existing list.
|
---|
1743 | If
|
---|
1744 | .SM
|
---|
1745 | .B HOSTFILE
|
---|
1746 | is set, but has no value, \fBbash\fP attempts to read
|
---|
1747 | .FN /etc/hosts
|
---|
1748 | to obtain the list of possible hostname completions.
|
---|
1749 | When
|
---|
1750 | .SM
|
---|
1751 | .B HOSTFILE
|
---|
1752 | is unset, the hostname list is cleared.
|
---|
1753 | .TP
|
---|
1754 | .B IFS
|
---|
1755 | The
|
---|
1756 | .I Internal Field Separator
|
---|
1757 | that is used
|
---|
1758 | for word splitting after expansion and to
|
---|
1759 | split lines into words with the
|
---|
1760 | .B read
|
---|
1761 | builtin command. The default value is
|
---|
1762 | ``<space><tab><newline>''.
|
---|
1763 | .TP
|
---|
1764 | .B IGNOREEOF
|
---|
1765 | Controls the
|
---|
1766 | action of an interactive shell on receipt of an
|
---|
1767 | .SM
|
---|
1768 | .B EOF
|
---|
1769 | character as the sole input. If set, the value is the number of
|
---|
1770 | consecutive
|
---|
1771 | .SM
|
---|
1772 | .B EOF
|
---|
1773 | characters which must be
|
---|
1774 | typed as the first characters on an input line before
|
---|
1775 | .B bash
|
---|
1776 | exits. If the variable exists but does not have a numeric value, or
|
---|
1777 | has no value, the default value is 10. If it does not exist,
|
---|
1778 | .SM
|
---|
1779 | .B EOF
|
---|
1780 | signifies the end of input to the shell.
|
---|
1781 | .TP
|
---|
1782 | .B INPUTRC
|
---|
1783 | The filename for the
|
---|
1784 | .B readline
|
---|
1785 | startup file, overriding the default of
|
---|
1786 | .FN ~/.inputrc
|
---|
1787 | (see
|
---|
1788 | .SM
|
---|
1789 | .B READLINE
|
---|
1790 | below).
|
---|
1791 | .TP
|
---|
1792 | .B LANG
|
---|
1793 | Used to determine the locale category for any category not specifically
|
---|
1794 | selected with a variable starting with \fBLC_\fP.
|
---|
1795 | .TP
|
---|
1796 | .B LC_ALL
|
---|
1797 | This variable overrides the value of \fBLANG\fP and any other
|
---|
1798 | \fBLC_\fP variable specifying a locale category.
|
---|
1799 | .TP
|
---|
1800 | .B LC_COLLATE
|
---|
1801 | This variable determines the collation order used when sorting the
|
---|
1802 | results of pathname expansion, and determines the behavior of range
|
---|
1803 | expressions, equivalence classes, and collating sequences within
|
---|
1804 | pathname expansion and pattern matching.
|
---|
1805 | .TP
|
---|
1806 | .B LC_CTYPE
|
---|
1807 | This variable determines the interpretation of characters and the
|
---|
1808 | behavior of character classes within pathname expansion and pattern
|
---|
1809 | matching.
|
---|
1810 | .TP
|
---|
1811 | .B LC_MESSAGES
|
---|
1812 | This variable determines the locale used to translate double-quoted
|
---|
1813 | strings preceded by a \fB$\fP.
|
---|
1814 | .TP
|
---|
1815 | .B LC_NUMERIC
|
---|
1816 | This variable determines the locale category used for number formatting.
|
---|
1817 | .TP
|
---|
1818 | .B LINES
|
---|
1819 | Used by the \fBselect\fP builtin command to determine the column length
|
---|
1820 | for printing selection lists. Automatically set upon receipt of a SIGWINCH.
|
---|
1821 | .TP
|
---|
1822 | .B MAIL
|
---|
1823 | If this parameter is set to a file name and the
|
---|
1824 | .SM
|
---|
1825 | .B MAILPATH
|
---|
1826 | variable is not set,
|
---|
1827 | .B bash
|
---|
1828 | informs the user of the arrival of mail in the specified file.
|
---|
1829 | .TP
|
---|
1830 | .B MAILCHECK
|
---|
1831 | Specifies how
|
---|
1832 | often (in seconds)
|
---|
1833 | .B bash
|
---|
1834 | checks for mail. The default is 60 seconds. When it is time to check
|
---|
1835 | for mail, the shell does so before displaying the primary prompt.
|
---|
1836 | If this variable is unset, or set to a value that is not a number
|
---|
1837 | greater than or equal to zero, the shell disables mail checking.
|
---|
1838 | .TP
|
---|
1839 | .B MAILPATH
|
---|
1840 | A colon-separated list of file names to be checked for mail.
|
---|
1841 | The message to be printed when mail arrives in a particular file
|
---|
1842 | may be specified by separating the file name from the message with a `?'.
|
---|
1843 | When used in the text of the message, \fB$_\fP expands to the name of
|
---|
1844 | the current mailfile.
|
---|
1845 | Example:
|
---|
1846 | .RS
|
---|
1847 | .PP
|
---|
1848 | \fBMAILPATH\fP='/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"'
|
---|
1849 | .PP
|
---|
1850 | .B Bash
|
---|
1851 | supplies a default value for this variable, but the location of the user
|
---|
1852 | mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP).
|
---|
1853 | .RE
|
---|
1854 | .TP
|
---|
1855 | .B OPTERR
|
---|
1856 | If set to the value 1,
|
---|
1857 | .B bash
|
---|
1858 | displays error messages generated by the
|
---|
1859 | .B getopts
|
---|
1860 | builtin command (see
|
---|
1861 | .SM
|
---|
1862 | .B SHELL BUILTIN COMMANDS
|
---|
1863 | below).
|
---|
1864 | .SM
|
---|
1865 | .B OPTERR
|
---|
1866 | is initialized to 1 each time the shell is invoked or a shell
|
---|
1867 | script is executed.
|
---|
1868 | .TP
|
---|
1869 | .B PATH
|
---|
1870 | The search path for commands. It
|
---|
1871 | is a colon-separated list of directories in which
|
---|
1872 | the shell looks for commands (see
|
---|
1873 | .SM
|
---|
1874 | .B COMMAND EXECUTION
|
---|
1875 | below).
|
---|
1876 | A zero-length (null) directory name in the value of \fBPATH\fP indicates the
|
---|
1877 | current directory.
|
---|
1878 | A null directory name may appear as two adjacent colons, or as an initial
|
---|
1879 | or trailing colon.
|
---|
1880 | The default path is system-dependent,
|
---|
1881 | and is set by the administrator who installs
|
---|
1882 | .BR bash .
|
---|
1883 | A common value is
|
---|
1884 | .if t \f(CW/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin\fP.
|
---|
1885 | .if n ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''.
|
---|
1886 | .TP
|
---|
1887 | .B POSIXLY_CORRECT
|
---|
1888 | If this variable is in the environment when \fBbash\fP starts, the shell
|
---|
1889 | enters \fIposix mode\fP before reading the startup files, as if the
|
---|
1890 | .B \-\-posix
|
---|
1891 | invocation option had been supplied. If it is set while the shell is
|
---|
1892 | running, \fBbash\fP enables \fIposix mode\fP, as if the command
|
---|
1893 | .if t \f(CWset -o posix\fP
|
---|
1894 | .if n \fIset -o posix\fP
|
---|
1895 | had been executed.
|
---|
1896 | .TP
|
---|
1897 | .B PROMPT_COMMAND
|
---|
1898 | If set, the value is executed as a command prior to issuing each primary
|
---|
1899 | prompt.
|
---|
1900 | .TP
|
---|
1901 | .B PS1
|
---|
1902 | The value of this parameter is expanded (see
|
---|
1903 | .SM
|
---|
1904 | .B PROMPTING
|
---|
1905 | below) and used as the primary prompt string. The default value is
|
---|
1906 | ``\fB\es\-\ev\e$ \fP''.
|
---|
1907 | .TP
|
---|
1908 | .B PS2
|
---|
1909 | The value of this parameter is expanded as with
|
---|
1910 | .B PS1
|
---|
1911 | and used as the secondary prompt string. The default is
|
---|
1912 | ``\fB> \fP''.
|
---|
1913 | .TP
|
---|
1914 | .B PS3
|
---|
1915 | The value of this parameter is used as the prompt for the
|
---|
1916 | .B select
|
---|
1917 | command (see
|
---|
1918 | .SM
|
---|
1919 | .B SHELL GRAMMAR
|
---|
1920 | above).
|
---|
1921 | .TP
|
---|
1922 | .B PS4
|
---|
1923 | The value of this parameter is expanded as with
|
---|
1924 | .B PS1
|
---|
1925 | and the value is printed before each command
|
---|
1926 | .B bash
|
---|
1927 | displays during an execution trace. The first character of
|
---|
1928 | .SM
|
---|
1929 | .B PS4
|
---|
1930 | is replicated multiple times, as necessary, to indicate multiple
|
---|
1931 | levels of indirection. The default is ``\fB+ \fP''.
|
---|
1932 | .TP
|
---|
1933 | .B SHELL
|
---|
1934 | The full pathname to the shell is kept in this environment variable.
|
---|
1935 | If it is not set when the shell starts,
|
---|
1936 | .B bash
|
---|
1937 | assigns to it the full pathname of the current user's login shell.
|
---|
1938 | .TP
|
---|
1939 | .B TIMEFORMAT
|
---|
1940 | The value of this parameter is used as a format string specifying
|
---|
1941 | how the timing information for pipelines prefixed with the
|
---|
1942 | .B time
|
---|
1943 | reserved word should be displayed.
|
---|
1944 | The \fB%\fP character introduces an escape sequence that is
|
---|
1945 | expanded to a time value or other information.
|
---|
1946 | The escape sequences and their meanings are as follows; the
|
---|
1947 | braces denote optional portions.
|
---|
1948 | .sp .5
|
---|
1949 | .RS
|
---|
1950 | .PD 0
|
---|
1951 | .TP 10
|
---|
1952 | .B %%
|
---|
1953 | A literal \fB%\fP.
|
---|
1954 | .TP
|
---|
1955 | .B %[\fIp\fP][l]R
|
---|
1956 | The elapsed time in seconds.
|
---|
1957 | .TP
|
---|
1958 | .B %[\fIp\fP][l]U
|
---|
1959 | The number of CPU seconds spent in user mode.
|
---|
1960 | .TP
|
---|
1961 | .B %[\fIp\fP][l]S
|
---|
1962 | The number of CPU seconds spent in system mode.
|
---|
1963 | .TP
|
---|
1964 | .B %P
|
---|
1965 | The CPU percentage, computed as (%U + %S) / %R.
|
---|
1966 | .PD
|
---|
1967 | .RE
|
---|
1968 | .IP
|
---|
1969 | The optional \fIp\fP is a digit specifying the \fIprecision\fP,
|
---|
1970 | the number of fractional digits after a decimal point.
|
---|
1971 | A value of 0 causes no decimal point or fraction to be output.
|
---|
1972 | At most three places after the decimal point may be specified;
|
---|
1973 | values of \fIp\fP greater than 3 are changed to 3.
|
---|
1974 | If \fIp\fP is not specified, the value 3 is used.
|
---|
1975 | .IP
|
---|
1976 | The optional \fBl\fP specifies a longer format, including
|
---|
1977 | minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
|
---|
1978 | The value of \fIp\fP determines whether or not the fraction is
|
---|
1979 | included.
|
---|
1980 | .IP
|
---|
1981 | If this variable is not set, \fBbash\fP acts as if it had the
|
---|
1982 | value \fB$'\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS'\fP.
|
---|
1983 | If the value is null, no timing information is displayed.
|
---|
1984 | A trailing newline is added when the format string is displayed.
|
---|
1985 | .TP
|
---|
1986 | .B TMOUT
|
---|
1987 | If set to a value greater than zero, \fBTMOUT\fP is treated as the
|
---|
1988 | default timeout for the \fBread\fP builtin.
|
---|
1989 | The \fBselect\fP command terminates if input does not arrive
|
---|
1990 | after \fBTMOUT\fP seconds when input is coming from a terminal.
|
---|
1991 | In an interactive shell, the value is interpreted as the
|
---|
1992 | number of seconds to wait for input after issuing the primary prompt.
|
---|
1993 | .B Bash
|
---|
1994 | terminates after waiting for that number of seconds if input does
|
---|
1995 | not arrive.
|
---|
1996 | .TP
|
---|
1997 | .B TMPDIR
|
---|
1998 | If set, \fBBash\fP uses its value as the name of a directory in which
|
---|
1999 | \fBBash\fP creates temporary files for the shell's use.
|
---|
2000 | .TP
|
---|
2001 | .B auto_resume
|
---|
2002 | This variable controls how the shell interacts with the user and
|
---|
2003 | job control. If this variable is set, single word simple
|
---|
2004 | commands without redirections are treated as candidates for resumption
|
---|
2005 | of an existing stopped job. There is no ambiguity allowed; if there is
|
---|
2006 | more than one job beginning with the string typed, the job most recently
|
---|
2007 | accessed is selected. The
|
---|
2008 | .I name
|
---|
2009 | of a stopped job, in this context, is the command line used to
|
---|
2010 | start it.
|
---|
2011 | If set to the value
|
---|
2012 | .IR exact ,
|
---|
2013 | the string supplied must match the name of a stopped job exactly;
|
---|
2014 | if set to
|
---|
2015 | .IR substring ,
|
---|
2016 | the string supplied needs to match a substring of the name of a
|
---|
2017 | stopped job. The
|
---|
2018 | .I substring
|
---|
2019 | value provides functionality analogous to the
|
---|
2020 | .B %?
|
---|
2021 | job identifier (see
|
---|
2022 | .SM
|
---|
2023 | .B JOB CONTROL
|
---|
2024 | below). If set to any other value, the supplied string must
|
---|
2025 | be a prefix of a stopped job's name; this provides functionality
|
---|
2026 | analogous to the \fB%\fP\fIstring\fP job identifier.
|
---|
2027 | .TP
|
---|
2028 | .B histchars
|
---|
2029 | The two or three characters which control history expansion
|
---|
2030 | and tokenization (see
|
---|
2031 | .SM
|
---|
2032 | .B HISTORY EXPANSION
|
---|
2033 | below). The first character is the \fIhistory expansion\fP character,
|
---|
2034 | the character which signals the start of a history
|
---|
2035 | expansion, normally `\fB!\fP'.
|
---|
2036 | The second character is the \fIquick substitution\fP
|
---|
2037 | character, which is used as shorthand for re-running the previous
|
---|
2038 | command entered, substituting one string for another in the command.
|
---|
2039 | The default is `\fB^\fP'.
|
---|
2040 | The optional third character is the character
|
---|
2041 | which indicates that the remainder of the line is a comment when found
|
---|
2042 | as the first character of a word, normally `\fB#\fP'. The history
|
---|
2043 | comment character causes history substitution to be skipped for the
|
---|
2044 | remaining words on the line. It does not necessarily cause the shell
|
---|
2045 | parser to treat the rest of the line as a comment.
|
---|
2046 | .PD
|
---|
2047 | .SS Arrays
|
---|
2048 | .B Bash
|
---|
2049 | provides one-dimensional array variables. Any variable may be used as
|
---|
2050 | an array; the
|
---|
2051 | .B declare
|
---|
2052 | builtin will explicitly declare an array. There is no maximum
|
---|
2053 | limit on the size of an array, nor any requirement that members
|
---|
2054 | be indexed or assigned contiguously. Arrays are indexed using
|
---|
2055 | integers and are zero-based.
|
---|
2056 | .PP
|
---|
2057 | An array is created automatically if any variable is assigned to using
|
---|
2058 | the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
|
---|
2059 | .I subscript
|
---|
2060 | is treated as an arithmetic expression that must evaluate to a number
|
---|
2061 | greater than or equal to zero. To explicitly declare an array, use
|
---|
2062 | .B declare \-a \fIname\fP
|
---|
2063 | (see
|
---|
2064 | .SM
|
---|
2065 | .B SHELL BUILTIN COMMANDS
|
---|
2066 | below).
|
---|
2067 | .B declare \-a \fIname\fP[\fIsubscript\fP]
|
---|
2068 | is also accepted; the \fIsubscript\fP is ignored. Attributes may be
|
---|
2069 | specified for an array variable using the
|
---|
2070 | .B declare
|
---|
2071 | and
|
---|
2072 | .B readonly
|
---|
2073 | builtins. Each attribute applies to all members of an array.
|
---|
2074 | .PP
|
---|
2075 | Arrays are assigned to using compound assignments of the form
|
---|
2076 | \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
|
---|
2077 | \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
|
---|
2078 | \fIstring\fP is required. If
|
---|
2079 | the optional brackets and subscript are supplied, that index is assigned to;
|
---|
2080 | otherwise the index of the element assigned is the last index assigned
|
---|
2081 | to by the statement plus one. Indexing starts at zero.
|
---|
2082 | This syntax is also accepted by the
|
---|
2083 | .B declare
|
---|
2084 | builtin. Individual array elements may be assigned to using the
|
---|
2085 | \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
|
---|
2086 | .PP
|
---|
2087 | Any element of an array may be referenced using
|
---|
2088 | ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
|
---|
2089 | conflicts with pathname expansion. If
|
---|
2090 | \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
|
---|
2091 | all members of \fIname\fP. These subscripts differ only when the
|
---|
2092 | word appears within double quotes. If the word is double-quoted,
|
---|
2093 | ${\fIname\fP[*]} expands to a single
|
---|
2094 | word with the value of each array member separated by the first
|
---|
2095 | character of the
|
---|
2096 | .SM
|
---|
2097 | .B IFS
|
---|
2098 | special variable, and ${\fIname\fP[@]} expands each element of
|
---|
2099 | \fIname\fP to a separate word. When there are no array members,
|
---|
2100 | ${\fIname\fP[@]} expands to nothing.
|
---|
2101 | If the double-quoted expansion occurs within a word, the expansion of
|
---|
2102 | the first parameter is joined with the beginning part of the original
|
---|
2103 | word, and the expansion of the last parameter is joined with the last
|
---|
2104 | part of the original word.
|
---|
2105 | This is analogous to the expansion
|
---|
2106 | of the special parameters \fB*\fP and \fB@\fP (see
|
---|
2107 | .B Special Parameters
|
---|
2108 | above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
|
---|
2109 | ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
|
---|
2110 | \fB@\fP, the expansion is the number of elements in the array.
|
---|
2111 | Referencing an array variable without a subscript is equivalent to
|
---|
2112 | referencing element zero.
|
---|
2113 | .PP
|
---|
2114 | The
|
---|
2115 | .B unset
|
---|
2116 | builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
|
---|
2117 | destroys the array element at index \fIsubscript\fP.
|
---|
2118 | Care must be taken to avoid unwanted side effects caused by filename
|
---|
2119 | generation.
|
---|
2120 | \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
|
---|
2121 | \fBunset\fP \fIname\fP[\fIsubscript\fP], where
|
---|
2122 | \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
|
---|
2123 | .PP
|
---|
2124 | The
|
---|
2125 | .BR declare ,
|
---|
2126 | .BR local ,
|
---|
2127 | and
|
---|
2128 | .B readonly
|
---|
2129 | builtins each accept a
|
---|
2130 | .B \-a
|
---|
2131 | option to specify an array. The
|
---|
2132 | .B read
|
---|
2133 | builtin accepts a
|
---|
2134 | .B \-a
|
---|
2135 | option to assign a list of words read from the standard input
|
---|
2136 | to an array. The
|
---|
2137 | .B set
|
---|
2138 | and
|
---|
2139 | .B declare
|
---|
2140 | builtins display array values in a way that allows them to be
|
---|
2141 | reused as assignments.
|
---|
2142 | .SH EXPANSION
|
---|
2143 | Expansion is performed on the command line after it has been split into
|
---|
2144 | words. There are seven kinds of expansion performed:
|
---|
2145 | .IR "brace expansion" ,
|
---|
2146 | .IR "tilde expansion" ,
|
---|
2147 | .IR "parameter and variable expansion" ,
|
---|
2148 | .IR "command substitution" ,
|
---|
2149 | .IR "arithmetic expansion" ,
|
---|
2150 | .IR "word splitting" ,
|
---|
2151 | and
|
---|
2152 | .IR "pathname expansion" .
|
---|
2153 | .PP
|
---|
2154 | The order of expansions is: brace expansion, tilde expansion,
|
---|
2155 | parameter, variable and arithmetic expansion and
|
---|
2156 | command substitution
|
---|
2157 | (done in a left-to-right fashion), word splitting, and pathname
|
---|
2158 | expansion.
|
---|
2159 | .PP
|
---|
2160 | On systems that can support it, there is an additional expansion
|
---|
2161 | available: \fIprocess substitution\fP.
|
---|
2162 | .PP
|
---|
2163 | Only brace expansion, word splitting, and pathname expansion
|
---|
2164 | can change the number of words of the expansion; other expansions
|
---|
2165 | expand a single word to a single word.
|
---|
2166 | The only exceptions to this are the expansions of
|
---|
2167 | "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP"
|
---|
2168 | as explained above (see
|
---|
2169 | .SM
|
---|
2170 | .BR PARAMETERS ).
|
---|
2171 | .SS Brace Expansion
|
---|
2172 | .PP
|
---|
2173 | .I "Brace expansion"
|
---|
2174 | is a mechanism by which arbitrary strings
|
---|
2175 | may be generated. This mechanism is similar to
|
---|
2176 | \fIpathname expansion\fP, but the filenames generated
|
---|
2177 | need not exist. Patterns to be brace expanded take
|
---|
2178 | the form of an optional
|
---|
2179 | .IR preamble ,
|
---|
2180 | followed by either a series of comma-separated strings or
|
---|
2181 | a sequence expression between a pair of braces, followed by
|
---|
2182 | an optional
|
---|
2183 | .IR postscript .
|
---|
2184 | The preamble is prefixed to each string contained
|
---|
2185 | within the braces, and the postscript is then appended
|
---|
2186 | to each resulting string, expanding left to right.
|
---|
2187 | .PP
|
---|
2188 | Brace expansions may be nested. The results of each expanded
|
---|
2189 | string are not sorted; left to right order is preserved.
|
---|
2190 | For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
|
---|
2191 | .PP
|
---|
2192 | A sequence expression takes the form \fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB}\fP,
|
---|
2193 | where \fIx\fP and \fIy\fP are either integers or single characters.
|
---|
2194 | When integers are supplied, the expression expands to each number between
|
---|
2195 | \fIx\fP and \fIy\fP, inclusive.
|
---|
2196 | When characters are supplied, the expression expands to each character
|
---|
2197 | lexicographically between \fIx\fP and \fIy\fP, inclusive. Note that
|
---|
2198 | both \fIx\fP and \fIy\fP must be of the same type.
|
---|
2199 | .PP
|
---|
2200 | Brace expansion is performed before any other expansions,
|
---|
2201 | and any characters special to other expansions are preserved
|
---|
2202 | in the result. It is strictly textual.
|
---|
2203 | .B Bash
|
---|
2204 | does not apply any syntactic interpretation to the context of the
|
---|
2205 | expansion or the text between the braces.
|
---|
2206 | .PP
|
---|
2207 | A correctly-formed brace expansion must contain unquoted opening
|
---|
2208 | and closing braces, and at least one unquoted comma or a valid
|
---|
2209 | sequence expression.
|
---|
2210 | Any incorrectly formed brace expansion is left unchanged.
|
---|
2211 | A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
|
---|
2212 | being considered part of a brace expression.
|
---|
2213 | To avoid conflicts with parameter expansion, the string \fB${\fP
|
---|
2214 | is not considered eligible for brace expansion.
|
---|
2215 | .PP
|
---|
2216 | This construct is typically used as shorthand when the common
|
---|
2217 | prefix of the strings to be generated is longer than in the
|
---|
2218 | above example:
|
---|
2219 | .RS
|
---|
2220 | .PP
|
---|
2221 | mkdir /usr/local/src/bash/{old,new,dist,bugs}
|
---|
2222 | .RE
|
---|
2223 | or
|
---|
2224 | .RS
|
---|
2225 | chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
|
---|
2226 | .RE
|
---|
2227 | .PP
|
---|
2228 | Brace expansion introduces a slight incompatibility with
|
---|
2229 | historical versions of
|
---|
2230 | .BR sh .
|
---|
2231 | .B sh
|
---|
2232 | does not treat opening or closing braces specially when they
|
---|
2233 | appear as part of a word, and preserves them in the output.
|
---|
2234 | .B Bash
|
---|
2235 | removes braces from words as a consequence of brace
|
---|
2236 | expansion. For example, a word entered to
|
---|
2237 | .B sh
|
---|
2238 | as \fIfile{1,2}\fP
|
---|
2239 | appears identically in the output. The same word is
|
---|
2240 | output as
|
---|
2241 | .I file1 file2
|
---|
2242 | after expansion by
|
---|
2243 | .BR bash .
|
---|
2244 | If strict compatibility with
|
---|
2245 | .B sh
|
---|
2246 | is desired, start
|
---|
2247 | .B bash
|
---|
2248 | with the
|
---|
2249 | .B +B
|
---|
2250 | option or disable brace expansion with the
|
---|
2251 | .B +B
|
---|
2252 | option to the
|
---|
2253 | .B set
|
---|
2254 | command (see
|
---|
2255 | .SM
|
---|
2256 | .B SHELL BUILTIN COMMANDS
|
---|
2257 | below).
|
---|
2258 | .SS Tilde Expansion
|
---|
2259 | .PP
|
---|
2260 | If a word begins with an unquoted tilde character (`\fB~\fP'), all of
|
---|
2261 | the characters preceding the first unquoted slash (or all characters,
|
---|
2262 | if there is no unquoted slash) are considered a \fItilde-prefix\fP.
|
---|
2263 | If none of the characters in the tilde-prefix are quoted, the
|
---|
2264 | characters in the tilde-prefix following the tilde are treated as a
|
---|
2265 | possible \fIlogin name\fP.
|
---|
2266 | If this login name is the null string, the tilde is replaced with the
|
---|
2267 | value of the shell parameter
|
---|
2268 | .SM
|
---|
2269 | .BR HOME .
|
---|
2270 | If
|
---|
2271 | .SM
|
---|
2272 | .B HOME
|
---|
2273 | is unset, the home directory of the user executing the shell is
|
---|
2274 | substituted instead.
|
---|
2275 | Otherwise, the tilde-prefix is replaced with the home directory
|
---|
2276 | associated with the specified login name.
|
---|
2277 | .PP
|
---|
2278 | If the tilde-prefix is a `~+', the value of the shell variable
|
---|
2279 | .SM
|
---|
2280 | .B PWD
|
---|
2281 | replaces the tilde-prefix.
|
---|
2282 | If the tilde-prefix is a `~\-', the value of the shell variable
|
---|
2283 | .SM
|
---|
2284 | .BR OLDPWD ,
|
---|
2285 | if it is set, is substituted.
|
---|
2286 | If the characters following the tilde in the tilde-prefix consist
|
---|
2287 | of a number \fIN\fP, optionally prefixed
|
---|
2288 | by a `+' or a `\-', the tilde-prefix is replaced with the corresponding
|
---|
2289 | element from the directory stack, as it would be displayed by the
|
---|
2290 | .B dirs
|
---|
2291 | builtin invoked with the tilde-prefix as an argument.
|
---|
2292 | If the characters following the tilde in the tilde-prefix consist of a
|
---|
2293 | number without a leading `+' or `\-', `+' is assumed.
|
---|
2294 | .PP
|
---|
2295 | If the login name is invalid, or the tilde expansion fails, the word
|
---|
2296 | is unchanged.
|
---|
2297 | .PP
|
---|
2298 | Each variable assignment is checked for unquoted tilde-prefixes immediately
|
---|
2299 | following a
|
---|
2300 | .B :
|
---|
2301 | or the first
|
---|
2302 | .BR = .
|
---|
2303 | In these cases, tilde expansion is also performed.
|
---|
2304 | Consequently, one may use file names with tildes in assignments to
|
---|
2305 | .SM
|
---|
2306 | .BR PATH ,
|
---|
2307 | .SM
|
---|
2308 | .BR MAILPATH ,
|
---|
2309 | and
|
---|
2310 | .SM
|
---|
2311 | .BR CDPATH ,
|
---|
2312 | and the shell assigns the expanded value.
|
---|
2313 | .SS Parameter Expansion
|
---|
2314 | .PP
|
---|
2315 | The `\fB$\fP' character introduces parameter expansion,
|
---|
2316 | command substitution, or arithmetic expansion. The parameter name
|
---|
2317 | or symbol to be expanded may be enclosed in braces, which
|
---|
2318 | are optional but serve to protect the variable to be expanded from
|
---|
2319 | characters immediately following it which could be
|
---|
2320 | interpreted as part of the name.
|
---|
2321 | .PP
|
---|
2322 | When braces are used, the matching ending brace is the first `\fB}\fP'
|
---|
2323 | not escaped by a backslash or within a quoted string, and not within an
|
---|
2324 | embedded arithmetic expansion, command substitution, or parameter
|
---|
2325 | expansion.
|
---|
2326 | .PP
|
---|
2327 | .PD 0
|
---|
2328 | .TP
|
---|
2329 | ${\fIparameter\fP}
|
---|
2330 | The value of \fIparameter\fP is substituted. The braces are required
|
---|
2331 | when
|
---|
2332 | .I parameter
|
---|
2333 | is a positional parameter with more than one digit,
|
---|
2334 | or when
|
---|
2335 | .I parameter
|
---|
2336 | is followed by a character which is not to be
|
---|
2337 | interpreted as part of its name.
|
---|
2338 | .PD
|
---|
2339 | .PP
|
---|
2340 | If the first character of \fIparameter\fP is an exclamation point,
|
---|
2341 | a level of variable indirection is introduced.
|
---|
2342 | \fBBash\fP uses the value of the variable formed from the rest of
|
---|
2343 | \fIparameter\fP as the name of the variable; this variable is then
|
---|
2344 | expanded and that value is used in the rest of the substitution, rather
|
---|
2345 | than the value of \fIparameter\fP itself.
|
---|
2346 | This is known as \fIindirect expansion\fP.
|
---|
2347 | The exceptions to this are the expansions of ${!\fIprefix\fP*} and
|
---|
2348 | ${\fB!\fP\fIname\fP[\fI@\fP]} described below.
|
---|
2349 | The exclamation point must immediately follow the left brace in order to
|
---|
2350 | introduce indirection.
|
---|
2351 | .PP
|
---|
2352 | In each of the cases below, \fIword\fP is subject to tilde expansion,
|
---|
2353 | parameter expansion, command substitution, and arithmetic expansion.
|
---|
2354 | When not performing substring expansion, \fBbash\fP tests for a parameter
|
---|
2355 | that is unset or null; omitting the colon results in a test only for a
|
---|
2356 | parameter that is unset.
|
---|
2357 | .PP
|
---|
2358 | .PD 0
|
---|
2359 | .TP
|
---|
2360 | ${\fIparameter\fP\fB:\-\fP\fIword\fP}
|
---|
2361 | \fBUse Default Values\fP. If
|
---|
2362 | .I parameter
|
---|
2363 | is unset or null, the expansion of
|
---|
2364 | .I word
|
---|
2365 | is substituted. Otherwise, the value of
|
---|
2366 | .I parameter
|
---|
2367 | is substituted.
|
---|
2368 | .TP
|
---|
2369 | ${\fIparameter\fP\fB:=\fP\fIword\fP}
|
---|
2370 | \fBAssign Default Values\fP.
|
---|
2371 | If
|
---|
2372 | .I parameter
|
---|
2373 | is unset or null, the expansion of
|
---|
2374 | .I word
|
---|
2375 | is assigned to
|
---|
2376 | .IR parameter .
|
---|
2377 | The value of
|
---|
2378 | .I parameter
|
---|
2379 | is then substituted. Positional parameters and special parameters may
|
---|
2380 | not be assigned to in this way.
|
---|
2381 | .TP
|
---|
2382 | ${\fIparameter\fP\fB:?\fP\fIword\fP}
|
---|
2383 | \fBDisplay Error if Null or Unset\fP.
|
---|
2384 | If
|
---|
2385 | .I parameter
|
---|
2386 | is null or unset, the expansion of \fIword\fP (or a message to that effect
|
---|
2387 | if
|
---|
2388 | .I word
|
---|
2389 | is not present) is written to the standard error and the shell, if it
|
---|
2390 | is not interactive, exits. Otherwise, the value of \fIparameter\fP is
|
---|
2391 | substituted.
|
---|
2392 | .TP
|
---|
2393 | ${\fIparameter\fP\fB:+\fP\fIword\fP}
|
---|
2394 | \fBUse Alternate Value\fP.
|
---|
2395 | If
|
---|
2396 | .I parameter
|
---|
2397 | is null or unset, nothing is substituted, otherwise the expansion of
|
---|
2398 | .I word
|
---|
2399 | is substituted.
|
---|
2400 | .TP
|
---|
2401 | ${\fIparameter\fP\fB:\fP\fIoffset\fP}
|
---|
2402 | .PD 0
|
---|
2403 | .TP
|
---|
2404 | ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
|
---|
2405 | .PD
|
---|
2406 | \fBSubstring Expansion.\fP
|
---|
2407 | Expands to up to \fIlength\fP characters of \fIparameter\fP
|
---|
2408 | starting at the character specified by \fIoffset\fP.
|
---|
2409 | If \fIlength\fP is omitted, expands to the substring of
|
---|
2410 | \fIparameter\fP starting at the character specified by \fIoffset\fP.
|
---|
2411 | \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
|
---|
2412 | .SM
|
---|
2413 | .B
|
---|
2414 | ARITHMETIC EVALUATION
|
---|
2415 | below).
|
---|
2416 | \fIlength\fP must evaluate to a number greater than or equal to zero.
|
---|
2417 | If \fIoffset\fP evaluates to a number less than zero, the value
|
---|
2418 | is used as an offset from the end of the value of \fIparameter\fP.
|
---|
2419 | If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
|
---|
2420 | parameters beginning at \fIoffset\fP.
|
---|
2421 | If \fIparameter\fP is an array name indexed by @ or *,
|
---|
2422 | the result is the \fIlength\fP
|
---|
2423 | members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
|
---|
2424 | A negative \fIoffset\fP is taken relative to one greater than the maximum
|
---|
2425 | index of the specified array.
|
---|
2426 | Note that a negative offset must be separated from the colon by at least
|
---|
2427 | one space to avoid being confused with the :- expansion.
|
---|
2428 | Substring indexing is zero-based unless the positional parameters
|
---|
2429 | are used, in which case the indexing starts at 1.
|
---|
2430 | .TP
|
---|
2431 | ${\fB!\fP\fIprefix\fP\fB*\fP}
|
---|
2432 | .PD 0
|
---|
2433 | .TP
|
---|
2434 | ${\fB!\fP\fIprefix\fP\fB@\fP}
|
---|
2435 | .PD
|
---|
2436 | Expands to the names of variables whose names begin with \fIprefix\fP,
|
---|
2437 | separated by the first character of the
|
---|
2438 | .SM
|
---|
2439 | .B IFS
|
---|
2440 | special variable.
|
---|
2441 | .TP
|
---|
2442 | ${\fB!\fP\fIname\fP[\fI@\fP]}
|
---|
2443 | .PD 0
|
---|
2444 | .TP
|
---|
2445 | ${\fB!\fP\fIname\fP[\fI*\fP]}
|
---|
2446 | .PD
|
---|
2447 | If \fIname\fP is an array variable, expands to the list of array indices
|
---|
2448 | (keys) assigned in \fIname\fP.
|
---|
2449 | If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null
|
---|
2450 | otherwise.
|
---|
2451 | When \fI@\fP is used and the expansion appears within double quotes, each
|
---|
2452 | key expands to a separate word.
|
---|
2453 | .TP
|
---|
2454 | ${\fB#\fP\fIparameter\fP}
|
---|
2455 | The length in characters of the value of \fIparameter\fP is substituted.
|
---|
2456 | If
|
---|
2457 | .I parameter
|
---|
2458 | is
|
---|
2459 | .B *
|
---|
2460 | or
|
---|
2461 | .BR @ ,
|
---|
2462 | the value substituted is the number of positional parameters.
|
---|
2463 | If
|
---|
2464 | .I parameter
|
---|
2465 | is an array name subscripted by
|
---|
2466 | .B *
|
---|
2467 | or
|
---|
2468 | .BR @ ,
|
---|
2469 | the value substituted is the number of elements in the array.
|
---|
2470 | .TP
|
---|
2471 | ${\fIparameter\fP\fB#\fP\fIword\fP}
|
---|
2472 | .PD 0
|
---|
2473 | .TP
|
---|
2474 | ${\fIparameter\fP\fB##\fP\fIword\fP}
|
---|
2475 | .PD
|
---|
2476 | The
|
---|
2477 | .I word
|
---|
2478 | is expanded to produce a pattern just as in pathname
|
---|
2479 | expansion. If the pattern matches the beginning of
|
---|
2480 | the value of
|
---|
2481 | .IR parameter ,
|
---|
2482 | then the result of the expansion is the expanded value of
|
---|
2483 | .I parameter
|
---|
2484 | with the shortest matching pattern (the ``\fB#\fP'' case) or the
|
---|
2485 | longest matching pattern (the ``\fB##\fP'' case) deleted.
|
---|
2486 | If
|
---|
2487 | .I parameter
|
---|
2488 | is
|
---|
2489 | .B @
|
---|
2490 | or
|
---|
2491 | .BR * ,
|
---|
2492 | the pattern removal operation is applied to each positional
|
---|
2493 | parameter in turn, and the expansion is the resultant list.
|
---|
2494 | If
|
---|
2495 | .I parameter
|
---|
2496 | is an array variable subscripted with
|
---|
2497 | .B @
|
---|
2498 | or
|
---|
2499 | .BR * ,
|
---|
2500 | the pattern removal operation is applied to each member of the
|
---|
2501 | array in turn, and the expansion is the resultant list.
|
---|
2502 | .TP
|
---|
2503 | ${\fIparameter\fP\fB%\fP\fIword\fP}
|
---|
2504 | .PD 0
|
---|
2505 | .TP
|
---|
2506 | ${\fIparameter\fP\fB%%\fP\fIword\fP}
|
---|
2507 | .PD
|
---|
2508 | The \fIword\fP is expanded to produce a pattern just as in
|
---|
2509 | pathname expansion.
|
---|
2510 | If the pattern matches a trailing portion of the expanded value of
|
---|
2511 | .IR parameter ,
|
---|
2512 | then the result of the expansion is the expanded value of
|
---|
2513 | .I parameter
|
---|
2514 | with the shortest matching pattern (the ``\fB%\fP'' case) or the
|
---|
2515 | longest matching pattern (the ``\fB%%\fP'' case) deleted.
|
---|
2516 | If
|
---|
2517 | .I parameter
|
---|
2518 | is
|
---|
2519 | .B @
|
---|
2520 | or
|
---|
2521 | .BR * ,
|
---|
2522 | the pattern removal operation is applied to each positional
|
---|
2523 | parameter in turn, and the expansion is the resultant list.
|
---|
2524 | If
|
---|
2525 | .I parameter
|
---|
2526 | is an array variable subscripted with
|
---|
2527 | .B @
|
---|
2528 | or
|
---|
2529 | .BR * ,
|
---|
2530 | the pattern removal operation is applied to each member of the
|
---|
2531 | array in turn, and the expansion is the resultant list.
|
---|
2532 | .TP
|
---|
2533 | ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
|
---|
2534 | .PD 0
|
---|
2535 | .TP
|
---|
2536 | ${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
|
---|
2537 | .PD
|
---|
2538 | The \fIpattern\fP is expanded to produce a pattern just as in
|
---|
2539 | pathname expansion.
|
---|
2540 | \fIParameter\fP is expanded and the longest match of \fIpattern\fP
|
---|
2541 | against its value is replaced with \fIstring\fP.
|
---|
2542 | In the first form, only the first match is replaced.
|
---|
2543 | The second form causes all matches of \fIpattern\fP to be
|
---|
2544 | replaced with \fIstring\fP.
|
---|
2545 | If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
|
---|
2546 | of the expanded value of \fIparameter\fP.
|
---|
2547 | If \fIpattern\fP begins with \fB%\fP, it must match at the end
|
---|
2548 | of the expanded value of \fIparameter\fP.
|
---|
2549 | If \fIstring\fP is null, matches of \fIpattern\fP are deleted
|
---|
2550 | and the \fB/\fP following \fIpattern\fP may be omitted.
|
---|
2551 | If
|
---|
2552 | .I parameter
|
---|
2553 | is
|
---|
2554 | .B @
|
---|
2555 | or
|
---|
2556 | .BR * ,
|
---|
2557 | the substitution operation is applied to each positional
|
---|
2558 | parameter in turn, and the expansion is the resultant list.
|
---|
2559 | If
|
---|
2560 | .I parameter
|
---|
2561 | is an array variable subscripted with
|
---|
2562 | .B @
|
---|
2563 | or
|
---|
2564 | .BR * ,
|
---|
2565 | the substitution operation is applied to each member of the
|
---|
2566 | array in turn, and the expansion is the resultant list.
|
---|
2567 | .SS Command Substitution
|
---|
2568 | .PP
|
---|
2569 | \fICommand substitution\fP allows the output of a command to replace
|
---|
2570 | the command name. There are two forms:
|
---|
2571 | .PP
|
---|
2572 | .RS
|
---|
2573 | .PP
|
---|
2574 | \fB$(\fP\fIcommand\fP\|\fB)\fP
|
---|
2575 | .RE
|
---|
2576 | or
|
---|
2577 | .RS
|
---|
2578 | \fB`\fP\fIcommand\fP\fB`\fP
|
---|
2579 | .RE
|
---|
2580 | .PP
|
---|
2581 | .B Bash
|
---|
2582 | performs the expansion by executing \fIcommand\fP and
|
---|
2583 | replacing the command substitution with the standard output of the
|
---|
2584 | command, with any trailing newlines deleted.
|
---|
2585 | Embedded newlines are not deleted, but they may be removed during
|
---|
2586 | word splitting.
|
---|
2587 | The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by
|
---|
2588 | the equivalent but faster \fB$(< \fIfile\fP)\fR.
|
---|
2589 | .PP
|
---|
2590 | When the old-style backquote form of substitution is used,
|
---|
2591 | backslash retains its literal meaning except when followed by
|
---|
2592 | .BR $ ,
|
---|
2593 | .BR ` ,
|
---|
2594 | or
|
---|
2595 | .BR \e .
|
---|
2596 | The first backquote not preceded by a backslash terminates the
|
---|
2597 | command substitution.
|
---|
2598 | When using the $(\^\fIcommand\fP\|) form, all characters between the
|
---|
2599 | parentheses make up the command; none are treated specially.
|
---|
2600 | .PP
|
---|
2601 | Command substitutions may be nested. To nest when using the backquoted form,
|
---|
2602 | escape the inner backquotes with backslashes.
|
---|
2603 | .PP
|
---|
2604 | If the substitution appears within double quotes, word splitting and
|
---|
2605 | pathname expansion are not performed on the results.
|
---|
2606 | .SS Arithmetic Expansion
|
---|
2607 | .PP
|
---|
2608 | Arithmetic expansion allows the evaluation of an arithmetic expression
|
---|
2609 | and the substitution of the result. The format for arithmetic expansion is:
|
---|
2610 | .RS
|
---|
2611 | .PP
|
---|
2612 | \fB$((\fP\fIexpression\fP\fB))\fP
|
---|
2613 | .RE
|
---|
2614 | .PP
|
---|
2615 | The
|
---|
2616 | .I expression
|
---|
2617 | is treated as if it were within double quotes, but a double quote
|
---|
2618 | inside the parentheses is not treated specially.
|
---|
2619 | All tokens in the expression undergo parameter expansion, string
|
---|
2620 | expansion, command substitution, and quote removal.
|
---|
2621 | Arithmetic expansions may be nested.
|
---|
2622 | .PP
|
---|
2623 | The evaluation is performed according to the rules listed below under
|
---|
2624 | .SM
|
---|
2625 | .BR "ARITHMETIC EVALUATION" .
|
---|
2626 | If
|
---|
2627 | .I expression
|
---|
2628 | is invalid,
|
---|
2629 | .B bash
|
---|
2630 | prints a message indicating failure and no substitution occurs.
|
---|
2631 | .SS Process Substitution
|
---|
2632 | .PP
|
---|
2633 | \fIProcess substitution\fP is supported on systems that support named
|
---|
2634 | pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
|
---|
2635 | It takes the form of
|
---|
2636 | \fB<(\fP\fIlist\^\fP\fB)\fP
|
---|
2637 | or
|
---|
2638 | \fB>(\fP\fIlist\^\fP\fB)\fP.
|
---|
2639 | The process \fIlist\fP is run with its input or output connected to a
|
---|
2640 | \fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is
|
---|
2641 | passed as an argument to the current command as the result of the
|
---|
2642 | expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
|
---|
2643 | the file will provide input for \fIlist\fP. If the
|
---|
2644 | \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
|
---|
2645 | argument should be read to obtain the output of \fIlist\fP.
|
---|
2646 | .PP
|
---|
2647 | When available, process substitution is performed
|
---|
2648 | simultaneously with parameter and variable expansion,
|
---|
2649 | command substitution,
|
---|
2650 | and arithmetic expansion.
|
---|
2651 | .SS Word Splitting
|
---|
2652 | .PP
|
---|
2653 | The shell scans the results of
|
---|
2654 | parameter expansion,
|
---|
2655 | command substitution,
|
---|
2656 | and
|
---|
2657 | arithmetic expansion
|
---|
2658 | that did not occur within double quotes for
|
---|
2659 | .IR "word splitting" .
|
---|
2660 | .PP
|
---|
2661 | The shell treats each character of
|
---|
2662 | .SM
|
---|
2663 | .B IFS
|
---|
2664 | as a delimiter, and splits the results of the other
|
---|
2665 | expansions into words on these characters. If
|
---|
2666 | .SM
|
---|
2667 | .B IFS
|
---|
2668 | is unset, or its
|
---|
2669 | value is exactly
|
---|
2670 | .BR <space><tab><newline> ,
|
---|
2671 | the default, then
|
---|
2672 | any sequence of
|
---|
2673 | .SM
|
---|
2674 | .B IFS
|
---|
2675 | characters serves to delimit words. If
|
---|
2676 | .SM
|
---|
2677 | .B IFS
|
---|
2678 | has a value other than the default, then sequences of
|
---|
2679 | the whitespace characters
|
---|
2680 | .B space
|
---|
2681 | and
|
---|
2682 | .B tab
|
---|
2683 | are ignored at the beginning and end of the
|
---|
2684 | word, as long as the whitespace character is in the
|
---|
2685 | value of
|
---|
2686 | .SM
|
---|
2687 | .BR IFS
|
---|
2688 | (an
|
---|
2689 | .SM
|
---|
2690 | .B IFS
|
---|
2691 | whitespace character).
|
---|
2692 | Any character in
|
---|
2693 | .SM
|
---|
2694 | .B IFS
|
---|
2695 | that is not
|
---|
2696 | .SM
|
---|
2697 | .B IFS
|
---|
2698 | whitespace, along with any adjacent
|
---|
2699 | .SM
|
---|
2700 | .B IFS
|
---|
2701 | whitespace characters, delimits a field.
|
---|
2702 | A sequence of
|
---|
2703 | .SM
|
---|
2704 | .B IFS
|
---|
2705 | whitespace characters is also treated as a delimiter.
|
---|
2706 | If the value of
|
---|
2707 | .SM
|
---|
2708 | .B IFS
|
---|
2709 | is null, no word splitting occurs.
|
---|
2710 | .PP
|
---|
2711 | Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained.
|
---|
2712 | Unquoted implicit null arguments, resulting from the expansion of
|
---|
2713 | parameters that have no values, are removed.
|
---|
2714 | If a parameter with no value is expanded within double quotes, a
|
---|
2715 | null argument results and is retained.
|
---|
2716 | .PP
|
---|
2717 | Note that if no expansion occurs, no splitting
|
---|
2718 | is performed.
|
---|
2719 | .SS Pathname Expansion
|
---|
2720 | .PP
|
---|
2721 | After word splitting,
|
---|
2722 | unless the
|
---|
2723 | .B \-f
|
---|
2724 | option has been set,
|
---|
2725 | .B bash
|
---|
2726 | scans each word for the characters
|
---|
2727 | .BR * ,
|
---|
2728 | .BR ? ,
|
---|
2729 | and
|
---|
2730 | .BR [ .
|
---|
2731 | If one of these characters appears, then the word is
|
---|
2732 | regarded as a
|
---|
2733 | .IR pattern ,
|
---|
2734 | and replaced with an alphabetically sorted list of
|
---|
2735 | file names matching the pattern.
|
---|
2736 | If no matching file names are found,
|
---|
2737 | and the shell option
|
---|
2738 | .B nullglob
|
---|
2739 | is disabled, the word is left unchanged.
|
---|
2740 | If the
|
---|
2741 | .B nullglob
|
---|
2742 | option is set, and no matches are found,
|
---|
2743 | the word is removed.
|
---|
2744 | If the
|
---|
2745 | .B failglob
|
---|
2746 | shell option is set, and no matches are found, an error message
|
---|
2747 | is printed and the command is not executed.
|
---|
2748 | If the shell option
|
---|
2749 | .B nocaseglob
|
---|
2750 | is enabled, the match is performed without regard to the case
|
---|
2751 | of alphabetic characters.
|
---|
2752 | When a pattern is used for pathname expansion,
|
---|
2753 | the character
|
---|
2754 | .B ``.''
|
---|
2755 | at the start of a name or immediately following a slash
|
---|
2756 | must be matched explicitly, unless the shell option
|
---|
2757 | .B dotglob
|
---|
2758 | is set.
|
---|
2759 | When matching a pathname, the slash character must always be
|
---|
2760 | matched explicitly.
|
---|
2761 | In other cases, the
|
---|
2762 | .B ``.''
|
---|
2763 | character is not treated specially.
|
---|
2764 | See the description of
|
---|
2765 | .B shopt
|
---|
2766 | below under
|
---|
2767 | .SM
|
---|
2768 | .B SHELL BUILTIN COMMANDS
|
---|
2769 | for a description of the
|
---|
2770 | .BR nocaseglob ,
|
---|
2771 | .BR nullglob ,
|
---|
2772 | .BR failglob ,
|
---|
2773 | and
|
---|
2774 | .B dotglob
|
---|
2775 | shell options.
|
---|
2776 | .PP
|
---|
2777 | The
|
---|
2778 | .SM
|
---|
2779 | .B GLOBIGNORE
|
---|
2780 | shell variable may be used to restrict the set of file names matching a
|
---|
2781 | .IR pattern .
|
---|
2782 | If
|
---|
2783 | .SM
|
---|
2784 | .B GLOBIGNORE
|
---|
2785 | is set, each matching file name that also matches one of the patterns in
|
---|
2786 | .SM
|
---|
2787 | .B GLOBIGNORE
|
---|
2788 | is removed from the list of matches.
|
---|
2789 | The file names
|
---|
2790 | .B ``.''
|
---|
2791 | and
|
---|
2792 | .B ``..''
|
---|
2793 | are always ignored when
|
---|
2794 | .SM
|
---|
2795 | .B GLOBIGNORE
|
---|
2796 | is set and not null. However, setting
|
---|
2797 | .SM
|
---|
2798 | .B GLOBIGNORE
|
---|
2799 | to a non-null value has the effect of enabling the
|
---|
2800 | .B dotglob
|
---|
2801 | shell option, so all other file names beginning with a
|
---|
2802 | .B ``.''
|
---|
2803 | will match.
|
---|
2804 | To get the old behavior of ignoring file names beginning with a
|
---|
2805 | .BR ``.'' ,
|
---|
2806 | make
|
---|
2807 | .B ``.*''
|
---|
2808 | one of the patterns in
|
---|
2809 | .SM
|
---|
2810 | .BR GLOBIGNORE .
|
---|
2811 | The
|
---|
2812 | .B dotglob
|
---|
2813 | option is disabled when
|
---|
2814 | .SM
|
---|
2815 | .B GLOBIGNORE
|
---|
2816 | is unset.
|
---|
2817 | .PP
|
---|
2818 | \fBPattern Matching\fP
|
---|
2819 | .PP
|
---|
2820 | Any character that appears in a pattern, other than the special pattern
|
---|
2821 | characters described below, matches itself. The NUL character may not
|
---|
2822 | occur in a pattern. A backslash escapes the following character; the
|
---|
2823 | escaping backslash is discarded when matching.
|
---|
2824 | The special pattern characters must be quoted if
|
---|
2825 | they are to be matched literally.
|
---|
2826 | .PP
|
---|
2827 | The special pattern characters have the following meanings:
|
---|
2828 | .PP
|
---|
2829 | .PD 0
|
---|
2830 | .TP
|
---|
2831 | .B *
|
---|
2832 | Matches any string, including the null string.
|
---|
2833 | .TP
|
---|
2834 | .B ?
|
---|
2835 | Matches any single character.
|
---|
2836 | .TP
|
---|
2837 | .B [...]
|
---|
2838 | Matches any one of the enclosed characters. A pair of characters
|
---|
2839 | separated by a hyphen denotes a
|
---|
2840 | \fIrange expression\fP;
|
---|
2841 | any character that sorts between those two characters, inclusive,
|
---|
2842 | using the current locale's collating sequence and character set,
|
---|
2843 | is matched. If the first character following the
|
---|
2844 | .B [
|
---|
2845 | is a
|
---|
2846 | .B !
|
---|
2847 | or a
|
---|
2848 | .B ^
|
---|
2849 | then any character not enclosed is matched.
|
---|
2850 | The sorting order of characters in range expressions is determined by
|
---|
2851 | the current locale and the value of the \fBLC_COLLATE\fP shell variable,
|
---|
2852 | if set.
|
---|
2853 | A
|
---|
2854 | .B \-
|
---|
2855 | may be matched by including it as the first or last character
|
---|
2856 | in the set.
|
---|
2857 | A
|
---|
2858 | .B ]
|
---|
2859 | may be matched by including it as the first character
|
---|
2860 | in the set.
|
---|
2861 | .br
|
---|
2862 | .if t .sp 0.5
|
---|
2863 | .if n .sp 1
|
---|
2864 | Within
|
---|
2865 | .B [
|
---|
2866 | and
|
---|
2867 | .BR ] ,
|
---|
2868 | \fIcharacter classes\fP can be specified using the syntax
|
---|
2869 | \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the
|
---|
2870 | following classes defined in the POSIX.2 standard:
|
---|
2871 | .PP
|
---|
2872 | .RS
|
---|
2873 | .B
|
---|
2874 | .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
|
---|
2875 | .if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
|
---|
2876 | .br
|
---|
2877 | A character class matches any character belonging to that class.
|
---|
2878 | The \fBword\fP character class matches letters, digits, and the character _.
|
---|
2879 | .br
|
---|
2880 | .if t .sp 0.5
|
---|
2881 | .if n .sp 1
|
---|
2882 | Within
|
---|
2883 | .B [
|
---|
2884 | and
|
---|
2885 | .BR ] ,
|
---|
2886 | an \fIequivalence class\fP can be specified using the syntax
|
---|
2887 | \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the
|
---|
2888 | same collation weight (as defined by the current locale) as
|
---|
2889 | the character \fIc\fP.
|
---|
2890 | .br
|
---|
2891 | .if t .sp 0.5
|
---|
2892 | .if n .sp 1
|
---|
2893 | Within
|
---|
2894 | .B [
|
---|
2895 | and
|
---|
2896 | .BR ] ,
|
---|
2897 | the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol
|
---|
2898 | \fIsymbol\fP.
|
---|
2899 | .RE
|
---|
2900 | .PD
|
---|
2901 | .PP
|
---|
2902 | If the \fBextglob\fP shell option is enabled using the \fBshopt\fP
|
---|
2903 | builtin, several extended pattern matching operators are recognized.
|
---|
2904 | In the following description, a \fIpattern-list\fP is a list of one
|
---|
2905 | or more patterns separated by a \fB|\fP.
|
---|
2906 | Composite patterns may be formed using one or more of the following
|
---|
2907 | sub-patterns:
|
---|
2908 | .sp 1
|
---|
2909 | .PD 0
|
---|
2910 | .RS
|
---|
2911 | .TP
|
---|
2912 | \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP
|
---|
2913 | Matches zero or one occurrence of the given patterns
|
---|
2914 | .TP
|
---|
2915 | \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP
|
---|
2916 | Matches zero or more occurrences of the given patterns
|
---|
2917 | .TP
|
---|
2918 | \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP
|
---|
2919 | Matches one or more occurrences of the given patterns
|
---|
2920 | .TP
|
---|
2921 | \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP
|
---|
2922 | Matches one of the given patterns
|
---|
2923 | .TP
|
---|
2924 | \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP
|
---|
2925 | Matches anything except one of the given patterns
|
---|
2926 | .RE
|
---|
2927 | .PD
|
---|
2928 | .SS Quote Removal
|
---|
2929 | .PP
|
---|
2930 | After the preceding expansions, all unquoted occurrences of the
|
---|
2931 | characters
|
---|
2932 | .BR \e ,
|
---|
2933 | .BR ' ,
|
---|
2934 | and \^\f3"\fP\^ that did not result from one of the above
|
---|
2935 | expansions are removed.
|
---|
2936 | .SH REDIRECTION
|
---|
2937 | Before a command is executed, its input and output
|
---|
2938 | may be
|
---|
2939 | .I redirected
|
---|
2940 | using a special notation interpreted by the shell.
|
---|
2941 | Redirection may also be used to open and close files for the
|
---|
2942 | current shell execution environment. The following redirection
|
---|
2943 | operators may precede or appear anywhere within a
|
---|
2944 | .I simple command
|
---|
2945 | or may follow a
|
---|
2946 | .IR command .
|
---|
2947 | Redirections are processed in the order they appear, from
|
---|
2948 | left to right.
|
---|
2949 | .PP
|
---|
2950 | In the following descriptions, if the file descriptor number is
|
---|
2951 | omitted, and the first character of the redirection operator is
|
---|
2952 | .BR < ,
|
---|
2953 | the redirection refers to the standard input (file descriptor
|
---|
2954 | 0). If the first character of the redirection operator is
|
---|
2955 | .BR > ,
|
---|
2956 | the redirection refers to the standard output (file descriptor
|
---|
2957 | 1).
|
---|
2958 | .PP
|
---|
2959 | The word following the redirection operator in the following
|
---|
2960 | descriptions, unless otherwise noted, is subjected to brace expansion,
|
---|
2961 | tilde expansion, parameter expansion, command substitution, arithmetic
|
---|
2962 | expansion, quote removal, pathname expansion, and word splitting.
|
---|
2963 | If it expands to more than one word,
|
---|
2964 | .B bash
|
---|
2965 | reports an error.
|
---|
2966 | .PP
|
---|
2967 | Note that the order of redirections is significant. For example,
|
---|
2968 | the command
|
---|
2969 | .RS
|
---|
2970 | .PP
|
---|
2971 | ls \fB>\fP dirlist 2\fB>&\fP1
|
---|
2972 | .RE
|
---|
2973 | .PP
|
---|
2974 | directs both standard output and standard error to the file
|
---|
2975 | .IR dirlist ,
|
---|
2976 | while the command
|
---|
2977 | .RS
|
---|
2978 | .PP
|
---|
2979 | ls 2\fB>&\fP1 \fB>\fP dirlist
|
---|
2980 | .RE
|
---|
2981 | .PP
|
---|
2982 | directs only the standard output to file
|
---|
2983 | .IR dirlist ,
|
---|
2984 | because the standard error was duplicated as standard output
|
---|
2985 | before the standard output was redirected to
|
---|
2986 | .IR dirlist .
|
---|
2987 | .PP
|
---|
2988 | \fBBash\fP handles several filenames specially when they are used in
|
---|
2989 | redirections, as described in the following table:
|
---|
2990 | .RS
|
---|
2991 | .PP
|
---|
2992 | .PD 0
|
---|
2993 | .TP
|
---|
2994 | .B /dev/fd/\fIfd\fP
|
---|
2995 | If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated.
|
---|
2996 | .TP
|
---|
2997 | .B /dev/stdin
|
---|
2998 | File descriptor 0 is duplicated.
|
---|
2999 | .TP
|
---|
3000 | .B /dev/stdout
|
---|
3001 | File descriptor 1 is duplicated.
|
---|
3002 | .TP
|
---|
3003 | .B /dev/stderr
|
---|
3004 | File descriptor 2 is duplicated.
|
---|
3005 | .TP
|
---|
3006 | .B /dev/tcp/\fIhost\fP/\fIport\fP
|
---|
3007 | If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
|
---|
3008 | is an integer port number or service name, \fBbash\fP attempts to open
|
---|
3009 | a TCP connection to the corresponding socket.
|
---|
3010 | .TP
|
---|
3011 | .B /dev/udp/\fIhost\fP/\fIport\fP
|
---|
3012 | If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
|
---|
3013 | is an integer port number or service name, \fBbash\fP attempts to open
|
---|
3014 | a UDP connection to the corresponding socket.
|
---|
3015 | .PD
|
---|
3016 | .RE
|
---|
3017 | .PP
|
---|
3018 | A failure to open or create a file causes the redirection to fail.
|
---|
3019 | .PP
|
---|
3020 | Redirections using file descriptors greater than 9 should be used with
|
---|
3021 | care, as they may conflict with file descriptors the shell uses
|
---|
3022 | internally.
|
---|
3023 | .SS Redirecting Input
|
---|
3024 | .PP
|
---|
3025 | Redirection of input causes the file whose name results from
|
---|
3026 | the expansion of
|
---|
3027 | .I word
|
---|
3028 | to be opened for reading on file descriptor
|
---|
3029 | .IR n ,
|
---|
3030 | or the standard input (file descriptor 0) if
|
---|
3031 | .I n
|
---|
3032 | is not specified.
|
---|
3033 | .PP
|
---|
3034 | The general format for redirecting input is:
|
---|
3035 | .RS
|
---|
3036 | .PP
|
---|
3037 | [\fIn\fP]\fB<\fP\fIword\fP
|
---|
3038 | .RE
|
---|
3039 | .SS Redirecting Output
|
---|
3040 | .PP
|
---|
3041 | Redirection of output causes the file whose name results from
|
---|
3042 | the expansion of
|
---|
3043 | .I word
|
---|
3044 | to be opened for writing on file descriptor
|
---|
3045 | .IR n ,
|
---|
3046 | or the standard output (file descriptor 1) if
|
---|
3047 | .I n
|
---|
3048 | is not specified. If the file does not exist it is created;
|
---|
3049 | if it does exist it is truncated to zero size.
|
---|
3050 | .PP
|
---|
3051 | The general format for redirecting output is:
|
---|
3052 | .RS
|
---|
3053 | .PP
|
---|
3054 | [\fIn\fP]\fB>\fP\fIword\fP
|
---|
3055 | .RE
|
---|
3056 | .PP
|
---|
3057 | If the redirection operator is
|
---|
3058 | .BR > ,
|
---|
3059 | and the
|
---|
3060 | .B noclobber
|
---|
3061 | option to the
|
---|
3062 | .B set
|
---|
3063 | builtin has been enabled, the redirection will fail if the file
|
---|
3064 | whose name results from the expansion of \fIword\fP exists and is
|
---|
3065 | a regular file.
|
---|
3066 | If the redirection operator is
|
---|
3067 | .BR >| ,
|
---|
3068 | or the redirection operator is
|
---|
3069 | .B >
|
---|
3070 | and the
|
---|
3071 | .B noclobber
|
---|
3072 | option to the
|
---|
3073 | .B set
|
---|
3074 | builtin command is not enabled, the redirection is attempted even
|
---|
3075 | if the file named by \fIword\fP exists.
|
---|
3076 | .SS Appending Redirected Output
|
---|
3077 | .PP
|
---|
3078 | Redirection of output in this fashion
|
---|
3079 | causes the file whose name results from
|
---|
3080 | the expansion of
|
---|
3081 | .I word
|
---|
3082 | to be opened for appending on file descriptor
|
---|
3083 | .IR n ,
|
---|
3084 | or the standard output (file descriptor 1) if
|
---|
3085 | .I n
|
---|
3086 | is not specified. If the file does not exist it is created.
|
---|
3087 | .PP
|
---|
3088 | The general format for appending output is:
|
---|
3089 | .RS
|
---|
3090 | .PP
|
---|
3091 | [\fIn\fP]\fB>>\fP\fIword\fP
|
---|
3092 | .RE
|
---|
3093 | .PP
|
---|
3094 | .SS Redirecting Standard Output and Standard Error
|
---|
3095 | .PP
|
---|
3096 | .B Bash
|
---|
3097 | allows both the
|
---|
3098 | standard output (file descriptor 1) and
|
---|
3099 | the standard error output (file descriptor 2)
|
---|
3100 | to be redirected to the file whose name is the
|
---|
3101 | expansion of
|
---|
3102 | .I word
|
---|
3103 | with this construct.
|
---|
3104 | .PP
|
---|
3105 | There are two formats for redirecting standard output and
|
---|
3106 | standard error:
|
---|
3107 | .RS
|
---|
3108 | .PP
|
---|
3109 | \fB&>\fP\fIword\fP
|
---|
3110 | .RE
|
---|
3111 | and
|
---|
3112 | .RS
|
---|
3113 | \fB>&\fP\fIword\fP
|
---|
3114 | .RE
|
---|
3115 | .PP
|
---|
3116 | Of the two forms, the first is preferred.
|
---|
3117 | This is semantically equivalent to
|
---|
3118 | .RS
|
---|
3119 | .PP
|
---|
3120 | \fB>\fP\fIword\fP 2\fB>&\fP1
|
---|
3121 | .RE
|
---|
3122 | .SS Here Documents
|
---|
3123 | .PP
|
---|
3124 | This type of redirection instructs the shell to read input from the
|
---|
3125 | current source until a line containing only
|
---|
3126 | .I word
|
---|
3127 | (with no trailing blanks)
|
---|
3128 | is seen. All of
|
---|
3129 | the lines read up to that point are then used as the standard
|
---|
3130 | input for a command.
|
---|
3131 | .PP
|
---|
3132 | The format of here-documents is:
|
---|
3133 | .RS
|
---|
3134 | .PP
|
---|
3135 | .nf
|
---|
3136 | \fB<<\fP[\fB\-\fP]\fIword\fP
|
---|
3137 | \fIhere-document\fP
|
---|
3138 | \fIdelimiter\fP
|
---|
3139 | .fi
|
---|
3140 | .RE
|
---|
3141 | .PP
|
---|
3142 | No parameter expansion, command substitution, arithmetic expansion,
|
---|
3143 | or pathname expansion is performed on
|
---|
3144 | .IR word .
|
---|
3145 | If any characters in
|
---|
3146 | .I word
|
---|
3147 | are quoted, the
|
---|
3148 | .I delimiter
|
---|
3149 | is the result of quote removal on
|
---|
3150 | .IR word ,
|
---|
3151 | and the lines in the here-document are not expanded.
|
---|
3152 | If \fIword\fP is unquoted,
|
---|
3153 | all lines of the here-document are subjected to parameter expansion,
|
---|
3154 | command substitution, and arithmetic expansion. In the latter
|
---|
3155 | case, the character sequence
|
---|
3156 | .B \e<newline>
|
---|
3157 | is ignored, and
|
---|
3158 | .B \e
|
---|
3159 | must be used to quote the characters
|
---|
3160 | .BR \e ,
|
---|
3161 | .BR $ ,
|
---|
3162 | and
|
---|
3163 | .BR ` .
|
---|
3164 | .PP
|
---|
3165 | If the redirection operator is
|
---|
3166 | .BR <<\- ,
|
---|
3167 | then all leading tab characters are stripped from input lines and the
|
---|
3168 | line containing
|
---|
3169 | .IR delimiter .
|
---|
3170 | This allows
|
---|
3171 | here-documents within shell scripts to be indented in a
|
---|
3172 | natural fashion.
|
---|
3173 | .SS "Here Strings"
|
---|
3174 | A variant of here documents, the format is:
|
---|
3175 | .RS
|
---|
3176 | .PP
|
---|
3177 | .nf
|
---|
3178 | \fB<<<\fP\fIword\fP
|
---|
3179 | .fi
|
---|
3180 | .RE
|
---|
3181 | .PP
|
---|
3182 | The \fIword\fP is expanded and supplied to the command on its standard
|
---|
3183 | input.
|
---|
3184 | .SS "Duplicating File Descriptors"
|
---|
3185 | .PP
|
---|
3186 | The redirection operator
|
---|
3187 | .RS
|
---|
3188 | .PP
|
---|
3189 | [\fIn\fP]\fB<&\fP\fIword\fP
|
---|
3190 | .RE
|
---|
3191 | .PP
|
---|
3192 | is used to duplicate input file descriptors.
|
---|
3193 | If
|
---|
3194 | .I word
|
---|
3195 | expands to one or more digits, the file descriptor denoted by
|
---|
3196 | .I n
|
---|
3197 | is made to be a copy of that file descriptor.
|
---|
3198 | If the digits in
|
---|
3199 | .I word
|
---|
3200 | do not specify a file descriptor open for input, a redirection error occurs.
|
---|
3201 | If
|
---|
3202 | .I word
|
---|
3203 | evaluates to
|
---|
3204 | .BR \- ,
|
---|
3205 | file descriptor
|
---|
3206 | .I n
|
---|
3207 | is closed. If
|
---|
3208 | .I n
|
---|
3209 | is not specified, the standard input (file descriptor 0) is used.
|
---|
3210 | .PP
|
---|
3211 | The operator
|
---|
3212 | .RS
|
---|
3213 | .PP
|
---|
3214 | [\fIn\fP]\fB>&\fP\fIword\fP
|
---|
3215 | .RE
|
---|
3216 | .PP
|
---|
3217 | is used similarly to duplicate output file descriptors. If
|
---|
3218 | .I n
|
---|
3219 | is not specified, the standard output (file descriptor 1) is used.
|
---|
3220 | If the digits in
|
---|
3221 | .I word
|
---|
3222 | do not specify a file descriptor open for output, a redirection error occurs.
|
---|
3223 | As a special case, if \fIn\fP is omitted, and \fIword\fP does not
|
---|
3224 | expand to one or more digits, the standard output and standard
|
---|
3225 | error are redirected as described previously.
|
---|
3226 | .SS "Moving File Descriptors"
|
---|
3227 | .PP
|
---|
3228 | The redirection operator
|
---|
3229 | .RS
|
---|
3230 | .PP
|
---|
3231 | [\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP
|
---|
3232 | .RE
|
---|
3233 | .PP
|
---|
3234 | moves the file descriptor \fIdigit\fP to file descriptor
|
---|
3235 | .IR n ,
|
---|
3236 | or the standard input (file descriptor 0) if \fIn\fP is not specified.
|
---|
3237 | \fIdigit\fP is closed after being duplicated to \fIn\fP.
|
---|
3238 | .PP
|
---|
3239 | Similarly, the redirection operator
|
---|
3240 | .RS
|
---|
3241 | .PP
|
---|
3242 | [\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP
|
---|
3243 | .RE
|
---|
3244 | .PP
|
---|
3245 | moves the file descriptor \fIdigit\fP to file descriptor
|
---|
3246 | .IR n ,
|
---|
3247 | or the standard output (file descriptor 1) if \fIn\fP is not specified.
|
---|
3248 | .SS "Opening File Descriptors for Reading and Writing"
|
---|
3249 | .PP
|
---|
3250 | The redirection operator
|
---|
3251 | .RS
|
---|
3252 | .PP
|
---|
3253 | [\fIn\fP]\fB<>\fP\fIword\fP
|
---|
3254 | .RE
|
---|
3255 | .PP
|
---|
3256 | causes the file whose name is the expansion of
|
---|
3257 | .I word
|
---|
3258 | to be opened for both reading and writing on file descriptor
|
---|
3259 | .IR n ,
|
---|
3260 | or on file descriptor 0 if
|
---|
3261 | .I n
|
---|
3262 | is not specified. If the file does not exist, it is created.
|
---|
3263 | .SH ALIASES
|
---|
3264 | \fIAliases\fP allow a string to be substituted for a word when it is used
|
---|
3265 | as the first word of a simple command.
|
---|
3266 | The shell maintains a list of aliases that may be set and unset with the
|
---|
3267 | .B alias
|
---|
3268 | and
|
---|
3269 | .B unalias
|
---|
3270 | builtin commands (see
|
---|
3271 | .SM
|
---|
3272 | .B SHELL BUILTIN COMMANDS
|
---|
3273 | below).
|
---|
3274 | The first word of each simple command, if unquoted,
|
---|
3275 | is checked to see if it has an
|
---|
3276 | alias. If so, that word is replaced by the text of the alias.
|
---|
3277 | The characters \fB/\fP, \fB$\fP, \fB`\fP, and \fB=\fP and
|
---|
3278 | any of the shell \fImetacharacters\fP or quoting characters
|
---|
3279 | listed above may not appear in an alias name.
|
---|
3280 | The replacement text may contain any valid shell input,
|
---|
3281 | including shell metacharacters.
|
---|
3282 | The first word of the replacement text is tested
|
---|
3283 | for aliases, but a word that is identical to an alias being expanded
|
---|
3284 | is not expanded a second time.
|
---|
3285 | This means that one may alias
|
---|
3286 | .B ls
|
---|
3287 | to
|
---|
3288 | .BR "ls \-F" ,
|
---|
3289 | for instance, and
|
---|
3290 | .B bash
|
---|
3291 | does not try to recursively expand the replacement text.
|
---|
3292 | If the last character of the alias value is a
|
---|
3293 | .IR blank ,
|
---|
3294 | then the next command
|
---|
3295 | word following the alias is also checked for alias expansion.
|
---|
3296 | .PP
|
---|
3297 | Aliases are created and listed with the
|
---|
3298 | .B alias
|
---|
3299 | command, and removed with the
|
---|
3300 | .B unalias
|
---|
3301 | command.
|
---|
3302 | .PP
|
---|
3303 | There is no mechanism for using arguments in the replacement text.
|
---|
3304 | If arguments are needed, a shell function should be used (see
|
---|
3305 | .SM
|
---|
3306 | .B FUNCTIONS
|
---|
3307 | below).
|
---|
3308 | .PP
|
---|
3309 | Aliases are not expanded when the shell is not interactive, unless
|
---|
3310 | the
|
---|
3311 | .B expand_aliases
|
---|
3312 | shell option is set using
|
---|
3313 | .B shopt
|
---|
3314 | (see the description of
|
---|
3315 | .B shopt
|
---|
3316 | under
|
---|
3317 | .SM
|
---|
3318 | \fBSHELL BUILTIN COMMANDS\fP
|
---|
3319 | below).
|
---|
3320 | .PP
|
---|
3321 | The rules concerning the definition and use of aliases are
|
---|
3322 | somewhat confusing.
|
---|
3323 | .B Bash
|
---|
3324 | always reads at least one complete line
|
---|
3325 | of input before executing any
|
---|
3326 | of the commands on that line. Aliases are expanded when a
|
---|
3327 | command is read, not when it is executed. Therefore, an
|
---|
3328 | alias definition appearing on the same line as another
|
---|
3329 | command does not take effect until the next line of input is read.
|
---|
3330 | The commands following the alias definition
|
---|
3331 | on that line are not affected by the new alias.
|
---|
3332 | This behavior is also an issue when functions are executed.
|
---|
3333 | Aliases are expanded when a function definition is read,
|
---|
3334 | not when the function is executed, because a function definition
|
---|
3335 | is itself a compound command. As a consequence, aliases
|
---|
3336 | defined in a function are not available until after that
|
---|
3337 | function is executed. To be safe, always put
|
---|
3338 | alias definitions on a separate line, and do not use
|
---|
3339 | .B alias
|
---|
3340 | in compound commands.
|
---|
3341 | .PP
|
---|
3342 | For almost every purpose, aliases are superseded by
|
---|
3343 | shell functions.
|
---|
3344 | .SH FUNCTIONS
|
---|
3345 | A shell function, defined as described above under
|
---|
3346 | .SM
|
---|
3347 | .BR "SHELL GRAMMAR" ,
|
---|
3348 | stores a series of commands for later execution.
|
---|
3349 | When the name of a shell function is used as a simple command name,
|
---|
3350 | the list of commands associated with that function name is executed.
|
---|
3351 | Functions are executed in the context of the
|
---|
3352 | current shell; no new process is created to interpret
|
---|
3353 | them (contrast this with the execution of a shell script).
|
---|
3354 | When a function is executed, the arguments to the
|
---|
3355 | function become the positional parameters
|
---|
3356 | during its execution.
|
---|
3357 | The special parameter
|
---|
3358 | .B #
|
---|
3359 | is updated to reflect the change. Special parameter 0
|
---|
3360 | is unchanged.
|
---|
3361 | The first element of the
|
---|
3362 | .SM
|
---|
3363 | .B FUNCNAME
|
---|
3364 | variable is set to the name of the function while the function
|
---|
3365 | is executing.
|
---|
3366 | All other aspects of the shell execution
|
---|
3367 | environment are identical between a function and its caller
|
---|
3368 | with the exception that the
|
---|
3369 | .SM
|
---|
3370 | .B DEBUG
|
---|
3371 | and
|
---|
3372 | .B RETURN
|
---|
3373 | traps (see the description of the
|
---|
3374 | .B trap
|
---|
3375 | builtin under
|
---|
3376 | .SM
|
---|
3377 | .B SHELL BUILTIN COMMANDS
|
---|
3378 | below) are not inherited unless the function has been given the
|
---|
3379 | \fBtrace\fP attribute (see the description of the
|
---|
3380 | .SM
|
---|
3381 | .B declare
|
---|
3382 | builtin below) or the
|
---|
3383 | \fB\-o functrace\fP shell option has been enabled with
|
---|
3384 | the \fBset\fP builtin
|
---|
3385 | (in which case all functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps).
|
---|
3386 | .PP
|
---|
3387 | Variables local to the function may be declared with the
|
---|
3388 | .B local
|
---|
3389 | builtin command. Ordinarily, variables and their values
|
---|
3390 | are shared between the function and its caller.
|
---|
3391 | .PP
|
---|
3392 | If the builtin command
|
---|
3393 | .B return
|
---|
3394 | is executed in a function, the function completes and
|
---|
3395 | execution resumes with the next command after the function
|
---|
3396 | call.
|
---|
3397 | Any command associated with the \fBRETURN\fP trap is executed
|
---|
3398 | before execution resumes.
|
---|
3399 | When a function completes, the values of the
|
---|
3400 | positional parameters and the special parameter
|
---|
3401 | .B #
|
---|
3402 | are restored to the values they had prior to the function's
|
---|
3403 | execution.
|
---|
3404 | .PP
|
---|
3405 | Function names and definitions may be listed with the
|
---|
3406 | .B \-f
|
---|
3407 | option to the
|
---|
3408 | .B declare
|
---|
3409 | or
|
---|
3410 | .B typeset
|
---|
3411 | builtin commands. The
|
---|
3412 | .B \-F
|
---|
3413 | option to
|
---|
3414 | .B declare
|
---|
3415 | or
|
---|
3416 | .B typeset
|
---|
3417 | will list the function names only
|
---|
3418 | (and optionally the source file and line number, if the \fBextdebug\fP
|
---|
3419 | shell option is enabled).
|
---|
3420 | Functions may be exported so that subshells
|
---|
3421 | automatically have them defined with the
|
---|
3422 | .B \-f
|
---|
3423 | option to the
|
---|
3424 | .B export
|
---|
3425 | builtin.
|
---|
3426 | Note that shell functions and variables with the same name may result
|
---|
3427 | in multiple identically-named entries in the environment passed to the
|
---|
3428 | shell's children.
|
---|
3429 | Care should be taken in cases where this may cause a problem.
|
---|
3430 | .PP
|
---|
3431 | Functions may be recursive. No limit is imposed on the number
|
---|
3432 | of recursive calls.
|
---|
3433 | .SH "ARITHMETIC EVALUATION"
|
---|
3434 | The shell allows arithmetic expressions to be evaluated, under
|
---|
3435 | certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin
|
---|
3436 | commands and \fBArithmetic Expansion\fP).
|
---|
3437 | Evaluation is done in fixed-width integers with no check for overflow,
|
---|
3438 | though division by 0 is trapped and flagged as an error.
|
---|
3439 | The operators and their precedence, associativity, and values
|
---|
3440 | are the same as in the C language.
|
---|
3441 | The following list of operators is grouped into levels of
|
---|
3442 | equal-precedence operators.
|
---|
3443 | The levels are listed in order of decreasing precedence.
|
---|
3444 | .PP
|
---|
3445 | .PD 0
|
---|
3446 | .TP
|
---|
3447 | .B \fIid\fP++ \fIid\fP\-\-
|
---|
3448 | variable post-increment and post-decrement
|
---|
3449 | .TP
|
---|
3450 | .B ++\fIid\fP \-\-\fIid\fP
|
---|
3451 | variable pre-increment and pre-decrement
|
---|
3452 | .TP
|
---|
3453 | .B \- +
|
---|
3454 | unary minus and plus
|
---|
3455 | .TP
|
---|
3456 | .B ! ~
|
---|
3457 | logical and bitwise negation
|
---|
3458 | .TP
|
---|
3459 | .B **
|
---|
3460 | exponentiation
|
---|
3461 | .TP
|
---|
3462 | .B * / %
|
---|
3463 | multiplication, division, remainder
|
---|
3464 | .TP
|
---|
3465 | .B + \-
|
---|
3466 | addition, subtraction
|
---|
3467 | .TP
|
---|
3468 | .B << >>
|
---|
3469 | left and right bitwise shifts
|
---|
3470 | .TP
|
---|
3471 | .B <= >= < >
|
---|
3472 | comparison
|
---|
3473 | .TP
|
---|
3474 | .B == !=
|
---|
3475 | equality and inequality
|
---|
3476 | .TP
|
---|
3477 | .B &
|
---|
3478 | bitwise AND
|
---|
3479 | .TP
|
---|
3480 | .B ^
|
---|
3481 | bitwise exclusive OR
|
---|
3482 | .TP
|
---|
3483 | .B |
|
---|
3484 | bitwise OR
|
---|
3485 | .TP
|
---|
3486 | .B &&
|
---|
3487 | logical AND
|
---|
3488 | .TP
|
---|
3489 | .B ||
|
---|
3490 | logical OR
|
---|
3491 | .TP
|
---|
3492 | .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
|
---|
3493 | conditional operator
|
---|
3494 | .TP
|
---|
3495 | .B = *= /= %= += \-= <<= >>= &= ^= |=
|
---|
3496 | assignment
|
---|
3497 | .TP
|
---|
3498 | .B \fIexpr1\fP , \fIexpr2\fP
|
---|
3499 | comma
|
---|
3500 | .PD
|
---|
3501 | .PP
|
---|
3502 | Shell variables are allowed as operands; parameter expansion is
|
---|
3503 | performed before the expression is evaluated.
|
---|
3504 | Within an expression, shell variables may also be referenced by name
|
---|
3505 | without using the parameter expansion syntax.
|
---|
3506 | A shell variable that is null or unset evaluates to 0 when referenced
|
---|
3507 | by name without using the parameter expansion syntax.
|
---|
3508 | The value of a variable is evaluated as an arithmetic expression
|
---|
3509 | when it is referenced, or when a variable which has been given the
|
---|
3510 | \fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value.
|
---|
3511 | A null value evaluates to 0.
|
---|
3512 | A shell variable need not have its integer attribute
|
---|
3513 | turned on to be used in an expression.
|
---|
3514 | .PP
|
---|
3515 | Constants with a leading 0 are interpreted as octal numbers.
|
---|
3516 | A leading 0x or 0X denotes hexadecimal.
|
---|
3517 | Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP
|
---|
3518 | is a decimal number between 2 and 64 representing the arithmetic
|
---|
3519 | base, and \fIn\fP is a number in that base.
|
---|
3520 | If \fIbase#\fP is omitted, then base 10 is used.
|
---|
3521 | The digits greater than 9 are represented by the lowercase letters,
|
---|
3522 | the uppercase letters, @, and _, in that order.
|
---|
3523 | If \fIbase\fP is less than or equal to 36, lowercase and uppercase
|
---|
3524 | letters may be used interchangeably to represent numbers between 10
|
---|
3525 | and 35.
|
---|
3526 | .PP
|
---|
3527 | Operators are evaluated in order of precedence. Sub-expressions in
|
---|
3528 | parentheses are evaluated first and may override the precedence
|
---|
3529 | rules above.
|
---|
3530 | .SH "CONDITIONAL EXPRESSIONS"
|
---|
3531 | Conditional expressions are used by the \fB[[\fP compound command and
|
---|
3532 | the \fBtest\fP and \fB[\fP builtin commands to test file attributes
|
---|
3533 | and perform string and arithmetic comparisons.
|
---|
3534 | Expressions are formed from the following unary or binary primaries.
|
---|
3535 | If any \fIfile\fP argument to one of the primaries is of the form
|
---|
3536 | \fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked.
|
---|
3537 | If the \fIfile\fP argument to one of the primaries is one of
|
---|
3538 | \fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file
|
---|
3539 | descriptor 0, 1, or 2, respectively, is checked.
|
---|
3540 | .PP
|
---|
3541 | Unless otherwise specified, primaries that operate on files follow symbolic
|
---|
3542 | links and operate on the target of the link, rather than the link itself.
|
---|
3543 | .sp 1
|
---|
3544 | .PD 0
|
---|
3545 | .TP
|
---|
3546 | .B \-a \fIfile\fP
|
---|
3547 | True if \fIfile\fP exists.
|
---|
3548 | .TP
|
---|
3549 | .B \-b \fIfile\fP
|
---|
3550 | True if \fIfile\fP exists and is a block special file.
|
---|
3551 | .TP
|
---|
3552 | .B \-c \fIfile\fP
|
---|
3553 | True if \fIfile\fP exists and is a character special file.
|
---|
3554 | .TP
|
---|
3555 | .B \-d \fIfile\fP
|
---|
3556 | True if \fIfile\fP exists and is a directory.
|
---|
3557 | .TP
|
---|
3558 | .B \-e \fIfile\fP
|
---|
3559 | True if \fIfile\fP exists.
|
---|
3560 | .TP
|
---|
3561 | .B \-f \fIfile\fP
|
---|
3562 | True if \fIfile\fP exists and is a regular file.
|
---|
3563 | .TP
|
---|
3564 | .B \-g \fIfile\fP
|
---|
3565 | True if \fIfile\fP exists and is set-group-id.
|
---|
3566 | .TP
|
---|
3567 | .B \-h \fIfile\fP
|
---|
3568 | True if \fIfile\fP exists and is a symbolic link.
|
---|
3569 | .TP
|
---|
3570 | .B \-k \fIfile\fP
|
---|
3571 | True if \fIfile\fP exists and its ``sticky'' bit is set.
|
---|
3572 | .TP
|
---|
3573 | .B \-p \fIfile\fP
|
---|
3574 | True if \fIfile\fP exists and is a named pipe (FIFO).
|
---|
3575 | .TP
|
---|
3576 | .B \-r \fIfile\fP
|
---|
3577 | True if \fIfile\fP exists and is readable.
|
---|
3578 | .TP
|
---|
3579 | .B \-s \fIfile\fP
|
---|
3580 | True if \fIfile\fP exists and has a size greater than zero.
|
---|
3581 | .TP
|
---|
3582 | .B \-t \fIfd\fP
|
---|
3583 | True if file descriptor
|
---|
3584 | .I fd
|
---|
3585 | is open and refers to a terminal.
|
---|
3586 | .TP
|
---|
3587 | .B \-u \fIfile\fP
|
---|
3588 | True if \fIfile\fP exists and its set-user-id bit is set.
|
---|
3589 | .TP
|
---|
3590 | .B \-w \fIfile\fP
|
---|
3591 | True if \fIfile\fP exists and is writable.
|
---|
3592 | .TP
|
---|
3593 | .B \-x \fIfile\fP
|
---|
3594 | True if \fIfile\fP exists and is executable.
|
---|
3595 | .TP
|
---|
3596 | .B \-O \fIfile\fP
|
---|
3597 | True if \fIfile\fP exists and is owned by the effective user id.
|
---|
3598 | .TP
|
---|
3599 | .B \-G \fIfile\fP
|
---|
3600 | True if \fIfile\fP exists and is owned by the effective group id.
|
---|
3601 | .TP
|
---|
3602 | .B \-L \fIfile\fP
|
---|
3603 | True if \fIfile\fP exists and is a symbolic link.
|
---|
3604 | .TP
|
---|
3605 | .B \-S \fIfile\fP
|
---|
3606 | True if \fIfile\fP exists and is a socket.
|
---|
3607 | .TP
|
---|
3608 | .B \-N \fIfile\fP
|
---|
3609 | True if \fIfile\fP exists and has been modified since it was last read.
|
---|
3610 | .TP
|
---|
3611 | \fIfile1\fP \-\fBnt\fP \fIfile2\fP
|
---|
3612 | True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP,
|
---|
3613 | or if \fIfile1\fP exists and \fPfile2\fP does not.
|
---|
3614 | .TP
|
---|
3615 | \fIfile1\fP \-\fBot\fP \fIfile2\fP
|
---|
3616 | True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists
|
---|
3617 | and \fIfile1\fP does not.
|
---|
3618 | .TP
|
---|
3619 | \fIfile1\fP \fB\-ef\fP \fIfile2\fP
|
---|
3620 | True if \fIfile1\fP and \fIfile2\fP refer to the same device and
|
---|
3621 | inode numbers.
|
---|
3622 | .TP
|
---|
3623 | .B \-o \fIoptname\fP
|
---|
3624 | True if shell option
|
---|
3625 | .I optname
|
---|
3626 | is enabled.
|
---|
3627 | See the list of options under the description of the
|
---|
3628 | .B \-o
|
---|
3629 | option to the
|
---|
3630 | .B set
|
---|
3631 | builtin below.
|
---|
3632 | .TP
|
---|
3633 | .B \-z \fIstring\fP
|
---|
3634 | True if the length of \fIstring\fP is zero.
|
---|
3635 | .TP
|
---|
3636 | \fIstring\fP
|
---|
3637 | .PD 0
|
---|
3638 | .TP
|
---|
3639 | .B \-n \fIstring\fP
|
---|
3640 | .PD
|
---|
3641 | True if the length of
|
---|
3642 | .I string
|
---|
3643 | is non-zero.
|
---|
3644 | .TP
|
---|
3645 | \fIstring1\fP \fB==\fP \fIstring2\fP
|
---|
3646 | True if the strings are equal. \fB=\fP may be used in place of
|
---|
3647 | \fB==\fP for strict POSIX compliance.
|
---|
3648 | .TP
|
---|
3649 | \fIstring1\fP \fB!=\fP \fIstring2\fP
|
---|
3650 | True if the strings are not equal.
|
---|
3651 | .TP
|
---|
3652 | \fIstring1\fP \fB<\fP \fIstring2\fP
|
---|
3653 | True if \fIstring1\fP sorts before \fIstring2\fP lexicographically
|
---|
3654 | in the current locale.
|
---|
3655 | .TP
|
---|
3656 | \fIstring1\fP \fB>\fP \fIstring2\fP
|
---|
3657 | True if \fIstring1\fP sorts after \fIstring2\fP lexicographically
|
---|
3658 | in the current locale.
|
---|
3659 | .TP
|
---|
3660 | .I \fIarg1\fP \fBOP\fP \fIarg2\fP
|
---|
3661 | .SM
|
---|
3662 | .B OP
|
---|
3663 | is one of
|
---|
3664 | .BR \-eq ,
|
---|
3665 | .BR \-ne ,
|
---|
3666 | .BR \-lt ,
|
---|
3667 | .BR \-le ,
|
---|
3668 | .BR \-gt ,
|
---|
3669 | or
|
---|
3670 | .BR \-ge .
|
---|
3671 | These arithmetic binary operators return true if \fIarg1\fP
|
---|
3672 | is equal to, not equal to, less than, less than or equal to,
|
---|
3673 | greater than, or greater than or equal to \fIarg2\fP, respectively.
|
---|
3674 | .I Arg1
|
---|
3675 | and
|
---|
3676 | .I arg2
|
---|
3677 | may be positive or negative integers.
|
---|
3678 | .PD
|
---|
3679 | .SH "SIMPLE COMMAND EXPANSION"
|
---|
3680 | When a simple command is executed, the shell performs the following
|
---|
3681 | expansions, assignments, and redirections, from left to right.
|
---|
3682 | .IP 1.
|
---|
3683 | The words that the parser has marked as variable assignments (those
|
---|
3684 | preceding the command name) and redirections are saved for later
|
---|
3685 | processing.
|
---|
3686 | .IP 2.
|
---|
3687 | The words that are not variable assignments or redirections are
|
---|
3688 | expanded. If any words remain after expansion, the first word
|
---|
3689 | is taken to be the name of the command and the remaining words are
|
---|
3690 | the arguments.
|
---|
3691 | .IP 3.
|
---|
3692 | Redirections are performed as described above under
|
---|
3693 | .SM
|
---|
3694 | .BR REDIRECTION .
|
---|
3695 | .IP 4.
|
---|
3696 | The text after the \fB=\fP in each variable assignment undergoes tilde
|
---|
3697 | expansion, parameter expansion, command substitution, arithmetic expansion,
|
---|
3698 | and quote removal before being assigned to the variable.
|
---|
3699 | .PP
|
---|
3700 | If no command name results, the variable assignments affect the current
|
---|
3701 | shell environment. Otherwise, the variables are added to the environment
|
---|
3702 | of the executed command and do not affect the current shell environment.
|
---|
3703 | If any of the assignments attempts to assign a value to a readonly variable,
|
---|
3704 | an error occurs, and the command exits with a non-zero status.
|
---|
3705 | .PP
|
---|
3706 | If no command name results, redirections are performed, but do not
|
---|
3707 | affect the current shell environment. A redirection error causes the
|
---|
3708 | command to exit with a non-zero status.
|
---|
3709 | .PP
|
---|
3710 | If there is a command name left after expansion, execution proceeds as
|
---|
3711 | described below. Otherwise, the command exits. If one of the expansions
|
---|
3712 | contained a command substitution, the exit status of the command is
|
---|
3713 | the exit status of the last command substitution performed. If there
|
---|
3714 | were no command substitutions, the command exits with a status of zero.
|
---|
3715 | .SH "COMMAND EXECUTION"
|
---|
3716 | After a command has been split into words, if it results in a
|
---|
3717 | simple command and an optional list of arguments, the following
|
---|
3718 | actions are taken.
|
---|
3719 | .PP
|
---|
3720 | If the command name contains no slashes, the shell attempts to
|
---|
3721 | locate it. If there exists a shell function by that name, that
|
---|
3722 | function is invoked as described above in
|
---|
3723 | .SM
|
---|
3724 | .BR FUNCTIONS .
|
---|
3725 | If the name does not match a function, the shell searches for
|
---|
3726 | it in the list of shell builtins. If a match is found, that
|
---|
3727 | builtin is invoked.
|
---|
3728 | .PP
|
---|
3729 | If the name is neither a shell function nor a builtin,
|
---|
3730 | and contains no slashes,
|
---|
3731 | .B bash
|
---|
3732 | searches each element of the
|
---|
3733 | .SM
|
---|
3734 | .B PATH
|
---|
3735 | for a directory containing an executable file by that name.
|
---|
3736 | .B Bash
|
---|
3737 | uses a hash table to remember the full pathnames of executable
|
---|
3738 | files (see
|
---|
3739 | .B hash
|
---|
3740 | under
|
---|
3741 | .SM
|
---|
3742 | .B "SHELL BUILTIN COMMANDS"
|
---|
3743 | below).
|
---|
3744 | A full search of the directories in
|
---|
3745 | .SM
|
---|
3746 | .B PATH
|
---|
3747 | is performed only if the command is not found in the hash table.
|
---|
3748 | If the search is unsuccessful, the shell prints an error
|
---|
3749 | message and returns an exit status of 127.
|
---|
3750 | .PP
|
---|
3751 | If the search is successful, or if the command name contains
|
---|
3752 | one or more slashes, the shell executes the named program in a
|
---|
3753 | separate execution environment.
|
---|
3754 | Argument 0 is set to the name given, and the remaining arguments
|
---|
3755 | to the command are set to the arguments given, if any.
|
---|
3756 | .PP
|
---|
3757 | If this execution fails because the file is not in executable
|
---|
3758 | format, and the file is not a directory, it is assumed to be
|
---|
3759 | a \fIshell script\fP, a file
|
---|
3760 | containing shell commands. A subshell is spawned to execute
|
---|
3761 | it. This subshell reinitializes itself, so
|
---|
3762 | that the effect is as if a new shell had been invoked
|
---|
3763 | to handle the script, with the exception that the locations of
|
---|
3764 | commands remembered by the parent (see
|
---|
3765 | .B hash
|
---|
3766 | below under
|
---|
3767 | .SM
|
---|
3768 | \fBSHELL BUILTIN COMMANDS\fP)
|
---|
3769 | are retained by the child.
|
---|
3770 | .PP
|
---|
3771 | If the program is a file beginning with
|
---|
3772 | .BR #! ,
|
---|
3773 | the remainder of the first line specifies an interpreter
|
---|
3774 | for the program. The shell executes the
|
---|
3775 | specified interpreter on operating systems that do not
|
---|
3776 | handle this executable format themselves. The arguments to the
|
---|
3777 | interpreter consist of a single optional argument following the
|
---|
3778 | interpreter name on the first line of the program, followed
|
---|
3779 | by the name of the program, followed by the command
|
---|
3780 | arguments, if any.
|
---|
3781 | .SH COMMAND EXECUTION ENVIRONMENT
|
---|
3782 | The shell has an \fIexecution environment\fP, which consists of the
|
---|
3783 | following:
|
---|
3784 | .sp 1
|
---|
3785 | .IP \(bu
|
---|
3786 | open files inherited by the shell at invocation, as modified by
|
---|
3787 | redirections supplied to the \fBexec\fP builtin
|
---|
3788 | .IP \(bu
|
---|
3789 | the current working directory as set by \fBcd\fP, \fBpushd\fP, or
|
---|
3790 | \fBpopd\fP, or inherited by the shell at invocation
|
---|
3791 | .IP \(bu
|
---|
3792 | the file creation mode mask as set by \fBumask\fP or inherited from
|
---|
3793 | the shell's parent
|
---|
3794 | .IP \(bu
|
---|
3795 | current traps set by \fBtrap\fP
|
---|
3796 | .IP \(bu
|
---|
3797 | shell parameters that are set by variable assignment or with \fBset\fP
|
---|
3798 | or inherited from the shell's parent in the environment
|
---|
3799 | .IP \(bu
|
---|
3800 | shell functions defined during execution or inherited from the shell's
|
---|
3801 | parent in the environment
|
---|
3802 | .IP \(bu
|
---|
3803 | options enabled at invocation (either by default or with command-line
|
---|
3804 | arguments) or by \fBset\fP
|
---|
3805 | .IP \(bu
|
---|
3806 | options enabled by \fBshopt\fP
|
---|
3807 | .IP \(bu
|
---|
3808 | shell aliases defined with \fBalias\fP
|
---|
3809 | .IP \(bu
|
---|
3810 | various process IDs, including those of background jobs, the value
|
---|
3811 | of \fB$$\fP, and the value of \fB$PPID\fP
|
---|
3812 | .PP
|
---|
3813 | When a simple command other than a builtin or shell function
|
---|
3814 | is to be executed, it
|
---|
3815 | is invoked in a separate execution environment that consists of
|
---|
3816 | the following. Unless otherwise noted, the values are inherited
|
---|
3817 | from the shell.
|
---|
3818 | .sp 1
|
---|
3819 | .IP \(bu
|
---|
3820 | the shell's open files, plus any modifications and additions specified
|
---|
3821 | by redirections to the command
|
---|
3822 | .IP \(bu
|
---|
3823 | the current working directory
|
---|
3824 | .IP \(bu
|
---|
3825 | the file creation mode mask
|
---|
3826 | .IP \(bu
|
---|
3827 | shell variables and functions marked for export, along with variables
|
---|
3828 | exported for the command, passed in the environment
|
---|
3829 | .IP \(bu
|
---|
3830 | traps caught by the shell are reset to the values inherited from the
|
---|
3831 | shell's parent, and traps ignored by the shell are ignored
|
---|
3832 | .PP
|
---|
3833 | A command invoked in this separate environment cannot affect the
|
---|
3834 | shell's execution environment.
|
---|
3835 | .PP
|
---|
3836 | Command substitution, commands grouped with parentheses,
|
---|
3837 | and asynchronous commands are invoked in a
|
---|
3838 | subshell environment that is a duplicate of the shell environment,
|
---|
3839 | except that traps caught by the shell are reset to the values
|
---|
3840 | that the shell inherited from its parent at invocation. Builtin
|
---|
3841 | commands that are invoked as part of a pipeline are also executed in a
|
---|
3842 | subshell environment. Changes made to the subshell environment
|
---|
3843 | cannot affect the shell's execution environment.
|
---|
3844 | .PP
|
---|
3845 | If a command is followed by a \fB&\fP and job control is not active, the
|
---|
3846 | default standard input for the command is the empty file \fI/dev/null\fP.
|
---|
3847 | Otherwise, the invoked command inherits the file descriptors of the calling
|
---|
3848 | shell as modified by redirections.
|
---|
3849 | .SH ENVIRONMENT
|
---|
3850 | When a program is invoked it is given an array of strings
|
---|
3851 | called the
|
---|
3852 | .IR environment .
|
---|
3853 | This is a list of
|
---|
3854 | \fIname\fP\-\fIvalue\fP pairs, of the form
|
---|
3855 | .IR "name\fR=\fPvalue" .
|
---|
3856 | .PP
|
---|
3857 | The shell provides several ways to manipulate the environment.
|
---|
3858 | On invocation, the shell scans its own environment and
|
---|
3859 | creates a parameter for each name found, automatically marking
|
---|
3860 | it for
|
---|
3861 | .I export
|
---|
3862 | to child processes. Executed commands inherit the environment.
|
---|
3863 | The
|
---|
3864 | .B export
|
---|
3865 | and
|
---|
3866 | .B declare \-x
|
---|
3867 | commands allow parameters and functions to be added to and
|
---|
3868 | deleted from the environment. If the value of a parameter
|
---|
3869 | in the environment is modified, the new value becomes part
|
---|
3870 | of the environment, replacing the old. The environment
|
---|
3871 | inherited by any executed command consists of the shell's
|
---|
3872 | initial environment, whose values may be modified in the shell,
|
---|
3873 | less any pairs removed by the
|
---|
3874 | .B unset
|
---|
3875 | command, plus any additions via the
|
---|
3876 | .B export
|
---|
3877 | and
|
---|
3878 | .B declare \-x
|
---|
3879 | commands.
|
---|
3880 | .PP
|
---|
3881 | The environment for any
|
---|
3882 | .I simple command
|
---|
3883 | or function may be augmented temporarily by prefixing it with
|
---|
3884 | parameter assignments, as described above in
|
---|
3885 | .SM
|
---|
3886 | .BR PARAMETERS .
|
---|
3887 | These assignment statements affect only the environment seen
|
---|
3888 | by that command.
|
---|
3889 | .PP
|
---|
3890 | If the
|
---|
3891 | .B \-k
|
---|
3892 | option is set (see the
|
---|
3893 | .B set
|
---|
3894 | builtin command below), then
|
---|
3895 | .I all
|
---|
3896 | parameter assignments are placed in the environment for a command,
|
---|
3897 | not just those that precede the command name.
|
---|
3898 | .PP
|
---|
3899 | When
|
---|
3900 | .B bash
|
---|
3901 | invokes an external command, the variable
|
---|
3902 | .B _
|
---|
3903 | is set to the full file name of the command and passed to that
|
---|
3904 | command in its environment.
|
---|
3905 | .SH "EXIT STATUS"
|
---|
3906 | For the shell's purposes, a command which exits with a
|
---|
3907 | zero exit status has succeeded. An exit status of zero
|
---|
3908 | indicates success. A non-zero exit status indicates failure.
|
---|
3909 | When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses
|
---|
3910 | the value of 128+\fIN\fP as the exit status.
|
---|
3911 | .PP
|
---|
3912 | If a command is not found, the child process created to
|
---|
3913 | execute it returns a status of 127. If a command is found
|
---|
3914 | but is not executable, the return status is 126.
|
---|
3915 | .PP
|
---|
3916 | If a command fails because of an error during expansion or redirection,
|
---|
3917 | the exit status is greater than zero.
|
---|
3918 | .PP
|
---|
3919 | Shell builtin commands return a status of 0 (\fItrue\fP) if
|
---|
3920 | successful, and non-zero (\fIfalse\fP) if an error occurs
|
---|
3921 | while they execute.
|
---|
3922 | All builtins return an exit status of 2 to indicate incorrect usage.
|
---|
3923 | .PP
|
---|
3924 | \fBBash\fP itself returns the exit status of the last command
|
---|
3925 | executed, unless a syntax error occurs, in which case it exits
|
---|
3926 | with a non-zero value. See also the \fBexit\fP builtin
|
---|
3927 | command below.
|
---|
3928 | .SH SIGNALS
|
---|
3929 | When \fBbash\fP is interactive, in the absence of any traps, it ignores
|
---|
3930 | .SM
|
---|
3931 | .B SIGTERM
|
---|
3932 | (so that \fBkill 0\fP does not kill an interactive shell),
|
---|
3933 | and
|
---|
3934 | .SM
|
---|
3935 | .B SIGINT
|
---|
3936 | is caught and handled (so that the \fBwait\fP builtin is interruptible).
|
---|
3937 | In all cases, \fBbash\fP ignores
|
---|
3938 | .SM
|
---|
3939 | .BR SIGQUIT .
|
---|
3940 | If job control is in effect,
|
---|
3941 | .B bash
|
---|
3942 | ignores
|
---|
3943 | .SM
|
---|
3944 | .BR SIGTTIN ,
|
---|
3945 | .SM
|
---|
3946 | .BR SIGTTOU ,
|
---|
3947 | and
|
---|
3948 | .SM
|
---|
3949 | .BR SIGTSTP .
|
---|
3950 | .PP
|
---|
3951 | Non-builtin commands run by \fBbash\fP have signal handlers
|
---|
3952 | set to the values inherited by the shell from its parent.
|
---|
3953 | When job control is not in effect, asynchronous commands
|
---|
3954 | ignore
|
---|
3955 | .SM
|
---|
3956 | .B SIGINT
|
---|
3957 | and
|
---|
3958 | .SM
|
---|
3959 | .B SIGQUIT
|
---|
3960 | in addition to these inherited handlers.
|
---|
3961 | Commands run as a result of command substitution ignore the
|
---|
3962 | keyboard-generated job control signals
|
---|
3963 | .SM
|
---|
3964 | .BR SIGTTIN ,
|
---|
3965 | .SM
|
---|
3966 | .BR SIGTTOU ,
|
---|
3967 | and
|
---|
3968 | .SM
|
---|
3969 | .BR SIGTSTP .
|
---|
3970 | .PP
|
---|
3971 | The shell exits by default upon receipt of a
|
---|
3972 | .SM
|
---|
3973 | .BR SIGHUP .
|
---|
3974 | Before exiting, an interactive shell resends the
|
---|
3975 | .SM
|
---|
3976 | .B SIGHUP
|
---|
3977 | to all jobs, running or stopped.
|
---|
3978 | Stopped jobs are sent
|
---|
3979 | .SM
|
---|
3980 | .B SIGCONT
|
---|
3981 | to ensure that they receive the
|
---|
3982 | .SM
|
---|
3983 | .BR SIGHUP .
|
---|
3984 | To prevent the shell from
|
---|
3985 | sending the signal to a particular job, it should be removed from the
|
---|
3986 | jobs table with the
|
---|
3987 | .B disown
|
---|
3988 | builtin (see
|
---|
3989 | .SM
|
---|
3990 | .B "SHELL BUILTIN COMMANDS"
|
---|
3991 | below) or marked
|
---|
3992 | to not receive
|
---|
3993 | .SM
|
---|
3994 | .B SIGHUP
|
---|
3995 | using
|
---|
3996 | .BR "disown \-h" .
|
---|
3997 | .PP
|
---|
3998 | If the
|
---|
3999 | .B huponexit
|
---|
4000 | shell option has been set with
|
---|
4001 | .BR shopt ,
|
---|
4002 | .B bash
|
---|
4003 | sends a
|
---|
4004 | .SM
|
---|
4005 | .B SIGHUP
|
---|
4006 | to all jobs when an interactive login shell exits.
|
---|
4007 | .PP
|
---|
4008 | If \fBbash\fP is waiting for a command to complete and receives a signal
|
---|
4009 | for which a trap has been set, the trap will not be executed until
|
---|
4010 | the command completes.
|
---|
4011 | When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP
|
---|
4012 | builtin, the reception of a signal for which a trap has been set will
|
---|
4013 | cause the \fBwait\fP builtin to return immediately with an exit status
|
---|
4014 | greater than 128, immediately after which the trap is executed.
|
---|
4015 | .SH "JOB CONTROL"
|
---|
4016 | .I Job control
|
---|
4017 | refers to the ability to selectively stop (\fIsuspend\fP)
|
---|
4018 | the execution of processes and continue (\fIresume\fP)
|
---|
4019 | their execution at a later point. A user typically employs
|
---|
4020 | this facility via an interactive interface supplied jointly
|
---|
4021 | by the system's terminal driver and
|
---|
4022 | .BR bash .
|
---|
4023 | .PP
|
---|
4024 | The shell associates a
|
---|
4025 | .I job
|
---|
4026 | with each pipeline. It keeps a table of currently executing
|
---|
4027 | jobs, which may be listed with the
|
---|
4028 | .B jobs
|
---|
4029 | command. When
|
---|
4030 | .B bash
|
---|
4031 | starts a job asynchronously (in the
|
---|
4032 | .IR background ),
|
---|
4033 | it prints a line that looks like:
|
---|
4034 | .RS
|
---|
4035 | .PP
|
---|
4036 | [1] 25647
|
---|
4037 | .RE
|
---|
4038 | .PP
|
---|
4039 | indicating that this job is job number 1 and that the process ID
|
---|
4040 | of the last process in the pipeline associated with this job is 25647.
|
---|
4041 | All of the processes in a single pipeline are members of the same job.
|
---|
4042 | .B Bash
|
---|
4043 | uses the
|
---|
4044 | .I job
|
---|
4045 | abstraction as the basis for job control.
|
---|
4046 | .PP
|
---|
4047 | To facilitate the implementation of the user interface to job
|
---|
4048 | control, the operating system maintains the notion of a \fIcurrent terminal
|
---|
4049 | process group ID\fP. Members of this process group (processes whose
|
---|
4050 | process group ID is equal to the current terminal process group ID)
|
---|
4051 | receive keyboard-generated signals such as
|
---|
4052 | .SM
|
---|
4053 | .BR SIGINT .
|
---|
4054 | These processes are said to be in the
|
---|
4055 | .IR foreground .
|
---|
4056 | .I Background
|
---|
4057 | processes are those whose process group ID differs from the terminal's;
|
---|
4058 | such processes are immune to keyboard-generated signals.
|
---|
4059 | Only foreground processes are allowed to read from or write to the
|
---|
4060 | terminal. Background processes which attempt to read from (write to) the
|
---|
4061 | terminal are sent a
|
---|
4062 | .SM
|
---|
4063 | .B SIGTTIN (SIGTTOU)
|
---|
4064 | signal by the terminal driver,
|
---|
4065 | which, unless caught, suspends the process.
|
---|
4066 | .PP
|
---|
4067 | If the operating system on which
|
---|
4068 | .B bash
|
---|
4069 | is running supports
|
---|
4070 | job control,
|
---|
4071 | .B bash
|
---|
4072 | contains facilities to use it.
|
---|
4073 | Typing the
|
---|
4074 | .I suspend
|
---|
4075 | character (typically
|
---|
4076 | .BR ^Z ,
|
---|
4077 | Control-Z) while a process is running
|
---|
4078 | causes that process to be stopped and returns control to
|
---|
4079 | .BR bash .
|
---|
4080 | Typing the
|
---|
4081 | .I "delayed suspend"
|
---|
4082 | character (typically
|
---|
4083 | .BR ^Y ,
|
---|
4084 | Control-Y) causes the process to be stopped when it
|
---|
4085 | attempts to read input from the terminal, and control to
|
---|
4086 | be returned to
|
---|
4087 | .BR bash .
|
---|
4088 | The user may then manipulate the state of this job, using the
|
---|
4089 | .B bg
|
---|
4090 | command to continue it in the background, the
|
---|
4091 | .B fg
|
---|
4092 | command to continue it in the foreground, or
|
---|
4093 | the
|
---|
4094 | .B kill
|
---|
4095 | command to kill it. A \fB^Z\fP takes effect immediately,
|
---|
4096 | and has the additional side effect of causing pending output
|
---|
4097 | and typeahead to be discarded.
|
---|
4098 | .PP
|
---|
4099 | There are a number of ways to refer to a job in the shell.
|
---|
4100 | The character
|
---|
4101 | .B %
|
---|
4102 | introduces a job name. Job number
|
---|
4103 | .I n
|
---|
4104 | may be referred to as
|
---|
4105 | .BR %n .
|
---|
4106 | A job may also be referred to using a prefix of the name used to
|
---|
4107 | start it, or using a substring that appears in its command line.
|
---|
4108 | For example,
|
---|
4109 | .B %ce
|
---|
4110 | refers to a stopped
|
---|
4111 | .B ce
|
---|
4112 | job. If a prefix matches more than one job,
|
---|
4113 | .B bash
|
---|
4114 | reports an error. Using
|
---|
4115 | .BR %?ce ,
|
---|
4116 | on the other hand, refers to any job containing the string
|
---|
4117 | .B ce
|
---|
4118 | in its command line. If the substring matches more than one job,
|
---|
4119 | .B bash
|
---|
4120 | reports an error. The symbols
|
---|
4121 | .B %%
|
---|
4122 | and
|
---|
4123 | .B %+
|
---|
4124 | refer to the shell's notion of the
|
---|
4125 | .IR "current job" ,
|
---|
4126 | which is the last job stopped while it was in
|
---|
4127 | the foreground or started in the background.
|
---|
4128 | The
|
---|
4129 | .I "previous job"
|
---|
4130 | may be referenced using
|
---|
4131 | .BR %\- .
|
---|
4132 | In output pertaining to jobs (e.g., the output of the
|
---|
4133 | .B jobs
|
---|
4134 | command), the current job is always flagged with a
|
---|
4135 | .BR + ,
|
---|
4136 | and the previous job with a
|
---|
4137 | .BR \- .
|
---|
4138 | A single % (with no accompanying job specification) also refers to the
|
---|
4139 | current job.
|
---|
4140 | .PP
|
---|
4141 | Simply naming a job can be used to bring it into the
|
---|
4142 | foreground:
|
---|
4143 | .B %1
|
---|
4144 | is a synonym for
|
---|
4145 | \fB``fg %1''\fP,
|
---|
4146 | bringing job 1 from the background into the foreground.
|
---|
4147 | Similarly,
|
---|
4148 | .B ``%1 &''
|
---|
4149 | resumes job 1 in the background, equivalent to
|
---|
4150 | \fB``bg %1''\fP.
|
---|
4151 | .PP
|
---|
4152 | The shell learns immediately whenever a job changes state.
|
---|
4153 | Normally,
|
---|
4154 | .B bash
|
---|
4155 | waits until it is about to print a prompt before reporting
|
---|
4156 | changes in a job's status so as to not interrupt
|
---|
4157 | any other output. If the
|
---|
4158 | .B \-b
|
---|
4159 | option to the
|
---|
4160 | .B set
|
---|
4161 | builtin command
|
---|
4162 | is enabled,
|
---|
4163 | .B bash
|
---|
4164 | reports such changes immediately.
|
---|
4165 | Any trap on
|
---|
4166 | .SM
|
---|
4167 | .B SIGCHLD
|
---|
4168 | is executed for each child that exits.
|
---|
4169 | .PP
|
---|
4170 | If an attempt to exit
|
---|
4171 | .B bash
|
---|
4172 | is made while jobs are stopped, the shell prints a warning message. The
|
---|
4173 | .B jobs
|
---|
4174 | command may then be used to inspect their status.
|
---|
4175 | If a second attempt to exit is made without an intervening command,
|
---|
4176 | the shell does not print another warning, and the stopped
|
---|
4177 | jobs are terminated.
|
---|
4178 | .SH PROMPTING
|
---|
4179 | When executing interactively,
|
---|
4180 | .B bash
|
---|
4181 | displays the primary prompt
|
---|
4182 | .SM
|
---|
4183 | .B PS1
|
---|
4184 | when it is ready to read a command, and the secondary prompt
|
---|
4185 | .SM
|
---|
4186 | .B PS2
|
---|
4187 | when it needs more input to complete a command.
|
---|
4188 | .B Bash
|
---|
4189 | allows these prompt strings to be customized by inserting a number of
|
---|
4190 | backslash-escaped special characters that are decoded as follows:
|
---|
4191 | .RS
|
---|
4192 | .PD 0
|
---|
4193 | .TP
|
---|
4194 | .B \ea
|
---|
4195 | an ASCII bell character (07)
|
---|
4196 | .TP
|
---|
4197 | .B \ed
|
---|
4198 | the date in "Weekday Month Date" format (e.g., "Tue May 26")
|
---|
4199 | .TP
|
---|
4200 | .B \eD{\fIformat\fP}
|
---|
4201 | the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted
|
---|
4202 | into the prompt string; an empty \fIformat\fP results in a locale-specific
|
---|
4203 | time representation. The braces are required
|
---|
4204 | .TP
|
---|
4205 | .B \ee
|
---|
4206 | an ASCII escape character (033)
|
---|
4207 | .TP
|
---|
4208 | .B \eh
|
---|
4209 | the hostname up to the first `.'
|
---|
4210 | .TP
|
---|
4211 | .B \eH
|
---|
4212 | the hostname
|
---|
4213 | .TP
|
---|
4214 | .B \ej
|
---|
4215 | the number of jobs currently managed by the shell
|
---|
4216 | .TP
|
---|
4217 | .B \el
|
---|
4218 | the basename of the shell's terminal device name
|
---|
4219 | .TP
|
---|
4220 | .B \en
|
---|
4221 | newline
|
---|
4222 | .TP
|
---|
4223 | .B \er
|
---|
4224 | carriage return
|
---|
4225 | .TP
|
---|
4226 | .B \es
|
---|
4227 | the name of the shell, the basename of
|
---|
4228 | .B $0
|
---|
4229 | (the portion following the final slash)
|
---|
4230 | .TP
|
---|
4231 | .B \et
|
---|
4232 | the current time in 24-hour HH:MM:SS format
|
---|
4233 | .TP
|
---|
4234 | .B \eT
|
---|
4235 | the current time in 12-hour HH:MM:SS format
|
---|
4236 | .TP
|
---|
4237 | .B \e@
|
---|
4238 | the current time in 12-hour am/pm format
|
---|
4239 | .TP
|
---|
4240 | .B \eA
|
---|
4241 | the current time in 24-hour HH:MM format
|
---|
4242 | .TP
|
---|
4243 | .B \eu
|
---|
4244 | the username of the current user
|
---|
4245 | .TP
|
---|
4246 | .B \ev
|
---|
4247 | the version of \fBbash\fP (e.g., 2.00)
|
---|
4248 | .TP
|
---|
4249 | .B \eV
|
---|
4250 | the release of \fBbash\fP, version + patch level (e.g., 2.00.0)
|
---|
4251 | .TP
|
---|
4252 | .B \ew
|
---|
4253 | the current working directory, with \fB$HOME\fP abbreviated with a tilde
|
---|
4254 | .TP
|
---|
4255 | .B \eW
|
---|
4256 | the basename of the current working directory, with \fB$HOME\fP
|
---|
4257 | abbreviated with a tilde
|
---|
4258 | .TP
|
---|
4259 | .B \e!
|
---|
4260 | the history number of this command
|
---|
4261 | .TP
|
---|
4262 | .B \e#
|
---|
4263 | the command number of this command
|
---|
4264 | .TP
|
---|
4265 | .B \e$
|
---|
4266 | if the effective UID is 0, a
|
---|
4267 | .BR # ,
|
---|
4268 | otherwise a
|
---|
4269 | .B $
|
---|
4270 | .TP
|
---|
4271 | .B \e\fInnn\fP
|
---|
4272 | the character corresponding to the octal number \fInnn\fP
|
---|
4273 | .TP
|
---|
4274 | .B \e\e
|
---|
4275 | a backslash
|
---|
4276 | .TP
|
---|
4277 | .B \e[
|
---|
4278 | begin a sequence of non-printing characters, which could be used to
|
---|
4279 | embed a terminal control sequence into the prompt
|
---|
4280 | .TP
|
---|
4281 | .B \e]
|
---|
4282 | end a sequence of non-printing characters
|
---|
4283 | .PD
|
---|
4284 | .RE
|
---|
4285 | .PP
|
---|
4286 | The command number and the history number are usually different:
|
---|
4287 | the history number of a command is its position in the history
|
---|
4288 | list, which may include commands restored from the history file
|
---|
4289 | (see
|
---|
4290 | .SM
|
---|
4291 | .B HISTORY
|
---|
4292 | below), while the command number is the position in the sequence
|
---|
4293 | of commands executed during the current shell session.
|
---|
4294 | After the string is decoded, it is expanded via
|
---|
4295 | parameter expansion, command substitution, arithmetic
|
---|
4296 | expansion, and quote removal, subject to the value of the
|
---|
4297 | .B promptvars
|
---|
4298 | shell option (see the description of the
|
---|
4299 | .B shopt
|
---|
4300 | command under
|
---|
4301 | .SM
|
---|
4302 | .B "SHELL BUILTIN COMMANDS"
|
---|
4303 | below).
|
---|
4304 | .SH READLINE
|
---|
4305 | This is the library that handles reading input when using an interactive
|
---|
4306 | shell, unless the
|
---|
4307 | .B \-\-noediting
|
---|
4308 | option is given at shell invocation.
|
---|
4309 | By default, the line editing commands are similar to those of emacs.
|
---|
4310 | A vi-style line editing interface is also available.
|
---|
4311 | To turn off line editing after the shell is running, use the
|
---|
4312 | .B +o emacs
|
---|
4313 | or
|
---|
4314 | .B +o vi
|
---|
4315 | options to the
|
---|
4316 | .B set
|
---|
4317 | builtin (see
|
---|
4318 | .SM
|
---|
4319 | .B SHELL BUILTIN COMMANDS
|
---|
4320 | below).
|
---|
4321 | .SS "Readline Notation"
|
---|
4322 | .PP
|
---|
4323 | In this section, the emacs-style notation is used to denote
|
---|
4324 | keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
|
---|
4325 | means Control\-N. Similarly,
|
---|
4326 | .I meta
|
---|
4327 | keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
|
---|
4328 | without a
|
---|
4329 | .I meta
|
---|
4330 | key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
|
---|
4331 | then the
|
---|
4332 | .I x
|
---|
4333 | key. This makes ESC the \fImeta prefix\fP.
|
---|
4334 | The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
|
---|
4335 | or press the Escape key
|
---|
4336 | then hold the Control key while pressing the
|
---|
4337 | .I x
|
---|
4338 | key.)
|
---|
4339 | .PP
|
---|
4340 | Readline commands may be given numeric
|
---|
4341 | .IR arguments ,
|
---|
4342 | which normally act as a repeat count.
|
---|
4343 | Sometimes, however, it is the sign of the argument that is significant.
|
---|
4344 | Passing a negative argument to a command that acts in the forward
|
---|
4345 | direction (e.g., \fBkill\-line\fP) causes that command to act in a
|
---|
4346 | backward direction.
|
---|
4347 | Commands whose behavior with arguments deviates from this are noted
|
---|
4348 | below.
|
---|
4349 | .PP
|
---|
4350 | When a command is described as \fIkilling\fP text, the text
|
---|
4351 | deleted is saved for possible future retrieval
|
---|
4352 | (\fIyanking\fP). The killed text is saved in a
|
---|
4353 | \fIkill ring\fP. Consecutive kills cause the text to be
|
---|
4354 | accumulated into one unit, which can be yanked all at once.
|
---|
4355 | Commands which do not kill text separate the chunks of text
|
---|
4356 | on the kill ring.
|
---|
4357 | .SS "Readline Initialization"
|
---|
4358 | .PP
|
---|
4359 | Readline is customized by putting commands in an initialization
|
---|
4360 | file (the \fIinputrc\fP file).
|
---|
4361 | The name of this file is taken from the value of the
|
---|
4362 | .SM
|
---|
4363 | .B INPUTRC
|
---|
4364 | variable. If that variable is unset, the default is
|
---|
4365 | .IR ~/.inputrc .
|
---|
4366 | When a program which uses the readline library starts up, the
|
---|
4367 | initialization file is read, and the key bindings and variables
|
---|
4368 | are set.
|
---|
4369 | There are only a few basic constructs allowed in the
|
---|
4370 | readline initialization file.
|
---|
4371 | Blank lines are ignored.
|
---|
4372 | Lines beginning with a \fB#\fP are comments.
|
---|
4373 | Lines beginning with a \fB$\fP indicate conditional constructs.
|
---|
4374 | Other lines denote key bindings and variable settings.
|
---|
4375 | .PP
|
---|
4376 | The default key-bindings may be changed with an
|
---|
4377 | .I inputrc
|
---|
4378 | file.
|
---|
4379 | Other programs that use this library may add their own commands
|
---|
4380 | and bindings.
|
---|
4381 | .PP
|
---|
4382 | For example, placing
|
---|
4383 | .RS
|
---|
4384 | .PP
|
---|
4385 | M\-Control\-u: universal\-argument
|
---|
4386 | .RE
|
---|
4387 | or
|
---|
4388 | .RS
|
---|
4389 | C\-Meta\-u: universal\-argument
|
---|
4390 | .RE
|
---|
4391 | into the
|
---|
4392 | .I inputrc
|
---|
4393 | would make M\-C\-u execute the readline command
|
---|
4394 | .IR universal\-argument .
|
---|
4395 | .PP
|
---|
4396 | The following symbolic character names are recognized:
|
---|
4397 | .IR RUBOUT ,
|
---|
4398 | .IR DEL ,
|
---|
4399 | .IR ESC ,
|
---|
4400 | .IR LFD ,
|
---|
4401 | .IR NEWLINE ,
|
---|
4402 | .IR RET ,
|
---|
4403 | .IR RETURN ,
|
---|
4404 | .IR SPC ,
|
---|
4405 | .IR SPACE ,
|
---|
4406 | and
|
---|
4407 | .IR TAB .
|
---|
4408 | .PP
|
---|
4409 | In addition to command names, readline allows keys to be bound
|
---|
4410 | to a string that is inserted when the key is pressed (a \fImacro\fP).
|
---|
4411 | .SS "Readline Key Bindings"
|
---|
4412 | .PP
|
---|
4413 | The syntax for controlling key bindings in the
|
---|
4414 | .I inputrc
|
---|
4415 | file is simple. All that is required is the name of the
|
---|
4416 | command or the text of a macro and a key sequence to which
|
---|
4417 | it should be bound. The name may be specified in one of two ways:
|
---|
4418 | as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
|
---|
4419 | prefixes, or as a key sequence.
|
---|
4420 | .PP
|
---|
4421 | When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP,
|
---|
4422 | .I keyname
|
---|
4423 | is the name of a key spelled out in English. For example:
|
---|
4424 | .sp
|
---|
4425 | .RS
|
---|
4426 | Control-u: universal\-argument
|
---|
4427 | .br
|
---|
4428 | Meta-Rubout: backward-kill-word
|
---|
4429 | .br
|
---|
4430 | Control-o: "> output"
|
---|
4431 | .RE
|
---|
4432 | .LP
|
---|
4433 | In the above example,
|
---|
4434 | .I C\-u
|
---|
4435 | is bound to the function
|
---|
4436 | .BR universal\-argument ,
|
---|
4437 | .I M\-DEL
|
---|
4438 | is bound to the function
|
---|
4439 | .BR backward\-kill\-word ,
|
---|
4440 | and
|
---|
4441 | .I C\-o
|
---|
4442 | is bound to run the macro
|
---|
4443 | expressed on the right hand side (that is, to insert the text
|
---|
4444 | .if t \f(CW> output\fP
|
---|
4445 | .if n ``> output''
|
---|
4446 | into the line).
|
---|
4447 | .PP
|
---|
4448 | In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
|
---|
4449 | .B keyseq
|
---|
4450 | differs from
|
---|
4451 | .B keyname
|
---|
4452 | above in that strings denoting
|
---|
4453 | an entire key sequence may be specified by placing the sequence
|
---|
4454 | within double quotes. Some GNU Emacs style key escapes can be
|
---|
4455 | used, as in the following example, but the symbolic character names
|
---|
4456 | are not recognized.
|
---|
4457 | .sp
|
---|
4458 | .RS
|
---|
4459 | "\eC\-u": universal\-argument
|
---|
4460 | .br
|
---|
4461 | "\eC\-x\eC\-r": re\-read\-init\-file
|
---|
4462 | .br
|
---|
4463 | "\ee[11~": "Function Key 1"
|
---|
4464 | .RE
|
---|
4465 | .PP
|
---|
4466 | In this example,
|
---|
4467 | .I C\-u
|
---|
4468 | is again bound to the function
|
---|
4469 | .BR universal\-argument .
|
---|
4470 | .I "C\-x C\-r"
|
---|
4471 | is bound to the function
|
---|
4472 | .BR re\-read\-init\-file ,
|
---|
4473 | and
|
---|
4474 | .I "ESC [ 1 1 ~"
|
---|
4475 | is bound to insert the text
|
---|
4476 | .if t \f(CWFunction Key 1\fP.
|
---|
4477 | .if n ``Function Key 1''.
|
---|
4478 | .PP
|
---|
4479 | The full set of GNU Emacs style escape sequences is
|
---|
4480 | .RS
|
---|
4481 | .PD 0
|
---|
4482 | .TP
|
---|
4483 | .B \eC\-
|
---|
4484 | control prefix
|
---|
4485 | .TP
|
---|
4486 | .B \eM\-
|
---|
4487 | meta prefix
|
---|
4488 | .TP
|
---|
4489 | .B \ee
|
---|
4490 | an escape character
|
---|
4491 | .TP
|
---|
4492 | .B \e\e
|
---|
4493 | backslash
|
---|
4494 | .TP
|
---|
4495 | .B \e"
|
---|
4496 | literal "
|
---|
4497 | .TP
|
---|
4498 | .B \e'
|
---|
4499 | literal '
|
---|
4500 | .RE
|
---|
4501 | .PD
|
---|
4502 | .PP
|
---|
4503 | In addition to the GNU Emacs style escape sequences, a second
|
---|
4504 | set of backslash escapes is available:
|
---|
4505 | .RS
|
---|
4506 | .PD 0
|
---|
4507 | .TP
|
---|
4508 | .B \ea
|
---|
4509 | alert (bell)
|
---|
4510 | .TP
|
---|
4511 | .B \eb
|
---|
4512 | backspace
|
---|
4513 | .TP
|
---|
4514 | .B \ed
|
---|
4515 | delete
|
---|
4516 | .TP
|
---|
4517 | .B \ef
|
---|
4518 | form feed
|
---|
4519 | .TP
|
---|
4520 | .B \en
|
---|
4521 | newline
|
---|
4522 | .TP
|
---|
4523 | .B \er
|
---|
4524 | carriage return
|
---|
4525 | .TP
|
---|
4526 | .B \et
|
---|
4527 | horizontal tab
|
---|
4528 | .TP
|
---|
4529 | .B \ev
|
---|
4530 | vertical tab
|
---|
4531 | .TP
|
---|
4532 | .B \e\fInnn\fP
|
---|
4533 | the eight-bit character whose value is the octal value \fInnn\fP
|
---|
4534 | (one to three digits)
|
---|
4535 | .TP
|
---|
4536 | .B \ex\fIHH\fP
|
---|
4537 | the eight-bit character whose value is the hexadecimal value \fIHH\fP
|
---|
4538 | (one or two hex digits)
|
---|
4539 | .RE
|
---|
4540 | .PD
|
---|
4541 | .PP
|
---|
4542 | When entering the text of a macro, single or double quotes must
|
---|
4543 | be used to indicate a macro definition.
|
---|
4544 | Unquoted text is assumed to be a function name.
|
---|
4545 | In the macro body, the backslash escapes described above are expanded.
|
---|
4546 | Backslash will quote any other character in the macro text,
|
---|
4547 | including " and '.
|
---|
4548 | .PP
|
---|
4549 | .B Bash
|
---|
4550 | allows the current readline key bindings to be displayed or modified
|
---|
4551 | with the
|
---|
4552 | .B bind
|
---|
4553 | builtin command. The editing mode may be switched during interactive
|
---|
4554 | use by using the
|
---|
4555 | .B \-o
|
---|
4556 | option to the
|
---|
4557 | .B set
|
---|
4558 | builtin command (see
|
---|
4559 | .SM
|
---|
4560 | .B SHELL BUILTIN COMMANDS
|
---|
4561 | below).
|
---|
4562 | .SS "Readline Variables"
|
---|
4563 | .PP
|
---|
4564 | Readline has variables that can be used to further customize its
|
---|
4565 | behavior. A variable may be set in the
|
---|
4566 | .I inputrc
|
---|
4567 | file with a statement of the form
|
---|
4568 | .RS
|
---|
4569 | .PP
|
---|
4570 | \fBset\fP \fIvariable\-name\fP \fIvalue\fP
|
---|
4571 | .RE
|
---|
4572 | .PP
|
---|
4573 | Except where noted, readline variables can take the values
|
---|
4574 | .B On
|
---|
4575 | or
|
---|
4576 | .B Off
|
---|
4577 | (without regard to case).
|
---|
4578 | Unrecognized variable names are ignored.
|
---|
4579 | When a variable value is read, empty or null values, "on" (case-insensitive),
|
---|
4580 | and "1" are equivalent to \fBOn\fP. All other values are equivalent to
|
---|
4581 | \fBOff\fP.
|
---|
4582 | The variables and their default values are:
|
---|
4583 | .PP
|
---|
4584 | .PD 0
|
---|
4585 | .TP
|
---|
4586 | .B bell\-style (audible)
|
---|
4587 | Controls what happens when readline wants to ring the terminal bell.
|
---|
4588 | If set to \fBnone\fP, readline never rings the bell. If set to
|
---|
4589 | \fBvisible\fP, readline uses a visible bell if one is available.
|
---|
4590 | If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
|
---|
4591 | .TP
|
---|
4592 | .B bind\-tty\-special\-chars (On)
|
---|
4593 | If set to \fBOn\fP, readline attempts to bind the control characters
|
---|
4594 | treated specially by the kernel's terminal driver to their readline
|
---|
4595 | equivalents.
|
---|
4596 | .TP
|
---|
4597 | .B comment\-begin (``#'')
|
---|
4598 | The string that is inserted when the readline
|
---|
4599 | .B insert\-comment
|
---|
4600 | command is executed.
|
---|
4601 | This command is bound to
|
---|
4602 | .B M\-#
|
---|
4603 | in emacs mode and to
|
---|
4604 | .B #
|
---|
4605 | in vi command mode.
|
---|
4606 | .TP
|
---|
4607 | .B completion\-ignore\-case (Off)
|
---|
4608 | If set to \fBOn\fP, readline performs filename matching and completion
|
---|
4609 | in a case\-insensitive fashion.
|
---|
4610 | .TP
|
---|
4611 | .B completion\-query\-items (100)
|
---|
4612 | This determines when the user is queried about viewing
|
---|
4613 | the number of possible completions
|
---|
4614 | generated by the \fBpossible\-completions\fP command.
|
---|
4615 | It may be set to any integer value greater than or equal to
|
---|
4616 | zero. If the number of possible completions is greater than
|
---|
4617 | or equal to the value of this variable, the user is asked whether
|
---|
4618 | or not he wishes to view them; otherwise they are simply listed
|
---|
4619 | on the terminal.
|
---|
4620 | .TP
|
---|
4621 | .B convert\-meta (On)
|
---|
4622 | If set to \fBOn\fP, readline will convert characters with the
|
---|
4623 | eighth bit set to an ASCII key sequence
|
---|
4624 | by stripping the eighth bit and prefixing an
|
---|
4625 | escape character (in effect, using escape as the \fImeta prefix\fP).
|
---|
4626 | .TP
|
---|
4627 | .B disable\-completion (Off)
|
---|
4628 | If set to \fBOn\fP, readline will inhibit word completion. Completion
|
---|
4629 | characters will be inserted into the line as if they had been
|
---|
4630 | mapped to \fBself-insert\fP.
|
---|
4631 | .TP
|
---|
4632 | .B editing\-mode (emacs)
|
---|
4633 | Controls whether readline begins with a set of key bindings similar
|
---|
4634 | to \fIemacs\fP or \fIvi\fP.
|
---|
4635 | .B editing\-mode
|
---|
4636 | can be set to either
|
---|
4637 | .B emacs
|
---|
4638 | or
|
---|
4639 | .BR vi .
|
---|
4640 | .TP
|
---|
4641 | .B enable\-keypad (Off)
|
---|
4642 | When set to \fBOn\fP, readline will try to enable the application
|
---|
4643 | keypad when it is called. Some systems need this to enable the
|
---|
4644 | arrow keys.
|
---|
4645 | .TP
|
---|
4646 | .B expand\-tilde (Off)
|
---|
4647 | If set to \fBon\fP, tilde expansion is performed when readline
|
---|
4648 | attempts word completion.
|
---|
4649 | .TP
|
---|
4650 | .B history\-preserve\-point (Off)
|
---|
4651 | If set to \fBon\fP, the history code attempts to place point at the
|
---|
4652 | same location on each history line retrieved with \fBprevious-history\fP
|
---|
4653 | or \fBnext-history\fP.
|
---|
4654 | .TP
|
---|
4655 | .B horizontal\-scroll\-mode (Off)
|
---|
4656 | When set to \fBOn\fP, makes readline use a single line for display,
|
---|
4657 | scrolling the input horizontally on a single screen line when it
|
---|
4658 | becomes longer than the screen width rather than wrapping to a new line.
|
---|
4659 | .TP
|
---|
4660 | .B input\-meta (Off)
|
---|
4661 | If set to \fBOn\fP, readline will enable eight-bit input (that is,
|
---|
4662 | it will not strip the high bit from the characters it reads),
|
---|
4663 | regardless of what the terminal claims it can support. The name
|
---|
4664 | .B meta\-flag
|
---|
4665 | is a synonym for this variable.
|
---|
4666 | .TP
|
---|
4667 | .B isearch\-terminators (``C\-[C\-J'')
|
---|
4668 | The string of characters that should terminate an incremental
|
---|
4669 | search without subsequently executing the character as a command.
|
---|
4670 | If this variable has not been given a value, the characters
|
---|
4671 | \fIESC\fP and \fIC\-J\fP will terminate an incremental search.
|
---|
4672 | .TP
|
---|
4673 | .B keymap (emacs)
|
---|
4674 | Set the current readline keymap. The set of valid keymap names is
|
---|
4675 | \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
|
---|
4676 | vi\-command\fP, and
|
---|
4677 | .IR vi\-insert .
|
---|
4678 | \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
|
---|
4679 | equivalent to \fIemacs\-standard\fP. The default value is
|
---|
4680 | .IR emacs ;
|
---|
4681 | the value of
|
---|
4682 | .B editing\-mode
|
---|
4683 | also affects the default keymap.
|
---|
4684 | .TP
|
---|
4685 | .B mark\-directories (On)
|
---|
4686 | If set to \fBOn\fP, completed directory names have a slash
|
---|
4687 | appended.
|
---|
4688 | .TP
|
---|
4689 | .B mark\-modified\-lines (Off)
|
---|
4690 | If set to \fBOn\fP, history lines that have been modified are displayed
|
---|
4691 | with a preceding asterisk (\fB*\fP).
|
---|
4692 | .TP
|
---|
4693 | .B mark\-symlinked\-directories (Off)
|
---|
4694 | If set to \fBOn\fP, completed names which are symbolic links to directories
|
---|
4695 | have a slash appended (subject to the value of
|
---|
4696 | \fBmark\-directories\fP).
|
---|
4697 | .TP
|
---|
4698 | .B match\-hidden\-files (On)
|
---|
4699 | This variable, when set to \fBOn\fP, causes readline to match files whose
|
---|
4700 | names begin with a `.' (hidden files) when performing filename
|
---|
4701 | completion, unless the leading `.' is
|
---|
4702 | supplied by the user in the filename to be completed.
|
---|
4703 | .TP
|
---|
4704 | .B output\-meta (Off)
|
---|
4705 | If set to \fBOn\fP, readline will display characters with the
|
---|
4706 | eighth bit set directly rather than as a meta-prefixed escape
|
---|
4707 | sequence.
|
---|
4708 | .TP
|
---|
4709 | .B page\-completions (On)
|
---|
4710 | If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager
|
---|
4711 | to display a screenful of possible completions at a time.
|
---|
4712 | .TP
|
---|
4713 | .B print\-completions\-horizontally (Off)
|
---|
4714 | If set to \fBOn\fP, readline will display completions with matches
|
---|
4715 | sorted horizontally in alphabetical order, rather than down the screen.
|
---|
4716 | .TP
|
---|
4717 | .B show\-all\-if\-ambiguous (Off)
|
---|
4718 | This alters the default behavior of the completion functions. If
|
---|
4719 | set to
|
---|
4720 | .BR on ,
|
---|
4721 | words which have more than one possible completion cause the
|
---|
4722 | matches to be listed immediately instead of ringing the bell.
|
---|
4723 | .TP
|
---|
4724 | .B show\-all\-if\-unmodified (Off)
|
---|
4725 | This alters the default behavior of the completion functions in
|
---|
4726 | a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
|
---|
4727 | If set to
|
---|
4728 | .BR on ,
|
---|
4729 | words which have more than one possible completion without any
|
---|
4730 | possible partial completion (the possible completions don't share
|
---|
4731 | a common prefix) cause the matches to be listed immediately instead
|
---|
4732 | of ringing the bell.
|
---|
4733 | .TP
|
---|
4734 | .B visible\-stats (Off)
|
---|
4735 | If set to \fBOn\fP, a character denoting a file's type as reported
|
---|
4736 | by \fIstat\fP(2) is appended to the filename when listing possible
|
---|
4737 | completions.
|
---|
4738 | .PD
|
---|
4739 | .SS "Readline Conditional Constructs"
|
---|
4740 | .PP
|
---|
4741 | Readline implements a facility similar in spirit to the conditional
|
---|
4742 | compilation features of the C preprocessor which allows key
|
---|
4743 | bindings and variable settings to be performed as the result
|
---|
4744 | of tests. There are four parser directives used.
|
---|
4745 | .IP \fB$if\fP
|
---|
4746 | The
|
---|
4747 | .B $if
|
---|
4748 | construct allows bindings to be made based on the
|
---|
4749 | editing mode, the terminal being used, or the application using
|
---|
4750 | readline. The text of the test extends to the end of the line;
|
---|
4751 | no characters are required to isolate it.
|
---|
4752 | .RS
|
---|
4753 | .IP \fBmode\fP
|
---|
4754 | The \fBmode=\fP form of the \fB$if\fP directive is used to test
|
---|
4755 | whether readline is in emacs or vi mode.
|
---|
4756 | This may be used in conjunction
|
---|
4757 | with the \fBset keymap\fP command, for instance, to set bindings in
|
---|
4758 | the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
|
---|
4759 | readline is starting out in emacs mode.
|
---|
4760 | .IP \fBterm\fP
|
---|
4761 | The \fBterm=\fP form may be used to include terminal-specific
|
---|
4762 | key bindings, perhaps to bind the key sequences output by the
|
---|
4763 | terminal's function keys. The word on the right side of the
|
---|
4764 | .B =
|
---|
4765 | is tested against the both full name of the terminal and the portion
|
---|
4766 | of the terminal name before the first \fB\-\fP. This allows
|
---|
4767 | .I sun
|
---|
4768 | to match both
|
---|
4769 | .I sun
|
---|
4770 | and
|
---|
4771 | .IR sun\-cmd ,
|
---|
4772 | for instance.
|
---|
4773 | .IP \fBapplication\fP
|
---|
4774 | The \fBapplication\fP construct is used to include
|
---|
4775 | application-specific settings. Each program using the readline
|
---|
4776 | library sets the \fIapplication name\fP, and an initialization
|
---|
4777 | file can test for a particular value.
|
---|
4778 | This could be used to bind key sequences to functions useful for
|
---|
4779 | a specific program. For instance, the following command adds a
|
---|
4780 | key sequence that quotes the current or previous word in Bash:
|
---|
4781 | .sp 1
|
---|
4782 | .RS
|
---|
4783 | .nf
|
---|
4784 | \fB$if\fP Bash
|
---|
4785 | # Quote the current or previous word
|
---|
4786 | "\eC\-xq": "\eeb\e"\eef\e""
|
---|
4787 | \fB$endif\fP
|
---|
4788 | .fi
|
---|
4789 | .RE
|
---|
4790 | .RE
|
---|
4791 | .IP \fB$endif\fP
|
---|
4792 | This command, as seen in the previous example, terminates an
|
---|
4793 | \fB$if\fP command.
|
---|
4794 | .IP \fB$else\fP
|
---|
4795 | Commands in this branch of the \fB$if\fP directive are executed if
|
---|
4796 | the test fails.
|
---|
4797 | .IP \fB$include\fP
|
---|
4798 | This directive takes a single filename as an argument and reads commands
|
---|
4799 | and bindings from that file. For example, the following directive
|
---|
4800 | would read \fI/etc/inputrc\fP:
|
---|
4801 | .sp 1
|
---|
4802 | .RS
|
---|
4803 | .nf
|
---|
4804 | \fB$include\fP \^ \fI/etc/inputrc\fP
|
---|
4805 | .fi
|
---|
4806 | .RE
|
---|
4807 | .SS Searching
|
---|
4808 | .PP
|
---|
4809 | Readline provides commands for searching through the command history
|
---|
4810 | (see
|
---|
4811 | .SM
|
---|
4812 | .B HISTORY
|
---|
4813 | below) for lines containing a specified string.
|
---|
4814 | There are two search modes:
|
---|
4815 | .I incremental
|
---|
4816 | and
|
---|
4817 | .IR non-incremental .
|
---|
4818 | .PP
|
---|
4819 | Incremental searches begin before the user has finished typing the
|
---|
4820 | search string.
|
---|
4821 | As each character of the search string is typed, readline displays
|
---|
4822 | the next entry from the history matching the string typed so far.
|
---|
4823 | An incremental search requires only as many characters as needed to
|
---|
4824 | find the desired history entry.
|
---|
4825 | The characters present in the value of the \fBisearch-terminators\fP
|
---|
4826 | variable are used to terminate an incremental search.
|
---|
4827 | If that variable has not been assigned a value the Escape and
|
---|
4828 | Control-J characters will terminate an incremental search.
|
---|
4829 | Control-G will abort an incremental search and restore the original
|
---|
4830 | line.
|
---|
4831 | When the search is terminated, the history entry containing the
|
---|
4832 | search string becomes the current line.
|
---|
4833 | .PP
|
---|
4834 | To find other matching entries in the history list, type Control-S or
|
---|
4835 | Control-R as appropriate.
|
---|
4836 | This will search backward or forward in the history for the next
|
---|
4837 | entry matching the search string typed so far.
|
---|
4838 | Any other key sequence bound to a readline command will terminate
|
---|
4839 | the search and execute that command.
|
---|
4840 | For instance, a \fInewline\fP will terminate the search and accept
|
---|
4841 | the line, thereby executing the command from the history list.
|
---|
4842 | .PP
|
---|
4843 | Readline remembers the last incremental search string. If two
|
---|
4844 | Control-Rs are typed without any intervening characters defining a
|
---|
4845 | new search string, any remembered search string is used.
|
---|
4846 | .PP
|
---|
4847 | Non-incremental searches read the entire search string before starting
|
---|
4848 | to search for matching history lines. The search string may be
|
---|
4849 | typed by the user or be part of the contents of the current line.
|
---|
4850 | .SS "Readline Command Names"
|
---|
4851 | .PP
|
---|
4852 | The following is a list of the names of the commands and the default
|
---|
4853 | key sequences to which they are bound.
|
---|
4854 | Command names without an accompanying key sequence are unbound by default.
|
---|
4855 | In the following descriptions, \fIpoint\fP refers to the current cursor
|
---|
4856 | position, and \fImark\fP refers to a cursor position saved by the
|
---|
4857 | \fBset\-mark\fP command.
|
---|
4858 | The text between the point and mark is referred to as the \fIregion\fP.
|
---|
4859 | .SS Commands for Moving
|
---|
4860 | .PP
|
---|
4861 | .PD 0
|
---|
4862 | .TP
|
---|
4863 | .B beginning\-of\-line (C\-a)
|
---|
4864 | Move to the start of the current line.
|
---|
4865 | .TP
|
---|
4866 | .B end\-of\-line (C\-e)
|
---|
4867 | Move to the end of the line.
|
---|
4868 | .TP
|
---|
4869 | .B forward\-char (C\-f)
|
---|
4870 | Move forward a character.
|
---|
4871 | .TP
|
---|
4872 | .B backward\-char (C\-b)
|
---|
4873 | Move back a character.
|
---|
4874 | .TP
|
---|
4875 | .B forward\-word (M\-f)
|
---|
4876 | Move forward to the end of the next word. Words are composed of
|
---|
4877 | alphanumeric characters (letters and digits).
|
---|
4878 | .TP
|
---|
4879 | .B backward\-word (M\-b)
|
---|
4880 | Move back to the start of the current or previous word. Words are
|
---|
4881 | composed of alphanumeric characters (letters and digits).
|
---|
4882 | .TP
|
---|
4883 | .B clear\-screen (C\-l)
|
---|
4884 | Clear the screen leaving the current line at the top of the screen.
|
---|
4885 | With an argument, refresh the current line without clearing the
|
---|
4886 | screen.
|
---|
4887 | .TP
|
---|
4888 | .B redraw\-current\-line
|
---|
4889 | Refresh the current line.
|
---|
4890 | .PD
|
---|
4891 | .SS Commands for Manipulating the History
|
---|
4892 | .PP
|
---|
4893 | .PD 0
|
---|
4894 | .TP
|
---|
4895 | .B accept\-line (Newline, Return)
|
---|
4896 | Accept the line regardless of where the cursor is. If this line is
|
---|
4897 | non-empty, add it to the history list according to the state of the
|
---|
4898 | .SM
|
---|
4899 | .B HISTCONTROL
|
---|
4900 | variable. If the line is a modified history
|
---|
4901 | line, then restore the history line to its original state.
|
---|
4902 | .TP
|
---|
4903 | .B previous\-history (C\-p)
|
---|
4904 | Fetch the previous command from the history list, moving back in
|
---|
4905 | the list.
|
---|
4906 | .TP
|
---|
4907 | .B next\-history (C\-n)
|
---|
4908 | Fetch the next command from the history list, moving forward in the
|
---|
4909 | list.
|
---|
4910 | .TP
|
---|
4911 | .B beginning\-of\-history (M\-<)
|
---|
4912 | Move to the first line in the history.
|
---|
4913 | .TP
|
---|
4914 | .B end\-of\-history (M\->)
|
---|
4915 | Move to the end of the input history, i.e., the line currently being
|
---|
4916 | entered.
|
---|
4917 | .TP
|
---|
4918 | .B reverse\-search\-history (C\-r)
|
---|
4919 | Search backward starting at the current line and moving `up' through
|
---|
4920 | the history as necessary. This is an incremental search.
|
---|
4921 | .TP
|
---|
4922 | .B forward\-search\-history (C\-s)
|
---|
4923 | Search forward starting at the current line and moving `down' through
|
---|
4924 | the history as necessary. This is an incremental search.
|
---|
4925 | .TP
|
---|
4926 | .B non\-incremental\-reverse\-search\-history (M\-p)
|
---|
4927 | Search backward through the history starting at the current line
|
---|
4928 | using a non-incremental search for a string supplied by the user.
|
---|
4929 | .TP
|
---|
4930 | .B non\-incremental\-forward\-search\-history (M\-n)
|
---|
4931 | Search forward through the history using a non-incremental search for
|
---|
4932 | a string supplied by the user.
|
---|
4933 | .TP
|
---|
4934 | .B history\-search\-forward
|
---|
4935 | Search forward through the history for the string of characters
|
---|
4936 | between the start of the current line and the point.
|
---|
4937 | This is a non-incremental search.
|
---|
4938 | .TP
|
---|
4939 | .B history\-search\-backward
|
---|
4940 | Search backward through the history for the string of characters
|
---|
4941 | between the start of the current line and the point.
|
---|
4942 | This is a non-incremental search.
|
---|
4943 | .TP
|
---|
4944 | .B yank\-nth\-arg (M\-C\-y)
|
---|
4945 | Insert the first argument to the previous command (usually
|
---|
4946 | the second word on the previous line) at point.
|
---|
4947 | With an argument
|
---|
4948 | .IR n ,
|
---|
4949 | insert the \fIn\fPth word from the previous command (the words
|
---|
4950 | in the previous command begin with word 0). A negative argument
|
---|
4951 | inserts the \fIn\fPth word from the end of the previous command.
|
---|
4952 | Once the argument \fIn\fP is computed, the argument is extracted
|
---|
4953 | as if the "!\fIn\fP" history expansion had been specified.
|
---|
4954 | .TP
|
---|
4955 | .B
|
---|
4956 | yank\-last\-arg (M\-.\^, M\-_\^)
|
---|
4957 | Insert the last argument to the previous command (the last word of
|
---|
4958 | the previous history entry). With an argument,
|
---|
4959 | behave exactly like \fByank\-nth\-arg\fP.
|
---|
4960 | Successive calls to \fByank\-last\-arg\fP move back through the history
|
---|
4961 | list, inserting the last argument of each line in turn.
|
---|
4962 | The history expansion facilities are used to extract the last argument,
|
---|
4963 | as if the "!$" history expansion had been specified.
|
---|
4964 | .TP
|
---|
4965 | .B shell\-expand\-line (M\-C\-e)
|
---|
4966 | Expand the line as the shell does. This
|
---|
4967 | performs alias and history expansion as well as all of the shell
|
---|
4968 | word expansions. See
|
---|
4969 | .SM
|
---|
4970 | .B HISTORY EXPANSION
|
---|
4971 | below for a description of history expansion.
|
---|
4972 | .TP
|
---|
4973 | .B history\-expand\-line (M\-^)
|
---|
4974 | Perform history expansion on the current line.
|
---|
4975 | See
|
---|
4976 | .SM
|
---|
4977 | .B HISTORY EXPANSION
|
---|
4978 | below for a description of history expansion.
|
---|
4979 | .TP
|
---|
4980 | .B magic\-space
|
---|
4981 | Perform history expansion on the current line and insert a space.
|
---|
4982 | See
|
---|
4983 | .SM
|
---|
4984 | .B HISTORY EXPANSION
|
---|
4985 | below for a description of history expansion.
|
---|
4986 | .TP
|
---|
4987 | .B alias\-expand\-line
|
---|
4988 | Perform alias expansion on the current line.
|
---|
4989 | See
|
---|
4990 | .SM
|
---|
4991 | .B ALIASES
|
---|
4992 | above for a description of alias expansion.
|
---|
4993 | .TP
|
---|
4994 | .B history\-and\-alias\-expand\-line
|
---|
4995 | Perform history and alias expansion on the current line.
|
---|
4996 | .TP
|
---|
4997 | .B insert\-last\-argument (M\-.\^, M\-_\^)
|
---|
4998 | A synonym for \fByank\-last\-arg\fP.
|
---|
4999 | .TP
|
---|
5000 | .B operate\-and\-get\-next (C\-o)
|
---|
5001 | Accept the current line for execution and fetch the next line
|
---|
5002 | relative to the current line from the history for editing. Any
|
---|
5003 | argument is ignored.
|
---|
5004 | .TP
|
---|
5005 | .B edit\-and\-execute\-command (C\-xC\-e)
|
---|
5006 | Invoke an editor on the current command line, and execute the result as shell
|
---|
5007 | commands.
|
---|
5008 | \fBBash\fP attempts to invoke
|
---|
5009 | .SM
|
---|
5010 | .BR $FCEDIT ,
|
---|
5011 | .SM
|
---|
5012 | .BR $EDITOR ,
|
---|
5013 | and \fIemacs\fP as the editor, in that order.
|
---|
5014 | .PD
|
---|
5015 | .SS Commands for Changing Text
|
---|
5016 | .PP
|
---|
5017 | .PD 0
|
---|
5018 | .TP
|
---|
5019 | .B delete\-char (C\-d)
|
---|
5020 | Delete the character at point. If point is at the
|
---|
5021 | beginning of the line, there are no characters in the line, and
|
---|
5022 | the last character typed was not bound to \fBdelete\-char\fP,
|
---|
5023 | then return
|
---|
5024 | .SM
|
---|
5025 | .BR EOF .
|
---|
5026 | .TP
|
---|
5027 | .B backward\-delete\-char (Rubout)
|
---|
5028 | Delete the character behind the cursor. When given a numeric argument,
|
---|
5029 | save the deleted text on the kill ring.
|
---|
5030 | .TP
|
---|
5031 | .B forward\-backward\-delete\-char
|
---|
5032 | Delete the character under the cursor, unless the cursor is at the
|
---|
5033 | end of the line, in which case the character behind the cursor is
|
---|
5034 | deleted.
|
---|
5035 | .TP
|
---|
5036 | .B quoted\-insert (C\-q, C\-v)
|
---|
5037 | Add the next character typed to the line verbatim. This is
|
---|
5038 | how to insert characters like \fBC\-q\fP, for example.
|
---|
5039 | .TP
|
---|
5040 | .B tab\-insert (C\-v TAB)
|
---|
5041 | Insert a tab character.
|
---|
5042 | .TP
|
---|
5043 | .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
|
---|
5044 | Insert the character typed.
|
---|
5045 | .TP
|
---|
5046 | .B transpose\-chars (C\-t)
|
---|
5047 | Drag the character before point forward over the character at point,
|
---|
5048 | moving point forward as well.
|
---|
5049 | If point is at the end of the line, then this transposes
|
---|
5050 | the two characters before point.
|
---|
5051 | Negative arguments have no effect.
|
---|
5052 | .TP
|
---|
5053 | .B transpose\-words (M\-t)
|
---|
5054 | Drag the word before point past the word after point,
|
---|
5055 | moving point over that word as well.
|
---|
5056 | If point is at the end of the line, this transposes
|
---|
5057 | the last two words on the line.
|
---|
5058 | .TP
|
---|
5059 | .B upcase\-word (M\-u)
|
---|
5060 | Uppercase the current (or following) word. With a negative argument,
|
---|
5061 | uppercase the previous word, but do not move point.
|
---|
5062 | .TP
|
---|
5063 | .B downcase\-word (M\-l)
|
---|
5064 | Lowercase the current (or following) word. With a negative argument,
|
---|
5065 | lowercase the previous word, but do not move point.
|
---|
5066 | .TP
|
---|
5067 | .B capitalize\-word (M\-c)
|
---|
5068 | Capitalize the current (or following) word. With a negative argument,
|
---|
5069 | capitalize the previous word, but do not move point.
|
---|
5070 | .TP
|
---|
5071 | .B overwrite\-mode
|
---|
5072 | Toggle overwrite mode. With an explicit positive numeric argument,
|
---|
5073 | switches to overwrite mode. With an explicit non-positive numeric
|
---|
5074 | argument, switches to insert mode. This command affects only
|
---|
5075 | \fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
|
---|
5076 | Each call to \fIreadline()\fP starts in insert mode.
|
---|
5077 | In overwrite mode, characters bound to \fBself\-insert\fP replace
|
---|
5078 | the text at point rather than pushing the text to the right.
|
---|
5079 | Characters bound to \fBbackward\-delete\-char\fP replace the character
|
---|
5080 | before point with a space. By default, this command is unbound.
|
---|
5081 | .PD
|
---|
5082 | .SS Killing and Yanking
|
---|
5083 | .PP
|
---|
5084 | .PD 0
|
---|
5085 | .TP
|
---|
5086 | .B kill\-line (C\-k)
|
---|
5087 | Kill the text from point to the end of the line.
|
---|
5088 | .TP
|
---|
5089 | .B backward\-kill\-line (C\-x Rubout)
|
---|
5090 | Kill backward to the beginning of the line.
|
---|
5091 | .TP
|
---|
5092 | .B unix\-line\-discard (C\-u)
|
---|
5093 | Kill backward from point to the beginning of the line.
|
---|
5094 | The killed text is saved on the kill-ring.
|
---|
5095 | .\" There is no real difference between this and backward-kill-line
|
---|
5096 | .TP
|
---|
5097 | .B kill\-whole\-line
|
---|
5098 | Kill all characters on the current line, no matter where point is.
|
---|
5099 | .TP
|
---|
5100 | .B kill\-word (M\-d)
|
---|
5101 | Kill from point to the end of the current word, or if between
|
---|
5102 | words, to the end of the next word.
|
---|
5103 | Word boundaries are the same as those used by \fBforward\-word\fP.
|
---|
5104 | .TP
|
---|
5105 | .B backward\-kill\-word (M\-Rubout)
|
---|
5106 | Kill the word behind point.
|
---|
5107 | Word boundaries are the same as those used by \fBbackward\-word\fP.
|
---|
5108 | .TP
|
---|
5109 | .B unix\-word\-rubout (C\-w)
|
---|
5110 | Kill the word behind point, using white space as a word boundary.
|
---|
5111 | The killed text is saved on the kill-ring.
|
---|
5112 | .TP
|
---|
5113 | .B unix\-filename\-rubout
|
---|
5114 | Kill the word behind point, using white space and the slash character
|
---|
5115 | as the word boundaries.
|
---|
5116 | The killed text is saved on the kill-ring.
|
---|
5117 | .TP
|
---|
5118 | .B delete\-horizontal\-space (M\-\e)
|
---|
5119 | Delete all spaces and tabs around point.
|
---|
5120 | .TP
|
---|
5121 | .B kill\-region
|
---|
5122 | Kill the text in the current region.
|
---|
5123 | .TP
|
---|
5124 | .B copy\-region\-as\-kill
|
---|
5125 | Copy the text in the region to the kill buffer.
|
---|
5126 | .TP
|
---|
5127 | .B copy\-backward\-word
|
---|
5128 | Copy the word before point to the kill buffer.
|
---|
5129 | The word boundaries are the same as \fBbackward\-word\fP.
|
---|
5130 | .TP
|
---|
5131 | .B copy\-forward\-word
|
---|
5132 | Copy the word following point to the kill buffer.
|
---|
5133 | The word boundaries are the same as \fBforward\-word\fP.
|
---|
5134 | .TP
|
---|
5135 | .B yank (C\-y)
|
---|
5136 | Yank the top of the kill ring into the buffer at point.
|
---|
5137 | .TP
|
---|
5138 | .B yank\-pop (M\-y)
|
---|
5139 | Rotate the kill ring, and yank the new top. Only works following
|
---|
5140 | .B yank
|
---|
5141 | or
|
---|
5142 | .BR yank\-pop .
|
---|
5143 | .PD
|
---|
5144 | .SS Numeric Arguments
|
---|
5145 | .PP
|
---|
5146 | .PD 0
|
---|
5147 | .TP
|
---|
5148 | .B digit\-argument (M\-0, M\-1, ..., M\-\-)
|
---|
5149 | Add this digit to the argument already accumulating, or start a new
|
---|
5150 | argument. M\-\- starts a negative argument.
|
---|
5151 | .TP
|
---|
5152 | .B universal\-argument
|
---|
5153 | This is another way to specify an argument.
|
---|
5154 | If this command is followed by one or more digits, optionally with a
|
---|
5155 | leading minus sign, those digits define the argument.
|
---|
5156 | If the command is followed by digits, executing
|
---|
5157 | .B universal\-argument
|
---|
5158 | again ends the numeric argument, but is otherwise ignored.
|
---|
5159 | As a special case, if this command is immediately followed by a
|
---|
5160 | character that is neither a digit or minus sign, the argument count
|
---|
5161 | for the next command is multiplied by four.
|
---|
5162 | The argument count is initially one, so executing this function the
|
---|
5163 | first time makes the argument count four, a second time makes the
|
---|
5164 | argument count sixteen, and so on.
|
---|
5165 | .PD
|
---|
5166 | .SS Completing
|
---|
5167 | .PP
|
---|
5168 | .PD 0
|
---|
5169 | .TP
|
---|
5170 | .B complete (TAB)
|
---|
5171 | Attempt to perform completion on the text before point.
|
---|
5172 | .B Bash
|
---|
5173 | attempts completion treating the text as a variable (if the
|
---|
5174 | text begins with \fB$\fP), username (if the text begins with
|
---|
5175 | \fB~\fP), hostname (if the text begins with \fB@\fP), or
|
---|
5176 | command (including aliases and functions) in turn. If none
|
---|
5177 | of these produces a match, filename completion is attempted.
|
---|
5178 | .TP
|
---|
5179 | .B possible\-completions (M\-?)
|
---|
5180 | List the possible completions of the text before point.
|
---|
5181 | .TP
|
---|
5182 | .B insert\-completions (M\-*)
|
---|
5183 | Insert all completions of the text before point
|
---|
5184 | that would have been generated by
|
---|
5185 | \fBpossible\-completions\fP.
|
---|
5186 | .TP
|
---|
5187 | .B menu\-complete
|
---|
5188 | Similar to \fBcomplete\fP, but replaces the word to be completed
|
---|
5189 | with a single match from the list of possible completions.
|
---|
5190 | Repeated execution of \fBmenu\-complete\fP steps through the list
|
---|
5191 | of possible completions, inserting each match in turn.
|
---|
5192 | At the end of the list of completions, the bell is rung
|
---|
5193 | (subject to the setting of \fBbell\-style\fP)
|
---|
5194 | and the original text is restored.
|
---|
5195 | An argument of \fIn\fP moves \fIn\fP positions forward in the list
|
---|
5196 | of matches; a negative argument may be used to move backward
|
---|
5197 | through the list.
|
---|
5198 | This command is intended to be bound to \fBTAB\fP, but is unbound
|
---|
5199 | by default.
|
---|
5200 | .TP
|
---|
5201 | .B delete\-char\-or\-list
|
---|
5202 | Deletes the character under the cursor if not at the beginning or
|
---|
5203 | end of the line (like \fBdelete\-char\fP).
|
---|
5204 | If at the end of the line, behaves identically to
|
---|
5205 | \fBpossible\-completions\fP.
|
---|
5206 | This command is unbound by default.
|
---|
5207 | .TP
|
---|
5208 | .B complete\-filename (M\-/)
|
---|
5209 | Attempt filename completion on the text before point.
|
---|
5210 | .TP
|
---|
5211 | .B possible\-filename\-completions (C\-x /)
|
---|
5212 | List the possible completions of the text before point,
|
---|
5213 | treating it as a filename.
|
---|
5214 | .TP
|
---|
5215 | .B complete\-username (M\-~)
|
---|
5216 | Attempt completion on the text before point, treating
|
---|
5217 | it as a username.
|
---|
5218 | .TP
|
---|
5219 | .B possible\-username\-completions (C\-x ~)
|
---|
5220 | List the possible completions of the text before point,
|
---|
5221 | treating it as a username.
|
---|
5222 | .TP
|
---|
5223 | .B complete\-variable (M\-$)
|
---|
5224 | Attempt completion on the text before point, treating
|
---|
5225 | it as a shell variable.
|
---|
5226 | .TP
|
---|
5227 | .B possible\-variable\-completions (C\-x $)
|
---|
5228 | List the possible completions of the text before point,
|
---|
5229 | treating it as a shell variable.
|
---|
5230 | .TP
|
---|
5231 | .B complete\-hostname (M\-@)
|
---|
5232 | Attempt completion on the text before point, treating
|
---|
5233 | it as a hostname.
|
---|
5234 | .TP
|
---|
5235 | .B possible\-hostname\-completions (C\-x @)
|
---|
5236 | List the possible completions of the text before point,
|
---|
5237 | treating it as a hostname.
|
---|
5238 | .TP
|
---|
5239 | .B complete\-command (M\-!)
|
---|
5240 | Attempt completion on the text before point, treating
|
---|
5241 | it as a command name. Command completion attempts to
|
---|
5242 | match the text against aliases, reserved words, shell
|
---|
5243 | functions, shell builtins, and finally executable filenames,
|
---|
5244 | in that order.
|
---|
5245 | .TP
|
---|
5246 | .B possible\-command\-completions (C\-x !)
|
---|
5247 | List the possible completions of the text before point,
|
---|
5248 | treating it as a command name.
|
---|
5249 | .TP
|
---|
5250 | .B dynamic\-complete\-history (M\-TAB)
|
---|
5251 | Attempt completion on the text before point, comparing
|
---|
5252 | the text against lines from the history list for possible
|
---|
5253 | completion matches.
|
---|
5254 | .TP
|
---|
5255 | .B complete\-into\-braces (M\-{)
|
---|
5256 | Perform filename completion and insert the list of possible completions
|
---|
5257 | enclosed within braces so the list is available to the shell (see
|
---|
5258 | .B Brace Expansion
|
---|
5259 | above).
|
---|
5260 | .PD
|
---|
5261 | .SS Keyboard Macros
|
---|
5262 | .PP
|
---|
5263 | .PD 0
|
---|
5264 | .TP
|
---|
5265 | .B start\-kbd\-macro (C\-x (\^)
|
---|
5266 | Begin saving the characters typed into the current keyboard macro.
|
---|
5267 | .TP
|
---|
5268 | .B end\-kbd\-macro (C\-x )\^)
|
---|
5269 | Stop saving the characters typed into the current keyboard macro
|
---|
5270 | and store the definition.
|
---|
5271 | .TP
|
---|
5272 | .B call\-last\-kbd\-macro (C\-x e)
|
---|
5273 | Re-execute the last keyboard macro defined, by making the characters
|
---|
5274 | in the macro appear as if typed at the keyboard.
|
---|
5275 | .PD
|
---|
5276 | .SS Miscellaneous
|
---|
5277 | .PP
|
---|
5278 | .PD 0
|
---|
5279 | .TP
|
---|
5280 | .B re\-read\-init\-file (C\-x C\-r)
|
---|
5281 | Read in the contents of the \fIinputrc\fP file, and incorporate
|
---|
5282 | any bindings or variable assignments found there.
|
---|
5283 | .TP
|
---|
5284 | .B abort (C\-g)
|
---|
5285 | Abort the current editing command and
|
---|
5286 | ring the terminal's bell (subject to the setting of
|
---|
5287 | .BR bell\-style ).
|
---|
5288 | .TP
|
---|
5289 | .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
|
---|
5290 | If the metafied character \fIx\fP is lowercase, run the command
|
---|
5291 | that is bound to the corresponding uppercase character.
|
---|
5292 | .TP
|
---|
5293 | .B prefix\-meta (ESC)
|
---|
5294 | Metafy the next character typed.
|
---|
5295 | .SM
|
---|
5296 | .B ESC
|
---|
5297 | .B f
|
---|
5298 | is equivalent to
|
---|
5299 | .BR Meta\-f .
|
---|
5300 | .TP
|
---|
5301 | .B undo (C\-_, C\-x C\-u)
|
---|
5302 | Incremental undo, separately remembered for each line.
|
---|
5303 | .TP
|
---|
5304 | .B revert\-line (M\-r)
|
---|
5305 | Undo all changes made to this line. This is like executing the
|
---|
5306 | .B undo
|
---|
5307 | command enough times to return the line to its initial state.
|
---|
5308 | .TP
|
---|
5309 | .B tilde\-expand (M\-&)
|
---|
5310 | Perform tilde expansion on the current word.
|
---|
5311 | .TP
|
---|
5312 | .B set\-mark (C\-@, M\-<space>)
|
---|
5313 | Set the mark to the point. If a
|
---|
5314 | numeric argument is supplied, the mark is set to that position.
|
---|
5315 | .TP
|
---|
5316 | .B exchange\-point\-and\-mark (C\-x C\-x)
|
---|
5317 | Swap the point with the mark. The current cursor position is set to
|
---|
5318 | the saved position, and the old cursor position is saved as the mark.
|
---|
5319 | .TP
|
---|
5320 | .B character\-search (C\-])
|
---|
5321 | A character is read and point is moved to the next occurrence of that
|
---|
5322 | character. A negative count searches for previous occurrences.
|
---|
5323 | .TP
|
---|
5324 | .B character\-search\-backward (M\-C\-])
|
---|
5325 | A character is read and point is moved to the previous occurrence of that
|
---|
5326 | character. A negative count searches for subsequent occurrences.
|
---|
5327 | .TP
|
---|
5328 | .B insert\-comment (M\-#)
|
---|
5329 | Without a numeric argument, the value of the readline
|
---|
5330 | .B comment\-begin
|
---|
5331 | variable is inserted at the beginning of the current line.
|
---|
5332 | If a numeric argument is supplied, this command acts as a toggle: if
|
---|
5333 | the characters at the beginning of the line do not match the value
|
---|
5334 | of \fBcomment\-begin\fP, the value is inserted, otherwise
|
---|
5335 | the characters in \fBcomment-begin\fP are deleted from the beginning of
|
---|
5336 | the line.
|
---|
5337 | In either case, the line is accepted as if a newline had been typed.
|
---|
5338 | The default value of
|
---|
5339 | \fBcomment\-begin\fP causes this command to make the current line
|
---|
5340 | a shell comment.
|
---|
5341 | If a numeric argument causes the comment character to be removed, the line
|
---|
5342 | will be executed by the shell.
|
---|
5343 | .TP
|
---|
5344 | .B glob\-complete\-word (M\-g)
|
---|
5345 | The word before point is treated as a pattern for pathname expansion,
|
---|
5346 | with an asterisk implicitly appended. This pattern is used to
|
---|
5347 | generate a list of matching file names for possible completions.
|
---|
5348 | .TP
|
---|
5349 | .B glob\-expand\-word (C\-x *)
|
---|
5350 | The word before point is treated as a pattern for pathname expansion,
|
---|
5351 | and the list of matching file names is inserted, replacing the word.
|
---|
5352 | If a numeric argument is supplied, an asterisk is appended before
|
---|
5353 | pathname expansion.
|
---|
5354 | .TP
|
---|
5355 | .B glob\-list\-expansions (C\-x g)
|
---|
5356 | The list of expansions that would have been generated by
|
---|
5357 | .B glob\-expand\-word
|
---|
5358 | is displayed, and the line is redrawn.
|
---|
5359 | If a numeric argument is supplied, an asterisk is appended before
|
---|
5360 | pathname expansion.
|
---|
5361 | .TP
|
---|
5362 | .B dump\-functions
|
---|
5363 | Print all of the functions and their key bindings to the
|
---|
5364 | readline output stream. If a numeric argument is supplied,
|
---|
5365 | the output is formatted in such a way that it can be made part
|
---|
5366 | of an \fIinputrc\fP file.
|
---|
5367 | .TP
|
---|
5368 | .B dump\-variables
|
---|
5369 | Print all of the settable readline variables and their values to the
|
---|
5370 | readline output stream. If a numeric argument is supplied,
|
---|
5371 | the output is formatted in such a way that it can be made part
|
---|
5372 | of an \fIinputrc\fP file.
|
---|
5373 | .TP
|
---|
5374 | .B dump\-macros
|
---|
5375 | Print all of the readline key sequences bound to macros and the
|
---|
5376 | strings they output. If a numeric argument is supplied,
|
---|
5377 | the output is formatted in such a way that it can be made part
|
---|
5378 | of an \fIinputrc\fP file.
|
---|
5379 | .TP
|
---|
5380 | .B display\-shell\-version (C\-x C\-v)
|
---|
5381 | Display version information about the current instance of
|
---|
5382 | .BR bash .
|
---|
5383 | .PD
|
---|
5384 | .SS Programmable Completion
|
---|
5385 | .PP
|
---|
5386 | When word completion is attempted for an argument to a command for
|
---|
5387 | which a completion specification (a \fIcompspec\fP) has been defined
|
---|
5388 | using the \fBcomplete\fP builtin (see
|
---|
5389 | .SM
|
---|
5390 | .B "SHELL BUILTIN COMMANDS"
|
---|
5391 | below), the programmable completion facilities are invoked.
|
---|
5392 | .PP
|
---|
5393 | First, the command name is identified.
|
---|
5394 | If a compspec has been defined for that command, the
|
---|
5395 | compspec is used to generate the list of possible completions for the word.
|
---|
5396 | If the command word is a full pathname, a compspec for the full
|
---|
5397 | pathname is searched for first.
|
---|
5398 | If no compspec is found for the full pathname, an attempt is made to
|
---|
5399 | find a compspec for the portion following the final slash.
|
---|
5400 | .PP
|
---|
5401 | Once a compspec has been found, it is used to generate the list of
|
---|
5402 | matching words.
|
---|
5403 | If a compspec is not found, the default \fBbash\fP completion as
|
---|
5404 | described above under \fBCompleting\fP is performed.
|
---|
5405 | .PP
|
---|
5406 | First, the actions specified by the compspec are used.
|
---|
5407 | Only matches which are prefixed by the word being completed are
|
---|
5408 | returned.
|
---|
5409 | When the
|
---|
5410 | .B \-f
|
---|
5411 | or
|
---|
5412 | .B \-d
|
---|
5413 | option is used for filename or directory name completion, the shell
|
---|
5414 | variable
|
---|
5415 | .SM
|
---|
5416 | .B FIGNORE
|
---|
5417 | is used to filter the matches.
|
---|
5418 | .PP
|
---|
5419 | Any completions specified by a filename expansion pattern to the
|
---|
5420 | \fB\-G\fP option are generated next.
|
---|
5421 | The words generated by the pattern need not match the word
|
---|
5422 | being completed.
|
---|
5423 | The
|
---|
5424 | .SM
|
---|
5425 | .B GLOBIGNORE
|
---|
5426 | shell variable is not used to filter the matches, but the
|
---|
5427 | .SM
|
---|
5428 | .B FIGNORE
|
---|
5429 | variable is used.
|
---|
5430 | .PP
|
---|
5431 | Next, the string specified as the argument to the \fB\-W\fP option
|
---|
5432 | is considered.
|
---|
5433 | The string is first split using the characters in the
|
---|
5434 | .SM
|
---|
5435 | .B IFS
|
---|
5436 | special variable as delimiters.
|
---|
5437 | Shell quoting is honored.
|
---|
5438 | Each word is then expanded using
|
---|
5439 | brace expansion, tilde expansion, parameter and variable expansion,
|
---|
5440 | command substitution, and arithmetic expansion,
|
---|
5441 | as described above under
|
---|
5442 | .SM
|
---|
5443 | .BR EXPANSION .
|
---|
5444 | The results are split using the rules described above under
|
---|
5445 | \fBWord Splitting\fP.
|
---|
5446 | The results of the expansion are prefix-matched against the word being
|
---|
5447 | completed, and the matching words become the possible completions.
|
---|
5448 | .PP
|
---|
5449 | After these matches have been generated, any shell function or command
|
---|
5450 | specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
|
---|
5451 | When the command or function is invoked, the
|
---|
5452 | .SM
|
---|
5453 | .B COMP_LINE
|
---|
5454 | and
|
---|
5455 | .SM
|
---|
5456 | .B COMP_POINT
|
---|
5457 | variables are assigned values as described above under
|
---|
5458 | \fBShell Variables\fP.
|
---|
5459 | If a shell function is being invoked, the
|
---|
5460 | .SM
|
---|
5461 | .B COMP_WORDS
|
---|
5462 | and
|
---|
5463 | .SM
|
---|
5464 | .B COMP_CWORD
|
---|
5465 | variables are also set.
|
---|
5466 | When the function or command is invoked, the first argument is the
|
---|
5467 | name of the command whose arguments are being completed, the
|
---|
5468 | second argument is the word being completed, and the third argument
|
---|
5469 | is the word preceding the word being completed on the current command line.
|
---|
5470 | No filtering of the generated completions against the word being completed
|
---|
5471 | is performed; the function or command has complete freedom in generating
|
---|
5472 | the matches.
|
---|
5473 | .PP
|
---|
5474 | Any function specified with \fB\-F\fP is invoked first.
|
---|
5475 | The function may use any of the shell facilities, including the
|
---|
5476 | \fBcompgen\fP builtin described below, to generate the matches.
|
---|
5477 | It must put the possible completions in the
|
---|
5478 | .SM
|
---|
5479 | .B COMPREPLY
|
---|
5480 | array variable.
|
---|
5481 | .PP
|
---|
5482 | Next, any command specified with the \fB\-C\fP option is invoked
|
---|
5483 | in an environment equivalent to command substitution.
|
---|
5484 | It should print a list of completions, one per line, to the
|
---|
5485 | standard output.
|
---|
5486 | Backslash may be used to escape a newline, if necessary.
|
---|
5487 | .PP
|
---|
5488 | After all of the possible completions are generated, any filter
|
---|
5489 | specified with the \fB\-X\fP option is applied to the list.
|
---|
5490 | The filter is a pattern as used for pathname expansion; a \fB&\fP
|
---|
5491 | in the pattern is replaced with the text of the word being completed.
|
---|
5492 | A literal \fB&\fP may be escaped with a backslash; the backslash
|
---|
5493 | is removed before attempting a match.
|
---|
5494 | Any completion that matches the pattern will be removed from the list.
|
---|
5495 | A leading \fB!\fP negates the pattern; in this case any completion
|
---|
5496 | not matching the pattern will be removed.
|
---|
5497 | .PP
|
---|
5498 | Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP
|
---|
5499 | options are added to each member of the completion list, and the result is
|
---|
5500 | returned to the readline completion code as the list of possible
|
---|
5501 | completions.
|
---|
5502 | .PP
|
---|
5503 | If the previously-applied actions do not generate any matches, and the
|
---|
5504 | \fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the
|
---|
5505 | compspec was defined, directory name completion is attempted.
|
---|
5506 | .PP
|
---|
5507 | If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the
|
---|
5508 | compspec was defined, directory name completion is attempted and any
|
---|
5509 | matches are added to the results of the other actions.
|
---|
5510 | .PP
|
---|
5511 | By default, if a compspec is found, whatever it generates is returned
|
---|
5512 | to the completion code as the full set of possible completions.
|
---|
5513 | The default \fBbash\fP completions are not attempted, and the readline
|
---|
5514 | default of filename completion is disabled.
|
---|
5515 | If the \fB\-o bashdefault\fP option was supplied to \fBcomplete\fP when
|
---|
5516 | the compspec was defined, the \fBbash\fP default completions are attempted
|
---|
5517 | if the compspec generates no matches.
|
---|
5518 | If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the
|
---|
5519 | compspec was defined, readline's default completion will be performed
|
---|
5520 | if the compspec (and, if attempted, the default \fBbash\fP completions)
|
---|
5521 | generate no matches.
|
---|
5522 | .PP
|
---|
5523 | When a compspec indicates that directory name completion is desired,
|
---|
5524 | the programmable completion functions force readline to append a slash
|
---|
5525 | to completed names which are symbolic links to directories, subject to
|
---|
5526 | the value of the \fBmark\-directories\fP readline variable, regardless
|
---|
5527 | of the setting of the \fBmark-symlinked\-directories\fP readline variable.
|
---|
5528 | .SH HISTORY
|
---|
5529 | When the
|
---|
5530 | .B \-o history
|
---|
5531 | option to the
|
---|
5532 | .B set
|
---|
5533 | builtin is enabled, the shell provides access to the
|
---|
5534 | \fIcommand history\fP,
|
---|
5535 | the list of commands previously typed.
|
---|
5536 | The value of the \fBHISTSIZE\fP variable is used as the
|
---|
5537 | number of commands to save in a history list.
|
---|
5538 | The text of the last
|
---|
5539 | .SM
|
---|
5540 | .B HISTSIZE
|
---|
5541 | commands (default 500) is saved. The shell
|
---|
5542 | stores each command in the history list prior to parameter and
|
---|
5543 | variable expansion (see
|
---|
5544 | .SM
|
---|
5545 | .B EXPANSION
|
---|
5546 | above) but after history expansion is performed, subject to the
|
---|
5547 | values of the shell variables
|
---|
5548 | .SM
|
---|
5549 | .B HISTIGNORE
|
---|
5550 | and
|
---|
5551 | .SM
|
---|
5552 | .BR HISTCONTROL .
|
---|
5553 | .PP
|
---|
5554 | On startup, the history is initialized from the file named by
|
---|
5555 | the variable
|
---|
5556 | .SM
|
---|
5557 | .B HISTFILE
|
---|
5558 | (default \fI~/.bash_history\fP).
|
---|
5559 | The file named by the value of
|
---|
5560 | .SM
|
---|
5561 | .B HISTFILE
|
---|
5562 | is truncated, if necessary, to contain no more than
|
---|
5563 | the number of lines specified by the value of
|
---|
5564 | .SM
|
---|
5565 | .BR HISTFILESIZE .
|
---|
5566 | When an interactive shell exits, the last
|
---|
5567 | .SM
|
---|
5568 | .B $HISTSIZE
|
---|
5569 | lines are copied from the history list to
|
---|
5570 | .SM
|
---|
5571 | .BR $HISTFILE .
|
---|
5572 | If the
|
---|
5573 | .B histappend
|
---|
5574 | shell option is enabled
|
---|
5575 | (see the description of
|
---|
5576 | .B shopt
|
---|
5577 | under
|
---|
5578 | .SM
|
---|
5579 | .B "SHELL BUILTIN COMMANDS"
|
---|
5580 | below), the lines are appended to the history file,
|
---|
5581 | otherwise the history file is overwritten.
|
---|
5582 | If
|
---|
5583 | .SM
|
---|
5584 | .B HISTFILE
|
---|
5585 | is unset, or if the history file is unwritable, the history is
|
---|
5586 | not saved. After saving the history, the history file is truncated
|
---|
5587 | to contain no more than
|
---|
5588 | .SM
|
---|
5589 | .B HISTFILESIZE
|
---|
5590 | lines. If
|
---|
5591 | .SM
|
---|
5592 | .B HISTFILESIZE
|
---|
5593 | is not set, no truncation is performed.
|
---|
5594 | .PP
|
---|
5595 | The builtin command
|
---|
5596 | .B fc
|
---|
5597 | (see
|
---|
5598 | .SM
|
---|
5599 | .B SHELL BUILTIN COMMANDS
|
---|
5600 | below) may be used to list or edit and re-execute a portion of
|
---|
5601 | the history list.
|
---|
5602 | The
|
---|
5603 | .B history
|
---|
5604 | builtin may be used to display or modify the history list and
|
---|
5605 | manipulate the history file.
|
---|
5606 | When using command-line editing, search commands
|
---|
5607 | are available in each editing mode that provide access to the
|
---|
5608 | history list.
|
---|
5609 | .PP
|
---|
5610 | The shell allows control over which commands are saved on the history
|
---|
5611 | list. The
|
---|
5612 | .SM
|
---|
5613 | .B HISTCONTROL
|
---|
5614 | and
|
---|
5615 | .SM
|
---|
5616 | .B HISTIGNORE
|
---|
5617 | variables may be set to cause the shell to save only a subset of the
|
---|
5618 | commands entered.
|
---|
5619 | The
|
---|
5620 | .B cmdhist
|
---|
5621 | shell option, if enabled, causes the shell to attempt to save each
|
---|
5622 | line of a multi-line command in the same history entry, adding
|
---|
5623 | semicolons where necessary to preserve syntactic correctness.
|
---|
5624 | The
|
---|
5625 | .B lithist
|
---|
5626 | shell option causes the shell to save the command with embedded newlines
|
---|
5627 | instead of semicolons. See the description of the
|
---|
5628 | .B shopt
|
---|
5629 | builtin below under
|
---|
5630 | .SM
|
---|
5631 | .B "SHELL BUILTIN COMMANDS"
|
---|
5632 | for information on setting and unsetting shell options.
|
---|
5633 | .SH "HISTORY EXPANSION"
|
---|
5634 | .PP
|
---|
5635 | The shell supports a history expansion feature that
|
---|
5636 | is similar to the history expansion in
|
---|
5637 | .BR csh.
|
---|
5638 | This section describes what syntax features are available. This
|
---|
5639 | feature is enabled by default for interactive shells, and can be
|
---|
5640 | disabled using the
|
---|
5641 | .B \+H
|
---|
5642 | option to the
|
---|
5643 | .B set
|
---|
5644 | builtin command (see
|
---|
5645 | .SM
|
---|
5646 | .B SHELL BUILTIN COMMANDS
|
---|
5647 | below). Non-interactive shells do not perform history expansion
|
---|
5648 | by default.
|
---|
5649 | .PP
|
---|
5650 | History expansions introduce words from the history list into
|
---|
5651 | the input stream, making it easy to repeat commands, insert the
|
---|
5652 | arguments to a previous command into the current input line, or
|
---|
5653 | fix errors in previous commands quickly.
|
---|
5654 | .PP
|
---|
5655 | History expansion is performed immediately after a complete line
|
---|
5656 | is read, before the shell breaks it into words.
|
---|
5657 | It takes place in two parts.
|
---|
5658 | The first is to determine which line from the history list
|
---|
5659 | to use during substitution.
|
---|
5660 | The second is to select portions of that line for inclusion into
|
---|
5661 | the current one.
|
---|
5662 | The line selected from the history is the \fIevent\fP,
|
---|
5663 | and the portions of that line that are acted upon are \fIwords\fP.
|
---|
5664 | Various \fImodifiers\fP are available to manipulate the selected words.
|
---|
5665 | The line is broken into words in the same fashion as when reading input,
|
---|
5666 | so that several \fImetacharacter\fP-separated words surrounded by
|
---|
5667 | quotes are considered one word.
|
---|
5668 | History expansions are introduced by the appearance of the
|
---|
5669 | history expansion character, which is \^\fB!\fP\^ by default.
|
---|
5670 | Only backslash (\^\fB\e\fP\^) and single quotes can quote
|
---|
5671 | the history expansion character.
|
---|
5672 | .PP
|
---|
5673 | Several characters inhibit history expansion if found immediately
|
---|
5674 | following the history expansion character, even if it is unquoted:
|
---|
5675 | space, tab, newline, carriage return, and \fB=\fP.
|
---|
5676 | If the \fBextglob\fP shell option is enabled, \fB(\fP will also
|
---|
5677 | inhibit expansion.
|
---|
5678 | .PP
|
---|
5679 | Several shell options settable with the
|
---|
5680 | .B shopt
|
---|
5681 | builtin may be used to tailor the behavior of history expansion.
|
---|
5682 | If the
|
---|
5683 | .B histverify
|
---|
5684 | shell option is enabled (see the description of the
|
---|
5685 | .B shopt
|
---|
5686 | builtin), and
|
---|
5687 | .B readline
|
---|
5688 | is being used, history substitutions are not immediately passed to
|
---|
5689 | the shell parser.
|
---|
5690 | Instead, the expanded line is reloaded into the
|
---|
5691 | .B readline
|
---|
5692 | editing buffer for further modification.
|
---|
5693 | If
|
---|
5694 | .B readline
|
---|
5695 | is being used, and the
|
---|
5696 | .B histreedit
|
---|
5697 | shell option is enabled, a failed history substitution will be reloaded
|
---|
5698 | into the
|
---|
5699 | .B readline
|
---|
5700 | editing buffer for correction.
|
---|
5701 | The
|
---|
5702 | .B \-p
|
---|
5703 | option to the
|
---|
5704 | .B history
|
---|
5705 | builtin command may be used to see what a history expansion will
|
---|
5706 | do before using it.
|
---|
5707 | The
|
---|
5708 | .B \-s
|
---|
5709 | option to the
|
---|
5710 | .B history
|
---|
5711 | builtin may be used to add commands to the end of the history list
|
---|
5712 | without actually executing them, so that they are available for
|
---|
5713 | subsequent recall.
|
---|
5714 | .PP
|
---|
5715 | The shell allows control of the various characters used by the
|
---|
5716 | history expansion mechanism (see the description of
|
---|
5717 | .B histchars
|
---|
5718 | above under
|
---|
5719 | .BR "Shell Variables" ).
|
---|
5720 | .SS Event Designators
|
---|
5721 | .PP
|
---|
5722 | An event designator is a reference to a command line entry in the
|
---|
5723 | history list.
|
---|
5724 | .PP
|
---|
5725 | .PD 0
|
---|
5726 | .TP
|
---|
5727 | .B !
|
---|
5728 | Start a history substitution, except when followed by a
|
---|
5729 | .BR blank ,
|
---|
5730 | newline, carriage return, =
|
---|
5731 | or ( (when the \fBextglob\fP shell option is enabled using
|
---|
5732 | the \fBshopt\fP builtin).
|
---|
5733 | .TP
|
---|
5734 | .B !\fIn\fR
|
---|
5735 | Refer to command line
|
---|
5736 | .IR n .
|
---|
5737 | .TP
|
---|
5738 | .B !\-\fIn\fR
|
---|
5739 | Refer to the current command line minus
|
---|
5740 | .IR n .
|
---|
5741 | .TP
|
---|
5742 | .B !!
|
---|
5743 | Refer to the previous command. This is a synonym for `!\-1'.
|
---|
5744 | .TP
|
---|
5745 | .B !\fIstring\fR
|
---|
5746 | Refer to the most recent command starting with
|
---|
5747 | .IR string .
|
---|
5748 | .TP
|
---|
5749 | .B !?\fIstring\fR\fB[?]\fR
|
---|
5750 | Refer to the most recent command containing
|
---|
5751 | .IR string .
|
---|
5752 | The trailing \fB?\fP may be omitted if
|
---|
5753 | .I string
|
---|
5754 | is followed immediately by a newline.
|
---|
5755 | .TP
|
---|
5756 | .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
|
---|
5757 | Quick substitution. Repeat the last command, replacing
|
---|
5758 | .I string1
|
---|
5759 | with
|
---|
5760 | .IR string2 .
|
---|
5761 | Equivalent to
|
---|
5762 | ``!!:s/\fIstring1\fP/\fIstring2\fP/''
|
---|
5763 | (see \fBModifiers\fP below).
|
---|
5764 | .TP
|
---|
5765 | .B !#
|
---|
5766 | The entire command line typed so far.
|
---|
5767 | .PD
|
---|
5768 | .SS Word Designators
|
---|
5769 | .PP
|
---|
5770 | Word designators are used to select desired words from the event.
|
---|
5771 | A
|
---|
5772 | .B :
|
---|
5773 | separates the event specification from the word designator.
|
---|
5774 | It may be omitted if the word designator begins with a
|
---|
5775 | .BR ^ ,
|
---|
5776 | .BR $ ,
|
---|
5777 | .BR * ,
|
---|
5778 | .BR \- ,
|
---|
5779 | or
|
---|
5780 | .BR % .
|
---|
5781 | Words are numbered from the beginning of the line,
|
---|
5782 | with the first word being denoted by 0 (zero).
|
---|
5783 | Words are inserted into the current line separated by single spaces.
|
---|
5784 | .PP
|
---|
5785 | .PD 0
|
---|
5786 | .TP
|
---|
5787 | .B 0 (zero)
|
---|
5788 | The zeroth word. For the shell, this is the command
|
---|
5789 | word.
|
---|
5790 | .TP
|
---|
5791 | .I n
|
---|
5792 | The \fIn\fRth word.
|
---|
5793 | .TP
|
---|
5794 | .B ^
|
---|
5795 | The first argument. That is, word 1.
|
---|
5796 | .TP
|
---|
5797 | .B $
|
---|
5798 | The last argument.
|
---|
5799 | .TP
|
---|
5800 | .B %
|
---|
5801 | The word matched by the most recent `?\fIstring\fR?' search.
|
---|
5802 | .TP
|
---|
5803 | .I x\fB\-\fPy
|
---|
5804 | A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
|
---|
5805 | .TP
|
---|
5806 | .B *
|
---|
5807 | All of the words but the zeroth. This is a synonym
|
---|
5808 | for `\fI1\-$\fP'. It is not an error to use
|
---|
5809 | .B *
|
---|
5810 | if there is just one
|
---|
5811 | word in the event; the empty string is returned in that case.
|
---|
5812 | .TP
|
---|
5813 | .B x*
|
---|
5814 | Abbreviates \fIx\-$\fP.
|
---|
5815 | .TP
|
---|
5816 | .B x\-
|
---|
5817 | Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
|
---|
5818 | .PD
|
---|
5819 | .PP
|
---|
5820 | If a word designator is supplied without an event specification, the
|
---|
5821 | previous command is used as the event.
|
---|
5822 | .SS Modifiers
|
---|
5823 | .PP
|
---|
5824 | After the optional word designator, there may appear a sequence of
|
---|
5825 | one or more of the following modifiers, each preceded by a `:'.
|
---|
5826 | .PP
|
---|
5827 | .PD 0
|
---|
5828 | .PP
|
---|
5829 | .TP
|
---|
5830 | .B h
|
---|
5831 | Remove a trailing file name component, leaving only the head.
|
---|
5832 | .TP
|
---|
5833 | .B t
|
---|
5834 | Remove all leading file name components, leaving the tail.
|
---|
5835 | .TP
|
---|
5836 | .B r
|
---|
5837 | Remove a trailing suffix of the form \fI.xxx\fP, leaving the
|
---|
5838 | basename.
|
---|
5839 | .TP
|
---|
5840 | .B e
|
---|
5841 | Remove all but the trailing suffix.
|
---|
5842 | .TP
|
---|
5843 | .B p
|
---|
5844 | Print the new command but do not execute it.
|
---|
5845 | .TP
|
---|
5846 | .B q
|
---|
5847 | Quote the substituted words, escaping further substitutions.
|
---|
5848 | .TP
|
---|
5849 | .B x
|
---|
5850 | Quote the substituted words as with
|
---|
5851 | .BR q ,
|
---|
5852 | but break into words at
|
---|
5853 | .B blanks
|
---|
5854 | and newlines.
|
---|
5855 | .TP
|
---|
5856 | .B s/\fIold\fP/\fInew\fP/
|
---|
5857 | Substitute
|
---|
5858 | .I new
|
---|
5859 | for the first occurrence of
|
---|
5860 | .I old
|
---|
5861 | in the event line. Any delimiter can be used in place of /. The
|
---|
5862 | final delimiter is optional if it is the last character of the
|
---|
5863 | event line. The delimiter may be quoted in
|
---|
5864 | .I old
|
---|
5865 | and
|
---|
5866 | .I new
|
---|
5867 | with a single backslash. If & appears in
|
---|
5868 | .IR new ,
|
---|
5869 | it is replaced by
|
---|
5870 | .IR old .
|
---|
5871 | A single backslash will quote the &. If
|
---|
5872 | .I old
|
---|
5873 | is null, it is set to the last
|
---|
5874 | .I old
|
---|
5875 | substituted, or, if no previous history substitutions took place,
|
---|
5876 | the last
|
---|
5877 | .I string
|
---|
5878 | in a
|
---|
5879 | .B !?\fIstring\fR\fB[?]\fR
|
---|
5880 | search.
|
---|
5881 | .TP
|
---|
5882 | .B &
|
---|
5883 | Repeat the previous substitution.
|
---|
5884 | .TP
|
---|
5885 | .B g
|
---|
5886 | Cause changes to be applied over the entire event line. This is
|
---|
5887 | used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
|
---|
5888 | or `\fB:&\fP'. If used with
|
---|
5889 | `\fB:s\fP', any delimiter can be used
|
---|
5890 | in place of /, and the final delimiter is optional
|
---|
5891 | if it is the last character of the event line.
|
---|
5892 | An \fBa\fP may be used as a synonym for \fBg\fP.
|
---|
5893 | .TP
|
---|
5894 | .B G
|
---|
5895 | Apply the following `\fBs\fP' modifier once to each word in the event line.
|
---|
5896 | .PD
|
---|
5897 | .SH "SHELL BUILTIN COMMANDS"
|
---|
5898 | .\" start of bash_builtins
|
---|
5899 | .zZ
|
---|
5900 | .PP
|
---|
5901 | Unless otherwise noted, each builtin command documented in this
|
---|
5902 | section as accepting options preceded by
|
---|
5903 | .B \-
|
---|
5904 | accepts
|
---|
5905 | .B \-\-
|
---|
5906 | to signify the end of the options.
|
---|
5907 | For example, the \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP builtins
|
---|
5908 | do not accept options.
|
---|
5909 | .sp .5
|
---|
5910 | .PD 0
|
---|
5911 | .TP
|
---|
5912 | \fB:\fP [\fIarguments\fP]
|
---|
5913 | .PD
|
---|
5914 | No effect; the command does nothing beyond expanding
|
---|
5915 | .I arguments
|
---|
5916 | and performing any specified
|
---|
5917 | redirections. A zero exit code is returned.
|
---|
5918 | .TP
|
---|
5919 | \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
|
---|
5920 | .PD 0
|
---|
5921 | .TP
|
---|
5922 | \fBsource\fP \fIfilename\fP [\fIarguments\fP]
|
---|
5923 | .PD
|
---|
5924 | Read and execute commands from
|
---|
5925 | .I filename
|
---|
5926 | in the current
|
---|
5927 | shell environment and return the exit status of the last command
|
---|
5928 | executed from
|
---|
5929 | .IR filename .
|
---|
5930 | If
|
---|
5931 | .I filename
|
---|
5932 | does not contain a slash, file names in
|
---|
5933 | .SM
|
---|
5934 | .B PATH
|
---|
5935 | are used to find the directory containing
|
---|
5936 | .IR filename .
|
---|
5937 | The file searched for in
|
---|
5938 | .SM
|
---|
5939 | .B PATH
|
---|
5940 | need not be executable.
|
---|
5941 | When \fBbash\fP is not in \fIposix mode\fP, the current directory is
|
---|
5942 | searched if no file is found in
|
---|
5943 | .SM
|
---|
5944 | .BR PATH .
|
---|
5945 | If the
|
---|
5946 | .B sourcepath
|
---|
5947 | option to the
|
---|
5948 | .B shopt
|
---|
5949 | builtin command is turned off, the
|
---|
5950 | .SM
|
---|
5951 | .B PATH
|
---|
5952 | is not searched.
|
---|
5953 | If any \fIarguments\fP are supplied, they become the positional
|
---|
5954 | parameters when \fIfilename\fP is executed. Otherwise the positional
|
---|
5955 | parameters are unchanged.
|
---|
5956 | The return status is the status of the last command exited within
|
---|
5957 | the script (0 if no commands are executed), and false if
|
---|
5958 | .I filename
|
---|
5959 | is not found or cannot be read.
|
---|
5960 | .TP
|
---|
5961 | \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
---|
5962 | \fBAlias\fP with no arguments or with the
|
---|
5963 | .B \-p
|
---|
5964 | option prints the list of aliases in the form
|
---|
5965 | \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
|
---|
5966 | When arguments are supplied, an alias is defined for
|
---|
5967 | each \fIname\fP whose \fIvalue\fP is given.
|
---|
5968 | A trailing space in \fIvalue\fP causes the next word to be
|
---|
5969 | checked for alias substitution when the alias is expanded.
|
---|
5970 | For each \fIname\fP in the argument list for which no \fIvalue\fP
|
---|
5971 | is supplied, the name and value of the alias is printed.
|
---|
5972 | \fBAlias\fP returns true unless a \fIname\fP is given for which
|
---|
5973 | no alias has been defined.
|
---|
5974 | .TP
|
---|
5975 | \fBbg\fP [\fIjobspec\fP ...]
|
---|
5976 | Resume each suspended job \fIjobspec\fP in the background, as if it
|
---|
5977 | had been started with
|
---|
5978 | .BR & .
|
---|
5979 | If \fIjobspec\fP is not present, the shell's notion of the
|
---|
5980 | \fIcurrent job\fP is used.
|
---|
5981 | .B bg
|
---|
5982 | .I jobspec
|
---|
5983 | returns 0 unless run when job control is disabled or, when run with
|
---|
5984 | job control enabled, any specified \fIjobspec\fP was not found
|
---|
5985 | or was started without job control.
|
---|
5986 | .TP
|
---|
5987 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP]
|
---|
5988 | .PD 0
|
---|
5989 | .TP
|
---|
5990 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP]
|
---|
5991 | .TP
|
---|
5992 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
|
---|
5993 | .TP
|
---|
5994 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP
|
---|
5995 | .TP
|
---|
5996 | \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
|
---|
5997 | .TP
|
---|
5998 | \fBbind\fP \fIreadline\-command\fP
|
---|
5999 | .PD
|
---|
6000 | Display current
|
---|
6001 | .B readline
|
---|
6002 | key and function bindings, bind a key sequence to a
|
---|
6003 | .B readline
|
---|
6004 | function or macro, or set a
|
---|
6005 | .B readline
|
---|
6006 | variable.
|
---|
6007 | Each non-option argument is a command as it would appear in
|
---|
6008 | .IR .inputrc ,
|
---|
6009 | but each binding or command must be passed as a separate argument;
|
---|
6010 | e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'.
|
---|
6011 | Options, if supplied, have the following meanings:
|
---|
6012 | .RS
|
---|
6013 | .PD 0
|
---|
6014 | .TP
|
---|
6015 | .B \-m \fIkeymap\fP
|
---|
6016 | Use
|
---|
6017 | .I keymap
|
---|
6018 | as the keymap to be affected by the subsequent bindings.
|
---|
6019 | Acceptable
|
---|
6020 | .I keymap
|
---|
6021 | names are
|
---|
6022 | \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
|
---|
6023 | vi\-move, vi\-command\fP, and
|
---|
6024 | .IR vi\-insert .
|
---|
6025 | \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
|
---|
6026 | equivalent to \fIemacs\-standard\fP.
|
---|
6027 | .TP
|
---|
6028 | .B \-l
|
---|
6029 | List the names of all \fBreadline\fP functions.
|
---|
6030 | .TP
|
---|
6031 | .B \-p
|
---|
6032 | Display \fBreadline\fP function names and bindings in such a way
|
---|
6033 | that they can be re-read.
|
---|
6034 | .TP
|
---|
6035 | .B \-P
|
---|
6036 | List current \fBreadline\fP function names and bindings.
|
---|
6037 | .TP
|
---|
6038 | .B \-v
|
---|
6039 | Display \fBreadline\fP variable names and values in such a way that they
|
---|
6040 | can be re-read.
|
---|
6041 | .TP
|
---|
6042 | .B \-V
|
---|
6043 | List current \fBreadline\fP variable names and values.
|
---|
6044 | .TP
|
---|
6045 | .B \-s
|
---|
6046 | Display \fBreadline\fP key sequences bound to macros and the strings
|
---|
6047 | they output in such a way that they can be re-read.
|
---|
6048 | .TP
|
---|
6049 | .B \-S
|
---|
6050 | Display \fBreadline\fP key sequences bound to macros and the strings
|
---|
6051 | they output.
|
---|
6052 | .TP
|
---|
6053 | .B \-f \fIfilename\fP
|
---|
6054 | Read key bindings from \fIfilename\fP.
|
---|
6055 | .TP
|
---|
6056 | .B \-q \fIfunction\fP
|
---|
6057 | Query about which keys invoke the named \fIfunction\fP.
|
---|
6058 | .TP
|
---|
6059 | .B \-u \fIfunction\fP
|
---|
6060 | Unbind all keys bound to the named \fIfunction\fP.
|
---|
6061 | .TP
|
---|
6062 | .B \-r \fIkeyseq\fP
|
---|
6063 | Remove any current binding for \fIkeyseq\fP.
|
---|
6064 | .TP
|
---|
6065 | .B \-x \fIkeyseq\fP:\fIshell\-command\fP
|
---|
6066 | Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is
|
---|
6067 | entered.
|
---|
6068 | .PD
|
---|
6069 | .PP
|
---|
6070 | The return value is 0 unless an unrecognized option is given or an
|
---|
6071 | error occurred.
|
---|
6072 | .RE
|
---|
6073 | .TP
|
---|
6074 | \fBbreak\fP [\fIn\fP]
|
---|
6075 | Exit from within a
|
---|
6076 | .BR for ,
|
---|
6077 | .BR while ,
|
---|
6078 | .BR until ,
|
---|
6079 | or
|
---|
6080 | .B select
|
---|
6081 | loop. If \fIn\fP is specified, break \fIn\fP levels.
|
---|
6082 | .I n
|
---|
6083 | must be \(>= 1. If
|
---|
6084 | .I n
|
---|
6085 | is greater than the number of enclosing loops, all enclosing loops
|
---|
6086 | are exited. The return value is 0 unless the shell is not executing
|
---|
6087 | a loop when
|
---|
6088 | .B break
|
---|
6089 | is executed.
|
---|
6090 | .TP
|
---|
6091 | \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
|
---|
6092 | Execute the specified shell builtin, passing it
|
---|
6093 | .IR arguments ,
|
---|
6094 | and return its exit status.
|
---|
6095 | This is useful when defining a
|
---|
6096 | function whose name is the same as a shell builtin,
|
---|
6097 | retaining the functionality of the builtin within the function.
|
---|
6098 | The \fBcd\fP builtin is commonly redefined this way.
|
---|
6099 | The return status is false if
|
---|
6100 | .I shell\-builtin
|
---|
6101 | is not a shell builtin command.
|
---|
6102 | .TP
|
---|
6103 | \fBcd\fP [\fB\-L|-P\fP] [\fIdir\fP]
|
---|
6104 | Change the current directory to \fIdir\fP. The variable
|
---|
6105 | .SM
|
---|
6106 | .B HOME
|
---|
6107 | is the
|
---|
6108 | default
|
---|
6109 | .IR dir .
|
---|
6110 | The variable
|
---|
6111 | .SM
|
---|
6112 | .B CDPATH
|
---|
6113 | defines the search path for the directory containing
|
---|
6114 | .IR dir .
|
---|
6115 | Alternative directory names in
|
---|
6116 | .SM
|
---|
6117 | .B CDPATH
|
---|
6118 | are separated by a colon (:). A null directory name in
|
---|
6119 | .SM
|
---|
6120 | .B CDPATH
|
---|
6121 | is the same as the current directory, i.e., ``\fB.\fP''. If
|
---|
6122 | .I dir
|
---|
6123 | begins with a slash (/),
|
---|
6124 | then
|
---|
6125 | .SM
|
---|
6126 | .B CDPATH
|
---|
6127 | is not used. The
|
---|
6128 | .B \-P
|
---|
6129 | option says to use the physical directory structure instead of
|
---|
6130 | following symbolic links (see also the
|
---|
6131 | .B \-P
|
---|
6132 | option to the
|
---|
6133 | .B set
|
---|
6134 | builtin command); the
|
---|
6135 | .B \-L
|
---|
6136 | option forces symbolic links to be followed. An argument of
|
---|
6137 | .B \-
|
---|
6138 | is equivalent to
|
---|
6139 | .SM
|
---|
6140 | .BR $OLDPWD .
|
---|
6141 | If a non-empty directory name from \fBCDPATH\fP is used, or if
|
---|
6142 | \fB\-\fP is the first argument, and the directory change is
|
---|
6143 | successful, the absolute pathname of the new working directory is
|
---|
6144 | written to the standard output.
|
---|
6145 | The return value is true if the directory was successfully changed;
|
---|
6146 | false otherwise.
|
---|
6147 | .TP
|
---|
6148 | \fBcaller\fP [\fIexpr\fP]
|
---|
6149 | Returns the context of any active subroutine call (a shell function or
|
---|
6150 | a script executed with the \fB.\fP or \fBsource\fP builtins.
|
---|
6151 | Without \fIexpr\fP, \fBcaller\fP displays the line number and source
|
---|
6152 | filename of the current subroutine call.
|
---|
6153 | If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP
|
---|
6154 | displays the line number, subroutine name, and source file corresponding
|
---|
6155 | to that position in the current execution call stack. This extra
|
---|
6156 | information may be used, for example, to print a stack trace. The
|
---|
6157 | current frame is frame 0.
|
---|
6158 | The return value is 0 unless the shell is not executing a subroutine
|
---|
6159 | call or \fIexpr\fP does not correspond to a valid position in the
|
---|
6160 | call stack.
|
---|
6161 | .TP
|
---|
6162 | \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
|
---|
6163 | Run
|
---|
6164 | .I command
|
---|
6165 | with
|
---|
6166 | .I args
|
---|
6167 | suppressing the normal shell function lookup. Only builtin
|
---|
6168 | commands or commands found in the
|
---|
6169 | .SM
|
---|
6170 | .B PATH
|
---|
6171 | are executed. If the
|
---|
6172 | .B \-p
|
---|
6173 | option is given, the search for
|
---|
6174 | .I command
|
---|
6175 | is performed using a default value for
|
---|
6176 | .B PATH
|
---|
6177 | that is guaranteed to find all of the standard utilities.
|
---|
6178 | If either the
|
---|
6179 | .B \-V
|
---|
6180 | or
|
---|
6181 | .B \-v
|
---|
6182 | option is supplied, a description of
|
---|
6183 | .I command
|
---|
6184 | is printed. The
|
---|
6185 | .B \-v
|
---|
6186 | option causes a single word indicating the command or file name
|
---|
6187 | used to invoke
|
---|
6188 | .I command
|
---|
6189 | to be displayed; the
|
---|
6190 | .B \-V
|
---|
6191 | option produces a more verbose description.
|
---|
6192 | If the
|
---|
6193 | .B \-V
|
---|
6194 | or
|
---|
6195 | .B \-v
|
---|
6196 | option is supplied, the exit status is 0 if
|
---|
6197 | .I command
|
---|
6198 | was found, and 1 if not. If neither option is supplied and
|
---|
6199 | an error occurred or
|
---|
6200 | .I command
|
---|
6201 | cannot be found, the exit status is 127. Otherwise, the exit status of the
|
---|
6202 | .B command
|
---|
6203 | builtin is the exit status of
|
---|
6204 | .IR command .
|
---|
6205 | .TP
|
---|
6206 | \fBcompgen\fP [\fIoption\fP] [\fIword\fP]
|
---|
6207 | Generate possible completion matches for \fIword\fP according to
|
---|
6208 | the \fIoption\fPs, which may be any option accepted by the
|
---|
6209 | .B complete
|
---|
6210 | builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write
|
---|
6211 | the matches to the standard output.
|
---|
6212 | When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables
|
---|
6213 | set by the programmable completion facilities, while available, will not
|
---|
6214 | have useful values.
|
---|
6215 | .sp 1
|
---|
6216 | The matches will be generated in the same way as if the programmable
|
---|
6217 | completion code had generated them directly from a completion specification
|
---|
6218 | with the same flags.
|
---|
6219 | If \fIword\fP is specified, only those completions matching \fIword\fP
|
---|
6220 | will be displayed.
|
---|
6221 | .sp 1
|
---|
6222 | The return value is true unless an invalid option is supplied, or no
|
---|
6223 | matches were generated.
|
---|
6224 | .TP
|
---|
6225 | \fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
|
---|
6226 | .br
|
---|
6227 | [\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP]
|
---|
6228 | .PD 0
|
---|
6229 | .TP
|
---|
6230 | \fBcomplete\fP \fB\-pr\fP [\fIname\fP ...]
|
---|
6231 | .PD
|
---|
6232 | Specify how arguments to each \fIname\fP should be completed.
|
---|
6233 | If the \fB\-p\fP option is supplied, or if no options are supplied,
|
---|
6234 | existing completion specifications are printed in a way that allows
|
---|
6235 | them to be reused as input.
|
---|
6236 | The \fB\-r\fP option removes a completion specification for
|
---|
6237 | each \fIname\fP, or, if no \fIname\fPs are supplied, all
|
---|
6238 | completion specifications.
|
---|
6239 | .sp 1
|
---|
6240 | The process of applying these completion specifications when word completion
|
---|
6241 | is attempted is described above under \fBProgrammable Completion\fP.
|
---|
6242 | .sp 1
|
---|
6243 | Other options, if specified, have the following meanings.
|
---|
6244 | The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options
|
---|
6245 | (and, if necessary, the \fB\-P\fP and \fB\-S\fP options)
|
---|
6246 | should be quoted to protect them from expansion before the
|
---|
6247 | .B complete
|
---|
6248 | builtin is invoked.
|
---|
6249 | .RS
|
---|
6250 | .PD 0
|
---|
6251 | .TP 8
|
---|
6252 | \fB\-o\fP \fIcomp-option\fP
|
---|
6253 | The \fIcomp-option\fP controls several aspects of the compspec's behavior
|
---|
6254 | beyond the simple generation of completions.
|
---|
6255 | \fIcomp-option\fP may be one of:
|
---|
6256 | .RS
|
---|
6257 | .TP 8
|
---|
6258 | .B bashdefault
|
---|
6259 | Perform the rest of the default \fBbash\fP completions if the compspec
|
---|
6260 | generates no matches.
|
---|
6261 | .TP 8
|
---|
6262 | .B default
|
---|
6263 | Use readline's default filename completion if the compspec generates
|
---|
6264 | no matches.
|
---|
6265 | .TP 8
|
---|
6266 | .B dirnames
|
---|
6267 | Perform directory name completion if the compspec generates no matches.
|
---|
6268 | .TP 8
|
---|
6269 | .B filenames
|
---|
6270 | Tell readline that the compspec generates filenames, so it can perform any
|
---|
6271 | filename\-specific processing (like adding a slash to directory names or
|
---|
6272 | suppressing trailing spaces). Intended to be used with shell functions.
|
---|
6273 | .TP 8
|
---|
6274 | .B nospace
|
---|
6275 | Tell readline not to append a space (the default) to words completed at
|
---|
6276 | the end of the line.
|
---|
6277 | .TP 8
|
---|
6278 | .B plusdirs
|
---|
6279 | After any matches defined by the compspec are generated,
|
---|
6280 | directory name completion is attempted and any
|
---|
6281 | matches are added to the results of the other actions.
|
---|
6282 | .RE
|
---|
6283 | .TP 8
|
---|
6284 | \fB\-A\fP \fIaction\fP
|
---|
6285 | The \fIaction\fP may be one of the following to generate a list of possible
|
---|
6286 | completions:
|
---|
6287 | .RS
|
---|
6288 | .TP 8
|
---|
6289 | .B alias
|
---|
6290 | Alias names. May also be specified as \fB\-a\fP.
|
---|
6291 | .TP 8
|
---|
6292 | .B arrayvar
|
---|
6293 | Array variable names.
|
---|
6294 | .TP 8
|
---|
6295 | .B binding
|
---|
6296 | \fBReadline\fP key binding names.
|
---|
6297 | .TP 8
|
---|
6298 | .B builtin
|
---|
6299 | Names of shell builtin commands. May also be specified as \fB\-b\fP.
|
---|
6300 | .TP 8
|
---|
6301 | .B command
|
---|
6302 | Command names. May also be specified as \fB\-c\fP.
|
---|
6303 | .TP 8
|
---|
6304 | .B directory
|
---|
6305 | Directory names. May also be specified as \fB\-d\fP.
|
---|
6306 | .TP 8
|
---|
6307 | .B disabled
|
---|
6308 | Names of disabled shell builtins.
|
---|
6309 | .TP 8
|
---|
6310 | .B enabled
|
---|
6311 | Names of enabled shell builtins.
|
---|
6312 | .TP 8
|
---|
6313 | .B export
|
---|
6314 | Names of exported shell variables. May also be specified as \fB\-e\fP.
|
---|
6315 | .TP 8
|
---|
6316 | .B file
|
---|
6317 | File names. May also be specified as \fB\-f\fP.
|
---|
6318 | .TP 8
|
---|
6319 | .B function
|
---|
6320 | Names of shell functions.
|
---|
6321 | .TP 8
|
---|
6322 | .B group
|
---|
6323 | Group names. May also be specified as \fB\-g\fP.
|
---|
6324 | .TP 8
|
---|
6325 | .B helptopic
|
---|
6326 | Help topics as accepted by the \fBhelp\fP builtin.
|
---|
6327 | .TP 8
|
---|
6328 | .B hostname
|
---|
6329 | Hostnames, as taken from the file specified by the
|
---|
6330 | .SM
|
---|
6331 | .B HOSTFILE
|
---|
6332 | shell variable.
|
---|
6333 | .TP 8
|
---|
6334 | .B job
|
---|
6335 | Job names, if job control is active. May also be specified as \fB\-j\fP.
|
---|
6336 | .TP 8
|
---|
6337 | .B keyword
|
---|
6338 | Shell reserved words. May also be specified as \fB\-k\fP.
|
---|
6339 | .TP 8
|
---|
6340 | .B running
|
---|
6341 | Names of running jobs, if job control is active.
|
---|
6342 | .TP 8
|
---|
6343 | .B service
|
---|
6344 | Service names. May also be specified as \fB\-s\fP.
|
---|
6345 | .TP 8
|
---|
6346 | .B setopt
|
---|
6347 | Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin.
|
---|
6348 | .TP 8
|
---|
6349 | .B shopt
|
---|
6350 | Shell option names as accepted by the \fBshopt\fP builtin.
|
---|
6351 | .TP 8
|
---|
6352 | .B signal
|
---|
6353 | Signal names.
|
---|
6354 | .TP 8
|
---|
6355 | .B stopped
|
---|
6356 | Names of stopped jobs, if job control is active.
|
---|
6357 | .TP 8
|
---|
6358 | .B user
|
---|
6359 | User names. May also be specified as \fB\-u\fP.
|
---|
6360 | .TP 8
|
---|
6361 | .B variable
|
---|
6362 | Names of all shell variables. May also be specified as \fB\-v\fP.
|
---|
6363 | .RE
|
---|
6364 | .TP 8
|
---|
6365 | \fB\-G\fP \fIglobpat\fP
|
---|
6366 | The filename expansion pattern \fIglobpat\fP is expanded to generate
|
---|
6367 | the possible completions.
|
---|
6368 | .TP 8
|
---|
6369 | \fB\-W\fP \fIwordlist\fP
|
---|
6370 | The \fIwordlist\fP is split using the characters in the
|
---|
6371 | .SM
|
---|
6372 | .B IFS
|
---|
6373 | special variable as delimiters, and each resultant word is expanded.
|
---|
6374 | The possible completions are the members of the resultant list which
|
---|
6375 | match the word being completed.
|
---|
6376 | .TP 8
|
---|
6377 | \fB\-C\fP \fIcommand\fP
|
---|
6378 | \fIcommand\fP is executed in a subshell environment, and its output is
|
---|
6379 | used as the possible completions.
|
---|
6380 | .TP 8
|
---|
6381 | \fB\-F\fP \fIfunction\fP
|
---|
6382 | The shell function \fIfunction\fP is executed in the current shell
|
---|
6383 | environment.
|
---|
6384 | When it finishes, the possible completions are retrieved from the value
|
---|
6385 | of the
|
---|
6386 | .SM
|
---|
6387 | .B COMPREPLY
|
---|
6388 | array variable.
|
---|
6389 | .TP 8
|
---|
6390 | \fB\-X\fP \fIfilterpat\fP
|
---|
6391 | \fIfilterpat\fP is a pattern as used for filename expansion.
|
---|
6392 | It is applied to the list of possible completions generated by the
|
---|
6393 | preceding options and arguments, and each completion matching
|
---|
6394 | \fIfilterpat\fP is removed from the list.
|
---|
6395 | A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this
|
---|
6396 | case, any completion not matching \fIfilterpat\fP is removed.
|
---|
6397 | .TP 8
|
---|
6398 | \fB\-P\fP \fIprefix\fP
|
---|
6399 | \fIprefix\fP is added at the beginning of each possible completion
|
---|
6400 | after all other options have been applied.
|
---|
6401 | .TP 8
|
---|
6402 | \fB\-S\fP \fIsuffix\fP
|
---|
6403 | \fIsuffix\fP is appended to each possible completion
|
---|
6404 | after all other options have been applied.
|
---|
6405 | .PD
|
---|
6406 | .PP
|
---|
6407 | The return value is true unless an invalid option is supplied, an option
|
---|
6408 | other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP
|
---|
6409 | argument, an attempt is made to remove a completion specification for
|
---|
6410 | a \fIname\fP for which no specification exists, or
|
---|
6411 | an error occurs adding a completion specification.
|
---|
6412 | .RE
|
---|
6413 | .TP
|
---|
6414 | \fBcontinue\fP [\fIn\fP]
|
---|
6415 | Resume the next iteration of the enclosing
|
---|
6416 | .BR for ,
|
---|
6417 | .BR while ,
|
---|
6418 | .BR until ,
|
---|
6419 | or
|
---|
6420 | .B select
|
---|
6421 | loop.
|
---|
6422 | If
|
---|
6423 | .I n
|
---|
6424 | is specified, resume at the \fIn\fPth enclosing loop.
|
---|
6425 | .I n
|
---|
6426 | must be \(>= 1. If
|
---|
6427 | .I n
|
---|
6428 | is greater than the number of enclosing loops, the last enclosing loop
|
---|
6429 | (the ``top-level'' loop) is resumed. The return value is 0 unless the
|
---|
6430 | shell is not executing a loop when
|
---|
6431 | .B continue
|
---|
6432 | is executed.
|
---|
6433 | .TP
|
---|
6434 | \fBdeclare\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
---|
6435 | .PD 0
|
---|
6436 | .TP
|
---|
6437 | \fBtypeset\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
---|
6438 | .PD
|
---|
6439 | Declare variables and/or give them attributes.
|
---|
6440 | If no \fIname\fPs are given then display the values of variables.
|
---|
6441 | The
|
---|
6442 | .B \-p
|
---|
6443 | option will display the attributes and values of each
|
---|
6444 | .IR name .
|
---|
6445 | When
|
---|
6446 | .B \-p
|
---|
6447 | is used, additional options are ignored.
|
---|
6448 | The
|
---|
6449 | .B \-F
|
---|
6450 | option inhibits the display of function definitions; only the
|
---|
6451 | function name and attributes are printed.
|
---|
6452 | If the \fBextdebug\fP shell option is enabled using \fBshopt\fP,
|
---|
6453 | the source file name and line number where the function is defined
|
---|
6454 | are displayed as well. The
|
---|
6455 | .B \-F
|
---|
6456 | option implies
|
---|
6457 | .BR \-f .
|
---|
6458 | The following options can
|
---|
6459 | be used to restrict output to variables with the specified attribute or
|
---|
6460 | to give variables attributes:
|
---|
6461 | .RS
|
---|
6462 | .PD 0
|
---|
6463 | .TP
|
---|
6464 | .B \-a
|
---|
6465 | Each \fIname\fP is an array variable (see
|
---|
6466 | .B Arrays
|
---|
6467 | above).
|
---|
6468 | .TP
|
---|
6469 | .B \-f
|
---|
6470 | Use function names only.
|
---|
6471 | .TP
|
---|
6472 | .B \-i
|
---|
6473 | The variable is treated as an integer; arithmetic evaluation (see
|
---|
6474 | .SM
|
---|
6475 | .B "ARITHMETIC EVALUATION" ") "
|
---|
6476 | is performed when the variable is assigned a value.
|
---|
6477 | .TP
|
---|
6478 | .B \-r
|
---|
6479 | Make \fIname\fPs readonly. These names cannot then be assigned values
|
---|
6480 | by subsequent assignment statements or unset.
|
---|
6481 | .TP
|
---|
6482 | .B \-t
|
---|
6483 | Give each \fIname\fP the \fItrace\fP attribute.
|
---|
6484 | Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from
|
---|
6485 | the calling shell.
|
---|
6486 | The trace attribute has no special meaning for variables.
|
---|
6487 | .TP
|
---|
6488 | .B \-x
|
---|
6489 | Mark \fIname\fPs for export to subsequent commands via the environment.
|
---|
6490 | .PD
|
---|
6491 | .PP
|
---|
6492 | Using `+' instead of `\-'
|
---|
6493 | turns off the attribute instead, with the exception that \fB+a\fP
|
---|
6494 | may not be used to destroy an array variable. When used in a function,
|
---|
6495 | makes each
|
---|
6496 | \fIname\fP local, as with the
|
---|
6497 | .B local
|
---|
6498 | command.
|
---|
6499 | If a variable name is followed by =\fIvalue\fP, the value of
|
---|
6500 | the variable is set to \fIvalue\fP.
|
---|
6501 | The return value is 0 unless an invalid option is encountered,
|
---|
6502 | an attempt is made to define a function using
|
---|
6503 | .if n ``\-f foo=bar'',
|
---|
6504 | .if t \f(CW\-f foo=bar\fP,
|
---|
6505 | an attempt is made to assign a value to a readonly variable,
|
---|
6506 | an attempt is made to assign a value to an array variable without
|
---|
6507 | using the compound assignment syntax (see
|
---|
6508 | .B Arrays
|
---|
6509 | above), one of the \fInames\fP is not a valid shell variable name,
|
---|
6510 | an attempt is made to turn off readonly status for a readonly variable,
|
---|
6511 | an attempt is made to turn off array status for an array variable,
|
---|
6512 | or an attempt is made to display a non-existent function with \fB\-f\fP.
|
---|
6513 | .RE
|
---|
6514 | .TP
|
---|
6515 | .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP]
|
---|
6516 | Without options, displays the list of currently remembered directories.
|
---|
6517 | The default display is on a single line with directory names separated
|
---|
6518 | by spaces.
|
---|
6519 | Directories are added to the list with the
|
---|
6520 | .B pushd
|
---|
6521 | command; the
|
---|
6522 | .B popd
|
---|
6523 | command removes entries from the list.
|
---|
6524 | .RS
|
---|
6525 | .PD 0
|
---|
6526 | .TP
|
---|
6527 | \fB+\fP\fIn\fP
|
---|
6528 | Displays the \fIn\fPth entry counting from the left of the list
|
---|
6529 | shown by
|
---|
6530 | .B dirs
|
---|
6531 | when invoked without options, starting with zero.
|
---|
6532 | .TP
|
---|
6533 | \fB\-\fP\fIn\fP
|
---|
6534 | Displays the \fIn\fPth entry counting from the right of the list
|
---|
6535 | shown by
|
---|
6536 | .B dirs
|
---|
6537 | when invoked without options, starting with zero.
|
---|
6538 | .TP
|
---|
6539 | .B \-c
|
---|
6540 | Clears the directory stack by deleting all of the entries.
|
---|
6541 | .TP
|
---|
6542 | .B \-l
|
---|
6543 | Produces a longer listing; the default listing format uses a
|
---|
6544 | tilde to denote the home directory.
|
---|
6545 | .TP
|
---|
6546 | .B \-p
|
---|
6547 | Print the directory stack with one entry per line.
|
---|
6548 | .TP
|
---|
6549 | .B \-v
|
---|
6550 | Print the directory stack with one entry per line,
|
---|
6551 | prefixing each entry with its index in the stack.
|
---|
6552 | .PD
|
---|
6553 | .PP
|
---|
6554 | The return value is 0 unless an
|
---|
6555 | invalid option is supplied or \fIn\fP indexes beyond the end
|
---|
6556 | of the directory stack.
|
---|
6557 | .RE
|
---|
6558 | .TP
|
---|
6559 | \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...]
|
---|
6560 | Without options, each
|
---|
6561 | .I jobspec
|
---|
6562 | is removed from the table of active jobs.
|
---|
6563 | If the \fB\-h\fP option is given, each
|
---|
6564 | .I jobspec
|
---|
6565 | is not removed from the table, but is marked so that
|
---|
6566 | .SM
|
---|
6567 | .B SIGHUP
|
---|
6568 | is not sent to the job if the shell receives a
|
---|
6569 | .SM
|
---|
6570 | .BR SIGHUP .
|
---|
6571 | If no
|
---|
6572 | .I jobspec
|
---|
6573 | is present, and neither the
|
---|
6574 | .B \-a
|
---|
6575 | nor the
|
---|
6576 | .B \-r
|
---|
6577 | option is supplied, the \fIcurrent job\fP is used.
|
---|
6578 | If no
|
---|
6579 | .I jobspec
|
---|
6580 | is supplied, the
|
---|
6581 | .B \-a
|
---|
6582 | option means to remove or mark all jobs; the
|
---|
6583 | .B \-r
|
---|
6584 | option without a
|
---|
6585 | .I jobspec
|
---|
6586 | argument restricts operation to running jobs.
|
---|
6587 | The return value is 0 unless a
|
---|
6588 | .I jobspec
|
---|
6589 | does not specify a valid job.
|
---|
6590 | .TP
|
---|
6591 | \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
|
---|
6592 | Output the \fIarg\fPs, separated by spaces, followed by a newline.
|
---|
6593 | The return status is always 0.
|
---|
6594 | If \fB\-n\fP is specified, the trailing newline is
|
---|
6595 | suppressed. If the \fB\-e\fP option is given, interpretation of
|
---|
6596 | the following backslash-escaped characters is enabled. The
|
---|
6597 | .B \-E
|
---|
6598 | option disables the interpretation of these escape characters,
|
---|
6599 | even on systems where they are interpreted by default.
|
---|
6600 | The \fBxpg_echo\fP shell option may be used to
|
---|
6601 | dynamically determine whether or not \fBecho\fP expands these
|
---|
6602 | escape characters by default.
|
---|
6603 | .B echo
|
---|
6604 | does not interpret \fB\-\-\fP to mean the end of options.
|
---|
6605 | .B echo
|
---|
6606 | interprets the following escape sequences:
|
---|
6607 | .RS
|
---|
6608 | .PD 0
|
---|
6609 | .TP
|
---|
6610 | .B \ea
|
---|
6611 | alert (bell)
|
---|
6612 | .TP
|
---|
6613 | .B \eb
|
---|
6614 | backspace
|
---|
6615 | .TP
|
---|
6616 | .B \ec
|
---|
6617 | suppress trailing newline
|
---|
6618 | .TP
|
---|
6619 | .B \ee
|
---|
6620 | an escape character
|
---|
6621 | .TP
|
---|
6622 | .B \ef
|
---|
6623 | form feed
|
---|
6624 | .TP
|
---|
6625 | .B \en
|
---|
6626 | new line
|
---|
6627 | .TP
|
---|
6628 | .B \er
|
---|
6629 | carriage return
|
---|
6630 | .TP
|
---|
6631 | .B \et
|
---|
6632 | horizontal tab
|
---|
6633 | .TP
|
---|
6634 | .B \ev
|
---|
6635 | vertical tab
|
---|
6636 | .TP
|
---|
6637 | .B \e\e
|
---|
6638 | backslash
|
---|
6639 | .TP
|
---|
6640 | .B \e0\fInnn\fP
|
---|
6641 | the eight-bit character whose value is the octal value \fInnn\fP
|
---|
6642 | (zero to three octal digits)
|
---|
6643 | .TP
|
---|
6644 | .B \e\fInnn\fP
|
---|
6645 | the eight-bit character whose value is the octal value \fInnn\fP
|
---|
6646 | (one to three octal digits)
|
---|
6647 | .TP
|
---|
6648 | .B \ex\fIHH\fP
|
---|
6649 | the eight-bit character whose value is the hexadecimal value \fIHH\fP
|
---|
6650 | (one or two hex digits)
|
---|
6651 | .PD
|
---|
6652 | .RE
|
---|
6653 | .TP
|
---|
6654 | \fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
|
---|
6655 | Enable and disable builtin shell commands.
|
---|
6656 | Disabling a builtin allows a disk command which has the same name
|
---|
6657 | as a shell builtin to be executed without specifying a full pathname,
|
---|
6658 | even though the shell normally searches for builtins before disk commands.
|
---|
6659 | If \fB\-n\fP is used, each \fIname\fP
|
---|
6660 | is disabled; otherwise,
|
---|
6661 | \fInames\fP are enabled. For example, to use the
|
---|
6662 | .B test
|
---|
6663 | binary found via the
|
---|
6664 | .SM
|
---|
6665 | .B PATH
|
---|
6666 | instead of the shell builtin version, run
|
---|
6667 | .if t \f(CWenable -n test\fP.
|
---|
6668 | .if n ``enable -n test''.
|
---|
6669 | The
|
---|
6670 | .B \-f
|
---|
6671 | option means to load the new builtin command
|
---|
6672 | .I name
|
---|
6673 | from shared object
|
---|
6674 | .IR filename ,
|
---|
6675 | on systems that support dynamic loading. The
|
---|
6676 | .B \-d
|
---|
6677 | option will delete a builtin previously loaded with
|
---|
6678 | .BR \-f .
|
---|
6679 | If no \fIname\fP arguments are given, or if the
|
---|
6680 | .B \-p
|
---|
6681 | option is supplied, a list of shell builtins is printed.
|
---|
6682 | With no other option arguments, the list consists of all enabled
|
---|
6683 | shell builtins.
|
---|
6684 | If \fB\-n\fP is supplied, only disabled builtins are printed.
|
---|
6685 | If \fB\-a\fP is supplied, the list printed includes all builtins, with an
|
---|
6686 | indication of whether or not each is enabled.
|
---|
6687 | If \fB\-s\fP is supplied, the output is restricted to the POSIX
|
---|
6688 | \fIspecial\fP builtins.
|
---|
6689 | The return value is 0 unless a
|
---|
6690 | .I name
|
---|
6691 | is not a shell builtin or there is an error loading a new builtin
|
---|
6692 | from a shared object.
|
---|
6693 | .TP
|
---|
6694 | \fBeval\fP [\fIarg\fP ...]
|
---|
6695 | The \fIarg\fPs are read and concatenated together into a single
|
---|
6696 | command. This command is then read and executed by the shell, and
|
---|
6697 | its exit status is returned as the value of
|
---|
6698 | .BR eval .
|
---|
6699 | If there are no
|
---|
6700 | .IR args ,
|
---|
6701 | or only null arguments,
|
---|
6702 | .B eval
|
---|
6703 | returns 0.
|
---|
6704 | .TP
|
---|
6705 | \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]]
|
---|
6706 | If
|
---|
6707 | .I command
|
---|
6708 | is specified, it replaces the shell.
|
---|
6709 | No new process is created. The
|
---|
6710 | .I arguments
|
---|
6711 | become the arguments to \fIcommand\fP.
|
---|
6712 | If the
|
---|
6713 | .B \-l
|
---|
6714 | option is supplied,
|
---|
6715 | the shell places a dash at the beginning of the zeroth arg passed to
|
---|
6716 | .IR command .
|
---|
6717 | This is what
|
---|
6718 | .IR login (1)
|
---|
6719 | does. The
|
---|
6720 | .B \-c
|
---|
6721 | option causes
|
---|
6722 | .I command
|
---|
6723 | to be executed with an empty environment. If
|
---|
6724 | .B \-a
|
---|
6725 | is supplied, the shell passes
|
---|
6726 | .I name
|
---|
6727 | as the zeroth argument to the executed command. If
|
---|
6728 | .I command
|
---|
6729 | cannot be executed for some reason, a non-interactive shell exits,
|
---|
6730 | unless the shell option
|
---|
6731 | .B execfail
|
---|
6732 | is enabled, in which case it returns failure.
|
---|
6733 | An interactive shell returns failure if the file cannot be executed.
|
---|
6734 | If
|
---|
6735 | .I command
|
---|
6736 | is not specified, any redirections take effect in the current shell,
|
---|
6737 | and the return status is 0. If there is a redirection error, the
|
---|
6738 | return status is 1.
|
---|
6739 | .TP
|
---|
6740 | \fBexit\fP [\fIn\fP]
|
---|
6741 | Cause the shell to exit
|
---|
6742 | with a status of \fIn\fP. If
|
---|
6743 | .I n
|
---|
6744 | is omitted, the exit status
|
---|
6745 | is that of the last command executed.
|
---|
6746 | A trap on
|
---|
6747 | .SM
|
---|
6748 | .B EXIT
|
---|
6749 | is executed before the shell terminates.
|
---|
6750 | .TP
|
---|
6751 | \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
|
---|
6752 | .PD 0
|
---|
6753 | .TP
|
---|
6754 | .B export \-p
|
---|
6755 | .PD
|
---|
6756 | The supplied
|
---|
6757 | .I names
|
---|
6758 | are marked for automatic export to the environment of
|
---|
6759 | subsequently executed commands. If the
|
---|
6760 | .B \-f
|
---|
6761 | option is given,
|
---|
6762 | the
|
---|
6763 | .I names
|
---|
6764 | refer to functions.
|
---|
6765 | If no
|
---|
6766 | .I names
|
---|
6767 | are given, or if the
|
---|
6768 | .B \-p
|
---|
6769 | option is supplied, a list
|
---|
6770 | of all names that are exported in this shell is printed.
|
---|
6771 | The
|
---|
6772 | .B \-n
|
---|
6773 | option causes the export property to be removed from each
|
---|
6774 | \fIname\fP.
|
---|
6775 | If a variable name is followed by =\fIword\fP, the value of
|
---|
6776 | the variable is set to \fIword\fP.
|
---|
6777 | .B export
|
---|
6778 | returns an exit status of 0 unless an invalid option is
|
---|
6779 | encountered,
|
---|
6780 | one of the \fInames\fP is not a valid shell variable name, or
|
---|
6781 | .B \-f
|
---|
6782 | is supplied with a
|
---|
6783 | .I name
|
---|
6784 | that is not a function.
|
---|
6785 | .TP
|
---|
6786 | \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
|
---|
6787 | .PD 0
|
---|
6788 | .TP
|
---|
6789 | \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
|
---|
6790 | .PD
|
---|
6791 | Fix Command. In the first form, a range of commands from
|
---|
6792 | .I first
|
---|
6793 | to
|
---|
6794 | .I last
|
---|
6795 | is selected from the history list.
|
---|
6796 | .I First
|
---|
6797 | and
|
---|
6798 | .I last
|
---|
6799 | may be specified as a string (to locate the last command beginning
|
---|
6800 | with that string) or as a number (an index into the history list,
|
---|
6801 | where a negative number is used as an offset from the current
|
---|
6802 | command number). If
|
---|
6803 | .I last
|
---|
6804 | is not specified it is set to
|
---|
6805 | the current command for listing (so that
|
---|
6806 | .if n ``fc \-l \-10''
|
---|
6807 | .if t \f(CWfc \-l \-10\fP
|
---|
6808 | prints the last 10 commands) and to
|
---|
6809 | .I first
|
---|
6810 | otherwise.
|
---|
6811 | If
|
---|
6812 | .I first
|
---|
6813 | is not specified it is set to the previous
|
---|
6814 | command for editing and \-16 for listing.
|
---|
6815 | .sp 1
|
---|
6816 | The
|
---|
6817 | .B \-n
|
---|
6818 | option suppresses
|
---|
6819 | the command numbers when listing. The
|
---|
6820 | .B \-r
|
---|
6821 | option reverses the order of
|
---|
6822 | the commands. If the
|
---|
6823 | .B \-l
|
---|
6824 | option is given,
|
---|
6825 | the commands are listed on
|
---|
6826 | standard output. Otherwise, the editor given by
|
---|
6827 | .I ename
|
---|
6828 | is invoked
|
---|
6829 | on a file containing those commands. If
|
---|
6830 | .I ename
|
---|
6831 | is not given, the
|
---|
6832 | value of the
|
---|
6833 | .SM
|
---|
6834 | .B FCEDIT
|
---|
6835 | variable is used, and
|
---|
6836 | the value of
|
---|
6837 | .SM
|
---|
6838 | .B EDITOR
|
---|
6839 | if
|
---|
6840 | .SM
|
---|
6841 | .B FCEDIT
|
---|
6842 | is not set. If neither variable is set,
|
---|
6843 | .FN vi
|
---|
6844 | is used. When editing is complete, the edited commands are
|
---|
6845 | echoed and executed.
|
---|
6846 | .sp 1
|
---|
6847 | In the second form, \fIcommand\fP is re-executed after each instance
|
---|
6848 | of \fIpat\fP is replaced by \fIrep\fP.
|
---|
6849 | A useful alias to use with this is
|
---|
6850 | .if n ``r="fc -s"'',
|
---|
6851 | .if t \f(CWr='fc \-s'\fP,
|
---|
6852 | so that typing
|
---|
6853 | .if n ``r cc''
|
---|
6854 | .if t \f(CWr cc\fP
|
---|
6855 | runs the last command beginning with
|
---|
6856 | .if n ``cc''
|
---|
6857 | .if t \f(CWcc\fP
|
---|
6858 | and typing
|
---|
6859 | .if n ``r''
|
---|
6860 | .if t \f(CWr\fP
|
---|
6861 | re-executes the last command.
|
---|
6862 | .sp 1
|
---|
6863 | If the first form is used, the return value is 0 unless an invalid
|
---|
6864 | option is encountered or
|
---|
6865 | .I first
|
---|
6866 | or
|
---|
6867 | .I last
|
---|
6868 | specify history lines out of range.
|
---|
6869 | If the
|
---|
6870 | .B \-e
|
---|
6871 | option is supplied, the return value is the value of the last
|
---|
6872 | command executed or failure if an error occurs with the temporary
|
---|
6873 | file of commands. If the second form is used, the return status
|
---|
6874 | is that of the command re-executed, unless
|
---|
6875 | .I cmd
|
---|
6876 | does not specify a valid history line, in which case
|
---|
6877 | .B fc
|
---|
6878 | returns failure.
|
---|
6879 | .TP
|
---|
6880 | \fBfg\fP [\fIjobspec\fP]
|
---|
6881 | Resume
|
---|
6882 | .I jobspec
|
---|
6883 | in the foreground, and make it the current job.
|
---|
6884 | If
|
---|
6885 | .I jobspec
|
---|
6886 | is not present, the shell's notion of the \fIcurrent job\fP is used.
|
---|
6887 | The return value is that of the command placed into the foreground,
|
---|
6888 | or failure if run when job control is disabled or, when run with
|
---|
6889 | job control enabled, if
|
---|
6890 | .I jobspec
|
---|
6891 | does not specify a valid job or
|
---|
6892 | .I jobspec
|
---|
6893 | specifies a job that was started without job control.
|
---|
6894 | .TP
|
---|
6895 | \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP]
|
---|
6896 | .B getopts
|
---|
6897 | is used by shell procedures to parse positional parameters.
|
---|
6898 | .I optstring
|
---|
6899 | contains the option characters to be recognized; if a character
|
---|
6900 | is followed by a colon, the option is expected to have an
|
---|
6901 | argument, which should be separated from it by white space.
|
---|
6902 | The colon and question mark characters may not be used as
|
---|
6903 | option characters.
|
---|
6904 | Each time it is invoked,
|
---|
6905 | .B getopts
|
---|
6906 | places the next option in the shell variable
|
---|
6907 | .IR name ,
|
---|
6908 | initializing
|
---|
6909 | .I name
|
---|
6910 | if it does not exist,
|
---|
6911 | and the index of the next argument to be processed into the
|
---|
6912 | variable
|
---|
6913 | .SM
|
---|
6914 | .BR OPTIND .
|
---|
6915 | .SM
|
---|
6916 | .B OPTIND
|
---|
6917 | is initialized to 1 each time the shell or a shell script
|
---|
6918 | is invoked. When an option requires an argument,
|
---|
6919 | .B getopts
|
---|
6920 | places that argument into the variable
|
---|
6921 | .SM
|
---|
6922 | .BR OPTARG .
|
---|
6923 | The shell does not reset
|
---|
6924 | .SM
|
---|
6925 | .B OPTIND
|
---|
6926 | automatically; it must be manually reset between multiple
|
---|
6927 | calls to
|
---|
6928 | .B getopts
|
---|
6929 | within the same shell invocation if a new set of parameters
|
---|
6930 | is to be used.
|
---|
6931 | .sp 1
|
---|
6932 | When the end of options is encountered, \fBgetopts\fP exits with a
|
---|
6933 | return value greater than zero.
|
---|
6934 | \fBOPTIND\fP is set to the index of the first non-option argument,
|
---|
6935 | and \fBname\fP is set to ?.
|
---|
6936 | .sp 1
|
---|
6937 | .B getopts
|
---|
6938 | normally parses the positional parameters, but if more arguments are
|
---|
6939 | given in
|
---|
6940 | .IR args ,
|
---|
6941 | .B getopts
|
---|
6942 | parses those instead.
|
---|
6943 | .sp 1
|
---|
6944 | .B getopts
|
---|
6945 | can report errors in two ways. If the first character of
|
---|
6946 | .I optstring
|
---|
6947 | is a colon,
|
---|
6948 | .I silent
|
---|
6949 | error reporting is used. In normal operation diagnostic messages
|
---|
6950 | are printed when invalid options or missing option arguments are
|
---|
6951 | encountered.
|
---|
6952 | If the variable
|
---|
6953 | .SM
|
---|
6954 | .B OPTERR
|
---|
6955 | is set to 0, no error messages will be displayed, even if the first
|
---|
6956 | character of
|
---|
6957 | .I optstring
|
---|
6958 | is not a colon.
|
---|
6959 | .sp 1
|
---|
6960 | If an invalid option is seen,
|
---|
6961 | .B getopts
|
---|
6962 | places ? into
|
---|
6963 | .I name
|
---|
6964 | and, if not silent,
|
---|
6965 | prints an error message and unsets
|
---|
6966 | .SM
|
---|
6967 | .BR OPTARG .
|
---|
6968 | If
|
---|
6969 | .B getopts
|
---|
6970 | is silent,
|
---|
6971 | the option character found is placed in
|
---|
6972 | .SM
|
---|
6973 | .B OPTARG
|
---|
6974 | and no diagnostic message is printed.
|
---|
6975 | .sp 1
|
---|
6976 | If a required argument is not found, and
|
---|
6977 | .B getopts
|
---|
6978 | is not silent,
|
---|
6979 | a question mark (\^\fB?\fP\^) is placed in
|
---|
6980 | .IR name ,
|
---|
6981 | .SM
|
---|
6982 | .B OPTARG
|
---|
6983 | is unset, and a diagnostic message is printed.
|
---|
6984 | If
|
---|
6985 | .B getopts
|
---|
6986 | is silent, then a colon (\^\fB:\fP\^) is placed in
|
---|
6987 | .I name
|
---|
6988 | and
|
---|
6989 | .SM
|
---|
6990 | .B OPTARG
|
---|
6991 | is set to the option character found.
|
---|
6992 | .sp 1
|
---|
6993 | .B getopts
|
---|
6994 | returns true if an option, specified or unspecified, is found.
|
---|
6995 | It returns false if the end of options is encountered or an
|
---|
6996 | error occurs.
|
---|
6997 | .TP
|
---|
6998 | \fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP]
|
---|
6999 | For each
|
---|
7000 | .IR name ,
|
---|
7001 | the full file name of the command is determined by searching
|
---|
7002 | the directories in
|
---|
7003 | .B $PATH
|
---|
7004 | and remembered.
|
---|
7005 | If the
|
---|
7006 | .B \-p
|
---|
7007 | option is supplied, no path search is performed, and
|
---|
7008 | .I filename
|
---|
7009 | is used as the full file name of the command.
|
---|
7010 | The
|
---|
7011 | .B \-r
|
---|
7012 | option causes the shell to forget all
|
---|
7013 | remembered locations.
|
---|
7014 | The
|
---|
7015 | .B \-d
|
---|
7016 | option causes the shell to forget the remembered location of each \fIname\fP.
|
---|
7017 | If the
|
---|
7018 | .B \-t
|
---|
7019 | option is supplied, the full pathname to which each \fIname\fP corresponds
|
---|
7020 | is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP,
|
---|
7021 | the \fIname\fP is printed before the hashed full pathname.
|
---|
7022 | The
|
---|
7023 | .B \-l
|
---|
7024 | option causes output to be displayed in a format that may be reused as input.
|
---|
7025 | If no arguments are given, or if only \fB\-l\fP is supplied,
|
---|
7026 | information about remembered commands is printed.
|
---|
7027 | The return status is true unless a
|
---|
7028 | .I name
|
---|
7029 | is not found or an invalid option is supplied.
|
---|
7030 | .TP
|
---|
7031 | \fBhelp\fP [\fB\-s\fP] [\fIpattern\fP]
|
---|
7032 | Display helpful information about builtin commands. If
|
---|
7033 | .I pattern
|
---|
7034 | is specified,
|
---|
7035 | .B help
|
---|
7036 | gives detailed help on all commands matching
|
---|
7037 | .IR pattern ;
|
---|
7038 | otherwise help for all the builtins and shell control structures
|
---|
7039 | is printed.
|
---|
7040 | The \fB\-s\fP option restricts the information displayed to a short
|
---|
7041 | usage synopsis.
|
---|
7042 | The return status is 0 unless no command matches
|
---|
7043 | .IR pattern .
|
---|
7044 | .TP
|
---|
7045 | \fBhistory [\fIn\fP]
|
---|
7046 | .PD 0
|
---|
7047 | .TP
|
---|
7048 | \fBhistory\fP \fB\-c\fP
|
---|
7049 | .TP
|
---|
7050 | \fBhistory \-d\fP \fIoffset\fP
|
---|
7051 | .TP
|
---|
7052 | \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
|
---|
7053 | .TP
|
---|
7054 | \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
|
---|
7055 | .TP
|
---|
7056 | \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
|
---|
7057 | .PD
|
---|
7058 | With no options, display the command
|
---|
7059 | history list with line numbers. Lines listed
|
---|
7060 | with a
|
---|
7061 | .B *
|
---|
7062 | have been modified. An argument of
|
---|
7063 | .I n
|
---|
7064 | lists only the last
|
---|
7065 | .I n
|
---|
7066 | lines.
|
---|
7067 | If the shell variable \fBHISTTIMEFORMAT\fP is set and not null,
|
---|
7068 | it is used as a format string for \fIstrftime\fP(3) to display
|
---|
7069 | the time stamp associated with each displayed history entry.
|
---|
7070 | No intervening blank is printed between the formatted time stamp
|
---|
7071 | and the history line.
|
---|
7072 | If \fIfilename\fP is supplied, it is used as the
|
---|
7073 | name of the history file; if not, the value of
|
---|
7074 | .SM
|
---|
7075 | .B HISTFILE
|
---|
7076 | is used. Options, if supplied, have the following meanings:
|
---|
7077 | .RS
|
---|
7078 | .PD 0
|
---|
7079 | .TP
|
---|
7080 | .B \-c
|
---|
7081 | Clear the history list by deleting all the entries.
|
---|
7082 | .TP
|
---|
7083 | \fB\-d\fP \fIoffset\fP
|
---|
7084 | Delete the history entry at position \fIoffset\fP.
|
---|
7085 | .TP
|
---|
7086 | .B \-a
|
---|
7087 | Append the ``new'' history lines (history lines entered since the
|
---|
7088 | beginning of the current \fBbash\fP session) to the history file.
|
---|
7089 | .TP
|
---|
7090 | .B \-n
|
---|
7091 | Read the history lines not already read from the history
|
---|
7092 | file into the current history list. These are lines
|
---|
7093 | appended to the history file since the beginning of the
|
---|
7094 | current \fBbash\fP session.
|
---|
7095 | .TP
|
---|
7096 | .B \-r
|
---|
7097 | Read the contents of the history file
|
---|
7098 | and use them as the current history.
|
---|
7099 | .TP
|
---|
7100 | .B \-w
|
---|
7101 | Write the current history to the history file, overwriting the
|
---|
7102 | history file's contents.
|
---|
7103 | .TP
|
---|
7104 | .B \-p
|
---|
7105 | Perform history substitution on the following \fIargs\fP and display
|
---|
7106 | the result on the standard output.
|
---|
7107 | Does not store the results in the history list.
|
---|
7108 | Each \fIarg\fP must be quoted to disable normal history expansion.
|
---|
7109 | .TP
|
---|
7110 | .B \-s
|
---|
7111 | Store the
|
---|
7112 | .I args
|
---|
7113 | in the history list as a single entry. The last command in the
|
---|
7114 | history list is removed before the
|
---|
7115 | .I args
|
---|
7116 | are added.
|
---|
7117 | .PD
|
---|
7118 | .PP
|
---|
7119 | If the \fBHISTTIMEFORMAT\fP is set, the time stamp information
|
---|
7120 | associated with each history entry is written to the history file.
|
---|
7121 | The return value is 0 unless an invalid option is encountered, an
|
---|
7122 | error occurs while reading or writing the history file, an invalid
|
---|
7123 | \fIoffset\fP is supplied as an argument to \fB\-d\fP, or the
|
---|
7124 | history expansion supplied as an argument to \fB\-p\fP fails.
|
---|
7125 | .RE
|
---|
7126 | .TP
|
---|
7127 | \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
|
---|
7128 | .PD 0
|
---|
7129 | .TP
|
---|
7130 | \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
|
---|
7131 | .PD
|
---|
7132 | The first form lists the active jobs. The options have the following
|
---|
7133 | meanings:
|
---|
7134 | .RS
|
---|
7135 | .PD 0
|
---|
7136 | .TP
|
---|
7137 | .B \-l
|
---|
7138 | List process IDs
|
---|
7139 | in addition to the normal information.
|
---|
7140 | .TP
|
---|
7141 | .B \-p
|
---|
7142 | List only the process ID of the job's process group
|
---|
7143 | leader.
|
---|
7144 | .TP
|
---|
7145 | .B \-n
|
---|
7146 | Display information only about jobs that have changed status since
|
---|
7147 | the user was last notified of their status.
|
---|
7148 | .TP
|
---|
7149 | .B \-r
|
---|
7150 | Restrict output to running jobs.
|
---|
7151 | .TP
|
---|
7152 | .B \-s
|
---|
7153 | Restrict output to stopped jobs.
|
---|
7154 | .PD
|
---|
7155 | .PP
|
---|
7156 | If
|
---|
7157 | .I jobspec
|
---|
7158 | is given, output is restricted to information about that job.
|
---|
7159 | The return status is 0 unless an invalid option is encountered
|
---|
7160 | or an invalid
|
---|
7161 | .I jobspec
|
---|
7162 | is supplied.
|
---|
7163 | .PP
|
---|
7164 | If the
|
---|
7165 | .B \-x
|
---|
7166 | option is supplied,
|
---|
7167 | .B jobs
|
---|
7168 | replaces any
|
---|
7169 | .I jobspec
|
---|
7170 | found in
|
---|
7171 | .I command
|
---|
7172 | or
|
---|
7173 | .I args
|
---|
7174 | with the corresponding process group ID, and executes
|
---|
7175 | .I command
|
---|
7176 | passing it
|
---|
7177 | .IR args ,
|
---|
7178 | returning its exit status.
|
---|
7179 | .RE
|
---|
7180 | .TP
|
---|
7181 | \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
|
---|
7182 | .PD 0
|
---|
7183 | .TP
|
---|
7184 | \fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP]
|
---|
7185 | .PD
|
---|
7186 | Send the signal named by
|
---|
7187 | .I sigspec
|
---|
7188 | or
|
---|
7189 | .I signum
|
---|
7190 | to the processes named by
|
---|
7191 | .I pid
|
---|
7192 | or
|
---|
7193 | .IR jobspec .
|
---|
7194 | .I sigspec
|
---|
7195 | is either a case-insensitive signal name such as
|
---|
7196 | .SM
|
---|
7197 | .B SIGKILL
|
---|
7198 | (with or without the
|
---|
7199 | .SM
|
---|
7200 | .B SIG
|
---|
7201 | prefix) or a signal number;
|
---|
7202 | .I signum
|
---|
7203 | is a signal number.
|
---|
7204 | If
|
---|
7205 | .I sigspec
|
---|
7206 | is not present, then
|
---|
7207 | .SM
|
---|
7208 | .B SIGTERM
|
---|
7209 | is assumed.
|
---|
7210 | An argument of
|
---|
7211 | .B \-l
|
---|
7212 | lists the signal names.
|
---|
7213 | If any arguments are supplied when
|
---|
7214 | .B \-l
|
---|
7215 | is given, the names of the signals corresponding to the arguments are
|
---|
7216 | listed, and the return status is 0.
|
---|
7217 | The \fIexit_status\fP argument to
|
---|
7218 | .B \-l
|
---|
7219 | is a number specifying either a signal number or the exit status of
|
---|
7220 | a process terminated by a signal.
|
---|
7221 | .B kill
|
---|
7222 | returns true if at least one signal was successfully sent, or false
|
---|
7223 | if an error occurs or an invalid option is encountered.
|
---|
7224 | .TP
|
---|
7225 | \fBlet\fP \fIarg\fP [\fIarg\fP ...]
|
---|
7226 | Each
|
---|
7227 | .I arg
|
---|
7228 | is an arithmetic expression to be evaluated (see
|
---|
7229 | .SM
|
---|
7230 | .BR "ARITHMETIC EVALUATION" ).
|
---|
7231 | If the last
|
---|
7232 | .I arg
|
---|
7233 | evaluates to 0,
|
---|
7234 | .B let
|
---|
7235 | returns 1; 0 is returned otherwise.
|
---|
7236 | .TP
|
---|
7237 | \fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
---|
7238 | For each argument, a local variable named
|
---|
7239 | .I name
|
---|
7240 | is created, and assigned
|
---|
7241 | .IR value .
|
---|
7242 | The \fIoption\fP can be any of the options accepted by \fBdeclare\fP.
|
---|
7243 | When
|
---|
7244 | .B local
|
---|
7245 | is used within a function, it causes the variable
|
---|
7246 | .I name
|
---|
7247 | to have a visible scope restricted to that function and its children.
|
---|
7248 | With no operands,
|
---|
7249 | .B local
|
---|
7250 | writes a list of local variables to the standard output. It is
|
---|
7251 | an error to use
|
---|
7252 | .B local
|
---|
7253 | when not within a function. The return status is 0 unless
|
---|
7254 | .B local
|
---|
7255 | is used outside a function, an invalid
|
---|
7256 | .I name
|
---|
7257 | is supplied, or
|
---|
7258 | \fIname\fP is a readonly variable.
|
---|
7259 | .TP
|
---|
7260 | .B logout
|
---|
7261 | Exit a login shell.
|
---|
7262 | .TP
|
---|
7263 | \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
|
---|
7264 | Removes entries from the directory stack. With no arguments,
|
---|
7265 | removes the top directory from the stack, and performs a
|
---|
7266 | .B cd
|
---|
7267 | to the new top directory.
|
---|
7268 | Arguments, if supplied, have the following meanings:
|
---|
7269 | .RS
|
---|
7270 | .PD 0
|
---|
7271 | .TP
|
---|
7272 | \fB+\fP\fIn\fP
|
---|
7273 | Removes the \fIn\fPth entry counting from the left of the list
|
---|
7274 | shown by
|
---|
7275 | .BR dirs ,
|
---|
7276 | starting with zero. For example:
|
---|
7277 | .if n ``popd +0''
|
---|
7278 | .if t \f(CWpopd +0\fP
|
---|
7279 | removes the first directory,
|
---|
7280 | .if n ``popd +1''
|
---|
7281 | .if t \f(CWpopd +1\fP
|
---|
7282 | the second.
|
---|
7283 | .TP
|
---|
7284 | \fB\-\fP\fIn\fP
|
---|
7285 | Removes the \fIn\fPth entry counting from the right of the list
|
---|
7286 | shown by
|
---|
7287 | .BR dirs ,
|
---|
7288 | starting with zero. For example:
|
---|
7289 | .if n ``popd -0''
|
---|
7290 | .if t \f(CWpopd -0\fP
|
---|
7291 | removes the last directory,
|
---|
7292 | .if n ``popd -1''
|
---|
7293 | .if t \f(CWpopd -1\fP
|
---|
7294 | the next to last.
|
---|
7295 | .TP
|
---|
7296 | .B \-n
|
---|
7297 | Suppresses the normal change of directory when removing directories
|
---|
7298 | from the stack, so that only the stack is manipulated.
|
---|
7299 | .PD
|
---|
7300 | .PP
|
---|
7301 | If the
|
---|
7302 | .B popd
|
---|
7303 | command is successful, a
|
---|
7304 | .B dirs
|
---|
7305 | is performed as well, and the return status is 0.
|
---|
7306 | .B popd
|
---|
7307 | returns false if an invalid option is encountered, the directory stack
|
---|
7308 | is empty, a non-existent directory stack entry is specified, or the
|
---|
7309 | directory change fails.
|
---|
7310 | .RE
|
---|
7311 | .TP
|
---|
7312 | \fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP]
|
---|
7313 | Write the formatted \fIarguments\fP to the standard output under the
|
---|
7314 | control of the \fIformat\fP.
|
---|
7315 | The \fIformat\fP is a character string which contains three types of objects:
|
---|
7316 | plain characters, which are simply copied to standard output, character
|
---|
7317 | escape sequences, which are converted and copied to the standard output, and
|
---|
7318 | format specifications, each of which causes printing of the next successive
|
---|
7319 | \fIargument\fP.
|
---|
7320 | In addition to the standard \fIprintf\fP(1) formats, \fB%b\fP causes
|
---|
7321 | \fBprintf\fP to expand backslash escape sequences in the corresponding
|
---|
7322 | \fIargument\fP (except that \fB\ec\fP terminates output, backslashes in
|
---|
7323 | \fB\e'\fP, \fB\e"\fP, and \fB\e?\fP are not removed, and octal escapes
|
---|
7324 | beginning with \fB\e0\fP may contain up to four digits),
|
---|
7325 | and \fB%q\fP causes \fBprintf\fP to output the corresponding
|
---|
7326 | \fIargument\fP in a format that can be reused as shell input.
|
---|
7327 | .sp 1
|
---|
7328 | The \fB\-v\fP option causes the output to be assigned to the variable
|
---|
7329 | \fIvar\fP rather than being printed to the standard output.
|
---|
7330 | .sp 1
|
---|
7331 | The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
|
---|
7332 | If the \fIformat\fP requires more \fIarguments\fP than are supplied, the
|
---|
7333 | extra format specifications behave as if a zero value or null string, as
|
---|
7334 | appropriate, had been supplied. The return value is zero on success,
|
---|
7335 | non-zero on failure.
|
---|
7336 | .TP
|
---|
7337 | \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
|
---|
7338 | .PD 0
|
---|
7339 | .TP
|
---|
7340 | \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
|
---|
7341 | .PD
|
---|
7342 | Adds a directory to the top of the directory stack, or rotates
|
---|
7343 | the stack, making the new top of the stack the current working
|
---|
7344 | directory. With no arguments, exchanges the top two directories
|
---|
7345 | and returns 0, unless the directory stack is empty.
|
---|
7346 | Arguments, if supplied, have the following meanings:
|
---|
7347 | .RS
|
---|
7348 | .PD 0
|
---|
7349 | .TP
|
---|
7350 | \fB+\fP\fIn\fP
|
---|
7351 | Rotates the stack so that the \fIn\fPth directory
|
---|
7352 | (counting from the left of the list shown by
|
---|
7353 | .BR dirs ,
|
---|
7354 | starting with zero)
|
---|
7355 | is at the top.
|
---|
7356 | .TP
|
---|
7357 | \fB\-\fP\fIn\fP
|
---|
7358 | Rotates the stack so that the \fIn\fPth directory
|
---|
7359 | (counting from the right of the list shown by
|
---|
7360 | .BR dirs ,
|
---|
7361 | starting with zero) is at the top.
|
---|
7362 | .TP
|
---|
7363 | .B \-n
|
---|
7364 | Suppresses the normal change of directory when adding directories
|
---|
7365 | to the stack, so that only the stack is manipulated.
|
---|
7366 | .TP
|
---|
7367 | .I dir
|
---|
7368 | Adds
|
---|
7369 | .I dir
|
---|
7370 | to the directory stack at the top, making it the
|
---|
7371 | new current working directory.
|
---|
7372 | .PD
|
---|
7373 | .PP
|
---|
7374 | If the
|
---|
7375 | .B pushd
|
---|
7376 | command is successful, a
|
---|
7377 | .B dirs
|
---|
7378 | is performed as well.
|
---|
7379 | If the first form is used,
|
---|
7380 | .B pushd
|
---|
7381 | returns 0 unless the cd to
|
---|
7382 | .I dir
|
---|
7383 | fails. With the second form,
|
---|
7384 | .B pushd
|
---|
7385 | returns 0 unless the directory stack is empty,
|
---|
7386 | a non-existent directory stack element is specified,
|
---|
7387 | or the directory change to the specified new current directory
|
---|
7388 | fails.
|
---|
7389 | .RE
|
---|
7390 | .TP
|
---|
7391 | \fBpwd\fP [\fB\-LP\fP]
|
---|
7392 | Print the absolute pathname of the current working directory.
|
---|
7393 | The pathname printed contains no symbolic links if the
|
---|
7394 | .B \-P
|
---|
7395 | option is supplied or the
|
---|
7396 | .B \-o physical
|
---|
7397 | option to the
|
---|
7398 | .B set
|
---|
7399 | builtin command is enabled.
|
---|
7400 | If the
|
---|
7401 | .B \-L
|
---|
7402 | option is used, the pathname printed may contain symbolic links.
|
---|
7403 | The return status is 0 unless an error occurs while
|
---|
7404 | reading the name of the current directory or an
|
---|
7405 | invalid option is supplied.
|
---|
7406 | .TP
|
---|
7407 | \fBread\fP [\fB\-ers\fP] [\fB\-u\fP \fIfd\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...]
|
---|
7408 | One line is read from the standard input, or from the file descriptor
|
---|
7409 | \fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
|
---|
7410 | is assigned to the first
|
---|
7411 | .IR name ,
|
---|
7412 | the second word to the second
|
---|
7413 | .IR name ,
|
---|
7414 | and so on, with leftover words and their intervening separators assigned
|
---|
7415 | to the last
|
---|
7416 | .IR name .
|
---|
7417 | If there are fewer words read from the input stream than names,
|
---|
7418 | the remaining names are assigned empty values.
|
---|
7419 | The characters in
|
---|
7420 | .SM
|
---|
7421 | .B IFS
|
---|
7422 | are used to split the line into words.
|
---|
7423 | The backslash character (\fB\e\fP) may be used to remove any special
|
---|
7424 | meaning for the next character read and for line continuation.
|
---|
7425 | Options, if supplied, have the following meanings:
|
---|
7426 | .RS
|
---|
7427 | .PD 0
|
---|
7428 | .TP
|
---|
7429 | .B \-a \fIaname\fP
|
---|
7430 | The words are assigned to sequential indices
|
---|
7431 | of the array variable
|
---|
7432 | .IR aname ,
|
---|
7433 | starting at 0.
|
---|
7434 | .I aname
|
---|
7435 | is unset before any new values are assigned.
|
---|
7436 | Other \fIname\fP arguments are ignored.
|
---|
7437 | .TP
|
---|
7438 | .B \-d \fIdelim\fP
|
---|
7439 | The first character of \fIdelim\fP is used to terminate the input line,
|
---|
7440 | rather than newline.
|
---|
7441 | .TP
|
---|
7442 | .B \-e
|
---|
7443 | If the standard input
|
---|
7444 | is coming from a terminal,
|
---|
7445 | .B readline
|
---|
7446 | (see
|
---|
7447 | .SM
|
---|
7448 | .B READLINE
|
---|
7449 | above) is used to obtain the line.
|
---|
7450 | .TP
|
---|
7451 | .B \-n \fInchars\fP
|
---|
7452 | \fBread\fP returns after reading \fInchars\fP characters rather than
|
---|
7453 | waiting for a complete line of input.
|
---|
7454 | .TP
|
---|
7455 | .B \-p \fIprompt\fP
|
---|
7456 | Display \fIprompt\fP on standard error, without a
|
---|
7457 | trailing newline, before attempting to read any input. The prompt
|
---|
7458 | is displayed only if input is coming from a terminal.
|
---|
7459 | .TP
|
---|
7460 | .B \-r
|
---|
7461 | Backslash does not act as an escape character.
|
---|
7462 | The backslash is considered to be part of the line.
|
---|
7463 | In particular, a backslash-newline pair may not be used as a line
|
---|
7464 | continuation.
|
---|
7465 | .TP
|
---|
7466 | .B \-s
|
---|
7467 | Silent mode. If input is coming from a terminal, characters are
|
---|
7468 | not echoed.
|
---|
7469 | .TP
|
---|
7470 | .B \-t \fItimeout\fP
|
---|
7471 | Cause \fBread\fP to time out and return failure if a complete line of
|
---|
7472 | input is not read within \fItimeout\fP seconds.
|
---|
7473 | This option has no effect if \fBread\fP is not reading input from the
|
---|
7474 | terminal or a pipe.
|
---|
7475 | .TP
|
---|
7476 | .B \-u \fIfd\fP
|
---|
7477 | Read input from file descriptor \fIfd\fP.
|
---|
7478 | .PD
|
---|
7479 | .PP
|
---|
7480 | If no
|
---|
7481 | .I names
|
---|
7482 | are supplied, the line read is assigned to the variable
|
---|
7483 | .SM
|
---|
7484 | .BR REPLY .
|
---|
7485 | The return code is zero, unless end-of-file is encountered, \fBread\fP
|
---|
7486 | times out, or an invalid file descriptor is supplied as the argument to
|
---|
7487 | \fB\-u\fP.
|
---|
7488 | .RE
|
---|
7489 | .TP
|
---|
7490 | \fBreadonly\fP [\fB\-apf\fP] [\fIname\fP[=\fIword\fP] ...]
|
---|
7491 | .PD
|
---|
7492 | The given
|
---|
7493 | \fInames\fP are marked readonly; the values of these
|
---|
7494 | .I names
|
---|
7495 | may not be changed by subsequent assignment.
|
---|
7496 | If the
|
---|
7497 | .B \-f
|
---|
7498 | option is supplied, the functions corresponding to the
|
---|
7499 | \fInames\fP are so
|
---|
7500 | marked.
|
---|
7501 | The
|
---|
7502 | .B \-a
|
---|
7503 | option restricts the variables to arrays.
|
---|
7504 | If no
|
---|
7505 | .I name
|
---|
7506 | arguments are given, or if the
|
---|
7507 | .B \-p
|
---|
7508 | option is supplied, a list of all readonly names is printed.
|
---|
7509 | The
|
---|
7510 | .B \-p
|
---|
7511 | option causes output to be displayed in a format that
|
---|
7512 | may be reused as input.
|
---|
7513 | If a variable name is followed by =\fIword\fP, the value of
|
---|
7514 | the variable is set to \fIword\fP.
|
---|
7515 | The return status is 0 unless an invalid option is encountered,
|
---|
7516 | one of the
|
---|
7517 | .I names
|
---|
7518 | is not a valid shell variable name, or
|
---|
7519 | .B \-f
|
---|
7520 | is supplied with a
|
---|
7521 | .I name
|
---|
7522 | that is not a function.
|
---|
7523 | .TP
|
---|
7524 | \fBreturn\fP [\fIn\fP]
|
---|
7525 | Causes a function to exit with the return value specified by
|
---|
7526 | .IR n .
|
---|
7527 | If
|
---|
7528 | .I n
|
---|
7529 | is omitted, the return status is that of the last command
|
---|
7530 | executed in the function body. If used outside a function,
|
---|
7531 | but during execution of a script by the
|
---|
7532 | .B .
|
---|
7533 | (\fBsource\fP) command, it causes the shell to stop executing
|
---|
7534 | that script and return either
|
---|
7535 | .I n
|
---|
7536 | or the exit status of the last command executed within the
|
---|
7537 | script as the exit status of the script. If used outside a
|
---|
7538 | function and not during execution of a script by \fB.\fP\^,
|
---|
7539 | the return status is false.
|
---|
7540 | Any command associated with the \fBRETURN\fP trap is executed
|
---|
7541 | before execution resumes after the function or script.
|
---|
7542 | .TP
|
---|
7543 | \fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
|
---|
7544 | Without options, the name and value of each shell variable are displayed
|
---|
7545 | in a format that can be reused as input
|
---|
7546 | for setting or resetting the currently-set variables.
|
---|
7547 | Read-only variables cannot be reset.
|
---|
7548 | In \fIposix mode\fP, only shell variables are listed.
|
---|
7549 | The output is sorted according to the current locale.
|
---|
7550 | When options are specified, they set or unset shell attributes.
|
---|
7551 | Any arguments remaining after the options are processed are treated
|
---|
7552 | as values for the positional parameters and are assigned, in order, to
|
---|
7553 | .BR $1 ,
|
---|
7554 | .BR $2 ,
|
---|
7555 | .B ...
|
---|
7556 | .BR $\fIn\fP .
|
---|
7557 | Options, if specified, have the following meanings:
|
---|
7558 | .RS
|
---|
7559 | .PD 0
|
---|
7560 | .TP 8
|
---|
7561 | .B \-a
|
---|
7562 | Automatically mark variables and functions which are modified or
|
---|
7563 | created for export to the environment of subsequent commands.
|
---|
7564 | .TP 8
|
---|
7565 | .B \-b
|
---|
7566 | Report the status of terminated background jobs
|
---|
7567 | immediately, rather than before the next primary prompt. This is
|
---|
7568 | effective only when job control is enabled.
|
---|
7569 | .TP 8
|
---|
7570 | .B \-e
|
---|
7571 | Exit immediately if a \fIsimple command\fP (see
|
---|
7572 | .SM
|
---|
7573 | .B SHELL GRAMMAR
|
---|
7574 | above) exits with a non-zero status.
|
---|
7575 | The shell does not exit if the
|
---|
7576 | command that fails is part of the command list immediately following a
|
---|
7577 | .B while
|
---|
7578 | or
|
---|
7579 | .B until
|
---|
7580 | keyword,
|
---|
7581 | part of the test in an
|
---|
7582 | .I if
|
---|
7583 | statement, part of a
|
---|
7584 | .B &&
|
---|
7585 | or
|
---|
7586 | .B \(bv\(bv
|
---|
7587 | list, or if the command's return value is
|
---|
7588 | being inverted via
|
---|
7589 | .BR ! .
|
---|
7590 | A trap on \fBERR\fP, if set, is executed before the shell exits.
|
---|
7591 | .TP 8
|
---|
7592 | .B \-f
|
---|
7593 | Disable pathname expansion.
|
---|
7594 | .TP 8
|
---|
7595 | .B \-h
|
---|
7596 | Remember the location of commands as they are looked up for execution.
|
---|
7597 | This is enabled by default.
|
---|
7598 | .TP 8
|
---|
7599 | .B \-k
|
---|
7600 | All arguments in the form of assignment statements
|
---|
7601 | are placed in the environment for a command, not just
|
---|
7602 | those that precede the command name.
|
---|
7603 | .TP 8
|
---|
7604 | .B \-m
|
---|
7605 | Monitor mode. Job control is enabled. This option is on
|
---|
7606 | by default for interactive shells on systems that support
|
---|
7607 | it (see
|
---|
7608 | .SM
|
---|
7609 | .B JOB CONTROL
|
---|
7610 | above). Background processes run in a separate process
|
---|
7611 | group and a line containing their exit status is printed
|
---|
7612 | upon their completion.
|
---|
7613 | .TP 8
|
---|
7614 | .B \-n
|
---|
7615 | Read commands but do not execute them. This may be used to
|
---|
7616 | check a shell script for syntax errors. This is ignored by
|
---|
7617 | interactive shells.
|
---|
7618 | .TP 8
|
---|
7619 | .B \-o \fIoption\-name\fP
|
---|
7620 | The \fIoption\-name\fP can be one of the following:
|
---|
7621 | .RS
|
---|
7622 | .TP 8
|
---|
7623 | .B allexport
|
---|
7624 | Same as
|
---|
7625 | .BR \-a .
|
---|
7626 | .TP 8
|
---|
7627 | .B braceexpand
|
---|
7628 | Same as
|
---|
7629 | .BR \-B .
|
---|
7630 | .TP 8
|
---|
7631 | .B emacs
|
---|
7632 | Use an emacs-style command line editing interface. This is enabled
|
---|
7633 | by default when the shell is interactive, unless the shell is started
|
---|
7634 | with the
|
---|
7635 | .B \-\-noediting
|
---|
7636 | option.
|
---|
7637 | .TP 8
|
---|
7638 | .B errtrace
|
---|
7639 | Same as
|
---|
7640 | .BR \-E .
|
---|
7641 | .TP 8
|
---|
7642 | .B functrace
|
---|
7643 | Same as
|
---|
7644 | .BR \-T .
|
---|
7645 | .TP 8
|
---|
7646 | .B errexit
|
---|
7647 | Same as
|
---|
7648 | .BR \-e .
|
---|
7649 | .TP 8
|
---|
7650 | .B hashall
|
---|
7651 | Same as
|
---|
7652 | .BR \-h .
|
---|
7653 | .TP 8
|
---|
7654 | .B histexpand
|
---|
7655 | Same as
|
---|
7656 | .BR \-H .
|
---|
7657 | .TP 8
|
---|
7658 | .B history
|
---|
7659 | Enable command history, as described above under
|
---|
7660 | .SM
|
---|
7661 | .BR HISTORY .
|
---|
7662 | This option is on by default in interactive shells.
|
---|
7663 | .TP 8
|
---|
7664 | .B ignoreeof
|
---|
7665 | The effect is as if the shell command
|
---|
7666 | .if t \f(CWIGNOREEOF=10\fP
|
---|
7667 | .if n ``IGNOREEOF=10''
|
---|
7668 | had been executed
|
---|
7669 | (see
|
---|
7670 | .B Shell Variables
|
---|
7671 | above).
|
---|
7672 | .TP 8
|
---|
7673 | .B keyword
|
---|
7674 | Same as
|
---|
7675 | .BR \-k .
|
---|
7676 | .TP 8
|
---|
7677 | .B monitor
|
---|
7678 | Same as
|
---|
7679 | .BR \-m .
|
---|
7680 | .TP 8
|
---|
7681 | .B noclobber
|
---|
7682 | Same as
|
---|
7683 | .BR \-C .
|
---|
7684 | .TP 8
|
---|
7685 | .B noexec
|
---|
7686 | Same as
|
---|
7687 | .BR \-n .
|
---|
7688 | .TP 8
|
---|
7689 | .B noglob
|
---|
7690 | Same as
|
---|
7691 | .BR \-f .
|
---|
7692 | .B nolog
|
---|
7693 | Currently ignored.
|
---|
7694 | .TP 8
|
---|
7695 | .B notify
|
---|
7696 | Same as
|
---|
7697 | .BR \-b .
|
---|
7698 | .TP 8
|
---|
7699 | .B nounset
|
---|
7700 | Same as
|
---|
7701 | .BR \-u .
|
---|
7702 | .TP 8
|
---|
7703 | .B onecmd
|
---|
7704 | Same as
|
---|
7705 | .BR \-t .
|
---|
7706 | .TP 8
|
---|
7707 | .B physical
|
---|
7708 | Same as
|
---|
7709 | .BR \-P .
|
---|
7710 | .TP 8
|
---|
7711 | .B pipefail
|
---|
7712 | If set, the return value of a pipeline is the value of the last
|
---|
7713 | (rightmost) command to exit with a non-zero status, or zero if all
|
---|
7714 | commands in the pipeline exit successfully.
|
---|
7715 | This option is disabled by default.
|
---|
7716 | .TP 8
|
---|
7717 | .B posix
|
---|
7718 | Change the behavior of
|
---|
7719 | .B bash
|
---|
7720 | where the default operation differs
|
---|
7721 | from the POSIX 1003.2 standard to match the standard (\fIposix mode\fP).
|
---|
7722 | .TP 8
|
---|
7723 | .B privileged
|
---|
7724 | Same as
|
---|
7725 | .BR \-p .
|
---|
7726 | .TP 8
|
---|
7727 | .B verbose
|
---|
7728 | Same as
|
---|
7729 | .BR \-v .
|
---|
7730 | .TP 8
|
---|
7731 | .B vi
|
---|
7732 | Use a vi-style command line editing interface.
|
---|
7733 | .TP 8
|
---|
7734 | .B xtrace
|
---|
7735 | Same as
|
---|
7736 | .BR \-x .
|
---|
7737 | .sp .5
|
---|
7738 | .PP
|
---|
7739 | If
|
---|
7740 | .B \-o
|
---|
7741 | is supplied with no \fIoption\-name\fP, the values of the current options are
|
---|
7742 | printed.
|
---|
7743 | If
|
---|
7744 | .B +o
|
---|
7745 | is supplied with no \fIoption\-name\fP, a series of
|
---|
7746 | .B set
|
---|
7747 | commands to recreate the current option settings is displayed on
|
---|
7748 | the standard output.
|
---|
7749 | .RE
|
---|
7750 | .TP 8
|
---|
7751 | .B \-p
|
---|
7752 | Turn on
|
---|
7753 | .I privileged
|
---|
7754 | mode. In this mode, the
|
---|
7755 | .SM
|
---|
7756 | .B $ENV
|
---|
7757 | and
|
---|
7758 | .SM
|
---|
7759 | .B $BASH_ENV
|
---|
7760 | files are not processed, shell functions are not inherited from the
|
---|
7761 | environment, and the
|
---|
7762 | .SM
|
---|
7763 | .B SHELLOPTS
|
---|
7764 | variable, if it appears in the environment, is ignored.
|
---|
7765 | If the shell is started with the effective user (group) id not equal to the
|
---|
7766 | real user (group) id, and the \fB\-p\fP option is not supplied, these actions
|
---|
7767 | are taken and the effective user id is set to the real user id.
|
---|
7768 | If the \fB\-p\fP option is supplied at startup, the effective user id is
|
---|
7769 | not reset.
|
---|
7770 | Turning this option off causes the effective user
|
---|
7771 | and group ids to be set to the real user and group ids.
|
---|
7772 | .TP 8
|
---|
7773 | .B \-t
|
---|
7774 | Exit after reading and executing one command.
|
---|
7775 | .TP 8
|
---|
7776 | .B \-u
|
---|
7777 | Treat unset variables as an error when performing
|
---|
7778 | parameter expansion. If expansion is attempted on an
|
---|
7779 | unset variable, the shell prints an error message, and,
|
---|
7780 | if not interactive, exits with a non-zero status.
|
---|
7781 | .TP 8
|
---|
7782 | .B \-v
|
---|
7783 | Print shell input lines as they are read.
|
---|
7784 | .TP 8
|
---|
7785 | .B \-x
|
---|
7786 | After expanding each \fIsimple command\fP,
|
---|
7787 | \fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or
|
---|
7788 | arithmetic \fBfor\fP command, display the expanded value of
|
---|
7789 | .SM
|
---|
7790 | .BR PS4 ,
|
---|
7791 | followed by the command and its expanded arguments
|
---|
7792 | or associated word list.
|
---|
7793 | .TP 8
|
---|
7794 | .B \-B
|
---|
7795 | The shell performs brace expansion (see
|
---|
7796 | .B Brace Expansion
|
---|
7797 | above). This is on by default.
|
---|
7798 | .TP 8
|
---|
7799 | .B \-C
|
---|
7800 | If set,
|
---|
7801 | .B bash
|
---|
7802 | does not overwrite an existing file with the
|
---|
7803 | .BR > ,
|
---|
7804 | .BR >& ,
|
---|
7805 | and
|
---|
7806 | .B <>
|
---|
7807 | redirection operators. This may be overridden when
|
---|
7808 | creating output files by using the redirection operator
|
---|
7809 | .B >|
|
---|
7810 | instead of
|
---|
7811 | .BR > .
|
---|
7812 | .TP 8
|
---|
7813 | .B \-E
|
---|
7814 | If set, any trap on \fBERR\fP is inherited by shell functions, command
|
---|
7815 | substitutions, and commands executed in a subshell environment.
|
---|
7816 | The \fBERR\fP trap is normally not inherited in such cases.
|
---|
7817 | .TP 8
|
---|
7818 | .B \-H
|
---|
7819 | Enable
|
---|
7820 | .B !
|
---|
7821 | style history substitution. This option is on by
|
---|
7822 | default when the shell is interactive.
|
---|
7823 | .TP 8
|
---|
7824 | .B \-P
|
---|
7825 | If set, the shell does not follow symbolic links when executing
|
---|
7826 | commands such as
|
---|
7827 | .B cd
|
---|
7828 | that change the current working directory. It uses the
|
---|
7829 | physical directory structure instead. By default,
|
---|
7830 | .B bash
|
---|
7831 | follows the logical chain of directories when performing commands
|
---|
7832 | which change the current directory.
|
---|
7833 | .TP 8
|
---|
7834 | .B \-T
|
---|
7835 | If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell
|
---|
7836 | functions, command substitutions, and commands executed in a
|
---|
7837 | subshell environment.
|
---|
7838 | The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited
|
---|
7839 | in such cases.
|
---|
7840 | .TP 8
|
---|
7841 | .B \-\-
|
---|
7842 | If no arguments follow this option, then the positional parameters are
|
---|
7843 | unset. Otherwise, the positional parameters are set to the
|
---|
7844 | \fIarg\fPs, even if some of them begin with a
|
---|
7845 | .BR \- .
|
---|
7846 | .TP 8
|
---|
7847 | .B \-
|
---|
7848 | Signal the end of options, cause all remaining \fIarg\fPs to be
|
---|
7849 | assigned to the positional parameters. The
|
---|
7850 | .B \-x
|
---|
7851 | and
|
---|
7852 | .B \-v
|
---|
7853 | options are turned off.
|
---|
7854 | If there are no \fIarg\fPs,
|
---|
7855 | the positional parameters remain unchanged.
|
---|
7856 | .PD
|
---|
7857 | .PP
|
---|
7858 | The options are off by default unless otherwise noted.
|
---|
7859 | Using + rather than \- causes these options to be turned off.
|
---|
7860 | The options can also be specified as arguments to an invocation of
|
---|
7861 | the shell.
|
---|
7862 | The current set of options may be found in
|
---|
7863 | .BR $\- .
|
---|
7864 | The return status is always true unless an invalid option is encountered.
|
---|
7865 | .RE
|
---|
7866 | .TP
|
---|
7867 | \fBshift\fP [\fIn\fP]
|
---|
7868 | The positional parameters from \fIn\fP+1 ... are renamed to
|
---|
7869 | .B $1
|
---|
7870 | .B ....
|
---|
7871 | Parameters represented by the numbers \fB$#\fP
|
---|
7872 | down to \fB$#\fP\-\fIn\fP+1 are unset.
|
---|
7873 | .I n
|
---|
7874 | must be a non-negative number less than or equal to \fB$#\fP.
|
---|
7875 | If
|
---|
7876 | .I n
|
---|
7877 | is 0, no parameters are changed.
|
---|
7878 | If
|
---|
7879 | .I n
|
---|
7880 | is not given, it is assumed to be 1.
|
---|
7881 | If
|
---|
7882 | .I n
|
---|
7883 | is greater than \fB$#\fP, the positional parameters are not changed.
|
---|
7884 | The return status is greater than zero if
|
---|
7885 | .I n
|
---|
7886 | is greater than
|
---|
7887 | .B $#
|
---|
7888 | or less than zero; otherwise 0.
|
---|
7889 | .TP
|
---|
7890 | \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
|
---|
7891 | Toggle the values of variables controlling optional shell behavior.
|
---|
7892 | With no options, or with the
|
---|
7893 | .B \-p
|
---|
7894 | option, a list of all settable options is displayed, with
|
---|
7895 | an indication of whether or not each is set.
|
---|
7896 | The \fB\-p\fP option causes output to be displayed in a form that
|
---|
7897 | may be reused as input.
|
---|
7898 | Other options have the following meanings:
|
---|
7899 | .RS
|
---|
7900 | .PD 0
|
---|
7901 | .TP
|
---|
7902 | .B \-s
|
---|
7903 | Enable (set) each \fIoptname\fP.
|
---|
7904 | .TP
|
---|
7905 | .B \-u
|
---|
7906 | Disable (unset) each \fIoptname\fP.
|
---|
7907 | .TP
|
---|
7908 | .B \-q
|
---|
7909 | Suppresses normal output (quiet mode); the return status indicates
|
---|
7910 | whether the \fIoptname\fP is set or unset.
|
---|
7911 | If multiple \fIoptname\fP arguments are given with
|
---|
7912 | .BR \-q ,
|
---|
7913 | the return status is zero if all \fIoptnames\fP are enabled; non-zero
|
---|
7914 | otherwise.
|
---|
7915 | .TP
|
---|
7916 | .B \-o
|
---|
7917 | Restricts the values of \fIoptname\fP to be those defined for the
|
---|
7918 | .B \-o
|
---|
7919 | option to the
|
---|
7920 | .B set
|
---|
7921 | builtin.
|
---|
7922 | .PD
|
---|
7923 | .PP
|
---|
7924 | If either
|
---|
7925 | .B \-s
|
---|
7926 | or
|
---|
7927 | .B \-u
|
---|
7928 | is used with no \fIoptname\fP arguments, the display is limited to
|
---|
7929 | those options which are set or unset, respectively.
|
---|
7930 | Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
|
---|
7931 | by default.
|
---|
7932 | .PP
|
---|
7933 | The return status when listing options is zero if all \fIoptnames\fP
|
---|
7934 | are enabled, non-zero otherwise. When setting or unsetting options,
|
---|
7935 | the return status is zero unless an \fIoptname\fP is not a valid shell
|
---|
7936 | option.
|
---|
7937 | .PP
|
---|
7938 | The list of \fBshopt\fP options is:
|
---|
7939 | .if t .sp .5v
|
---|
7940 | .if n .sp 1v
|
---|
7941 | .PD 0
|
---|
7942 | .TP 8
|
---|
7943 | .B cdable_vars
|
---|
7944 | If set, an argument to the
|
---|
7945 | .B cd
|
---|
7946 | builtin command that
|
---|
7947 | is not a directory is assumed to be the name of a variable whose
|
---|
7948 | value is the directory to change to.
|
---|
7949 | .TP 8
|
---|
7950 | .B cdspell
|
---|
7951 | If set, minor errors in the spelling of a directory component in a
|
---|
7952 | .B cd
|
---|
7953 | command will be corrected.
|
---|
7954 | The errors checked for are transposed characters,
|
---|
7955 | a missing character, and one character too many.
|
---|
7956 | If a correction is found, the corrected file name is printed,
|
---|
7957 | and the command proceeds.
|
---|
7958 | This option is only used by interactive shells.
|
---|
7959 | .TP 8
|
---|
7960 | .B checkhash
|
---|
7961 | If set, \fBbash\fP checks that a command found in the hash
|
---|
7962 | table exists before trying to execute it. If a hashed command no
|
---|
7963 | longer exists, a normal path search is performed.
|
---|
7964 | .TP 8
|
---|
7965 | .B checkwinsize
|
---|
7966 | If set, \fBbash\fP checks the window size after each command
|
---|
7967 | and, if necessary, updates the values of
|
---|
7968 | .SM
|
---|
7969 | .B LINES
|
---|
7970 | and
|
---|
7971 | .SM
|
---|
7972 | .BR COLUMNS .
|
---|
7973 | .TP 8
|
---|
7974 | .B cmdhist
|
---|
7975 | If set,
|
---|
7976 | .B bash
|
---|
7977 | attempts to save all lines of a multiple-line
|
---|
7978 | command in the same history entry. This allows
|
---|
7979 | easy re-editing of multi-line commands.
|
---|
7980 | .TP 8
|
---|
7981 | .B dotglob
|
---|
7982 | If set,
|
---|
7983 | .B bash
|
---|
7984 | includes filenames beginning with a `.' in the results of pathname
|
---|
7985 | expansion.
|
---|
7986 | .TP 8
|
---|
7987 | .B execfail
|
---|
7988 | If set, a non-interactive shell will not exit if
|
---|
7989 | it cannot execute the file specified as an argument to the
|
---|
7990 | .B exec
|
---|
7991 | builtin command. An interactive shell does not exit if
|
---|
7992 | .B exec
|
---|
7993 | fails.
|
---|
7994 | .TP 8
|
---|
7995 | .B expand_aliases
|
---|
7996 | If set, aliases are expanded as described above under
|
---|
7997 | .SM
|
---|
7998 | .BR ALIASES .
|
---|
7999 | This option is enabled by default for interactive shells.
|
---|
8000 | .TP 8
|
---|
8001 | .B extdebug
|
---|
8002 | If set, behavior intended for use by debuggers is enabled:
|
---|
8003 | .RS
|
---|
8004 | .TP
|
---|
8005 | .B 1.
|
---|
8006 | The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source
|
---|
8007 | file name and line number corresponding to each function name supplied
|
---|
8008 | as an argument.
|
---|
8009 | .TP
|
---|
8010 | .B 2.
|
---|
8011 | If the command run by the \fBDEBUG\fP trap returns a non-zero value, the
|
---|
8012 | next command is skipped and not executed.
|
---|
8013 | .TP
|
---|
8014 | .B 3.
|
---|
8015 | If the command run by the \fBDEBUG\fP trap returns a value of 2, and the
|
---|
8016 | shell is executing in a subroutine (a shell function or a shell script
|
---|
8017 | executed by the \fB.\fP or \fBsource\fP builtins), a call to
|
---|
8018 | \fBreturn\fP is simulated.
|
---|
8019 | .TP
|
---|
8020 | .B 4.
|
---|
8021 | \fBBASH_ARGC\fP and \fBBASH_ARGV\fP are updated as described in their
|
---|
8022 | descriptions above.
|
---|
8023 | .TP
|
---|
8024 | .B 5.
|
---|
8025 | Function tracing is enabled: command substitution, shell functions, and
|
---|
8026 | subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
|
---|
8027 | \fBDEBUG\fP and \fBRETURN\fP traps.
|
---|
8028 | .TP
|
---|
8029 | .B 6.
|
---|
8030 | Error tracing is enabled: command substitution, shell functions, and
|
---|
8031 | subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
|
---|
8032 | \fBERROR\fP trap.
|
---|
8033 | .RE
|
---|
8034 | .TP 8
|
---|
8035 | .B extglob
|
---|
8036 | If set, the extended pattern matching features described above under
|
---|
8037 | \fBPathname Expansion\fP are enabled.
|
---|
8038 | .TP 8
|
---|
8039 | .B extquote
|
---|
8040 | If set, \fB$\fP'\fIstring\fP' and \fB$\fP"\fIstring\fP" quoting is
|
---|
8041 | performed within \fB${\fP\fIparameter\fP\fB}\fP expansions
|
---|
8042 | enclosed in double quotes. This option is enabled by default.
|
---|
8043 | .TP 8
|
---|
8044 | .B failglob
|
---|
8045 | If set, patterns which fail to match filenames during pathname expansion
|
---|
8046 | result in an expansion error.
|
---|
8047 | .TP 8
|
---|
8048 | .B force_fignore
|
---|
8049 | If set, the suffixes specified by the \fBFIGNORE\fP shell variable
|
---|
8050 | cause words to be ignored when performing word completion even if
|
---|
8051 | the ignored words are the only possible completions.
|
---|
8052 | See
|
---|
8053 | .SM
|
---|
8054 | \fBSHELL VARIABLES\fP
|
---|
8055 | above for a description of \fBFIGNORE\fP.
|
---|
8056 | This option is enabled by default.
|
---|
8057 | .TP 8
|
---|
8058 | .B gnu_errfmt
|
---|
8059 | If set, shell error messages are written in the standard GNU error
|
---|
8060 | message format.
|
---|
8061 | .TP 8
|
---|
8062 | .B histappend
|
---|
8063 | If set, the history list is appended to the file named by the value
|
---|
8064 | of the
|
---|
8065 | .B HISTFILE
|
---|
8066 | variable when the shell exits, rather than overwriting the file.
|
---|
8067 | .TP 8
|
---|
8068 | .B histreedit
|
---|
8069 | If set, and
|
---|
8070 | .B readline
|
---|
8071 | is being used, a user is given the opportunity to re-edit a
|
---|
8072 | failed history substitution.
|
---|
8073 | .TP 8
|
---|
8074 | .B histverify
|
---|
8075 | If set, and
|
---|
8076 | .B readline
|
---|
8077 | is being used, the results of history substitution are not immediately
|
---|
8078 | passed to the shell parser. Instead, the resulting line is loaded into
|
---|
8079 | the \fBreadline\fP editing buffer, allowing further modification.
|
---|
8080 | .TP 8
|
---|
8081 | .B hostcomplete
|
---|
8082 | If set, and
|
---|
8083 | .B readline
|
---|
8084 | is being used, \fBbash\fP will attempt to perform hostname completion when a
|
---|
8085 | word containing a \fB@\fP is being completed (see
|
---|
8086 | .B Completing
|
---|
8087 | under
|
---|
8088 | .SM
|
---|
8089 | .B READLINE
|
---|
8090 | above).
|
---|
8091 | This is enabled by default.
|
---|
8092 | .TP 8
|
---|
8093 | .B huponexit
|
---|
8094 | If set, \fBbash\fP will send
|
---|
8095 | .SM
|
---|
8096 | .B SIGHUP
|
---|
8097 | to all jobs when an interactive login shell exits.
|
---|
8098 | .TP 8
|
---|
8099 | .B interactive_comments
|
---|
8100 | If set, allow a word beginning with
|
---|
8101 | .B #
|
---|
8102 | to cause that word and all remaining characters on that
|
---|
8103 | line to be ignored in an interactive shell (see
|
---|
8104 | .SM
|
---|
8105 | .B COMMENTS
|
---|
8106 | above). This option is enabled by default.
|
---|
8107 | .TP 8
|
---|
8108 | .B lithist
|
---|
8109 | If set, and the
|
---|
8110 | .B cmdhist
|
---|
8111 | option is enabled, multi-line commands are saved to the history with
|
---|
8112 | embedded newlines rather than using semicolon separators where possible.
|
---|
8113 | .TP 8
|
---|
8114 | .B login_shell
|
---|
8115 | The shell sets this option if it is started as a login shell (see
|
---|
8116 | .SM
|
---|
8117 | .B "INVOCATION"
|
---|
8118 | above).
|
---|
8119 | The value may not be changed.
|
---|
8120 | .TP 8
|
---|
8121 | .B mailwarn
|
---|
8122 | If set, and a file that \fBbash\fP is checking for mail has been
|
---|
8123 | accessed since the last time it was checked, the message ``The mail in
|
---|
8124 | \fImailfile\fP has been read'' is displayed.
|
---|
8125 | .TP 8
|
---|
8126 | .B no_empty_cmd_completion
|
---|
8127 | If set, and
|
---|
8128 | .B readline
|
---|
8129 | is being used,
|
---|
8130 | .B bash
|
---|
8131 | will not attempt to search the \fBPATH\fP for possible completions when
|
---|
8132 | completion is attempted on an empty line.
|
---|
8133 | .TP 8
|
---|
8134 | .B nocaseglob
|
---|
8135 | If set,
|
---|
8136 | .B bash
|
---|
8137 | matches filenames in a case\-insensitive fashion when performing pathname
|
---|
8138 | expansion (see
|
---|
8139 | .B Pathname Expansion
|
---|
8140 | above).
|
---|
8141 | .TP 8
|
---|
8142 | .B nocasematch
|
---|
8143 | If set,
|
---|
8144 | .B bash
|
---|
8145 | matches patterns in a case\-insensitive fashion when performing matching
|
---|
8146 | while executing \fBcase\fP or \fB[[\fP conditional commands.
|
---|
8147 | .TP 8
|
---|
8148 | .B nullglob
|
---|
8149 | If set,
|
---|
8150 | .B bash
|
---|
8151 | allows patterns which match no
|
---|
8152 | files (see
|
---|
8153 | .B Pathname Expansion
|
---|
8154 | above)
|
---|
8155 | to expand to a null string, rather than themselves.
|
---|
8156 | .TP 8
|
---|
8157 | .B progcomp
|
---|
8158 | If set, the programmable completion facilities (see
|
---|
8159 | \fBProgrammable Completion\fP above) are enabled.
|
---|
8160 | This option is enabled by default.
|
---|
8161 | .TP 8
|
---|
8162 | .B promptvars
|
---|
8163 | If set, prompt strings undergo
|
---|
8164 | parameter expansion, command substitution, arithmetic
|
---|
8165 | expansion, and quote removal after being expanded as described in
|
---|
8166 | .SM
|
---|
8167 | .B PROMPTING
|
---|
8168 | above. This option is enabled by default.
|
---|
8169 | .TP 8
|
---|
8170 | .B restricted_shell
|
---|
8171 | The shell sets this option if it is started in restricted mode (see
|
---|
8172 | .SM
|
---|
8173 | .B "RESTRICTED SHELL"
|
---|
8174 | below).
|
---|
8175 | The value may not be changed.
|
---|
8176 | This is not reset when the startup files are executed, allowing
|
---|
8177 | the startup files to discover whether or not a shell is restricted.
|
---|
8178 | .TP 8
|
---|
8179 | .B shift_verbose
|
---|
8180 | If set, the
|
---|
8181 | .B shift
|
---|
8182 | builtin prints an error message when the shift count exceeds the
|
---|
8183 | number of positional parameters.
|
---|
8184 | .TP 8
|
---|
8185 | .B sourcepath
|
---|
8186 | If set, the
|
---|
8187 | \fBsource\fP (\fB.\fP) builtin uses the value of
|
---|
8188 | .SM
|
---|
8189 | .B PATH
|
---|
8190 | to find the directory containing the file supplied as an argument.
|
---|
8191 | This option is enabled by default.
|
---|
8192 | .TP 8
|
---|
8193 | .B xpg_echo
|
---|
8194 | If set, the \fBecho\fP builtin expands backslash-escape sequences
|
---|
8195 | by default.
|
---|
8196 | .RE
|
---|
8197 | .TP
|
---|
8198 | \fBsuspend\fP [\fB\-f\fP]
|
---|
8199 | Suspend the execution of this shell until it receives a
|
---|
8200 | .SM
|
---|
8201 | .B SIGCONT
|
---|
8202 | signal. The
|
---|
8203 | .B \-f
|
---|
8204 | option says not to complain if this is
|
---|
8205 | a login shell; just suspend anyway. The return status is 0 unless
|
---|
8206 | the shell is a login shell and
|
---|
8207 | .B \-f
|
---|
8208 | is not supplied, or if job control is not enabled.
|
---|
8209 | .TP
|
---|
8210 | \fBtest\fP \fIexpr\fP
|
---|
8211 | .PD 0
|
---|
8212 | .TP
|
---|
8213 | \fB[\fP \fIexpr\fP \fB]\fP
|
---|
8214 | Return a status of 0 or 1 depending on
|
---|
8215 | the evaluation of the conditional expression
|
---|
8216 | .IR expr .
|
---|
8217 | Each operator and operand must be a separate argument.
|
---|
8218 | Expressions are composed of the primaries described above under
|
---|
8219 | .SM
|
---|
8220 | .BR "CONDITIONAL EXPRESSIONS" .
|
---|
8221 | \fBtest\fP does not accept any options, nor does it accept and ignore
|
---|
8222 | an argument of \fB\-\-\fP as signifying the end of options.
|
---|
8223 | .if t .sp 0.5
|
---|
8224 | .if n .sp 1
|
---|
8225 | Expressions may be combined using the following operators, listed
|
---|
8226 | in decreasing order of precedence.
|
---|
8227 | .RS
|
---|
8228 | .PD 0
|
---|
8229 | .TP
|
---|
8230 | .B ! \fIexpr\fP
|
---|
8231 | True if
|
---|
8232 | .I expr
|
---|
8233 | is false.
|
---|
8234 | .TP
|
---|
8235 | .B ( \fIexpr\fP )
|
---|
8236 | Returns the value of \fIexpr\fP.
|
---|
8237 | This may be used to override the normal precedence of operators.
|
---|
8238 | .TP
|
---|
8239 | \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
|
---|
8240 | True if both
|
---|
8241 | .I expr1
|
---|
8242 | and
|
---|
8243 | .I expr2
|
---|
8244 | are true.
|
---|
8245 | .TP
|
---|
8246 | \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
|
---|
8247 | True if either
|
---|
8248 | .I expr1
|
---|
8249 | or
|
---|
8250 | .I expr2
|
---|
8251 | is true.
|
---|
8252 | .PD
|
---|
8253 | .PP
|
---|
8254 | \fBtest\fP and \fB[\fP evaluate conditional
|
---|
8255 | expressions using a set of rules based on the number of arguments.
|
---|
8256 | .if t .sp 0.5
|
---|
8257 | .if n .sp 1
|
---|
8258 | .PD 0
|
---|
8259 | .TP
|
---|
8260 | 0 arguments
|
---|
8261 | The expression is false.
|
---|
8262 | .TP
|
---|
8263 | 1 argument
|
---|
8264 | The expression is true if and only if the argument is not null.
|
---|
8265 | .TP
|
---|
8266 | 2 arguments
|
---|
8267 | If the first argument is \fB!\fP, the expression is true if and
|
---|
8268 | only if the second argument is null.
|
---|
8269 | If the first argument is one of the unary conditional operators listed above
|
---|
8270 | under
|
---|
8271 | .SM
|
---|
8272 | .BR "CONDITIONAL EXPRESSIONS" ,
|
---|
8273 | the expression is true if the unary test is true.
|
---|
8274 | If the first argument is not a valid unary conditional operator, the expression
|
---|
8275 | is false.
|
---|
8276 | .TP
|
---|
8277 | 3 arguments
|
---|
8278 | If the second argument is one of the binary conditional operators listed above
|
---|
8279 | under
|
---|
8280 | .SM
|
---|
8281 | .BR "CONDITIONAL EXPRESSIONS" ,
|
---|
8282 | the result of the expression is the result of the binary test using
|
---|
8283 | the first and third arguments as operands.
|
---|
8284 | If the first argument is \fB!\fP, the value is the negation of
|
---|
8285 | the two-argument test using the second and third arguments.
|
---|
8286 | If the first argument is exactly \fB(\fP and the third argument is
|
---|
8287 | exactly \fB)\fP, the result is the one-argument test of the second
|
---|
8288 | argument.
|
---|
8289 | Otherwise, the expression is false.
|
---|
8290 | The \fB\-a\fP and \fB\-o\fP operators are considered binary operators
|
---|
8291 | in this case.
|
---|
8292 | .TP
|
---|
8293 | 4 arguments
|
---|
8294 | If the first argument is \fB!\fP, the result is the negation of
|
---|
8295 | the three-argument expression composed of the remaining arguments.
|
---|
8296 | Otherwise, the expression is parsed and evaluated according to
|
---|
8297 | precedence using the rules listed above.
|
---|
8298 | .TP
|
---|
8299 | 5 or more arguments
|
---|
8300 | The expression is parsed and evaluated according to precedence
|
---|
8301 | using the rules listed above.
|
---|
8302 | .RE
|
---|
8303 | .PD
|
---|
8304 | .TP
|
---|
8305 | .B times
|
---|
8306 | Print the accumulated user and system times for the shell and
|
---|
8307 | for processes run from the shell. The return status is 0.
|
---|
8308 | .TP
|
---|
8309 | \fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...]
|
---|
8310 | The command
|
---|
8311 | .I arg
|
---|
8312 | is to be read and executed when the shell receives
|
---|
8313 | signal(s)
|
---|
8314 | .IR sigspec .
|
---|
8315 | If
|
---|
8316 | .I arg
|
---|
8317 | is absent (and there is a single \fIsigspec\fP) or
|
---|
8318 | .BR \- ,
|
---|
8319 | each specified signal is
|
---|
8320 | reset to its original disposition (the value it had
|
---|
8321 | upon entrance to the shell).
|
---|
8322 | If
|
---|
8323 | .I arg
|
---|
8324 | is the null string the signal specified by each
|
---|
8325 | .I sigspec
|
---|
8326 | is ignored by the shell and by the commands it invokes.
|
---|
8327 | If
|
---|
8328 | .I arg
|
---|
8329 | is not present and
|
---|
8330 | .B \-p
|
---|
8331 | has been supplied, then the trap commands associated with each
|
---|
8332 | .I sigspec
|
---|
8333 | are displayed.
|
---|
8334 | If no arguments are supplied or if only
|
---|
8335 | .B \-p
|
---|
8336 | is given,
|
---|
8337 | .B trap
|
---|
8338 | prints the list of commands associated with each signal.
|
---|
8339 | The
|
---|
8340 | .B \-l
|
---|
8341 | option causes the shell to print a list of signal names and
|
---|
8342 | their corresponding numbers.
|
---|
8343 | Each
|
---|
8344 | .I sigspec
|
---|
8345 | is either
|
---|
8346 | a signal name defined in <\fIsignal.h\fP>, or a signal number.
|
---|
8347 | Signal names are case insensitive and the SIG prefix is optional.
|
---|
8348 | If a
|
---|
8349 | .I sigspec
|
---|
8350 | is
|
---|
8351 | .SM
|
---|
8352 | .B EXIT
|
---|
8353 | (0) the command
|
---|
8354 | .I arg
|
---|
8355 | is executed on exit from the shell.
|
---|
8356 | If a
|
---|
8357 | .I sigspec
|
---|
8358 | is
|
---|
8359 | .SM
|
---|
8360 | .BR DEBUG ,
|
---|
8361 | the command
|
---|
8362 | .I arg
|
---|
8363 | is executed before every \fIsimple command\fP, \fIfor\fP command,
|
---|
8364 | \fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP
|
---|
8365 | command, and before the first command executes in a shell function (see
|
---|
8366 | .SM
|
---|
8367 | .B SHELL GRAMMAR
|
---|
8368 | above).
|
---|
8369 | Refer to the description of the \fBextdebug\fP option to the
|
---|
8370 | \fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap.
|
---|
8371 | If a
|
---|
8372 | .I sigspec
|
---|
8373 | is
|
---|
8374 | .SM
|
---|
8375 | .BR ERR ,
|
---|
8376 | the command
|
---|
8377 | .I arg
|
---|
8378 | is executed whenever a simple command has a non\-zero exit status,
|
---|
8379 | subject to the following conditions.
|
---|
8380 | The
|
---|
8381 | .SM
|
---|
8382 | .B ERR
|
---|
8383 | trap is not executed if the failed
|
---|
8384 | command is part of the command list immediately following a
|
---|
8385 | .B while
|
---|
8386 | or
|
---|
8387 | .B until
|
---|
8388 | keyword,
|
---|
8389 | part of the test in an
|
---|
8390 | .I if
|
---|
8391 | statement, part of a
|
---|
8392 | .B &&
|
---|
8393 | or
|
---|
8394 | .B \(bv\(bv
|
---|
8395 | list, or if the command's return value is
|
---|
8396 | being inverted via
|
---|
8397 | .BR ! .
|
---|
8398 | These are the same conditions obeyed by the \fBerrexit\fP option.
|
---|
8399 | If a
|
---|
8400 | .I sigspec
|
---|
8401 | is
|
---|
8402 | .SM
|
---|
8403 | .BR RETURN ,
|
---|
8404 | the command
|
---|
8405 | .I arg
|
---|
8406 | is executed each time a shell function or a script executed with the
|
---|
8407 | \fB.\fP or \fBsource\fP builtins finishes executing.
|
---|
8408 | Signals ignored upon entry to the shell cannot be trapped or reset.
|
---|
8409 | Trapped signals are reset to their original values in a child
|
---|
8410 | process when it is created.
|
---|
8411 | The return status is false if any
|
---|
8412 | .I sigspec
|
---|
8413 | is invalid; otherwise
|
---|
8414 | .B trap
|
---|
8415 | returns true.
|
---|
8416 | .TP
|
---|
8417 | \fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...]
|
---|
8418 | With no options,
|
---|
8419 | indicate how each
|
---|
8420 | .I name
|
---|
8421 | would be interpreted if used as a command name.
|
---|
8422 | If the
|
---|
8423 | .B \-t
|
---|
8424 | option is used,
|
---|
8425 | .B type
|
---|
8426 | prints a string which is one of
|
---|
8427 | .IR alias ,
|
---|
8428 | .IR keyword ,
|
---|
8429 | .IR function ,
|
---|
8430 | .IR builtin ,
|
---|
8431 | or
|
---|
8432 | .I file
|
---|
8433 | if
|
---|
8434 | .I name
|
---|
8435 | is an alias, shell reserved word, function, builtin, or disk file,
|
---|
8436 | respectively.
|
---|
8437 | If the
|
---|
8438 | .I name
|
---|
8439 | is not found, then nothing is printed, and an exit status of false
|
---|
8440 | is returned.
|
---|
8441 | If the
|
---|
8442 | .B \-p
|
---|
8443 | option is used,
|
---|
8444 | .B type
|
---|
8445 | either returns the name of the disk file
|
---|
8446 | that would be executed if
|
---|
8447 | .I name
|
---|
8448 | were specified as a command name,
|
---|
8449 | or nothing if
|
---|
8450 | .if t \f(CWtype -t name\fP
|
---|
8451 | .if n ``type -t name''
|
---|
8452 | would not return
|
---|
8453 | .IR file .
|
---|
8454 | The
|
---|
8455 | .B \-P
|
---|
8456 | option forces a
|
---|
8457 | .SM
|
---|
8458 | .B PATH
|
---|
8459 | search for each \fIname\fP, even if
|
---|
8460 | .if t \f(CWtype -t name\fP
|
---|
8461 | .if n ``type -t name''
|
---|
8462 | would not return
|
---|
8463 | .IR file .
|
---|
8464 | If a command is hashed,
|
---|
8465 | .B \-p
|
---|
8466 | and
|
---|
8467 | .B \-P
|
---|
8468 | print the hashed value, not necessarily the file that appears
|
---|
8469 | first in
|
---|
8470 | .SM
|
---|
8471 | .BR PATH .
|
---|
8472 | If the
|
---|
8473 | .B \-a
|
---|
8474 | option is used,
|
---|
8475 | .B type
|
---|
8476 | prints all of the places that contain
|
---|
8477 | an executable named
|
---|
8478 | .IR name .
|
---|
8479 | This includes aliases and functions,
|
---|
8480 | if and only if the
|
---|
8481 | .B \-p
|
---|
8482 | option is not also used.
|
---|
8483 | The table of hashed commands is not consulted
|
---|
8484 | when using
|
---|
8485 | .BR \-a .
|
---|
8486 | The
|
---|
8487 | .B \-f
|
---|
8488 | option suppresses shell function lookup, as with the \fBcommand\fP builtin.
|
---|
8489 | .B type
|
---|
8490 | returns true if any of the arguments are found, false if
|
---|
8491 | none are found.
|
---|
8492 | .TP
|
---|
8493 | \fBulimit\fP [\fB\-SHacdfilmnpqstuvx\fP [\fIlimit\fP]]
|
---|
8494 | Provides control over the resources available to the shell and to
|
---|
8495 | processes started by it, on systems that allow such control.
|
---|
8496 | The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
|
---|
8497 | set for the given resource. A hard limit cannot be increased once it
|
---|
8498 | is set; a soft limit may be increased up to the value of the hard limit.
|
---|
8499 | If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
|
---|
8500 | limits are set.
|
---|
8501 | The value of
|
---|
8502 | .I limit
|
---|
8503 | can be a number in the unit specified for the resource
|
---|
8504 | or one of the special values
|
---|
8505 | .BR hard ,
|
---|
8506 | .BR soft ,
|
---|
8507 | or
|
---|
8508 | .BR unlimited ,
|
---|
8509 | which stand for the current hard limit, the current soft limit, and
|
---|
8510 | no limit, respectively.
|
---|
8511 | If
|
---|
8512 | .I limit
|
---|
8513 | is omitted, the current value of the soft limit of the resource is
|
---|
8514 | printed, unless the \fB\-H\fP option is given. When more than one
|
---|
8515 | resource is specified, the limit name and unit are printed before the value.
|
---|
8516 | Other options are interpreted as follows:
|
---|
8517 | .RS
|
---|
8518 | .PD 0
|
---|
8519 | .TP
|
---|
8520 | .B \-a
|
---|
8521 | All current limits are reported
|
---|
8522 | .TP
|
---|
8523 | .B \-c
|
---|
8524 | The maximum size of core files created
|
---|
8525 | .TP
|
---|
8526 | .B \-d
|
---|
8527 | The maximum size of a process's data segment
|
---|
8528 | .TP
|
---|
8529 | .B \-f
|
---|
8530 | The maximum size of files created by the shell
|
---|
8531 | .TP
|
---|
8532 | .B \-i
|
---|
8533 | The maximum number of pending signals
|
---|
8534 | .TP
|
---|
8535 | .B \-l
|
---|
8536 | The maximum size that may be locked into memory
|
---|
8537 | .TP
|
---|
8538 | .B \-m
|
---|
8539 | The maximum resident set size
|
---|
8540 | .TP
|
---|
8541 | .B \-n
|
---|
8542 | The maximum number of open file descriptors (most systems do not
|
---|
8543 | allow this value to be set)
|
---|
8544 | .TP
|
---|
8545 | .B \-p
|
---|
8546 | The pipe size in 512-byte blocks (this may not be set)
|
---|
8547 | .TP
|
---|
8548 | .B \-q
|
---|
8549 | The maximum number of bytes in POSIX message queues
|
---|
8550 | .TP
|
---|
8551 | .B \-s
|
---|
8552 | The maximum stack size
|
---|
8553 | .TP
|
---|
8554 | .B \-t
|
---|
8555 | The maximum amount of cpu time in seconds
|
---|
8556 | .TP
|
---|
8557 | .B \-u
|
---|
8558 | The maximum number of processes available to a single user
|
---|
8559 | .TP
|
---|
8560 | .B \-v
|
---|
8561 | The maximum amount of virtual memory available to the shell
|
---|
8562 | .TP
|
---|
8563 | .B \-x
|
---|
8564 | The maximum number of file locks
|
---|
8565 | .PD
|
---|
8566 | .PP
|
---|
8567 | If
|
---|
8568 | .I limit
|
---|
8569 | is given, it is the new value of the specified resource (the
|
---|
8570 | .B \-a
|
---|
8571 | option is display only).
|
---|
8572 | If no option is given, then
|
---|
8573 | .B \-f
|
---|
8574 | is assumed. Values are in 1024-byte increments, except for
|
---|
8575 | .BR \-t ,
|
---|
8576 | which is in seconds,
|
---|
8577 | .BR \-p ,
|
---|
8578 | which is in units of 512-byte blocks,
|
---|
8579 | and
|
---|
8580 | .B \-n
|
---|
8581 | and
|
---|
8582 | .BR \-u ,
|
---|
8583 | which are unscaled values.
|
---|
8584 | The return status is 0 unless an invalid option or argument is supplied,
|
---|
8585 | or an error occurs while setting a new limit.
|
---|
8586 | .RE
|
---|
8587 | .TP
|
---|
8588 | \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP]
|
---|
8589 | The user file-creation mask is set to
|
---|
8590 | .IR mode .
|
---|
8591 | If
|
---|
8592 | .I mode
|
---|
8593 | begins with a digit, it
|
---|
8594 | is interpreted as an octal number; otherwise
|
---|
8595 | it is interpreted as a symbolic mode mask similar
|
---|
8596 | to that accepted by
|
---|
8597 | .IR chmod (1).
|
---|
8598 | If
|
---|
8599 | .I mode
|
---|
8600 | is omitted, the current value of the mask is printed.
|
---|
8601 | The
|
---|
8602 | .B \-S
|
---|
8603 | option causes the mask to be printed in symbolic form; the
|
---|
8604 | default output is an octal number.
|
---|
8605 | If the
|
---|
8606 | .B \-p
|
---|
8607 | option is supplied, and
|
---|
8608 | .I mode
|
---|
8609 | is omitted, the output is in a form that may be reused as input.
|
---|
8610 | The return status is 0 if the mode was successfully changed or if
|
---|
8611 | no \fImode\fP argument was supplied, and false otherwise.
|
---|
8612 | .TP
|
---|
8613 | \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
|
---|
8614 | Remove each \fIname\fP from the list of defined aliases. If
|
---|
8615 | .B \-a
|
---|
8616 | is supplied, all alias definitions are removed. The return
|
---|
8617 | value is true unless a supplied
|
---|
8618 | .I name
|
---|
8619 | is not a defined alias.
|
---|
8620 | .TP
|
---|
8621 | \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
|
---|
8622 | For each
|
---|
8623 | .IR name ,
|
---|
8624 | remove the corresponding variable or function.
|
---|
8625 | If no options are supplied, or the
|
---|
8626 | .B \-v
|
---|
8627 | option is given, each
|
---|
8628 | .I name
|
---|
8629 | refers to a shell variable.
|
---|
8630 | Read-only variables may not be unset.
|
---|
8631 | If
|
---|
8632 | .B \-f
|
---|
8633 | is specified, each
|
---|
8634 | .I name
|
---|
8635 | refers to a shell function, and the function definition
|
---|
8636 | is removed.
|
---|
8637 | Each unset variable or function is removed from the environment
|
---|
8638 | passed to subsequent commands.
|
---|
8639 | If any of
|
---|
8640 | .SM
|
---|
8641 | .BR RANDOM ,
|
---|
8642 | .SM
|
---|
8643 | .BR SECONDS ,
|
---|
8644 | .SM
|
---|
8645 | .BR LINENO ,
|
---|
8646 | .SM
|
---|
8647 | .BR HISTCMD ,
|
---|
8648 | .SM
|
---|
8649 | .BR FUNCNAME ,
|
---|
8650 | .SM
|
---|
8651 | .BR GROUPS ,
|
---|
8652 | or
|
---|
8653 | .SM
|
---|
8654 | .B DIRSTACK
|
---|
8655 | are unset, they lose their special properties, even if they are
|
---|
8656 | subsequently reset. The exit status is true unless a
|
---|
8657 | .I name
|
---|
8658 | is readonly.
|
---|
8659 | .TP
|
---|
8660 | \fBwait\fP [\fIn ...\fP]
|
---|
8661 | Wait for each specified process and return its termination status.
|
---|
8662 | Each
|
---|
8663 | .I n
|
---|
8664 | may be a process
|
---|
8665 | ID or a job specification; if a job spec is given, all processes
|
---|
8666 | in that job's pipeline are waited for. If
|
---|
8667 | .I n
|
---|
8668 | is not given, all currently active child processes
|
---|
8669 | are waited for, and the return status is zero. If
|
---|
8670 | .I n
|
---|
8671 | specifies a non-existent process or job, the return status is
|
---|
8672 | 127. Otherwise, the return status is the exit status of the last
|
---|
8673 | process or job waited for.
|
---|
8674 | .\" bash_builtins
|
---|
8675 | .if \n(zZ=1 .ig zZ
|
---|
8676 | .SH "RESTRICTED SHELL"
|
---|
8677 | .\" rbash.1
|
---|
8678 | .zY
|
---|
8679 | .PP
|
---|
8680 | If
|
---|
8681 | .B bash
|
---|
8682 | is started with the name
|
---|
8683 | .BR rbash ,
|
---|
8684 | or the
|
---|
8685 | .B \-r
|
---|
8686 | option is supplied at invocation,
|
---|
8687 | the shell becomes restricted.
|
---|
8688 | A restricted shell is used to
|
---|
8689 | set up an environment more controlled than the standard shell.
|
---|
8690 | It behaves identically to
|
---|
8691 | .B bash
|
---|
8692 | with the exception that the following are disallowed or not performed:
|
---|
8693 | .IP \(bu
|
---|
8694 | changing directories with \fBcd\fP
|
---|
8695 | .IP \(bu
|
---|
8696 | setting or unsetting the values of
|
---|
8697 | .BR SHELL ,
|
---|
8698 | .BR PATH ,
|
---|
8699 | .BR ENV ,
|
---|
8700 | or
|
---|
8701 | .B BASH_ENV
|
---|
8702 | .IP \(bu
|
---|
8703 | specifying command names containing
|
---|
8704 | .B /
|
---|
8705 | .IP \(bu
|
---|
8706 | specifying a file name containing a
|
---|
8707 | .B /
|
---|
8708 | as an argument to the
|
---|
8709 | .B .
|
---|
8710 | builtin command
|
---|
8711 | .IP \(bu
|
---|
8712 | Specifying a filename containing a slash as an argument to the
|
---|
8713 | .B \-p
|
---|
8714 | option to the
|
---|
8715 | .B hash
|
---|
8716 | builtin command
|
---|
8717 | .IP \(bu
|
---|
8718 | importing function definitions from the shell environment at startup
|
---|
8719 | .IP \(bu
|
---|
8720 | parsing the value of \fBSHELLOPTS\fP from the shell environment at startup
|
---|
8721 | .IP \(bu
|
---|
8722 | redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
|
---|
8723 | .IP \(bu
|
---|
8724 | using the
|
---|
8725 | .B exec
|
---|
8726 | builtin command to replace the shell with another command
|
---|
8727 | .IP \(bu
|
---|
8728 | adding or deleting builtin commands with the
|
---|
8729 | .B \-f
|
---|
8730 | and
|
---|
8731 | .B \-d
|
---|
8732 | options to the
|
---|
8733 | .B enable
|
---|
8734 | builtin command
|
---|
8735 | .IP \(bu
|
---|
8736 | Using the \fBenable\fP builtin command to enable disabled shell builtins
|
---|
8737 | .IP \(bu
|
---|
8738 | specifying the
|
---|
8739 | .B \-p
|
---|
8740 | option to the
|
---|
8741 | .B command
|
---|
8742 | builtin command
|
---|
8743 | .IP \(bu
|
---|
8744 | turning off restricted mode with
|
---|
8745 | \fBset +r\fP or \fBset +o restricted\fP.
|
---|
8746 | .PP
|
---|
8747 | These restrictions are enforced after any startup files are read.
|
---|
8748 | .PP
|
---|
8749 | .ie \n(zY=1 When a command that is found to be a shell script is executed,
|
---|
8750 | .el \{ When a command that is found to be a shell script is executed
|
---|
8751 | (see
|
---|
8752 | .SM
|
---|
8753 | .B "COMMAND EXECUTION"
|
---|
8754 | above),
|
---|
8755 | \}
|
---|
8756 | .B rbash
|
---|
8757 | turns off any restrictions in the shell spawned to execute the
|
---|
8758 | script.
|
---|
8759 | .\" end of rbash.1
|
---|
8760 | .if \n(zY=1 .ig zY
|
---|
8761 | .SH "SEE ALSO"
|
---|
8762 | .PD 0
|
---|
8763 | .TP
|
---|
8764 | \fIBash Reference Manual\fP, Brian Fox and Chet Ramey
|
---|
8765 | .TP
|
---|
8766 | \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
|
---|
8767 | .TP
|
---|
8768 | \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
|
---|
8769 | .TP
|
---|
8770 | \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
|
---|
8771 | .TP
|
---|
8772 | \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
|
---|
8773 | .TP
|
---|
8774 | \fIemacs\fP(1), \fIvi\fP(1)
|
---|
8775 | .TP
|
---|
8776 | \fIreadline\fP(3)
|
---|
8777 | .PD
|
---|
8778 | .SH FILES
|
---|
8779 | .PD 0
|
---|
8780 | .TP
|
---|
8781 | .FN /bin/bash
|
---|
8782 | The \fBbash\fP executable
|
---|
8783 | .TP
|
---|
8784 | .FN /etc/profile
|
---|
8785 | The systemwide initialization file, executed for login shells
|
---|
8786 | .TP
|
---|
8787 | .FN ~/.bash_profile
|
---|
8788 | The personal initialization file, executed for login shells
|
---|
8789 | .TP
|
---|
8790 | .FN ~/.bashrc
|
---|
8791 | The individual per-interactive-shell startup file
|
---|
8792 | .TP
|
---|
8793 | .FN ~/.bash_logout
|
---|
8794 | The individual login shell cleanup file, executed when a login shell exits
|
---|
8795 | .TP
|
---|
8796 | .FN ~/.inputrc
|
---|
8797 | Individual \fIreadline\fP initialization file
|
---|
8798 | .PD
|
---|
8799 | .SH AUTHORS
|
---|
8800 | Brian Fox, Free Software Foundation
|
---|
8801 | .br
|
---|
8802 | bfox@gnu.org
|
---|
8803 | .PP
|
---|
8804 | Chet Ramey, Case Western Reserve University
|
---|
8805 | .br
|
---|
8806 | chet@po.cwru.edu
|
---|
8807 | .SH BUG REPORTS
|
---|
8808 | If you find a bug in
|
---|
8809 | .B bash,
|
---|
8810 | you should report it. But first, you should
|
---|
8811 | make sure that it really is a bug, and that it appears in the latest
|
---|
8812 | version of
|
---|
8813 | .BR bash .
|
---|
8814 | The latest version is always available from
|
---|
8815 | \fIftp://ftp.gnu.org/pub/bash/\fP.
|
---|
8816 | .PP
|
---|
8817 | Once you have determined that a bug actually exists, use the
|
---|
8818 | .I bashbug
|
---|
8819 | command to submit a bug report.
|
---|
8820 | If you have a fix, you are encouraged to mail that as well!
|
---|
8821 | Suggestions and `philosophical' bug reports may be mailed
|
---|
8822 | to \fIbug-bash@gnu.org\fP or posted to the Usenet
|
---|
8823 | newsgroup
|
---|
8824 | .BR gnu.bash.bug .
|
---|
8825 | .PP
|
---|
8826 | ALL bug reports should include:
|
---|
8827 | .PP
|
---|
8828 | .PD 0
|
---|
8829 | .TP 20
|
---|
8830 | The version number of \fBbash\fR
|
---|
8831 | .TP
|
---|
8832 | The hardware and operating system
|
---|
8833 | .TP
|
---|
8834 | The compiler used to compile
|
---|
8835 | .TP
|
---|
8836 | A description of the bug behaviour
|
---|
8837 | .TP
|
---|
8838 | A short script or `recipe' which exercises the bug
|
---|
8839 | .PD
|
---|
8840 | .PP
|
---|
8841 | .I bashbug
|
---|
8842 | inserts the first three items automatically into the template
|
---|
8843 | it provides for filing a bug report.
|
---|
8844 | .PP
|
---|
8845 | Comments and bug reports concerning
|
---|
8846 | this manual page should be directed to
|
---|
8847 | .IR chet@po.cwru.edu .
|
---|
8848 | .SH BUGS
|
---|
8849 | .PP
|
---|
8850 | It's too big and too slow.
|
---|
8851 | .PP
|
---|
8852 | There are some subtle differences between
|
---|
8853 | .B bash
|
---|
8854 | and traditional versions of
|
---|
8855 | .BR sh ,
|
---|
8856 | mostly because of the
|
---|
8857 | .SM
|
---|
8858 | .B POSIX
|
---|
8859 | specification.
|
---|
8860 | .PP
|
---|
8861 | Aliases are confusing in some uses.
|
---|
8862 | .PP
|
---|
8863 | Shell builtin commands and functions are not stoppable/restartable.
|
---|
8864 | .PP
|
---|
8865 | Compound commands and command sequences of the form `a ; b ; c'
|
---|
8866 | are not handled gracefully when process suspension is attempted.
|
---|
8867 | When a process is stopped, the shell immediately executes the next
|
---|
8868 | command in the sequence.
|
---|
8869 | It suffices to place the sequence of commands between
|
---|
8870 | parentheses to force it into a subshell, which may be stopped as
|
---|
8871 | a unit.
|
---|
8872 | .PP
|
---|
8873 | Commands inside of \fB$(\fP...\fB)\fP command substitution are not
|
---|
8874 | parsed until substitution is attempted. This will delay error
|
---|
8875 | reporting until some time after the command is entered. For example,
|
---|
8876 | unmatched parentheses, even inside shell comments, will result in
|
---|
8877 | error messages while the construct is being read.
|
---|
8878 | .PP
|
---|
8879 | Array variables may not (yet) be exported.
|
---|
8880 | .zZ
|
---|
8881 | .zY
|
---|