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