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