]> git.ipfire.org Git - thirdparty/bash.git/blame - doc/bashref.info
commit bash-20041118 snapshot
[thirdparty/bash.git] / doc / bashref.info
CommitLineData
37c41ab1 1This is bashref.info, produced by makeinfo version 4.7 from
22e63b05 2/usr/homes/chet/src/bash/src/doc/bashref.texi.
e8ce775d 3
37c41ab1 4 This text is a brief description of the features that are present in
22e63b05 5the Bash shell (version 3.0, 17 September 2004).
d3a24ed2 6
22e63b05
CR
7 This is Edition 3.0, last updated 17 September 2004, of `The GNU
8Bash Reference Manual', for `Bash', Version 3.0.
d3a24ed2 9
9f422431 10 Copyright (C) 1988-2004 Free Software Foundation, Inc.
d3a24ed2
CR
11
12 Permission is granted to make and distribute verbatim copies of this
13manual provided the copyright notice and this permission notice are
14preserved on all copies.
15
16 Permission is granted to copy, distribute and/or modify this
17 document under the terms of the GNU Free Documentation License,
18 Version 1.1 or any later version published by the Free Software
19 Foundation; with no Invariant Sections, with the Front-Cover texts
20 being "A GNU Manual," and with the Back-Cover Texts as in (a)
21 below. A copy of the license is included in the section entitled
22 "GNU Free Documentation License."
23
24 (a) The FSF's Back-Cover Text is: "You have freedom to copy and
25 modify this GNU Manual, like GNU software. Copies published by
26 the Free Software Foundation raise funds for GNU development."
37c41ab1 27
d3a24ed2 28INFO-DIR-SECTION Basics
e8ce775d 29START-INFO-DIR-ENTRY
cce855bc 30* Bash: (bash). The GNU Bourne-Again SHell.
e8ce775d 31END-INFO-DIR-ENTRY
ccc6cda3 32
ccc6cda3
JA
33\1f
34File: bashref.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir)
35
36Bash Features
37*************
38
37c41ab1 39This text is a brief description of the features that are present in
22e63b05 40the Bash shell (version 3.0, 17 September 2004)..
ccc6cda3 41
22e63b05
CR
42 This is Edition 3.0, last updated 17 September 2004, of `The GNU
43Bash Reference Manual', for `Bash', Version 3.0.
ccc6cda3
JA
44
45 Bash contains features that appear in other popular shells, and some
46features that only appear in Bash. Some of the shells that Bash has
47borrowed concepts from are the Bourne Shell (`sh'), the Korn Shell
48(`ksh'), and the C-shell (`csh' and its successor, `tcsh'). The
49following menu breaks the features up into categories based upon which
50one of these other shells inspired the feature.
51
52 This manual is meant as a brief introduction to features found in
53Bash. The Bash manual page should be used as the definitive reference
54on shell behavior.
55
56* Menu:
57
58* Introduction:: An introduction to the shell.
59
60* Definitions:: Some definitions used in the rest of this
61 manual.
62
63* Basic Shell Features:: The shell "building blocks".
64
bb70624e
JA
65* Shell Builtin Commands:: Commands that are a part of the shell.
66
67* Shell Variables:: Variables used or set by Bash.
ccc6cda3 68
ccc6cda3
JA
69* Bash Features:: Features found only in Bash.
70
71* Job Control:: A chapter describing what job control is
72 and how Bash allows you to use it.
73
74* Using History Interactively:: Chapter dealing with history expansion
75 rules.
76
77* Command Line Editing:: Chapter describing the command line
78 editing features.
79
80* Installing Bash:: How to build and install Bash on your system.
81
82* Reporting Bugs:: How to report bugs in Bash.
83
bb70624e
JA
84* Major Differences From The Bourne Shell:: A terse list of the differences
85 between Bash and historical
86 versions of /bin/sh.
87
d3a24ed2
CR
88* Copying This Manual:: Copying this manual.
89
ccc6cda3
JA
90* Builtin Index:: Index of Bash builtin commands.
91
92* Reserved Word Index:: Index of Bash reserved words.
93
94* Variable Index:: Quick reference helps you find the
95 variable you want.
96
97* Function Index:: Index of bindable Readline functions.
98
99* Concept Index:: General index for concepts described in
100 this manual.
101
102\1f
103File: bashref.info, Node: Introduction, Next: Definitions, Prev: Top, Up: Top
104
37c41ab1
CR
1051 Introduction
106**************
ccc6cda3
JA
107
108* Menu:
109
110* What is Bash?:: A short description of Bash.
111
112* What is a shell?:: A brief introduction to shells.
113
114\1f
115File: bashref.info, Node: What is Bash?, Next: What is a shell?, Up: Introduction
116
37c41ab1
CR
1171.1 What is Bash?
118=================
ccc6cda3 119
37c41ab1 120Bash is the shell, or command language interpreter, for the GNU
bb70624e
JA
121operating system. The name is an acronym for the `Bourne-Again SHell',
122a pun on Stephen Bourne, the author of the direct ancestor of the
d3a24ed2
CR
123current Unix shell `sh', which appeared in the Seventh Edition Bell
124Labs Research version of Unix.
ccc6cda3 125
bb70624e
JA
126 Bash is largely compatible with `sh' and incorporates useful
127features from the Korn shell `ksh' and the C shell `csh'. It is
128intended to be a conformant implementation of the IEEE POSIX Shell and
129Tools specification (IEEE Working Group 1003.2). It offers functional
ccc6cda3
JA
130improvements over `sh' for both interactive and programming use.
131
bb70624e
JA
132 While the GNU operating system provides other shells, including a
133version of `csh', Bash is the default shell. Like other GNU software,
134Bash is quite portable. It currently runs on nearly every version of
135Unix and a few other operating systems - independently-supported ports
d3a24ed2 136exist for MS-DOS, OS/2, and Windows platforms.
ccc6cda3
JA
137
138\1f
139File: bashref.info, Node: What is a shell?, Prev: What is Bash?, Up: Introduction
140
37c41ab1
CR
1411.2 What is a shell?
142====================
ccc6cda3 143
37c41ab1 144At its base, a shell is simply a macro processor that executes
d3a24ed2
CR
145commands. The term macro processor means functionality where text and
146symbols are expanded to create larger expressions.
147
148 A Unix shell is both a command interpreter and a programming
149language. As a command interpreter, the shell provides the user
150interface to the rich set of GNU utilities. The programming language
151features allow these utilitites to be combined. Files containing
cce855bc 152commands can be created, and become commands themselves. These new
bb70624e 153commands have the same status as system commands in directories such as
d3a24ed2
CR
154`/bin', allowing users or groups to establish custom environments to
155automate their common tasks.
156
157 Shells may be used interactively or non-interactively. In
158interactive mode, they accept input typed from the keyboard. When
159executing non-interactively, shells execute commands read from a file.
ccc6cda3 160
bb70624e 161 A shell allows execution of GNU commands, both synchronously and
cce855bc
JA
162asynchronously. The shell waits for synchronous commands to complete
163before accepting more input; asynchronous commands continue to execute
164in parallel with the shell while it reads and executes additional
165commands. The "redirection" constructs permit fine-grained control of
bb70624e 166the input and output of those commands. Moreover, the shell allows
d3a24ed2 167control over the contents of commands' environments.
bb70624e
JA
168
169 Shells also provide a small set of built-in commands ("builtins")
170implementing functionality impossible or inconvenient to obtain via
171separate utilities. For example, `cd', `break', `continue', and
172`exec') cannot be implemented outside of the shell because they
173directly manipulate the shell itself. The `history', `getopts',
174`kill', or `pwd' builtins, among others, could be implemented in
175separate utilities, but they are more convenient to use as builtin
176commands. All of the shell builtins are described in subsequent
177sections.
ccc6cda3
JA
178
179 While executing commands is essential, most of the power (and
180complexity) of shells is due to their embedded programming languages.
181Like any high-level language, the shell provides variables, flow
182control constructs, quoting, and functions.
183
bb70624e
JA
184 Shells offer features geared specifically for interactive use rather
185than to augment the programming language. These interactive features
d3a24ed2
CR
186include job control, command line editing, command history and aliases.
187Each of these features is described in this manual.
ccc6cda3
JA
188
189\1f
190File: bashref.info, Node: Definitions, Next: Basic Shell Features, Prev: Introduction, Up: Top
191
37c41ab1
CR
1922 Definitions
193*************
ccc6cda3 194
37c41ab1 195These definitions are used throughout the remainder of this manual.
ccc6cda3
JA
196
197`POSIX'
198 A family of open system standards based on Unix. Bash is
199 concerned with POSIX 1003.2, the Shell and Tools Standard.
200
201`blank'
202 A space or tab character.
203
204`builtin'
205 A command that is implemented internally by the shell itself,
206 rather than by an executable program somewhere in the file system.
207
208`control operator'
209 A `word' that performs a control function. It is a `newline' or
210 one of the following: `||', `&&', `&', `;', `;;', `|', `(', or `)'.
211
212`exit status'
f73dda09
JA
213 The value returned by a command to its caller. The value is
214 restricted to eight bits, so the maximum value is 255.
ccc6cda3
JA
215
216`field'
217 A unit of text that is the result of one of the shell expansions.
218 After expansion, when executing a command, the resulting fields
219 are used as the command name and arguments.
220
221`filename'
222 A string of characters used to identify a file.
223
224`job'
225 A set of processes comprising a pipeline, and any processes
226 descended from it, that are all in the same process group.
227
228`job control'
d166f048
JA
229 A mechanism by which users can selectively stop (suspend) and
230 restart (resume) execution of processes.
ccc6cda3
JA
231
232`metacharacter'
233 A character that, when unquoted, separates words. A metacharacter
234 is a `blank' or one of the following characters: `|', `&', `;',
235 `(', `)', `<', or `>'.
236
237`name'
238 A `word' consisting solely of letters, numbers, and underscores,
239 and beginning with a letter or underscore. `Name's are used as
240 shell variable and function names. Also referred to as an
241 `identifier'.
242
243`operator'
244 A `control operator' or a `redirection operator'. *Note
245 Redirections::, for a list of redirection operators.
246
247`process group'
248 A collection of related processes each having the same process
249 group ID.
250
251`process group ID'
252 A unique identifer that represents a `process group' during its
253 lifetime.
254
255`reserved word'
256 A `word' that has a special meaning to the shell. Most reserved
257 words introduce shell flow control constructs, such as `for' and
258 `while'.
259
260`return status'
261 A synonym for `exit status'.
262
263`signal'
bb70624e 264 A mechanism by which a process may be notified by the kernel of an
ccc6cda3
JA
265 event occurring in the system.
266
267`special builtin'
268 A shell builtin command that has been classified as special by the
bb70624e 269 POSIX 1003.2 standard.
ccc6cda3
JA
270
271`token'
272 A sequence of characters considered a single unit by the shell.
273 It is either a `word' or an `operator'.
274
275`word'
276 A `token' that is not an `operator'.
277
278\1f
bb70624e 279File: bashref.info, Node: Basic Shell Features, Next: Shell Builtin Commands, Prev: Definitions, Up: Top
ccc6cda3 280
37c41ab1
CR
2813 Basic Shell Features
282**********************
ccc6cda3 283
37c41ab1
CR
284Bash is an acronym for `Bourne-Again SHell'. The Bourne shell is the
285traditional Unix shell originally written by Stephen Bourne. All of
286the Bourne shell builtin commands are available in Bash, The rules for
287evaluation and quoting are taken from the POSIX specification for the
288`standard' Unix shell.
ccc6cda3 289
cce855bc 290 This chapter briefly summarizes the shell's `building blocks':
ccc6cda3
JA
291commands, control structures, shell functions, shell parameters, shell
292expansions, redirections, which are a way to direct input and output
293from and to named files, and how the shell executes commands.
294
295* Menu:
296
297* Shell Syntax:: What your input means to the shell.
cce855bc 298* Shell Commands:: The types of commands you can use.
ccc6cda3 299* Shell Functions:: Grouping commands by name.
d3a24ed2
CR
300* Shell Parameters:: How the shell stores values.
301* Shell Expansions:: How Bash expands parameters and the various
ccc6cda3
JA
302 expansions available.
303* Redirections:: A way to control where input and output go.
304* Executing Commands:: What happens when you run a command.
305* Shell Scripts:: Executing files of shell commands.
306
307\1f
cce855bc 308File: bashref.info, Node: Shell Syntax, Next: Shell Commands, Up: Basic Shell Features
ccc6cda3 309
37c41ab1
CR
3103.1 Shell Syntax
311================
ccc6cda3
JA
312
313* Menu:
314
315* Shell Operation:: The basic operation of the shell.
316
317* Quoting:: How to remove the special meaning from characters.
318
319* Comments:: How to specify comments.
320
bb70624e
JA
321 When the shell reads input, it proceeds through a sequence of
322operations. If the input indicates the beginning of a comment, the
323shell ignores the comment symbol (`#'), and the rest of that line.
324
325 Otherwise, roughly speaking, the shell reads its input and divides
326the input into words and operators, employing the quoting rules to
327select which meanings to assign various words and characters.
328
329 The shell then parses these tokens into commands and other
330constructs, removes the special meaning of certain words or characters,
331expands others, redirects input and output as needed, executes the
332specified command, waits for the command's exit status, and makes that
333exit status available for further inspection or processing.
334
ccc6cda3
JA
335\1f
336File: bashref.info, Node: Shell Operation, Next: Quoting, Up: Shell Syntax
337
37c41ab1
CR
3383.1.1 Shell Operation
339---------------------
ccc6cda3 340
37c41ab1 341The following is a brief description of the shell's operation when it
ccc6cda3
JA
342reads and executes a command. Basically, the shell does the following:
343
28ef6c31 344 1. Reads its input from a file (*note Shell Scripts::), from a string
ccc6cda3 345 supplied as an argument to the `-c' invocation option (*note
28ef6c31 346 Invoking Bash::), or from the user's terminal.
ccc6cda3
JA
347
348 2. Breaks the input into words and operators, obeying the quoting
cce855bc 349 rules described in *Note Quoting::. These tokens are separated by
ccc6cda3 350 `metacharacters'. Alias expansion is performed by this step
28ef6c31 351 (*note Aliases::).
ccc6cda3 352
cce855bc 353 3. Parses the tokens into simple and compound commands (*note Shell
28ef6c31 354 Commands::).
ccc6cda3 355
28ef6c31 356 4. Performs the various shell expansions (*note Shell Expansions::),
ccc6cda3 357 breaking the expanded tokens into lists of filenames (*note
28ef6c31 358 Filename Expansion::) and commands and arguments.
ccc6cda3 359
28ef6c31 360 5. Performs any necessary redirections (*note Redirections::) and
ccc6cda3
JA
361 removes the redirection operators and their operands from the
362 argument list.
363
28ef6c31 364 6. Executes the command (*note Executing Commands::).
ccc6cda3
JA
365
366 7. Optionally waits for the command to complete and collects its exit
28ef6c31 367 status (*note Exit Status::).
ccc6cda3
JA
368
369
370\1f
371File: bashref.info, Node: Quoting, Next: Comments, Prev: Shell Operation, Up: Shell Syntax
372
37c41ab1
CR
3733.1.2 Quoting
374-------------
ccc6cda3
JA
375
376* Menu:
377
378* Escape Character:: How to remove the special meaning from a single
379 character.
380* Single Quotes:: How to inhibit all interpretation of a sequence
381 of characters.
382* Double Quotes:: How to suppress most of the interpretation of a
383 sequence of characters.
384* ANSI-C Quoting:: How to expand ANSI-C sequences in quoted strings.
385
386* Locale Translation:: How to translate strings into different languages.
387
388 Quoting is used to remove the special meaning of certain characters
389or words to the shell. Quoting can be used to disable special
390treatment for special characters, to prevent reserved words from being
391recognized as such, and to prevent parameter expansion.
392
28ef6c31 393 Each of the shell metacharacters (*note Definitions::) has special
cce855bc 394meaning to the shell and must be quoted if it is to represent itself.
bb70624e
JA
395When the command history expansion facilities are being used, the
396HISTORY EXPANSION character, usually `!', must be quoted to prevent
28ef6c31 397history expansion. *Note Bash History Facilities::, for more details
d3a24ed2
CR
398concerning history expansion.
399
400 There are three quoting mechanisms: the ESCAPE CHARACTER, single
401quotes, and double quotes.
ccc6cda3
JA
402
403\1f
404File: bashref.info, Node: Escape Character, Next: Single Quotes, Up: Quoting
405
37c41ab1
CR
4063.1.2.1 Escape Character
407........................
ccc6cda3 408
37c41ab1
CR
409A non-quoted backslash `\' is the Bash escape character. It preserves
410the literal value of the next character that follows, with the
411exception of `newline'. If a `\newline' pair appears, and the
cce855bc
JA
412backslash itself is not quoted, the `\newline' is treated as a line
413continuation (that is, it is removed from the input stream and
414effectively ignored).
ccc6cda3
JA
415
416\1f
417File: bashref.info, Node: Single Quotes, Next: Double Quotes, Prev: Escape Character, Up: Quoting
418
37c41ab1
CR
4193.1.2.2 Single Quotes
420.....................
ccc6cda3 421
37c41ab1
CR
422Enclosing characters in single quotes (`'') preserves the literal value
423of each character within the quotes. A single quote may not occur
bb70624e 424between single quotes, even when preceded by a backslash.
ccc6cda3
JA
425
426\1f
427File: bashref.info, Node: Double Quotes, Next: ANSI-C Quoting, Prev: Single Quotes, Up: Quoting
428
37c41ab1
CR
4293.1.2.3 Double Quotes
430.....................
ccc6cda3 431
37c41ab1
CR
432Enclosing characters in double quotes (`"') preserves the literal value
433of all characters within the quotes, with the exception of `$', ``',
434and `\'. The characters `$' and ``' retain their special meaning
28ef6c31
JA
435within double quotes (*note Shell Expansions::). The backslash retains
436its special meaning only when followed by one of the following
bb70624e
JA
437characters: `$', ``', `"', `\', or `newline'. Within double quotes,
438backslashes that are followed by one of these characters are removed.
439Backslashes preceding characters without a special meaning are left
440unmodified. A double quote may be quoted within double quotes by
d3a24ed2
CR
441preceding it with a backslash. When command history is being used, the
442double quote may not be used to quote the history expansion character.
ccc6cda3
JA
443
444 The special parameters `*' and `@' have special meaning when in
28ef6c31 445double quotes (*note Shell Parameter Expansion::).
ccc6cda3
JA
446
447\1f
448File: bashref.info, Node: ANSI-C Quoting, Next: Locale Translation, Prev: Double Quotes, Up: Quoting
449
37c41ab1
CR
4503.1.2.4 ANSI-C Quoting
451......................
ccc6cda3 452
37c41ab1
CR
453Words of the form `$'STRING'' are treated specially. The word expands
454to STRING, with backslash-escaped characters replaced as specified by
455the ANSI C standard. Backslash escape sequences, if present, are
456decoded as follows:
ccc6cda3
JA
457
458`\a'
459 alert (bell)
460
461`\b'
462 backspace
463
464`\e'
465 an escape character (not ANSI C)
466
467`\f'
468 form feed
469
470`\n'
471 newline
472
473`\r'
474 carriage return
475
476`\t'
477 horizontal tab
478
479`\v'
480 vertical tab
481
482`\\'
483 backslash
484
bb70624e
JA
485`\''
486 single quote
487
ccc6cda3 488`\NNN'
f73dda09 489 the eight-bit character whose value is the octal value NNN (one to
cce855bc
JA
490 three digits)
491
f73dda09
JA
492`\xHH'
493 the eight-bit character whose value is the hexadecimal value HH
494 (one or two hex digits)
ccc6cda3 495
7117c2d2
JA
496`\cX'
497 a control-X character
498
bb70624e
JA
499The expanded result is single-quoted, as if the dollar sign had not
500been present.
ccc6cda3
JA
501
502\1f
503File: bashref.info, Node: Locale Translation, Prev: ANSI-C Quoting, Up: Quoting
504
37c41ab1
CR
5053.1.2.5 Locale-Specific Translation
506...................................
ccc6cda3 507
37c41ab1
CR
508A double-quoted string preceded by a dollar sign (`$') will cause the
509string to be translated according to the current locale. If the
ccc6cda3
JA
510current locale is `C' or `POSIX', the dollar sign is ignored. If the
511string is translated and replaced, the replacement is double-quoted.
512
28ef6c31
JA
513 Some systems use the message catalog selected by the `LC_MESSAGES'
514shell variable. Others create the name of the message catalog from the
515value of the `TEXTDOMAIN' shell variable, possibly adding a suffix of
516`.mo'. If you use the `TEXTDOMAIN' variable, you may need to set the
517`TEXTDOMAINDIR' variable to the location of the message catalog files.
f73dda09
JA
518Still others use both variables in this fashion:
519`TEXTDOMAINDIR'/`LC_MESSAGES'/LC_MESSAGES/`TEXTDOMAIN'.mo.
28ef6c31 520
ccc6cda3
JA
521\1f
522File: bashref.info, Node: Comments, Prev: Quoting, Up: Shell Syntax
523
37c41ab1
CR
5243.1.3 Comments
525--------------
ccc6cda3 526
37c41ab1 527In a non-interactive shell, or an interactive shell in which the
ccc6cda3 528`interactive_comments' option to the `shopt' builtin is enabled (*note
28ef6c31 529Bash Builtins::), a word beginning with `#' causes that word and all
ccc6cda3
JA
530remaining characters on that line to be ignored. An interactive shell
531without the `interactive_comments' option enabled does not allow
532comments. The `interactive_comments' option is on by default in
bb70624e
JA
533interactive shells. *Note Interactive Shells::, for a description of
534what makes a shell interactive.
cce855bc
JA
535
536\1f
537File: bashref.info, Node: Shell Commands, Next: Shell Functions, Prev: Shell Syntax, Up: Basic Shell Features
538
37c41ab1
CR
5393.2 Shell Commands
540==================
cce855bc 541
37c41ab1 542A simple shell command such as `echo a b c' consists of the command
bb70624e
JA
543itself followed by arguments, separated by spaces.
544
545 More complex shell commands are composed of simple commands arranged
546together in a variety of ways: in a pipeline in which the output of one
547command becomes the input of a second, in a loop or conditional
548construct, or in some other grouping.
549
cce855bc
JA
550* Menu:
551
552* Simple Commands:: The most common type of command.
553* Pipelines:: Connecting the input and output of several
554 commands.
555* Lists:: How to execute commands sequentially.
d3a24ed2 556* Compound Commands:: Shell commands for control flow.
ccc6cda3
JA
557
558\1f
cce855bc 559File: bashref.info, Node: Simple Commands, Next: Pipelines, Up: Shell Commands
ccc6cda3 560
37c41ab1
CR
5613.2.1 Simple Commands
562---------------------
ccc6cda3 563
37c41ab1
CR
564A simple command is the kind of command encountered most often. It's
565just a sequence of words separated by `blank's, terminated by one of
566the shell's control operators (*note Definitions::). The first word
28ef6c31 567generally specifies a command to be executed, with the rest of the
bb70624e 568words being that command's arguments.
ccc6cda3 569
28ef6c31 570 The return status (*note Exit Status::) of a simple command is its
bb70624e
JA
571exit status as provided by the POSIX 1003.1 `waitpid' function, or
572128+N if the command was terminated by signal N.
ccc6cda3
JA
573
574\1f
cce855bc 575File: bashref.info, Node: Pipelines, Next: Lists, Prev: Simple Commands, Up: Shell Commands
ccc6cda3 576
37c41ab1
CR
5773.2.2 Pipelines
578---------------
ccc6cda3 579
37c41ab1 580A `pipeline' is a sequence of simple commands separated by `|'.
ccc6cda3
JA
581
582 The format for a pipeline is
583 [`time' [`-p']] [`!'] COMMAND1 [`|' COMMAND2 ...]
584
f73dda09
JA
585The output of each command in the pipeline is connected via a pipe to
586the input of the next command. That is, each command reads the
587previous command's output.
ccc6cda3
JA
588
589 The reserved word `time' causes timing statistics to be printed for
cce855bc
JA
590the pipeline once it finishes. The statistics currently consist of
591elapsed (wall-clock) time and user and system time consumed by the
592command's execution. The `-p' option changes the output format to that
593specified by POSIX. The `TIMEFORMAT' variable may be set to a format
594string that specifies how the timing information should be displayed.
595*Note Bash Variables::, for a description of the available formats.
596The use of `time' as a reserved word permits the timing of shell
597builtins, shell functions, and pipelines. An external `time' command
598cannot time these easily.
599
28ef6c31 600 If the pipeline is not executed asynchronously (*note Lists::), the
cce855bc 601shell waits for all commands in the pipeline to complete.
ccc6cda3 602
cce855bc 603 Each command in a pipeline is executed in its own subshell (*note
28ef6c31 604Command Execution Environment::). The exit status of a pipeline is the
5e13499c
CR
605exit status of the last command in the pipeline, unless the `pipefail'
606option is enabled (*note The Set Builtin::). If `pipefail' is enabled,
607the pipeline's return status is the value of the last (rightmost)
608command to exit with a non-zero status, or zero if all commands exit
609successfully. If the reserved word `!' precedes the pipeline, the exit
610status is the logical negation of the exit status as described above.
611The shell waits for all commands in the pipeline to terminate before
612returning a value.
ccc6cda3
JA
613
614\1f
d3a24ed2 615File: bashref.info, Node: Lists, Next: Compound Commands, Prev: Pipelines, Up: Shell Commands
ccc6cda3 616
37c41ab1
CR
6173.2.3 Lists of Commands
618-----------------------
ccc6cda3 619
37c41ab1
CR
620A `list' is a sequence of one or more pipelines separated by one of the
621operators `;', `&', `&&', or `||', and optionally terminated by one of
622`;', `&', or a `newline'.
ccc6cda3
JA
623
624 Of these list operators, `&&' and `||' have equal precedence,
625followed by `;' and `&', which have equal precedence.
626
7117c2d2
JA
627 A sequence of one or more newlines may appear in a `list' to delimit
628commands, equivalent to a semicolon.
629
ccc6cda3 630 If a command is terminated by the control operator `&', the shell
cce855bc
JA
631executes the command asynchronously in a subshell. This is known as
632executing the command in the BACKGROUND. The shell does not wait for
bb70624e 633the command to finish, and the return status is 0 (true). When job
28ef6c31 634control is not active (*note Job Control::), the standard input for
bb70624e
JA
635asynchronous commands, in the absence of any explicit redirections, is
636redirected from `/dev/null'.
cce855bc
JA
637
638 Commands separated by a `;' are executed sequentially; the shell
639waits for each command to terminate in turn. The return status is the
640exit status of the last command executed.
ccc6cda3
JA
641
642 The control operators `&&' and `||' denote AND lists and OR lists,
643respectively. An AND list has the form
bb70624e 644 COMMAND1 && COMMAND2
ccc6cda3 645
bb70624e
JA
646COMMAND2 is executed if, and only if, COMMAND1 returns an exit status
647of zero.
ccc6cda3
JA
648
649 An OR list has the form
bb70624e 650 COMMAND1 || COMMAND2
ccc6cda3 651
bb70624e 652COMMAND2 is executed if, and only if, COMMAND1 returns a non-zero exit
ccc6cda3
JA
653status.
654
655 The return status of AND and OR lists is the exit status of the last
656command executed in the list.
657
658\1f
d3a24ed2
CR
659File: bashref.info, Node: Compound Commands, Prev: Lists, Up: Shell Commands
660
37c41ab1
CR
6613.2.4 Compound Commands
662-----------------------
d3a24ed2
CR
663
664* Menu:
665
666* Looping Constructs:: Shell commands for iterative action.
667* Conditional Constructs:: Shell commands for conditional execution.
668* Command Grouping:: Ways to group commands.
669
670 Compound commands are the shell programming constructs. Each
671construct begins with a reserved word or control operator and is
672terminated by a corresponding reserved word or operator. Any
673redirections (*note Redirections::) associated with a compound command
674apply to all commands within that compound command unless explicitly
675overridden.
676
677 Bash provides looping constructs, conditional commands, and
678mechanisms to group commands and execute them as a unit.
679
680\1f
681File: bashref.info, Node: Looping Constructs, Next: Conditional Constructs, Up: Compound Commands
ccc6cda3 682
37c41ab1
CR
6833.2.4.1 Looping Constructs
684..........................
ccc6cda3 685
37c41ab1 686Bash supports the following looping constructs.
ccc6cda3 687
bb70624e 688 Note that wherever a `;' appears in the description of a command's
cce855bc
JA
689syntax, it may be replaced with one or more newlines.
690
ccc6cda3
JA
691`until'
692 The syntax of the `until' command is:
693 until TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
cce855bc
JA
694 Execute CONSEQUENT-COMMANDS as long as TEST-COMMANDS has an exit
695 status which is not zero. The return status is the exit status of
696 the last command executed in CONSEQUENT-COMMANDS, or zero if none
697 was executed.
ccc6cda3
JA
698
699`while'
700 The syntax of the `while' command is:
701 while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
702
cce855bc
JA
703 Execute CONSEQUENT-COMMANDS as long as TEST-COMMANDS has an exit
704 status of zero. The return status is the exit status of the last
705 command executed in CONSEQUENT-COMMANDS, or zero if none was
706 executed.
ccc6cda3
JA
707
708`for'
709 The syntax of the `for' command is:
710
711 for NAME [in WORDS ...]; do COMMANDS; done
cce855bc
JA
712 Expand WORDS, and execute COMMANDS once for each member in the
713 resultant list, with NAME bound to the current member. If `in
bb70624e
JA
714 WORDS' is not present, the `for' command executes the COMMANDS
715 once for each positional parameter that is set, as if `in "$@"'
28ef6c31 716 had been specified (*note Special Parameters::). The return
bb70624e
JA
717 status is the exit status of the last command that executes. If
718 there are no items in the expansion of WORDS, no commands are
719 executed, and the return status is zero.
720
721 An alternate form of the `for' command is also supported:
722
723 for (( EXPR1 ; EXPR2 ; EXPR3 )) ; do COMMANDS ; done
724 First, the arithmetic expression EXPR1 is evaluated according to
28ef6c31 725 the rules described below (*note Shell Arithmetic::). The
bb70624e
JA
726 arithmetic expression EXPR2 is then evaluated repeatedly until it
727 evaluates to zero. Each time EXPR2 evaluates to a non-zero value,
728 COMMANDS are executed and the arithmetic expression EXPR3 is
729 evaluated. If any expression is omitted, it behaves as if it
730 evaluates to 1. The return value is the exit status of the last
731 command in LIST that is executed, or false if any of the
732 expressions is invalid.
ccc6cda3 733
761783bf 734
28ef6c31 735 The `break' and `continue' builtins (*note Bourne Shell Builtins::)
ccc6cda3
JA
736may be used to control loop execution.
737
738\1f
d3a24ed2 739File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Prev: Looping Constructs, Up: Compound Commands
ccc6cda3 740
37c41ab1
CR
7413.2.4.2 Conditional Constructs
742..............................
ccc6cda3
JA
743
744`if'
745 The syntax of the `if' command is:
746
747 if TEST-COMMANDS; then
748 CONSEQUENT-COMMANDS;
749 [elif MORE-TEST-COMMANDS; then
750 MORE-CONSEQUENTS;]
751 [else ALTERNATE-CONSEQUENTS;]
752 fi
753
cce855bc
JA
754 The TEST-COMMANDS list is executed, and if its return status is
755 zero, the CONSEQUENT-COMMANDS list is executed. If TEST-COMMANDS
756 returns a non-zero status, each `elif' list is executed in turn,
757 and if its exit status is zero, the corresponding MORE-CONSEQUENTS
758 is executed and the command completes. If `else
759 ALTERNATE-CONSEQUENTS' is present, and the final command in the
760 final `if' or `elif' clause has a non-zero exit status, then
761 ALTERNATE-CONSEQUENTS is executed. The return status is the exit
762 status of the last command executed, or zero if no condition
763 tested true.
ccc6cda3
JA
764
765`case'
766 The syntax of the `case' command is:
767
cce855bc 768 `case WORD in [ [(] PATTERN [| PATTERN]...) COMMAND-LIST ;;]... esac'
ccc6cda3 769
cce855bc
JA
770 `case' will selectively execute the COMMAND-LIST corresponding to
771 the first PATTERN that matches WORD. The `|' is used to separate
772 multiple patterns, and the `)' operator terminates a pattern list.
773 A list of patterns and an associated command-list is known as a
774 CLAUSE. Each clause must be terminated with `;;'. The WORD
775 undergoes tilde expansion, parameter expansion, command
776 substitution, arithmetic expansion, and quote removal before
777 matching is attempted. Each PATTERN undergoes tilde expansion,
778 parameter expansion, command substitution, and arithmetic
779 expansion.
780
781 There may be an arbitrary number of `case' clauses, each terminated
782 by a `;;'. The first pattern that matches determines the
783 command-list that is executed.
ccc6cda3
JA
784
785 Here is an example using `case' in a script that could be used to
786 describe one interesting feature of an animal:
787
788 echo -n "Enter the name of an animal: "
789 read ANIMAL
790 echo -n "The $ANIMAL has "
791 case $ANIMAL in
792 horse | dog | cat) echo -n "four";;
793 man | kangaroo ) echo -n "two";;
794 *) echo -n "an unknown number of";;
795 esac
796 echo " legs."
797
cce855bc
JA
798 The return status is zero if no PATTERN is matched. Otherwise, the
799 return status is the exit status of the COMMAND-LIST executed.
800
801`select'
802 The `select' construct allows the easy generation of menus. It
803 has almost the same syntax as the `for' command:
804
805 select NAME [in WORDS ...]; do COMMANDS; done
806
807 The list of words following `in' is expanded, generating a list of
808 items. The set of expanded words is printed on the standard error
809 output stream, each preceded by a number. If the `in WORDS' is
810 omitted, the positional parameters are printed, as if `in "$@"'
811 had been specifed. The `PS3' prompt is then displayed and a line
812 is read from the standard input. If the line consists of a number
813 corresponding to one of the displayed words, then the value of
814 NAME is set to that word. If the line is empty, the words and
815 prompt are displayed again. If `EOF' is read, the `select'
816 command completes. Any other value read causes NAME to be set to
817 null. The line read is saved in the variable `REPLY'.
818
f73dda09
JA
819 The COMMANDS are executed after each selection until a `break'
820 command is executed, at which point the `select' command completes.
cce855bc
JA
821
822 Here is an example that allows the user to pick a filename from the
823 current directory, and displays the name and index of the file
824 selected.
825
826 select fname in *;
827 do
828 echo you picked $fname \($REPLY\)
829 break;
830 done
831
ccc6cda3
JA
832`((...))'
833 (( EXPRESSION ))
834
cce855bc 835 The arithmetic EXPRESSION is evaluated according to the rules
28ef6c31 836 described below (*note Shell Arithmetic::). If the value of the
cce855bc
JA
837 expression is non-zero, the return status is 0; otherwise the
838 return status is 1. This is exactly equivalent to
ccc6cda3 839 let "EXPRESSION"
cce855bc
JA
840 *Note Bash Builtins::, for a full description of the `let' builtin.
841
842`[[...]]'
843 [[ EXPRESSION ]]
844
845 Return a status of 0 or 1 depending on the evaluation of the
846 conditional expression EXPRESSION. Expressions are composed of
847 the primaries described below in *Note Bash Conditional
848 Expressions::. Word splitting and filename expansion are not
849 performed on the words between the `[[' and `]]'; tilde expansion,
850 parameter and variable expansion, arithmetic expansion, command
851 substitution, process substitution, and quote removal are
d3a24ed2
CR
852 performed. Conditional operators such as `-f' must be unquoted to
853 be recognized as primaries.
cce855bc
JA
854
855 When the `==' and `!=' operators are used, the string to the right
856 of the operator is considered a pattern and matched according to
857 the rules described below in *Note Pattern Matching::. The return
858 value is 0 if the string matches or does not match the pattern,
859 respectively, and 1 otherwise. Any part of the pattern may be
860 quoted to force it to be matched as a string.
861
5e13499c
CR
862 An additional binary operator, `=~', is available, with the same
863 precedence as `==' and `!='. When it is used, the string to the
864 right of the operator is considered an extended regular expression
865 and matched accordingly (as in regex3)). The return value is 0 if
866 the string matches the pattern, and 1 otherwise. If the regular
867 expression is syntactically incorrect, the conditional
868 expression's return value is 2. If the shell option `nocaseglob'
869 (see the description of `shopt' in *Note Bash Builtins::) is
870 enabled, the match is performed without regard to the case of
871 alphabetic characters. Substrings matched by parenthesized
872 subexpressions within the regular expression are saved in the
873 array variable `BASH_REMATCH'. The element of `BASH_REMATCH' with
874 index 0 is the portion of the string matching the entire regular
875 expression. The element of `BASH_REMATCH' with index N is the
876 portion of the string matching the Nth parenthesized subexpression.
877
cce855bc
JA
878 Expressions may be combined using the following operators, listed
879 in decreasing order of precedence:
880
881 `( EXPRESSION )'
882 Returns the value of EXPRESSION. This may be used to
883 override the normal precedence of operators.
884
885 `! EXPRESSION'
886 True if EXPRESSION is false.
887
888 `EXPRESSION1 && EXPRESSION2'
889 True if both EXPRESSION1 and EXPRESSION2 are true.
890
891 `EXPRESSION1 || EXPRESSION2'
892 True if either EXPRESSION1 or EXPRESSION2 is true.
7117c2d2
JA
893 The `&&' and `||' operators do not evaluate EXPRESSION2 if the
894 value of EXPRESSION1 is sufficient to determine the return value
895 of the entire conditional expression.
ccc6cda3 896
761783bf 897
ccc6cda3 898\1f
d3a24ed2 899File: bashref.info, Node: Command Grouping, Prev: Conditional Constructs, Up: Compound Commands
ccc6cda3 900
37c41ab1
CR
9013.2.4.3 Grouping Commands
902.........................
ccc6cda3 903
37c41ab1
CR
904Bash provides two ways to group a list of commands to be executed as a
905unit. When commands are grouped, redirections may be applied to the
ccc6cda3
JA
906entire command list. For example, the output of all the commands in
907the list may be redirected to a single stream.
908
909`()'
910 ( LIST )
911
912 Placing a list of commands between parentheses causes a subshell
d3a24ed2
CR
913 environment to be created (*note Command Execution Environment::),
914 and each of the commands in LIST to be executed in that subshell.
915 Since the LIST is executed in a subshell, variable assignments do
916 not remain in effect after the subshell completes.
ccc6cda3
JA
917
918`{}'
919 { LIST; }
920
921 Placing a list of commands between curly braces causes the list to
922 be executed in the current shell context. No subshell is created.
cce855bc 923 The semicolon (or newline) following LIST is required.
ccc6cda3
JA
924
925 In addition to the creation of a subshell, there is a subtle
926difference between these two constructs due to historical reasons. The
927braces are `reserved words', so they must be separated from the LIST by
928`blank's. The parentheses are `operators', and are recognized as
d166f048
JA
929separate tokens by the shell even if they are not separated from the
930LIST by whitespace.
ccc6cda3
JA
931
932 The exit status of both of these constructs is the exit status of
933LIST.
934
935\1f
cce855bc 936File: bashref.info, Node: Shell Functions, Next: Shell Parameters, Prev: Shell Commands, Up: Basic Shell Features
ccc6cda3 937
37c41ab1
CR
9383.3 Shell Functions
939===================
ccc6cda3 940
37c41ab1
CR
941Shell functions are a way to group commands for later execution using a
942single name for the group. They are executed just like a "regular"
943command. When the name of a shell function is used as a simple command
944name, the list of commands associated with that function name is
945executed. Shell functions are executed in the current shell context;
946no new process is created to interpret them.
ccc6cda3 947
37c41ab1 948 Functions are declared using this syntax:
d3a24ed2 949 [ `function' ] NAME () COMPOUND-COMMAND [ REDIRECTIONS ]
ccc6cda3
JA
950
951 This defines a shell function named NAME. The reserved word
cce855bc 952`function' is optional. If the `function' reserved word is supplied,
d3a24ed2
CR
953the parentheses are optional. The BODY of the function is the compound
954command COMPOUND-COMMAND (*note Compound Commands::). That command is
955usually a LIST enclosed between { and }, but may be any compound
956command listed above. COMPOUND-COMMAND is executed whenever NAME is
957specified as the name of a command. Any redirections (*note
958Redirections::) associated with the shell function are performed when
959the function is executed.
960
961 The exit status of a function definition is zero unless a syntax
962error occurs or a readonly function with the same name already exists.
963When executed, the exit status of a function is the exit status of the
964last command executed in the body.
965
966 Note that for historical reasons, in the most common usage the curly
967braces that surround the body of the function must be separated from
968the body by `blank's or newlines. This is because the braces are
969reserved words and are only recognized as such when they are separated
970by whitespace. Also, when using the braces, the LIST must be
971terminated by a semicolon, a `&', or a newline.
bb70624e 972
ccc6cda3
JA
973 When a function is executed, the arguments to the function become
974the positional parameters during its execution (*note Positional
28ef6c31 975Parameters::). The special parameter `#' that expands to the number of
de8913bd 976positional parameters is updated to reflect the change. Special
d3a24ed2
CR
977parameter `0' is unchanged. The first element of the `FUNCNAME'
978variable is set to the name of the function while the function is
979executing. All other aspects of the shell execution environment are
980identical between a function and its caller with the exception that the
981`DEBUG' trap below) is not inherited unless the function has been given
982the `trace' attribute using the `declare' builtin or the `-o functrace'
983option has been enabled with the `set' builtin, (in which case all
984functions inherit the `DEBUG' trap). *Note Bourne Shell Builtins::,
985for the description of the `trap' builtin.
ccc6cda3
JA
986
987 If the builtin command `return' is executed in a function, the
988function completes and execution resumes with the next command after
d3a24ed2
CR
989the function call. Any command associated with the `RETURN' trap is
990executed before execution resumes. When a function completes, the
991values of the positional parameters and the special parameter `#' are
992restored to the values they had prior to the function's execution. If
993a numeric argument is given to `return', that is the function's return
994status; otherwise the function's return status is the exit status of
995the last command executed before the `return'.
ccc6cda3
JA
996
997 Variables local to the function may be declared with the `local'
998builtin. These variables are visible only to the function and the
999commands it invokes.
1000
d3a24ed2
CR
1001 Function names and definitions may be listed with the `-f' option to
1002the `declare' or `typeset' builtin commands (*note Bash Builtins::).
1003The `-F' option to `declare' or `typeset' will list the function names
1004only (and optionally the source file and line number, if the `extdebug'
1005shell option is enabled). Functions may be exported so that subshells
1006automatically have them defined with the `-f' option to the `export'
1007builtin (*note Bourne Shell Builtins::). Note that shell functions and
1008variables with the same name may result in multiple identically-named
1009entries in the environment passed to the shell's children. Care should
1010be taken in cases where this may cause a problem.
1011
ccc6cda3
JA
1012 Functions may be recursive. No limit is placed on the number of
1013recursive calls.
1014
1015\1f
1016File: bashref.info, Node: Shell Parameters, Next: Shell Expansions, Prev: Shell Functions, Up: Basic Shell Features
1017
37c41ab1
CR
10183.4 Shell Parameters
1019====================
ccc6cda3
JA
1020
1021* Menu:
1022
1023* Positional Parameters:: The shell's command-line arguments.
d3a24ed2 1024* Special Parameters:: Parameters denoted by special characters.
ccc6cda3
JA
1025
1026 A PARAMETER is an entity that stores values. It can be a `name', a
d3a24ed2
CR
1027number, or one of the special characters listed below. A VARIABLE is a
1028parameter denoted by a `name'. A variable has a VALUE and zero or more
1029ATTRIBUTES. Attributes are assigned using the `declare' builtin command
1030(see the description of the `declare' builtin in *Note Bash Builtins::).
ccc6cda3
JA
1031
1032 A parameter is set if it has been assigned a value. The null string
1033is a valid value. Once a variable is set, it may be unset only by using
1034the `unset' builtin command.
1035
1036 A variable may be assigned to by a statement of the form
1037 NAME=[VALUE]
37c41ab1 1038 If VALUE is not given, the variable is assigned the null string. All
ccc6cda3
JA
1039VALUEs undergo tilde expansion, parameter and variable expansion,
1040command substitution, arithmetic expansion, and quote removal (detailed
f73dda09 1041below). If the variable has its `integer' attribute set, then VALUE is
d3a24ed2
CR
1042evaluated as an arithmetic expression even if the `$((...))' expansion
1043is not used (*note Arithmetic Expansion::). Word splitting is not
1044performed, with the exception of `"$@"' as explained below. Filename
1045expansion is not performed. Assignment statements may also appear as
5e13499c
CR
1046arguments to the `alias', `declare', `typeset', `export', `readonly',
1047and `local' builtin commands.
ccc6cda3
JA
1048
1049\1f
1050File: bashref.info, Node: Positional Parameters, Next: Special Parameters, Up: Shell Parameters
1051
37c41ab1
CR
10523.4.1 Positional Parameters
1053---------------------------
ccc6cda3 1054
37c41ab1 1055A POSITIONAL PARAMETER is a parameter denoted by one or more digits,
ccc6cda3
JA
1056other than the single digit `0'. Positional parameters are assigned
1057from the shell's arguments when it is invoked, and may be reassigned
cce855bc 1058using the `set' builtin command. Positional parameter `N' may be
bb70624e
JA
1059referenced as `${N}', or as `$N' when `N' consists of a single digit.
1060Positional parameters may not be assigned to with assignment statements.
1061The `set' and `shift' builtins are used to set and unset them (*note
28ef6c31
JA
1062Shell Builtin Commands::). The positional parameters are temporarily
1063replaced when a shell function is executed (*note Shell Functions::).
ccc6cda3
JA
1064
1065 When a positional parameter consisting of more than a single digit
1066is expanded, it must be enclosed in braces.
1067
1068\1f
1069File: bashref.info, Node: Special Parameters, Prev: Positional Parameters, Up: Shell Parameters
1070
37c41ab1
CR
10713.4.2 Special Parameters
1072------------------------
ccc6cda3 1073
37c41ab1 1074The shell treats several parameters specially. These parameters may
ccc6cda3
JA
1075only be referenced; assignment to them is not allowed.
1076
1077`*'
1078 Expands to the positional parameters, starting from one. When the
1079 expansion occurs within double quotes, it expands to a single word
1080 with the value of each parameter separated by the first character
1081 of the `IFS' special variable. That is, `"$*"' is equivalent to
1082 `"$1C$2C..."', where C is the first character of the value of the
d166f048
JA
1083 `IFS' variable. If `IFS' is unset, the parameters are separated
1084 by spaces. If `IFS' is null, the parameters are joined without
1085 intervening separators.
ccc6cda3
JA
1086
1087`@'
1088 Expands to the positional parameters, starting from one. When the
cce855bc 1089 expansion occurs within double quotes, each parameter expands to a
ccc6cda3 1090 separate word. That is, `"$@"' is equivalent to `"$1" "$2" ...'.
37c41ab1
CR
1091 If the double-quoted expansion occurs within a word, the expansion
1092 of the first parameter is joined with the beginning part of the
1093 original word, and the expansion of the last parameter is joined
1094 with the last part of the original word. When there are no
1095 positional parameters, `"$@"' and `$@' expand to nothing (i.e.,
1096 they are removed).
ccc6cda3
JA
1097
1098`#'
1099 Expands to the number of positional parameters in decimal.
1100
1101`?'
1102 Expands to the exit status of the most recently executed foreground
1103 pipeline.
1104
1105`-'
bb70624e
JA
1106 (A hyphen.) Expands to the current option flags as specified upon
1107 invocation, by the `set' builtin command, or those set by the
1108 shell itself (such as the `-i' option).
ccc6cda3
JA
1109
1110`$'
1111 Expands to the process ID of the shell. In a `()' subshell, it
cce855bc 1112 expands to the process ID of the invoking shell, not the subshell.
ccc6cda3
JA
1113
1114`!'
1115 Expands to the process ID of the most recently executed background
1116 (asynchronous) command.
1117
1118`0'
1119 Expands to the name of the shell or shell script. This is set at
cce855bc 1120 shell initialization. If Bash is invoked with a file of commands
28ef6c31
JA
1121 (*note Shell Scripts::), `$0' is set to the name of that file. If
1122 Bash is started with the `-c' option (*note Invoking Bash::), then
1123 `$0' is set to the first argument after the string to be executed,
1124 if one is present. Otherwise, it is set to the filename used to
1125 invoke Bash, as given by argument zero.
ccc6cda3
JA
1126
1127`_'
bb70624e
JA
1128 (An underscore.) At shell startup, set to the absolute filename
1129 of the shell or shell script being executed as passed in the
1130 argument list. Subsequently, expands to the last argument to the
1131 previous command, after expansion. Also set to the full pathname
1132 of each command executed and placed in the environment exported to
1133 that command. When checking mail, this parameter holds the name
1134 of the mail file.
ccc6cda3
JA
1135
1136\1f
1137File: bashref.info, Node: Shell Expansions, Next: Redirections, Prev: Shell Parameters, Up: Basic Shell Features
1138
37c41ab1
CR
11393.5 Shell Expansions
1140====================
ccc6cda3 1141
37c41ab1
CR
1142Expansion is performed on the command line after it has been split into
1143`token's. There are seven kinds of expansion performed:
ccc6cda3
JA
1144 * brace expansion
1145
1146 * tilde expansion
1147
1148 * parameter and variable expansion
1149
1150 * command substitution
1151
1152 * arithmetic expansion
1153
1154 * word splitting
1155
1156 * filename expansion
1157
1158* Menu:
1159
cce855bc
JA
1160* Brace Expansion:: Expansion of expressions within braces.
1161* Tilde Expansion:: Expansion of the ~ character.
ccc6cda3
JA
1162* Shell Parameter Expansion:: How Bash expands variables to their values.
1163* Command Substitution:: Using the output of a command as an argument.
cce855bc 1164* Arithmetic Expansion:: How to use arithmetic in shell expansions.
ccc6cda3
JA
1165* Process Substitution:: A way to write and read to and from a
1166 command.
1167* Word Splitting:: How the results of expansion are split into separate
1168 arguments.
1169* Filename Expansion:: A shorthand for specifying filenames matching patterns.
1170* Quote Removal:: How and when quote characters are removed from
1171 words.
1172
ccc6cda3
JA
1173 The order of expansions is: brace expansion, tilde expansion,
1174parameter, variable, and arithmetic expansion and command substitution
1175(done in a left-to-right fashion), word splitting, and filename
1176expansion.
1177
1178 On systems that can support it, there is an additional expansion
1179available: PROCESS SUBSTITUTION. This is performed at the same time as
cce855bc 1180parameter, variable, and arithmetic expansion and command substitution.
ccc6cda3
JA
1181
1182 Only brace expansion, word splitting, and filename expansion can
1183change the number of words of the expansion; other expansions expand a
1184single word to a single word. The only exceptions to this are the
28ef6c31
JA
1185expansions of `"$@"' (*note Special Parameters::) and `"${NAME[@]}"'
1186(*note Arrays::).
ccc6cda3 1187
28ef6c31 1188 After all expansions, `quote removal' (*note Quote Removal::) is
ccc6cda3
JA
1189performed.
1190
1191\1f
cce855bc
JA
1192File: bashref.info, Node: Brace Expansion, Next: Tilde Expansion, Up: Shell Expansions
1193
37c41ab1
CR
11943.5.1 Brace Expansion
1195---------------------
cce855bc 1196
37c41ab1 1197Brace expansion is a mechanism by which arbitrary strings may be
cce855bc 1198generated. This mechanism is similar to FILENAME EXPANSION (*note
28ef6c31 1199Filename Expansion::), but the file names generated need not exist.
cce855bc 1200Patterns to be brace expanded take the form of an optional PREAMBLE,
d3a24ed2
CR
1201followed by either a series of comma-separated strings or a sequnce
1202expression between a pair of braces, followed by an optional POSTSCRIPT.
1203The preamble is prefixed to each string contained within the braces, and
1204the postscript is then appended to each resulting string, expanding left
1205to right.
cce855bc
JA
1206
1207 Brace expansions may be nested. The results of each expanded string
1208are not sorted; left to right order is preserved. For example,
1209 bash$ echo a{d,c,b}e
1210 ade ace abe
1211
d3a24ed2
CR
1212 A sequence expression takes the form `{X..Y}', where X and Y are
1213either integers or single characters. When integers are supplied, the
1214expression expands to each number between X and Y, inclusive. When
1215characters are supplied, the expression expands to each character
1216lexicographically between X and Y, inclusive. Note that both X and Y
1217must be of the same type.
1218
cce855bc
JA
1219 Brace expansion is performed before any other expansions, and any
1220characters special to other expansions are preserved in the result. It
1221is strictly textual. Bash does not apply any syntactic interpretation
bb70624e
JA
1222to the context of the expansion or the text between the braces. To
1223avoid conflicts with parameter expansion, the string `${' is not
1224considered eligible for brace expansion.
cce855bc
JA
1225
1226 A correctly-formed brace expansion must contain unquoted opening and
d3a24ed2
CR
1227closing braces, and at least one unquoted comma or a valid sequence
1228expression. Any incorrectly formed brace expansion is left unchanged.
1229
1230 A { or `,' may be quoted with a backslash to prevent its being
1231considered part of a brace expression. To avoid conflicts with
1232parameter expansion, the string `${' is not considered eligible for
1233brace expansion.
cce855bc
JA
1234
1235 This construct is typically used as shorthand when the common prefix
1236of the strings to be generated is longer than in the above example:
1237 mkdir /usr/local/src/bash/{old,new,dist,bugs}
1238 or
1239 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
1240
1241\1f
1242File: bashref.info, Node: Tilde Expansion, Next: Shell Parameter Expansion, Prev: Brace Expansion, Up: Shell Expansions
1243
37c41ab1
CR
12443.5.2 Tilde Expansion
1245---------------------
cce855bc 1246
37c41ab1 1247If a word begins with an unquoted tilde character (`~'), all of the
cce855bc
JA
1248characters up to the first unquoted slash (or all characters, if there
1249is no unquoted slash) are considered a TILDE-PREFIX. If none of the
1250characters in the tilde-prefix are quoted, the characters in the
1251tilde-prefix following the tilde are treated as a possible LOGIN NAME.
1252If this login name is the null string, the tilde is replaced with the
1253value of the `HOME' shell variable. If `HOME' is unset, the home
1254directory of the user executing the shell is substituted instead.
1255Otherwise, the tilde-prefix is replaced with the home directory
1256associated with the specified login name.
1257
1258 If the tilde-prefix is `~+', the value of the shell variable `PWD'
1259replaces the tilde-prefix. If the tilde-prefix is `~-', the value of
1260the shell variable `OLDPWD', if it is set, is substituted.
1261
1262 If the characters following the tilde in the tilde-prefix consist of
1263a number N, optionally prefixed by a `+' or a `-', the tilde-prefix is
1264replaced with the corresponding element from the directory stack, as it
1265would be displayed by the `dirs' builtin invoked with the characters
1266following tilde in the tilde-prefix as an argument (*note The Directory
28ef6c31 1267Stack::). If the tilde-prefix, sans the tilde, consists of a number
cce855bc
JA
1268without a leading `+' or `-', `+' is assumed.
1269
1270 If the login name is invalid, or the tilde expansion fails, the word
1271is left unchanged.
1272
1273 Each variable assignment is checked for unquoted tilde-prefixes
1274immediately following a `:' or `='. In these cases, tilde expansion is
1275also performed. Consequently, one may use file names with tildes in
1276assignments to `PATH', `MAILPATH', and `CDPATH', and the shell assigns
1277the expanded value.
1278
1279 The following table shows how Bash treats unquoted tilde-prefixes:
1280
1281`~'
1282 The value of `$HOME'
1283
1284`~/foo'
1285 `$HOME/foo'
1286
1287`~fred/foo'
1288 The subdirectory `foo' of the home directory of the user `fred'
1289
1290`~+/foo'
1291 `$PWD/foo'
1292
1293`~-/foo'
1294 `${OLDPWD-'~-'}/foo'
1295
1296`~N'
1297 The string that would be displayed by `dirs +N'
1298
1299`~+N'
1300 The string that would be displayed by `dirs +N'
1301
1302`~-N'
1303 The string that would be displayed by `dirs -N'
1304
761783bf 1305
cce855bc
JA
1306\1f
1307File: bashref.info, Node: Shell Parameter Expansion, Next: Command Substitution, Prev: Tilde Expansion, Up: Shell Expansions
ccc6cda3 1308
37c41ab1
CR
13093.5.3 Shell Parameter Expansion
1310-------------------------------
ccc6cda3 1311
37c41ab1
CR
1312The `$' character introduces parameter expansion, command substitution,
1313or arithmetic expansion. The parameter name or symbol to be expanded
1314may be enclosed in braces, which are optional but serve to protect the
1315variable to be expanded from characters immediately following it which
1316could be interpreted as part of the name.
ccc6cda3 1317
cce855bc
JA
1318 When braces are used, the matching ending brace is the first `}' not
1319escaped by a backslash or within a quoted string, and not within an
1320embedded arithmetic expansion, command substitution, or parameter
1321expansion.
1322
ccc6cda3
JA
1323 The basic form of parameter expansion is ${PARAMETER}. The value of
1324PARAMETER is substituted. The braces are required when PARAMETER is a
1325positional parameter with more than one digit, or when PARAMETER is
1326followed by a character that is not to be interpreted as part of its
1327name.
1328
1329 If the first character of PARAMETER is an exclamation point, a level
1330of variable indirection is introduced. Bash uses the value of the
1331variable formed from the rest of PARAMETER as the name of the variable;
d166f048
JA
1332this variable is then expanded and that value is used in the rest of
1333the substitution, rather than the value of PARAMETER itself. This is
d3a24ed2
CR
1334known as `indirect expansion'. The exceptions to this are the
1335expansions of ${!PREFIX*} and ${!NAME[@]} described below. The
1336exclamation point must immediately follow the left brace in order to
1337introduce indirection.
ccc6cda3
JA
1338
1339 In each of the cases below, WORD is subject to tilde expansion,
1340parameter expansion, command substitution, and arithmetic expansion.
bb70624e
JA
1341
1342 When not performing substring expansion, Bash tests for a parameter
ccc6cda3 1343that is unset or null; omitting the colon results in a test only for a
bb70624e
JA
1344parameter that is unset. Put another way, if the colon is included,
1345the operator tests for both existence and that the value is not null;
1346if the colon is omitted, the operator tests only for existence.
ccc6cda3
JA
1347
1348`${PARAMETER:-WORD}'
1349 If PARAMETER is unset or null, the expansion of WORD is
1350 substituted. Otherwise, the value of PARAMETER is substituted.
1351
1352`${PARAMETER:=WORD}'
1353 If PARAMETER is unset or null, the expansion of WORD is assigned
1354 to PARAMETER. The value of PARAMETER is then substituted.
de8913bd
CR
1355 Positional parameters and special parameters may not be assigned to
1356 in this way.
ccc6cda3
JA
1357
1358`${PARAMETER:?WORD}'
1359 If PARAMETER is null or unset, the expansion of WORD (or a message
1360 to that effect if WORD is not present) is written to the standard
1361 error and the shell, if it is not interactive, exits. Otherwise,
1362 the value of PARAMETER is substituted.
1363
1364`${PARAMETER:+WORD}'
1365 If PARAMETER is null or unset, nothing is substituted, otherwise
1366 the expansion of WORD is substituted.
1367
1368`${PARAMETER:OFFSET}'
1369`${PARAMETER:OFFSET:LENGTH}'
bb70624e 1370 Expands to up to LENGTH characters of PARAMETER starting at the
cce855bc 1371 character specified by OFFSET. If LENGTH is omitted, expands to
bb70624e 1372 the substring of PARAMETER starting at the character specified by
cce855bc 1373 OFFSET. LENGTH and OFFSET are arithmetic expressions (*note Shell
28ef6c31 1374 Arithmetic::). This is referred to as Substring Expansion.
ccc6cda3
JA
1375
1376 LENGTH must evaluate to a number greater than or equal to zero.
1377 If OFFSET evaluates to a number less than zero, the value is used
1378 as an offset from the end of the value of PARAMETER. If PARAMETER
1379 is `@', the result is LENGTH positional parameters beginning at
1380 OFFSET. If PARAMETER is an array name indexed by `@' or `*', the
1381 result is the LENGTH members of the array beginning with
cce855bc
JA
1382 `${PARAMETER[OFFSET]}'. Substring indexing is zero-based unless
1383 the positional parameters are used, in which case the indexing
1384 starts at 1.
ccc6cda3 1385
bb70624e 1386`${!PREFIX*}'
d3a24ed2 1387`${!PREFIX@}'
bb70624e
JA
1388 Expands to the names of variables whose names begin with PREFIX,
1389 separated by the first character of the `IFS' special variable.
1390
d3a24ed2
CR
1391`${!NAME[@]}'
1392`${!NAME[*]}'
1393 If NAME is an array variable, expands to the list of array indices
1394 (keys) assigned in NAME. If NAME is not an array, expands to 0 if
1395 NAME is set and null otherwise. When `@' is used and the
1396 expansion appears within double quotes, each key expands to a
1397 separate word.
1398
ccc6cda3 1399`${#PARAMETER}'
cce855bc
JA
1400 The length in characters of the expanded value of PARAMETER is
1401 substituted. If PARAMETER is `*' or `@', the value substituted is
1402 the number of positional parameters. If PARAMETER is an array
1403 name subscripted by `*' or `@', the value substituted is the
1404 number of elements in the array.
ccc6cda3
JA
1405
1406`${PARAMETER#WORD}'
1407`${PARAMETER##WORD}'
1408 The WORD is expanded to produce a pattern just as in filename
28ef6c31 1409 expansion (*note Filename Expansion::). If the pattern matches
cce855bc
JA
1410 the beginning of the expanded value of PARAMETER, then the result
1411 of the expansion is the expanded value of PARAMETER with the
1412 shortest matching pattern (the `#' case) or the longest matching
1413 pattern (the `##' case) deleted. If PARAMETER is `@' or `*', the
1414 pattern removal operation is applied to each positional parameter
1415 in turn, and the expansion is the resultant list. If PARAMETER is
1416 an array variable subscripted with `@' or `*', the pattern removal
1417 operation is applied to each member of the array in turn, and the
1418 expansion is the resultant list.
ccc6cda3
JA
1419
1420`${PARAMETER%WORD}'
1421`${PARAMETER%%WORD}'
1422 The WORD is expanded to produce a pattern just as in filename
cce855bc
JA
1423 expansion. If the pattern matches a trailing portion of the
1424 expanded value of PARAMETER, then the result of the expansion is
1425 the value of PARAMETER with the shortest matching pattern (the `%'
1426 case) or the longest matching pattern (the `%%' case) deleted. If
1427 PARAMETER is `@' or `*', the pattern removal operation is applied
1428 to each positional parameter in turn, and the expansion is the
1429 resultant list. If PARAMETER is an array variable subscripted
1430 with `@' or `*', the pattern removal operation is applied to each
1431 member of the array in turn, and the expansion is the resultant
1432 list.
ccc6cda3
JA
1433
1434`${PARAMETER/PATTERN/STRING}'
1435`${PARAMETER//PATTERN/STRING}'
1436 The PATTERN is expanded to produce a pattern just as in filename
1437 expansion. PARAMETER is expanded and the longest match of PATTERN
1438 against its value is replaced with STRING. In the first form,
1439 only the first match is replaced. The second form causes all
1440 matches of PATTERN to be replaced with STRING. If PATTERN begins
b72432fd
JA
1441 with `#', it must match at the beginning of the expanded value of
1442 PARAMETER. If PATTERN begins with `%', it must match at the end
1443 of the expanded value of PARAMETER. If STRING is null, matches of
1444 PATTERN are deleted and the `/' following PATTERN may be omitted.
1445 If PARAMETER is `@' or `*', the substitution operation is applied
1446 to each positional parameter in turn, and the expansion is the
1447 resultant list. If PARAMETER is an array variable subscripted
1448 with `@' or `*', the substitution operation is applied to each
1449 member of the array in turn, and the expansion is the resultant
1450 list.
ccc6cda3 1451
761783bf 1452
ccc6cda3 1453\1f
cce855bc 1454File: bashref.info, Node: Command Substitution, Next: Arithmetic Expansion, Prev: Shell Parameter Expansion, Up: Shell Expansions
ccc6cda3 1455
37c41ab1
CR
14563.5.4 Command Substitution
1457--------------------------
ccc6cda3 1458
37c41ab1 1459Command substitution allows the output of a command to replace the
bb70624e
JA
1460command itself. Command substitution occurs when a command is enclosed
1461as follows:
ccc6cda3 1462 $(COMMAND)
37c41ab1 1463 or
ccc6cda3
JA
1464 `COMMAND`
1465
1466Bash performs the expansion by executing COMMAND and replacing the
1467command substitution with the standard output of the command, with any
cce855bc
JA
1468trailing newlines deleted. Embedded newlines are not deleted, but they
1469may be removed during word splitting. The command substitution `$(cat
1470FILE)' can be replaced by the equivalent but faster `$(< FILE)'.
ccc6cda3
JA
1471
1472 When the old-style backquote form of substitution is used, backslash
1473retains its literal meaning except when followed by `$', ``', or `\'.
cce855bc
JA
1474The first backquote not preceded by a backslash terminates the command
1475substitution. When using the `$(COMMAND)' form, all characters between
1476the parentheses make up the command; none are treated specially.
ccc6cda3 1477
cce855bc
JA
1478 Command substitutions may be nested. To nest when using the
1479backquoted form, escape the inner backquotes with backslashes.
ccc6cda3
JA
1480
1481 If the substitution appears within double quotes, word splitting and
1482filename expansion are not performed on the results.
1483
1484\1f
cce855bc
JA
1485File: bashref.info, Node: Arithmetic Expansion, Next: Process Substitution, Prev: Command Substitution, Up: Shell Expansions
1486
37c41ab1
CR
14873.5.5 Arithmetic Expansion
1488--------------------------
cce855bc 1489
37c41ab1
CR
1490Arithmetic expansion allows the evaluation of an arithmetic expression
1491and the substitution of the result. The format for arithmetic
1492expansion is:
cce855bc
JA
1493
1494 $(( EXPRESSION ))
1495
1496 The expression is treated as if it were within double quotes, but a
1497double quote inside the parentheses is not treated specially. All
1498tokens in the expression undergo parameter expansion, command
d3a24ed2 1499substitution, and quote removal. Arithmetic expansions may be nested.
cce855bc
JA
1500
1501 The evaluation is performed according to the rules listed below
28ef6c31 1502(*note Shell Arithmetic::). If the expression is invalid, Bash prints
cce855bc
JA
1503a message indicating failure to the standard error and no substitution
1504occurs.
1505
1506\1f
1507File: bashref.info, Node: Process Substitution, Next: Word Splitting, Prev: Arithmetic Expansion, Up: Shell Expansions
ccc6cda3 1508
37c41ab1
CR
15093.5.6 Process Substitution
1510--------------------------
ccc6cda3 1511
37c41ab1
CR
1512Process substitution is supported on systems that support named pipes
1513(FIFOs) or the `/dev/fd' method of naming open files. It takes the
1514form of
ccc6cda3 1515 <(LIST)
37c41ab1 1516 or
ccc6cda3 1517 >(LIST)
37c41ab1
CR
1518 The process LIST is run with its input or output connected to a FIFO
1519or some file in `/dev/fd'. The name of this file is passed as an
1520argument to the current command as the result of the expansion. If the
ccc6cda3
JA
1521`>(LIST)' form is used, writing to the file will provide input for
1522LIST. If the `<(LIST)' form is used, the file passed as an argument
bb70624e
JA
1523should be read to obtain the output of LIST. Note that no space may
1524appear between the `<' or `>' and the left parenthesis, otherwise the
1525construct would be interpreted as a redirection.
ccc6cda3 1526
cce855bc
JA
1527 When available, process substitution is performed simultaneously with
1528parameter and variable expansion, command substitution, and arithmetic
1529expansion.
ccc6cda3
JA
1530
1531\1f
1532File: bashref.info, Node: Word Splitting, Next: Filename Expansion, Prev: Process Substitution, Up: Shell Expansions
1533
37c41ab1
CR
15343.5.7 Word Splitting
1535--------------------
ccc6cda3 1536
37c41ab1 1537The shell scans the results of parameter expansion, command
ccc6cda3
JA
1538substitution, and arithmetic expansion that did not occur within double
1539quotes for word splitting.
1540
1541 The shell treats each character of `$IFS' as a delimiter, and splits
1542the results of the other expansions into words on these characters. If
1543`IFS' is unset, or its value is exactly `<space><tab><newline>', the
1544default, then any sequence of `IFS' characters serves to delimit words.
1545If `IFS' has a value other than the default, then sequences of the
1546whitespace characters `space' and `tab' are ignored at the beginning
1547and end of the word, as long as the whitespace character is in the
1548value of `IFS' (an `IFS' whitespace character). Any character in `IFS'
1549that is not `IFS' whitespace, along with any adjacent `IFS' whitespace
1550characters, delimits a field. A sequence of `IFS' whitespace
1551characters is also treated as a delimiter. If the value of `IFS' is
1552null, no word splitting occurs.
1553
1554 Explicit null arguments (`""' or `''') are retained. Unquoted
bb70624e 1555implicit null arguments, resulting from the expansion of parameters
ccc6cda3
JA
1556that have no values, are removed. If a parameter with no value is
1557expanded within double quotes, a null argument results and is retained.
1558
1559 Note that if no expansion occurs, no splitting is performed.
1560
1561\1f
1562File: bashref.info, Node: Filename Expansion, Next: Quote Removal, Prev: Word Splitting, Up: Shell Expansions
1563
37c41ab1
CR
15643.5.8 Filename Expansion
1565------------------------
ccc6cda3 1566
cce855bc
JA
1567* Menu:
1568
1569* Pattern Matching:: How the shell matches patterns.
1570
ccc6cda3 1571 After word splitting, unless the `-f' option has been set (*note The
28ef6c31 1572Set Builtin::), Bash scans each word for the characters `*', `?', and
bb70624e
JA
1573`['. If one of these characters appears, then the word is regarded as
1574a PATTERN, and replaced with an alphabetically sorted list of file
ccc6cda3 1575names matching the pattern. If no matching file names are found, and
cce855bc
JA
1576the shell option `nullglob' is disabled, the word is left unchanged.
1577If the `nullglob' option is set, and no matches are found, the word is
5e13499c
CR
1578removed. If the `failglob' shell option is set, and no matches are
1579found, an error message is printed and the command is not executed. If
1580the shell option `nocaseglob' is enabled, the match is performed
1581without regard to the case of alphabetic characters.
cce855bc 1582
28ef6c31
JA
1583 When a pattern is used for filename generation, the character `.' at
1584the start of a filename or immediately following a slash must be
cce855bc
JA
1585matched explicitly, unless the shell option `dotglob' is set. When
1586matching a file name, the slash character must always be matched
1587explicitly. In other cases, the `.' character is not treated specially.
1588
1589 See the description of `shopt' in *Note Bash Builtins::, for a
5e13499c
CR
1590description of the `nocaseglob', `nullglob', `failglob', and `dotglob'
1591options.
ccc6cda3
JA
1592
1593 The `GLOBIGNORE' shell variable may be used to restrict the set of
cce855bc 1594filenames matching a pattern. If `GLOBIGNORE' is set, each matching
ccc6cda3 1595filename that also matches one of the patterns in `GLOBIGNORE' is
28ef6c31 1596removed from the list of matches. The filenames `.' and `..' are
d3a24ed2
CR
1597always ignored when `GLOBIGNORE' is set and not null. However, setting
1598`GLOBIGNORE' to a non-null value has the effect of enabling the
1599`dotglob' shell option, so all other filenames beginning with a `.'
1600will match. To get the old behavior of ignoring filenames beginning
1601with a `.', make `.*' one of the patterns in `GLOBIGNORE'. The
1602`dotglob' option is disabled when `GLOBIGNORE' is unset.
ccc6cda3 1603
cce855bc
JA
1604\1f
1605File: bashref.info, Node: Pattern Matching, Up: Filename Expansion
1606
37c41ab1
CR
16073.5.8.1 Pattern Matching
1608........................
cce855bc 1609
37c41ab1
CR
1610Any character that appears in a pattern, other than the special pattern
1611characters described below, matches itself. The NUL character may not
1612occur in a pattern. A backslash escapes the following character; the
1613escaping backslash is discarded when matching. The special pattern
1614characters must be quoted if they are to be matched literally.
cce855bc 1615
ccc6cda3
JA
1616 The special pattern characters have the following meanings:
1617`*'
1618 Matches any string, including the null string.
1619
1620`?'
1621 Matches any single character.
1622
1623`[...]'
1624 Matches any one of the enclosed characters. A pair of characters
28ef6c31
JA
1625 separated by a hyphen denotes a RANGE EXPRESSION; any character
1626 that sorts between those two characters, inclusive, using the
1627 current locale's collating sequence and character set, is matched.
1628 If the first character following the `[' is a `!' or a `^' then
1629 any character not enclosed is matched. A `-' may be matched by
1630 including it as the first or last character in the set. A `]' may
1631 be matched by including it as the first character in the set. The
1632 sorting order of characters in range expressions is determined by
1633 the current locale and the value of the `LC_COLLATE' shell
1634 variable, if set.
1635
1636 For example, in the default C locale, `[a-dx-z]' is equivalent to
1637 `[abcdxyz]'. Many locales sort characters in dictionary order,
1638 and in these locales `[a-dx-z]' is typically not equivalent to
1639 `[abcdxyz]'; it might be equivalent to `[aBbCcDdxXyYz]', for
1640 example. To obtain the traditional interpretation of ranges in
1641 bracket expressions, you can force the use of the C locale by
1642 setting the `LC_COLLATE' or `LC_ALL' environment variable to the
1643 value `C'.
ccc6cda3 1644
cce855bc
JA
1645 Within `[' and `]', CHARACTER CLASSES can be specified using the
1646 syntax `[:'CLASS`:]', where CLASS is one of the following classes
bb70624e 1647 defined in the POSIX 1003.2 standard:
cce855bc 1648 alnum alpha ascii blank cntrl digit graph lower
7117c2d2 1649 print punct space upper word xdigit
cce855bc 1650 A character class matches any character belonging to that class.
7117c2d2
JA
1651 The `word' character class matches letters, digits, and the
1652 character `_'.
cce855bc
JA
1653
1654 Within `[' and `]', an EQUIVALENCE CLASS can be specified using
1655 the syntax `[='C`=]', which matches all characters with the same
1656 collation weight (as defined by the current locale) as the
1657 character C.
1658
28ef6c31 1659 Within `[' and `]', the syntax `[.'SYMBOL`.]' matches the
cce855bc
JA
1660 collating symbol SYMBOL.
1661
1662 If the `extglob' shell option is enabled using the `shopt' builtin,
1663several extended pattern matching operators are recognized. In the
1664following description, a PATTERN-LIST is a list of one or more patterns
1665separated by a `|'. Composite patterns may be formed using one or more
1666of the following sub-patterns:
1667
1668`?(PATTERN-LIST)'
1669 Matches zero or one occurrence of the given patterns.
1670
1671`*(PATTERN-LIST)'
1672 Matches zero or more occurrences of the given patterns.
1673
1674`+(PATTERN-LIST)'
1675 Matches one or more occurrences of the given patterns.
1676
1677`@(PATTERN-LIST)'
1678 Matches exactly one of the given patterns.
1679
1680`!(PATTERN-LIST)'
1681 Matches anything except one of the given patterns.
1682
ccc6cda3
JA
1683\1f
1684File: bashref.info, Node: Quote Removal, Prev: Filename Expansion, Up: Shell Expansions
1685
37c41ab1
CR
16863.5.9 Quote Removal
1687-------------------
ccc6cda3 1688
37c41ab1 1689After the preceding expansions, all unquoted occurrences of the
ccc6cda3
JA
1690characters `\', `'', and `"' that did not result from one of the above
1691expansions are removed.
1692
1693\1f
1694File: bashref.info, Node: Redirections, Next: Executing Commands, Prev: Shell Expansions, Up: Basic Shell Features
1695
37c41ab1
CR
16963.6 Redirections
1697================
ccc6cda3 1698
37c41ab1 1699Before a command is executed, its input and output may be REDIRECTED
ccc6cda3
JA
1700using a special notation interpreted by the shell. Redirection may
1701also be used to open and close files for the current shell execution
1702environment. The following redirection operators may precede or appear
1703anywhere within a simple command or may follow a command. Redirections
1704are processed in the order they appear, from left to right.
1705
1706 In the following descriptions, if the file descriptor number is
1707omitted, and the first character of the redirection operator is `<',
1708the redirection refers to the standard input (file descriptor 0). If
1709the first character of the redirection operator is `>', the redirection
1710refers to the standard output (file descriptor 1).
1711
cce855bc
JA
1712 The word following the redirection operator in the following
1713descriptions, unless otherwise noted, is subjected to brace expansion,
1714tilde expansion, parameter expansion, command substitution, arithmetic
bb70624e
JA
1715expansion, quote removal, filename expansion, and word splitting. If
1716it expands to more than one word, Bash reports an error.
ccc6cda3
JA
1717
1718 Note that the order of redirections is significant. For example,
1719the command
1720 ls > DIRLIST 2>&1
37c41ab1 1721 directs both standard output (file descriptor 1) and standard error
bb70624e 1722(file descriptor 2) to the file DIRLIST, while the command
ccc6cda3 1723 ls 2>&1 > DIRLIST
37c41ab1
CR
1724 directs only the standard output to file DIRLIST, because the
1725standard error was duplicated as standard output before the standard
1726output was redirected to DIRLIST.
ccc6cda3 1727
bb70624e
JA
1728 Bash handles several filenames specially when they are used in
1729redirections, as described in the following table:
1730
1731`/dev/fd/FD'
1732 If FD is a valid integer, file descriptor FD is duplicated.
1733
1734`/dev/stdin'
1735 File descriptor 0 is duplicated.
1736
1737`/dev/stdout'
1738 File descriptor 1 is duplicated.
1739
1740`/dev/stderr'
1741 File descriptor 2 is duplicated.
1742
1743`/dev/tcp/HOST/PORT'
1744 If HOST is a valid hostname or Internet address, and PORT is an
f73dda09
JA
1745 integer port number or service name, Bash attempts to open a TCP
1746 connection to the corresponding socket.
bb70624e
JA
1747
1748`/dev/udp/HOST/PORT'
1749 If HOST is a valid hostname or Internet address, and PORT is an
f73dda09
JA
1750 integer port number or service name, Bash attempts to open a UDP
1751 connection to the corresponding socket.
bb70624e 1752
761783bf 1753
cce855bc
JA
1754 A failure to open or create a file causes the redirection to fail.
1755
37c41ab1
CR
17563.6.1 Redirecting Input
1757-----------------------
ccc6cda3 1758
37c41ab1 1759Redirection of input causes the file whose name results from the
ccc6cda3
JA
1760expansion of WORD to be opened for reading on file descriptor `n', or
1761the standard input (file descriptor 0) if `n' is not specified.
1762
1763 The general format for redirecting input is:
7117c2d2 1764 [N]<WORD
ccc6cda3 1765
37c41ab1
CR
17663.6.2 Redirecting Output
1767------------------------
ccc6cda3 1768
37c41ab1 1769Redirection of output causes the file whose name results from the
7117c2d2
JA
1770expansion of WORD to be opened for writing on file descriptor N, or the
1771standard output (file descriptor 1) if N is not specified. If the file
1772does not exist it is created; if it does exist it is truncated to zero
1773size.
ccc6cda3
JA
1774
1775 The general format for redirecting output is:
7117c2d2 1776 [N]>[|]WORD
ccc6cda3 1777
cce855bc
JA
1778 If the redirection operator is `>', and the `noclobber' option to
1779the `set' builtin has been enabled, the redirection will fail if the
bb70624e 1780file whose name results from the expansion of WORD exists and is a
cce855bc
JA
1781regular file. If the redirection operator is `>|', or the redirection
1782operator is `>' and the `noclobber' option is not enabled, the
1783redirection is attempted even if the file named by WORD exists.
ccc6cda3 1784
37c41ab1
CR
17853.6.3 Appending Redirected Output
1786---------------------------------
ccc6cda3 1787
37c41ab1 1788Redirection of output in this fashion causes the file whose name
ccc6cda3 1789results from the expansion of WORD to be opened for appending on file
7117c2d2
JA
1790descriptor N, or the standard output (file descriptor 1) if N is not
1791specified. If the file does not exist it is created.
ccc6cda3
JA
1792
1793 The general format for appending output is:
7117c2d2 1794 [N]>>WORD
ccc6cda3 1795
37c41ab1
CR
17963.6.4 Redirecting Standard Output and Standard Error
1797----------------------------------------------------
ccc6cda3 1798
37c41ab1 1799Bash allows both the standard output (file descriptor 1) and the
ccc6cda3
JA
1800standard error output (file descriptor 2) to be redirected to the file
1801whose name is the expansion of WORD with this construct.
1802
1803 There are two formats for redirecting standard output and standard
1804error:
1805 &>WORD
37c41ab1 1806 and
ccc6cda3 1807 >&WORD
37c41ab1 1808 Of the two forms, the first is preferred. This is semantically
ccc6cda3
JA
1809equivalent to
1810 >WORD 2>&1
1811
37c41ab1
CR
18123.6.5 Here Documents
1813--------------------
ccc6cda3 1814
37c41ab1 1815This type of redirection instructs the shell to read input from the
ccc6cda3
JA
1816current source until a line containing only WORD (with no trailing
1817blanks) is seen. All of the lines read up to that point are then used
1818as the standard input for a command.
1819
7117c2d2 1820 The format of here-documents is:
ccc6cda3
JA
1821 <<[-]WORD
1822 HERE-DOCUMENT
1823 DELIMITER
1824
bb70624e
JA
1825 No parameter expansion, command substitution, arithmetic expansion,
1826or filename expansion is performed on WORD. If any characters in WORD
ccc6cda3 1827are quoted, the DELIMITER is the result of quote removal on WORD, and
cce855bc
JA
1828the lines in the here-document are not expanded. If WORD is unquoted,
1829all lines of the here-document are subjected to parameter expansion,
1830command substitution, and arithmetic expansion. In the latter case,
bb70624e
JA
1831the character sequence `\newline' is ignored, and `\' must be used to
1832quote the characters `\', `$', and ``'.
ccc6cda3
JA
1833
1834 If the redirection operator is `<<-', then all leading tab
1835characters are stripped from input lines and the line containing
1836DELIMITER. This allows here-documents within shell scripts to be
1837indented in a natural fashion.
1838
37c41ab1
CR
18393.6.6 Here Strings
1840------------------
7117c2d2 1841
37c41ab1 1842A variant of here documents, the format is:
7117c2d2
JA
1843 <<< WORD
1844
1845 The WORD is expanded and supplied to the command on its standard
1846input.
1847
37c41ab1
CR
18483.6.7 Duplicating File Descriptors
1849----------------------------------
ccc6cda3 1850
37c41ab1 1851The redirection operator
7117c2d2 1852 [N]<&WORD
37c41ab1
CR
1853 is used to duplicate input file descriptors. If WORD expands to one
1854or more digits, the file descriptor denoted by N is made to be a copy
1855of that file descriptor. If the digits in WORD do not specify a file
cce855bc 1856descriptor open for input, a redirection error occurs. If WORD
7117c2d2
JA
1857evaluates to `-', file descriptor N is closed. If N is not specified,
1858the standard input (file descriptor 0) is used.
ccc6cda3
JA
1859
1860 The operator
7117c2d2 1861 [N]>&WORD
37c41ab1 1862 is used similarly to duplicate output file descriptors. If N is not
cce855bc
JA
1863specified, the standard output (file descriptor 1) is used. If the
1864digits in WORD do not specify a file descriptor open for output, a
7117c2d2
JA
1865redirection error occurs. As a special case, if N is omitted, and WORD
1866does not expand to one or more digits, the standard output and standard
1867error are redirected as described previously.
1868
37c41ab1
CR
18693.6.8 Moving File Descriptors
1870-----------------------------
7117c2d2 1871
37c41ab1 1872The redirection operator
7117c2d2 1873 [N]<&DIGIT-
37c41ab1
CR
1874 moves the file descriptor DIGIT to file descriptor N, or the
1875standard input (file descriptor 0) if N is not specified. DIGIT is
1876closed after being duplicated to N.
7117c2d2
JA
1877
1878 Similarly, the redirection operator
1879 [N]>&DIGIT-
37c41ab1
CR
1880 moves the file descriptor DIGIT to file descriptor N, or the
1881standard output (file descriptor 1) if N is not specified.
7117c2d2 1882
37c41ab1
CR
18833.6.9 Opening File Descriptors for Reading and Writing
1884------------------------------------------------------
ccc6cda3 1885
37c41ab1 1886The redirection operator
7117c2d2 1887 [N]<>WORD
37c41ab1 1888 causes the file whose name is the expansion of WORD to be opened for
7117c2d2
JA
1889both reading and writing on file descriptor N, or on file descriptor 0
1890if N is not specified. If the file does not exist, it is created.
ccc6cda3
JA
1891
1892\1f
1893File: bashref.info, Node: Executing Commands, Next: Shell Scripts, Prev: Redirections, Up: Basic Shell Features
1894
37c41ab1
CR
18953.7 Executing Commands
1896======================
ccc6cda3
JA
1897
1898* Menu:
1899
cce855bc
JA
1900* Simple Command Expansion:: How Bash expands simple commands before
1901 executing them.
1902
ccc6cda3
JA
1903* Command Search and Execution:: How Bash finds commands and runs them.
1904
cce855bc
JA
1905* Command Execution Environment:: The environment in which Bash
1906 executes commands that are not
1907 shell builtins.
1908
ccc6cda3
JA
1909* Environment:: The environment given to a command.
1910
1911* Exit Status:: The status returned by commands and how Bash
1912 interprets it.
1913
1914* Signals:: What happens when Bash or a command it runs
1915 receives a signal.
1916
1917\1f
cce855bc
JA
1918File: bashref.info, Node: Simple Command Expansion, Next: Command Search and Execution, Up: Executing Commands
1919
37c41ab1
CR
19203.7.1 Simple Command Expansion
1921------------------------------
cce855bc 1922
37c41ab1 1923When a simple command is executed, the shell performs the following
cce855bc
JA
1924expansions, assignments, and redirections, from left to right.
1925
1926 1. The words that the parser has marked as variable assignments (those
1927 preceding the command name) and redirections are saved for later
1928 processing.
1929
1930 2. The words that are not variable assignments or redirections are
28ef6c31 1931 expanded (*note Shell Expansions::). If any words remain after
cce855bc
JA
1932 expansion, the first word is taken to be the name of the command
1933 and the remaining words are the arguments.
1934
1935 3. Redirections are performed as described above (*note
28ef6c31 1936 Redirections::).
cce855bc
JA
1937
1938 4. The text after the `=' in each variable assignment undergoes tilde
1939 expansion, parameter expansion, command substitution, arithmetic
1940 expansion, and quote removal before being assigned to the variable.
1941
1942 If no command name results, the variable assignments affect the
1943current shell environment. Otherwise, the variables are added to the
1944environment of the executed command and do not affect the current shell
1945environment. If any of the assignments attempts to assign a value to a
1946readonly variable, an error occurs, and the command exits with a
1947non-zero status.
1948
1949 If no command name results, redirections are performed, but do not
1950affect the current shell environment. A redirection error causes the
1951command to exit with a non-zero status.
1952
1953 If there is a command name left after expansion, execution proceeds
1954as described below. Otherwise, the command exits. If one of the
1955expansions contained a command substitution, the exit status of the
1956command is the exit status of the last command substitution performed.
1957If there were no command substitutions, the command exits with a status
1958of zero.
1959
1960\1f
1961File: bashref.info, Node: Command Search and Execution, Next: Command Execution Environment, Prev: Simple Command Expansion, Up: Executing Commands
ccc6cda3 1962
37c41ab1
CR
19633.7.2 Command Search and Execution
1964----------------------------------
ccc6cda3 1965
37c41ab1 1966After a command has been split into words, if it results in a simple
ccc6cda3
JA
1967command and an optional list of arguments, the following actions are
1968taken.
1969
1970 1. If the command name contains no slashes, the shell attempts to
1971 locate it. If there exists a shell function by that name, that
bb70624e 1972 function is invoked as described in *Note Shell Functions::.
ccc6cda3
JA
1973
1974 2. If the name does not match a function, the shell searches for it
1975 in the list of shell builtins. If a match is found, that builtin
1976 is invoked.
1977
1978 3. If the name is neither a shell function nor a builtin, and
1979 contains no slashes, Bash searches each element of `$PATH' for a
1980 directory containing an executable file by that name. Bash uses a
cce855bc
JA
1981 hash table to remember the full pathnames of executable files to
1982 avoid multiple `PATH' searches (see the description of `hash' in
1983 *Note Bourne Shell Builtins::). A full search of the directories
ccc6cda3
JA
1984 in `$PATH' is performed only if the command is not found in the
1985 hash table. If the search is unsuccessful, the shell prints an
cce855bc 1986 error message and returns an exit status of 127.
ccc6cda3
JA
1987
1988 4. If the search is successful, or if the command name contains one
cce855bc
JA
1989 or more slashes, the shell executes the named program in a
1990 separate execution environment. Argument 0 is set to the name
1991 given, and the remaining arguments to the command are set to the
1992 arguments supplied, if any.
ccc6cda3
JA
1993
1994 5. If this execution fails because the file is not in executable
cce855bc
JA
1995 format, and the file is not a directory, it is assumed to be a
1996 SHELL SCRIPT and the shell executes it as described in *Note Shell
1997 Scripts::.
1998
1999 6. If the command was not begun asynchronously, the shell waits for
2000 the command to complete and collects its exit status.
2001
2002
2003\1f
2004File: bashref.info, Node: Command Execution Environment, Next: Environment, Prev: Command Search and Execution, Up: Executing Commands
2005
37c41ab1
CR
20063.7.3 Command Execution Environment
2007-----------------------------------
cce855bc 2008
37c41ab1 2009The shell has an EXECUTION ENVIRONMENT, which consists of the following:
cce855bc
JA
2010
2011 * open files inherited by the shell at invocation, as modified by
2012 redirections supplied to the `exec' builtin
2013
2014 * the current working directory as set by `cd', `pushd', or `popd',
2015 or inherited by the shell at invocation
2016
2017 * the file creation mode mask as set by `umask' or inherited from
2018 the shell's parent
2019
2020 * current traps set by `trap'
2021
2022 * shell parameters that are set by variable assignment or with `set'
2023 or inherited from the shell's parent in the environment
2024
2025 * shell functions defined during execution or inherited from the
2026 shell's parent in the environment
2027
2028 * options enabled at invocation (either by default or with
2029 command-line arguments) or by `set'
2030
2031 * options enabled by `shopt'
2032
28ef6c31 2033 * shell aliases defined with `alias' (*note Aliases::)
cce855bc
JA
2034
2035 * various process IDs, including those of background jobs (*note
28ef6c31
JA
2036 Lists::), the value of `$$', and the value of `$PPID'
2037
cce855bc
JA
2038
2039 When a simple command other than a builtin or shell function is to
2040be executed, it is invoked in a separate execution environment that
2041consists of the following. Unless otherwise noted, the values are
2042inherited from the shell.
2043
2044 * the shell's open files, plus any modifications and additions
2045 specified by redirections to the command
2046
2047 * the current working directory
2048
2049 * the file creation mode mask
2050
d3a24ed2
CR
2051 * shell variables and functions marked for export, along with
2052 variables exported for the command, passed in the environment
2053 (*note Environment::)
cce855bc
JA
2054
2055 * traps caught by the shell are reset to the values inherited from
2056 the shell's parent, and traps ignored by the shell are ignored
2057
28ef6c31 2058
cce855bc
JA
2059 A command invoked in this separate environment cannot affect the
2060shell's execution environment.
2061
d3a24ed2
CR
2062 Command substitution, commands grouped with parentheses, and
2063asynchronous commands are invoked in a subshell environment that is a
2064duplicate of the shell environment, except that traps caught by the
2065shell are reset to the values that the shell inherited from its parent
2066at invocation. Builtin commands that are invoked as part of a pipeline
2067are also executed in a subshell environment. Changes made to the
2068subshell environment cannot affect the shell's execution environment.
ccc6cda3 2069
f73dda09
JA
2070 If a command is followed by a `&' and job control is not active, the
2071default standard input for the command is the empty file `/dev/null'.
2072Otherwise, the invoked command inherits the file descriptors of the
2073calling shell as modified by redirections.
2074
ccc6cda3 2075\1f
cce855bc 2076File: bashref.info, Node: Environment, Next: Exit Status, Prev: Command Execution Environment, Up: Executing Commands
ccc6cda3 2077
37c41ab1
CR
20783.7.4 Environment
2079-----------------
ccc6cda3 2080
37c41ab1 2081When a program is invoked it is given an array of strings called the
ccc6cda3
JA
2082ENVIRONMENT. This is a list of name-value pairs, of the form
2083`name=value'.
2084
bb70624e 2085 Bash provides several ways to manipulate the environment. On
ccc6cda3
JA
2086invocation, the shell scans its own environment and creates a parameter
2087for each name found, automatically marking it for EXPORT to child
2088processes. Executed commands inherit the environment. The `export'
2089and `declare -x' commands allow parameters and functions to be added to
2090and deleted from the environment. If the value of a parameter in the
2091environment is modified, the new value becomes part of the environment,
2092replacing the old. The environment inherited by any executed command
2093consists of the shell's initial environment, whose values may be
cce855bc
JA
2094modified in the shell, less any pairs removed by the `unset' and
2095`export -n' commands, plus any additions via the `export' and `declare
2096-x' commands.
ccc6cda3
JA
2097
2098 The environment for any simple command or function may be augmented
2099temporarily by prefixing it with parameter assignments, as described in
2100*Note Shell Parameters::. These assignment statements affect only the
2101environment seen by that command.
2102
28ef6c31 2103 If the `-k' option is set (*note The Set Builtin::), then all
ccc6cda3
JA
2104parameter assignments are placed in the environment for a command, not
2105just those that precede the command name.
2106
2107 When Bash invokes an external command, the variable `$_' is set to
2108the full path name of the command and passed to that command in its
2109environment.
2110
2111\1f
2112File: bashref.info, Node: Exit Status, Next: Signals, Prev: Environment, Up: Executing Commands
2113
37c41ab1
CR
21143.7.5 Exit Status
2115-----------------
ccc6cda3 2116
37c41ab1
CR
2117For the shell's purposes, a command which exits with a zero exit status
2118has succeeded. A non-zero exit status indicates failure. This
cce855bc
JA
2119seemingly counter-intuitive scheme is used so there is one well-defined
2120way to indicate success and a variety of ways to indicate various
2121failure modes. When a command terminates on a fatal signal whose
2122number is N, Bash uses the value 128+N as the exit status.
ccc6cda3
JA
2123
2124 If a command is not found, the child process created to execute it
2125returns a status of 127. If a command is found but is not executable,
2126the return status is 126.
2127
cce855bc
JA
2128 If a command fails because of an error during expansion or
2129redirection, the exit status is greater than zero.
2130
ccc6cda3 2131 The exit status is used by the Bash conditional commands (*note
28ef6c31
JA
2132Conditional Constructs::) and some of the list constructs (*note
2133Lists::).
ccc6cda3
JA
2134
2135 All of the Bash builtins return an exit status of zero if they
2136succeed and a non-zero status on failure, so they may be used by the
cce855bc
JA
2137conditional and list constructs. All builtins return an exit status of
21382 to indicate incorrect usage.
ccc6cda3
JA
2139
2140\1f
2141File: bashref.info, Node: Signals, Prev: Exit Status, Up: Executing Commands
2142
37c41ab1
CR
21433.7.6 Signals
2144-------------
ccc6cda3 2145
37c41ab1 2146When Bash is interactive, in the absence of any traps, it ignores
cce855bc
JA
2147`SIGTERM' (so that `kill 0' does not kill an interactive shell), and
2148`SIGINT' is caught and handled (so that the `wait' builtin is
2149interruptible). When Bash receives a `SIGINT', it breaks out of any
2150executing loops. In all cases, Bash ignores `SIGQUIT'. If job control
28ef6c31 2151is in effect (*note Job Control::), Bash ignores `SIGTTIN', `SIGTTOU',
cce855bc 2152and `SIGTSTP'.
ccc6cda3 2153
5e13499c
CR
2154 Non-builtin commands started by Bash have signal handlers set to the
2155values inherited by the shell from its parent. When job control is not
2156in effect, asynchronous commands ignore `SIGINT' and `SIGQUIT' in
2157addition to these inherited handlers. Commands run as a result of
2158command substitution ignore the keyboard-generated job control signals
2159`SIGTTIN', `SIGTTOU', and `SIGTSTP'.
ccc6cda3
JA
2160
2161 The shell exits by default upon receipt of a `SIGHUP'. Before
f73dda09
JA
2162exiting, an interactive shell resends the `SIGHUP' to all jobs, running
2163or stopped. Stopped jobs are sent `SIGCONT' to ensure that they receive
2164the `SIGHUP'. To prevent the shell from sending the `SIGHUP' signal to
2165a particular job, it should be removed from the jobs table with the
28ef6c31 2166`disown' builtin (*note Job Control Builtins::) or marked to not
cce855bc
JA
2167receive `SIGHUP' using `disown -h'.
2168
2169 If the `huponexit' shell option has been set with `shopt' (*note
28ef6c31
JA
2170Bash Builtins::), Bash sends a `SIGHUP' to all jobs when an interactive
2171login shell exits.
cce855bc 2172
5e13499c
CR
2173 If Bash is waiting for a command to complete and receives a signal
2174for which a trap has been set, the trap will not be executed until the
2175command completes. When Bash is waiting for an asynchronous command
2176via the `wait' builtin, the reception of a signal for which a trap has
2177been set will cause the `wait' builtin to return immediately with an
2178exit status greater than 128, immediately after which the trap is
2179executed.
ccc6cda3
JA
2180
2181\1f
2182File: bashref.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic Shell Features
2183
37c41ab1
CR
21843.8 Shell Scripts
2185=================
ccc6cda3 2186
37c41ab1
CR
2187A shell script is a text file containing shell commands. When such a
2188file is used as the first non-option argument when invoking Bash, and
28ef6c31 2189neither the `-c' nor `-s' option is supplied (*note Invoking Bash::),
ccc6cda3 2190Bash reads and executes commands from the file, then exits. This mode
f73dda09
JA
2191of operation creates a non-interactive shell. The shell first searches
2192for the file in the current directory, and looks in the directories in
2193`$PATH' if not found there.
2194
2195 When Bash runs a shell script, it sets the special parameter `0' to
2196the name of the file, rather than the name of the shell, and the
2197positional parameters are set to the remaining arguments, if any are
2198given. If no additional arguments are supplied, the positional
2199parameters are unset.
ccc6cda3
JA
2200
2201 A shell script may be made executable by using the `chmod' command
2202to turn on the execute bit. When Bash finds such a file while
2203searching the `$PATH' for a command, it spawns a subshell to execute
2204it. In other words, executing
2205 filename ARGUMENTS
37c41ab1 2206 is equivalent to executing
ccc6cda3
JA
2207 bash filename ARGUMENTS
2208
2209if `filename' is an executable shell script. This subshell
2210reinitializes itself, so that the effect is as if a new shell had been
cce855bc
JA
2211invoked to interpret the script, with the exception that the locations
2212of commands remembered by the parent (see the description of `hash' in
2213*Note Bourne Shell Builtins::) are retained by the child.
ccc6cda3 2214
bb70624e
JA
2215 Most versions of Unix make this a part of the operating system's
2216command execution mechanism. If the first line of a script begins with
2217the two characters `#!', the remainder of the line specifies an
2218interpreter for the program. Thus, you can specify Bash, `awk', Perl,
2219or some other interpreter and write the rest of the script file in that
2220language.
2221
2222 The arguments to the interpreter consist of a single optional
2223argument following the interpreter name on the first line of the script
2224file, followed by the name of the script file, followed by the rest of
2225the arguments. Bash will perform this action on operating systems that
2226do not handle it themselves. Note that some older versions of Unix
2227limit the interpreter name and argument to a maximum of 32 characters.
2228
2229 Bash scripts often begin with `#! /bin/bash' (assuming that Bash has
2230been installed in `/bin'), since this ensures that Bash will be used to
2231interpret the script, even if it is executed under another shell.
ccc6cda3
JA
2232
2233\1f
bb70624e 2234File: bashref.info, Node: Shell Builtin Commands, Next: Shell Variables, Prev: Basic Shell Features, Up: Top
ccc6cda3 2235
37c41ab1
CR
22364 Shell Builtin Commands
2237************************
ccc6cda3
JA
2238
2239* Menu:
2240
2241* Bourne Shell Builtins:: Builtin commands inherited from the Bourne
2242 Shell.
bb70624e
JA
2243* Bash Builtins:: Table of builtins specific to Bash.
2244* The Set Builtin:: This builtin is so overloaded it
2245 deserves its own section.
2246* Special Builtins:: Builtin commands classified specially by
2247 POSIX.2.
2248
2249 Builtin commands are contained within the shell itself. When the
2250name of a builtin command is used as the first word of a simple command
28ef6c31 2251(*note Simple Commands::), the shell executes the command directly,
bb70624e
JA
2252without invoking another program. Builtin commands are necessary to
2253implement functionality impossible or inconvenient to obtain with
2254separate utilities.
ccc6cda3 2255
bb70624e
JA
2256 This section briefly the builtins which Bash inherits from the
2257Bourne Shell, as well as the builtin commands which are unique to or
2258have been extended in Bash.
2259
2260 Several builtin commands are described in other chapters: builtin
2261commands which provide the Bash interface to the job control facilities
28ef6c31
JA
2262(*note Job Control Builtins::), the directory stack (*note Directory
2263Stack Builtins::), the command history (*note Bash History Builtins::),
2264and the programmable completion facilities (*note Programmable
2265Completion Builtins::).
bb70624e
JA
2266
2267 Many of the builtins have been extended by POSIX or Bash.
ccc6cda3 2268
c2258e1c
CR
2269 Unless otherwise noted, each builtin command documented as accepting
2270options preceded by `-' accepts `--' to signify the end of the options.
2271
ccc6cda3 2272\1f
bb70624e 2273File: bashref.info, Node: Bourne Shell Builtins, Next: Bash Builtins, Up: Shell Builtin Commands
ccc6cda3 2274
37c41ab1
CR
22754.1 Bourne Shell Builtins
2276=========================
ccc6cda3 2277
37c41ab1 2278The following shell builtin commands are inherited from the Bourne
ccc6cda3
JA
2279Shell. These commands are implemented as specified by the POSIX 1003.2
2280standard.
2281
bb70624e 2282`: (a colon)'
ccc6cda3
JA
2283 : [ARGUMENTS]
2284 Do nothing beyond expanding ARGUMENTS and performing redirections.
cce855bc 2285 The return status is zero.
ccc6cda3 2286
bb70624e 2287`. (a period)'
b72432fd 2288 . FILENAME [ARGUMENTS]
ccc6cda3 2289 Read and execute commands from the FILENAME argument in the
cce855bc 2290 current shell context. If FILENAME does not contain a slash, the
28ef6c31
JA
2291 `PATH' variable is used to find FILENAME. When Bash is not in
2292 POSIX mode, the current directory is searched if FILENAME is not
2293 found in `$PATH'. If any ARGUMENTS are supplied, they become the
2294 positional parameters when FILENAME is executed. Otherwise the
2295 positional parameters are unchanged. The return status is the
2296 exit status of the last command executed, or zero if no commands
2297 are executed. If FILENAME is not found, or cannot be read, the
2298 return status is non-zero. This builtin is equivalent to `source'.
ccc6cda3
JA
2299
2300`break'
2301 break [N]
2302 Exit from a `for', `while', `until', or `select' loop. If N is
cce855bc
JA
2303 supplied, the Nth enclosing loop is exited. N must be greater
2304 than or equal to 1. The return status is zero unless N is not
2305 greater than or equal to 1.
ccc6cda3
JA
2306
2307`cd'
7117c2d2 2308 cd [-L|-P] [DIRECTORY]
ccc6cda3
JA
2309 Change the current working directory to DIRECTORY. If DIRECTORY
2310 is not given, the value of the `HOME' shell variable is used. If
2311 the shell variable `CDPATH' exists, it is used as a search path.
d3a24ed2
CR
2312 If DIRECTORY begins with a slash, `CDPATH' is not used.
2313
2314 The `-P' option means to not follow symbolic links; symbolic links
2315 are followed by default or with the `-L' option. If DIRECTORY is
2316 `-', it is equivalent to `$OLDPWD'.
2317
2318 If a non-empty directory name from `CDPATH' is used, or if `-' is
2319 the first argument, and the directory change is successful, the
2320 absolute pathname of the new working directory is written to the
2321 standard output.
2322
2323 The return status is zero if the directory is successfully changed,
2324 non-zero otherwise.
ccc6cda3
JA
2325
2326`continue'
2327 continue [N]
2328 Resume the next iteration of an enclosing `for', `while', `until',
2329 or `select' loop. If N is supplied, the execution of the Nth
cce855bc
JA
2330 enclosing loop is resumed. N must be greater than or equal to 1.
2331 The return status is zero unless N is not greater than or equal to
2332 1.
ccc6cda3
JA
2333
2334`eval'
2335 eval [ARGUMENTS]
2336 The arguments are concatenated together into a single command,
cce855bc
JA
2337 which is then read and executed, and its exit status returned as
2338 the exit status of `eval'. If there are no arguments or only
2339 empty arguments, the return status is zero.
ccc6cda3
JA
2340
2341`exec'
cce855bc
JA
2342 exec [-cl] [-a NAME] [COMMAND [ARGUMENTS]]
2343 If COMMAND is supplied, it replaces the shell without creating a
2344 new process. If the `-l' option is supplied, the shell places a
bb70624e
JA
2345 dash at the beginning of the zeroth arg passed to COMMAND. This
2346 is what the `login' program does. The `-c' option causes COMMAND
2347 to be executed with an empty environment. If `-a' is supplied,
2348 the shell passes NAME as the zeroth argument to COMMAND. If no
cce855bc
JA
2349 COMMAND is specified, redirections may be used to affect the
2350 current shell environment. If there are no redirection errors, the
2351 return status is zero; otherwise the return status is non-zero.
ccc6cda3
JA
2352
2353`exit'
2354 exit [N]
bb70624e
JA
2355 Exit the shell, returning a status of N to the shell's parent. If
2356 N is omitted, the exit status is that of the last command executed.
cce855bc 2357 Any trap on `EXIT' is executed before the shell terminates.
ccc6cda3
JA
2358
2359`export'
2360 export [-fn] [-p] [NAME[=VALUE]]
2361 Mark each NAME to be passed to child processes in the environment.
2362 If the `-f' option is supplied, the NAMEs refer to shell
cce855bc
JA
2363 functions; otherwise the names refer to shell variables. The `-n'
2364 option means to no longer mark each NAME for export. If no NAMES
2365 are supplied, or if the `-p' option is given, a list of exported
2366 names is displayed. The `-p' option displays output in a form
d3a24ed2
CR
2367 that may be reused as input. If a variable name is followed by
2368 =VALUE, the value of the variable is set to VALUE.
2369
2370 The return status is zero unless an invalid option is supplied,
2371 one of the names is not a valid shell variable name, or `-f' is
2372 supplied with a name that is not a shell function.
ccc6cda3
JA
2373
2374`getopts'
2375 getopts OPTSTRING NAME [ARGS]
2376 `getopts' is used by shell scripts to parse positional parameters.
bb70624e
JA
2377 OPTSTRING contains the option characters to be recognized; if a
2378 character is followed by a colon, the option is expected to have an
2379 argument, which should be separated from it by white space. The
2380 colon (`:') and question mark (`?') may not be used as option
2381 characters. Each time it is invoked, `getopts' places the next
2382 option in the shell variable NAME, initializing NAME if it does
2383 not exist, and the index of the next argument to be processed into
2384 the variable `OPTIND'. `OPTIND' is initialized to 1 each time the
2385 shell or a shell script is invoked. When an option requires an
2386 argument, `getopts' places that argument into the variable
2387 `OPTARG'. The shell does not reset `OPTIND' automatically; it
2388 must be manually reset between multiple calls to `getopts' within
2389 the same shell invocation if a new set of parameters is to be used.
ccc6cda3 2390
cce855bc
JA
2391 When the end of options is encountered, `getopts' exits with a
2392 return value greater than zero. `OPTIND' is set to the index of
2393 the first non-option argument, and `name' is set to `?'.
2394
2395 `getopts' normally parses the positional parameters, but if more
2396 arguments are given in ARGS, `getopts' parses those instead.
2397
ccc6cda3
JA
2398 `getopts' can report errors in two ways. If the first character of
2399 OPTSTRING is a colon, SILENT error reporting is used. In normal
cce855bc 2400 operation diagnostic messages are printed when invalid options or
ccc6cda3 2401 missing option arguments are encountered. If the variable `OPTERR'
cce855bc 2402 is set to 0, no error messages will be displayed, even if the first
ccc6cda3
JA
2403 character of `optstring' is not a colon.
2404
cce855bc 2405 If an invalid option is seen, `getopts' places `?' into NAME and,
ccc6cda3
JA
2406 if not silent, prints an error message and unsets `OPTARG'. If
2407 `getopts' is silent, the option character found is placed in
2408 `OPTARG' and no diagnostic message is printed.
2409
2410 If a required argument is not found, and `getopts' is not silent,
2411 a question mark (`?') is placed in NAME, `OPTARG' is unset, and a
2412 diagnostic message is printed. If `getopts' is silent, then a
2413 colon (`:') is placed in NAME and `OPTARG' is set to the option
2414 character found.
2415
ccc6cda3 2416`hash'
7117c2d2 2417 hash [-'r] [-p FILENAME] [-dt] [NAME]
cce855bc
JA
2418 Remember the full pathnames of commands specified as NAME
2419 arguments, so they need not be searched for on subsequent
2420 invocations. The commands are found by searching through the
2421 directories listed in `$PATH'. The `-p' option inhibits the path
2422 search, and FILENAME is used as the location of NAME. The `-r'
7117c2d2
JA
2423 option causes the shell to forget all remembered locations. The
2424 `-d' option causes the shell to forget the remembered location of
2425 each NAME. If the `-t' option is supplied, the full pathname to
2426 which each NAME corresponds is printed. If multiple NAME
2427 arguments are supplied with `-t' the NAME is printed before the
2428 hashed full pathname. The `-l' option causes output to be
2429 displayed in a format that may be reused as input. If no
2430 arguments are given, or if only `-l' is supplied, information
2431 about remembered commands is printed. The return status is zero
2432 unless a NAME is not found or an invalid option is supplied.
ccc6cda3
JA
2433
2434`pwd'
2435 pwd [-LP]
bb70624e
JA
2436 Print the absolute pathname of the current working directory. If
2437 the `-P' option is supplied, the pathname printed will not contain
2438 symbolic links. If the `-L' option is supplied, the pathname
2439 printed may contain symbolic links. The return status is zero
2440 unless an error is encountered while determining the name of the
2441 current directory or an invalid option is supplied.
ccc6cda3
JA
2442
2443`readonly'
d3a24ed2 2444 readonly [-apf] [NAME[=VALUE]] ...
cce855bc
JA
2445 Mark each NAME as readonly. The values of these names may not be
2446 changed by subsequent assignment. If the `-f' option is supplied,
2447 each NAME refers to a shell function. The `-a' option means each
2448 NAME refers to an array variable. If no NAME arguments are given,
2449 or if the `-p' option is supplied, a list of all readonly names is
2450 printed. The `-p' option causes output to be displayed in a
d3a24ed2
CR
2451 format that may be reused as input. If a variable name is
2452 followed by =VALUE, the value of the variable is set to VALUE.
2453 The return status is zero unless an invalid option is supplied,
2454 one of the NAME arguments is not a valid shell variable or
2455 function name, or the `-f' option is supplied with a name that is
2456 not a shell function.
ccc6cda3
JA
2457
2458`return'
2459 return [N]
bb70624e
JA
2460 Cause a shell function to exit with the return value N. If N is
2461 not supplied, the return value is the exit status of the last
2462 command executed in the function. This may also be used to
2463 terminate execution of a script being executed with the `.' (or
2464 `source') builtin, returning either N or the exit status of the
cce855bc 2465 last command executed within the script as the exit status of the
d3a24ed2
CR
2466 script. Any command associated with the `RETURN' trap is executed
2467 before execution resumes after the function or script. The return
2468 status is non-zero if `return' is used outside a function and not
2469 during the execution of a script by `.' or `source'.
ccc6cda3
JA
2470
2471`shift'
2472 shift [N]
cce855bc
JA
2473 Shift the positional parameters to the left by N. The positional
2474 parameters from N+1 ... `$#' are renamed to `$1' ... `$#'-N+1.
2475 Parameters represented by the numbers `$#' to N+1 are unset. N
2476 must be a non-negative number less than or equal to `$#'. If N is
2477 zero or greater than `$#', the positional parameters are not
bb70624e
JA
2478 changed. If N is not supplied, it is assumed to be 1. The return
2479 status is zero unless N is greater than `$#' or less than zero,
2480 non-zero otherwise.
ccc6cda3
JA
2481
2482`test'
2483`['
cce855bc
JA
2484 Evaluate a conditional expression EXPR. Each operator and operand
2485 must be a separate argument. Expressions are composed of the
2486 primaries described below in *Note Bash Conditional Expressions::.
2487
bb70624e
JA
2488 When the `[' form is used, the last argument to the command must
2489 be a `]'.
2490
cce855bc
JA
2491 Expressions may be combined using the following operators, listed
2492 in decreasing order of precedence.
2493
2494 `! EXPR'
2495 True if EXPR is false.
2496
2497 `( EXPR )'
2498 Returns the value of EXPR. This may be used to override the
2499 normal precedence of operators.
2500
2501 `EXPR1 -a EXPR2'
2502 True if both EXPR1 and EXPR2 are true.
2503
2504 `EXPR1 -o EXPR2'
2505 True if either EXPR1 or EXPR2 is true.
2506
2507 The `test' and `[' builtins evaluate conditional expressions using
2508 a set of rules based on the number of arguments.
2509
2510 0 arguments
2511 The expression is false.
2512
2513 1 argument
2514 The expression is true if and only if the argument is not
2515 null.
2516
2517 2 arguments
2518 If the first argument is `!', the expression is true if and
2519 only if the second argument is null. If the first argument
2520 is one of the unary conditional operators (*note Bash
28ef6c31 2521 Conditional Expressions::), the expression is true if the
cce855bc
JA
2522 unary test is true. If the first argument is not a valid
2523 unary operator, the expression is false.
2524
2525 3 arguments
2526 If the second argument is one of the binary conditional
28ef6c31 2527 operators (*note Bash Conditional Expressions::), the result
cce855bc
JA
2528 of the expression is the result of the binary test using the
2529 first and third arguments as operands. If the first argument
2530 is `!', the value is the negation of the two-argument test
2531 using the second and third arguments. If the first argument
2532 is exactly `(' and the third argument is exactly `)', the
2533 result is the one-argument test of the second argument.
2534 Otherwise, the expression is false. The `-a' and `-o'
2535 operators are considered binary operators in this case.
2536
2537 4 arguments
2538 If the first argument is `!', the result is the negation of
2539 the three-argument expression composed of the remaining
2540 arguments. Otherwise, the expression is parsed and evaluated
2541 according to precedence using the rules listed above.
2542
2543 5 or more arguments
2544 The expression is parsed and evaluated according to precedence
2545 using the rules listed above.
ccc6cda3
JA
2546
2547`times'
2548 times
2549 Print out the user and system times used by the shell and its
cce855bc 2550 children. The return status is zero.
ccc6cda3
JA
2551
2552`trap'
d166f048 2553 trap [-lp] [ARG] [SIGSPEC ...]
ccc6cda3 2554 The commands in ARG are to be read and executed when the shell
9f422431
CR
2555 receives signal SIGSPEC. If ARG is absent (and there is a single
2556 SIGSPEC) or equal to `-', each specified signal's disposition is
2557 reset to the value it had when the shell was started. If ARG is
2558 the null string, then the signal specified by each SIGSPEC is
2559 ignored by the shell and commands it invokes. If ARG is not
2560 present and `-p' has been supplied, the shell displays the trap
2561 commands associated with each SIGSPEC. If no arguments are
2562 supplied, or only `-p' is given, `trap' prints the list of commands
2563 associated with each signal number in a form that may be reused as
2564 shell input. The `-l' option causes the shell to print a list of
2565 signal names and their corresponding numbers. Each SIGSPEC is
2566 either a signal name or a signal number. Signal names are case
2567 insensitive and the `SIG' prefix is optional. If a SIGSPEC is `0'
d3a24ed2
CR
2568 or `EXIT', ARG is executed when the shell exits. If a SIGSPEC is
2569 `DEBUG', the command ARG is executed before every simple command,
2570 `for' command, `case' command, `select' command, every arithmetic
2571 `for' command, and before the first command executes in a shell
2572 function. Refer to the description of the `extglob' option to the
2573 `shopt' builtin (*note Bash Builtins::) for details of its effect
2574 on the `DEBUG' trap. If a SIGSPEC is `ERR', the command ARG is
5e13499c
CR
2575 executed whenever a simple command has a non-zero exit status,
2576 subject to the following conditions. The `ERR' trap is not
2577 executed if the failed command is part of the command list
2578 immediately following an `until' or `while' keyword, part of the
2579 test in an `if' statement, part of a `&&' or `||' list, or if the
2580 command's return status is being inverted using `!'. These are
2581 the same conditions obeyed by the `errexit' option. If a SIGSPEC
2582 is `RETURN', the command ARG is executed each time a shell
2583 function or a script executed with the `.' or `source' builtins
2584 finishes executing.
d3a24ed2 2585
ccc6cda3
JA
2586 Signals ignored upon entry to the shell cannot be trapped or reset.
2587 Trapped signals are reset to their original values in a child
2588 process when it is created.
2589
cce855bc
JA
2590 The return status is zero unless a SIGSPEC does not specify a
2591 valid signal.
2592
ccc6cda3 2593`umask'
cce855bc 2594 umask [-p] [-S] [MODE]
ccc6cda3
JA
2595 Set the shell process's file creation mask to MODE. If MODE
2596 begins with a digit, it is interpreted as an octal number; if not,
2597 it is interpreted as a symbolic mode mask similar to that accepted
2598 by the `chmod' command. If MODE is omitted, the current value of
2599 the mask is printed. If the `-S' option is supplied without a
cce855bc
JA
2600 MODE argument, the mask is printed in a symbolic format. If the
2601 `-p' option is supplied, and MODE is omitted, the output is in a
2602 form that may be reused as input. The return status is zero if
2603 the mode is successfully changed or if no MODE argument is
2604 supplied, and non-zero otherwise.
ccc6cda3 2605
bb70624e
JA
2606 Note that when the mode is interpreted as an octal number, each
2607 number of the umask is subtracted from `7'. Thus, a umask of `022'
2608 results in permissions of `755'.
2609
ccc6cda3
JA
2610`unset'
2611 unset [-fv] [NAME]
2612 Each variable or function NAME is removed. If no options are
2613 supplied, or the `-v' option is given, each NAME refers to a shell
2614 variable. If the `-f' option is given, the NAMEs refer to shell
cce855bc
JA
2615 functions, and the function definition is removed. Readonly
2616 variables and functions may not be unset. The return status is
d3a24ed2 2617 zero unless a NAME is readonly.
ccc6cda3
JA
2618
2619\1f
bb70624e 2620File: bashref.info, Node: Bash Builtins, Next: The Set Builtin, Prev: Bourne Shell Builtins, Up: Shell Builtin Commands
ccc6cda3 2621
37c41ab1
CR
26224.2 Bash Builtin Commands
2623=========================
ccc6cda3 2624
37c41ab1 2625This section describes builtin commands which are unique to or have
bb70624e
JA
2626been extended in Bash. Some of these commands are specified in the
2627POSIX 1003.2 standard.
ccc6cda3 2628
bb70624e
JA
2629`alias'
2630 alias [`-p'] [NAME[=VALUE] ...]
ccc6cda3 2631
bb70624e
JA
2632 Without arguments or with the `-p' option, `alias' prints the list
2633 of aliases on the standard output in a form that allows them to be
2634 reused as input. If arguments are supplied, an alias is defined
2635 for each NAME whose VALUE is given. If no VALUE is given, the name
2636 and value of the alias is printed. Aliases are described in *Note
2637 Aliases::.
ccc6cda3 2638
bb70624e
JA
2639`bind'
2640 bind [-m KEYMAP] [-lpsvPSV]
2641 bind [-m KEYMAP] [-q FUNCTION] [-u FUNCTION] [-r KEYSEQ]
2642 bind [-m KEYMAP] -f FILENAME
2643 bind [-m KEYMAP] -x KEYSEQ:SHELL-COMMAND
2644 bind [-m KEYMAP] KEYSEQ:FUNCTION-NAME
7117c2d2 2645 bind READLINE-COMMAND
ccc6cda3 2646
28ef6c31 2647 Display current Readline (*note Command Line Editing::) key and
7117c2d2
JA
2648 function bindings, bind a key sequence to a Readline function or
2649 macro, or set a Readline variable. Each non-option argument is a
2650 command as it would appear in a a Readline initialization file
2651 (*note Readline Init File::), but each binding or command must be
2652 passed as a separate argument; e.g.,
bb70624e
JA
2653 `"\C-x\C-r":re-read-init-file'. Options, if supplied, have the
2654 following meanings:
ccc6cda3 2655
bb70624e
JA
2656 `-m KEYMAP'
2657 Use KEYMAP as the keymap to be affected by the subsequent
2658 bindings. Acceptable KEYMAP names are `emacs',
28ef6c31 2659 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
bb70624e
JA
2660 `vi-command', and `vi-insert'. `vi' is equivalent to
2661 `vi-command'; `emacs' is equivalent to `emacs-standard'.
cce855bc 2662
bb70624e
JA
2663 `-l'
2664 List the names of all Readline functions.
cce855bc 2665
bb70624e
JA
2666 `-p'
2667 Display Readline function names and bindings in such a way
2668 that they can be used as input or in a Readline
2669 initialization file.
cce855bc 2670
bb70624e
JA
2671 `-P'
2672 List current Readline function names and bindings.
cce855bc 2673
bb70624e
JA
2674 `-v'
2675 Display Readline variable names and values in such a way that
2676 they can be used as input or in a Readline initialization
2677 file.
ccc6cda3 2678
bb70624e
JA
2679 `-V'
2680 List current Readline variable names and values.
ccc6cda3 2681
bb70624e
JA
2682 `-s'
2683 Display Readline key sequences bound to macros and the
2684 strings they output in such a way that they can be used as
2685 input or in a Readline initialization file.
ccc6cda3 2686
bb70624e
JA
2687 `-S'
2688 Display Readline key sequences bound to macros and the
2689 strings they output.
ccc6cda3 2690
bb70624e
JA
2691 `-f FILENAME'
2692 Read key bindings from FILENAME.
ccc6cda3 2693
bb70624e
JA
2694 `-q FUNCTION'
2695 Query about which keys invoke the named FUNCTION.
ccc6cda3 2696
bb70624e
JA
2697 `-u FUNCTION'
2698 Unbind all keys bound to the named FUNCTION.
ccc6cda3 2699
bb70624e
JA
2700 `-r KEYSEQ'
2701 Remove any current binding for KEYSEQ.
ccc6cda3 2702
bb70624e
JA
2703 `-x KEYSEQ:SHELL-COMMAND'
2704 Cause SHELL-COMMAND to be executed whenever KEYSEQ is entered.
ccc6cda3 2705
761783bf 2706
bb70624e
JA
2707 The return status is zero unless an invalid option is supplied or
2708 an error occurs.
ccc6cda3 2709
bb70624e
JA
2710`builtin'
2711 builtin [SHELL-BUILTIN [ARGS]]
2712 Run a shell builtin, passing it ARGS, and return its exit status.
2713 This is useful when defining a shell function with the same name
2714 as a shell builtin, retaining the functionality of the builtin
2715 within the function. The return status is non-zero if
2716 SHELL-BUILTIN is not a shell builtin command.
ccc6cda3 2717
d3a24ed2
CR
2718`caller'
2719 caller [EXPR]
2720 Returns the context of any active subroutine call (a shell
5e13499c 2721 function or a script executed with the `.' or `source' builtins).
d3a24ed2
CR
2722
2723 Without EXPR, `caller' displays the line number and source
2724 filename of the current subroutine call. If a non-negative
2725 integer is supplied as EXPR, `caller' displays the line number,
2726 subroutine name, and source file corresponding to that position in
2727 the current execution call stack. This extra information may be
2728 used, for example, to print a stack trace. The current frame is
2729 frame 0.
2730
2731 The return value is 0 unless the shell is not executing a
2732 subroutine call or EXPR does not correspond to a valid position in
2733 the call stack.
2734
bb70624e
JA
2735`command'
2736 command [-pVv] COMMAND [ARGUMENTS ...]
2737 Runs COMMAND with ARGUMENTS ignoring any shell function named
2738 COMMAND. Only shell builtin commands or commands found by
2739 searching the `PATH' are executed. If there is a shell function
2740 named `ls', running `command ls' within the function will execute
2741 the external command `ls' instead of calling the function
2742 recursively. The `-p' option means to use a default value for
28ef6c31 2743 `PATH' that is guaranteed to find all of the standard utilities.
bb70624e
JA
2744 The return status in this case is 127 if COMMAND cannot be found
2745 or an error occurred, and the exit status of COMMAND otherwise.
ccc6cda3 2746
bb70624e
JA
2747 If either the `-V' or `-v' option is supplied, a description of
2748 COMMAND is printed. The `-v' option causes a single word
2749 indicating the command or file name used to invoke COMMAND to be
2750 displayed; the `-V' option produces a more verbose description.
2751 In this case, the return status is zero if COMMAND is found, and
2752 non-zero if not.
ccc6cda3 2753
bb70624e 2754`declare'
d3a24ed2 2755 declare [-afFirtx] [-p] [NAME[=VALUE] ...]
ccc6cda3 2756
bb70624e
JA
2757 Declare variables and give them attributes. If no NAMEs are
2758 given, then display the values of variables instead.
ccc6cda3 2759
bb70624e
JA
2760 The `-p' option will display the attributes and values of each
2761 NAME. When `-p' is used, additional options are ignored. The
2762 `-F' option inhibits the display of function definitions; only the
d3a24ed2
CR
2763 function name and attributes are printed. If the `extdebug' shell
2764 option is enabled using `shopt' (*note Bash Builtins::), the
2765 source file name and line number where the function is defined are
2766 displayed as well. `-F' implies `-f'. The following options can
2767 be used to restrict output to variables with the specified
2768 attributes or to give variables attributes:
ccc6cda3 2769
bb70624e 2770 `-a'
28ef6c31 2771 Each NAME is an array variable (*note Arrays::).
ccc6cda3 2772
bb70624e
JA
2773 `-f'
2774 Use function names only.
ccc6cda3 2775
bb70624e
JA
2776 `-i'
2777 The variable is to be treated as an integer; arithmetic
28ef6c31 2778 evaluation (*note Shell Arithmetic::) is performed when the
bb70624e 2779 variable is assigned a value.
ccc6cda3 2780
bb70624e
JA
2781 `-r'
2782 Make NAMEs readonly. These names cannot then be assigned
2783 values by subsequent assignment statements or unset.
ccc6cda3 2784
7117c2d2
JA
2785 `-t'
2786 Give each NAME the `trace' attribute. Traced functions
2787 inherit the `DEBUG' trap from the calling shell. The trace
2788 attribute has no special meaning for variables.
2789
bb70624e
JA
2790 `-x'
2791 Mark each NAME for export to subsequent commands via the
2792 environment.
ccc6cda3 2793
bb70624e
JA
2794 Using `+' instead of `-' turns off the attribute instead. When
2795 used in a function, `declare' makes each NAME local, as with the
d3a24ed2
CR
2796 `local' command. If a variable name is followed by =VALUE, the
2797 value of the variable is set to VALUE.
ccc6cda3 2798
bb70624e
JA
2799 The return status is zero unless an invalid option is encountered,
2800 an attempt is made to define a function using `-f foo=bar', an
2801 attempt is made to assign a value to a readonly variable, an
2802 attempt is made to assign a value to an array variable without
28ef6c31 2803 using the compound assignment syntax (*note Arrays::), one of the
bb70624e
JA
2804 NAMES is not a valid shell variable name, an attempt is made to
2805 turn off readonly status for a readonly variable, an attempt is
2806 made to turn off array status for an array variable, or an attempt
2807 is made to display a non-existent function with `-f'.
ccc6cda3 2808
bb70624e
JA
2809`echo'
2810 echo [-neE] [ARG ...]
2811 Output the ARGs, separated by spaces, terminated with a newline.
2812 The return status is always 0. If `-n' is specified, the trailing
2813 newline is suppressed. If the `-e' option is given,
2814 interpretation of the following backslash-escaped characters is
2815 enabled. The `-E' option disables the interpretation of these
2816 escape characters, even on systems where they are interpreted by
2817 default. The `xpg_echo' shell option may be used to dynamically
2818 determine whether or not `echo' expands these escape characters by
2819 default. `echo' interprets the following escape sequences:
2820 `\a'
2821 alert (bell)
ccc6cda3 2822
bb70624e
JA
2823 `\b'
2824 backspace
ccc6cda3 2825
bb70624e
JA
2826 `\c'
2827 suppress trailing newline
ccc6cda3 2828
bb70624e
JA
2829 `\e'
2830 escape
ccc6cda3 2831
bb70624e
JA
2832 `\f'
2833 form feed
ccc6cda3 2834
bb70624e
JA
2835 `\n'
2836 new line
ccc6cda3 2837
bb70624e
JA
2838 `\r'
2839 carriage return
ccc6cda3 2840
bb70624e
JA
2841 `\t'
2842 horizontal tab
ccc6cda3 2843
bb70624e
JA
2844 `\v'
2845 vertical tab
ccc6cda3 2846
bb70624e
JA
2847 `\\'
2848 backslash
ccc6cda3 2849
7117c2d2
JA
2850 `\0NNN'
2851 the eight-bit character whose value is the octal value NNN
2852 (zero to three octal digits)
2853
bb70624e 2854 `\NNN'
f73dda09 2855 the eight-bit character whose value is the octal value NNN
7117c2d2 2856 (one to three octal digits)
ccc6cda3 2857
f73dda09
JA
2858 `\xHH'
2859 the eight-bit character whose value is the hexadecimal value
2860 HH (one or two hex digits)
2861
bb70624e
JA
2862`enable'
2863 enable [-n] [-p] [-f FILENAME] [-ads] [NAME ...]
2864 Enable and disable builtin shell commands. Disabling a builtin
2865 allows a disk command which has the same name as a shell builtin
2866 to be executed without specifying a full pathname, even though the
2867 shell normally searches for builtins before disk commands. If
2868 `-n' is used, the NAMEs become disabled. Otherwise NAMEs are
2869 enabled. For example, to use the `test' binary found via `$PATH'
2870 instead of the shell builtin version, type `enable -n test'.
ccc6cda3 2871
bb70624e
JA
2872 If the `-p' option is supplied, or no NAME arguments appear, a
2873 list of shell builtins is printed. With no other arguments, the
2874 list consists of all enabled shell builtins. The `-a' option
2875 means to list each builtin with an indication of whether or not it
2876 is enabled.
ccc6cda3 2877
bb70624e
JA
2878 The `-f' option means to load the new builtin command NAME from
2879 shared object FILENAME, on systems that support dynamic loading.
2880 The `-d' option will delete a builtin loaded with `-f'.
ccc6cda3 2881
bb70624e
JA
2882 If there are no options, a list of the shell builtins is displayed.
2883 The `-s' option restricts `enable' to the POSIX special builtins.
2884 If `-s' is used with `-f', the new builtin becomes a special
28ef6c31 2885 builtin (*note Special Builtins::).
ccc6cda3 2886
bb70624e
JA
2887 The return status is zero unless a NAME is not a shell builtin or
2888 there is an error loading a new builtin from a shared object.
ccc6cda3 2889
bb70624e
JA
2890`help'
2891 help [-s] [PATTERN]
2892 Display helpful information about builtin commands. If PATTERN is
2893 specified, `help' gives detailed help on all commands matching
2894 PATTERN, otherwise a list of the builtins is printed. The `-s'
2895 option restricts the information displayed to a short usage
2896 synopsis. The return status is zero unless no command matches
2897 PATTERN.
ccc6cda3 2898
bb70624e
JA
2899`let'
2900 let EXPRESSION [EXPRESSION]
2901 The `let' builtin allows arithmetic to be performed on shell
2902 variables. Each EXPRESSION is evaluated according to the rules
2903 given below in *Note Shell Arithmetic::. If the last EXPRESSION
2904 evaluates to 0, `let' returns 1; otherwise 0 is returned.
ccc6cda3 2905
bb70624e 2906`local'
d3a24ed2 2907 local [OPTION] NAME[=VALUE] ...
bb70624e
JA
2908 For each argument, a local variable named NAME is created, and
2909 assigned VALUE. The OPTION can be any of the options accepted by
2910 `declare'. `local' can only be used within a function; it makes
2911 the variable NAME have a visible scope restricted to that function
2912 and its children. The return status is zero unless `local' is
2913 used outside a function, an invalid NAME is supplied, or NAME is a
2914 readonly variable.
ccc6cda3 2915
bb70624e
JA
2916`logout'
2917 logout [N]
2918 Exit a login shell, returning a status of N to the shell's parent.
ccc6cda3 2919
bb70624e
JA
2920`printf'
2921 `printf' FORMAT [ARGUMENTS]
2922 Write the formatted ARGUMENTS to the standard output under the
2923 control of the FORMAT. The FORMAT is a character string which
2924 contains three types of objects: plain characters, which are
2925 simply copied to standard output, character escape sequences,
2926 which are converted and copied to the standard output, and format
2927 specifications, each of which causes printing of the next
2928 successive ARGUMENT. In addition to the standard `printf(1)'
2929 formats, `%b' causes `printf' to expand backslash escape sequences
5e13499c
CR
2930 in the corresponding ARGUMENT, (except that `\c' terminates
2931 output, backslashes in `\'', `\"', and `\?' are not removed, and
2932 octal escapes beginning with `\0' may contain up to four digits),
2933 and `%q' causes `printf' to output the corresponding ARGUMENT in a
2934 format that can be reused as shell input.
ccc6cda3 2935
bb70624e
JA
2936 The FORMAT is reused as necessary to consume all of the ARGUMENTS.
2937 If the FORMAT requires more ARGUMENTS than are supplied, the extra
2938 format specifications behave as if a zero value or null string, as
2939 appropriate, had been supplied. The return value is zero on
2940 success, non-zero on failure.
ccc6cda3 2941
bb70624e 2942`read'
7117c2d2
JA
2943 read [-ers] [-a ANAME] [-d DELIM] [-n NCHARS] [-p PROMPT] [-t TIMEOUT] [-u FD] [NAME ...]
2944 One line is read from the standard input, or from the file
2945 descriptor FD supplied as an argument to the `-u' option, and the
2946 first word is assigned to the first NAME, the second word to the
2947 second NAME, and so on, with leftover words and their intervening
2948 separators assigned to the last NAME. If there are fewer words
2949 read from the input stream than names, the remaining names are
2950 assigned empty values. The characters in the value of the `IFS'
2951 variable are used to split the line into words. The backslash
2952 character `\' may be used to remove any special meaning for the
2953 next character read and for line continuation. If no names are
2954 supplied, the line read is assigned to the variable `REPLY'. The
2955 return code is zero, unless end-of-file is encountered, `read'
2956 times out, or an invalid file descriptor is supplied as the
2957 argument to `-u'. Options, if supplied, have the following
2958 meanings:
ccc6cda3 2959
bb70624e
JA
2960 `-a ANAME'
2961 The words are assigned to sequential indices of the array
2962 variable ANAME, starting at 0. All elements are removed from
2963 ANAME before the assignment. Other NAME arguments are
2964 ignored.
ccc6cda3 2965
bb70624e
JA
2966 `-d DELIM'
2967 The first character of DELIM is used to terminate the input
2968 line, rather than newline.
ccc6cda3 2969
bb70624e 2970 `-e'
28ef6c31
JA
2971 Readline (*note Command Line Editing::) is used to obtain the
2972 line.
ccc6cda3 2973
bb70624e
JA
2974 `-n NCHARS'
2975 `read' returns after reading NCHARS characters rather than
2976 waiting for a complete line of input.
cce855bc 2977
bb70624e
JA
2978 `-p PROMPT'
2979 Display PROMPT, without a trailing newline, before attempting
2980 to read any input. The prompt is displayed only if input is
2981 coming from a terminal.
ccc6cda3 2982
bb70624e
JA
2983 `-r'
2984 If this option is given, backslash does not act as an escape
2985 character. The backslash is considered to be part of the
2986 line. In particular, a backslash-newline pair may not be
2987 used as a line continuation.
ccc6cda3 2988
bb70624e
JA
2989 `-s'
2990 Silent mode. If input is coming from a terminal, characters
2991 are not echoed.
cce855bc 2992
bb70624e
JA
2993 `-t TIMEOUT'
2994 Cause `read' to time out and return failure if a complete
2995 line of input is not read within TIMEOUT seconds. This
2996 option has no effect if `read' is not reading input from the
2997 terminal or a pipe.
cce855bc 2998
7117c2d2
JA
2999 `-u FD'
3000 Read input from file descriptor FD.
3001
761783bf 3002
bb70624e
JA
3003`shopt'
3004 shopt [-pqsu] [-o] [OPTNAME ...]
3005 Toggle the values of variables controlling optional shell behavior.
3006 With no options, or with the `-p' option, a list of all settable
3007 options is displayed, with an indication of whether or not each is
3008 set. The `-p' option causes output to be displayed in a form that
3009 may be reused as input. Other options have the following meanings:
cce855bc 3010
bb70624e
JA
3011 `-s'
3012 Enable (set) each OPTNAME.
ccc6cda3 3013
bb70624e
JA
3014 `-u'
3015 Disable (unset) each OPTNAME.
ccc6cda3 3016
bb70624e
JA
3017 `-q'
3018 Suppresses normal output; the return status indicates whether
3019 the OPTNAME is set or unset. If multiple OPTNAME arguments
3020 are given with `-q', the return status is zero if all
3021 OPTNAMES are enabled; non-zero otherwise.
ccc6cda3 3022
bb70624e
JA
3023 `-o'
3024 Restricts the values of OPTNAME to be those defined for the
28ef6c31 3025 `-o' option to the `set' builtin (*note The Set Builtin::).
ccc6cda3 3026
bb70624e
JA
3027 If either `-s' or `-u' is used with no OPTNAME arguments, the
3028 display is limited to those options which are set or unset,
3029 respectively.
ccc6cda3 3030
bb70624e
JA
3031 Unless otherwise noted, the `shopt' options are disabled (off) by
3032 default.
ccc6cda3 3033
bb70624e
JA
3034 The return status when listing options is zero if all OPTNAMES are
3035 enabled, non-zero otherwise. When setting or unsetting options,
3036 the return status is zero unless an OPTNAME is not a valid shell
3037 option.
ccc6cda3 3038
bb70624e
JA
3039 The list of `shopt' options is:
3040 `cdable_vars'
3041 If this is set, an argument to the `cd' builtin command that
3042 is not a directory is assumed to be the name of a variable
3043 whose value is the directory to change to.
ccc6cda3 3044
bb70624e
JA
3045 `cdspell'
3046 If set, minor errors in the spelling of a directory component
3047 in a `cd' command will be corrected. The errors checked for
3048 are transposed characters, a missing character, and a
3049 character too many. If a correction is found, the corrected
3050 path is printed, and the command proceeds. This option is
3051 only used by interactive shells.
ccc6cda3 3052
bb70624e
JA
3053 `checkhash'
3054 If this is set, Bash checks that a command found in the hash
3055 table exists before trying to execute it. If a hashed
3056 command no longer exists, a normal path search is performed.
ccc6cda3 3057
bb70624e
JA
3058 `checkwinsize'
3059 If set, Bash checks the window size after each command and,
3060 if necessary, updates the values of `LINES' and `COLUMNS'.
ccc6cda3 3061
bb70624e
JA
3062 `cmdhist'
3063 If set, Bash attempts to save all lines of a multiple-line
3064 command in the same history entry. This allows easy
3065 re-editing of multi-line commands.
cce855bc 3066
bb70624e
JA
3067 `dotglob'
3068 If set, Bash includes filenames beginning with a `.' in the
3069 results of filename expansion.
cce855bc 3070
bb70624e
JA
3071 `execfail'
3072 If this is set, a non-interactive shell will not exit if it
3073 cannot execute the file specified as an argument to the `exec'
3074 builtin command. An interactive shell does not exit if `exec'
3075 fails.
ccc6cda3 3076
bb70624e
JA
3077 `expand_aliases'
3078 If set, aliases are expanded as described below under Aliases,
3079 *Note Aliases::. This option is enabled by default for
3080 interactive shells.
ccc6cda3 3081
d3a24ed2
CR
3082 `extdebug'
3083 If set, behavior intended for use by debuggers is enabled:
3084
3085 1. The `-F' option to the `declare' builtin (*note Bash
3086 Builtins::) displays the source file name and line
3087 number corresponding to each function name supplied as
3088 an argument.
3089
3090 2. If the command run by the `DEBUG' trap returns a
3091 non-zero value, the next command is skipped and not
3092 executed.
3093
3094 3. If the command run by the `DEBUG' trap returns a value
3095 of 2, and the shell is executing in a subroutine (a
3096 shell function or a shell script executed by the `.' or
3097 `source' builtins), a call to `return' is simulated.
3098
bb70624e
JA
3099 `extglob'
3100 If set, the extended pattern matching features described above
28ef6c31 3101 (*note Pattern Matching::) are enabled.
ccc6cda3 3102
d3a24ed2
CR
3103 `extquote'
3104 If set, `$'STRING'' and `$"STRING"' quoting is performed
3105 within `${PARAMETER}' expansions enclosed in double quotes.
3106 This option is enabled by default.
3107
5e13499c
CR
3108 `failglob'
3109 If set, patterns which fail to match filenames during
3110 pathname expansion result in an expansion error.
3111
d3a24ed2
CR
3112 `force_fignore'
3113 If set, the suffixes specified by the `FIGNORE' shell variable
3114 cause words to be ignored when performing word completion
3115 even if the ignored words are the only possible completions.
3116 *Note Bash Variables::, for a description of `FIGNORE'. This
3117 option is enabled by default.
3118
3119 `gnu_errfmt'
3120 If set, shell error messages are written in the standard GNU
3121 error message format.
3122
bb70624e
JA
3123 `histappend'
3124 If set, the history list is appended to the file named by the
3125 value of the `HISTFILE' variable when the shell exits, rather
3126 than overwriting the file.
ccc6cda3 3127
bb70624e
JA
3128 `histreedit'
3129 If set, and Readline is being used, a user is given the
3130 opportunity to re-edit a failed history substitution.
ccc6cda3 3131
bb70624e
JA
3132 `histverify'
3133 If set, and Readline is being used, the results of history
3134 substitution are not immediately passed to the shell parser.
3135 Instead, the resulting line is loaded into the Readline
3136 editing buffer, allowing further modification.
ccc6cda3 3137
bb70624e
JA
3138 `hostcomplete'
3139 If set, and Readline is being used, Bash will attempt to
3140 perform hostname completion when a word containing a `@' is
28ef6c31 3141 being completed (*note Commands For Completion::). This
bb70624e 3142 option is enabled by default.
ccc6cda3 3143
bb70624e
JA
3144 `huponexit'
3145 If set, Bash will send `SIGHUP' to all jobs when an
28ef6c31 3146 interactive login shell exits (*note Signals::).
ccc6cda3 3147
bb70624e
JA
3148 `interactive_comments'
3149 Allow a word beginning with `#' to cause that word and all
3150 remaining characters on that line to be ignored in an
3151 interactive shell. This option is enabled by default.
ccc6cda3 3152
bb70624e
JA
3153 `lithist'
3154 If enabled, and the `cmdhist' option is enabled, multi-line
3155 commands are saved to the history with embedded newlines
3156 rather than using semicolon separators where possible.
ccc6cda3 3157
f73dda09
JA
3158 `login_shell'
3159 The shell sets this option if it is started as a login shell
3160 (*note Invoking Bash::). The value may not be changed.
3161
bb70624e
JA
3162 `mailwarn'
3163 If set, and a file that Bash is checking for mail has been
3164 accessed since the last time it was checked, the message
3165 `"The mail in MAILFILE has been read"' is displayed.
ccc6cda3 3166
bb70624e
JA
3167 `no_empty_cmd_completion'
3168 If set, and Readline is being used, Bash will not attempt to
3169 search the `PATH' for possible completions when completion is
3170 attempted on an empty line.
ccc6cda3 3171
bb70624e
JA
3172 `nocaseglob'
3173 If set, Bash matches filenames in a case-insensitive fashion
3174 when performing filename expansion.
ccc6cda3 3175
bb70624e
JA
3176 `nullglob'
3177 If set, Bash allows filename patterns which match no files to
3178 expand to a null string, rather than themselves.
ccc6cda3 3179
bb70624e
JA
3180 `progcomp'
3181 If set, the programmable completion facilities (*note
28ef6c31 3182 Programmable Completion::) are enabled. This option is
bb70624e 3183 enabled by default.
ccc6cda3 3184
bb70624e 3185 `promptvars'
d3a24ed2
CR
3186 If set, prompt strings undergo parameter expansion, command
3187 substitution, arithmetic expansion, and quote removal after
3188 being expanded as described below (*note Printing a Prompt::).
bb70624e 3189 This option is enabled by default.
ccc6cda3 3190
bb70624e
JA
3191 `restricted_shell'
3192 The shell sets this option if it is started in restricted mode
28ef6c31
JA
3193 (*note The Restricted Shell::). The value may not be changed.
3194 This is not reset when the startup files are executed,
3195 allowing the startup files to discover whether or not a shell
3196 is restricted.
ccc6cda3 3197
bb70624e
JA
3198 `shift_verbose'
3199 If this is set, the `shift' builtin prints an error message
3200 when the shift count exceeds the number of positional
3201 parameters.
ccc6cda3 3202
bb70624e
JA
3203 `sourcepath'
3204 If set, the `source' builtin uses the value of `PATH' to find
3205 the directory containing the file supplied as an argument.
3206 This option is enabled by default.
ccc6cda3 3207
bb70624e
JA
3208 `xpg_echo'
3209 If set, the `echo' builtin expands backslash-escape sequences
3210 by default.
ccc6cda3 3211
761783bf 3212
bb70624e
JA
3213 The return status when listing options is zero if all OPTNAMES are
3214 enabled, non-zero otherwise. When setting or unsetting options,
3215 the return status is zero unless an OPTNAME is not a valid shell
3216 option.
ccc6cda3 3217
bb70624e
JA
3218`source'
3219 source FILENAME
28ef6c31 3220 A synonym for `.' (*note Bourne Shell Builtins::).
ccc6cda3 3221
bb70624e 3222`type'
7117c2d2 3223 type [-afptP] [NAME ...]
bb70624e
JA
3224 For each NAME, indicate how it would be interpreted if used as a
3225 command name.
cce855bc 3226
bb70624e
JA
3227 If the `-t' option is used, `type' prints a single word which is
3228 one of `alias', `function', `builtin', `file' or `keyword', if
3229 NAME is an alias, shell function, shell builtin, disk file, or
3230 shell reserved word, respectively. If the NAME is not found, then
3231 nothing is printed, and `type' returns a failure status.
ccc6cda3 3232
bb70624e
JA
3233 If the `-p' option is used, `type' either returns the name of the
3234 disk file that would be executed, or nothing if `-t' would not
3235 return `file'.
ccc6cda3 3236
7117c2d2
JA
3237 The `-P' option forces a path search for each NAME, even if `-t'
3238 would not return `file'.
3239
3240 If a command is hashed, `-p' and `-P' print the hashed value, not
3241 necessarily the file that appears first in `$PATH'.
3242
bb70624e
JA
3243 If the `-a' option is used, `type' returns all of the places that
3244 contain an executable named FILE. This includes aliases and
3245 functions, if and only if the `-p' option is not also used.
ccc6cda3 3246
7117c2d2
JA
3247 If the `-f' option is used, `type' does not attempt to find shell
3248 functions, as with the `command' builtin.
3249
bb70624e
JA
3250 The return status is zero if any of the NAMES are found, non-zero
3251 if none are found.
ccc6cda3 3252
bb70624e 3253`typeset'
d3a24ed2 3254 typeset [-afFrxi] [-p] [NAME[=VALUE] ...]
bb70624e
JA
3255 The `typeset' command is supplied for compatibility with the Korn
3256 shell; however, it has been deprecated in favor of the `declare'
3257 builtin command.
ccc6cda3 3258
bb70624e
JA
3259`ulimit'
3260 ulimit [-acdflmnpstuvSH] [LIMIT]
3261 `ulimit' provides control over the resources available to processes
3262 started by the shell, on systems that allow such control. If an
3263 option is given, it is interpreted as follows:
3264 `-S'
3265 Change and report the soft limit associated with a resource.
ccc6cda3 3266
bb70624e
JA
3267 `-H'
3268 Change and report the hard limit associated with a resource.
ccc6cda3 3269
bb70624e
JA
3270 `-a'
3271 All current limits are reported.
ccc6cda3 3272
bb70624e
JA
3273 `-c'
3274 The maximum size of core files created.
ccc6cda3 3275
bb70624e
JA
3276 `-d'
3277 The maximum size of a process's data segment.
ccc6cda3 3278
bb70624e
JA
3279 `-f'
3280 The maximum size of files created by the shell.
ccc6cda3 3281
bb70624e
JA
3282 `-l'
3283 The maximum size that may be locked into memory.
ccc6cda3 3284
bb70624e
JA
3285 `-m'
3286 The maximum resident set size.
ccc6cda3 3287
bb70624e
JA
3288 `-n'
3289 The maximum number of open file descriptors.
ccc6cda3 3290
bb70624e
JA
3291 `-p'
3292 The pipe buffer size.
ccc6cda3 3293
bb70624e
JA
3294 `-s'
3295 The maximum stack size.
ccc6cda3 3296
bb70624e
JA
3297 `-t'
3298 The maximum amount of cpu time in seconds.
ccc6cda3 3299
bb70624e
JA
3300 `-u'
3301 The maximum number of processes available to a single user.
cce855bc 3302
bb70624e
JA
3303 `-v'
3304 The maximum amount of virtual memory available to the process.
ccc6cda3 3305
761783bf 3306
f73dda09
JA
3307 If LIMIT is given, it is the new value of the specified resource;
3308 the special LIMIT values `hard', `soft', and `unlimited' stand for
3309 the current hard limit, the current soft limit, and no limit,
3310 respectively. Otherwise, the current value of the soft limit for
3311 the specified resource is printed, unless the `-H' option is
3312 supplied. When setting new limits, if neither `-H' nor `-S' is
3313 supplied, both the hard and soft limits are set. If no option is
3314 given, then `-f' is assumed. Values are in 1024-byte increments,
3315 except for `-t', which is in seconds, `-p', which is in units of
3316 512-byte blocks, and `-n' and `-u', which are unscaled values.
ccc6cda3 3317
f73dda09
JA
3318 The return status is zero unless an invalid option or argument is
3319 supplied, or an error occurs while setting a new limit.
ccc6cda3 3320
bb70624e
JA
3321`unalias'
3322 unalias [-a] [NAME ... ]
ccc6cda3 3323
bb70624e
JA
3324 Remove each NAME from the list of aliases. If `-a' is supplied,
3325 all aliases are removed. Aliases are described in *Note Aliases::.
ccc6cda3 3326
761783bf 3327
bb70624e
JA
3328\1f
3329File: bashref.info, Node: The Set Builtin, Next: Special Builtins, Prev: Bash Builtins, Up: Shell Builtin Commands
ccc6cda3 3330
37c41ab1
CR
33314.3 The Set Builtin
3332===================
ccc6cda3 3333
37c41ab1 3334This builtin is so complicated that it deserves its own section.
ccc6cda3 3335
bb70624e
JA
3336`set'
3337 set [--abefhkmnptuvxBCHP] [-o OPTION] [ARGUMENT ...]
ccc6cda3 3338
bb70624e
JA
3339 If no options or arguments are supplied, `set' displays the names
3340 and values of all shell variables and functions, sorted according
3341 to the current locale, in a format that may be reused as input.
ccc6cda3 3342
bb70624e
JA
3343 When options are supplied, they set or unset shell attributes.
3344 Options, if specified, have the following meanings:
ccc6cda3 3345
bb70624e 3346 `-a'
28ef6c31
JA
3347 Mark variables and function which are modified or created for
3348 export to the environment of subsequent commands.
ccc6cda3 3349
bb70624e
JA
3350 `-b'
3351 Cause the status of terminated background jobs to be reported
3352 immediately, rather than before printing the next primary
3353 prompt.
ccc6cda3 3354
bb70624e
JA
3355 `-e'
3356 Exit immediately if a simple command (*note Simple
28ef6c31 3357 Commands::) exits with a non-zero status, unless the command
d3a24ed2
CR
3358 that fails is part of the command list immediately following
3359 a `while' or `until' keyword, part of the test in an `if'
3360 statement, part of a `&&' or `||' list, or if the command's
3361 return status is being inverted using `!'. A trap on `ERR',
3362 if set, is executed before the shell exits.
ccc6cda3 3363
bb70624e
JA
3364 `-f'
3365 Disable file name generation (globbing).
ccc6cda3 3366
bb70624e
JA
3367 `-h'
3368 Locate and remember (hash) commands as they are looked up for
3369 execution. This option is enabled by default.
ccc6cda3 3370
bb70624e
JA
3371 `-k'
3372 All arguments in the form of assignment statements are placed
3373 in the environment for a command, not just those that precede
3374 the command name.
ccc6cda3 3375
bb70624e 3376 `-m'
28ef6c31 3377 Job control is enabled (*note Job Control::).
b72432fd 3378
bb70624e
JA
3379 `-n'
3380 Read commands but do not execute them; this may be used to
3381 check a script for syntax errors. This option is ignored by
3382 interactive shells.
ccc6cda3 3383
bb70624e
JA
3384 `-o OPTION-NAME'
3385 Set the option corresponding to OPTION-NAME:
ccc6cda3 3386
bb70624e
JA
3387 `allexport'
3388 Same as `-a'.
ccc6cda3 3389
bb70624e
JA
3390 `braceexpand'
3391 Same as `-B'.
ccc6cda3 3392
bb70624e
JA
3393 `emacs'
3394 Use an `emacs'-style line editing interface (*note
28ef6c31 3395 Command Line Editing::).
ccc6cda3 3396
bb70624e
JA
3397 `errexit'
3398 Same as `-e'.
d166f048 3399
d3a24ed2
CR
3400 `errtrace'
3401 Same as `-E'.
3402
3403 `functrace'
3404 Same as `-T'.
3405
bb70624e
JA
3406 `hashall'
3407 Same as `-h'.
d166f048 3408
bb70624e
JA
3409 `histexpand'
3410 Same as `-H'.
ccc6cda3 3411
bb70624e
JA
3412 `history'
3413 Enable command history, as described in *Note Bash
3414 History Facilities::. This option is on by default in
3415 interactive shells.
ccc6cda3 3416
bb70624e
JA
3417 `ignoreeof'
3418 An interactive shell will not exit upon reading EOF.
ccc6cda3 3419
bb70624e
JA
3420 `keyword'
3421 Same as `-k'.
ccc6cda3 3422
bb70624e
JA
3423 `monitor'
3424 Same as `-m'.
ccc6cda3 3425
bb70624e
JA
3426 `noclobber'
3427 Same as `-C'.
ccc6cda3 3428
bb70624e
JA
3429 `noexec'
3430 Same as `-n'.
ccc6cda3 3431
bb70624e
JA
3432 `noglob'
3433 Same as `-f'.
ccc6cda3 3434
f73dda09
JA
3435 `nolog'
3436 Currently ignored.
3437
bb70624e
JA
3438 `notify'
3439 Same as `-b'.
ccc6cda3 3440
bb70624e
JA
3441 `nounset'
3442 Same as `-u'.
ccc6cda3 3443
bb70624e
JA
3444 `onecmd'
3445 Same as `-t'.
ccc6cda3 3446
bb70624e
JA
3447 `physical'
3448 Same as `-P'.
ccc6cda3 3449
5e13499c
CR
3450 `pipefail'
3451 If set, the return value of a pipeline is the value of
3452 the last (rightmost) command to exit with a non-zero
3453 status, or zero if all commands in the pipeline exit
3454 successfully. This option is disabled by default.
3455
bb70624e
JA
3456 `posix'
3457 Change the behavior of Bash where the default operation
3458 differs from the POSIX 1003.2 standard to match the
28ef6c31
JA
3459 standard (*note Bash POSIX Mode::). This is intended to
3460 make Bash behave as a strict superset of that standard.
ccc6cda3 3461
bb70624e
JA
3462 `privileged'
3463 Same as `-p'.
ccc6cda3 3464
bb70624e
JA
3465 `verbose'
3466 Same as `-v'.
cce855bc 3467
bb70624e
JA
3468 `vi'
3469 Use a `vi'-style line editing interface.
ccc6cda3 3470
bb70624e
JA
3471 `xtrace'
3472 Same as `-x'.
cce855bc 3473
bb70624e
JA
3474 `-p'
3475 Turn on privileged mode. In this mode, the `$BASH_ENV' and
3476 `$ENV' files are not processed, shell functions are not
3477 inherited from the environment, and the `SHELLOPTS' variable,
3478 if it appears in the environment, is ignored. If the shell
3479 is started with the effective user (group) id not equal to the
3480 real user (group) id, and the `-p' option is not supplied,
3481 these actions are taken and the effective user id is set to
3482 the real user id. If the `-p' option is supplied at startup,
3483 the effective user id is not reset. Turning this option off
3484 causes the effective user and group ids to be set to the real
3485 user and group ids.
ccc6cda3 3486
bb70624e
JA
3487 `-t'
3488 Exit after reading and executing one command.
ccc6cda3 3489
bb70624e
JA
3490 `-u'
3491 Treat unset variables as an error when performing parameter
3492 expansion. An error message will be written to the standard
3493 error, and a non-interactive shell will exit.
ccc6cda3 3494
bb70624e
JA
3495 `-v'
3496 Print shell input lines as they are read.
ccc6cda3 3497
bb70624e 3498 `-x'
d3a24ed2
CR
3499 Print a trace of simple commands, \fBfor\fP commands,
3500 \fBcase\fP commands, \fBselect\fP commands, and arithmetic
3501 \fBfor\fP commands and their arguments or associated word
3502 lists after they are expanded and before they are executed.
3503 The value of the `PS4' variable is expanded and the resultant
3504 value is printed before the command and its expanded
3505 arguments.
ccc6cda3 3506
bb70624e
JA
3507 `-B'
3508 The shell will perform brace expansion (*note Brace
28ef6c31 3509 Expansion::). This option is on by default.
ccc6cda3 3510
bb70624e
JA
3511 `-C'
3512 Prevent output redirection using `>', `>&', and `<>' from
3513 overwriting existing files.
ccc6cda3 3514
d3a24ed2
CR
3515 `-E'
3516 If set, any trap on `ERR' is inherited by shell functions,
3517 command substitutions, and commands executed in a subshell
3518 environment. The `ERR' trap is normally not inherited in
3519 such cases.
3520
bb70624e
JA
3521 `-H'
3522 Enable `!' style history substitution (*note History
28ef6c31
JA
3523 Interaction::). This option is on by default for interactive
3524 shells.
ccc6cda3 3525
bb70624e
JA
3526 `-P'
3527 If set, do not follow symbolic links when performing commands
3528 such as `cd' which change the current directory. The
3529 physical directory is used instead. By default, Bash follows
3530 the logical chain of directories when performing commands
3531 which change the current directory.
ccc6cda3 3532
bb70624e
JA
3533 For example, if `/usr/sys' is a symbolic link to
3534 `/usr/local/sys' then:
3535 $ cd /usr/sys; echo $PWD
3536 /usr/sys
3537 $ cd ..; pwd
3538 /usr
ccc6cda3 3539
bb70624e
JA
3540 If `set -P' is on, then:
3541 $ cd /usr/sys; echo $PWD
3542 /usr/local/sys
3543 $ cd ..; pwd
3544 /usr/local
ccc6cda3 3545
d3a24ed2
CR
3546 `-T'
3547 If set, any trap on `DEBUG' is inherited by shell functions,
3548 command substitutions, and commands executed in a subshell
3549 environment. The `DEBUG' trap is normally not inherited in
3550 such cases.
3551
bb70624e
JA
3552 `--'
3553 If no arguments follow this option, then the positional
3554 parameters are unset. Otherwise, the positional parameters
3555 are set to the ARGUMENTS, even if some of them begin with a
3556 `-'.
ccc6cda3 3557
bb70624e
JA
3558 `-'
3559 Signal the end of options, cause all remaining ARGUMENTS to
3560 be assigned to the positional parameters. The `-x' and `-v'
3561 options are turned off. If there are no arguments, the
3562 positional parameters remain unchanged.
ccc6cda3 3563
bb70624e
JA
3564 Using `+' rather than `-' causes these options to be turned off.
3565 The options can also be used upon invocation of the shell. The
3566 current set of options may be found in `$-'.
cce855bc 3567
bb70624e
JA
3568 The remaining N ARGUMENTS are positional parameters and are
3569 assigned, in order, to `$1', `$2', ... `$N'. The special
3570 parameter `#' is set to N.
ccc6cda3 3571
bb70624e
JA
3572 The return status is always zero unless an invalid option is
3573 supplied.
ccc6cda3 3574
bb70624e
JA
3575\1f
3576File: bashref.info, Node: Special Builtins, Prev: The Set Builtin, Up: Shell Builtin Commands
ccc6cda3 3577
37c41ab1
CR
35784.4 Special Builtins
3579====================
ccc6cda3 3580
37c41ab1 3581For historical reasons, the POSIX 1003.2 standard has classified
28ef6c31 3582several builtin commands as _special_. When Bash is executing in POSIX
bb70624e
JA
3583mode, the special builtins differ from other builtin commands in three
3584respects:
ccc6cda3 3585
bb70624e
JA
3586 1. Special builtins are found before shell functions during command
3587 lookup.
ccc6cda3 3588
bb70624e
JA
3589 2. If a special builtin returns an error status, a non-interactive
3590 shell exits.
ccc6cda3 3591
bb70624e
JA
3592 3. Assignment statements preceding the command stay in effect in the
3593 shell environment after the command completes.
ccc6cda3 3594
bb70624e
JA
3595 When Bash is not executing in POSIX mode, these builtins behave no
3596differently than the rest of the Bash builtin commands. The Bash POSIX
3597mode is described in *Note Bash POSIX Mode::.
ccc6cda3 3598
bb70624e
JA
3599 These are the POSIX special builtins:
3600 break : . continue eval exec exit export readonly return set
3601 shift trap unset
ccc6cda3 3602
bb70624e
JA
3603\1f
3604File: bashref.info, Node: Shell Variables, Next: Bash Features, Prev: Shell Builtin Commands, Up: Top
cce855bc 3605
37c41ab1
CR
36065 Shell Variables
3607*****************
ccc6cda3 3608
bb70624e 3609* Menu:
ccc6cda3 3610
bb70624e
JA
3611* Bourne Shell Variables:: Variables which Bash uses in the same way
3612 as the Bourne Shell.
3613* Bash Variables:: List of variables that exist in Bash.
ccc6cda3 3614
bb70624e
JA
3615 This chapter describes the shell variables that Bash uses. Bash
3616automatically assigns default values to a number of variables.
cce855bc 3617
bb70624e
JA
3618\1f
3619File: bashref.info, Node: Bourne Shell Variables, Next: Bash Variables, Up: Shell Variables
ccc6cda3 3620
37c41ab1
CR
36215.1 Bourne Shell Variables
3622==========================
cce855bc 3623
37c41ab1
CR
3624Bash uses certain shell variables in the same way as the Bourne shell.
3625In some cases, Bash assigns a default value to the variable.
cce855bc 3626
bb70624e
JA
3627`CDPATH'
3628 A colon-separated list of directories used as a search path for
3629 the `cd' builtin command.
ccc6cda3 3630
bb70624e
JA
3631`HOME'
3632 The current user's home directory; the default for the `cd' builtin
3633 command. The value of this variable is also used by tilde
28ef6c31 3634 expansion (*note Tilde Expansion::).
ccc6cda3 3635
bb70624e
JA
3636`IFS'
3637 A list of characters that separate fields; used when the shell
3638 splits words as part of expansion.
ccc6cda3 3639
bb70624e
JA
3640`MAIL'
3641 If this parameter is set to a filename and the `MAILPATH' variable
3642 is not set, Bash informs the user of the arrival of mail in the
3643 specified file.
cce855bc 3644
bb70624e
JA
3645`MAILPATH'
3646 A colon-separated list of filenames which the shell periodically
3647 checks for new mail. Each list entry can specify the message that
3648 is printed when new mail arrives in the mail file by separating
3649 the file name from the message with a `?'. When used in the text
3650 of the message, `$_' expands to the name of the current mail file.
cce855bc 3651
bb70624e
JA
3652`OPTARG'
3653 The value of the last option argument processed by the `getopts'
3654 builtin.
ccc6cda3 3655
bb70624e
JA
3656`OPTIND'
3657 The index of the last option argument processed by the `getopts'
3658 builtin.
ccc6cda3 3659
bb70624e
JA
3660`PATH'
3661 A colon-separated list of directories in which the shell looks for
d3a24ed2
CR
3662 commands. A zero-length (null) directory name in the value of
3663 `PATH' indicates the current directory. A null directory name may
3664 appear as two adjacent colons, or as an initial or trailing colon.
ccc6cda3 3665
bb70624e
JA
3666`PS1'
3667 The primary prompt string. The default value is `\s-\v\$ '.
3668 *Note Printing a Prompt::, for the complete list of escape
3669 sequences that are expanded before `PS1' is displayed.
ccc6cda3 3670
bb70624e
JA
3671`PS2'
3672 The secondary prompt string. The default value is `> '.
ccc6cda3 3673
761783bf 3674
bb70624e
JA
3675\1f
3676File: bashref.info, Node: Bash Variables, Prev: Bourne Shell Variables, Up: Shell Variables
ccc6cda3 3677
37c41ab1
CR
36785.2 Bash Variables
3679==================
ccc6cda3 3680
37c41ab1 3681These variables are set or used by Bash, but other shells do not
bb70624e 3682normally treat them specially.
ccc6cda3 3683
bb70624e
JA
3684 A few variables used by Bash are described in different chapters:
3685variables for controlling the job control facilities (*note Job Control
28ef6c31 3686Variables::).
ccc6cda3 3687
bb70624e
JA
3688`BASH'
3689 The full pathname used to execute the current instance of Bash.
ccc6cda3 3690
d3a24ed2
CR
3691`BASH_ARGC'
3692 An array variable whose values are the number of parameters in each
3693 frame of the current bash execution call stack. The number of
3694 parameters to the current subroutine (shell function or script
3695 executed with `.' or `source') is at the top of the stack. When a
3696 subroutine is executed, the number of parameters passed is pushed
3697 onto `BASH_ARGC'.
3698
3699`BASH_ARGV'
3700 An array variable containing all of the parameters in the current
3701 bash execution call stack. The final parameter of the last
3702 subroutine call is at the top of the stack; the first parameter of
3703 the initial call is at the bottom. When a subroutine is executed,
3704 the parameters supplied are pushed onto `BASH_ARGV'.
3705
3706`BASH_COMMAND'
3707 The command currently being executed or about to be executed,
3708 unless the shell is executing a command as the result of a trap,
3709 in which case it is the command executing at the time of the trap.
3710
bb70624e
JA
3711`BASH_ENV'
3712 If this variable is set when Bash is invoked to execute a shell
3713 script, its value is expanded and used as the name of a startup
3714 file to read before executing the script. *Note Bash Startup
3715 Files::.
ccc6cda3 3716
d3a24ed2
CR
3717`BASH_EXECUTION_STRING'
3718 The command argument to the `-c' invocation option.
3719
3720`BASH_LINENO'
3721 An array variable whose members are the line numbers in source
3722 files corresponding to each member of FUNCNAME.
3723 `${BASH_LINENO[$i]}' is the line number in the source file where
22e63b05
CR
3724 `${FUNCNAME[$i]}' was called. The corresponding source file name
3725 is `${BASH_SOURCE[$i]}'. Use `LINENO' to obtain the current line
3726 number.
d3a24ed2 3727
5e13499c
CR
3728`BASH_REMATCH'
3729 An array variable whose members are assigned by the `=~' binary
3730 operator to the `[[' conditional command (*note Conditional
3731 Constructs::). The element with index 0 is the portion of the
3732 string matching the entire regular expression. The element with
3733 index N is the portion of the string matching the Nth
3734 parenthesized subexpression. This variable is read-only.
3735
d3a24ed2
CR
3736`BASH_SOURCE'
3737 An array variable whose members are the source filenames
3738 corresponding to the elements in the `FUNCNAME' array variable.
3739
3740`BASH_SUBSHELL'
3741 Incremented by one each time a subshell or subshell environment is
3742 spawned. The initial value is 0.
ccc6cda3 3743
bb70624e 3744`BASH_VERSINFO'
28ef6c31 3745 A readonly array variable (*note Arrays::) whose members hold
bb70624e
JA
3746 version information for this instance of Bash. The values
3747 assigned to the array members are as follows:
ccc6cda3 3748
bb70624e
JA
3749 `BASH_VERSINFO[0]'
3750 The major version number (the RELEASE).
ccc6cda3 3751
bb70624e
JA
3752 `BASH_VERSINFO[1]'
3753 The minor version number (the VERSION).
ccc6cda3 3754
bb70624e
JA
3755 `BASH_VERSINFO[2]'
3756 The patch level.
ccc6cda3 3757
bb70624e
JA
3758 `BASH_VERSINFO[3]'
3759 The build version.
ccc6cda3 3760
bb70624e
JA
3761 `BASH_VERSINFO[4]'
3762 The release status (e.g., BETA1).
ccc6cda3 3763
bb70624e
JA
3764 `BASH_VERSINFO[5]'
3765 The value of `MACHTYPE'.
ccc6cda3 3766
761783bf 3767
d3a24ed2
CR
3768`BASH_VERSION'
3769 The version number of the current instance of Bash.
3770
f73dda09
JA
3771`COLUMNS'
3772 Used by the `select' builtin command to determine the terminal
3773 width when printing selection lists. Automatically set upon
3774 receipt of a `SIGWINCH'.
bb70624e
JA
3775
3776`COMP_CWORD'
3777 An index into `${COMP_WORDS}' of the word containing the current
3778 cursor position. This variable is available only in shell
3779 functions invoked by the programmable completion facilities (*note
28ef6c31 3780 Programmable Completion::).
bb70624e
JA
3781
3782`COMP_LINE'
3783 The current command line. This variable is available only in
3784 shell functions and external commands invoked by the programmable
28ef6c31 3785 completion facilities (*note Programmable Completion::).
bb70624e
JA
3786
3787`COMP_POINT'
3788 The index of the current cursor position relative to the beginning
3789 of the current command. If the current cursor position is at the
3790 end of the current command, the value of this variable is equal to
3791 `${#COMP_LINE}'. This variable is available only in shell
3792 functions and external commands invoked by the programmable
28ef6c31 3793 completion facilities (*note Programmable Completion::).
bb70624e 3794
d3a24ed2
CR
3795`COMP_WORDBREAKS'
3796 The set of characters that the Readline library treats as word
3797 separators when performing word completion. If `COMP_WORDBREAKS'
3798 is unset, it loses its special properties, even if it is
3799 subsequently reset.
3800
f73dda09
JA
3801`COMP_WORDS'
3802 An array variable consisting of the individual words in the
3803 current command line. This variable is available only in shell
3804 functions invoked by the programmable completion facilities (*note
3805 Programmable Completion::).
3806
bb70624e
JA
3807`COMPREPLY'
3808 An array variable from which Bash reads the possible completions
3809 generated by a shell function invoked by the programmable
28ef6c31 3810 completion facility (*note Programmable Completion::).
ccc6cda3 3811
bb70624e
JA
3812`DIRSTACK'
3813 An array variable containing the current contents of the directory
3814 stack. Directories appear in the stack in the order they are
3815 displayed by the `dirs' builtin. Assigning to members of this
3816 array variable may be used to modify directories already in the
3817 stack, but the `pushd' and `popd' builtins must be used to add and
3818 remove directories. Assignment to this variable will not change
3819 the current directory. If `DIRSTACK' is unset, it loses its
3820 special properties, even if it is subsequently reset.
cce855bc 3821
d3a24ed2
CR
3822`EMACS'
3823 If Bash finds this variable in the environment when the shell
3824 starts with value `t', it assumes that the shell is running in an
3825 emacs shell buffer and disables line editing.
3826
bb70624e
JA
3827`EUID'
3828 The numeric effective user id of the current user. This variable
3829 is readonly.
cce855bc 3830
bb70624e
JA
3831`FCEDIT'
3832 The editor used as a default by the `-e' option to the `fc'
3833 builtin command.
ccc6cda3 3834
bb70624e
JA
3835`FIGNORE'
3836 A colon-separated list of suffixes to ignore when performing
3837 filename completion. A file name whose suffix matches one of the
3838 entries in `FIGNORE' is excluded from the list of matched file
3839 names. A sample value is `.o:~'
ccc6cda3 3840
f73dda09 3841`FUNCNAME'
d3a24ed2
CR
3842 An array variable containing the names of all shell functions
3843 currently in the execution call stack. The element with index 0
3844 is the name of any currently-executing shell function. The
3845 bottom-most element is "main". This variable exists only when a
3846 shell function is executing. Assignments to `FUNCNAME' have no
3847 effect and return an error status. If `FUNCNAME' is unset, it
3848 loses its special properties, even if it is subsequently reset.
f73dda09 3849
bb70624e
JA
3850`GLOBIGNORE'
3851 A colon-separated list of patterns defining the set of filenames to
3852 be ignored by filename expansion. If a filename matched by a
3853 filename expansion pattern also matches one of the patterns in
3854 `GLOBIGNORE', it is removed from the list of matches.
ccc6cda3 3855
bb70624e
JA
3856`GROUPS'
3857 An array variable containing the list of groups of which the
3858 current user is a member. Assignments to `GROUPS' have no effect
28ef6c31 3859 and return an error status. If `GROUPS' is unset, it loses its
bb70624e 3860 special properties, even if it is subsequently reset.
ccc6cda3 3861
bb70624e
JA
3862`histchars'
3863 Up to three characters which control history expansion, quick
28ef6c31
JA
3864 substitution, and tokenization (*note History Interaction::). The
3865 first character is the HISTORY EXPANSION character, that is, the
3866 character which signifies the start of a history expansion,
bb70624e
JA
3867 normally `!'. The second character is the character which
3868 signifies `quick substitution' when seen as the first character on
3869 a line, normally `^'. The optional third character is the
3870 character which indicates that the remainder of the line is a
3871 comment when found as the first character of a word, usually `#'.
3872 The history comment character causes history substitution to be
3873 skipped for the remaining words on the line. It does not
3874 necessarily cause the shell parser to treat the rest of the line
3875 as a comment.
cce855bc 3876
bb70624e
JA
3877`HISTCMD'
3878 The history number, or index in the history list, of the current
3879 command. If `HISTCMD' is unset, it loses its special properties,
3880 even if it is subsequently reset.
ccc6cda3 3881
bb70624e 3882`HISTCONTROL'
d3a24ed2
CR
3883 A colon-separated list of values controlling how commands are
3884 saved on the history list. If the list of values includes
3885 `ignorespace', lines which begin with a space character are not
3886 saved in the history list. A value of `ignoredups' causes lines
3887 which match the previous history entry to not be saved. A value
3888 of `ignoreboth' is shorthand for `ignorespace' and `ignoredups'.
3889 A value of `erasedups' causes all previous lines matching the
3890 current line to be removed from the history list before that line
3891 is saved. Any value not in the above list is ignored. If
3892 `HISTCONTROL' is unset, or does not include a valid value, all
3893 lines read by the shell parser are saved on the history list,
3894 subject to the value of `HISTIGNORE'. The second and subsequent
3895 lines of a multi-line compound command are not tested, and are
3896 added to the history regardless of the value of `HISTCONTROL'.
ccc6cda3 3897
f73dda09
JA
3898`HISTFILE'
3899 The name of the file to which the command history is saved. The
3900 default value is `~/.bash_history'.
3901
3902`HISTFILESIZE'
3903 The maximum number of lines contained in the history file. When
3904 this variable is assigned a value, the history file is truncated,
3905 if necessary, to contain no more than that number of lines. The
3906 history file is also truncated to this size after writing it when
3907 an interactive shell exits. The default value is 500.
3908
bb70624e
JA
3909`HISTIGNORE'
3910 A colon-separated list of patterns used to decide which command
3911 lines should be saved on the history list. Each pattern is
3912 anchored at the beginning of the line and must match the complete
3913 line (no implicit `*' is appended). Each pattern is tested
3914 against the line after the checks specified by `HISTCONTROL' are
3915 applied. In addition to the normal shell pattern matching
3916 characters, `&' matches the previous history line. `&' may be
3917 escaped using a backslash; the backslash is removed before
3918 attempting a match. The second and subsequent lines of a
3919 multi-line compound command are not tested, and are added to the
3920 history regardless of the value of `HISTIGNORE'.
cce855bc 3921
bb70624e
JA
3922 `HISTIGNORE' subsumes the function of `HISTCONTROL'. A pattern of
3923 `&' is identical to `ignoredups', and a pattern of `[ ]*' is
3924 identical to `ignorespace'. Combining these two patterns,
3925 separating them with a colon, provides the functionality of
3926 `ignoreboth'.
ccc6cda3 3927
bb70624e
JA
3928`HISTSIZE'
3929 The maximum number of commands to remember on the history list.
3930 The default value is 500.
b72432fd 3931
d3a24ed2
CR
3932`HISTTIMEFORMAT'
3933 If this variable is set and not null, its value is used as a
3934 format string for STRFTIME to print the time stamp associated with
3935 each history entry displayed by the `history' builtin. If this
3936 variable is set, time stamps are written to the history file so
3937 they may be preserved across shell sessions.
3938
bb70624e
JA
3939`HOSTFILE'
3940 Contains the name of a file in the same format as `/etc/hosts' that
3941 should be read when the shell needs to complete a hostname. The
3942 list of possible hostname completions may be changed while the
3943 shell is running; the next time hostname completion is attempted
3944 after the value is changed, Bash adds the contents of the new file
3945 to the existing list. If `HOSTFILE' is set, but has no value,
3946 Bash attempts to read `/etc/hosts' to obtain the list of possible
3947 hostname completions. When `HOSTFILE' is unset, the hostname list
3948 is cleared.
cce855bc 3949
bb70624e
JA
3950`HOSTNAME'
3951 The name of the current host.
cce855bc 3952
bb70624e
JA
3953`HOSTTYPE'
3954 A string describing the machine Bash is running on.
ccc6cda3 3955
bb70624e
JA
3956`IGNOREEOF'
3957 Controls the action of the shell on receipt of an `EOF' character
3958 as the sole input. If set, the value denotes the number of
3959 consecutive `EOF' characters that can be read as the first
3960 character on an input line before the shell will exit. If the
3961 variable exists but does not have a numeric value (or has no
3962 value) then the default is 10. If the variable does not exist,
3963 then `EOF' signifies the end of input to the shell. This is only
3964 in effect for interactive shells.
ccc6cda3 3965
bb70624e
JA
3966`INPUTRC'
3967 The name of the Readline initialization file, overriding the
3968 default of `~/.inputrc'.
ccc6cda3 3969
bb70624e
JA
3970`LANG'
3971 Used to determine the locale category for any category not
3972 specifically selected with a variable starting with `LC_'.
ccc6cda3 3973
bb70624e
JA
3974`LC_ALL'
3975 This variable overrides the value of `LANG' and any other `LC_'
3976 variable specifying a locale category.
cce855bc 3977
bb70624e
JA
3978`LC_COLLATE'
3979 This variable determines the collation order used when sorting the
3980 results of filename expansion, and determines the behavior of
3981 range expressions, equivalence classes, and collating sequences
3982 within filename expansion and pattern matching (*note Filename
28ef6c31 3983 Expansion::).
ccc6cda3 3984
bb70624e
JA
3985`LC_CTYPE'
3986 This variable determines the interpretation of characters and the
3987 behavior of character classes within filename expansion and pattern
28ef6c31 3988 matching (*note Filename Expansion::).
ccc6cda3 3989
bb70624e
JA
3990`LC_MESSAGES'
3991 This variable determines the locale used to translate double-quoted
28ef6c31 3992 strings preceded by a `$' (*note Locale Translation::).
ccc6cda3 3993
bb70624e
JA
3994`LC_NUMERIC'
3995 This variable determines the locale category used for number
3996 formatting.
ccc6cda3 3997
f73dda09
JA
3998`LINENO'
3999 The line number in the script or shell function currently
4000 executing.
4001
28ef6c31
JA
4002`LINES'
4003 Used by the `select' builtin command to determine the column length
4004 for printing selection lists. Automatically set upon receipt of a
4005 `SIGWINCH'.
4006
bb70624e
JA
4007`MACHTYPE'
4008 A string that fully describes the system type on which Bash is
4009 executing, in the standard GNU CPU-COMPANY-SYSTEM format.
ccc6cda3 4010
bb70624e
JA
4011`MAILCHECK'
4012 How often (in seconds) that the shell should check for mail in the
28ef6c31
JA
4013 files specified in the `MAILPATH' or `MAIL' variables. The
4014 default is 60 seconds. When it is time to check for mail, the
4015 shell does so before displaying the primary prompt. If this
4016 variable is unset, or set to a value that is not a number greater
4017 than or equal to zero, the shell disables mail checking.
ccc6cda3 4018
bb70624e
JA
4019`OLDPWD'
4020 The previous working directory as set by the `cd' builtin.
ccc6cda3 4021
bb70624e
JA
4022`OPTERR'
4023 If set to the value 1, Bash displays error messages generated by
4024 the `getopts' builtin command.
ccc6cda3 4025
bb70624e
JA
4026`OSTYPE'
4027 A string describing the operating system Bash is running on.
ccc6cda3 4028
bb70624e 4029`PIPESTATUS'
28ef6c31 4030 An array variable (*note Arrays::) containing a list of exit
bb70624e
JA
4031 status values from the processes in the most-recently-executed
4032 foreground pipeline (which may contain only a single command).
ccc6cda3 4033
f73dda09
JA
4034`POSIXLY_CORRECT'
4035 If this variable is in the environment when `bash' starts, the
4036 shell enters POSIX mode (*note Bash POSIX Mode::) before reading
4037 the startup files, as if the `--posix' invocation option had been
4038 supplied. If it is set while the shell is running, `bash' enables
4039 POSIX mode, as if the command
4040 `set -o posix'
f73dda09
JA
4041 had been executed.
4042
bb70624e
JA
4043`PPID'
4044 The process ID of the shell's parent process. This variable is
4045 readonly.
ccc6cda3 4046
bb70624e
JA
4047`PROMPT_COMMAND'
4048 If set, the value is interpreted as a command to execute before
4049 the printing of each primary prompt (`$PS1').
ccc6cda3 4050
bb70624e
JA
4051`PS3'
4052 The value of this variable is used as the prompt for the `select'
4053 command. If this variable is not set, the `select' command
4054 prompts with `#? '
ccc6cda3 4055
bb70624e
JA
4056`PS4'
4057 The value is the prompt printed before the command line is echoed
28ef6c31 4058 when the `-x' option is set (*note The Set Builtin::). The first
bb70624e
JA
4059 character of `PS4' is replicated multiple times, as necessary, to
4060 indicate multiple levels of indirection. The default is `+ '.
ccc6cda3 4061
bb70624e
JA
4062`PWD'
4063 The current working directory as set by the `cd' builtin.
ccc6cda3 4064
bb70624e
JA
4065`RANDOM'
4066 Each time this parameter is referenced, a random integer between 0
4067 and 32767 is generated. Assigning a value to this variable seeds
4068 the random number generator.
cce855bc 4069
bb70624e
JA
4070`REPLY'
4071 The default variable for the `read' builtin.
ccc6cda3 4072
bb70624e
JA
4073`SECONDS'
4074 This variable expands to the number of seconds since the shell was
4075 started. Assignment to this variable resets the count to the
4076 value assigned, and the expanded value becomes the value assigned
4077 plus the number of seconds since the assignment.
ccc6cda3 4078
9f422431
CR
4079`SHELL'
4080 The full pathname to the shell is kept in this environment
4081 variable. If it is not set when the shell starts, Bash assigns to
4082 it the full pathname of the current user's login shell.
4083
bb70624e
JA
4084`SHELLOPTS'
4085 A colon-separated list of enabled shell options. Each word in the
4086 list is a valid argument for the `-o' option to the `set' builtin
28ef6c31 4087 command (*note The Set Builtin::). The options appearing in
bb70624e
JA
4088 `SHELLOPTS' are those reported as `on' by `set -o'. If this
4089 variable is in the environment when Bash starts up, each shell
4090 option in the list will be enabled before reading any startup
4091 files. This variable is readonly.
ccc6cda3 4092
bb70624e
JA
4093`SHLVL'
4094 Incremented by one each time a new instance of Bash is started.
4095 This is intended to be a count of how deeply your Bash shells are
4096 nested.
cce855bc 4097
bb70624e
JA
4098`TIMEFORMAT'
4099 The value of this parameter is used as a format string specifying
4100 how the timing information for pipelines prefixed with the `time'
4101 reserved word should be displayed. The `%' character introduces an
4102 escape sequence that is expanded to a time value or other
4103 information. The escape sequences and their meanings are as
4104 follows; the braces denote optional portions.
cce855bc 4105
bb70624e
JA
4106 `%%'
4107 A literal `%'.
ccc6cda3 4108
bb70624e
JA
4109 `%[P][l]R'
4110 The elapsed time in seconds.
ccc6cda3 4111
bb70624e
JA
4112 `%[P][l]U'
4113 The number of CPU seconds spent in user mode.
ccc6cda3 4114
bb70624e
JA
4115 `%[P][l]S'
4116 The number of CPU seconds spent in system mode.
ccc6cda3 4117
bb70624e
JA
4118 `%P'
4119 The CPU percentage, computed as (%U + %S) / %R.
ccc6cda3 4120
bb70624e
JA
4121 The optional P is a digit specifying the precision, the number of
4122 fractional digits after a decimal point. A value of 0 causes no
4123 decimal point or fraction to be output. At most three places
4124 after the decimal point may be specified; values of P greater than
4125 3 are changed to 3. If P is not specified, the value 3 is used.
ccc6cda3 4126
bb70624e
JA
4127 The optional `l' specifies a longer format, including minutes, of
4128 the form MMmSS.FFs. The value of P determines whether or not the
4129 fraction is included.
ccc6cda3 4130
bb70624e
JA
4131 If this variable is not set, Bash acts as if it had the value
4132 `$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS''
4133 If the value is null, no timing information is displayed. A
4134 trailing newline is added when the format string is displayed.
ccc6cda3 4135
bb70624e 4136`TMOUT'
7117c2d2
JA
4137 If set to a value greater than zero, `TMOUT' is treated as the
4138 default timeout for the `read' builtin (*note Bash Builtins::).
4139 The `select' command (*note Conditional Constructs::) terminates
4140 if input does not arrive after `TMOUT' seconds when input is coming
4141 from a terminal.
4142
4143 In an interative shell, the value is interpreted as the number of
4144 seconds to wait for input after issuing the primary prompt when
4145 the shell is interactive. Bash terminates after that number of
4146 seconds if input does not arrive.
ccc6cda3 4147
bb70624e
JA
4148`UID'
4149 The numeric real user id of the current user. This variable is
4150 readonly.
ccc6cda3 4151
761783bf 4152
bb70624e
JA
4153\1f
4154File: bashref.info, Node: Bash Features, Next: Job Control, Prev: Shell Variables, Up: Top
ccc6cda3 4155
37c41ab1
CR
41566 Bash Features
4157***************
ccc6cda3 4158
37c41ab1 4159This section describes features unique to Bash.
ccc6cda3 4160
bb70624e 4161* Menu:
ccc6cda3 4162
bb70624e
JA
4163* Invoking Bash:: Command line options that you can give
4164 to Bash.
4165* Bash Startup Files:: When and how Bash executes scripts.
4166* Interactive Shells:: What an interactive shell is.
4167* Bash Conditional Expressions:: Primitives used in composing expressions for
4168 the `test' builtin.
4169* Shell Arithmetic:: Arithmetic on shell variables.
4170* Aliases:: Substituting one command for another.
4171* Arrays:: Array Variables.
4172* The Directory Stack:: History of visited directories.
4173* Printing a Prompt:: Controlling the PS1 string.
4174* The Restricted Shell:: A more controlled mode of shell execution.
4175* Bash POSIX Mode:: Making Bash behave more closely to what
4176 the POSIX standard specifies.
ccc6cda3 4177
bb70624e
JA
4178\1f
4179File: bashref.info, Node: Invoking Bash, Next: Bash Startup Files, Up: Bash Features
ccc6cda3 4180
37c41ab1
CR
41816.1 Invoking Bash
4182=================
ccc6cda3 4183
f73dda09
JA
4184 bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] [ARGUMENT ...]
4185 bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] -c STRING [ARGUMENT ...]
4186 bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] [ARGUMENT ...]
ccc6cda3 4187
bb70624e 4188 In addition to the single-character shell command-line options
28ef6c31 4189(*note The Set Builtin::), there are several multi-character options
bb70624e 4190that you can use. These options must appear on the command line before
7117c2d2 4191the single-character options to be recognized.
ccc6cda3 4192
d3a24ed2
CR
4193`--debugger'
4194 Arrange for the debugger profile to be executed before the shell
4195 starts. Turns on extended debugging mode (see *Note Bash
4196 Builtins:: for a description of the `extdebug' option to the
4197 `shopt' builtin) and shell function tracing (see *Note The Set
4198 Builtin:: for a description of the `-o functrace' option).
4199
bb70624e
JA
4200`--dump-po-strings'
4201 A list of all double-quoted strings preceded by `$' is printed on
4202 the standard ouput in the GNU `gettext' PO (portable object) file
4203 format. Equivalent to `-D' except for the output format.
ccc6cda3 4204
bb70624e
JA
4205`--dump-strings'
4206 Equivalent to `-D'.
ccc6cda3 4207
bb70624e
JA
4208`--help'
4209 Display a usage message on standard output and exit sucessfully.
ccc6cda3 4210
28ef6c31
JA
4211`--init-file FILENAME'
4212`--rcfile FILENAME'
4213 Execute commands from FILENAME (instead of `~/.bashrc') in an
4214 interactive shell.
4215
bb70624e 4216`--login'
7117c2d2 4217 Equivalent to `-l'.
ccc6cda3 4218
bb70624e 4219`--noediting'
28ef6c31 4220 Do not use the GNU Readline library (*note Command Line Editing::)
bb70624e 4221 to read command lines when the shell is interactive.
ccc6cda3 4222
bb70624e
JA
4223`--noprofile'
4224 Don't load the system-wide startup file `/etc/profile' or any of
4225 the personal initialization files `~/.bash_profile',
4226 `~/.bash_login', or `~/.profile' when Bash is invoked as a login
4227 shell.
ccc6cda3 4228
bb70624e
JA
4229`--norc'
4230 Don't read the `~/.bashrc' initialization file in an interactive
4231 shell. This is on by default if the shell is invoked as `sh'.
ccc6cda3 4232
bb70624e
JA
4233`--posix'
4234 Change the behavior of Bash where the default operation differs
4235 from the POSIX 1003.2 standard to match the standard. This is
4236 intended to make Bash behave as a strict superset of that
4237 standard. *Note Bash POSIX Mode::, for a description of the Bash
4238 POSIX mode.
ccc6cda3 4239
bb70624e 4240`--restricted'
28ef6c31 4241 Make the shell a restricted shell (*note The Restricted Shell::).
ccc6cda3 4242
bb70624e
JA
4243`--verbose'
4244 Equivalent to `-v'. Print shell input lines as they're read.
ccc6cda3 4245
bb70624e
JA
4246`--version'
4247 Show version information for this instance of Bash on the standard
4248 output and exit successfully.
ccc6cda3 4249
761783bf 4250
bb70624e
JA
4251 There are several single-character options that may be supplied at
4252invocation which are not available with the `set' builtin.
ccc6cda3 4253
bb70624e
JA
4254`-c STRING'
4255 Read and execute commands from STRING after processing the
4256 options, then exit. Any remaining arguments are assigned to the
4257 positional parameters, starting with `$0'.
ccc6cda3 4258
bb70624e
JA
4259`-i'
4260 Force the shell to run interactively. Interactive shells are
4261 described in *Note Interactive Shells::.
ccc6cda3 4262
7117c2d2
JA
4263`-l'
4264 Make this shell act as if it had been directly invoked by login.
4265 When the shell is interactive, this is equivalent to starting a
4266 login shell with `exec -l bash'. When the shell is not
4267 interactive, the login shell startup files will be executed.
4268 `exec bash -l' or `exec bash --login' will replace the current
4269 shell with a Bash login shell. *Note Bash Startup Files::, for a
4270 description of the special behavior of a login shell.
4271
bb70624e 4272`-r'
28ef6c31 4273 Make the shell a restricted shell (*note The Restricted Shell::).
ccc6cda3 4274
bb70624e
JA
4275`-s'
4276 If this option is present, or if no arguments remain after option
4277 processing, then commands are read from the standard input. This
4278 option allows the positional parameters to be set when invoking an
4279 interactive shell.
ccc6cda3 4280
bb70624e
JA
4281`-D'
4282 A list of all double-quoted strings preceded by `$' is printed on
4283 the standard ouput. These are the strings that are subject to
4284 language translation when the current locale is not `C' or `POSIX'
28ef6c31 4285 (*note Locale Translation::). This implies the `-n' option; no
bb70624e 4286 commands will be executed.
ccc6cda3 4287
f73dda09
JA
4288`[-+]O [SHOPT_OPTION]'
4289 SHOPT_OPTION is one of the shell options accepted by the `shopt'
4290 builtin (*note Shell Builtin Commands::). If SHOPT_OPTION is
4291 present, `-O' sets the value of that option; `+O' unsets it. If
4292 SHOPT_OPTION is not supplied, the names and values of the shell
4293 options accepted by `shopt' are printed on the standard output.
4294 If the invocation option is `+O', the output is displayed in a
4295 format that may be reused as input.
4296
bb70624e
JA
4297`--'
4298 A `--' signals the end of options and disables further option
4299 processing. Any arguments after the `--' are treated as filenames
4300 and arguments.
ccc6cda3 4301
761783bf 4302
f73dda09
JA
4303 A _login_ shell is one whose first character of argument zero is
4304`-', or one invoked with the `--login' option.
4305
28ef6c31 4306 An _interactive_ shell is one started without non-option arguments,
bb70624e
JA
4307unless `-s' is specified, without specifying the `-c' option, and whose
4308input and output are both connected to terminals (as determined by
4309`isatty(3)'), or one started with the `-i' option. *Note Interactive
28ef6c31 4310Shells::, for more information.
ccc6cda3 4311
bb70624e
JA
4312 If arguments remain after option processing, and neither the `-c'
4313nor the `-s' option has been supplied, the first argument is assumed to
28ef6c31
JA
4314be the name of a file containing shell commands (*note Shell Scripts::).
4315When Bash is invoked in this fashion, `$0' is set to the name of the
4316file, and the positional parameters are set to the remaining arguments.
4317Bash reads and executes commands from this file, then exits. Bash's
4318exit status is the exit status of the last command executed in the
4319script. If no commands are executed, the exit status is 0.
ccc6cda3 4320
bb70624e
JA
4321\1f
4322File: bashref.info, Node: Bash Startup Files, Next: Interactive Shells, Prev: Invoking Bash, Up: Bash Features
ccc6cda3 4323
37c41ab1
CR
43246.2 Bash Startup Files
4325======================
ccc6cda3 4326
37c41ab1
CR
4327This section describs how Bash executes its startup files. If any of
4328the files exist but cannot be read, Bash reports an error. Tildes are
4329expanded in file names as described above under Tilde Expansion (*note
4330Tilde Expansion::).
ccc6cda3 4331
bb70624e 4332 Interactive shells are described in *Note Interactive Shells::.
ccc6cda3 4333
bb70624e
JA
4334Invoked as an interactive login shell, or with `--login'
4335........................................................
cce855bc 4336
37c41ab1 4337When Bash is invoked as an interactive login shell, or as a
bb70624e
JA
4338non-interactive shell with the `--login' option, it first reads and
4339executes commands from the file `/etc/profile', if that file exists.
4340After reading that file, it looks for `~/.bash_profile',
4341`~/.bash_login', and `~/.profile', in that order, and reads and
4342executes commands from the first one that exists and is readable. The
4343`--noprofile' option may be used when the shell is started to inhibit
4344this behavior.
ccc6cda3 4345
bb70624e
JA
4346 When a login shell exits, Bash reads and executes commands from the
4347file `~/.bash_logout', if it exists.
ccc6cda3 4348
bb70624e
JA
4349Invoked as an interactive non-login shell
4350.........................................
ccc6cda3 4351
37c41ab1 4352When an interactive shell that is not a login shell is started, Bash
bb70624e
JA
4353reads and executes commands from `~/.bashrc', if that file exists.
4354This may be inhibited by using the `--norc' option. The `--rcfile
4355FILE' option will force Bash to read and execute commands from FILE
4356instead of `~/.bashrc'.
ccc6cda3 4357
bb70624e
JA
4358 So, typically, your `~/.bash_profile' contains the line
4359 `if [ -f ~/.bashrc ]; then . ~/.bashrc; fi'
37c41ab1 4360 after (or before) any login-specific initializations.
ccc6cda3 4361
bb70624e
JA
4362Invoked non-interactively
4363.........................
ccc6cda3 4364
37c41ab1 4365When Bash is started non-interactively, to run a shell script, for
bb70624e
JA
4366example, it looks for the variable `BASH_ENV' in the environment,
4367expands its value if it appears there, and uses the expanded value as
4368the name of a file to read and execute. Bash behaves as if the
4369following command were executed:
4370 `if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi'
37c41ab1
CR
4371 but the value of the `PATH' variable is not used to search for the
4372file name.
ccc6cda3 4373
28ef6c31
JA
4374 As noted above, if a non-interactive shell is invoked with the
4375`--login' option, Bash attempts to read and execute commands from the
4376login shell startup files.
4377
bb70624e
JA
4378Invoked with name `sh'
4379......................
ccc6cda3 4380
37c41ab1 4381If Bash is invoked with the name `sh', it tries to mimic the startup
bb70624e
JA
4382behavior of historical versions of `sh' as closely as possible, while
4383conforming to the POSIX standard as well.
ccc6cda3 4384
bb70624e
JA
4385 When invoked as an interactive login shell, or as a non-interactive
4386shell with the `--login' option, it first attempts to read and execute
4387commands from `/etc/profile' and `~/.profile', in that order. The
4388`--noprofile' option may be used to inhibit this behavior. When
4389invoked as an interactive shell with the name `sh', Bash looks for the
4390variable `ENV', expands its value if it is defined, and uses the
4391expanded value as the name of a file to read and execute. Since a
4392shell invoked as `sh' does not attempt to read and execute commands
4393from any other startup files, the `--rcfile' option has no effect. A
4394non-interactive shell invoked with the name `sh' does not attempt to
4395read any other startup files.
ccc6cda3 4396
bb70624e
JA
4397 When invoked as `sh', Bash enters POSIX mode after the startup files
4398are read.
b72432fd 4399
bb70624e
JA
4400Invoked in POSIX mode
4401.....................
ccc6cda3 4402
37c41ab1
CR
4403When Bash is started in POSIX mode, as with the `--posix' command line
4404option, it follows the POSIX standard for startup files. In this mode,
4405interactive shells expand the `ENV' variable and commands are read and
4406executed from the file whose name is the expanded value. No other
4407startup files are read.
ccc6cda3 4408
bb70624e
JA
4409Invoked by remote shell daemon
4410..............................
ccc6cda3 4411
37c41ab1 4412Bash attempts to determine when it is being run by the remote shell
bb70624e
JA
4413daemon, usually `rshd'. If Bash determines it is being run by rshd, it
4414reads and executes commands from `~/.bashrc', if that file exists and
4415is readable. It will not do this if invoked as `sh'. The `--norc'
4416option may be used to inhibit this behavior, and the `--rcfile' option
4417may be used to force another file to be read, but `rshd' does not
4418generally invoke the shell with those options or allow them to be
4419specified.
ccc6cda3 4420
bb70624e
JA
4421Invoked with unequal effective and real UID/GIDs
4422................................................
4423
37c41ab1
CR
4424If Bash is started with the effective user (group) id not equal to the
4425real user (group) id, and the `-p' option is not supplied, no startup
4426files are read, shell functions are not inherited from the environment,
4427the `SHELLOPTS' variable, if it appears in the environment, is ignored,
4428and the effective user id is set to the real user id. If the `-p'
4429option is supplied at invocation, the startup behavior is the same, but
4430the effective user id is not reset.
bb70624e
JA
4431
4432\1f
4433File: bashref.info, Node: Interactive Shells, Next: Bash Conditional Expressions, Prev: Bash Startup Files, Up: Bash Features
4434
37c41ab1
CR
44356.3 Interactive Shells
4436======================
bb70624e
JA
4437
4438* Menu:
4439
4440* What is an Interactive Shell?:: What determines whether a shell is Interactive.
4441* Is this Shell Interactive?:: How to tell if a shell is interactive.
4442* Interactive Shell Behavior:: What changes in a interactive shell?
4443
4444\1f
4445File: bashref.info, Node: What is an Interactive Shell?, Next: Is this Shell Interactive?, Up: Interactive Shells
4446
37c41ab1
CR
44476.3.1 What is an Interactive Shell?
4448-----------------------------------
bb70624e 4449
37c41ab1 4450An interactive shell is one started without non-option arguments,
bb70624e 4451unless `-s' is specified, without specifiying the `-c' option, and
56299fa5
CR
4452whose input and error output are both connected to terminals (as
4453determined by `isatty(3)'), or one started with the `-i' option.
bb70624e
JA
4454
4455 An interactive shell generally reads from and writes to a user's
4456terminal.
4457
4458 The `-s' invocation option may be used to set the positional
4459parameters when an interactive shell is started.
4460
4461\1f
4462File: bashref.info, Node: Is this Shell Interactive?, Next: Interactive Shell Behavior, Prev: What is an Interactive Shell?, Up: Interactive Shells
4463
37c41ab1
CR
44646.3.2 Is this Shell Interactive?
4465--------------------------------
bb70624e 4466
37c41ab1 4467To determine within a startup script whether or not Bash is running
bb70624e
JA
4468interactively, test the value of the `-' special parameter. It
4469contains `i' when the shell is interactive. For example:
4470
4471 case "$-" in
4472 *i*) echo This shell is interactive ;;
4473 *) echo This shell is not interactive ;;
4474 esac
4475
28ef6c31
JA
4476 Alternatively, startup scripts may examine the variable `PS1'; it is
4477unset in non-interactive shells, and set in interactive shells. Thus:
bb70624e
JA
4478
4479 if [ -z "$PS1" ]; then
4480 echo This shell is not interactive
4481 else
4482 echo This shell is interactive
4483 fi
4484
4485\1f
4486File: bashref.info, Node: Interactive Shell Behavior, Prev: Is this Shell Interactive?, Up: Interactive Shells
4487
37c41ab1
CR
44886.3.3 Interactive Shell Behavior
4489--------------------------------
bb70624e 4490
37c41ab1 4491When the shell is running interactively, it changes its behavior in
bb70624e
JA
4492several ways.
4493
4494 1. Startup files are read and executed as described in *Note Bash
4495 Startup Files::.
4496
28ef6c31 4497 2. Job Control (*note Job Control::) is enabled by default. When job
bb70624e
JA
4498 control is in effect, Bash ignores the keyboard-generated job
4499 control signals `SIGTTIN', `SIGTTOU', and `SIGTSTP'.
4500
28ef6c31
JA
4501 3. Bash expands and displays `PS1' before reading the first line of a
4502 command, and expands and displays `PS2' before reading the second
4503 and subsequent lines of a multi-line command.
bb70624e
JA
4504
4505 4. Bash executes the value of the `PROMPT_COMMAND' variable as a
4506 command before printing the primary prompt, `$PS1' (*note Bash
28ef6c31 4507 Variables::).
bb70624e 4508
28ef6c31 4509 5. Readline (*note Command Line Editing::) is used to read commands
bb70624e
JA
4510 from the user's terminal.
4511
4512 6. Bash inspects the value of the `ignoreeof' option to `set -o'
4513 instead of exiting immediately when it receives an `EOF' on its
28ef6c31 4514 standard input when reading a command (*note The Set Builtin::).
bb70624e 4515
28ef6c31
JA
4516 7. Command history (*note Bash History Facilities::) and history
4517 expansion (*note History Interaction::) are enabled by default.
bb70624e
JA
4518 Bash will save the command history to the file named by `$HISTFILE'
4519 when an interactive shell exits.
4520
28ef6c31 4521 8. Alias expansion (*note Aliases::) is performed by default.
bb70624e
JA
4522
4523 9. In the absence of any traps, Bash ignores `SIGTERM' (*note
28ef6c31 4524 Signals::).
bb70624e
JA
4525
4526 10. In the absence of any traps, `SIGINT' is caught and handled
28ef6c31 4527 ((*note Signals::). `SIGINT' will interrupt some shell builtins.
bb70624e
JA
4528
4529 11. An interactive login shell sends a `SIGHUP' to all jobs on exit if
28ef6c31 4530 the `hupoxexit' shell option has been enabled (*note Signals::).
bb70624e
JA
4531
4532 12. The `-n' invocation option is ignored, and `set -n' has no effect
28ef6c31 4533 (*note The Set Builtin::).
bb70624e
JA
4534
4535 13. Bash will check for mail periodically, depending on the values of
4536 the `MAIL', `MAILPATH', and `MAILCHECK' shell variables (*note
28ef6c31 4537 Bash Variables::).
bb70624e
JA
4538
4539 14. Expansion errors due to references to unbound shell variables after
4540 `set -u' has been enabled will not cause the shell to exit (*note
28ef6c31 4541 The Set Builtin::).
bb70624e
JA
4542
4543 15. The shell will not exit on expansion errors caused by VAR being
4544 unset or null in `${VAR:?WORD}' expansions (*note Shell Parameter
28ef6c31 4545 Expansion::).
bb70624e
JA
4546
4547 16. Redirection errors encountered by shell builtins will not cause the
4548 shell to exit.
4549
4550 17. When running in POSIX mode, a special builtin returning an error
28ef6c31 4551 status will not cause the shell to exit (*note Bash POSIX Mode::).
bb70624e
JA
4552
4553 18. A failed `exec' will not cause the shell to exit (*note Bourne
28ef6c31 4554 Shell Builtins::).
bb70624e
JA
4555
4556 19. Parser syntax errors will not cause the shell to exit.
4557
4558 20. Simple spelling correction for directory arguments to the `cd'
4559 builtin is enabled by default (see the description of the `cdspell'
4560 option to the `shopt' builtin in *Note Bash Builtins::).
4561
4562 21. The shell will check the value of the `TMOUT' variable and exit if
4563 a command is not read within the specified number of seconds after
28ef6c31 4564 printing `$PS1' (*note Bash Variables::).
bb70624e
JA
4565
4566
4567\1f
4568File: bashref.info, Node: Bash Conditional Expressions, Next: Shell Arithmetic, Prev: Interactive Shells, Up: Bash Features
4569
37c41ab1
CR
45706.4 Bash Conditional Expressions
4571================================
bb70624e 4572
37c41ab1
CR
4573Conditional expressions are used by the `[[' compound command and the
4574`test' and `[' builtin commands.
bb70624e
JA
4575
4576 Expressions may be unary or binary. Unary expressions are often
4577used to examine the status of a file. There are string operators and
4578numeric comparison operators as well. If the FILE argument to one of
4579the primaries is of the form `/dev/fd/N', then file descriptor N is
4580checked. If the FILE argument to one of the primaries is one of
4581`/dev/stdin', `/dev/stdout', or `/dev/stderr', file descriptor 0, 1, or
45822, respectively, is checked.
4583
37c41ab1
CR
4584 Unless otherwise specified, primaries that operate on files follow
4585symbolic links and operate on the target of the link, rather than the
4586link itself.
4587
bb70624e
JA
4588`-a FILE'
4589 True if FILE exists.
4590
4591`-b FILE'
4592 True if FILE exists and is a block special file.
4593
4594`-c FILE'
4595 True if FILE exists and is a character special file.
4596
4597`-d FILE'
4598 True if FILE exists and is a directory.
4599
4600`-e FILE'
4601 True if FILE exists.
4602
4603`-f FILE'
4604 True if FILE exists and is a regular file.
4605
4606`-g FILE'
4607 True if FILE exists and its set-group-id bit is set.
4608
4609`-h FILE'
4610 True if FILE exists and is a symbolic link.
4611
4612`-k FILE'
4613 True if FILE exists and its "sticky" bit is set.
4614
4615`-p FILE'
4616 True if FILE exists and is a named pipe (FIFO).
4617
4618`-r FILE'
4619 True if FILE exists and is readable.
4620
4621`-s FILE'
4622 True if FILE exists and has a size greater than zero.
4623
4624`-t FD'
4625 True if file descriptor FD is open and refers to a terminal.
ccc6cda3
JA
4626
4627`-u FILE'
4628 True if FILE exists and its set-user-id bit is set.
4629
4630`-w FILE'
4631 True if FILE exists and is writable.
4632
4633`-x FILE'
4634 True if FILE exists and is executable.
4635
4636`-O FILE'
4637 True if FILE exists and is owned by the effective user id.
4638
4639`-G FILE'
4640 True if FILE exists and is owned by the effective group id.
4641
cce855bc
JA
4642`-L FILE'
4643 True if FILE exists and is a symbolic link.
4644
4645`-S FILE'
4646 True if FILE exists and is a socket.
4647
4648`-N FILE'
4649 True if FILE exists and has been modified since it was last read.
4650
ccc6cda3 4651`FILE1 -nt FILE2'
7117c2d2
JA
4652 True if FILE1 is newer (according to modification date) than
4653 FILE2, or if FILE1 exists and FILE2 does not.
ccc6cda3
JA
4654
4655`FILE1 -ot FILE2'
7117c2d2
JA
4656 True if FILE1 is older than FILE2, or if FILE2 exists and FILE1
4657 does not.
ccc6cda3
JA
4658
4659`FILE1 -ef FILE2'
7117c2d2 4660 True if FILE1 and FILE2 refer to the same device and inode numbers.
ccc6cda3
JA
4661
4662`-o OPTNAME'
4663 True if shell option OPTNAME is enabled. The list of options
4664 appears in the description of the `-o' option to the `set' builtin
28ef6c31 4665 (*note The Set Builtin::).
ccc6cda3
JA
4666
4667`-z STRING'
4668 True if the length of STRING is zero.
4669
4670`-n STRING'
4671`STRING'
4672 True if the length of STRING is non-zero.
4673
cce855bc 4674`STRING1 == STRING2'
7117c2d2
JA
4675 True if the strings are equal. `=' may be used in place of `=='
4676 for strict POSIX compliance.
ccc6cda3
JA
4677
4678`STRING1 != STRING2'
4679 True if the strings are not equal.
4680
4681`STRING1 < STRING2'
cce855bc
JA
4682 True if STRING1 sorts before STRING2 lexicographically in the
4683 current locale.
ccc6cda3
JA
4684
4685`STRING1 > STRING2'
cce855bc
JA
4686 True if STRING1 sorts after STRING2 lexicographically in the
4687 current locale.
ccc6cda3
JA
4688
4689`ARG1 OP ARG2'
4690 `OP' is one of `-eq', `-ne', `-lt', `-le', `-gt', or `-ge'. These
4691 arithmetic binary operators return true if ARG1 is equal to, not
4692 equal to, less than, less than or equal to, greater than, or
4693 greater than or equal to ARG2, respectively. ARG1 and ARG2 may be
4694 positive or negative integers.
4695
761783bf 4696
ccc6cda3 4697\1f
bb70624e 4698File: bashref.info, Node: Shell Arithmetic, Next: Aliases, Prev: Bash Conditional Expressions, Up: Bash Features
ccc6cda3 4699
37c41ab1
CR
47006.5 Shell Arithmetic
4701====================
ccc6cda3 4702
37c41ab1
CR
4703The shell allows arithmetic expressions to be evaluated, as one of the
4704shell expansions or by the `let' and the `-i' option to the `declare'
4705builtins.
ccc6cda3 4706
7117c2d2
JA
4707 Evaluation is done in fixed-width integers with no check for
4708overflow, though division by 0 is trapped and flagged as an error. The
d3a24ed2
CR
4709operators and their precedence, associativity, and values are the same
4710as in the C language. The following list of operators is grouped into
4711levels of equal-precedence operators. The levels are listed in order
4712of decreasing precedence.
cce855bc 4713
bb70624e
JA
4714`ID++ ID--'
4715 variable post-increment and post-decrement
d166f048 4716
bb70624e
JA
4717`++ID --ID'
4718 variable pre-increment and pre-decrement
ccc6cda3 4719
bb70624e
JA
4720`- +'
4721 unary minus and plus
ccc6cda3 4722
bb70624e
JA
4723`! ~'
4724 logical and bitwise negation
ccc6cda3 4725
bb70624e
JA
4726`**'
4727 exponentiation
ccc6cda3 4728
bb70624e
JA
4729`* / %'
4730 multiplication, division, remainder
ccc6cda3 4731
bb70624e
JA
4732`+ -'
4733 addition, subtraction
ccc6cda3 4734
bb70624e
JA
4735`<< >>'
4736 left and right bitwise shifts
cce855bc 4737
bb70624e
JA
4738`<= >= < >'
4739 comparison
cce855bc 4740
bb70624e
JA
4741`== !='
4742 equality and inequality
cce855bc 4743
bb70624e
JA
4744`&'
4745 bitwise AND
cce855bc 4746
bb70624e
JA
4747`^'
4748 bitwise exclusive OR
cce855bc 4749
bb70624e
JA
4750`|'
4751 bitwise OR
cce855bc 4752
bb70624e
JA
4753`&&'
4754 logical AND
ccc6cda3 4755
bb70624e
JA
4756`||'
4757 logical OR
ccc6cda3 4758
bb70624e 4759`expr ? expr : expr'
d3a24ed2 4760 conditional operator
cce855bc 4761
bb70624e
JA
4762`= *= /= %= += -= <<= >>= &= ^= |='
4763 assignment
ccc6cda3 4764
bb70624e
JA
4765`expr1 , expr2'
4766 comma
ccc6cda3 4767
bb70624e
JA
4768 Shell variables are allowed as operands; parameter expansion is
4769performed before the expression is evaluated. Within an expression,
4770shell variables may also be referenced by name without using the
d3a24ed2
CR
4771parameter expansion syntax. A shell variable that is null or unset
4772evaluates to 0 when referenced by name without using the parameter
4773expansion syntax. The value of a variable is evaluated as an
4774arithmetic expression when it is referenced, or when a variable which
4775has been given the INTEGER attribute using `declare -i' is assigned a
4776value. A null value evaluates to 0. A shell variable need not have
4777its integer attribute turned on to be used in an expression.
ccc6cda3 4778
bb70624e
JA
4779 Constants with a leading 0 are interpreted as octal numbers. A
4780leading `0x' or `0X' denotes hexadecimal. Otherwise, numbers take the
4781form [BASE`#']N, where BASE is a decimal number between 2 and 64
4782representing the arithmetic base, and N is a number in that base. If
4783BASE`#' is omitted, then base 10 is used. The digits greater than 9
f73dda09
JA
4784are represented by the lowercase letters, the uppercase letters, `@',
4785and `_', in that order. If BASE is less than or equal to 36, lowercase
bb70624e
JA
4786and uppercase letters may be used interchangably to represent numbers
4787between 10 and 35.
ccc6cda3 4788
bb70624e
JA
4789 Operators are evaluated in order of precedence. Sub-expressions in
4790parentheses are evaluated first and may override the precedence rules
4791above.
ccc6cda3 4792
bb70624e
JA
4793\1f
4794File: bashref.info, Node: Aliases, Next: Arrays, Prev: Shell Arithmetic, Up: Bash Features
ccc6cda3 4795
37c41ab1
CR
47966.6 Aliases
4797===========
ccc6cda3 4798
37c41ab1
CR
4799ALIASES allow a string to be substituted for a word when it is used as
4800the first word of a simple command. The shell maintains a list of
bb70624e 4801aliases that may be set and unset with the `alias' and `unalias'
cce855bc
JA
4802builtin commands.
4803
4804 The first word of each simple command, if unquoted, is checked to see
4805if it has an alias. If so, that word is replaced by the text of the
de8913bd
CR
4806alias. The characters `/', `$', ``', `=' and any of the shell
4807metacharacters or quoting characters listed above may not appear in an
4808alias name. The replacement text may contain any valid shell input,
4809including shell metacharacters. The first word of the replacement text
4810is tested for aliases, but a word that is identical to an alias being
4811expanded is not expanded a second time. This means that one may alias
4812`ls' to `"ls -F"', for instance, and Bash does not try to recursively
4813expand the replacement text. If the last character of the alias value
4814is a space or tab character, then the next command word following the
4815alias is also checked for alias expansion.
cce855bc
JA
4816
4817 Aliases are created and listed with the `alias' command, and removed
4818with the `unalias' command.
4819
4820 There is no mechanism for using arguments in the replacement text,
4821as in `csh'. If arguments are needed, a shell function should be used
28ef6c31 4822(*note Shell Functions::).
cce855bc
JA
4823
4824 Aliases are not expanded when the shell is not interactive, unless
4825the `expand_aliases' shell option is set using `shopt' (*note Bash
28ef6c31 4826Builtins::).
ccc6cda3 4827
cce855bc
JA
4828 The rules concerning the definition and use of aliases are somewhat
4829confusing. Bash always reads at least one complete line of input
4830before executing any of the commands on that line. Aliases are
4831expanded when a command is read, not when it is executed. Therefore, an
4832alias definition appearing on the same line as another command does not
4833take effect until the next line of input is read. The commands
4834following the alias definition on that line are not affected by the new
4835alias. This behavior is also an issue when functions are executed.
4836Aliases are expanded when a function definition is read, not when the
4837function is executed, because a function definition is itself a
4838compound command. As a consequence, aliases defined in a function are
4839not available until after that function is executed. To be safe,
4840always put alias definitions on a separate line, and do not use `alias'
4841in compound commands.
ccc6cda3 4842
bb70624e 4843 For almost every purpose, shell functions are preferred over aliases.
ccc6cda3
JA
4844
4845\1f
cce855bc 4846File: bashref.info, Node: Arrays, Next: The Directory Stack, Prev: Aliases, Up: Bash Features
ccc6cda3 4847
37c41ab1
CR
48486.7 Arrays
4849==========
ccc6cda3 4850
37c41ab1 4851Bash provides one-dimensional array variables. Any variable may be
ccc6cda3
JA
4852used as an array; the `declare' builtin will explicitly declare an
4853array. There is no maximum limit on the size of an array, nor any
4854requirement that members be indexed or assigned contiguously. Arrays
4855are zero-based.
4856
4857 An array is created automatically if any variable is assigned to
4858using the syntax
4859 name[SUBSCRIPT]=VALUE
4860
4861The SUBSCRIPT is treated as an arithmetic expression that must evaluate
4862to a number greater than or equal to zero. To explicitly declare an
4863array, use
4864 declare -a NAME
37c41ab1 4865 The syntax
ccc6cda3 4866 declare -a NAME[SUBSCRIPT]
37c41ab1 4867 is also accepted; the SUBSCRIPT is ignored. Attributes may be
ccc6cda3
JA
4868specified for an array variable using the `declare' and `readonly'
4869builtins. Each attribute applies to all members of an array.
4870
4871 Arrays are assigned to using compound assignments of the form
4872 name=(value1 ... valueN)
37c41ab1 4873 where each VALUE is of the form `[[SUBSCRIPT]=]'STRING. If the
ccc6cda3
JA
4874optional subscript is supplied, that index is assigned to; otherwise
4875the index of the element assigned is the last index assigned to by the
4876statement plus one. Indexing starts at zero. This syntax is also
4877accepted by the `declare' builtin. Individual array elements may be
4878assigned to using the `name['SUBSCRIPT`]='VALUE syntax introduced above.
4879
4880 Any element of an array may be referenced using
4881`${name['SUBSCRIPT`]}'. The braces are required to avoid conflicts
4882with the shell's filename expansion operators. If the SUBSCRIPT is `@'
4883or `*', the word expands to all members of the array NAME. These
4884subscripts differ only when the word appears within double quotes. If
4885the word is double-quoted, `${name[*]}' expands to a single word with
4886the value of each array member separated by the first character of the
4887`IFS' variable, and `${name[@]}' expands each element of NAME to a
4888separate word. When there are no array members, `${name[@]}' expands
37c41ab1
CR
4889to nothing. If the double-quoted expansion occurs within a word, the
4890expansion of the first parameter is joined with the beginning part of
4891the original word, and the expansion of the last parameter is joined
4892with the last part of the original word. This is analogous to the
4893expansion of the special parameters `@' and `*'.
4894`${#name['SUBSCRIPT`]}' expands to the length of `${name['SUBSCRIPT`]}'.
4895If SUBSCRIPT is `@' or `*', the expansion is the number of elements in
4896the array. Referencing an array variable without a subscript is
4897equivalent to referencing element zero.
ccc6cda3
JA
4898
4899 The `unset' builtin is used to destroy arrays. `unset'
bb70624e
JA
4900NAME[SUBSCRIPT] destroys the array element at index SUBSCRIPT. `unset'
4901NAME, where NAME is an array, removes the entire array. A subscript of
4902`*' or `@' also removes the entire array.
ccc6cda3
JA
4903
4904 The `declare', `local', and `readonly' builtins each accept a `-a'
4905option to specify an array. The `read' builtin accepts a `-a' option
4906to assign a list of words read from the standard input to an array, and
4907can read values from the standard input into individual array elements.
4908The `set' and `declare' builtins display array values in a way that
4909allows them to be reused as input.
4910
4911\1f
cce855bc
JA
4912File: bashref.info, Node: The Directory Stack, Next: Printing a Prompt, Prev: Arrays, Up: Bash Features
4913
37c41ab1
CR
49146.8 The Directory Stack
4915=======================
cce855bc 4916
bb70624e
JA
4917* Menu:
4918
4919* Directory Stack Builtins:: Bash builtin commands to manipulate
4920 the directory stack.
4921
4922 The directory stack is a list of recently-visited directories. The
cce855bc
JA
4923`pushd' builtin adds directories to the stack as it changes the current
4924directory, and the `popd' builtin removes specified directories from
4925the stack and changes the current directory to the directory removed.
4926The `dirs' builtin displays the contents of the directory stack.
4927
4928 The contents of the directory stack are also visible as the value of
4929the `DIRSTACK' shell variable.
4930
bb70624e
JA
4931\1f
4932File: bashref.info, Node: Directory Stack Builtins, Up: The Directory Stack
4933
37c41ab1
CR
49346.8.1 Directory Stack Builtins
4935------------------------------
bb70624e 4936
cce855bc 4937`dirs'
bb70624e 4938 dirs [+N | -N] [-clpv]
cce855bc
JA
4939 Display the list of currently remembered directories. Directories
4940 are added to the list with the `pushd' command; the `popd' command
4941 removes directories from the list.
4942 `+N'
4943 Displays the Nth directory (counting from the left of the
4944 list printed by `dirs' when invoked without options), starting
4945 with zero.
4946
4947 `-N'
4948 Displays the Nth directory (counting from the right of the
4949 list printed by `dirs' when invoked without options), starting
4950 with zero.
4951
4952 `-c'
4953 Clears the directory stack by deleting all of the elements.
4954
4955 `-l'
4956 Produces a longer listing; the default listing format uses a
4957 tilde to denote the home directory.
4958
4959 `-p'
4960 Causes `dirs' to print the directory stack with one entry per
4961 line.
4962
4963 `-v'
4964 Causes `dirs' to print the directory stack with one entry per
4965 line, prefixing each entry with its index in the stack.
4966
4967`popd'
4968 popd [+N | -N] [-n]
4969
4970 Remove the top entry from the directory stack, and `cd' to the new
4971 top directory. When no arguments are given, `popd' removes the
4972 top directory from the stack and performs a `cd' to the new top
4973 directory. The elements are numbered from 0 starting at the first
4974 directory listed with `dirs'; i.e., `popd' is equivalent to `popd
4975 +0'.
4976 `+N'
4977 Removes the Nth directory (counting from the left of the list
4978 printed by `dirs'), starting with zero.
4979
4980 `-N'
4981 Removes the Nth directory (counting from the right of the
4982 list printed by `dirs'), starting with zero.
4983
4984 `-n'
4985 Suppresses the normal change of directory when removing
4986 directories from the stack, so that only the stack is
4987 manipulated.
4988
4989`pushd'
4990 pushd [DIR | +N | -N] [-n]
4991
4992 Save the current directory on the top of the directory stack and
4993 then `cd' to DIR. With no arguments, `pushd' exchanges the top
4994 two directories.
4995
4996 `+N'
4997 Brings the Nth directory (counting from the left of the list
4998 printed by `dirs', starting with zero) to the top of the list
4999 by rotating the stack.
5000
5001 `-N'
5002 Brings the Nth directory (counting from the right of the list
5003 printed by `dirs', starting with zero) to the top of the list
5004 by rotating the stack.
5005
5006 `-n'
5007 Suppresses the normal change of directory when adding
5008 directories to the stack, so that only the stack is
5009 manipulated.
5010
5011 `DIR'
5012 Makes the current working directory be the top of the stack,
5013 and then executes the equivalent of ``cd' DIR'. `cd's to DIR.
5014
761783bf 5015
cce855bc
JA
5016\1f
5017File: bashref.info, Node: Printing a Prompt, Next: The Restricted Shell, Prev: The Directory Stack, Up: Bash Features
ccc6cda3 5018
37c41ab1
CR
50196.9 Controlling the Prompt
5020==========================
ccc6cda3 5021
37c41ab1
CR
5022The value of the variable `PROMPT_COMMAND' is examined just before Bash
5023prints each primary prompt. If `PROMPT_COMMAND' is set and has a
bb70624e
JA
5024non-null value, then the value is executed just as if it had been typed
5025on the command line.
ccc6cda3
JA
5026
5027 In addition, the following table describes the special characters
5028which can appear in the prompt variables:
5029
5030`\a'
cce855bc 5031 A bell character.
ccc6cda3
JA
5032
5033`\d'
cce855bc 5034 The date, in "Weekday Month Date" format (e.g., "Tue May 26").
ccc6cda3 5035
7117c2d2
JA
5036`\D{FORMAT}'
5037 The FORMAT is passed to `strftime'(3) and the result is inserted
5038 into the prompt string; an empty FORMAT results in a
5039 locale-specific time representation. The braces are required.
5040
ccc6cda3 5041`\e'
cce855bc 5042 An escape character.
ccc6cda3
JA
5043
5044`\h'
cce855bc 5045 The hostname, up to the first `.'.
ccc6cda3
JA
5046
5047`\H'
cce855bc 5048 The hostname.
ccc6cda3 5049
bb70624e
JA
5050`\j'
5051 The number of jobs currently managed by the shell.
5052
5053`\l'
5054 The basename of the shell's terminal device name.
5055
ccc6cda3 5056`\n'
cce855bc
JA
5057 A newline.
5058
5059`\r'
5060 A carriage return.
ccc6cda3
JA
5061
5062`\s'
cce855bc 5063 The name of the shell, the basename of `$0' (the portion following
ccc6cda3
JA
5064 the final slash).
5065
5066`\t'
cce855bc 5067 The time, in 24-hour HH:MM:SS format.
ccc6cda3
JA
5068
5069`\T'
cce855bc 5070 The time, in 12-hour HH:MM:SS format.
ccc6cda3
JA
5071
5072`\@'
cce855bc
JA
5073 The time, in 12-hour am/pm format.
5074
f73dda09
JA
5075`\A'
5076 The time, in 24-hour HH:MM format.
5077
cce855bc
JA
5078`\u'
5079 The username of the current user.
ccc6cda3
JA
5080
5081`\v'
cce855bc 5082 The version of Bash (e.g., 2.00)
ccc6cda3
JA
5083
5084`\V'
cce855bc 5085 The release of Bash, version + patchlevel (e.g., 2.00.0)
ccc6cda3
JA
5086
5087`\w'
12d937f9
CR
5088 The current working directory, with `$HOME' abbreviated with a
5089 tilde.
ccc6cda3
JA
5090
5091`\W'
12d937f9 5092 The basename of `$PWD', with `$HOME' abbreviated with a tilde.
ccc6cda3
JA
5093
5094`\!'
cce855bc 5095 The history number of this command.
ccc6cda3
JA
5096
5097`\#'
cce855bc 5098 The command number of this command.
ccc6cda3
JA
5099
5100`\$'
cce855bc 5101 If the effective uid is 0, `#', otherwise `$'.
ccc6cda3 5102
cce855bc
JA
5103`\NNN'
5104 The character whose ASCII code is the octal value NNN.
ccc6cda3
JA
5105
5106`\\'
cce855bc 5107 A backslash.
ccc6cda3
JA
5108
5109`\['
cce855bc 5110 Begin a sequence of non-printing characters. This could be used to
ccc6cda3
JA
5111 embed a terminal control sequence into the prompt.
5112
5113`\]'
cce855bc 5114 End a sequence of non-printing characters.
ccc6cda3 5115
bb70624e
JA
5116 The command number and the history number are usually different: the
5117history number of a command is its position in the history list, which
5118may include commands restored from the history file (*note Bash History
28ef6c31
JA
5119Facilities::), while the command number is the position in the sequence
5120of commands executed during the current shell session.
bb70624e
JA
5121
5122 After the string is decoded, it is expanded via parameter expansion,
5123command substitution, arithmetic expansion, and quote removal, subject
28ef6c31 5124to the value of the `promptvars' shell option (*note Bash Builtins::).
bb70624e 5125
ccc6cda3
JA
5126\1f
5127File: bashref.info, Node: The Restricted Shell, Next: Bash POSIX Mode, Prev: Printing a Prompt, Up: Bash Features
5128
37c41ab1
CR
51296.10 The Restricted Shell
5130=========================
ccc6cda3 5131
37c41ab1
CR
5132If Bash is started with the name `rbash', or the `--restricted' or `-r'
5133option is supplied at invocation, the shell becomes restricted. A
ccc6cda3
JA
5134restricted shell is used to set up an environment more controlled than
5135the standard shell. A restricted shell behaves identically to `bash'
7117c2d2
JA
5136with the exception that the following are disallowed or not performed:
5137
ccc6cda3
JA
5138 * Changing directories with the `cd' builtin.
5139
b72432fd
JA
5140 * Setting or unsetting the values of the `SHELL', `PATH', `ENV', or
5141 `BASH_ENV' variables.
ccc6cda3
JA
5142
5143 * Specifying command names containing slashes.
5144
5145 * Specifying a filename containing a slash as an argument to the `.'
5146 builtin command.
5147
bb70624e
JA
5148 * Specifying a filename containing a slash as an argument to the `-p'
5149 option to the `hash' builtin command.
5150
ccc6cda3
JA
5151 * Importing function definitions from the shell environment at
5152 startup.
5153
cce855bc
JA
5154 * Parsing the value of `SHELLOPTS' from the shell environment at
5155 startup.
5156
ccc6cda3
JA
5157 * Redirecting output using the `>', `>|', `<>', `>&', `&>', and `>>'
5158 redirection operators.
5159
5160 * Using the `exec' builtin to replace the shell with another command.
5161
5162 * Adding or deleting builtin commands with the `-f' and `-d' options
5163 to the `enable' builtin.
5164
7117c2d2
JA
5165 * Using the `enable' builtin command to enable disabled shell
5166 builtins.
5167
ccc6cda3
JA
5168 * Specifying the `-p' option to the `command' builtin.
5169
cce855bc 5170 * Turning off restricted mode with `set +r' or `set +o restricted'.
ccc6cda3 5171
7117c2d2
JA
5172 These restrictions are enforced after any startup files are read.
5173
5174 When a command that is found to be a shell script is executed (*note
5175Shell Scripts::), `rbash' turns off any restrictions in the shell
5176spawned to execute the script.
5177
ccc6cda3
JA
5178\1f
5179File: bashref.info, Node: Bash POSIX Mode, Prev: The Restricted Shell, Up: Bash Features
5180
37c41ab1
CR
51816.11 Bash POSIX Mode
5182====================
ccc6cda3 5183
37c41ab1
CR
5184Starting Bash with the `--posix' command-line option or executing `set
5185-o posix' while Bash is running will cause Bash to conform more closely
5186to the POSIX 1003.2 standard by changing the behavior to match that
5187specified by POSIX in areas where the Bash default differs.
ccc6cda3 5188
7117c2d2
JA
5189 When invoked as `sh', Bash enters POSIX mode after reading the
5190startup files.
5191
ccc6cda3
JA
5192 The following list is what's changed when `POSIX mode' is in effect:
5193
5194 1. When a command in the hash table no longer exists, Bash will
5195 re-search `$PATH' to find the new location. This is also
5196 available with `shopt -s checkhash'.
5197
28ef6c31
JA
5198 2. The message printed by the job control code and builtins when a job
5199 exits with a non-zero status is `Done(status)'.
ccc6cda3
JA
5200
5201 3. The message printed by the job control code and builtins when a job
28ef6c31
JA
5202 is stopped is `Stopped(SIGNAME)', where SIGNAME is, for example,
5203 `SIGTSTP'.
ccc6cda3
JA
5204
5205 4. Reserved words may not be aliased.
5206
bb70624e 5207 5. The POSIX 1003.2 `PS1' and `PS2' expansions of `!' to the history
ccc6cda3 5208 number and `!!' to `!' are enabled, and parameter expansion is
cce855bc
JA
5209 performed on the values of `PS1' and `PS2' regardless of the
5210 setting of the `promptvars' option.
ccc6cda3 5211
d3a24ed2 5212 6. The POSIX 1003.2 startup files are executed (`$ENV') rather than
bb70624e 5213 the normal Bash files.
ccc6cda3 5214
d3a24ed2 5215 7. Tilde expansion is only performed on assignments preceding a
ccc6cda3
JA
5216 command name, rather than on all assignment statements on the line.
5217
d3a24ed2 5218 8. The default history file is `~/.sh_history' (this is the default
ccc6cda3
JA
5219 value of `$HISTFILE').
5220
d3a24ed2
CR
5221 9. The output of `kill -l' prints all the signal names on a single
5222 line, separated by spaces, without the `SIG' prefix.
5223
5224 10. The `kill' builtin does not accept signal names with a `SIG'
5225 prefix.
ccc6cda3
JA
5226
5227 11. Non-interactive shells exit if FILENAME in `.' FILENAME is not
5228 found.
5229
cce855bc
JA
5230 12. Non-interactive shells exit if a syntax error in an arithmetic
5231 expansion results in an invalid expression.
5232
5233 13. Redirection operators do not perform filename expansion on the word
ccc6cda3
JA
5234 in the redirection unless the shell is interactive.
5235
bb70624e
JA
5236 14. Redirection operators do not perform word splitting on the word in
5237 the redirection.
5238
5239 15. Function names must be valid shell `name's. That is, they may not
ccc6cda3 5240 contain characters other than letters, digits, and underscores, and
cce855bc 5241 may not start with a digit. Declaring a function with an invalid
ccc6cda3
JA
5242 name causes a fatal syntax error in non-interactive shells.
5243
bb70624e
JA
5244 16. POSIX 1003.2 `special' builtins are found before shell functions
5245 during command lookup.
ccc6cda3 5246
bb70624e 5247 17. If a POSIX 1003.2 special builtin returns an error status, a
ccc6cda3
JA
5248 non-interactive shell exits. The fatal errors are those listed in
5249 the POSIX.2 standard, and include things like passing incorrect
5250 options, redirection errors, variable assignment errors for
5251 assignments preceding the command name, and so on.
5252
bb70624e 5253 18. If the `cd' builtin finds a directory to change to using
ccc6cda3
JA
5254 `$CDPATH', the value it assigns to the `PWD' variable does not
5255 contain any symbolic links, as if `cd -P' had been executed.
5256
28ef6c31 5257 19. If `CDPATH' is set, the `cd' builtin will not implicitly append
cce855bc
JA
5258 the current directory to it. This means that `cd' will fail if no
5259 valid directory name can be constructed from any of the entries in
5260 `$CDPATH', even if the a directory with the same name as the name
5261 given as an argument to `cd' exists in the current directory.
5262
bb70624e 5263 20. A non-interactive shell exits with an error status if a variable
ccc6cda3
JA
5264 assignment error occurs when no command name follows the assignment
5265 statements. A variable assignment error occurs, for example, when
cce855bc 5266 trying to assign a value to a readonly variable.
ccc6cda3 5267
bb70624e 5268 21. A non-interactive shell exits with an error status if the iteration
ccc6cda3 5269 variable in a `for' statement or the selection variable in a
cce855bc 5270 `select' statement is a readonly variable.
ccc6cda3 5271
bb70624e 5272 22. Process substitution is not available.
ccc6cda3 5273
bb70624e
JA
5274 23. Assignment statements preceding POSIX 1003.2 special builtins
5275 persist in the shell environment after the builtin completes.
ccc6cda3 5276
28ef6c31
JA
5277 24. Assignment statements preceding shell function calls persist in the
5278 shell environment after the function returns, as if a POSIX
5279 special builtin command had been executed.
5280
5281 25. The `export' and `readonly' builtin commands display their output
bb70624e 5282 in the format required by POSIX 1003.2.
d166f048 5283
28ef6c31
JA
5284 26. The `trap' builtin displays signal names without the leading `SIG'.
5285
d3a24ed2
CR
5286 27. The `trap' builtin doesn't check the first argument for a possible
5287 signal specification and revert the signal handling to the original
8a9c66f6
CR
5288 disposition if it is, unless that argument consists solely of
5289 digits and is a valid signal number. If users want to reset the
5290 handler for a given signal to the original disposition, they
5291 should use `-' as the first argument.
d3a24ed2
CR
5292
5293 28. The `.' and `source' builtins do not search the current directory
28ef6c31
JA
5294 for the filename argument if it is not found by searching `PATH'.
5295
d3a24ed2 5296 29. Subshells spawned to execute command substitutions inherit the
28ef6c31
JA
5297 value of the `-e' option from the parent shell. When not in POSIX
5298 mode, Bash clears the `-e' option in such subshells.
5299
d3a24ed2 5300 30. Alias expansion is always enabled, even in non-interactive shells.
28ef6c31 5301
d3a24ed2
CR
5302 31. When the `alias' builtin displays alias definitions, it does not
5303 display them with a leading `alias ' unless the `-p' option is
5304 supplied.
5305
5306 32. When the `set' builtin is invoked without options, it does not
28ef6c31
JA
5307 display shell function names and definitions.
5308
d3a24ed2 5309 33. When the `set' builtin is invoked without options, it displays
f73dda09
JA
5310 variable values without quotes, unless they contain shell
5311 metacharacters, even if the result contains nonprinting characters.
ccc6cda3 5312
d3a24ed2 5313 34. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
7117c2d2
JA
5314 constructed from `$PWD' and the directory name supplied as an
5315 argument does not refer to an existing directory, `cd' will fail
5316 instead of falling back to PHYSICAL mode.
5317
8a9c66f6
CR
5318 35. When listing the history, the `fc' builtin does not include an
5319 indication of whether or not a history entry has been modified.
5320
5321 36. The default editor used by `fc' is `ed'.
5322
37c41ab1
CR
5323 37. The `type' and `command' builtins will not report a non-executable
5324 file as having been found, though the shell will attempt to
5325 execute such a file if it is the only so-named file found in
5326 `$PATH'.
5327
5328 38. When the `xpg_echo' option is enabled, Bash does not attempt to
5329 interpret any arguments to `echo' as options. Each argument is
5330 displayed, after escape characters are converted.
5331
8a9c66f6 5332
bb70624e 5333 There is other POSIX 1003.2 behavior that Bash does not implement.
ccc6cda3
JA
5334Specifically:
5335
5336 1. Assignment statements affect the execution environment of all
5337 builtins, not just special ones.
5338
28ef6c31
JA
5339 2. When a subshell is created to execute a shell script with execute
5340 permission, but without a leading `#!', Bash sets `$0' to the full
5341 pathname of the script as found by searching `$PATH', rather than
5342 the command as typed by the user.
5343
5344 3. When using `.' to source a shell script found in `$PATH', bash
5345 checks execute permission bits rather than read permission bits,
5346 just as if it were searching for a command.
5347
5348
ccc6cda3
JA
5349\1f
5350File: bashref.info, Node: Job Control, Next: Using History Interactively, Prev: Bash Features, Up: Top
5351
37c41ab1
CR
53527 Job Control
5353*************
ccc6cda3 5354
37c41ab1
CR
5355This chapter discusses what job control is, how it works, and how Bash
5356allows you to access its facilities.
ccc6cda3
JA
5357
5358* Menu:
5359
5360* Job Control Basics:: How job control works.
5361* Job Control Builtins:: Bash builtin commands used to interact
5362 with job control.
5363* Job Control Variables:: Variables Bash uses to customize job
5364 control.
5365
5366\1f
5367File: bashref.info, Node: Job Control Basics, Next: Job Control Builtins, Up: Job Control
5368
37c41ab1
CR
53697.1 Job Control Basics
5370======================
ccc6cda3 5371
37c41ab1 5372Job control refers to the ability to selectively stop (suspend) the
ccc6cda3
JA
5373execution of processes and continue (resume) their execution at a later
5374point. A user typically employs this facility via an interactive
5375interface supplied jointly by the system's terminal driver and Bash.
5376
5377 The shell associates a JOB with each pipeline. It keeps a table of
5378currently executing jobs, which may be listed with the `jobs' command.
cce855bc 5379When Bash starts a job asynchronously, it prints a line that looks like:
ccc6cda3 5380 [1] 25647
37c41ab1
CR
5381 indicating that this job is job number 1 and that the process ID of
5382the last process in the pipeline associated with this job is 25647.
5383All of the processes in a single pipeline are members of the same job.
5384Bash uses the JOB abstraction as the basis for job control.
ccc6cda3
JA
5385
5386 To facilitate the implementation of the user interface to job
bb70624e
JA
5387control, the operating system maintains the notion of a current terminal
5388process group ID. Members of this process group (processes whose
5389process group ID is equal to the current terminal process group ID)
5390receive keyboard-generated signals such as `SIGINT'. These processes
5391are said to be in the foreground. Background processes are those whose
5392process group ID differs from the terminal's; such processes are immune
5393to keyboard-generated signals. Only foreground processes are allowed
5394to read from or write to the terminal. Background processes which
5395attempt to read from (write to) the terminal are sent a `SIGTTIN'
5396(`SIGTTOU') signal by the terminal driver, which, unless caught,
5397suspends the process.
ccc6cda3
JA
5398
5399 If the operating system on which Bash is running supports job
cce855bc
JA
5400control, Bash contains facilities to use it. Typing the SUSPEND
5401character (typically `^Z', Control-Z) while a process is running causes
5402that process to be stopped and returns control to Bash. Typing the
5403DELAYED SUSPEND character (typically `^Y', Control-Y) causes the
5404process to be stopped when it attempts to read input from the terminal,
5405and control to be returned to Bash. The user then manipulates the
5406state of this job, using the `bg' command to continue it in the
5407background, the `fg' command to continue it in the foreground, or the
5408`kill' command to kill it. A `^Z' takes effect immediately, and has
5409the additional side effect of causing pending output and typeahead to
5410be discarded.
ccc6cda3
JA
5411
5412 There are a number of ways to refer to a job in the shell. The
bb70624e
JA
5413character `%' introduces a job name.
5414
5415 Job number `n' may be referred to as `%n'. The symbols `%%' and
5416`%+' refer to the shell's notion of the current job, which is the last
5417job stopped while it was in the foreground or started in the
5418background. The previous job may be referenced using `%-'. In output
5419pertaining to jobs (e.g., the output of the `jobs' command), the
5420current job is always flagged with a `+', and the previous job with a
5421`-'.
5422
5423 A job may also be referred to using a prefix of the name used to
5424start it, or using a substring that appears in its command line. For
5425example, `%ce' refers to a stopped `ce' job. Using `%?ce', on the other
5426hand, refers to any job containing the string `ce' in its command line.
5427If the prefix or substring matches more than one job, Bash reports an
5428error.
ccc6cda3
JA
5429
5430 Simply naming a job can be used to bring it into the foreground:
5431`%1' is a synonym for `fg %1', bringing job 1 from the background into
5432the foreground. Similarly, `%1 &' resumes job 1 in the background,
5433equivalent to `bg %1'
5434
5435 The shell learns immediately whenever a job changes state.
5436Normally, Bash waits until it is about to print a prompt before
5437reporting changes in a job's status so as to not interrupt any other
f73dda09
JA
5438output. If the `-b' option to the `set' builtin is enabled, Bash
5439reports such changes immediately (*note The Set Builtin::). Any trap
5440on `SIGCHLD' is executed for each child process that exits.
ccc6cda3 5441
de8913bd 5442 If an attempt to exit Bash is made while jobs are stopped, the shell
cce855bc
JA
5443prints a message warning that there are stopped jobs. The `jobs'
5444command may then be used to inspect their status. If a second attempt
5445to exit is made without an intervening command, Bash does not print
5446another warning, and the stopped jobs are terminated.
ccc6cda3
JA
5447
5448\1f
5449File: bashref.info, Node: Job Control Builtins, Next: Job Control Variables, Prev: Job Control Basics, Up: Job Control
5450
37c41ab1
CR
54517.2 Job Control Builtins
5452========================
ccc6cda3
JA
5453
5454`bg'
37c41ab1
CR
5455 bg [JOBSPEC ...]
5456 Resume each suspended job JOBSPEC in the background, as if it had
cce855bc
JA
5457 been started with `&'. If JOBSPEC is not supplied, the current
5458 job is used. The return status is zero unless it is run when job
5459 control is not enabled, or, when run with job control enabled, if
37c41ab1
CR
5460 the last JOBSPEC was not found or the last JOBSPEC specifies a job
5461 that was started without job control.
ccc6cda3
JA
5462
5463`fg'
5464 fg [JOBSPEC]
cce855bc
JA
5465 Resume the job JOBSPEC in the foreground and make it the current
5466 job. If JOBSPEC is not supplied, the current job is used. The
5467 return status is that of the command placed into the foreground,
5468 or non-zero if run when job control is disabled or, when run with
5469 job control enabled, JOBSPEC does not specify a valid job or
5470 JOBSPEC specifies a job that was started without job control.
ccc6cda3
JA
5471
5472`jobs'
bb70624e 5473 jobs [-lnprs] [JOBSPEC]
cce855bc 5474 jobs -x COMMAND [ARGUMENTS]
ccc6cda3
JA
5475
5476 The first form lists the active jobs. The options have the
5477 following meanings:
5478
5479 `-l'
cce855bc 5480 List process IDs in addition to the normal information.
ccc6cda3
JA
5481
5482 `-n'
5483 Display information only about jobs that have changed status
cce855bc 5484 since the user was last notified of their status.
ccc6cda3
JA
5485
5486 `-p'
5487 List only the process ID of the job's process group leader.
5488
5489 `-r'
5490 Restrict output to running jobs.
5491
5492 `-s'
5493 Restrict output to stopped jobs.
5494
5495 If JOBSPEC is given, output is restricted to information about
5496 that job. If JOBSPEC is not supplied, the status of all jobs is
5497 listed.
5498
5499 If the `-x' option is supplied, `jobs' replaces any JOBSPEC found
5500 in COMMAND or ARGUMENTS with the corresponding process group ID,
5501 and executes COMMAND, passing it ARGUMENTs, returning its exit
5502 status.
5503
5504`kill'
cce855bc
JA
5505 kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] JOBSPEC or PID
5506 kill -l [EXIT_STATUS]
ccc6cda3 5507 Send a signal specified by SIGSPEC or SIGNUM to the process named
cce855bc 5508 by job specification JOBSPEC or process ID PID. SIGSPEC is either
9f422431
CR
5509 a case-insensitive signal name such as `SIGINT' (with or without
5510 the `SIG' prefix) or a signal number; SIGNUM is a signal number.
5511 If SIGSPEC and SIGNUM are not present, `SIGTERM' is used. The
5512 `-l' option lists the signal names. If any arguments are supplied
5513 when `-l' is given, the names of the signals corresponding to the
5514 arguments are listed, and the return status is zero. EXIT_STATUS
5515 is a number specifying a signal number or the exit status of a
5516 process terminated by a signal. The return status is zero if at
5517 least one signal was successfully sent, or non-zero if an error
5518 occurs or an invalid option is encountered.
ccc6cda3
JA
5519
5520`wait'
bb70624e 5521 wait [JOBSPEC or PID]
ccc6cda3 5522 Wait until the child process specified by process ID PID or job
cce855bc
JA
5523 specification JOBSPEC exits and return the exit status of the last
5524 command waited for. If a job spec is given, all processes in the
5525 job are waited for. If no arguments are given, all currently
5526 active child processes are waited for, and the return status is
5527 zero. If neither JOBSPEC nor PID specifies an active child process
5528 of the shell, the return status is 127.
ccc6cda3
JA
5529
5530`disown'
cce855bc 5531 disown [-ar] [-h] [JOBSPEC ...]
ccc6cda3
JA
5532 Without options, each JOBSPEC is removed from the table of active
5533 jobs. If the `-h' option is given, the job is not removed from
5534 the table, but is marked so that `SIGHUP' is not sent to the job
cce855bc
JA
5535 if the shell receives a `SIGHUP'. If JOBSPEC is not present, and
5536 neither the `-a' nor `-r' option is supplied, the current job is
5537 used. If no JOBSPEC is supplied, the `-a' option means to remove
5538 or mark all jobs; the `-r' option without a JOBSPEC argument
5539 restricts operation to running jobs.
ccc6cda3
JA
5540
5541`suspend'
5542 suspend [-f]
5543 Suspend the execution of this shell until it receives a `SIGCONT'
5544 signal. The `-f' option means to suspend even if the shell is a
5545 login shell.
5546
761783bf 5547
ccc6cda3
JA
5548 When job control is not active, the `kill' and `wait' builtins do
5549not accept JOBSPEC arguments. They must be supplied process IDs.
5550
5551\1f
5552File: bashref.info, Node: Job Control Variables, Prev: Job Control Builtins, Up: Job Control
5553
37c41ab1
CR
55547.3 Job Control Variables
5555=========================
ccc6cda3
JA
5556
5557`auto_resume'
5558 This variable controls how the shell interacts with the user and
5559 job control. If this variable exists then single word simple
cce855bc
JA
5560 commands without redirections are treated as candidates for
5561 resumption of an existing job. There is no ambiguity allowed; if
5562 there is more than one job beginning with the string typed, then
5563 the most recently accessed job will be selected. The name of a
5564 stopped job, in this context, is the command line used to start
5565 it. If this variable is set to the value `exact', the string
5566 supplied must match the name of a stopped job exactly; if set to
ccc6cda3
JA
5567 `substring', the string supplied needs to match a substring of the
5568 name of a stopped job. The `substring' value provides
5569 functionality analogous to the `%?' job ID (*note Job Control
28ef6c31
JA
5570 Basics::). If set to any other value, the supplied string must be
5571 a prefix of a stopped job's name; this provides functionality
ccc6cda3
JA
5572 analogous to the `%' job ID.
5573
761783bf 5574
ccc6cda3 5575\1f
bb70624e 5576File: bashref.info, Node: Command Line Editing, Next: Installing Bash, Prev: Using History Interactively, Up: Top
ccc6cda3 5577
37c41ab1
CR
55788 Command Line Editing
5579**********************
ccc6cda3 5580
37c41ab1 5581This chapter describes the basic features of the GNU command line
bb70624e
JA
5582editing interface. Command line editing is provided by the Readline
5583library, which is used by several different programs, including Bash.
ccc6cda3
JA
5584
5585* Menu:
5586
bb70624e
JA
5587* Introduction and Notation:: Notation used in this text.
5588* Readline Interaction:: The minimum set of commands for editing a line.
5589* Readline Init File:: Customizing Readline from a user's view.
5590* Bindable Readline Commands:: A description of most of the Readline commands
5591 available for binding
5592* Readline vi Mode:: A short description of how to make Readline
5593 behave like the vi editor.
5594
5595* Programmable Completion:: How to specify the possible completions for
5596 a specific command.
5597* Programmable Completion Builtins:: Builtin commands to specify how to
5598 complete arguments for a particular command.
ccc6cda3
JA
5599
5600\1f
bb70624e 5601File: bashref.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing
ccc6cda3 5602
37c41ab1
CR
56038.1 Introduction to Line Editing
5604================================
ccc6cda3 5605
37c41ab1 5606The following paragraphs describe the notation used to represent
bb70624e 5607keystrokes.
ccc6cda3 5608
28ef6c31 5609 The text `C-k' is read as `Control-K' and describes the character
bb70624e 5610produced when the <k> key is pressed while the Control key is depressed.
ccc6cda3 5611
28ef6c31 5612 The text `M-k' is read as `Meta-K' and describes the character
bb70624e
JA
5613produced when the Meta key (if you have one) is depressed, and the <k>
5614key is pressed. The Meta key is labeled <ALT> on many keyboards. On
5615keyboards with two keys labeled <ALT> (usually to either side of the
5616space bar), the <ALT> on the left side is generally set to work as a
5617Meta key. The <ALT> key on the right may also be configured to work as
5618a Meta key or may be configured as some other modifier, such as a
5619Compose key for typing accented characters.
5620
5621 If you do not have a Meta or <ALT> key, or another key working as a
5622Meta key, the identical keystroke can be generated by typing <ESC>
28ef6c31
JA
5623_first_, and then typing <k>. Either process is known as "metafying"
5624the <k> key.
bb70624e 5625
28ef6c31
JA
5626 The text `M-C-k' is read as `Meta-Control-k' and describes the
5627character produced by "metafying" `C-k'.
bb70624e
JA
5628
5629 In addition, several keys have their own names. Specifically,
5630<DEL>, <ESC>, <LFD>, <SPC>, <RET>, and <TAB> all stand for themselves
28ef6c31
JA
5631when seen in this text, or in an init file (*note Readline Init File::).
5632If your keyboard lacks a <LFD> key, typing <C-j> will produce the
5633desired character. The <RET> key may be labeled <Return> or <Enter> on
5634some keyboards.
ccc6cda3
JA
5635
5636\1f
bb70624e 5637File: bashref.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing
cce855bc 5638
37c41ab1
CR
56398.2 Readline Interaction
5640========================
cce855bc 5641
37c41ab1 5642Often during an interactive session you type in a long line of text,
bb70624e
JA
5643only to notice that the first word on the line is misspelled. The
5644Readline library gives you a set of commands for manipulating the text
5645as you type it in, allowing you to just fix your typo, and not forcing
5646you to retype the majority of the line. Using these editing commands,
5647you move the cursor to the place that needs correction, and delete or
5648insert the text of the corrections. Then, when you are satisfied with
28ef6c31
JA
5649the line, you simply press <RET>. You do not have to be at the end of
5650the line to press <RET>; the entire line is accepted regardless of the
5651location of the cursor within the line.
cce855bc 5652
bb70624e 5653* Menu:
cce855bc 5654
bb70624e
JA
5655* Readline Bare Essentials:: The least you need to know about Readline.
5656* Readline Movement Commands:: Moving about the input line.
5657* Readline Killing Commands:: How to delete text, and how to get it back!
5658* Readline Arguments:: Giving numeric arguments to commands.
5659* Searching:: Searching through previous lines.
cce855bc 5660
bb70624e
JA
5661\1f
5662File: bashref.info, Node: Readline Bare Essentials, Next: Readline Movement Commands, Up: Readline Interaction
cce855bc 5663
37c41ab1
CR
56648.2.1 Readline Bare Essentials
5665------------------------------
cce855bc 5666
37c41ab1
CR
5667In order to enter characters into the line, simply type them. The typed
5668character appears where the cursor was, and then the cursor moves one
5669space to the right. If you mistype a character, you can use your erase
5670character to back up and delete the mistyped character.
cce855bc 5671
bb70624e
JA
5672 Sometimes you may mistype a character, and not notice the error
5673until you have typed several other characters. In that case, you can
28ef6c31
JA
5674type `C-b' to move the cursor to the left, and then correct your
5675mistake. Afterwards, you can move the cursor to the right with `C-f'.
cce855bc 5676
bb70624e
JA
5677 When you add text in the middle of a line, you will notice that
5678characters to the right of the cursor are `pushed over' to make room
5679for the text that you have inserted. Likewise, when you delete text
5680behind the cursor, characters to the right of the cursor are `pulled
5681back' to fill in the blank space created by the removal of the text. A
5682list of the bare essentials for editing the text of an input line
5683follows.
cce855bc 5684
28ef6c31 5685`C-b'
bb70624e 5686 Move back one character.
cce855bc 5687
28ef6c31 5688`C-f'
bb70624e 5689 Move forward one character.
cce855bc 5690
bb70624e
JA
5691<DEL> or <Backspace>
5692 Delete the character to the left of the cursor.
cce855bc 5693
28ef6c31 5694`C-d'
bb70624e 5695 Delete the character underneath the cursor.
cce855bc 5696
bb70624e
JA
5697Printing characters
5698 Insert the character into the line at the cursor.
cce855bc 5699
28ef6c31 5700`C-_' or `C-x C-u'
bb70624e
JA
5701 Undo the last editing command. You can undo all the way back to an
5702 empty line.
cce855bc 5703
bb70624e
JA
5704(Depending on your configuration, the <Backspace> key be set to delete
5705the character to the left of the cursor and the <DEL> key set to delete
28ef6c31 5706the character underneath the cursor, like `C-d', rather than the
bb70624e 5707character to the left of the cursor.)
cce855bc
JA
5708
5709\1f
bb70624e 5710File: bashref.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction
ccc6cda3 5711
37c41ab1
CR
57128.2.2 Readline Movement Commands
5713--------------------------------
ccc6cda3 5714
37c41ab1 5715The above table describes the most basic keystrokes that you need in
bb70624e 5716order to do editing of the input line. For your convenience, many
28ef6c31 5717other commands have been added in addition to `C-b', `C-f', `C-d', and
bb70624e 5718<DEL>. Here are some commands for moving more rapidly about the line.
ccc6cda3 5719
28ef6c31 5720`C-a'
bb70624e 5721 Move to the start of the line.
ccc6cda3 5722
28ef6c31 5723`C-e'
bb70624e 5724 Move to the end of the line.
ccc6cda3 5725
28ef6c31 5726`M-f'
bb70624e
JA
5727 Move forward a word, where a word is composed of letters and
5728 digits.
ccc6cda3 5729
28ef6c31 5730`M-b'
bb70624e 5731 Move backward a word.
ccc6cda3 5732
28ef6c31 5733`C-l'
bb70624e 5734 Clear the screen, reprinting the current line at the top.
ccc6cda3 5735
28ef6c31 5736 Notice how `C-f' moves forward a character, while `M-f' moves
bb70624e
JA
5737forward a word. It is a loose convention that control keystrokes
5738operate on characters while meta keystrokes operate on words.
ccc6cda3
JA
5739
5740\1f
bb70624e 5741File: bashref.info, Node: Readline Killing Commands, Next: Readline Arguments, Prev: Readline Movement Commands, Up: Readline Interaction
ccc6cda3 5742
37c41ab1
CR
57438.2.3 Readline Killing Commands
5744-------------------------------
ccc6cda3 5745
37c41ab1
CR
5746"Killing" text means to delete the text from the line, but to save it
5747away for later use, usually by "yanking" (re-inserting) it back into
bb70624e
JA
5748the line. (`Cut' and `paste' are more recent jargon for `kill' and
5749`yank'.)
ccc6cda3 5750
bb70624e
JA
5751 If the description for a command says that it `kills' text, then you
5752can be sure that you can get the text back in a different (or the same)
5753place later.
ccc6cda3 5754
bb70624e
JA
5755 When you use a kill command, the text is saved in a "kill-ring".
5756Any number of consecutive kills save all of the killed text together, so
5757that when you yank it back, you get it all. The kill ring is not line
5758specific; the text that you killed on a previously typed line is
37c41ab1 5759available to be yanked back later, when you are typing another line.
ccc6cda3 5760
bb70624e 5761 Here is the list of commands for killing text.
ccc6cda3 5762
28ef6c31 5763`C-k'
bb70624e
JA
5764 Kill the text from the current cursor position to the end of the
5765 line.
ccc6cda3 5766
28ef6c31 5767`M-d'
bb70624e
JA
5768 Kill from the cursor to the end of the current word, or, if between
5769 words, to the end of the next word. Word boundaries are the same
28ef6c31 5770 as those used by `M-f'.
ccc6cda3 5771
28ef6c31 5772`M-<DEL>'
f73dda09 5773 Kill from the cursor the start of the current word, or, if between
bb70624e 5774 words, to the start of the previous word. Word boundaries are the
28ef6c31 5775 same as those used by `M-b'.
ccc6cda3 5776
28ef6c31 5777`C-w'
ccc6cda3 5778 Kill from the cursor to the previous whitespace. This is
28ef6c31 5779 different than `M-<DEL>' because the word boundaries differ.
ccc6cda3 5780
761783bf 5781
cce855bc
JA
5782 Here is how to "yank" the text back into the line. Yanking means to
5783copy the most-recently-killed text from the kill buffer.
ccc6cda3 5784
28ef6c31 5785`C-y'
ccc6cda3
JA
5786 Yank the most recently killed text back into the buffer at the
5787 cursor.
5788
28ef6c31 5789`M-y'
ccc6cda3 5790 Rotate the kill-ring, and yank the new top. You can only do this
28ef6c31 5791 if the prior command is `C-y' or `M-y'.
ccc6cda3
JA
5792
5793\1f
5794File: bashref.info, Node: Readline Arguments, Next: Searching, Prev: Readline Killing Commands, Up: Readline Interaction
5795
37c41ab1
CR
57968.2.4 Readline Arguments
5797------------------------
ccc6cda3 5798
37c41ab1 5799You can pass numeric arguments to Readline commands. Sometimes the
ccc6cda3
JA
5800argument acts as a repeat count, other times it is the sign of the
5801argument that is significant. If you pass a negative argument to a
5802command which normally acts in a forward direction, that command will
5803act in a backward direction. For example, to kill text back to the
5804start of the line, you might type `M-- C-k'.
5805
5806 The general way to pass numeric arguments to a command is to type
cce855bc 5807meta digits before the command. If the first `digit' typed is a minus
bb70624e 5808sign (`-'), then the sign of the argument will be negative. Once you
cce855bc
JA
5809have typed one meta digit to get the argument started, you can type the
5810remainder of the digits, and then the command. For example, to give
28ef6c31
JA
5811the `C-d' command an argument of 10, you could type `M-1 0 C-d', which
5812will delete the next ten characters on the input line.
ccc6cda3
JA
5813
5814\1f
5815File: bashref.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction
5816
37c41ab1
CR
58178.2.5 Searching for Commands in the History
5818-------------------------------------------
ccc6cda3 5819
37c41ab1 5820Readline provides commands for searching through the command history
28ef6c31
JA
5821(*note Bash History Facilities::) for lines containing a specified
5822string. There are two search modes: "incremental" and
5823"non-incremental".
ccc6cda3
JA
5824
5825 Incremental searches begin before the user has finished typing the
5826search string. As each character of the search string is typed,
cce855bc 5827Readline displays the next entry from the history matching the string
ccc6cda3 5828typed so far. An incremental search requires only as many characters
bb70624e 5829as needed to find the desired history entry. To search backward in the
28ef6c31 5830history for a particular string, type `C-r'. Typing `C-s' searches
bb70624e
JA
5831forward through the history. The characters present in the value of
5832the `isearch-terminators' variable are used to terminate an incremental
5833search. If that variable has not been assigned a value, the <ESC> and
28ef6c31 5834`C-J' characters will terminate an incremental search. `C-g' will
bb70624e
JA
5835abort an incremental search and restore the original line. When the
5836search is terminated, the history entry containing the search string
5837becomes the current line.
5838
28ef6c31
JA
5839 To find other matching entries in the history list, type `C-r' or
5840`C-s' as appropriate. This will search backward or forward in the
bb70624e
JA
5841history for the next entry matching the search string typed so far.
5842Any other key sequence bound to a Readline command will terminate the
5843search and execute that command. For instance, a <RET> will terminate
5844the search and accept the line, thereby executing the command from the
28ef6c31
JA
5845history list. A movement command will terminate the search, make the
5846last line found the current line, and begin editing.
ccc6cda3 5847
f73dda09
JA
5848 Readline remembers the last incremental search string. If two
5849`C-r's are typed without any intervening characters defining a new
5850search string, any remembered search string is used.
5851
ccc6cda3
JA
5852 Non-incremental searches read the entire search string before
5853starting to search for matching history lines. The search string may be
cce855bc 5854typed by the user or be part of the contents of the current line.
ccc6cda3
JA
5855
5856\1f
5857File: bashref.info, Node: Readline Init File, Next: Bindable Readline Commands, Prev: Readline Interaction, Up: Command Line Editing
5858
37c41ab1
CR
58598.3 Readline Init File
5860======================
ccc6cda3 5861
37c41ab1 5862Although the Readline library comes with a set of Emacs-like
cce855bc
JA
5863keybindings installed by default, it is possible to use a different set
5864of keybindings. Any user can customize programs that use Readline by
bb70624e
JA
5865putting commands in an "inputrc" file, conventionally in his home
5866directory. The name of this file is taken from the value of the shell
5867variable `INPUTRC'. If that variable is unset, the default is
5868`~/.inputrc'.
ccc6cda3
JA
5869
5870 When a program which uses the Readline library starts up, the init
5871file is read, and the key bindings are set.
5872
5873 In addition, the `C-x C-r' command re-reads this init file, thus
5874incorporating any changes that you might have made to it.
5875
5876* Menu:
5877
5878* Readline Init File Syntax:: Syntax for the commands in the inputrc file.
5879
5880* Conditional Init Constructs:: Conditional key bindings in the inputrc file.
5881
5882* Sample Init File:: An example inputrc file.
5883
5884\1f
5885File: bashref.info, Node: Readline Init File Syntax, Next: Conditional Init Constructs, Up: Readline Init File
5886
37c41ab1
CR
58878.3.1 Readline Init File Syntax
5888-------------------------------
ccc6cda3 5889
37c41ab1 5890There are only a few basic constructs allowed in the Readline init
ccc6cda3
JA
5891file. Blank lines are ignored. Lines beginning with a `#' are
5892comments. Lines beginning with a `$' indicate conditional constructs
28ef6c31 5893(*note Conditional Init Constructs::). Other lines denote variable
ccc6cda3
JA
5894settings and key bindings.
5895
5896Variable Settings
cce855bc
JA
5897 You can modify the run-time behavior of Readline by altering the
5898 values of variables in Readline using the `set' command within the
28ef6c31
JA
5899 init file. The syntax is simple:
5900
5901 set VARIABLE VALUE
5902
5903 Here, for example, is how to change from the default Emacs-like
5904 key binding to use `vi' line editing commands:
ccc6cda3
JA
5905
5906 set editing-mode vi
5907
28ef6c31
JA
5908 Variable names and values, where appropriate, are recognized
5909 without regard to case.
5910
bb70624e
JA
5911 The `bind -V' command lists the current Readline variable names
5912 and values. *Note Bash Builtins::.
5913
cce855bc
JA
5914 A great deal of run-time behavior is changeable with the following
5915 variables.
ccc6cda3
JA
5916
5917 `bell-style'
5918 Controls what happens when Readline wants to ring the
5919 terminal bell. If set to `none', Readline never rings the
5920 bell. If set to `visible', Readline uses a visible bell if
5921 one is available. If set to `audible' (the default),
5922 Readline attempts to ring the terminal's bell.
5923
5924 `comment-begin'
5925 The string to insert at the beginning of the line when the
5926 `insert-comment' command is executed. The default value is
5927 `"#"'.
5928
cce855bc
JA
5929 `completion-ignore-case'
5930 If set to `on', Readline performs filename matching and
5931 completion in a case-insensitive fashion. The default value
5932 is `off'.
5933
ccc6cda3
JA
5934 `completion-query-items'
5935 The number of possible completions that determines when the
d3a24ed2
CR
5936 user is asked whether the list of possibilities should be
5937 displayed. If the number of possible completions is greater
5938 than this value, Readline will ask the user whether or not he
5939 wishes to view them; otherwise, they are simply listed. This
5940 variable must be set to an integer value greater than or
5941 equal to 0. The default limit is `100'.
ccc6cda3
JA
5942
5943 `convert-meta'
5944 If set to `on', Readline will convert characters with the
cce855bc 5945 eighth bit set to an ASCII key sequence by stripping the
bb70624e 5946 eighth bit and prefixing an <ESC> character, converting them
cce855bc 5947 to a meta-prefixed key sequence. The default value is `on'.
ccc6cda3
JA
5948
5949 `disable-completion'
cce855bc 5950 If set to `On', Readline will inhibit word completion.
ccc6cda3
JA
5951 Completion characters will be inserted into the line as if
5952 they had been mapped to `self-insert'. The default is `off'.
5953
5954 `editing-mode'
cce855bc
JA
5955 The `editing-mode' variable controls which default set of key
5956 bindings is used. By default, Readline starts up in Emacs
5957 editing mode, where the keystrokes are most similar to Emacs.
5958 This variable can be set to either `emacs' or `vi'.
ccc6cda3
JA
5959
5960 `enable-keypad'
cce855bc 5961 When set to `on', Readline will try to enable the application
ccc6cda3
JA
5962 keypad when it is called. Some systems need this to enable
5963 the arrow keys. The default is `off'.
5964
5965 `expand-tilde'
5966 If set to `on', tilde expansion is performed when Readline
5967 attempts word completion. The default is `off'.
5968
f73dda09 5969 If set to `on', the history code attempts to place point at
d3a24ed2 5970 the same location on each history line retrieved with
f73dda09
JA
5971 `previous-history' or `next-history'.
5972
ccc6cda3
JA
5973 `horizontal-scroll-mode'
5974 This variable can be set to either `on' or `off'. Setting it
cce855bc 5975 to `on' means that the text of the lines being edited will
ccc6cda3
JA
5976 scroll horizontally on a single screen line when they are
5977 longer than the width of the screen, instead of wrapping onto
5978 a new screen line. By default, this variable is set to `off'.
5979
b72432fd
JA
5980 `input-meta'
5981 If set to `on', Readline will enable eight-bit input (it will
28ef6c31 5982 not clear the eighth bit in the characters it reads),
b72432fd
JA
5983 regardless of what the terminal claims it can support. The
5984 default value is `off'. The name `meta-flag' is a synonym
5985 for this variable.
5986
5987 `isearch-terminators'
5988 The string of characters that should terminate an incremental
5989 search without subsequently executing the character as a
28ef6c31
JA
5990 command (*note Searching::). If this variable has not been
5991 given a value, the characters <ESC> and `C-J' will terminate
b72432fd
JA
5992 an incremental search.
5993
ccc6cda3
JA
5994 `keymap'
5995 Sets Readline's idea of the current keymap for key binding
5996 commands. Acceptable `keymap' names are `emacs',
28ef6c31 5997 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
ccc6cda3
JA
5998 `vi-command', and `vi-insert'. `vi' is equivalent to
5999 `vi-command'; `emacs' is equivalent to `emacs-standard'. The
6000 default value is `emacs'. The value of the `editing-mode'
6001 variable also affects the default keymap.
6002
6003 `mark-directories'
6004 If set to `on', completed directory names have a slash
6005 appended. The default is `on'.
6006
6007 `mark-modified-lines'
cce855bc
JA
6008 This variable, when set to `on', causes Readline to display an
6009 asterisk (`*') at the start of history lines which have been
6010 modified. This variable is `off' by default.
ccc6cda3 6011
7117c2d2
JA
6012 `mark-symlinked-directories'
6013 If set to `on', completed names which are symbolic links to
6014 directories have a slash appended (subject to the value of
6015 `mark-directories'). The default is `off'.
6016
f73dda09
JA
6017 `match-hidden-files'
6018 This variable, when set to `on', causes Readline to match
6019 files whose names begin with a `.' (hidden files) when
6020 performing filename completion, unless the leading `.' is
6021 supplied by the user in the filename to be completed. This
6022 variable is `on' by default.
6023
ccc6cda3
JA
6024 `output-meta'
6025 If set to `on', Readline will display characters with the
6026 eighth bit set directly rather than as a meta-prefixed escape
6027 sequence. The default is `off'.
6028
7117c2d2
JA
6029 `page-completions'
6030 If set to `on', Readline uses an internal `more'-like pager
6031 to display a screenful of possible completions at a time.
6032 This variable is `on' by default.
6033
cce855bc
JA
6034 `print-completions-horizontally'
6035 If set to `on', Readline will display completions with matches
6036 sorted horizontally in alphabetical order, rather than down
6037 the screen. The default is `off'.
6038
ccc6cda3
JA
6039 `show-all-if-ambiguous'
6040 This alters the default behavior of the completion functions.
6041 If set to `on', words which have more than one possible
6042 completion cause the matches to be listed immediately instead
6043 of ringing the bell. The default value is `off'.
6044
d3a24ed2
CR
6045 `show-all-if-unmodified'
6046 This alters the default behavior of the completion functions
6047 in a fashion similar to SHOW-ALL-IF-AMBIGUOUS. If set to
6048 `on', words which have more than one possible completion
6049 without any possible partial completion (the possible
6050 completions don't share a common prefix) cause the matches to
6051 be listed immediately instead of ringing the bell. The
6052 default value is `off'.
6053
ccc6cda3
JA
6054 `visible-stats'
6055 If set to `on', a character denoting a file's type is
6056 appended to the filename when listing possible completions.
6057 The default is `off'.
6058
761783bf 6059
ccc6cda3
JA
6060Key Bindings
6061 The syntax for controlling key bindings in the init file is
bb70624e 6062 simple. First you need to find the name of the command that you
cce855bc
JA
6063 want to change. The following sections contain tables of the
6064 command name, the default keybinding, if any, and a short
6065 description of what the command does.
ccc6cda3 6066
28ef6c31
JA
6067 Once you know the name of the command, simply place on a line in
6068 the init file the name of the key you wish to bind the command to,
6069 a colon, and then the name of the command. The name of the key
6070 can be expressed in different ways, depending on what you find most
6071 comfortable.
6072
6073 In addition to command names, readline allows keys to be bound to
6074 a string that is inserted when the key is pressed (a MACRO).
ccc6cda3 6075
bb70624e
JA
6076 The `bind -p' command displays Readline function names and
6077 bindings in a format that can put directly into an initialization
6078 file. *Note Bash Builtins::.
6079
ccc6cda3
JA
6080 KEYNAME: FUNCTION-NAME or MACRO
6081 KEYNAME is the name of a key spelled out in English. For
6082 example:
6083 Control-u: universal-argument
6084 Meta-Rubout: backward-kill-word
6085 Control-o: "> output"
6086
28ef6c31
JA
6087 In the above example, `C-u' is bound to the function
6088 `universal-argument', `M-DEL' is bound to the function
6089 `backward-kill-word', and `C-o' is bound to run the macro
ccc6cda3
JA
6090 expressed on the right hand side (that is, to insert the text
6091 `> output' into the line).
6092
28ef6c31
JA
6093 A number of symbolic character names are recognized while
6094 processing this key binding syntax: DEL, ESC, ESCAPE, LFD,
6095 NEWLINE, RET, RETURN, RUBOUT, SPACE, SPC, and TAB.
6096
ccc6cda3
JA
6097 "KEYSEQ": FUNCTION-NAME or MACRO
6098 KEYSEQ differs from KEYNAME above in that strings denoting an
6099 entire key sequence can be specified, by placing the key
6100 sequence in double quotes. Some GNU Emacs style key escapes
6101 can be used, as in the following example, but the special
6102 character names are not recognized.
6103
6104 "\C-u": universal-argument
6105 "\C-x\C-r": re-read-init-file
6106 "\e[11~": "Function Key 1"
6107
28ef6c31 6108 In the above example, `C-u' is again bound to the function
ccc6cda3 6109 `universal-argument' (just as it was in the first example),
28ef6c31
JA
6110 `C-x C-r' is bound to the function `re-read-init-file', and
6111 `<ESC> <[> <1> <1> <~>' is bound to insert the text `Function
6112 Key 1'.
cce855bc 6113
761783bf 6114
cce855bc
JA
6115 The following GNU Emacs style escape sequences are available when
6116 specifying key sequences:
6117
6118 `\C-'
6119 control prefix
6120
6121 `\M-'
6122 meta prefix
6123
6124 `\e'
6125 an escape character
6126
6127 `\\'
6128 backslash
6129
6130 `\"'
bb70624e 6131 <">, a double quotation mark
cce855bc
JA
6132
6133 `\''
bb70624e 6134 <'>, a single quote or apostrophe
cce855bc
JA
6135
6136 In addition to the GNU Emacs style escape sequences, a second set
6137 of backslash escapes is available:
ccc6cda3 6138
cce855bc
JA
6139 `\a'
6140 alert (bell)
6141
6142 `\b'
6143 backspace
6144
6145 `\d'
6146 delete
6147
6148 `\f'
6149 form feed
6150
6151 `\n'
6152 newline
ccc6cda3 6153
cce855bc
JA
6154 `\r'
6155 carriage return
ccc6cda3 6156
cce855bc
JA
6157 `\t'
6158 horizontal tab
ccc6cda3 6159
cce855bc
JA
6160 `\v'
6161 vertical tab
ccc6cda3 6162
cce855bc 6163 `\NNN'
f73dda09 6164 the eight-bit character whose value is the octal value NNN
cce855bc 6165 (one to three digits)
ccc6cda3 6166
f73dda09
JA
6167 `\xHH'
6168 the eight-bit character whose value is the hexadecimal value
6169 HH (one or two hex digits)
6170
cce855bc
JA
6171 When entering the text of a macro, single or double quotes must be
6172 used to indicate a macro definition. Unquoted text is assumed to
6173 be a function name. In the macro body, the backslash escapes
6174 described above are expanded. Backslash will quote any other
6175 character in the macro text, including `"' and `''. For example,
6176 the following binding will make `C-x \' insert a single `\' into
6177 the line:
6178 "\C-x\\": "\\"
ccc6cda3 6179
761783bf 6180
ccc6cda3
JA
6181\1f
6182File: bashref.info, Node: Conditional Init Constructs, Next: Sample Init File, Prev: Readline Init File Syntax, Up: Readline Init File
6183
37c41ab1
CR
61848.3.2 Conditional Init Constructs
6185---------------------------------
ccc6cda3 6186
37c41ab1 6187Readline implements a facility similar in spirit to the conditional
ccc6cda3
JA
6188compilation features of the C preprocessor which allows key bindings
6189and variable settings to be performed as the result of tests. There
cce855bc 6190are four parser directives used.
ccc6cda3
JA
6191
6192`$if'
6193 The `$if' construct allows bindings to be made based on the
6194 editing mode, the terminal being used, or the application using
6195 Readline. The text of the test extends to the end of the line; no
6196 characters are required to isolate it.
6197
6198 `mode'
6199 The `mode=' form of the `$if' directive is used to test
6200 whether Readline is in `emacs' or `vi' mode. This may be
6201 used in conjunction with the `set keymap' command, for
6202 instance, to set bindings in the `emacs-standard' and
6203 `emacs-ctlx' keymaps only if Readline is starting out in
6204 `emacs' mode.
6205
6206 `term'
6207 The `term=' form may be used to include terminal-specific key
6208 bindings, perhaps to bind the key sequences output by the
6209 terminal's function keys. The word on the right side of the
cce855bc
JA
6210 `=' is tested against both the full name of the terminal and
6211 the portion of the terminal name before the first `-'. This
ccc6cda3
JA
6212 allows `sun' to match both `sun' and `sun-cmd', for instance.
6213
6214 `application'
6215 The APPLICATION construct is used to include
6216 application-specific settings. Each program using the
6217 Readline library sets the APPLICATION NAME, and you can test
28ef6c31
JA
6218 for a particular value. This could be used to bind key
6219 sequences to functions useful for a specific program. For
6220 instance, the following command adds a key sequence that
6221 quotes the current or previous word in Bash:
ccc6cda3
JA
6222 $if Bash
6223 # Quote the current or previous word
6224 "\C-xq": "\eb\"\ef\""
6225 $endif
6226
6227`$endif'
cce855bc
JA
6228 This command, as seen in the previous example, terminates an `$if'
6229 command.
ccc6cda3
JA
6230
6231`$else'
6232 Commands in this branch of the `$if' directive are executed if the
6233 test fails.
6234
cce855bc
JA
6235`$include'
6236 This directive takes a single filename as an argument and reads
28ef6c31
JA
6237 commands and bindings from that file. For example, the following
6238 directive reads from `/etc/inputrc':
cce855bc
JA
6239 $include /etc/inputrc
6240
ccc6cda3
JA
6241\1f
6242File: bashref.info, Node: Sample Init File, Prev: Conditional Init Constructs, Up: Readline Init File
6243
37c41ab1
CR
62448.3.3 Sample Init File
6245----------------------
ccc6cda3 6246
37c41ab1
CR
6247Here is an example of an INPUTRC file. This illustrates key binding,
6248variable assignment, and conditional syntax.
ccc6cda3
JA
6249
6250
6251 # This file controls the behaviour of line input editing for
7117c2d2
JA
6252 # programs that use the GNU Readline library. Existing
6253 # programs include FTP, Bash, and GDB.
ccc6cda3
JA
6254 #
6255 # You can re-read the inputrc file with C-x C-r.
6256 # Lines beginning with '#' are comments.
cce855bc 6257 #
7117c2d2
JA
6258 # First, include any systemwide bindings and variable
6259 # assignments from /etc/Inputrc
cce855bc 6260 $include /etc/Inputrc
37c41ab1 6261
ccc6cda3
JA
6262 #
6263 # Set various bindings for emacs mode.
37c41ab1 6264
ccc6cda3 6265 set editing-mode emacs
37c41ab1 6266
ccc6cda3 6267 $if mode=emacs
37c41ab1 6268
ccc6cda3 6269 Meta-Control-h: backward-kill-word Text after the function name is ignored
37c41ab1 6270
ccc6cda3
JA
6271 #
6272 # Arrow keys in keypad mode
6273 #
d166f048
JA
6274 #"\M-OD": backward-char
6275 #"\M-OC": forward-char
6276 #"\M-OA": previous-history
6277 #"\M-OB": next-history
ccc6cda3
JA
6278 #
6279 # Arrow keys in ANSI mode
6280 #
d166f048
JA
6281 "\M-[D": backward-char
6282 "\M-[C": forward-char
6283 "\M-[A": previous-history
6284 "\M-[B": next-history
ccc6cda3
JA
6285 #
6286 # Arrow keys in 8 bit keypad mode
6287 #
d166f048
JA
6288 #"\M-\C-OD": backward-char
6289 #"\M-\C-OC": forward-char
6290 #"\M-\C-OA": previous-history
6291 #"\M-\C-OB": next-history
ccc6cda3
JA
6292 #
6293 # Arrow keys in 8 bit ANSI mode
6294 #
d166f048
JA
6295 #"\M-\C-[D": backward-char
6296 #"\M-\C-[C": forward-char
6297 #"\M-\C-[A": previous-history
6298 #"\M-\C-[B": next-history
37c41ab1 6299
ccc6cda3 6300 C-q: quoted-insert
37c41ab1 6301
ccc6cda3 6302 $endif
37c41ab1 6303
ccc6cda3
JA
6304 # An old-style binding. This happens to be the default.
6305 TAB: complete
37c41ab1 6306
ccc6cda3
JA
6307 # Macros that are convenient for shell interaction
6308 $if Bash
6309 # edit the path
6310 "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
7117c2d2
JA
6311 # prepare to type a quoted word --
6312 # insert open and close double quotes
ccc6cda3
JA
6313 # and move to just after the open quote
6314 "\C-x\"": "\"\"\C-b"
7117c2d2
JA
6315 # insert a backslash (testing backslash escapes
6316 # in sequences and macros)
ccc6cda3
JA
6317 "\C-x\\": "\\"
6318 # Quote the current or previous word
6319 "\C-xq": "\eb\"\ef\""
6320 # Add a binding to refresh the line, which is unbound
6321 "\C-xr": redraw-current-line
6322 # Edit variable on current line.
6323 "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
6324 $endif
37c41ab1 6325
ccc6cda3
JA
6326 # use a visible bell if one is available
6327 set bell-style visible
37c41ab1 6328
ccc6cda3
JA
6329 # don't strip characters to 7 bits when reading
6330 set input-meta on
37c41ab1 6331
7117c2d2
JA
6332 # allow iso-latin1 characters to be inserted rather
6333 # than converted to prefix-meta sequences
ccc6cda3 6334 set convert-meta off
37c41ab1 6335
7117c2d2
JA
6336 # display characters with the eighth bit set directly
6337 # rather than as meta-prefixed characters
ccc6cda3 6338 set output-meta on
37c41ab1 6339
7117c2d2
JA
6340 # if there are more than 150 possible completions for
6341 # a word, ask the user if he wants to see all of them
ccc6cda3 6342 set completion-query-items 150
37c41ab1 6343
ccc6cda3
JA
6344 # For FTP
6345 $if Ftp
6346 "\C-xg": "get \M-?"
6347 "\C-xt": "put \M-?"
6348 "\M-.": yank-last-arg
6349 $endif
6350
6351\1f
bb70624e
JA
6352File: bashref.info, Node: Bindable Readline Commands, Next: Readline vi Mode, Prev: Readline Init File, Up: Command Line Editing
6353
37c41ab1
CR
63548.4 Bindable Readline Commands
6355==============================
bb70624e
JA
6356
6357* Menu:
6358
6359* Commands For Moving:: Moving about the line.
6360* Commands For History:: Getting at previous lines.
6361* Commands For Text:: Commands for changing text.
6362* Commands For Killing:: Commands for killing and yanking.
6363* Numeric Arguments:: Specifying numeric arguments, repeat counts.
6364* Commands For Completion:: Getting Readline to do the typing for you.
6365* Keyboard Macros:: Saving and re-executing typed characters
6366* Miscellaneous Commands:: Other miscellaneous commands.
6367
6368 This section describes Readline commands that may be bound to key
6369sequences. You can list your key bindings by executing `bind -P' or,
6370for a more terse format, suitable for an INPUTRC file, `bind -p'.
28ef6c31
JA
6371(*Note Bash Builtins::.) Command names without an accompanying key
6372sequence are unbound by default.
bb70624e 6373
28ef6c31
JA
6374 In the following descriptions, "point" refers to the current cursor
6375position, and "mark" refers to a cursor position saved by the
bb70624e 6376`set-mark' command. The text between the point and mark is referred to
28ef6c31 6377as the "region".
bb70624e
JA
6378
6379\1f
6380File: bashref.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands
6381
37c41ab1
CR
63828.4.1 Commands For Moving
6383-------------------------
bb70624e
JA
6384
6385`beginning-of-line (C-a)'
6386 Move to the start of the current line.
6387
6388`end-of-line (C-e)'
6389 Move to the end of the line.
6390
6391`forward-char (C-f)'
6392 Move forward a character.
6393
6394`backward-char (C-b)'
6395 Move back a character.
6396
6397`forward-word (M-f)'
6398 Move forward to the end of the next word. Words are composed of
6399 letters and digits.
6400
6401`backward-word (M-b)'
6402 Move back to the start of the current or previous word. Words are
6403 composed of letters and digits.
6404
6405`clear-screen (C-l)'
6406 Clear the screen and redraw the current line, leaving the current
6407 line at the top of the screen.
6408
6409`redraw-current-line ()'
6410 Refresh the current line. By default, this is unbound.
6411
761783bf 6412
bb70624e
JA
6413\1f
6414File: bashref.info, Node: Commands For History, Next: Commands For Text, Prev: Commands For Moving, Up: Bindable Readline Commands
6415
37c41ab1
CR
64168.4.2 Commands For Manipulating The History
6417-------------------------------------------
bb70624e 6418
28ef6c31 6419`accept-line (Newline or Return)'
bb70624e
JA
6420 Accept the line regardless of where the cursor is. If this line is
6421 non-empty, add it to the history list according to the setting of
28ef6c31
JA
6422 the `HISTCONTROL' and `HISTIGNORE' variables. If this line is a
6423 modified history line, then restore the history line to its
6424 original state.
bb70624e
JA
6425
6426`previous-history (C-p)'
28ef6c31
JA
6427 Move `back' through the history list, fetching the previous
6428 command.
bb70624e
JA
6429
6430`next-history (C-n)'
28ef6c31 6431 Move `forward' through the history list, fetching the next command.
bb70624e
JA
6432
6433`beginning-of-history (M-<)'
6434 Move to the first line in the history.
6435
6436`end-of-history (M->)'
6437 Move to the end of the input history, i.e., the line currently
6438 being entered.
6439
6440`reverse-search-history (C-r)'
6441 Search backward starting at the current line and moving `up'
6442 through the history as necessary. This is an incremental search.
6443
6444`forward-search-history (C-s)'
6445 Search forward starting at the current line and moving `down'
6446 through the the history as necessary. This is an incremental
6447 search.
6448
6449`non-incremental-reverse-search-history (M-p)'
6450 Search backward starting at the current line and moving `up'
6451 through the history as necessary using a non-incremental search
6452 for a string supplied by the user.
6453
6454`non-incremental-forward-search-history (M-n)'
6455 Search forward starting at the current line and moving `down'
6456 through the the history as necessary using a non-incremental search
6457 for a string supplied by the user.
6458
6459`history-search-forward ()'
6460 Search forward through the history for the string of characters
6461 between the start of the current line and the point. This is a
6462 non-incremental search. By default, this command is unbound.
6463
6464`history-search-backward ()'
6465 Search backward through the history for the string of characters
6466 between the start of the current line and the point. This is a
6467 non-incremental search. By default, this command is unbound.
6468
6469`yank-nth-arg (M-C-y)'
6470 Insert the first argument to the previous command (usually the
28ef6c31
JA
6471 second word on the previous line) at point. With an argument N,
6472 insert the Nth word from the previous command (the words in the
6473 previous command begin with word 0). A negative argument inserts
6474 the Nth word from the end of the previous command.
bb70624e 6475
28ef6c31 6476`yank-last-arg (M-. or M-_)'
bb70624e
JA
6477 Insert last argument to the previous command (the last word of the
6478 previous history entry). With an argument, behave exactly like
6479 `yank-nth-arg'. Successive calls to `yank-last-arg' move back
6480 through the history list, inserting the last argument of each line
6481 in turn.
6482
761783bf 6483
bb70624e
JA
6484\1f
6485File: bashref.info, Node: Commands For Text, Next: Commands For Killing, Prev: Commands For History, Up: Bindable Readline Commands
6486
37c41ab1
CR
64878.4.3 Commands For Changing Text
6488--------------------------------
bb70624e
JA
6489
6490`delete-char (C-d)'
28ef6c31
JA
6491 Delete the character at point. If point is at the beginning of
6492 the line, there are no characters in the line, and the last
6493 character typed was not bound to `delete-char', then return EOF.
bb70624e
JA
6494
6495`backward-delete-char (Rubout)'
6496 Delete the character behind the cursor. A numeric argument means
6497 to kill the characters instead of deleting them.
6498
6499`forward-backward-delete-char ()'
6500 Delete the character under the cursor, unless the cursor is at the
6501 end of the line, in which case the character behind the cursor is
6502 deleted. By default, this is not bound to a key.
6503
28ef6c31 6504`quoted-insert (C-q or C-v)'
bb70624e 6505 Add the next character typed to the line verbatim. This is how to
28ef6c31 6506 insert key sequences like `C-q', for example.
bb70624e
JA
6507
6508`self-insert (a, b, A, 1, !, ...)'
6509 Insert yourself.
6510
6511`transpose-chars (C-t)'
6512 Drag the character before the cursor forward over the character at
6513 the cursor, moving the cursor forward as well. If the insertion
6514 point is at the end of the line, then this transposes the last two
6515 characters of the line. Negative arguments have no effect.
6516
6517`transpose-words (M-t)'
6518 Drag the word before point past the word after point, moving point
f73dda09
JA
6519 past that word as well. If the insertion point is at the end of
6520 the line, this transposes the last two words on the line.
bb70624e
JA
6521
6522`upcase-word (M-u)'
6523 Uppercase the current (or following) word. With a negative
6524 argument, uppercase the previous word, but do not move the cursor.
6525
6526`downcase-word (M-l)'
6527 Lowercase the current (or following) word. With a negative
6528 argument, lowercase the previous word, but do not move the cursor.
6529
6530`capitalize-word (M-c)'
6531 Capitalize the current (or following) word. With a negative
6532 argument, capitalize the previous word, but do not move the cursor.
6533
7117c2d2
JA
6534`overwrite-mode ()'
6535 Toggle overwrite mode. With an explicit positive numeric argument,
6536 switches to overwrite mode. With an explicit non-positive numeric
6537 argument, switches to insert mode. This command affects only
6538 `emacs' mode; `vi' mode does overwrite differently. Each call to
6539 `readline()' starts in insert mode.
6540
6541 In overwrite mode, characters bound to `self-insert' replace the
6542 text at point rather than pushing the text to the right.
6543 Characters bound to `backward-delete-char' replace the character
6544 before point with a space.
6545
6546 By default, this command is unbound.
6547
761783bf 6548
bb70624e
JA
6549\1f
6550File: bashref.info, Node: Commands For Killing, Next: Numeric Arguments, Prev: Commands For Text, Up: Bindable Readline Commands
6551
37c41ab1
CR
65528.4.4 Killing And Yanking
6553-------------------------
bb70624e
JA
6554
6555`kill-line (C-k)'
6556 Kill the text from point to the end of the line.
6557
6558`backward-kill-line (C-x Rubout)'
6559 Kill backward to the beginning of the line.
6560
6561`unix-line-discard (C-u)'
6562 Kill backward from the cursor to the beginning of the current line.
6563
6564`kill-whole-line ()'
28ef6c31
JA
6565 Kill all characters on the current line, no matter where point is.
6566 By default, this is unbound.
bb70624e
JA
6567
6568`kill-word (M-d)'
6569 Kill from point to the end of the current word, or if between
6570 words, to the end of the next word. Word boundaries are the same
6571 as `forward-word'.
6572
28ef6c31 6573`backward-kill-word (M-<DEL>)'
bb70624e
JA
6574 Kill the word behind point. Word boundaries are the same as
6575 `backward-word'.
6576
6577`unix-word-rubout (C-w)'
6578 Kill the word behind point, using white space as a word boundary.
6579 The killed text is saved on the kill-ring.
6580
113d85a4
CR
6581`unix-filename-rubout ()'
6582 Kill the word behind point, using white space and the slash
6583 character as the word boundaries. The killed text is saved on the
6584 kill-ring.
6585
bb70624e
JA
6586`delete-horizontal-space ()'
6587 Delete all spaces and tabs around point. By default, this is
6588 unbound.
6589
6590`kill-region ()'
6591 Kill the text in the current region. By default, this command is
6592 unbound.
6593
6594`copy-region-as-kill ()'
6595 Copy the text in the region to the kill buffer, so it can be yanked
6596 right away. By default, this command is unbound.
6597
6598`copy-backward-word ()'
6599 Copy the word before point to the kill buffer. The word
6600 boundaries are the same as `backward-word'. By default, this
6601 command is unbound.
6602
6603`copy-forward-word ()'
6604 Copy the word following point to the kill buffer. The word
6605 boundaries are the same as `forward-word'. By default, this
6606 command is unbound.
6607
6608`yank (C-y)'
28ef6c31 6609 Yank the top of the kill ring into the buffer at point.
bb70624e
JA
6610
6611`yank-pop (M-y)'
6612 Rotate the kill-ring, and yank the new top. You can only do this
28ef6c31 6613 if the prior command is `yank' or `yank-pop'.
bb70624e
JA
6614
6615\1f
6616File: bashref.info, Node: Numeric Arguments, Next: Commands For Completion, Prev: Commands For Killing, Up: Bindable Readline Commands
6617
37c41ab1
CR
66188.4.5 Specifying Numeric Arguments
6619----------------------------------
bb70624e
JA
6620
6621`digit-argument (M-0, M-1, ... M--)'
6622 Add this digit to the argument already accumulating, or start a new
28ef6c31 6623 argument. `M--' starts a negative argument.
bb70624e
JA
6624
6625`universal-argument ()'
6626 This is another way to specify an argument. If this command is
6627 followed by one or more digits, optionally with a leading minus
6628 sign, those digits define the argument. If the command is
6629 followed by digits, executing `universal-argument' again ends the
6630 numeric argument, but is otherwise ignored. As a special case, if
6631 this command is immediately followed by a character that is
6632 neither a digit or minus sign, the argument count for the next
6633 command is multiplied by four. The argument count is initially
6634 one, so executing this function the first time makes the argument
6635 count four, a second time makes the argument count sixteen, and so
6636 on. By default, this is not bound to a key.
6637
6638\1f
6639File: bashref.info, Node: Commands For Completion, Next: Keyboard Macros, Prev: Numeric Arguments, Up: Bindable Readline Commands
6640
37c41ab1
CR
66418.4.6 Letting Readline Type For You
6642-----------------------------------
bb70624e 6643
28ef6c31
JA
6644`complete (<TAB>)'
6645 Attempt to perform completion on the text before point. The
6646 actual completion performed is application-specific. Bash
6647 attempts completion treating the text as a variable (if the text
6648 begins with `$'), username (if the text begins with `~'), hostname
6649 (if the text begins with `@'), or command (including aliases and
6650 functions) in turn. If none of these produces a match, filename
6651 completion is attempted.
bb70624e
JA
6652
6653`possible-completions (M-?)'
28ef6c31 6654 List the possible completions of the text before point.
bb70624e
JA
6655
6656`insert-completions (M-*)'
6657 Insert all completions of the text before point that would have
6658 been generated by `possible-completions'.
6659
6660`menu-complete ()'
6661 Similar to `complete', but replaces the word to be completed with
6662 a single match from the list of possible completions. Repeated
6663 execution of `menu-complete' steps through the list of possible
6664 completions, inserting each match in turn. At the end of the list
28ef6c31
JA
6665 of completions, the bell is rung (subject to the setting of
6666 `bell-style') and the original text is restored. An argument of N
6667 moves N positions forward in the list of matches; a negative
6668 argument may be used to move backward through the list. This
6669 command is intended to be bound to <TAB>, but is unbound by
bb70624e
JA
6670 default.
6671
6672`delete-char-or-list ()'
6673 Deletes the character under the cursor if not at the beginning or
6674 end of the line (like `delete-char'). If at the end of the line,
6675 behaves identically to `possible-completions'. This command is
6676 unbound by default.
6677
6678`complete-filename (M-/)'
6679 Attempt filename completion on the text before point.
6680
6681`possible-filename-completions (C-x /)'
6682 List the possible completions of the text before point, treating
6683 it as a filename.
6684
6685`complete-username (M-~)'
6686 Attempt completion on the text before point, treating it as a
6687 username.
6688
6689`possible-username-completions (C-x ~)'
6690 List the possible completions of the text before point, treating
6691 it as a username.
6692
6693`complete-variable (M-$)'
6694 Attempt completion on the text before point, treating it as a
6695 shell variable.
6696
6697`possible-variable-completions (C-x $)'
6698 List the possible completions of the text before point, treating
6699 it as a shell variable.
6700
6701`complete-hostname (M-@)'
6702 Attempt completion on the text before point, treating it as a
6703 hostname.
6704
6705`possible-hostname-completions (C-x @)'
6706 List the possible completions of the text before point, treating
6707 it as a hostname.
6708
6709`complete-command (M-!)'
6710 Attempt completion on the text before point, treating it as a
6711 command name. Command completion attempts to match the text
6712 against aliases, reserved words, shell functions, shell builtins,
6713 and finally executable filenames, in that order.
6714
6715`possible-command-completions (C-x !)'
6716 List the possible completions of the text before point, treating
6717 it as a command name.
6718
28ef6c31 6719`dynamic-complete-history (M-<TAB>)'
bb70624e
JA
6720 Attempt completion on the text before point, comparing the text
6721 against lines from the history list for possible completion
6722 matches.
6723
6724`complete-into-braces (M-{)'
6725 Perform filename completion and insert the list of possible
6726 completions enclosed within braces so the list is available to the
28ef6c31 6727 shell (*note Brace Expansion::).
bb70624e 6728
761783bf 6729
bb70624e
JA
6730\1f
6731File: bashref.info, Node: Keyboard Macros, Next: Miscellaneous Commands, Prev: Commands For Completion, Up: Bindable Readline Commands
6732
37c41ab1
CR
67338.4.7 Keyboard Macros
6734---------------------
bb70624e
JA
6735
6736`start-kbd-macro (C-x ()'
6737 Begin saving the characters typed into the current keyboard macro.
6738
6739`end-kbd-macro (C-x ))'
6740 Stop saving the characters typed into the current keyboard macro
6741 and save the definition.
6742
6743`call-last-kbd-macro (C-x e)'
6744 Re-execute the last keyboard macro defined, by making the
6745 characters in the macro appear as if typed at the keyboard.
6746
761783bf 6747
bb70624e
JA
6748\1f
6749File: bashref.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up: Bindable Readline Commands
6750
37c41ab1
CR
67518.4.8 Some Miscellaneous Commands
6752---------------------------------
bb70624e
JA
6753
6754`re-read-init-file (C-x C-r)'
6755 Read in the contents of the INPUTRC file, and incorporate any
6756 bindings or variable assignments found there.
6757
6758`abort (C-g)'
6759 Abort the current editing command and ring the terminal's bell
6760 (subject to the setting of `bell-style').
6761
6762`do-uppercase-version (M-a, M-b, M-X, ...)'
6763 If the metafied character X is lowercase, run the command that is
6764 bound to the corresponding uppercase character.
6765
28ef6c31
JA
6766`prefix-meta (<ESC>)'
6767 Metafy the next character typed. This is for keyboards without a
6768 meta key. Typing `<ESC> f' is equivalent to typing `M-f'.
bb70624e 6769
28ef6c31 6770`undo (C-_ or C-x C-u)'
bb70624e
JA
6771 Incremental undo, separately remembered for each line.
6772
6773`revert-line (M-r)'
6774 Undo all changes made to this line. This is like executing the
6775 `undo' command enough times to get back to the beginning.
6776
6777`tilde-expand (M-&)'
6778 Perform tilde expansion on the current word.
6779
6780`set-mark (C-@)'
28ef6c31
JA
6781 Set the mark to the point. If a numeric argument is supplied, the
6782 mark is set to that position.
bb70624e
JA
6783
6784`exchange-point-and-mark (C-x C-x)'
6785 Swap the point with the mark. The current cursor position is set
6786 to the saved position, and the old cursor position is saved as the
6787 mark.
6788
6789`character-search (C-])'
6790 A character is read and point is moved to the next occurrence of
6791 that character. A negative count searches for previous
6792 occurrences.
6793
6794`character-search-backward (M-C-])'
6795 A character is read and point is moved to the previous occurrence
6796 of that character. A negative count searches for subsequent
6797 occurrences.
6798
6799`insert-comment (M-#)'
7117c2d2
JA
6800 Without a numeric argument, the value of the `comment-begin'
6801 variable is inserted at the beginning of the current line. If a
6802 numeric argument is supplied, this command acts as a toggle: if
6803 the characters at the beginning of the line do not match the value
6804 of `comment-begin', the value is inserted, otherwise the
6805 characters in `comment-begin' are deleted from the beginning of
6806 the line. In either case, the line is accepted as if a newline
6807 had been typed. The default value of `comment-begin' causes this
6808 command to make the current line a shell comment. If a numeric
6809 argument causes the comment character to be removed, the line will
6810 be executed by the shell.
bb70624e
JA
6811
6812`dump-functions ()'
6813 Print all of the functions and their key bindings to the Readline
6814 output stream. If a numeric argument is supplied, the output is
6815 formatted in such a way that it can be made part of an INPUTRC
6816 file. This command is unbound by default.
6817
6818`dump-variables ()'
6819 Print all of the settable variables and their values to the
6820 Readline output stream. If a numeric argument is supplied, the
6821 output is formatted in such a way that it can be made part of an
6822 INPUTRC file. This command is unbound by default.
6823
6824`dump-macros ()'
6825 Print all of the Readline key sequences bound to macros and the
28ef6c31
JA
6826 strings they output. If a numeric argument is supplied, the
6827 output is formatted in such a way that it can be made part of an
6828 INPUTRC file. This command is unbound by default.
bb70624e 6829
7117c2d2
JA
6830`glob-complete-word (M-g)'
6831 The word before point is treated as a pattern for pathname
6832 expansion, with an asterisk implicitly appended. This pattern is
6833 used to generate a list of matching file names for possible
6834 completions.
6835
bb70624e
JA
6836`glob-expand-word (C-x *)'
6837 The word before point is treated as a pattern for pathname
6838 expansion, and the list of matching file names is inserted,
7117c2d2
JA
6839 replacing the word. If a numeric argument is supplied, a `*' is
6840 appended before pathname expansion.
bb70624e
JA
6841
6842`glob-list-expansions (C-x g)'
6843 The list of expansions that would have been generated by
7117c2d2
JA
6844 `glob-expand-word' is displayed, and the line is redrawn. If a
6845 numeric argument is supplied, a `*' is appended before pathname
6846 expansion.
bb70624e
JA
6847
6848`display-shell-version (C-x C-v)'
6849 Display version information about the current instance of Bash.
6850
6851`shell-expand-line (M-C-e)'
6852 Expand the line as the shell does. This performs alias and
6853 history expansion as well as all of the shell word expansions
28ef6c31 6854 (*note Shell Expansions::).
bb70624e
JA
6855
6856`history-expand-line (M-^)'
6857 Perform history expansion on the current line.
6858
6859`magic-space ()'
6860 Perform history expansion on the current line and insert a space
28ef6c31 6861 (*note History Interaction::).
bb70624e
JA
6862
6863`alias-expand-line ()'
28ef6c31 6864 Perform alias expansion on the current line (*note Aliases::).
bb70624e
JA
6865
6866`history-and-alias-expand-line ()'
6867 Perform history and alias expansion on the current line.
6868
28ef6c31 6869`insert-last-argument (M-. or M-_)'
bb70624e
JA
6870 A synonym for `yank-last-arg'.
6871
6872`operate-and-get-next (C-o)'
6873 Accept the current line for execution and fetch the next line
6874 relative to the current line from the history for editing. Any
6875 argument is ignored.
6876
7117c2d2
JA
6877`edit-and-execute-command (C-xC-e)'
6878 Invoke an editor on the current command line, and execute the
c2258e1c 6879 result as shell commands. Bash attempts to invoke `$VISUAL',
7117c2d2 6880 `$EDITOR', and `emacs' as the editor, in that order.
bb70624e 6881
761783bf 6882
bb70624e
JA
6883\1f
6884File: bashref.info, Node: Readline vi Mode, Next: Programmable Completion, Prev: Bindable Readline Commands, Up: Command Line Editing
6885
37c41ab1
CR
68868.5 Readline vi Mode
6887====================
bb70624e 6888
37c41ab1 6889While the Readline library does not have a full set of `vi' editing
bb70624e
JA
6890functions, it does contain enough to allow simple editing of the line.
6891The Readline `vi' mode behaves as specified in the POSIX 1003.2
6892standard.
6893
6894 In order to switch interactively between `emacs' and `vi' editing
6895modes, use the `set -o emacs' and `set -o vi' commands (*note The Set
28ef6c31 6896Builtin::). The Readline default is `emacs' mode.
bb70624e
JA
6897
6898 When you enter a line in `vi' mode, you are already placed in
6899`insertion' mode, as if you had typed an `i'. Pressing <ESC> switches
6900you into `command' mode, where you can edit the text of the line with
6901the standard `vi' movement keys, move to previous history lines with
6902`k' and subsequent lines with `j', and so forth.
6903
6904\1f
6905File: bashref.info, Node: Programmable Completion, Next: Programmable Completion Builtins, Prev: Readline vi Mode, Up: Command Line Editing
6906
37c41ab1
CR
69078.6 Programmable Completion
6908===========================
bb70624e 6909
37c41ab1 6910When word completion is attempted for an argument to a command for
bb70624e 6911which a completion specification (a COMPSPEC) has been defined using
28ef6c31 6912the `complete' builtin (*note Programmable Completion Builtins::), the
bb70624e
JA
6913programmable completion facilities are invoked.
6914
6915 First, the command name is identified. If a compspec has been
6916defined for that command, the compspec is used to generate the list of
6917possible completions for the word. If the command word is a full
6918pathname, a compspec for the full pathname is searched for first. If
6919no compspec is found for the full pathname, an attempt is made to find
6920a compspec for the portion following the final slash.
6921
6922 Once a compspec has been found, it is used to generate the list of
6923matching words. If a compspec is not found, the default Bash completion
28ef6c31 6924described above (*note Commands For Completion::) is performed.
bb70624e
JA
6925
6926 First, the actions specified by the compspec are used. Only matches
6927which are prefixed by the word being completed are returned. When the
6928`-f' or `-d' option is used for filename or directory name completion,
6929the shell variable `FIGNORE' is used to filter the matches. *Note Bash
6930Variables::, for a description of `FIGNORE'.
6931
6932 Any completions specified by a filename expansion pattern to the
6933`-G' option are generated next. The words generated by the pattern
6934need not match the word being completed. The `GLOBIGNORE' shell
6935variable is not used to filter the matches, but the `FIGNORE' shell
6936variable is used.
6937
6938 Next, the string specified as the argument to the `-W' option is
6939considered. The string is first split using the characters in the `IFS'
6940special variable as delimiters. Shell quoting is honored. Each word
6941is then expanded using brace expansion, tilde expansion, parameter and
6942variable expansion, command substitution, arithmetic expansion, and
28ef6c31
JA
6943pathname expansion, as described above (*note Shell Expansions::). The
6944results are split using the rules described above (*note Word
6945Splitting::). The results of the expansion are prefix-matched against
bb70624e
JA
6946the word being completed, and the matching words become the possible
6947completions.
6948
6949 After these matches have been generated, any shell function or
6950command specified with the `-F' and `-C' options is invoked. When the
6951command or function is invoked, the `COMP_LINE' and `COMP_POINT'
6952variables are assigned values as described above (*note Bash
28ef6c31 6953Variables::). If a shell function is being invoked, the `COMP_WORDS'
bb70624e
JA
6954and `COMP_CWORD' variables are also set. When the function or command
6955is invoked, the first argument is the name of the command whose
6956arguments are being completed, the second argument is the word being
6957completed, and the third argument is the word preceding the word being
6958completed on the current command line. No filtering of the generated
6959completions against the word being completed is performed; the function
6960or command has complete freedom in generating the matches.
6961
6962 Any function specified with `-F' is invoked first. The function may
6963use any of the shell facilities, including the `compgen' builtin
28ef6c31
JA
6964described below (*note Programmable Completion Builtins::), to generate
6965the matches. It must put the possible completions in the `COMPREPLY'
6966array variable.
bb70624e
JA
6967
6968 Next, any command specified with the `-C' option is invoked in an
6969environment equivalent to command substitution. It should print a list
6970of completions, one per line, to the standard output. Backslash may be
6971used to escape a newline, if necessary.
6972
6973 After all of the possible completions are generated, any filter
6974specified with the `-X' option is applied to the list. The filter is a
6975pattern as used for pathname expansion; a `&' in the pattern is
6976replaced with the text of the word being completed. A literal `&' may
6977be escaped with a backslash; the backslash is removed before attempting
6978a match. Any completion that matches the pattern will be removed from
6979the list. A leading `!' negates the pattern; in this case any
6980completion not matching the pattern will be removed.
6981
6982 Finally, any prefix and suffix specified with the `-P' and `-S'
6983options are added to each member of the completion list, and the result
6984is returned to the Readline completion code as the list of possible
6985completions.
6986
28ef6c31
JA
6987 If the previously-applied actions do not generate any matches, and
6988the `-o dirnames' option was supplied to `complete' when the compspec
6989was defined, directory name completion is attempted.
6990
d3a24ed2
CR
6991 If the `-o plusdirs' option was supplied to `complete' when the
6992compspec was defined, directory name completion is attempted and any
6993matches are added to the results of the other actions.
6994
28ef6c31
JA
6995 By default, if a compspec is found, whatever it generates is
6996returned to the completion code as the full set of possible completions.
6997The default Bash completions are not attempted, and the Readline default
d3a24ed2
CR
6998of filename completion is disabled. If the `-o bashdefault' option was
6999supplied to `complete' when the compspec was defined, the default Bash
7000completions are attempted if the compspec generates no matches. If the
7001`-o default' option was supplied to `complete' when the compspec was
7002defined, Readline's default completion will be performed if the
7003compspec (and, if attempted, the default Bash completions) generate no
28ef6c31 7004matches.
bb70624e 7005
7117c2d2
JA
7006 When a compspec indicates that directory name completion is desired,
7007the programmable completion functions force Readline to append a slash
7008to completed names which are symbolic links to directories, subject to
7009the value of the MARK-DIRECTORIES Readline variable, regardless of the
7010setting of the MARK-SYMLINKED-DIRECTORIES Readline variable.
7011
bb70624e
JA
7012\1f
7013File: bashref.info, Node: Programmable Completion Builtins, Prev: Programmable Completion, Up: Command Line Editing
7014
37c41ab1
CR
70158.7 Programmable Completion Builtins
7016====================================
bb70624e 7017
37c41ab1 7018Two builtin commands are available to manipulate the programmable
bb70624e
JA
7019completion facilities.
7020
7021`compgen'
7022 `compgen [OPTION] [WORD]'
7023
7024 Generate possible completion matches for WORD according to the
7025 OPTIONs, which may be any option accepted by the `complete'
7026 builtin with the exception of `-p' and `-r', and write the matches
7027 to the standard output. When using the `-F' or `-C' options, the
7028 various shell variables set by the programmable completion
7029 facilities, while available, will not have useful values.
7030
7031 The matches will be generated in the same way as if the
7032 programmable completion code had generated them directly from a
7033 completion specification with the same flags. If WORD is
7034 specified, only those completions matching WORD will be displayed.
7035
7036 The return value is true unless an invalid option is supplied, or
7037 no matches were generated.
7038
7039`complete'
7117c2d2 7040 `complete [-abcdefgjksuv] [-o COMP-OPTION] [-A ACTION] [-G GLOBPAT] [-W WORDLIST]
bb70624e
JA
7041 [-P PREFIX] [-S SUFFIX] [-X FILTERPAT] [-F FUNCTION]
7042 [-C COMMAND] NAME [NAME ...]'
7043 `complete -pr [NAME ...]'
7044
7045 Specify how arguments to each NAME should be completed. If the
7046 `-p' option is supplied, or if no options are supplied, existing
7047 completion specifications are printed in a way that allows them to
7048 be reused as input. The `-r' option removes a completion
7049 specification for each NAME, or, if no NAMEs are supplied, all
7050 completion specifications.
7051
7052 The process of applying these completion specifications when word
7053 completion is attempted is described above (*note Programmable
28ef6c31 7054 Completion::).
bb70624e
JA
7055
7056 Other options, if specified, have the following meanings. The
7057 arguments to the `-G', `-W', and `-X' options (and, if necessary,
7058 the `-P' and `-S' options) should be quoted to protect them from
7059 expansion before the `complete' builtin is invoked.
7060
28ef6c31
JA
7061 `-o COMP-OPTION'
7062 The COMP-OPTION controls several aspects of the compspec's
7063 behavior beyond the simple generation of completions.
7064 COMP-OPTION may be one of:
7065
d3a24ed2
CR
7066 `bashdefault'
7067 Perform the rest of the default Bash completions if the
7068 compspec generates no matches.
7069
28ef6c31 7070 `default'
7117c2d2
JA
7071 Use Readline's default filename completion if the
7072 compspec generates no matches.
28ef6c31
JA
7073
7074 `dirnames'
7075 Perform directory name completion if the compspec
7076 generates no matches.
7077
7078 `filenames'
7079 Tell Readline that the compspec generates filenames, so
d3a24ed2 7080 it can perform any filename-specific processing (like
28ef6c31
JA
7081 adding a slash to directory names or suppressing
7082 trailing spaces). This option is intended to be used
7083 with shell functions specified with `-F'.
7084
7117c2d2
JA
7085 `nospace'
7086 Tell Readline not to append a space (the default) to
7087 words completed at the end of the line.
7088
22e63b05
CR
7089 `plusdirs'
7090 After any matches defined by the compspec are generated,
7091 directory name completion is attempted and any matches
7092 are added to the results of the other actions.
7093
7094
bb70624e
JA
7095 `-A ACTION'
7096 The ACTION may be one of the following to generate a list of
7097 possible completions:
7098
7099 `alias'
7100 Alias names. May also be specified as `-a'.
7101
7102 `arrayvar'
7103 Array variable names.
7104
7105 `binding'
7106 Readline key binding names (*note Bindable Readline
28ef6c31 7107 Commands::).
bb70624e
JA
7108
7109 `builtin'
7110 Names of shell builtin commands. May also be specified
7111 as `-b'.
7112
7113 `command'
7114 Command names. May also be specified as `-c'.
7115
7116 `directory'
7117 Directory names. May also be specified as `-d'.
7118
7119 `disabled'
7120 Names of disabled shell builtins.
7121
7122 `enabled'
7123 Names of enabled shell builtins.
7124
7125 `export'
7126 Names of exported shell variables. May also be
7127 specified as `-e'.
7128
7129 `file'
7130 File names. May also be specified as `-f'.
7131
7132 `function'
7133 Names of shell functions.
7134
f73dda09
JA
7135 `group'
7136 Group names. May also be specified as `-g'.
7137
bb70624e
JA
7138 `helptopic'
7139 Help topics as accepted by the `help' builtin (*note
28ef6c31 7140 Bash Builtins::).
bb70624e
JA
7141
7142 `hostname'
7143 Hostnames, as taken from the file specified by the
28ef6c31 7144 `HOSTFILE' shell variable (*note Bash Variables::).
bb70624e
JA
7145
7146 `job'
7147 Job names, if job control is active. May also be
7148 specified as `-j'.
7149
7150 `keyword'
7151 Shell reserved words. May also be specified as `-k'.
7152
7153 `running'
7154 Names of running jobs, if job control is active.
7155
7117c2d2
JA
7156 `service'
7157 Service names. May also be specified as `-s'.
7158
bb70624e
JA
7159 `setopt'
7160 Valid arguments for the `-o' option to the `set' builtin
28ef6c31 7161 (*note The Set Builtin::).
bb70624e
JA
7162
7163 `shopt'
7164 Shell option names as accepted by the `shopt' builtin
28ef6c31 7165 (*note Bash Builtins::).
bb70624e
JA
7166
7167 `signal'
7168 Signal names.
7169
7170 `stopped'
7171 Names of stopped jobs, if job control is active.
7172
7173 `user'
7174 User names. May also be specified as `-u'.
7175
7176 `variable'
7177 Names of all shell variables. May also be specified as
7178 `-v'.
7179
7180 `-G GLOBPAT'
7181 The filename expansion pattern GLOBPAT is expanded to generate
7182 the possible completions.
7183
7184 `-W WORDLIST'
7185 The WORDLIST is split using the characters in the `IFS'
7186 special variable as delimiters, and each resultant word is
7187 expanded. The possible completions are the members of the
7188 resultant list which match the word being completed.
7189
7190 `-C COMMAND'
7191 COMMAND is executed in a subshell environment, and its output
7192 is used as the possible completions.
7193
7194 `-F FUNCTION'
7195 The shell function FUNCTION is executed in the current shell
7196 environment. When it finishes, the possible completions are
7197 retrieved from the value of the `COMPREPLY' array variable.
7198
7199 `-X FILTERPAT'
7200 FILTERPAT is a pattern as used for filename expansion. It is
7201 applied to the list of possible completions generated by the
7202 preceding options and arguments, and each completion matching
7203 FILTERPAT is removed from the list. A leading `!' in
7204 FILTERPAT negates the pattern; in this case, any completion
7205 not matching FILTERPAT is removed.
7206
7207 `-P PREFIX'
7208 PREFIX is added at the beginning of each possible completion
7209 after all other options have been applied.
7210
7211 `-S SUFFIX'
7212 SUFFIX is appended to each possible completion after all
7213 other options have been applied.
7214
7215 The return value is true unless an invalid option is supplied, an
7216 option other than `-p' or `-r' is supplied without a NAME
7217 argument, an attempt is made to remove a completion specification
7218 for a NAME for which no specification exists, or an error occurs
7219 adding a completion specification.
7220
37c41ab1 7221
bb70624e
JA
7222\1f
7223File: bashref.info, Node: Using History Interactively, Next: Command Line Editing, Prev: Job Control, Up: Top
7224
37c41ab1
CR
72259 Using History Interactively
7226*****************************
bb70624e 7227
37c41ab1 7228This chapter describes how to use the GNU History Library
bb70624e
JA
7229interactively, from a user's standpoint. It should be considered a
7230user's guide. For information on using the GNU History Library in
7231other programs, see the GNU Readline Library Manual.
7232
7233* Menu:
7234
7235* Bash History Facilities:: How Bash lets you manipulate your command
7236 history.
7237* Bash History Builtins:: The Bash builtin commands that manipulate
7238 the command history.
7239* History Interaction:: What it feels like using History as a user.
7240
7241\1f
7242File: bashref.info, Node: Bash History Facilities, Next: Bash History Builtins, Up: Using History Interactively
7243
37c41ab1
CR
72449.1 Bash History Facilities
7245===========================
bb70624e 7246
37c41ab1
CR
7247When the `-o history' option to the `set' builtin is enabled (*note The
7248Set Builtin::), the shell provides access to the "command history", the
7249list of commands previously typed. The value of the `HISTSIZE' shell
7250variable is used as the number of commands to save in a history list.
7251The text of the last `$HISTSIZE' commands (default 500) is saved. The
7252shell stores each command in the history list prior to parameter and
7253variable expansion but after history expansion is performed, subject to
7254the values of the shell variables `HISTIGNORE' and `HISTCONTROL'.
bb70624e
JA
7255
7256 When the shell starts up, the history is initialized from the file
7257named by the `HISTFILE' variable (default `~/.bash_history'). The file
7258named by the value of `HISTFILE' is truncated, if necessary, to contain
7259no more than the number of lines specified by the value of the
7260`HISTFILESIZE' variable. When an interactive shell exits, the last
7261`$HISTSIZE' lines are copied from the history list to the file named by
7262`$HISTFILE'. If the `histappend' shell option is set (*note Bash
28ef6c31 7263Builtins::), the lines are appended to the history file, otherwise the
bb70624e
JA
7264history file is overwritten. If `HISTFILE' is unset, or if the history
7265file is unwritable, the history is not saved. After saving the
7266history, the history file is truncated to contain no more than
7267`$HISTFILESIZE' lines. If `HISTFILESIZE' is not set, no truncation is
7268performed.
7269
d3a24ed2
CR
7270 If the `HISTTIMEFORMAT' is set, the time stamp information
7271associated with each history entry is written to the history file.
7272
bb70624e
JA
7273 The builtin command `fc' may be used to list or edit and re-execute
7274a portion of the history list. The `history' builtin may be used to
7275display or modify the history list and manipulate the history file.
7276When using command-line editing, search commands are available in each
7277editing mode that provide access to the history list (*note Commands
28ef6c31 7278For History::).
bb70624e
JA
7279
7280 The shell allows control over which commands are saved on the history
7281list. The `HISTCONTROL' and `HISTIGNORE' variables may be set to cause
7282the shell to save only a subset of the commands entered. The `cmdhist'
7283shell option, if enabled, causes the shell to attempt to save each line
7284of a multi-line command in the same history entry, adding semicolons
7285where necessary to preserve syntactic correctness. The `lithist' shell
7286option causes the shell to save the command with embedded newlines
7287instead of semicolons. The `shopt' builtin is used to set these
7288options. *Note Bash Builtins::, for a description of `shopt'.
7289
7290\1f
7291File: bashref.info, Node: Bash History Builtins, Next: History Interaction, Prev: Bash History Facilities, Up: Using History Interactively
7292
37c41ab1
CR
72939.2 Bash History Builtins
7294=========================
bb70624e 7295
37c41ab1 7296Bash provides two builtin commands which manipulate the history list
bb70624e
JA
7297and history file.
7298
7299`fc'
7300 `fc [-e ENAME] [-nlr] [FIRST] [LAST]'
7301 `fc -s [PAT=REP] [COMMAND]'
7302
7303 Fix Command. In the first form, a range of commands from FIRST to
7304 LAST is selected from the history list. Both FIRST and LAST may
7305 be specified as a string (to locate the most recent command
7306 beginning with that string) or as a number (an index into the
7307 history list, where a negative number is used as an offset from the
7308 current command number). If LAST is not specified it is set to
7309 FIRST. If FIRST is not specified it is set to the previous
7310 command for editing and -16 for listing. If the `-l' flag is
7311 given, the commands are listed on standard output. The `-n' flag
7312 suppresses the command numbers when listing. The `-r' flag
7313 reverses the order of the listing. Otherwise, the editor given by
7314 ENAME is invoked on a file containing those commands. If ENAME is
7315 not given, the value of the following variable expansion is used:
7316 `${FCEDIT:-${EDITOR:-vi}}'. This says to use the value of the
7317 `FCEDIT' variable if set, or the value of the `EDITOR' variable if
7318 that is set, or `vi' if neither is set. When editing is complete,
7319 the edited commands are echoed and executed.
7320
7321 In the second form, COMMAND is re-executed after each instance of
7322 PAT in the selected command is replaced by REP.
7323
7324 A useful alias to use with the `fc' command is `r='fc -s'', so
7325 that typing `r cc' runs the last command beginning with `cc' and
28ef6c31 7326 typing `r' re-executes the last command (*note Aliases::).
bb70624e
JA
7327
7328`history'
7329 history [N]
7330 history -c
7331 history -d OFFSET
7332 history [-anrw] [FILENAME]
7333 history -ps ARG
7334
7335 With no options, display the history list with line numbers.
28ef6c31 7336 Lines prefixed with a `*' have been modified. An argument of N
d3a24ed2
CR
7337 lists only the last N lines. If the shell variable
7338 `HISTTIMEFORMAT' is set and not null, it is used as a format
7339 string for STRFTIME to display the time stamp associated with each
7340 displayed history entry. No intervening blank is printed between
7341 the formatted time stamp and the history line.
7342
7343 Options, if supplied, have the following meanings:
bb70624e
JA
7344
7345 `-c'
7346 Clear the history list. This may be combined with the other
7347 options to replace the history list completely.
7348
7349 `-d OFFSET'
7350 Delete the history entry at position OFFSET. OFFSET should
7351 be specified as it appears when the history is displayed.
7352
7353 `-a'
7354 Append the new history lines (history lines entered since the
7355 beginning of the current Bash session) to the history file.
7356
7357 `-n'
7358 Append the history lines not already read from the history
7359 file to the current history list. These are lines appended
7360 to the history file since the beginning of the current Bash
7361 session.
7362
7363 `-r'
7364 Read the current history file and append its contents to the
7365 history list.
7366
7367 `-w'
7368 Write out the current history to the history file.
7369
7370 `-p'
7371 Perform history substitution on the ARGs and display the
7372 result on the standard output, without storing the results in
7373 the history list.
7374
7375 `-s'
7376 The ARGs are added to the end of the history list as a single
7377 entry.
7378
761783bf 7379
bb70624e
JA
7380 When any of the `-w', `-r', `-a', or `-n' options is used, if
7381 FILENAME is given, then it is used as the history file. If not,
7382 then the value of the `HISTFILE' variable is used.
7383
761783bf 7384
bb70624e
JA
7385\1f
7386File: bashref.info, Node: History Interaction, Prev: Bash History Builtins, Up: Using History Interactively
ccc6cda3 7387
37c41ab1
CR
73889.3 History Expansion
7389=====================
ccc6cda3 7390
37c41ab1
CR
7391The History library provides a history expansion feature that is similar
7392to the history expansion provided by `csh'. This section describes the
7393syntax used to manipulate the history information.
ccc6cda3 7394
bb70624e
JA
7395 History expansions introduce words from the history list into the
7396input stream, making it easy to repeat commands, insert the arguments
7397to a previous command into the current input line, or fix errors in
7398previous commands quickly.
ccc6cda3 7399
bb70624e
JA
7400 History expansion takes place in two parts. The first is to
7401determine which line from the history list should be used during
7402substitution. The second is to select portions of that line for
7403inclusion into the current one. The line selected from the history is
7404called the "event", and the portions of that line that are acted upon
7405are called "words". Various "modifiers" are available to manipulate
7406the selected words. The line is broken into words in the same fashion
7407that Bash does, so that several words surrounded by quotes are
7408considered one word. History expansions are introduced by the
7409appearance of the history expansion character, which is `!' by default.
7410Only `\' and `'' may be used to escape the history expansion character.
7411
7412 Several shell options settable with the `shopt' builtin (*note Bash
28ef6c31 7413Builtins::) may be used to tailor the behavior of history expansion.
bb70624e
JA
7414If the `histverify' shell option is enabled, and Readline is being
7415used, history substitutions are not immediately passed to the shell
7416parser. Instead, the expanded line is reloaded into the Readline
7417editing buffer for further modification. If Readline is being used,
7418and the `histreedit' shell option is enabled, a failed history
7419expansion will be reloaded into the Readline editing buffer for
7420correction. The `-p' option to the `history' builtin command may be
7421used to see what a history expansion will do before using it. The `-s'
7422option to the `history' builtin may be used to add commands to the end
7423of the history list without actually executing them, so that they are
7424available for subsequent recall. This is most useful in conjunction
7425with Readline.
7426
7427 The shell allows control of the various characters used by the
7428history expansion mechanism with the `histchars' variable.
7429
7430* Menu:
7431
7432* Event Designators:: How to specify which history line to use.
7433* Word Designators:: Specifying which words are of interest.
7434* Modifiers:: Modifying the results of substitution.
ccc6cda3
JA
7435
7436\1f
bb70624e 7437File: bashref.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
ccc6cda3 7438
37c41ab1
CR
74399.3.1 Event Designators
7440-----------------------
ccc6cda3 7441
37c41ab1
CR
7442An event designator is a reference to a command line entry in the
7443history list.
ccc6cda3 7444
bb70624e
JA
7445`!'
7446 Start a history substitution, except when followed by a space, tab,
d3a24ed2
CR
7447 the end of the line, `=' or `(' (when the `extglob' shell option
7448 is enabled using the `shopt' builtin).
ccc6cda3 7449
bb70624e
JA
7450`!N'
7451 Refer to command line N.
ccc6cda3 7452
bb70624e
JA
7453`!-N'
7454 Refer to the command N lines back.
ccc6cda3 7455
bb70624e
JA
7456`!!'
7457 Refer to the previous command. This is a synonym for `!-1'.
ccc6cda3 7458
bb70624e
JA
7459`!STRING'
7460 Refer to the most recent command starting with STRING.
ccc6cda3 7461
bb70624e
JA
7462`!?STRING[?]'
7463 Refer to the most recent command containing STRING. The trailing
7464 `?' may be omitted if the STRING is followed immediately by a
7465 newline.
ccc6cda3 7466
bb70624e
JA
7467`^STRING1^STRING2^'
7468 Quick Substitution. Repeat the last command, replacing STRING1
7469 with STRING2. Equivalent to `!!:s/STRING1/STRING2/'.
7470
7471`!#'
7472 The entire command line typed so far.
ccc6cda3 7473
761783bf 7474
ccc6cda3 7475\1f
bb70624e 7476File: bashref.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
ccc6cda3 7477
37c41ab1
CR
74789.3.2 Word Designators
7479----------------------
ccc6cda3 7480
37c41ab1 7481Word designators are used to select desired words from the event. A
bb70624e
JA
7482`:' separates the event specification from the word designator. It may
7483be omitted if the word designator begins with a `^', `$', `*', `-', or
7484`%'. Words are numbered from the beginning of the line, with the first
7485word being denoted by 0 (zero). Words are inserted into the current
7486line separated by single spaces.
ccc6cda3 7487
bb70624e 7488 For example,
ccc6cda3 7489
bb70624e
JA
7490`!!'
7491 designates the preceding command. When you type this, the
7492 preceding command is repeated in toto.
ccc6cda3 7493
bb70624e
JA
7494`!!:$'
7495 designates the last argument of the preceding command. This may be
7496 shortened to `!$'.
ccc6cda3 7497
bb70624e
JA
7498`!fi:2'
7499 designates the second argument of the most recent command starting
7500 with the letters `fi'.
ccc6cda3 7501
bb70624e 7502 Here are the word designators:
ccc6cda3 7503
bb70624e
JA
7504`0 (zero)'
7505 The `0'th word. For many applications, this is the command word.
ccc6cda3 7506
bb70624e
JA
7507`N'
7508 The Nth word.
ccc6cda3 7509
bb70624e
JA
7510`^'
7511 The first argument; that is, word 1.
ccc6cda3 7512
bb70624e
JA
7513`$'
7514 The last argument.
ccc6cda3 7515
bb70624e
JA
7516`%'
7517 The word matched by the most recent `?STRING?' search.
ccc6cda3 7518
bb70624e
JA
7519`X-Y'
7520 A range of words; `-Y' abbreviates `0-Y'.
ccc6cda3 7521
bb70624e
JA
7522`*'
7523 All of the words, except the `0'th. This is a synonym for `1-$'.
7524 It is not an error to use `*' if there is just one word in the
7525 event; the empty string is returned in that case.
7526
7527`X*'
7528 Abbreviates `X-$'
7529
7530`X-'
7531 Abbreviates `X-$' like `X*', but omits the last word.
7532
761783bf 7533
bb70624e
JA
7534 If a word designator is supplied without an event specification, the
7535previous command is used as the event.
ccc6cda3
JA
7536
7537\1f
bb70624e 7538File: bashref.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
ccc6cda3 7539
37c41ab1
CR
75409.3.3 Modifiers
7541---------------
ccc6cda3 7542
37c41ab1 7543After the optional word designator, you can add a sequence of one or
bb70624e 7544more of the following modifiers, each preceded by a `:'.
ccc6cda3 7545
bb70624e
JA
7546`h'
7547 Remove a trailing pathname component, leaving only the head.
ccc6cda3 7548
bb70624e
JA
7549`t'
7550 Remove all leading pathname components, leaving the tail.
7551
7552`r'
7553 Remove a trailing suffix of the form `.SUFFIX', leaving the
7554 basename.
7555
7556`e'
7557 Remove all but the trailing suffix.
7558
7559`p'
7560 Print the new command but do not execute it.
7561
7562`q'
7563 Quote the substituted words, escaping further substitutions.
7564
7565`x'
7566 Quote the substituted words as with `q', but break into words at
7567 spaces, tabs, and newlines.
7568
7569`s/OLD/NEW/'
7570 Substitute NEW for the first occurrence of OLD in the event line.
7571 Any delimiter may be used in place of `/'. The delimiter may be
7572 quoted in OLD and NEW with a single backslash. If `&' appears in
7573 NEW, it is replaced by OLD. A single backslash will quote the
7574 `&'. The final delimiter is optional if it is the last character
7575 on the input line.
7576
7577`&'
7578 Repeat the previous substitution.
7579
7580`g'
d3a24ed2 7581`a'
bb70624e
JA
7582 Cause changes to be applied over the entire event line. Used in
7583 conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
7584
d3a24ed2
CR
7585`G'
7586 Apply the following `s' modifier once to each word in the event.
7587
761783bf 7588
bb70624e
JA
7589\1f
7590File: bashref.info, Node: Installing Bash, Next: Reporting Bugs, Prev: Command Line Editing, Up: Top
7591
37c41ab1
CR
759210 Installing Bash
7593******************
b72432fd 7594
37c41ab1 7595This chapter provides basic instructions for installing Bash on the
bb70624e
JA
7596various supported platforms. The distribution supports the GNU
7597operating systems, nearly every version of Unix, and several non-Unix
7598systems such as BeOS and Interix. Other independent ports exist for
d3a24ed2 7599MS-DOS, OS/2, and Windows platforms.
ccc6cda3 7600
bb70624e 7601* Menu:
ccc6cda3 7602
bb70624e 7603* Basic Installation:: Installation instructions.
ccc6cda3 7604
bb70624e
JA
7605* Compilers and Options:: How to set special options for various
7606 systems.
ccc6cda3 7607
bb70624e
JA
7608* Compiling For Multiple Architectures:: How to compile Bash for more
7609 than one kind of system from
7610 the same source tree.
ccc6cda3 7611
bb70624e 7612* Installation Names:: How to set the various paths used by the installation.
ccc6cda3 7613
bb70624e 7614* Specifying the System Type:: How to configure Bash for a particular system.
ccc6cda3 7615
bb70624e
JA
7616* Sharing Defaults:: How to share default configuration values among GNU
7617 programs.
ccc6cda3 7618
bb70624e 7619* Operation Controls:: Options recognized by the configuration program.
ccc6cda3 7620
bb70624e
JA
7621* Optional Features:: How to enable and disable optional features when
7622 building Bash.
ccc6cda3 7623
bb70624e
JA
7624\1f
7625File: bashref.info, Node: Basic Installation, Next: Compilers and Options, Up: Installing Bash
ccc6cda3 7626
37c41ab1
CR
762710.1 Basic Installation
7628=======================
ccc6cda3 7629
37c41ab1 7630These are installation instructions for Bash.
ccc6cda3 7631
bb70624e 7632 The simplest way to compile Bash is:
ccc6cda3 7633
bb70624e
JA
7634 1. `cd' to the directory containing the source code and type
7635 `./configure' to configure Bash for your system. If you're using
7636 `csh' on an old version of System V, you might need to type `sh
7637 ./configure' instead to prevent `csh' from trying to execute
7638 `configure' itself.
ccc6cda3 7639
bb70624e
JA
7640 Running `configure' takes some time. While running, it prints
7641 messages telling which features it is checking for.
ccc6cda3 7642
bb70624e
JA
7643 2. Type `make' to compile Bash and build the `bashbug' bug reporting
7644 script.
ccc6cda3 7645
bb70624e 7646 3. Optionally, type `make tests' to run the Bash test suite.
ccc6cda3 7647
bb70624e
JA
7648 4. Type `make install' to install `bash' and `bashbug'. This will
7649 also install the manual pages and Info file.
ccc6cda3 7650
ccc6cda3 7651
bb70624e
JA
7652 The `configure' shell script attempts to guess correct values for
7653various system-dependent variables used during compilation. It uses
7654those values to create a `Makefile' in each directory of the package
7655(the top directory, the `builtins', `doc', and `support' directories,
7656each directory under `lib', and several others). It also creates a
7657`config.h' file containing system-dependent definitions. Finally, it
7658creates a shell script named `config.status' that you can run in the
7659future to recreate the current configuration, a file `config.cache'
7660that saves the results of its tests to speed up reconfiguring, and a
7661file `config.log' containing compiler output (useful mainly for
7662debugging `configure'). If at some point `config.cache' contains
7663results you don't want to keep, you may remove or edit it.
ccc6cda3 7664
bb70624e
JA
7665 To find out more about the options and arguments that the
7666`configure' script understands, type
ccc6cda3 7667
bb70624e 7668 bash-2.04$ ./configure --help
ccc6cda3 7669
bb70624e 7670at the Bash prompt in your Bash source directory.
ccc6cda3 7671
bb70624e
JA
7672 If you need to do unusual things to compile Bash, please try to
7673figure out how `configure' could check whether or not to do them, and
7674mail diffs or instructions to <bash-maintainers@gnu.org> so they can be
7675considered for the next release.
ccc6cda3 7676
bb70624e
JA
7677 The file `configure.in' is used to create `configure' by a program
7678called Autoconf. You only need `configure.in' if you want to change it
7679or regenerate `configure' using a newer version of Autoconf. If you do
f73dda09 7680this, make sure you are using Autoconf version 2.50 or newer.
ccc6cda3 7681
bb70624e
JA
7682 You can remove the program binaries and object files from the source
7683code directory by typing `make clean'. To also remove the files that
7684`configure' created (so you can compile Bash for a different kind of
7685computer), type `make distclean'.
ccc6cda3 7686
bb70624e
JA
7687\1f
7688File: bashref.info, Node: Compilers and Options, Next: Compiling For Multiple Architectures, Prev: Basic Installation, Up: Installing Bash
ccc6cda3 7689
37c41ab1
CR
769010.2 Compilers and Options
7691==========================
ccc6cda3 7692
37c41ab1 7693Some systems require unusual options for compilation or linking that
bb70624e
JA
7694the `configure' script does not know about. You can give `configure'
7695initial values for variables by setting them in the environment. Using
7696a Bourne-compatible shell, you can do that on the command line like
7697this:
ccc6cda3 7698
bb70624e 7699 CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
ccc6cda3 7700
bb70624e 7701 On systems that have the `env' program, you can do it like this:
cce855bc 7702
bb70624e 7703 env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
b72432fd 7704
bb70624e 7705 The configuration process uses GCC to build Bash if it is available.
ccc6cda3 7706
bb70624e
JA
7707\1f
7708File: bashref.info, Node: Compiling For Multiple Architectures, Next: Installation Names, Prev: Compilers and Options, Up: Installing Bash
ccc6cda3 7709
37c41ab1
CR
771010.3 Compiling For Multiple Architectures
7711=========================================
ccc6cda3 7712
37c41ab1 7713You can compile Bash for more than one kind of computer at the same
bb70624e
JA
7714time, by placing the object files for each architecture in their own
7715directory. To do this, you must use a version of `make' that supports
7716the `VPATH' variable, such as GNU `make'. `cd' to the directory where
7717you want the object files and executables to go and run the `configure'
7718script from the source directory. You may need to supply the
7719`--srcdir=PATH' argument to tell `configure' where the source files
7720are. `configure' automatically checks for the source code in the
7721directory that `configure' is in and in `..'.
ccc6cda3 7722
bb70624e
JA
7723 If you have to use a `make' that does not supports the `VPATH'
7724variable, you can compile Bash for one architecture at a time in the
7725source code directory. After you have installed Bash for one
7726architecture, use `make distclean' before reconfiguring for another
7727architecture.
ccc6cda3 7728
bb70624e
JA
7729 Alternatively, if your system supports symbolic links, you can use
7730the `support/mkclone' script to create a build tree which has symbolic
7731links back to each file in the source directory. Here's an example
7732that creates a build directory in the current directory from a source
7733directory `/usr/gnu/src/bash-2.0':
ccc6cda3 7734
bb70624e 7735 bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
ccc6cda3 7736
bb70624e
JA
7737The `mkclone' script requires Bash, so you must have already built Bash
7738for at least one architecture before you can create build directories
7739for other architectures.
ccc6cda3 7740
bb70624e
JA
7741\1f
7742File: bashref.info, Node: Installation Names, Next: Specifying the System Type, Prev: Compiling For Multiple Architectures, Up: Installing Bash
ccc6cda3 7743
37c41ab1
CR
774410.4 Installation Names
7745=======================
ccc6cda3 7746
37c41ab1 7747By default, `make install' will install into `/usr/local/bin',
bb70624e 7748`/usr/local/man', etc. You can specify an installation prefix other
f73dda09
JA
7749than `/usr/local' by giving `configure' the option `--prefix=PATH', or
7750by specifying a value for the `DESTDIR' `make' variable when running
7751`make install'.
ccc6cda3 7752
bb70624e
JA
7753 You can specify separate installation prefixes for
7754architecture-specific files and architecture-independent files. If you
7755give `configure' the option `--exec-prefix=PATH', `make install' will
7756use PATH as the prefix for installing programs and libraries.
7757Documentation and other data files will still use the regular prefix.
ccc6cda3
JA
7758
7759\1f
bb70624e 7760File: bashref.info, Node: Specifying the System Type, Next: Sharing Defaults, Prev: Installation Names, Up: Installing Bash
ccc6cda3 7761
37c41ab1
CR
776210.5 Specifying the System Type
7763===============================
ccc6cda3 7764
37c41ab1 7765There may be some features `configure' can not figure out
f73dda09 7766automatically, but need to determine by the type of host Bash will run
bb70624e
JA
7767on. Usually `configure' can figure that out, but if it prints a
7768message saying it can not guess the host type, give it the
7769`--host=TYPE' option. `TYPE' can either be a short name for the system
7770type, such as `sun4', or a canonical name with three fields:
f73dda09 7771`CPU-COMPANY-SYSTEM' (e.g., `i386-unknown-freebsd4.2').
ccc6cda3 7772
bb70624e
JA
7773 See the file `support/config.sub' for the possible values of each
7774field.
ccc6cda3 7775
bb70624e
JA
7776\1f
7777File: bashref.info, Node: Sharing Defaults, Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash
7778
37c41ab1
CR
777910.6 Sharing Defaults
7780=====================
bb70624e 7781
37c41ab1
CR
7782If you want to set default values for `configure' scripts to share, you
7783can create a site shell script called `config.site' that gives default
7784values for variables like `CC', `cache_file', and `prefix'. `configure'
7785looks for `PREFIX/share/config.site' if it exists, then
bb70624e
JA
7786`PREFIX/etc/config.site' if it exists. Or, you can set the
7787`CONFIG_SITE' environment variable to the location of the site script.
7788A warning: the Bash `configure' looks for a site script, but not all
7789`configure' scripts do.
ccc6cda3
JA
7790
7791\1f
bb70624e 7792File: bashref.info, Node: Operation Controls, Next: Optional Features, Prev: Sharing Defaults, Up: Installing Bash
ccc6cda3 7793
37c41ab1
CR
779410.7 Operation Controls
7795=======================
ccc6cda3 7796
37c41ab1 7797`configure' recognizes the following options to control how it operates.
ccc6cda3 7798
bb70624e
JA
7799`--cache-file=FILE'
7800 Use and save the results of the tests in FILE instead of
7801 `./config.cache'. Set FILE to `/dev/null' to disable caching, for
7802 debugging `configure'.
ccc6cda3 7803
bb70624e
JA
7804`--help'
7805 Print a summary of the options to `configure', and exit.
ccc6cda3 7806
bb70624e
JA
7807`--quiet'
7808`--silent'
7809`-q'
7810 Do not print messages saying which checks are being made.
ccc6cda3 7811
bb70624e
JA
7812`--srcdir=DIR'
7813 Look for the Bash source code in directory DIR. Usually
7814 `configure' can determine that directory automatically.
ccc6cda3 7815
bb70624e
JA
7816`--version'
7817 Print the version of Autoconf used to generate the `configure'
7818 script, and exit.
ccc6cda3 7819
bb70624e
JA
7820 `configure' also accepts some other, not widely used, boilerplate
7821options. `configure --help' prints the complete list.
ccc6cda3 7822
bb70624e
JA
7823\1f
7824File: bashref.info, Node: Optional Features, Prev: Operation Controls, Up: Installing Bash
ccc6cda3 7825
37c41ab1
CR
782610.8 Optional Features
7827======================
ccc6cda3 7828
37c41ab1
CR
7829The Bash `configure' has a number of `--enable-FEATURE' options, where
7830FEATURE indicates an optional part of Bash. There are also several
7831`--with-PACKAGE' options, where PACKAGE is something like `bash-malloc'
7832or `purify'. To turn off the default use of a package, use
7833`--without-PACKAGE'. To configure Bash without a feature that is
bb70624e 7834enabled by default, use `--disable-FEATURE'.
ccc6cda3 7835
bb70624e
JA
7836 Here is a complete list of the `--enable-' and `--with-' options
7837that the Bash `configure' recognizes.
ccc6cda3 7838
bb70624e
JA
7839`--with-afs'
7840 Define if you are using the Andrew File System from Transarc.
ccc6cda3 7841
bb70624e
JA
7842`--with-bash-malloc'
7843 Use the Bash version of `malloc' in `lib/malloc/malloc.c'. This
7844 is not the same `malloc' that appears in GNU libc, but an older
7845 version derived from the 4.2 BSD `malloc'. This `malloc' is very
7846 fast, but wastes some space on each allocation. This option is
7847 enabled by default. The `NOTES' file contains a list of systems
7848 for which this should be turned off, and `configure' disables this
7849 option automatically for a number of systems.
ccc6cda3 7850
bb70624e
JA
7851`--with-curses'
7852 Use the curses library instead of the termcap library. This should
7853 be supplied if your system has an inadequate or incomplete termcap
7854 database.
ccc6cda3 7855
bb70624e
JA
7856`--with-gnu-malloc'
7857 A synonym for `--with-bash-malloc'.
ccc6cda3 7858
f73dda09 7859`--with-installed-readline[=PREFIX]'
bb70624e
JA
7860 Define this to make Bash link with a locally-installed version of
7861 Readline rather than the version in `lib/readline'. This works
7117c2d2 7862 only with Readline 4.3 and later versions. If PREFIX is `yes' or
f73dda09
JA
7863 not supplied, `configure' uses the values of the make variables
7864 `includedir' and `libdir', which are subdirectories of `prefix' by
7865 default, to find the installed version of Readline if it is not in
7866 the standard system include and library directories. If PREFIX is
7867 `no', Bash links with the version in `lib/readline'. If PREFIX is
7868 set to any other value, `configure' treats it as a directory
7869 pathname and looks for the installed version of Readline in
7870 subdirectories of that directory (include files in
7871 PREFIX/`include' and the library in PREFIX/`lib').
ccc6cda3 7872
bb70624e
JA
7873`--with-purify'
7874 Define this to use the Purify memory allocation checker from
7875 Rational Software.
ccc6cda3 7876
bb70624e
JA
7877`--enable-minimal-config'
7878 This produces a shell with minimal features, close to the
7879 historical Bourne shell.
ccc6cda3 7880
bb70624e
JA
7881 There are several `--enable-' options that alter how Bash is
7882compiled and linked, rather than changing run-time features.
ccc6cda3 7883
f73dda09
JA
7884`--enable-largefile'
7885 Enable support for large files
7886 (http://www.sas.com/standards/large_file/x_open.20Mar96.html) if
7887 the operating system requires special compiler options to build
7117c2d2
JA
7888 programs which can access large files. This is enabled by
7889 default, if the operating system provides large file support.
f73dda09 7890
bb70624e
JA
7891`--enable-profiling'
7892 This builds a Bash binary that produces profiling information to be
7893 processed by `gprof' each time it is executed.
cce855bc 7894
bb70624e
JA
7895`--enable-static-link'
7896 This causes Bash to be linked statically, if `gcc' is being used.
7897 This could be used to build a version to use as root's shell.
d166f048 7898
bb70624e
JA
7899 The `minimal-config' option can be used to disable all of the
7900following options, but it is processed first, so individual options may
7901be enabled using `enable-FEATURE'.
d166f048 7902
bb70624e
JA
7903 All of the following options except for `disabled-builtins' and
7904`xpg-echo-default' are enabled by default, unless the operating system
7905does not provide the necessary support.
ccc6cda3 7906
bb70624e
JA
7907`--enable-alias'
7908 Allow alias expansion and include the `alias' and `unalias'
28ef6c31 7909 builtins (*note Aliases::).
ccc6cda3 7910
bb70624e
JA
7911`--enable-arith-for-command'
7912 Include support for the alternate form of the `for' command that
7913 behaves like the C language `for' statement (*note Looping
28ef6c31 7914 Constructs::).
ccc6cda3 7915
bb70624e
JA
7916`--enable-array-variables'
7917 Include support for one-dimensional array shell variables (*note
28ef6c31 7918 Arrays::).
ccc6cda3 7919
bb70624e
JA
7920`--enable-bang-history'
7921 Include support for `csh'-like history substitution (*note History
28ef6c31 7922 Interaction::).
ccc6cda3 7923
bb70624e
JA
7924`--enable-brace-expansion'
7925 Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
7926 See *Note Brace Expansion::, for a complete description.
ccc6cda3 7927
bb70624e
JA
7928`--enable-command-timing'
7929 Include support for recognizing `time' as a reserved word and for
7930 displaying timing statistics for the pipeline following `time'
28ef6c31 7931 (*note Pipelines::). This allows pipelines as well as shell
bb70624e 7932 builtins and functions to be timed.
ccc6cda3 7933
bb70624e 7934`--enable-cond-command'
5e13499c
CR
7935 Include support for the `[[' conditional command. (*note
7936 Conditional Constructs::).
7937
7938`--enable-cond-regexp'
7939 Include support for matching POSIX regular expressions using the
7940 `=~' binary operator in the `[[' conditional command. (*note
28ef6c31 7941 Conditional Constructs::).
ccc6cda3 7942
bb70624e
JA
7943`--enable-directory-stack'
7944 Include support for a `csh'-like directory stack and the `pushd',
28ef6c31 7945 `popd', and `dirs' builtins (*note The Directory Stack::).
ccc6cda3 7946
bb70624e
JA
7947`--enable-disabled-builtins'
7948 Allow builtin commands to be invoked via `builtin xxx' even after
7949 `xxx' has been disabled using `enable -n xxx'. See *Note Bash
7950 Builtins::, for details of the `builtin' and `enable' builtin
7951 commands.
ccc6cda3 7952
bb70624e
JA
7953`--enable-dparen-arithmetic'
7954 Include support for the `((...))' command (*note Conditional
28ef6c31 7955 Constructs::).
ccc6cda3 7956
bb70624e
JA
7957`--enable-extended-glob'
7958 Include support for the extended pattern matching features
7959 described above under *Note Pattern Matching::.
ccc6cda3 7960
bb70624e
JA
7961`--enable-help-builtin'
7962 Include the `help' builtin, which displays help on shell builtins
28ef6c31 7963 and variables (*note Bash Builtins::).
ccc6cda3 7964
bb70624e
JA
7965`--enable-history'
7966 Include command history and the `fc' and `history' builtin
28ef6c31 7967 commands (*note Bash History Facilities::).
ccc6cda3 7968
bb70624e 7969`--enable-job-control'
28ef6c31 7970 This enables the job control features (*note Job Control::), if
bb70624e 7971 the operating system supports them.
ccc6cda3 7972
d3a24ed2
CR
7973`--enable-multibyte'
7974 This enables support for multibyte characters if the operating
7975 system provides the necessary support.
7976
bb70624e
JA
7977`--enable-net-redirections'
7978 This enables the special handling of filenames of the form
7979 `/dev/tcp/HOST/PORT' and `/dev/udp/HOST/PORT' when used in
28ef6c31 7980 redirections (*note Redirections::).
ccc6cda3 7981
bb70624e 7982`--enable-process-substitution'
28ef6c31
JA
7983 This enables process substitution (*note Process Substitution::) if
7984 the operating system provides the necessary support.
ccc6cda3 7985
bb70624e
JA
7986`--enable-prompt-string-decoding'
7987 Turn on the interpretation of a number of backslash-escaped
7988 characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
7989 strings. See *Note Printing a Prompt::, for a complete list of
7990 prompt string escape sequences.
ccc6cda3 7991
bb70624e
JA
7992`--enable-progcomp'
7993 Enable the programmable completion facilities (*note Programmable
28ef6c31 7994 Completion::). If Readline is not enabled, this option has no
bb70624e 7995 effect.
ccc6cda3 7996
bb70624e
JA
7997`--enable-readline'
7998 Include support for command-line editing and history with the Bash
28ef6c31 7999 version of the Readline library (*note Command Line Editing::).
ccc6cda3 8000
bb70624e
JA
8001`--enable-restricted'
8002 Include support for a "restricted shell". If this is enabled,
8003 Bash, when called as `rbash', enters a restricted mode. See *Note
8004 The Restricted Shell::, for a description of restricted mode.
ccc6cda3 8005
bb70624e
JA
8006`--enable-select'
8007 Include the `select' builtin, which allows the generation of simple
28ef6c31 8008 menus (*note Conditional Constructs::).
ccc6cda3 8009
bb70624e
JA
8010`--enable-usg-echo-default'
8011 A synonym for `--enable-xpg-echo-default'.
ccc6cda3 8012
bb70624e
JA
8013`--enable-xpg-echo-default'
8014 Make the `echo' builtin expand backslash-escaped characters by
8015 default, without requiring the `-e' option. This sets the default
8016 value of the `xpg_echo' shell option to `on', which makes the Bash
8017 `echo' behave more like the version specified in the Single Unix
8018 Specification, version 2. *Note Bash Builtins::, for a
8019 description of the escape sequences that `echo' recognizes.
ccc6cda3 8020
761783bf 8021
bb70624e
JA
8022 The file `config-top.h' contains C Preprocessor `#define' statements
8023for options which are not settable from `configure'. Some of these are
8024not meant to be changed; beware of the consequences if you do. Read
8025the comments associated with each definition for more information about
8026its effect.
ccc6cda3 8027
bb70624e
JA
8028\1f
8029File: bashref.info, Node: Reporting Bugs, Next: Major Differences From The Bourne Shell, Prev: Installing Bash, Up: Top
d166f048 8030
37c41ab1
CR
8031Appendix A Reporting Bugs
8032*************************
ccc6cda3 8033
37c41ab1 8034Please report all bugs you find in Bash. But first, you should make
bb70624e 8035sure that it really is a bug, and that it appears in the latest version
d3a24ed2
CR
8036of Bash. The latest version of Bash is always available for FTP from
8037`ftp://ftp.gnu.org/pub/bash/'.
ccc6cda3 8038
bb70624e
JA
8039 Once you have determined that a bug actually exists, use the
8040`bashbug' command to submit a bug report. If you have a fix, you are
8041encouraged to mail that as well! Suggestions and `philosophical' bug
8042reports may be mailed to <bug-bash@gnu.org> or posted to the Usenet
8043newsgroup `gnu.bash.bug'.
ccc6cda3 8044
bb70624e
JA
8045 All bug reports should include:
8046 * The version number of Bash.
ccc6cda3 8047
bb70624e 8048 * The hardware and operating system.
ccc6cda3 8049
bb70624e 8050 * The compiler used to compile Bash.
ccc6cda3 8051
bb70624e 8052 * A description of the bug behaviour.
ccc6cda3 8053
bb70624e
JA
8054 * A short script or `recipe' which exercises the bug and may be used
8055 to reproduce it.
ccc6cda3 8056
bb70624e
JA
8057`bashbug' inserts the first three items automatically into the template
8058it provides for filing a bug report.
8059
8060 Please send all reports concerning this manual to <chet@po.CWRU.Edu>.
ccc6cda3
JA
8061
8062\1f
d3a24ed2 8063File: bashref.info, Node: Major Differences From The Bourne Shell, Next: Copying This Manual, Prev: Reporting Bugs, Up: Top
ccc6cda3 8064
37c41ab1
CR
8065Appendix B Major Differences From The Bourne Shell
8066**************************************************
ccc6cda3 8067
37c41ab1 8068Bash implements essentially the same grammar, parameter and variable
bb70624e
JA
8069expansion, redirection, and quoting as the Bourne Shell. Bash uses the
8070POSIX 1003.2 standard as the specification of how these features are to
8071be implemented. There are some differences between the traditional
8072Bourne shell and Bash; this section quickly details the differences of
8073significance. A number of these differences are explained in greater
8074depth in previous sections. This section uses the version of `sh'
28ef6c31 8075included in SVR4.2 as the baseline reference.
ccc6cda3 8076
bb70624e 8077 * Bash is POSIX-conformant, even where the POSIX specification
28ef6c31 8078 differs from traditional `sh' behavior (*note Bash POSIX Mode::).
ccc6cda3 8079
bb70624e 8080 * Bash has multi-character invocation options (*note Invoking
28ef6c31 8081 Bash::).
ccc6cda3 8082
28ef6c31 8083 * Bash has command-line editing (*note Command Line Editing::) and
bb70624e 8084 the `bind' builtin.
ccc6cda3 8085
bb70624e 8086 * Bash provides a programmable word completion mechanism (*note
28ef6c31 8087 Programmable Completion::), and two builtin commands, `complete'
bb70624e 8088 and `compgen', to manipulate it.
ccc6cda3 8089
28ef6c31 8090 * Bash has command history (*note Bash History Facilities::) and the
5e13499c
CR
8091 `history' and `fc' builtins to manipulate it. The Bash history
8092 list maintains timestamp information and uses the value of the
8093 `HISTTIMEFORMAT' variable to display it.
ccc6cda3 8094
bb70624e 8095 * Bash implements `csh'-like history expansion (*note History
28ef6c31 8096 Interaction::).
ccc6cda3 8097
28ef6c31 8098 * Bash has one-dimensional array variables (*note Arrays::), and the
bb70624e
JA
8099 appropriate variable expansions and assignment syntax to use them.
8100 Several of the Bash builtins take options to act on arrays. Bash
8101 provides a number of built-in array variables.
ccc6cda3 8102
bb70624e
JA
8103 * The `$'...'' quoting syntax, which expands ANSI-C
8104 backslash-escaped characters in the text between the single quotes,
28ef6c31 8105 is supported (*note ANSI-C Quoting::).
ccc6cda3 8106
bb70624e
JA
8107 * Bash supports the `$"..."' quoting syntax to do locale-specific
8108 translation of the characters between the double quotes. The
8109 `-D', `--dump-strings', and `--dump-po-strings' invocation options
8110 list the translatable strings found in a script (*note Locale
28ef6c31 8111 Translation::).
ccc6cda3 8112
bb70624e 8113 * Bash implements the `!' keyword to negate the return value of a
28ef6c31 8114 pipeline (*note Pipelines::). Very useful when an `if' statement
bb70624e 8115 needs to act only if a test fails.
ccc6cda3 8116
bb70624e 8117 * Bash has the `time' reserved word and command timing (*note
28ef6c31 8118 Pipelines::). The display of the timing statistics may be
bb70624e 8119 controlled with the `TIMEFORMAT' variable.
ccc6cda3 8120
bb70624e
JA
8121 * Bash implements the `for (( EXPR1 ; EXPR2 ; EXPR3 ))' arithmetic
8122 for command, similar to the C language (*note Looping
28ef6c31 8123 Constructs::).
ccc6cda3 8124
bb70624e 8125 * Bash includes the `select' compound command, which allows the
28ef6c31 8126 generation of simple menus (*note Conditional Constructs::).
ccc6cda3 8127
bb70624e 8128 * Bash includes the `[[' compound command, which makes conditional
28ef6c31 8129 testing part of the shell grammar (*note Conditional Constructs::).
ccc6cda3 8130
28ef6c31
JA
8131 * Bash includes brace expansion (*note Brace Expansion::) and tilde
8132 expansion (*note Tilde Expansion::).
ccc6cda3 8133
bb70624e 8134 * Bash implements command aliases and the `alias' and `unalias'
28ef6c31 8135 builtins (*note Aliases::).
ccc6cda3 8136
bb70624e 8137 * Bash provides shell arithmetic, the `((' compound command (*note
28ef6c31
JA
8138 Conditional Constructs::), and arithmetic expansion (*note Shell
8139 Arithmetic::).
ccc6cda3 8140
bb70624e
JA
8141 * Variables present in the shell's initial environment are
8142 automatically exported to child processes. The Bourne shell does
8143 not normally do this unless the variables are explicitly marked
8144 using the `export' command.
ccc6cda3 8145
bb70624e
JA
8146 * Bash includes the POSIX pattern removal `%', `#', `%%' and `##'
8147 expansions to remove leading or trailing substrings from variable
28ef6c31 8148 values (*note Shell Parameter Expansion::).
ccc6cda3 8149
bb70624e 8150 * The expansion `${#xx}', which returns the length of `${xx}', is
28ef6c31 8151 supported (*note Shell Parameter Expansion::).
ccc6cda3 8152
bb70624e
JA
8153 * The expansion `${var:'OFFSET`[:'LENGTH`]}', which expands to the
8154 substring of `var''s value of length LENGTH, beginning at OFFSET,
28ef6c31 8155 is present (*note Shell Parameter Expansion::).
ccc6cda3 8156
bb70624e
JA
8157 * The expansion `${var/[/]'PATTERN`[/'REPLACEMENT`]}', which matches
8158 PATTERN and replaces it with REPLACEMENT in the value of `var', is
28ef6c31 8159 available (*note Shell Parameter Expansion::).
ccc6cda3 8160
bb70624e
JA
8161 * The expansion `${!PREFIX}*' expansion, which expands to the names
8162 of all shell variables whose names begin with PREFIX, is available
28ef6c31 8163 (*note Shell Parameter Expansion::).
ccc6cda3 8164
bb70624e 8165 * Bash has INDIRECT variable expansion using `${!word}' (*note Shell
28ef6c31 8166 Parameter Expansion::).
ccc6cda3 8167
bb70624e 8168 * Bash can expand positional parameters beyond `$9' using `${NUM}'.
ccc6cda3 8169
bb70624e 8170 * The POSIX `$()' form of command substitution is implemented (*note
28ef6c31 8171 Command Substitution::), and preferred to the Bourne shell's ```'
bb70624e 8172 (which is also implemented for backwards compatibility).
ccc6cda3 8173
28ef6c31 8174 * Bash has process substitution (*note Process Substitution::).
ccc6cda3 8175
bb70624e
JA
8176 * Bash automatically assigns variables that provide information
8177 about the current user (`UID', `EUID', and `GROUPS'), the current
8178 host (`HOSTTYPE', `OSTYPE', `MACHTYPE', and `HOSTNAME'), and the
8179 instance of Bash that is running (`BASH', `BASH_VERSION', and
8180 `BASH_VERSINFO'). *Note Bash Variables::, for details.
ccc6cda3 8181
bb70624e 8182 * The `IFS' variable is used to split only the results of expansion,
28ef6c31 8183 not all words (*note Word Splitting::). This closes a
bb70624e 8184 longstanding shell security hole.
ccc6cda3 8185
bb70624e
JA
8186 * Bash implements the full set of POSIX 1003.2 filename expansion
8187 operators, including CHARACTER CLASSES, EQUIVALENCE CLASSES, and
28ef6c31 8188 COLLATING SYMBOLS (*note Filename Expansion::).
ccc6cda3 8189
bb70624e 8190 * Bash implements extended pattern matching features when the
28ef6c31 8191 `extglob' shell option is enabled (*note Pattern Matching::).
ccc6cda3 8192
bb70624e
JA
8193 * It is possible to have a variable and a function with the same
8194 name; `sh' does not separate the two name spaces.
ccc6cda3 8195
bb70624e
JA
8196 * Bash functions are permitted to have local variables using the
8197 `local' builtin, and thus useful recursive functions may be written
28ef6c31 8198 (*note Bash Builtins::).
ccc6cda3 8199
bb70624e 8200 * Variable assignments preceding commands affect only that command,
28ef6c31 8201 even builtins and functions (*note Environment::). In `sh', all
bb70624e
JA
8202 variable assignments preceding commands are global unless the
8203 command is executed from the file system.
ccc6cda3 8204
bb70624e 8205 * Bash performs filename expansion on filenames specified as operands
28ef6c31 8206 to input and output redirection operators (*note Redirections::).
ccc6cda3 8207
bb70624e
JA
8208 * Bash contains the `<>' redirection operator, allowing a file to be
8209 opened for both reading and writing, and the `&>' redirection
8210 operator, for directing standard output and standard error to the
28ef6c31 8211 same file (*note Redirections::).
d166f048 8212
bb70624e 8213 * Bash treats a number of filenames specially when they are used in
28ef6c31 8214 redirection operators (*note Redirections::).
ccc6cda3 8215
bb70624e 8216 * Bash can open network connections to arbitrary machines and
28ef6c31 8217 services with the redirection operators (*note Redirections::).
ccc6cda3 8218
bb70624e 8219 * The `noclobber' option is available to avoid overwriting existing
28ef6c31
JA
8220 files with output redirection (*note The Set Builtin::). The `>|'
8221 redirection operator may be used to override `noclobber'.
ccc6cda3 8222
28ef6c31
JA
8223 * The Bash `cd' and `pwd' builtins (*note Bourne Shell Builtins::)
8224 each take `-L' and `-P' options to switch between logical and
bb70624e 8225 physical modes.
b72432fd 8226
bb70624e
JA
8227 * Bash allows a function to override a builtin with the same name,
8228 and provides access to that builtin's functionality within the
8229 function via the `builtin' and `command' builtins (*note Bash
28ef6c31 8230 Builtins::).
ccc6cda3 8231
bb70624e 8232 * The `command' builtin allows selective disabling of functions when
28ef6c31 8233 command lookup is performed (*note Bash Builtins::).
ccc6cda3 8234
bb70624e 8235 * Individual builtins may be enabled or disabled using the `enable'
28ef6c31 8236 builtin (*note Bash Builtins::).
cce855bc 8237
bb70624e
JA
8238 * The Bash `exec' builtin takes additional options that allow users
8239 to control the contents of the environment passed to the executed
8240 command, and what the zeroth argument to the command is to be
28ef6c31 8241 (*note Bourne Shell Builtins::).
cce855bc 8242
bb70624e 8243 * Shell functions may be exported to children via the environment
28ef6c31 8244 using `export -f' (*note Shell Functions::).
cce855bc 8245
bb70624e
JA
8246 * The Bash `export', `readonly', and `declare' builtins can take a
8247 `-f' option to act on shell functions, a `-p' option to display
8248 variables with various attributes set in a format that can be used
8249 as shell input, a `-n' option to remove various variable
8250 attributes, and `name=value' arguments to set variable attributes
8251 and values simultaneously.
ccc6cda3 8252
bb70624e
JA
8253 * The Bash `hash' builtin allows a name to be associated with an
8254 arbitrary filename, even when that filename cannot be found by
8255 searching the `$PATH', using `hash -p' (*note Bourne Shell
28ef6c31 8256 Builtins::).
ccc6cda3 8257
bb70624e 8258 * Bash includes a `help' builtin for quick reference to shell
28ef6c31 8259 facilities (*note Bash Builtins::).
ccc6cda3 8260
bb70624e 8261 * The `printf' builtin is available to display formatted output
28ef6c31 8262 (*note Bash Builtins::).
ccc6cda3 8263
28ef6c31 8264 * The Bash `read' builtin (*note Bash Builtins::) will read a line
bb70624e
JA
8265 ending in `\' with the `-r' option, and will use the `REPLY'
8266 variable as a default if no non-option arguments are supplied.
8267 The Bash `read' builtin also accepts a prompt string with the `-p'
8268 option and will use Readline to obtain the line when given the
8269 `-e' option. The `read' builtin also has additional options to
8270 control input: the `-s' option will turn off echoing of input
8271 characters as they are read, the `-t' option will allow `read' to
8272 time out if input does not arrive within a specified number of
8273 seconds, the `-n' option will allow reading only a specified
8274 number of characters rather than a full line, and the `-d' option
8275 will read until a particular character rather than newline.
ccc6cda3 8276
bb70624e
JA
8277 * The `return' builtin may be used to abort execution of scripts
8278 executed with the `.' or `source' builtins (*note Bourne Shell
28ef6c31 8279 Builtins::).
d166f048 8280
bb70624e 8281 * Bash includes the `shopt' builtin, for finer control of shell
f73dda09
JA
8282 optional capabilities (*note Bash Builtins::), and allows these
8283 options to be set and unset at shell invocation (*note Invoking
8284 Bash::).
d166f048 8285
bb70624e 8286 * Bash has much more optional behavior controllable with the `set'
28ef6c31 8287 builtin (*note The Set Builtin::).
cce855bc 8288
5e13499c
CR
8289 * The `-x' (`xtrace') option displays commands other than simple
8290 commands when performing an execution trace (*note The Set
8291 Builtin::).
8292
28ef6c31 8293 * The `test' builtin (*note Bourne Shell Builtins::) is slightly
bb70624e
JA
8294 different, as it implements the POSIX algorithm, which specifies
8295 the behavior based on the number of arguments.
ccc6cda3 8296
5e13499c
CR
8297 * Bash includes the `caller' builtin, which displays the context of
8298 any active subroutine call (a shell function or a script executed
8299 with the `.' or `source' builtins). This supports the bash
8300 debugger.
8301
28ef6c31 8302 * The `trap' builtin (*note Bourne Shell Builtins::) allows a
bb70624e 8303 `DEBUG' pseudo-signal specification, similar to `EXIT'. Commands
d3a24ed2
CR
8304 specified with a `DEBUG' trap are executed before every simple
8305 command, `for' command, `case' command, `select' command, every
8306 arithmetic `for' command, and before the first command executes in
8307 a shell function. The `DEBUG' trap is not inherited by shell
8308 functions unless the function has been given the `trace' attribute
8309 or the `functrace' option has been enabled using the `shopt'
8310 builtin. The `extdebug' shell option has additional effects on the
8311 `DEBUG' trap.
d166f048 8312
f73dda09
JA
8313 The `trap' builtin (*note Bourne Shell Builtins::) allows an `ERR'
8314 pseudo-signal specification, similar to `EXIT' and `DEBUG'.
8315 Commands specified with an `ERR' trap are executed after a simple
8316 command fails, with a few exceptions. The `ERR' trap is not
d3a24ed2
CR
8317 inherited by shell functions unless the `-o errtrace' option to
8318 the `set' builtin is enabled.
8319
8320 The `trap' builtin (*note Bourne Shell Builtins::) allows a
8321 `RETURN' pseudo-signal specification, similar to `EXIT' and
8322 `DEBUG'. Commands specified with an `RETURN' trap are executed
8323 before execution resumes after a shell function or a shell script
8324 executed with `.' or `source' returns. The `RETURN' trap is not
f73dda09
JA
8325 inherited by shell functions.
8326
bb70624e 8327 * The Bash `type' builtin is more extensive and gives more
28ef6c31 8328 information about the names it finds (*note Bash Builtins::).
cce855bc 8329
bb70624e
JA
8330 * The Bash `umask' builtin permits a `-p' option to cause the output
8331 to be displayed in the form of a `umask' command that may be
28ef6c31 8332 reused as input (*note Bourne Shell Builtins::).
d166f048 8333
bb70624e
JA
8334 * Bash implements a `csh'-like directory stack, and provides the
8335 `pushd', `popd', and `dirs' builtins to manipulate it (*note The
28ef6c31 8336 Directory Stack::). Bash also makes the directory stack visible
bb70624e 8337 as the value of the `DIRSTACK' shell variable.
d166f048 8338
bb70624e 8339 * Bash interprets special backslash-escaped characters in the prompt
28ef6c31 8340 strings when interactive (*note Printing a Prompt::).
d166f048 8341
bb70624e 8342 * The Bash restricted mode is more useful (*note The Restricted
28ef6c31 8343 Shell::); the SVR4.2 shell restricted mode is too limited.
ccc6cda3 8344
bb70624e 8345 * The `disown' builtin can remove a job from the internal shell job
28ef6c31 8346 table (*note Job Control Builtins::) or suppress the sending of
bb70624e 8347 `SIGHUP' to a job when the shell exits as the result of a `SIGHUP'.
ccc6cda3 8348
bb70624e
JA
8349 * The SVR4.2 shell has two privilege-related builtins (`mldmode' and
8350 `priv') not present in Bash.
ccc6cda3 8351
bb70624e 8352 * Bash does not have the `stop' or `newgrp' builtins.
d166f048 8353
bb70624e
JA
8354 * Bash does not use the `SHACCT' variable or perform shell
8355 accounting.
d166f048 8356
bb70624e 8357 * The SVR4.2 `sh' uses a `TIMEOUT' variable like Bash uses `TMOUT'.
ccc6cda3 8358
28ef6c31 8359
bb70624e 8360More features unique to Bash may be found in *Note Bash Features::.
ccc6cda3 8361
37c41ab1
CR
8362B.1 Implementation Differences From The SVR4.2 Shell
8363====================================================
ccc6cda3 8364
37c41ab1
CR
8365Since Bash is a completely new implementation, it does not suffer from
8366many of the limitations of the SVR4.2 shell. For instance:
ccc6cda3 8367
bb70624e
JA
8368 * Bash does not fork a subshell when redirecting into or out of a
8369 shell control structure such as an `if' or `while' statement.
ccc6cda3 8370
bb70624e
JA
8371 * Bash does not allow unbalanced quotes. The SVR4.2 shell will
8372 silently insert a needed closing quote at `EOF' under certain
8373 circumstances. This can be the cause of some hard-to-find errors.
ccc6cda3 8374
bb70624e
JA
8375 * The SVR4.2 shell uses a baroque memory management scheme based on
8376 trapping `SIGSEGV'. If the shell is started from a process with
8377 `SIGSEGV' blocked (e.g., by using the `system()' C library
8378 function call), it misbehaves badly.
ccc6cda3 8379
bb70624e
JA
8380 * In a questionable attempt at security, the SVR4.2 shell, when
8381 invoked without the `-p' option, will alter its real and effective
8382 UID and GID if they are less than some magic threshold value,
8383 commonly 100. This can lead to unexpected results.
ccc6cda3 8384
bb70624e
JA
8385 * The SVR4.2 shell does not allow users to trap `SIGSEGV',
8386 `SIGALRM', or `SIGCHLD'.
ccc6cda3 8387
bb70624e
JA
8388 * The SVR4.2 shell does not allow the `IFS', `MAILCHECK', `PATH',
8389 `PS1', or `PS2' variables to be unset.
ccc6cda3 8390
bb70624e 8391 * The SVR4.2 shell treats `^' as the undocumented equivalent of `|'.
ccc6cda3 8392
bb70624e
JA
8393 * Bash allows multiple option arguments when it is invoked (`-x -v');
8394 the SVR4.2 shell allows only one option argument (`-xv'). In
8395 fact, some versions of the shell dump core if the second argument
8396 begins with a `-'.
ccc6cda3 8397
bb70624e
JA
8398 * The SVR4.2 shell exits a script if any builtin fails; Bash exits a
8399 script only if one of the POSIX 1003.2 special builtins fails, and
8400 only for certain failures, as enumerated in the POSIX 1003.2
8401 standard.
ccc6cda3 8402
bb70624e
JA
8403 * The SVR4.2 shell behaves differently when invoked as `jsh' (it
8404 turns on job control).
ccc6cda3
JA
8405
8406\1f
d3a24ed2
CR
8407File: bashref.info, Node: Copying This Manual, Next: Builtin Index, Prev: Major Differences From The Bourne Shell, Up: Top
8408
37c41ab1
CR
8409Appendix C Copying This Manual
8410******************************
d3a24ed2
CR
8411
8412* Menu:
8413
8414* GNU Free Documentation License:: License for copying this manual.
8415
8416\1f
8417File: bashref.info, Node: GNU Free Documentation License, Up: Copying This Manual
8418
37c41ab1
CR
8419C.1 GNU Free Documentation License
8420==================================
d3a24ed2
CR
8421
8422 Version 1.2, November 2002
37c41ab1 8423
d3a24ed2
CR
8424 Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
8425 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
37c41ab1 8426
d3a24ed2
CR
8427 Everyone is permitted to copy and distribute verbatim copies
8428 of this license document, but changing it is not allowed.
8429
8430 0. PREAMBLE
8431
8432 The purpose of this License is to make a manual, textbook, or other
8433 functional and useful document "free" in the sense of freedom: to
8434 assure everyone the effective freedom to copy and redistribute it,
8435 with or without modifying it, either commercially or
8436 noncommercially. Secondarily, this License preserves for the
8437 author and publisher a way to get credit for their work, while not
8438 being considered responsible for modifications made by others.
8439
8440 This License is a kind of "copyleft", which means that derivative
8441 works of the document must themselves be free in the same sense.
8442 It complements the GNU General Public License, which is a copyleft
8443 license designed for free software.
8444
8445 We have designed this License in order to use it for manuals for
8446 free software, because free software needs free documentation: a
8447 free program should come with manuals providing the same freedoms
8448 that the software does. But this License is not limited to
8449 software manuals; it can be used for any textual work, regardless
8450 of subject matter or whether it is published as a printed book.
8451 We recommend this License principally for works whose purpose is
8452 instruction or reference.
8453
8454 1. APPLICABILITY AND DEFINITIONS
8455
8456 This License applies to any manual or other work, in any medium,
8457 that contains a notice placed by the copyright holder saying it
8458 can be distributed under the terms of this License. Such a notice
8459 grants a world-wide, royalty-free license, unlimited in duration,
8460 to use that work under the conditions stated herein. The
8461 "Document", below, refers to any such manual or work. Any member
8462 of the public is a licensee, and is addressed as "you". You
8463 accept the license if you copy, modify or distribute the work in a
8464 way requiring permission under copyright law.
8465
8466 A "Modified Version" of the Document means any work containing the
8467 Document or a portion of it, either copied verbatim, or with
8468 modifications and/or translated into another language.
8469
8470 A "Secondary Section" is a named appendix or a front-matter section
8471 of the Document that deals exclusively with the relationship of the
8472 publishers or authors of the Document to the Document's overall
8473 subject (or to related matters) and contains nothing that could
8474 fall directly within that overall subject. (Thus, if the Document
8475 is in part a textbook of mathematics, a Secondary Section may not
8476 explain any mathematics.) The relationship could be a matter of
8477 historical connection with the subject or with related matters, or
8478 of legal, commercial, philosophical, ethical or political position
8479 regarding them.
8480
8481 The "Invariant Sections" are certain Secondary Sections whose
8482 titles are designated, as being those of Invariant Sections, in
8483 the notice that says that the Document is released under this
8484 License. If a section does not fit the above definition of
8485 Secondary then it is not allowed to be designated as Invariant.
8486 The Document may contain zero Invariant Sections. If the Document
8487 does not identify any Invariant Sections then there are none.
8488
8489 The "Cover Texts" are certain short passages of text that are
8490 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
8491 that says that the Document is released under this License. A
8492 Front-Cover Text may be at most 5 words, and a Back-Cover Text may
8493 be at most 25 words.
8494
8495 A "Transparent" copy of the Document means a machine-readable copy,
8496 represented in a format whose specification is available to the
8497 general public, that is suitable for revising the document
8498 straightforwardly with generic text editors or (for images
8499 composed of pixels) generic paint programs or (for drawings) some
8500 widely available drawing editor, and that is suitable for input to
8501 text formatters or for automatic translation to a variety of
8502 formats suitable for input to text formatters. A copy made in an
8503 otherwise Transparent file format whose markup, or absence of
8504 markup, has been arranged to thwart or discourage subsequent
8505 modification by readers is not Transparent. An image format is
8506 not Transparent if used for any substantial amount of text. A
8507 copy that is not "Transparent" is called "Opaque".
8508
8509 Examples of suitable formats for Transparent copies include plain
8510 ASCII without markup, Texinfo input format, LaTeX input format,
8511 SGML or XML using a publicly available DTD, and
8512 standard-conforming simple HTML, PostScript or PDF designed for
8513 human modification. Examples of transparent image formats include
8514 PNG, XCF and JPG. Opaque formats include proprietary formats that
8515 can be read and edited only by proprietary word processors, SGML or
8516 XML for which the DTD and/or processing tools are not generally
8517 available, and the machine-generated HTML, PostScript or PDF
8518 produced by some word processors for output purposes only.
8519
8520 The "Title Page" means, for a printed book, the title page itself,
8521 plus such following pages as are needed to hold, legibly, the
8522 material this License requires to appear in the title page. For
8523 works in formats which do not have any title page as such, "Title
8524 Page" means the text near the most prominent appearance of the
8525 work's title, preceding the beginning of the body of the text.
8526
8527 A section "Entitled XYZ" means a named subunit of the Document
8528 whose title either is precisely XYZ or contains XYZ in parentheses
8529 following text that translates XYZ in another language. (Here XYZ
8530 stands for a specific section name mentioned below, such as
8531 "Acknowledgements", "Dedications", "Endorsements", or "History".)
8532 To "Preserve the Title" of such a section when you modify the
8533 Document means that it remains a section "Entitled XYZ" according
8534 to this definition.
8535
8536 The Document may include Warranty Disclaimers next to the notice
8537 which states that this License applies to the Document. These
8538 Warranty Disclaimers are considered to be included by reference in
8539 this License, but only as regards disclaiming warranties: any other
8540 implication that these Warranty Disclaimers may have is void and
8541 has no effect on the meaning of this License.
8542
8543 2. VERBATIM COPYING
8544
8545 You may copy and distribute the Document in any medium, either
8546 commercially or noncommercially, provided that this License, the
8547 copyright notices, and the license notice saying this License
8548 applies to the Document are reproduced in all copies, and that you
8549 add no other conditions whatsoever to those of this License. You
8550 may not use technical measures to obstruct or control the reading
8551 or further copying of the copies you make or distribute. However,
8552 you may accept compensation in exchange for copies. If you
8553 distribute a large enough number of copies you must also follow
8554 the conditions in section 3.
8555
8556 You may also lend copies, under the same conditions stated above,
8557 and you may publicly display copies.
8558
8559 3. COPYING IN QUANTITY
8560
8561 If you publish printed copies (or copies in media that commonly
8562 have printed covers) of the Document, numbering more than 100, and
8563 the Document's license notice requires Cover Texts, you must
8564 enclose the copies in covers that carry, clearly and legibly, all
8565 these Cover Texts: Front-Cover Texts on the front cover, and
8566 Back-Cover Texts on the back cover. Both covers must also clearly
8567 and legibly identify you as the publisher of these copies. The
8568 front cover must present the full title with all words of the
8569 title equally prominent and visible. You may add other material
8570 on the covers in addition. Copying with changes limited to the
8571 covers, as long as they preserve the title of the Document and
8572 satisfy these conditions, can be treated as verbatim copying in
8573 other respects.
8574
8575 If the required texts for either cover are too voluminous to fit
8576 legibly, you should put the first ones listed (as many as fit
8577 reasonably) on the actual cover, and continue the rest onto
8578 adjacent pages.
8579
8580 If you publish or distribute Opaque copies of the Document
8581 numbering more than 100, you must either include a
8582 machine-readable Transparent copy along with each Opaque copy, or
8583 state in or with each Opaque copy a computer-network location from
8584 which the general network-using public has access to download
8585 using public-standard network protocols a complete Transparent
8586 copy of the Document, free of added material. If you use the
8587 latter option, you must take reasonably prudent steps, when you
8588 begin distribution of Opaque copies in quantity, to ensure that
8589 this Transparent copy will remain thus accessible at the stated
8590 location until at least one year after the last time you
8591 distribute an Opaque copy (directly or through your agents or
8592 retailers) of that edition to the public.
8593
8594 It is requested, but not required, that you contact the authors of
8595 the Document well before redistributing any large number of
8596 copies, to give them a chance to provide you with an updated
8597 version of the Document.
8598
8599 4. MODIFICATIONS
8600
8601 You may copy and distribute a Modified Version of the Document
8602 under the conditions of sections 2 and 3 above, provided that you
8603 release the Modified Version under precisely this License, with
8604 the Modified Version filling the role of the Document, thus
8605 licensing distribution and modification of the Modified Version to
8606 whoever possesses a copy of it. In addition, you must do these
8607 things in the Modified Version:
8608
8609 A. Use in the Title Page (and on the covers, if any) a title
8610 distinct from that of the Document, and from those of
8611 previous versions (which should, if there were any, be listed
8612 in the History section of the Document). You may use the
8613 same title as a previous version if the original publisher of
8614 that version gives permission.
8615
8616 B. List on the Title Page, as authors, one or more persons or
8617 entities responsible for authorship of the modifications in
8618 the Modified Version, together with at least five of the
8619 principal authors of the Document (all of its principal
8620 authors, if it has fewer than five), unless they release you
8621 from this requirement.
8622
8623 C. State on the Title page the name of the publisher of the
8624 Modified Version, as the publisher.
8625
8626 D. Preserve all the copyright notices of the Document.
8627
8628 E. Add an appropriate copyright notice for your modifications
8629 adjacent to the other copyright notices.
8630
8631 F. Include, immediately after the copyright notices, a license
8632 notice giving the public permission to use the Modified
8633 Version under the terms of this License, in the form shown in
8634 the Addendum below.
8635
8636 G. Preserve in that license notice the full lists of Invariant
8637 Sections and required Cover Texts given in the Document's
8638 license notice.
8639
8640 H. Include an unaltered copy of this License.
8641
8642 I. Preserve the section Entitled "History", Preserve its Title,
8643 and add to it an item stating at least the title, year, new
8644 authors, and publisher of the Modified Version as given on
8645 the Title Page. If there is no section Entitled "History" in
8646 the Document, create one stating the title, year, authors,
8647 and publisher of the Document as given on its Title Page,
8648 then add an item describing the Modified Version as stated in
8649 the previous sentence.
8650
8651 J. Preserve the network location, if any, given in the Document
8652 for public access to a Transparent copy of the Document, and
8653 likewise the network locations given in the Document for
8654 previous versions it was based on. These may be placed in
8655 the "History" section. You may omit a network location for a
8656 work that was published at least four years before the
8657 Document itself, or if the original publisher of the version
8658 it refers to gives permission.
8659
8660 K. For any section Entitled "Acknowledgements" or "Dedications",
8661 Preserve the Title of the section, and preserve in the
8662 section all the substance and tone of each of the contributor
8663 acknowledgements and/or dedications given therein.
8664
8665 L. Preserve all the Invariant Sections of the Document,
8666 unaltered in their text and in their titles. Section numbers
8667 or the equivalent are not considered part of the section
8668 titles.
8669
8670 M. Delete any section Entitled "Endorsements". Such a section
8671 may not be included in the Modified Version.
8672
8673 N. Do not retitle any existing section to be Entitled
8674 "Endorsements" or to conflict in title with any Invariant
8675 Section.
8676
8677 O. Preserve any Warranty Disclaimers.
8678
8679 If the Modified Version includes new front-matter sections or
8680 appendices that qualify as Secondary Sections and contain no
8681 material copied from the Document, you may at your option
8682 designate some or all of these sections as invariant. To do this,
8683 add their titles to the list of Invariant Sections in the Modified
8684 Version's license notice. These titles must be distinct from any
8685 other section titles.
8686
8687 You may add a section Entitled "Endorsements", provided it contains
8688 nothing but endorsements of your Modified Version by various
8689 parties--for example, statements of peer review or that the text
8690 has been approved by an organization as the authoritative
8691 definition of a standard.
8692
8693 You may add a passage of up to five words as a Front-Cover Text,
8694 and a passage of up to 25 words as a Back-Cover Text, to the end
8695 of the list of Cover Texts in the Modified Version. Only one
8696 passage of Front-Cover Text and one of Back-Cover Text may be
8697 added by (or through arrangements made by) any one entity. If the
8698 Document already includes a cover text for the same cover,
8699 previously added by you or by arrangement made by the same entity
8700 you are acting on behalf of, you may not add another; but you may
8701 replace the old one, on explicit permission from the previous
8702 publisher that added the old one.
8703
8704 The author(s) and publisher(s) of the Document do not by this
8705 License give permission to use their names for publicity for or to
8706 assert or imply endorsement of any Modified Version.
8707
8708 5. COMBINING DOCUMENTS
8709
8710 You may combine the Document with other documents released under
8711 this License, under the terms defined in section 4 above for
8712 modified versions, provided that you include in the combination
8713 all of the Invariant Sections of all of the original documents,
8714 unmodified, and list them all as Invariant Sections of your
8715 combined work in its license notice, and that you preserve all
8716 their Warranty Disclaimers.
8717
8718 The combined work need only contain one copy of this License, and
8719 multiple identical Invariant Sections may be replaced with a single
8720 copy. If there are multiple Invariant Sections with the same name
8721 but different contents, make the title of each such section unique
8722 by adding at the end of it, in parentheses, the name of the
8723 original author or publisher of that section if known, or else a
8724 unique number. Make the same adjustment to the section titles in
8725 the list of Invariant Sections in the license notice of the
8726 combined work.
8727
8728 In the combination, you must combine any sections Entitled
8729 "History" in the various original documents, forming one section
8730 Entitled "History"; likewise combine any sections Entitled
8731 "Acknowledgements", and any sections Entitled "Dedications". You
8732 must delete all sections Entitled "Endorsements."
8733
8734 6. COLLECTIONS OF DOCUMENTS
8735
8736 You may make a collection consisting of the Document and other
8737 documents released under this License, and replace the individual
8738 copies of this License in the various documents with a single copy
8739 that is included in the collection, provided that you follow the
8740 rules of this License for verbatim copying of each of the
8741 documents in all other respects.
8742
8743 You may extract a single document from such a collection, and
8744 distribute it individually under this License, provided you insert
8745 a copy of this License into the extracted document, and follow
8746 this License in all other respects regarding verbatim copying of
8747 that document.
8748
8749 7. AGGREGATION WITH INDEPENDENT WORKS
8750
8751 A compilation of the Document or its derivatives with other
8752 separate and independent documents or works, in or on a volume of
8753 a storage or distribution medium, is called an "aggregate" if the
8754 copyright resulting from the compilation is not used to limit the
8755 legal rights of the compilation's users beyond what the individual
8756 works permit. When the Document is included an aggregate, this
8757 License does not apply to the other works in the aggregate which
8758 are not themselves derivative works of the Document.
8759
8760 If the Cover Text requirement of section 3 is applicable to these
8761 copies of the Document, then if the Document is less than one half
8762 of the entire aggregate, the Document's Cover Texts may be placed
8763 on covers that bracket the Document within the aggregate, or the
8764 electronic equivalent of covers if the Document is in electronic
8765 form. Otherwise they must appear on printed covers that bracket
8766 the whole aggregate.
8767
8768 8. TRANSLATION
8769
8770 Translation is considered a kind of modification, so you may
8771 distribute translations of the Document under the terms of section
8772 4. Replacing Invariant Sections with translations requires special
8773 permission from their copyright holders, but you may include
8774 translations of some or all Invariant Sections in addition to the
8775 original versions of these Invariant Sections. You may include a
8776 translation of this License, and all the license notices in the
8777 Document, and any Warranty Disclaimers, provided that you also
8778 include the original English version of this License and the
8779 original versions of those notices and disclaimers. In case of a
8780 disagreement between the translation and the original version of
8781 this License or a notice or disclaimer, the original version will
8782 prevail.
8783
8784 If a section in the Document is Entitled "Acknowledgements",
8785 "Dedications", or "History", the requirement (section 4) to
8786 Preserve its Title (section 1) will typically require changing the
8787 actual title.
8788
8789 9. TERMINATION
8790
8791 You may not copy, modify, sublicense, or distribute the Document
8792 except as expressly provided for under this License. Any other
8793 attempt to copy, modify, sublicense or distribute the Document is
8794 void, and will automatically terminate your rights under this
8795 License. However, parties who have received copies, or rights,
8796 from you under this License will not have their licenses
8797 terminated so long as such parties remain in full compliance.
8798
8799 10. FUTURE REVISIONS OF THIS LICENSE
8800
8801 The Free Software Foundation may publish new, revised versions of
8802 the GNU Free Documentation License from time to time. Such new
8803 versions will be similar in spirit to the present version, but may
8804 differ in detail to address new problems or concerns. See
8805 `http://www.gnu.org/copyleft/'.
8806
8807 Each version of the License is given a distinguishing version
8808 number. If the Document specifies that a particular numbered
8809 version of this License "or any later version" applies to it, you
8810 have the option of following the terms and conditions either of
8811 that specified version or of any later version that has been
8812 published (not as a draft) by the Free Software Foundation. If
8813 the Document does not specify a version number of this License,
8814 you may choose any version ever published (not as a draft) by the
8815 Free Software Foundation.
8816
37c41ab1
CR
8817C.1.1 ADDENDUM: How to use this License for your documents
8818----------------------------------------------------------
d3a24ed2 8819
37c41ab1 8820To use this License in a document you have written, include a copy of
d3a24ed2
CR
8821the License in the document and put the following copyright and license
8822notices just after the title page:
8823
8824 Copyright (C) YEAR YOUR NAME.
8825 Permission is granted to copy, distribute and/or modify this document
8826 under the terms of the GNU Free Documentation License, Version 1.2
8827 or any later version published by the Free Software Foundation;
8828 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
8829 A copy of the license is included in the section entitled ``GNU
8830 Free Documentation License''.
8831
8832 If you have Invariant Sections, Front-Cover Texts and Back-Cover
8833Texts, replace the "with...Texts." line with this:
8834
8835 with the Invariant Sections being LIST THEIR TITLES, with
8836 the Front-Cover Texts being LIST, and with the Back-Cover Texts
8837 being LIST.
8838
8839 If you have Invariant Sections without Cover Texts, or some other
8840combination of the three, merge those two alternatives to suit the
8841situation.
8842
8843 If your document contains nontrivial examples of program code, we
8844recommend releasing these examples in parallel under your choice of
8845free software license, such as the GNU General Public License, to
8846permit their use in free software.
8847
8848\1f
8849File: bashref.info, Node: Builtin Index, Next: Reserved Word Index, Prev: Copying This Manual, Up: Top
ccc6cda3
JA
8850
8851Index of Shell Builtin Commands
8852*******************************
8853
37c41ab1 8854\0\b[index\0\b]
ccc6cda3
JA
8855* Menu:
8856
e8ce775d 8857* .: Bourne Shell Builtins.
37c41ab1 8858 (line 16)
e8ce775d 8859* :: Bourne Shell Builtins.
37c41ab1 8860 (line 11)
e8ce775d 8861* [: Bourne Shell Builtins.
37c41ab1
CR
8862 (line 212)
8863* alias: Bash Builtins. (line 11)
e8ce775d 8864* bg: Job Control Builtins.
37c41ab1
CR
8865 (line 7)
8866* bind: Bash Builtins. (line 21)
e8ce775d 8867* break: Bourne Shell Builtins.
37c41ab1
CR
8868 (line 29)
8869* builtin: Bash Builtins. (line 92)
8870* caller: Bash Builtins. (line 100)
e8ce775d 8871* cd: Bourne Shell Builtins.
37c41ab1
CR
8872 (line 36)
8873* command: Bash Builtins. (line 117)
bb70624e 8874* compgen: Programmable Completion Builtins.
37c41ab1 8875 (line 10)
bb70624e 8876* complete: Programmable Completion Builtins.
37c41ab1 8877 (line 28)
e8ce775d 8878* continue: Bourne Shell Builtins.
37c41ab1
CR
8879 (line 55)
8880* declare: Bash Builtins. (line 136)
bb70624e 8881* dirs: Directory Stack Builtins.
37c41ab1 8882 (line 7)
e8ce775d 8883* disown: Job Control Builtins.
37c41ab1
CR
8884 (line 83)
8885* echo: Bash Builtins. (line 191)
8886* enable: Bash Builtins. (line 244)
e8ce775d 8887* eval: Bourne Shell Builtins.
37c41ab1 8888 (line 63)
e8ce775d 8889* exec: Bourne Shell Builtins.
37c41ab1 8890 (line 70)
e8ce775d 8891* exit: Bourne Shell Builtins.
37c41ab1 8892 (line 82)
e8ce775d 8893* export: Bourne Shell Builtins.
37c41ab1 8894 (line 88)
cce855bc 8895* fc: Bash History Builtins.
37c41ab1 8896 (line 10)
e8ce775d 8897* fg: Job Control Builtins.
37c41ab1 8898 (line 16)
e8ce775d 8899* getopts: Bourne Shell Builtins.
37c41ab1 8900 (line 103)
e8ce775d 8901* hash: Bourne Shell Builtins.
37c41ab1
CR
8902 (line 145)
8903* help: Bash Builtins. (line 272)
cce855bc 8904* history: Bash History Builtins.
37c41ab1 8905 (line 39)
e8ce775d 8906* jobs: Job Control Builtins.
37c41ab1 8907 (line 25)
e8ce775d 8908* kill: Job Control Builtins.
37c41ab1
CR
8909 (line 57)
8910* let: Bash Builtins. (line 281)
8911* local: Bash Builtins. (line 288)
8912* logout: Bash Builtins. (line 298)
bb70624e 8913* popd: Directory Stack Builtins.
37c41ab1
CR
8914 (line 37)
8915* printf: Bash Builtins. (line 302)
bb70624e 8916* pushd: Directory Stack Builtins.
37c41ab1 8917 (line 58)
e8ce775d 8918* pwd: Bourne Shell Builtins.
37c41ab1
CR
8919 (line 163)
8920* read: Bash Builtins. (line 324)
e8ce775d 8921* readonly: Bourne Shell Builtins.
37c41ab1 8922 (line 172)
e8ce775d 8923* return: Bourne Shell Builtins.
37c41ab1
CR
8924 (line 187)
8925* set: The Set Builtin. (line 9)
e8ce775d 8926* shift: Bourne Shell Builtins.
37c41ab1
CR
8927 (line 200)
8928* shopt: Bash Builtins. (line 385)
8929* source: Bash Builtins. (line 600)
e8ce775d 8930* suspend: Job Control Builtins.
37c41ab1 8931 (line 94)
e8ce775d 8932* test: Bourne Shell Builtins.
37c41ab1 8933 (line 212)
e8ce775d 8934* times: Bourne Shell Builtins.
37c41ab1 8935 (line 276)
e8ce775d 8936* trap: Bourne Shell Builtins.
37c41ab1
CR
8937 (line 281)
8938* type: Bash Builtins. (line 604)
8939* typeset: Bash Builtins. (line 635)
8940* ulimit: Bash Builtins. (line 641)
e8ce775d 8941* umask: Bourne Shell Builtins.
37c41ab1
CR
8942 (line 322)
8943* unalias: Bash Builtins. (line 703)
e8ce775d 8944* unset: Bourne Shell Builtins.
37c41ab1 8945 (line 339)
e8ce775d 8946* wait: Job Control Builtins.
37c41ab1 8947 (line 73)
ccc6cda3
JA
8948
8949\1f
8950File: bashref.info, Node: Reserved Word Index, Next: Variable Index, Prev: Builtin Index, Up: Top
8951
bb70624e
JA
8952Index of Shell Reserved Words
8953*****************************
ccc6cda3 8954
37c41ab1 8955\0\b[index\0\b]
ccc6cda3
JA
8956* Menu:
8957
37c41ab1 8958* !: Pipelines. (line 8)
cce855bc 8959* [[: Conditional Constructs.
37c41ab1 8960 (line 105)
cce855bc 8961* ]]: Conditional Constructs.
37c41ab1 8962 (line 105)
e8ce775d 8963* case: Conditional Constructs.
37c41ab1
CR
8964 (line 28)
8965* do: Looping Constructs. (line 12)
8966* done: Looping Constructs. (line 12)
e8ce775d 8967* elif: Conditional Constructs.
37c41ab1 8968 (line 7)
e8ce775d 8969* else: Conditional Constructs.
37c41ab1 8970 (line 7)
e8ce775d 8971* esac: Conditional Constructs.
37c41ab1 8972 (line 28)
e8ce775d 8973* fi: Conditional Constructs.
37c41ab1
CR
8974 (line 7)
8975* for: Looping Constructs. (line 29)
8976* function: Shell Functions. (line 13)
e8ce775d 8977* if: Conditional Constructs.
37c41ab1 8978 (line 7)
e8ce775d 8979* in: Conditional Constructs.
37c41ab1 8980 (line 28)
cce855bc 8981* select: Conditional Constructs.
37c41ab1 8982 (line 64)
e8ce775d 8983* then: Conditional Constructs.
37c41ab1
CR
8984 (line 7)
8985* time: Pipelines. (line 8)
8986* until: Looping Constructs. (line 12)
8987* while: Looping Constructs. (line 20)
8988* {: Command Grouping. (line 21)
8989* }: Command Grouping. (line 21)
ccc6cda3
JA
8990
8991\1f
8992File: bashref.info, Node: Variable Index, Next: Function Index, Prev: Reserved Word Index, Up: Top
8993
8994Parameter and Variable Index
8995****************************
8996
37c41ab1 8997\0\b[index\0\b]
ccc6cda3
JA
8998* Menu:
8999
37c41ab1
CR
9000* !: Special Parameters. (line 46)
9001* #: Special Parameters. (line 30)
9002* $: Special Parameters. (line 42)
9003* *: Special Parameters. (line 9)
9004* -: Special Parameters. (line 37)
9005* 0: Special Parameters. (line 50)
9006* ?: Special Parameters. (line 33)
9007* @: Special Parameters. (line 19)
9008* _: Special Parameters. (line 59)
e8ce775d 9009* auto_resume: Job Control Variables.
37c41ab1
CR
9010 (line 6)
9011* BASH: Bash Variables. (line 13)
9012* BASH_ARGC: Bash Variables. (line 16)
9013* BASH_ARGV: Bash Variables. (line 24)
9014* BASH_COMMAND: Bash Variables. (line 31)
9015* BASH_ENV: Bash Variables. (line 36)
9016* BASH_EXECUTION_STRING: Bash Variables. (line 42)
9017* BASH_LINENO: Bash Variables. (line 45)
9018* BASH_REMATCH: Bash Variables. (line 53)
9019* BASH_SOURCE: Bash Variables. (line 61)
9020* BASH_SUBSHELL: Bash Variables. (line 65)
9021* BASH_VERSINFO: Bash Variables. (line 69)
9022* BASH_VERSION: Bash Variables. (line 93)
e8ce775d 9023* bell-style: Readline Init File Syntax.
37c41ab1 9024 (line 34)
e8ce775d 9025* CDPATH: Bourne Shell Variables.
37c41ab1
CR
9026 (line 9)
9027* COLUMNS: Bash Variables. (line 96)
e8ce775d 9028* comment-begin: Readline Init File Syntax.
37c41ab1
CR
9029 (line 41)
9030* COMP_CWORD: Bash Variables. (line 101)
9031* COMP_LINE: Bash Variables. (line 107)
9032* COMP_POINT: Bash Variables. (line 112)
9033* COMP_WORDBREAKS: Bash Variables. (line 120)
9034* COMP_WORDS: Bash Variables. (line 126)
e8ce775d 9035* completion-query-items: Readline Init File Syntax.
37c41ab1
CR
9036 (line 51)
9037* COMPREPLY: Bash Variables. (line 132)
e8ce775d 9038* convert-meta: Readline Init File Syntax.
37c41ab1
CR
9039 (line 60)
9040* DIRSTACK: Bash Variables. (line 137)
e8ce775d 9041* disable-completion: Readline Init File Syntax.
37c41ab1 9042 (line 66)
e8ce775d 9043* editing-mode: Readline Init File Syntax.
37c41ab1
CR
9044 (line 71)
9045* EMACS: Bash Variables. (line 147)
e8ce775d 9046* enable-keypad: Readline Init File Syntax.
37c41ab1
CR
9047 (line 77)
9048* EUID: Bash Variables. (line 152)
e8ce775d 9049* expand-tilde: Readline Init File Syntax.
37c41ab1
CR
9050 (line 82)
9051* FCEDIT: Bash Variables. (line 156)
9052* FIGNORE: Bash Variables. (line 160)
9053* FUNCNAME: Bash Variables. (line 166)
9054* GLOBIGNORE: Bash Variables. (line 175)
9055* GROUPS: Bash Variables. (line 181)
9056* histchars: Bash Variables. (line 187)
9057* HISTCMD: Bash Variables. (line 202)
9058* HISTCONTROL: Bash Variables. (line 207)
9059* HISTFILE: Bash Variables. (line 223)
9060* HISTFILESIZE: Bash Variables. (line 227)
9061* HISTIGNORE: Bash Variables. (line 234)
f73dda09 9062* history-preserve-point: Readline Init File Syntax.
37c41ab1
CR
9063 (line 85)
9064* HISTSIZE: Bash Variables. (line 253)
9065* HISTTIMEFORMAT: Bash Variables. (line 257)
e8ce775d 9066* HOME: Bourne Shell Variables.
37c41ab1 9067 (line 13)
e8ce775d 9068* horizontal-scroll-mode: Readline Init File Syntax.
37c41ab1
CR
9069 (line 90)
9070* HOSTFILE: Bash Variables. (line 264)
9071* HOSTNAME: Bash Variables. (line 275)
9072* HOSTTYPE: Bash Variables. (line 278)
e8ce775d 9073* IFS: Bourne Shell Variables.
37c41ab1
CR
9074 (line 18)
9075* IGNOREEOF: Bash Variables. (line 281)
e8ce775d 9076* input-meta: Readline Init File Syntax.
37c41ab1
CR
9077 (line 97)
9078* INPUTRC: Bash Variables. (line 291)
b72432fd 9079* isearch-terminators: Readline Init File Syntax.
37c41ab1 9080 (line 104)
e8ce775d 9081* keymap: Readline Init File Syntax.
37c41ab1
CR
9082 (line 111)
9083* LANG: Bash Variables. (line 295)
9084* LC_ALL: Bash Variables. (line 299)
9085* LC_COLLATE: Bash Variables. (line 303)
9086* LC_CTYPE: Bash Variables. (line 310)
9087* LC_MESSAGES <1>: Locale Translation. (line 11)
9088* LC_MESSAGES: Bash Variables. (line 315)
9089* LC_NUMERIC: Bash Variables. (line 319)
9090* LINENO: Bash Variables. (line 323)
9091* LINES: Bash Variables. (line 327)
9092* MACHTYPE: Bash Variables. (line 332)
e8ce775d 9093* MAIL: Bourne Shell Variables.
37c41ab1
CR
9094 (line 22)
9095* MAILCHECK: Bash Variables. (line 336)
e8ce775d 9096* MAILPATH: Bourne Shell Variables.
37c41ab1 9097 (line 27)
e8ce775d 9098* mark-modified-lines: Readline Init File Syntax.
37c41ab1 9099 (line 124)
7117c2d2 9100* mark-symlinked-directories: Readline Init File Syntax.
37c41ab1 9101 (line 129)
f73dda09 9102* match-hidden-files: Readline Init File Syntax.
37c41ab1 9103 (line 134)
e8ce775d 9104* meta-flag: Readline Init File Syntax.
37c41ab1
CR
9105 (line 97)
9106* OLDPWD: Bash Variables. (line 344)
e8ce775d 9107* OPTARG: Bourne Shell Variables.
37c41ab1
CR
9108 (line 34)
9109* OPTERR: Bash Variables. (line 347)
e8ce775d 9110* OPTIND: Bourne Shell Variables.
37c41ab1
CR
9111 (line 38)
9112* OSTYPE: Bash Variables. (line 351)
e8ce775d 9113* output-meta: Readline Init File Syntax.
37c41ab1 9114 (line 141)
7117c2d2 9115* page-completions: Readline Init File Syntax.
37c41ab1 9116 (line 146)
e8ce775d 9117* PATH: Bourne Shell Variables.
37c41ab1
CR
9118 (line 42)
9119* PIPESTATUS: Bash Variables. (line 354)
9120* POSIXLY_CORRECT: Bash Variables. (line 359)
9121* PPID: Bash Variables. (line 368)
9122* PROMPT_COMMAND: Bash Variables. (line 372)
e8ce775d 9123* PS1: Bourne Shell Variables.
37c41ab1 9124 (line 48)
e8ce775d 9125* PS2: Bourne Shell Variables.
37c41ab1
CR
9126 (line 53)
9127* PS3: Bash Variables. (line 376)
9128* PS4: Bash Variables. (line 381)
9129* PWD: Bash Variables. (line 387)
9130* RANDOM: Bash Variables. (line 390)
9131* REPLY: Bash Variables. (line 395)
9132* SECONDS: Bash Variables. (line 398)
9133* SHELL: Bash Variables. (line 404)
9134* SHELLOPTS: Bash Variables. (line 409)
9135* SHLVL: Bash Variables. (line 418)
e8ce775d 9136* show-all-if-ambiguous: Readline Init File Syntax.
37c41ab1 9137 (line 156)
d3a24ed2 9138* show-all-if-unmodified: Readline Init File Syntax.
37c41ab1
CR
9139 (line 162)
9140* TEXTDOMAIN: Locale Translation. (line 11)
9141* TEXTDOMAINDIR: Locale Translation. (line 11)
9142* TIMEFORMAT: Bash Variables. (line 423)
9143* TMOUT: Bash Variables. (line 461)
9144* UID: Bash Variables. (line 473)
e8ce775d 9145* visible-stats: Readline Init File Syntax.
37c41ab1 9146 (line 171)
ccc6cda3
JA
9147
9148\1f
9149File: bashref.info, Node: Function Index, Next: Concept Index, Prev: Variable Index, Up: Top
9150
9151Function Index
9152**************
9153
37c41ab1 9154\0\b[index\0\b]
ccc6cda3
JA
9155* Menu:
9156
e8ce775d 9157* abort (C-g): Miscellaneous Commands.
37c41ab1
CR
9158 (line 10)
9159* accept-line (Newline or Return): Commands For History. (line 6)
9160* backward-char (C-b): Commands For Moving. (line 15)
9161* backward-delete-char (Rubout): Commands For Text. (line 11)
9162* backward-kill-line (C-x Rubout): Commands For Killing. (line 9)
9163* backward-kill-word (M-<DEL>): Commands For Killing. (line 24)
9164* backward-word (M-b): Commands For Moving. (line 22)
9165* beginning-of-history (M-<): Commands For History. (line 20)
9166* beginning-of-line (C-a): Commands For Moving. (line 6)
9167* call-last-kbd-macro (C-x e): Keyboard Macros. (line 13)
9168* capitalize-word (M-c): Commands For Text. (line 46)
e8ce775d 9169* character-search (C-]): Miscellaneous Commands.
37c41ab1 9170 (line 41)
e8ce775d 9171* character-search-backward (M-C-]): Miscellaneous Commands.
37c41ab1
CR
9172 (line 46)
9173* clear-screen (C-l): Commands For Moving. (line 26)
28ef6c31 9174* complete (<TAB>): Commands For Completion.
37c41ab1
CR
9175 (line 6)
9176* copy-backward-word (): Commands For Killing. (line 49)
9177* copy-forward-word (): Commands For Killing. (line 54)
9178* copy-region-as-kill (): Commands For Killing. (line 45)
9179* delete-char (C-d): Commands For Text. (line 6)
b72432fd 9180* delete-char-or-list (): Commands For Completion.
37c41ab1
CR
9181 (line 34)
9182* delete-horizontal-space (): Commands For Killing. (line 37)
9183* digit-argument (M-0, M-1, ... M--): Numeric Arguments. (line 6)
ccc6cda3 9184* do-uppercase-version (M-a, M-b, M-X, ...): Miscellaneous Commands.
37c41ab1
CR
9185 (line 14)
9186* downcase-word (M-l): Commands For Text. (line 42)
e8ce775d 9187* dump-functions (): Miscellaneous Commands.
37c41ab1 9188 (line 64)
e8ce775d 9189* dump-macros (): Miscellaneous Commands.
37c41ab1 9190 (line 76)
e8ce775d 9191* dump-variables (): Miscellaneous Commands.
37c41ab1
CR
9192 (line 70)
9193* end-kbd-macro (C-x )): Keyboard Macros. (line 9)
9194* end-of-history (M->): Commands For History. (line 23)
9195* end-of-line (C-e): Commands For Moving. (line 9)
e8ce775d 9196* exchange-point-and-mark (C-x C-x): Miscellaneous Commands.
37c41ab1
CR
9197 (line 36)
9198* forward-backward-delete-char (): Commands For Text. (line 15)
9199* forward-char (C-f): Commands For Moving. (line 12)
9200* forward-search-history (C-s): Commands For History. (line 31)
9201* forward-word (M-f): Commands For Moving. (line 18)
9202* history-search-backward (): Commands For History. (line 51)
9203* history-search-forward (): Commands For History. (line 46)
e8ce775d 9204* insert-comment (M-#): Miscellaneous Commands.
37c41ab1 9205 (line 51)
e8ce775d 9206* insert-completions (M-*): Commands For Completion.
37c41ab1
CR
9207 (line 18)
9208* kill-line (C-k): Commands For Killing. (line 6)
9209* kill-region (): Commands For Killing. (line 41)
9210* kill-whole-line (): Commands For Killing. (line 15)
9211* kill-word (M-d): Commands For Killing. (line 19)
cce855bc 9212* menu-complete (): Commands For Completion.
37c41ab1
CR
9213 (line 22)
9214* next-history (C-n): Commands For History. (line 17)
ccc6cda3 9215* non-incremental-forward-search-history (M-n): Commands For History.
37c41ab1 9216 (line 41)
ccc6cda3 9217* non-incremental-reverse-search-history (M-p): Commands For History.
37c41ab1
CR
9218 (line 36)
9219* overwrite-mode (): Commands For Text. (line 50)
e8ce775d 9220* possible-completions (M-?): Commands For Completion.
37c41ab1 9221 (line 15)
28ef6c31 9222* prefix-meta (<ESC>): Miscellaneous Commands.
37c41ab1
CR
9223 (line 18)
9224* previous-history (C-p): Commands For History. (line 13)
9225* quoted-insert (C-q or C-v): Commands For Text. (line 20)
e8ce775d 9226* re-read-init-file (C-x C-r): Miscellaneous Commands.
37c41ab1
CR
9227 (line 6)
9228* redraw-current-line (): Commands For Moving. (line 30)
9229* reverse-search-history (C-r): Commands For History. (line 27)
e8ce775d 9230* revert-line (M-r): Miscellaneous Commands.
37c41ab1
CR
9231 (line 25)
9232* self-insert (a, b, A, 1, !, ...): Commands For Text. (line 24)
e8ce775d 9233* set-mark (C-@): Miscellaneous Commands.
37c41ab1
CR
9234 (line 32)
9235* start-kbd-macro (C-x (): Keyboard Macros. (line 6)
9236* transpose-chars (C-t): Commands For Text. (line 27)
9237* transpose-words (M-t): Commands For Text. (line 33)
28ef6c31 9238* undo (C-_ or C-x C-u): Miscellaneous Commands.
37c41ab1
CR
9239 (line 22)
9240* universal-argument (): Numeric Arguments. (line 10)
9241* unix-filename-rubout (): Commands For Killing. (line 32)
9242* unix-line-discard (C-u): Commands For Killing. (line 12)
9243* unix-word-rubout (C-w): Commands For Killing. (line 28)
9244* upcase-word (M-u): Commands For Text. (line 38)
9245* yank (C-y): Commands For Killing. (line 59)
9246* yank-last-arg (M-. or M-_): Commands For History. (line 63)
9247* yank-nth-arg (M-C-y): Commands For History. (line 56)
9248* yank-pop (M-y): Commands For Killing. (line 62)
ccc6cda3
JA
9249
9250\1f
9251File: bashref.info, Node: Concept Index, Prev: Function Index, Up: Top
9252
9253Concept Index
9254*************
9255
37c41ab1 9256\0\b[index\0\b]
ccc6cda3
JA
9257* Menu:
9258
37c41ab1
CR
9259* alias expansion: Aliases. (line 6)
9260* arithmetic evaluation: Shell Arithmetic. (line 6)
e8ce775d 9261* arithmetic expansion: Arithmetic Expansion.
37c41ab1
CR
9262 (line 6)
9263* arithmetic, shell: Shell Arithmetic. (line 6)
9264* arrays: Arrays. (line 6)
9265* background: Job Control Basics. (line 6)
9266* Bash configuration: Basic Installation. (line 6)
9267* Bash installation: Basic Installation. (line 6)
e8ce775d 9268* Bourne shell: Basic Shell Features.
37c41ab1
CR
9269 (line 6)
9270* brace expansion: Brace Expansion. (line 6)
9271* builtin: Definitions. (line 16)
e8ce775d 9272* command editing: Readline Bare Essentials.
37c41ab1 9273 (line 6)
e8ce775d 9274* command execution: Command Search and Execution.
37c41ab1 9275 (line 6)
cce855bc 9276* command expansion: Simple Command Expansion.
37c41ab1 9277 (line 6)
e8ce775d 9278* command history: Bash History Facilities.
37c41ab1 9279 (line 6)
e8ce775d 9280* command search: Command Search and Execution.
37c41ab1 9281 (line 6)
e8ce775d 9282* command substitution: Command Substitution.
37c41ab1
CR
9283 (line 6)
9284* command timing: Pipelines. (line 8)
9285* commands, compound: Compound Commands. (line 6)
e8ce775d 9286* commands, conditional: Conditional Constructs.
37c41ab1
CR
9287 (line 6)
9288* commands, grouping: Command Grouping. (line 6)
9289* commands, lists: Lists. (line 6)
9290* commands, looping: Looping Constructs. (line 6)
9291* commands, pipelines: Pipelines. (line 6)
9292* commands, shell: Shell Commands. (line 6)
9293* commands, simple: Simple Commands. (line 6)
9294* comments, shell: Comments. (line 6)
bb70624e 9295* completion builtins: Programmable Completion Builtins.
37c41ab1
CR
9296 (line 6)
9297* configuration: Basic Installation. (line 6)
9298* control operator: Definitions. (line 20)
9299* directory stack: The Directory Stack. (line 6)
e8ce775d 9300* editing command lines: Readline Bare Essentials.
37c41ab1
CR
9301 (line 6)
9302* environment: Environment. (line 6)
9303* evaluation, arithmetic: Shell Arithmetic. (line 6)
9304* event designators: Event Designators. (line 6)
cce855bc 9305* execution environment: Command Execution Environment.
37c41ab1
CR
9306 (line 6)
9307* exit status <1>: Exit Status. (line 6)
9308* exit status: Definitions. (line 24)
9309* expansion: Shell Expansions. (line 6)
e8ce775d 9310* expansion, arithmetic: Arithmetic Expansion.
37c41ab1
CR
9311 (line 6)
9312* expansion, brace: Brace Expansion. (line 6)
9313* expansion, filename: Filename Expansion. (line 9)
e8ce775d 9314* expansion, parameter: Shell Parameter Expansion.
37c41ab1
CR
9315 (line 6)
9316* expansion, pathname: Filename Expansion. (line 9)
9317* expansion, tilde: Tilde Expansion. (line 6)
9318* expressions, arithmetic: Shell Arithmetic. (line 6)
e8ce775d 9319* expressions, conditional: Bash Conditional Expressions.
37c41ab1 9320 (line 6)
d3a24ed2 9321* FDL, GNU Free Documentation License: GNU Free Documentation License.
37c41ab1
CR
9322 (line 6)
9323* field: Definitions. (line 28)
9324* filename: Definitions. (line 33)
9325* filename expansion: Filename Expansion. (line 9)
9326* foreground: Job Control Basics. (line 6)
9327* functions, shell: Shell Functions. (line 6)
cce855bc 9328* history builtins: Bash History Builtins.
37c41ab1
CR
9329 (line 6)
9330* history events: Event Designators. (line 7)
9331* history expansion: History Interaction. (line 6)
e8ce775d 9332* history list: Bash History Facilities.
37c41ab1 9333 (line 6)
bb70624e 9334* History, how to use: Programmable Completion Builtins.
22e63b05 9335 (line 209)
37c41ab1
CR
9336* identifier: Definitions. (line 49)
9337* initialization file, readline: Readline Init File. (line 6)
9338* installation: Basic Installation. (line 6)
e8ce775d 9339* interaction, readline: Readline Interaction.
37c41ab1
CR
9340 (line 6)
9341* interactive shell <1>: Interactive Shells. (line 6)
9342* interactive shell: Invoking Bash. (line 128)
9343* internationalization: Locale Translation. (line 6)
9344* job: Definitions. (line 36)
9345* job control <1>: Definitions. (line 40)
9346* job control: Job Control Basics. (line 6)
e8ce775d 9347* kill ring: Readline Killing Commands.
37c41ab1 9348 (line 19)
e8ce775d 9349* killing text: Readline Killing Commands.
37c41ab1
CR
9350 (line 6)
9351* localization: Locale Translation. (line 6)
9352* login shell: Invoking Bash. (line 125)
9353* matching, pattern: Pattern Matching. (line 6)
9354* metacharacter: Definitions. (line 44)
9355* name: Definitions. (line 49)
9356* native languages: Locale Translation. (line 6)
e8ce775d 9357* notation, readline: Readline Bare Essentials.
37c41ab1
CR
9358 (line 6)
9359* operator, shell: Definitions. (line 55)
e8ce775d 9360* parameter expansion: Shell Parameter Expansion.
37c41ab1
CR
9361 (line 6)
9362* parameters: Shell Parameters. (line 6)
e8ce775d 9363* parameters, positional: Positional Parameters.
37c41ab1
CR
9364 (line 6)
9365* parameters, special: Special Parameters. (line 6)
9366* pathname expansion: Filename Expansion. (line 9)
9367* pattern matching: Pattern Matching. (line 6)
9368* pipeline: Pipelines. (line 6)
9369* POSIX: Definitions. (line 9)
9370* POSIX Mode: Bash POSIX Mode. (line 6)
9371* process group: Definitions. (line 59)
9372* process group ID: Definitions. (line 63)
e8ce775d 9373* process substitution: Process Substitution.
37c41ab1 9374 (line 6)
bb70624e 9375* programmable completion: Programmable Completion.
37c41ab1
CR
9376 (line 6)
9377* prompting: Printing a Prompt. (line 6)
9378* quoting: Quoting. (line 6)
9379* quoting, ANSI: ANSI-C Quoting. (line 6)
bb70624e 9380* Readline, how to use: Job Control Variables.
37c41ab1
CR
9381 (line 24)
9382* redirection: Redirections. (line 6)
9383* reserved word: Definitions. (line 67)
e8ce775d 9384* restricted shell: The Restricted Shell.
37c41ab1
CR
9385 (line 6)
9386* return status: Definitions. (line 72)
9387* shell arithmetic: Shell Arithmetic. (line 6)
9388* shell function: Shell Functions. (line 6)
9389* shell script: Shell Scripts. (line 6)
9390* shell variable: Shell Parameters. (line 6)
9391* shell, interactive: Interactive Shells. (line 6)
9392* signal: Definitions. (line 75)
9393* signal handling: Signals. (line 6)
9394* special builtin <1>: Definitions. (line 79)
9395* special builtin: Special Builtins. (line 6)
9396* startup files: Bash Startup Files. (line 6)
9397* suspending jobs: Job Control Basics. (line 6)
9398* tilde expansion: Tilde Expansion. (line 6)
9399* token: Definitions. (line 83)
9400* translation, native languages: Locale Translation. (line 6)
9401* variable, shell: Shell Parameters. (line 6)
28ef6c31 9402* variables, readline: Readline Init File Syntax.
37c41ab1
CR
9403 (line 33)
9404* word: Definitions. (line 87)
9405* word splitting: Word Splitting. (line 6)
e8ce775d 9406* yanking text: Readline Killing Commands.
37c41ab1 9407 (line 6)
ccc6cda3
JA
9408
9409
9410\1f
9411Tag Table:
22e63b05
CR
9412Node: Top\7f1363
9413Node: Introduction\7f3509
9414Node: What is Bash?\7f3738
9415Node: What is a shell?\7f4831
9416Node: Definitions\7f7372
9417Node: Basic Shell Features\7f10113
9418Node: Shell Syntax\7f11332
9419Node: Shell Operation\7f12364
9420Node: Quoting\7f13658
9421Node: Escape Character\7f14932
9422Node: Single Quotes\7f15417
9423Node: Double Quotes\7f15765
9424Node: ANSI-C Quoting\7f16791
9425Node: Locale Translation\7f17747
9426Node: Comments\7f18643
9427Node: Shell Commands\7f19257
9428Node: Simple Commands\7f20023
9429Node: Pipelines\7f20654
9430Node: Lists\7f22529
9431Node: Compound Commands\7f24160
9432Node: Looping Constructs\7f24944
9433Node: Conditional Constructs\7f27391
9434Node: Command Grouping\7f34458
9435Node: Shell Functions\7f35907
9436Node: Shell Parameters\7f40175
9437Node: Positional Parameters\7f41756
9438Node: Special Parameters\7f42656
9439Node: Shell Expansions\7f45581
9440Node: Brace Expansion\7f47506
9441Node: Tilde Expansion\7f49831
9442Node: Shell Parameter Expansion\7f52172
9443Node: Command Substitution\7f59435
9444Node: Arithmetic Expansion\7f60768
9445Node: Process Substitution\7f61618
9446Node: Word Splitting\7f62668
9447Node: Filename Expansion\7f64129
9448Node: Pattern Matching\7f66265
9449Node: Quote Removal\7f69598
9450Node: Redirections\7f69893
9451Node: Executing Commands\7f77472
9452Node: Simple Command Expansion\7f78147
9453Node: Command Search and Execution\7f80077
9454Node: Command Execution Environment\7f82083
9455Node: Environment\7f84854
9456Node: Exit Status\7f86514
9457Node: Signals\7f87718
9458Node: Shell Scripts\7f89682
9459Node: Shell Builtin Commands\7f92200
9460Node: Bourne Shell Builtins\7f93779
9461Node: Bash Builtins\7f110732
9462Node: The Set Builtin\7f138859
9463Node: Special Builtins\7f147082
9464Node: Shell Variables\7f148059
9465Node: Bourne Shell Variables\7f148499
9466Node: Bash Variables\7f150480
9467Node: Bash Features\7f170187
9468Node: Invoking Bash\7f171070
9469Node: Bash Startup Files\7f176889
9470Node: Interactive Shells\7f181747
9471Node: What is an Interactive Shell?\7f182157
9472Node: Is this Shell Interactive?\7f182807
9473Node: Interactive Shell Behavior\7f183622
9474Node: Bash Conditional Expressions\7f186898
9475Node: Shell Arithmetic\7f190477
9476Node: Aliases\7f193222
9477Node: Arrays\7f195790
9478Node: The Directory Stack\7f199057
9479Node: Directory Stack Builtins\7f199771
9480Node: Printing a Prompt\7f202662
9481Node: The Restricted Shell\7f205376
9482Node: Bash POSIX Mode\7f207208
9483Node: Job Control\7f214541
9484Node: Job Control Basics\7f215008
9485Node: Job Control Builtins\7f219298
9486Node: Job Control Variables\7f223641
9487Node: Command Line Editing\7f224799
9488Node: Introduction and Notation\7f225798
9489Node: Readline Interaction\7f227420
9490Node: Readline Bare Essentials\7f228611
9491Node: Readline Movement Commands\7f230400
9492Node: Readline Killing Commands\7f231365
9493Node: Readline Arguments\7f233285
9494Node: Searching\7f234329
9495Node: Readline Init File\7f236515
9496Node: Readline Init File Syntax\7f237574
9497Node: Conditional Init Constructs\7f249227
9498Node: Sample Init File\7f251760
9499Node: Bindable Readline Commands\7f254877
9500Node: Commands For Moving\7f256084
9501Node: Commands For History\7f256945
9502Node: Commands For Text\7f259846
9503Node: Commands For Killing\7f262519
9504Node: Numeric Arguments\7f264661
9505Node: Commands For Completion\7f265800
9506Node: Keyboard Macros\7f269393
9507Node: Miscellaneous Commands\7f269964
9508Node: Readline vi Mode\7f275275
9509Node: Programmable Completion\7f276189
9510Node: Programmable Completion Builtins\7f282001
9511Node: Using History Interactively\7f289597
9512Node: Bash History Facilities\7f290277
9513Node: Bash History Builtins\7f292972
9514Node: History Interaction\7f296829
9515Node: Event Designators\7f299385
9516Node: Word Designators\7f300400
9517Node: Modifiers\7f302039
9518Node: Installing Bash\7f303445
9519Node: Basic Installation\7f304582
9520Node: Compilers and Options\7f307274
9521Node: Compiling For Multiple Architectures\7f308015
9522Node: Installation Names\7f309679
9523Node: Specifying the System Type\7f310497
9524Node: Sharing Defaults\7f311213
9525Node: Operation Controls\7f311886
9526Node: Optional Features\7f312844
9527Node: Reporting Bugs\7f321123
9528Node: Major Differences From The Bourne Shell\7f322317
9529Node: Copying This Manual\7f338089
9530Node: GNU Free Documentation License\7f338365
9531Node: Builtin Index\7f360771
9532Node: Reserved Word Index\7f367320
9533Node: Variable Index\7f369756
9534Node: Function Index\7f380475
9535Node: Concept Index\7f387195
ccc6cda3
JA
9536\1f
9537End Tag Table