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