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