189e58bcff436ed709c223f5ada15b7ec9f702e0
[platform/upstream/bash.git] / doc / bashref.info
1 This is bashref.info, produced by makeinfo version 4.13 from
2 /Users/chet/src/bash/src/doc/bashref.texi.
3
4 This text is a brief description of the features that are present in
5 the Bash shell (version 4.1, 23 December 2009).
6
7    This is Edition 4.1, last updated 23 December 2009, of `The GNU Bash
8 Reference Manual', for `Bash', Version 4.1.
9
10    Copyright (C) 1988-2009 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.3 or any later version published by the Free Software
19      Foundation; with no Invariant Sections, with the Front-Cover texts
20      being "A GNU Manual", and with the Back-Cover Texts as in (a)
21      below.  A copy of the license is included in the section entitled
22      "GNU Free Documentation License".
23
24      (a) The FSF's Back-Cover Text is: You are free to copy and modify
25      this GNU manual.  Buying copies from GNU Press supports the FSF in
26      developing GNU and promoting software freedom."
27
28
29 INFO-DIR-SECTION Basics
30 START-INFO-DIR-ENTRY
31 * Bash: (bash).                     The GNU Bourne-Again SHell.
32 END-INFO-DIR-ENTRY
33
34 \1f
35 File: bashref.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
36
37 Bash Features
38 *************
39
40 This text is a brief description of the features that are present in
41 the Bash shell (version 4.1, 23 December 2009).
42
43    This is Edition 4.1, last updated 23 December 2009, of `The GNU Bash
44 Reference Manual', for `Bash', Version 4.1.
45
46    Bash contains features that appear in other popular shells, and some
47 features that only appear in Bash.  Some of the shells that Bash has
48 borrowed concepts from are the Bourne Shell (`sh'), the Korn Shell
49 (`ksh'), and the C-shell (`csh' and its successor, `tcsh'). The
50 following menu breaks the features up into categories based upon which
51 one of these other shells inspired the feature.
52
53    This manual is meant as a brief introduction to features found in
54 Bash.  The Bash manual page should be used as the definitive reference
55 on shell behavior.
56
57 * Menu:
58
59 * Introduction::                An introduction to the shell.
60 * Definitions::                 Some definitions used in the rest of this
61                                 manual.
62 * Basic Shell Features::        The shell "building blocks".
63 * Shell Builtin Commands::      Commands that are a part of the shell.
64 * Shell Variables::             Variables used or set by Bash.
65 * Bash Features::               Features found only in Bash.
66 * Job Control::                 What job control is and how Bash allows you
67                                 to use it.
68 * Command Line Editing::        Chapter describing the command line
69                                 editing features.
70 * Using History Interactively:: Command History Expansion
71 * Installing Bash::             How to build and install Bash on your system.
72 * Reporting Bugs::              How to report bugs in Bash.
73 * Major Differences From The Bourne Shell::     A terse list of the differences
74                                                 between Bash and historical
75                                                 versions of /bin/sh.
76 * GNU Free Documentation License::      Copying and sharing this documentation.
77 * Indexes::                     Various indexes for this manual.
78
79 \1f
80 File: bashref.info,  Node: Introduction,  Next: Definitions,  Prev: Top,  Up: Top
81
82 1 Introduction
83 **************
84
85 * Menu:
86
87 * What is Bash?::               A short description of Bash.
88 * What is a shell?::            A brief introduction to shells.
89
90 \1f
91 File: bashref.info,  Node: What is Bash?,  Next: What is a shell?,  Up: Introduction
92
93 1.1 What is Bash?
94 =================
95
96 Bash is the shell, or command language interpreter, for the GNU
97 operating system.  The name is an acronym for the `Bourne-Again SHell',
98 a pun on Stephen Bourne, the author of the direct ancestor of the
99 current Unix shell `sh', which appeared in the Seventh Edition Bell
100 Labs Research version of Unix.
101
102    Bash is largely compatible with `sh' and incorporates useful
103 features from the Korn shell `ksh' and the C shell `csh'.  It is
104 intended to be a conformant implementation of the IEEE POSIX Shell and
105 Tools portion of the IEEE POSIX specification (IEEE Standard 1003.1).
106 It offers functional improvements over `sh' for both interactive and
107 programming use.
108
109    While the GNU operating system provides other shells, including a
110 version of `csh', Bash is the default shell.  Like other GNU software,
111 Bash is quite portable.  It currently runs on nearly every version of
112 Unix and a few other operating systems - independently-supported ports
113 exist for MS-DOS, OS/2, and Windows platforms.
114
115 \1f
116 File: bashref.info,  Node: What is a shell?,  Prev: What is Bash?,  Up: Introduction
117
118 1.2 What is a shell?
119 ====================
120
121 At its base, a shell is simply a macro processor that executes
122 commands.  The term macro processor means functionality where text and
123 symbols are expanded to create larger expressions.
124
125    A Unix shell is both a command interpreter and a programming
126 language.  As a command interpreter, the shell provides the user
127 interface to the rich set of GNU utilities.  The programming language
128 features allow these utilities to be combined.  Files containing
129 commands can be created, and become commands themselves.  These new
130 commands have the same status as system commands in directories such as
131 `/bin', allowing users or groups to establish custom environments to
132 automate their common tasks.
133
134    Shells may be used interactively or non-interactively.  In
135 interactive mode, they accept input typed from the keyboard.  When
136 executing non-interactively, shells execute commands read from a file.
137
138    A shell allows execution of GNU commands, both synchronously and
139 asynchronously.  The shell waits for synchronous commands to complete
140 before accepting more input; asynchronous commands continue to execute
141 in parallel with the shell while it reads and executes additional
142 commands.  The "redirection" constructs permit fine-grained control of
143 the input and output of those commands.  Moreover, the shell allows
144 control over the contents of commands' environments.
145
146    Shells also provide a small set of built-in commands ("builtins")
147 implementing functionality impossible or inconvenient to obtain via
148 separate utilities.  For example, `cd', `break', `continue', and
149 `exec') cannot be implemented outside of the shell because they
150 directly manipulate the shell itself.  The `history', `getopts',
151 `kill', or `pwd' builtins, among others, could be implemented in
152 separate utilities, but they are more convenient to use as builtin
153 commands.  All of the shell builtins are described in subsequent
154 sections.
155
156    While executing commands is essential, most of the power (and
157 complexity) of shells is due to their embedded programming languages.
158 Like any high-level language, the shell provides variables, flow
159 control constructs, quoting, and functions.
160
161    Shells offer features geared specifically for interactive use rather
162 than to augment the programming language.  These interactive features
163 include job control, command line editing, command history and aliases.
164 Each of these features is described in this manual.
165
166 \1f
167 File: bashref.info,  Node: Definitions,  Next: Basic Shell Features,  Prev: Introduction,  Up: Top
168
169 2 Definitions
170 *************
171
172 These definitions are used throughout the remainder of this manual.
173
174 `POSIX'
175      A family of open system standards based on Unix.  Bash is
176      primarily concerned with the Shell and Utilities portion of the
177      POSIX 1003.1 standard.
178
179 `blank'
180      A space or tab character.
181
182 `builtin'
183      A command that is implemented internally by the shell itself,
184      rather than by an executable program somewhere in the file system.
185
186 `control operator'
187      A `token' that performs a control function.  It is a `newline' or
188      one of the following: `||', `&&', `&', `;', `;;', `|', `|&', `(',
189      or `)'.
190
191 `exit status'
192      The value returned by a command to its caller.  The value is
193      restricted to eight bits, so the maximum value is 255.
194
195 `field'
196      A unit of text that is the result of one of the shell expansions.
197      After expansion, when executing a command, the resulting fields
198      are used as the command name and arguments.
199
200 `filename'
201      A string of characters used to identify a file.
202
203 `job'
204      A set of processes comprising a pipeline, and any processes
205      descended from it, that are all in the same process group.
206
207 `job control'
208      A mechanism by which users can selectively stop (suspend) and
209      restart (resume) execution of processes.
210
211 `metacharacter'
212      A character that, when unquoted, separates words.  A metacharacter
213      is a `blank' or one of the following characters: `|', `&', `;',
214      `(', `)', `<', or `>'.
215
216 `name'
217      A `word' consisting solely of letters, numbers, and underscores,
218      and beginning with a letter or underscore.  `Name's are used as
219      shell variable and function names.  Also referred to as an
220      `identifier'.
221
222 `operator'
223      A `control operator' or a `redirection operator'.  *Note
224      Redirections::, for a list of redirection operators.  Operators
225      contain at least one unquoted `metacharacter'.
226
227 `process group'
228      A collection of related processes each having the same process
229      group ID.
230
231 `process group ID'
232      A unique identifier that represents a `process group' during its
233      lifetime.
234
235 `reserved word'
236      A `word' that has a special meaning to the shell.  Most reserved
237      words introduce shell flow control constructs, such as `for' and
238      `while'.
239
240 `return status'
241      A synonym for `exit status'.
242
243 `signal'
244      A mechanism by which a process may be notified by the kernel of an
245      event occurring in the system.
246
247 `special builtin'
248      A shell builtin command that has been classified as special by the
249      POSIX standard.
250
251 `token'
252      A sequence of characters considered a single unit by the shell.
253      It is either a `word' or an `operator'.
254
255 `word'
256      A sequence of characters treated as a unit by the shell.  Words
257      may not include unquoted `metacharacters'.
258
259 \1f
260 File: bashref.info,  Node: Basic Shell Features,  Next: Shell Builtin Commands,  Prev: Definitions,  Up: Top
261
262 3 Basic Shell Features
263 **********************
264
265 Bash is an acronym for `Bourne-Again SHell'.  The Bourne shell is the
266 traditional Unix shell originally written by Stephen Bourne.  All of
267 the Bourne shell builtin commands are available in Bash, The rules for
268 evaluation and quoting are taken from the POSIX specification for the
269 `standard' Unix shell.
270
271    This chapter briefly summarizes the shell's `building blocks':
272 commands, control structures, shell functions, shell parameters, shell
273 expansions, redirections, which are a way to direct input and output
274 from and to named files, and how the shell executes commands.
275
276 * Menu:
277
278 * Shell Syntax::                What your input means to the shell.
279 * Shell Commands::              The types of commands you can use.
280 * Shell Functions::             Grouping commands by name.
281 * Shell Parameters::            How the shell stores values.
282 * Shell Expansions::            How Bash expands parameters and the various
283                                 expansions available.
284 * Redirections::                A way to control where input and output go.
285 * Executing Commands::          What happens when you run a command.
286 * Shell Scripts::               Executing files of shell commands.
287
288 \1f
289 File: bashref.info,  Node: Shell Syntax,  Next: Shell Commands,  Up: Basic Shell Features
290
291 3.1 Shell Syntax
292 ================
293
294 * Menu:
295
296 * Shell Operation::     The basic operation of the shell.
297 * Quoting::             How to remove the special meaning from characters.
298 * Comments::            How to specify comments.
299
300    When the shell reads input, it proceeds through a sequence of
301 operations.  If the input indicates the beginning of a comment, the
302 shell ignores the comment symbol (`#'), and the rest of that line.
303
304    Otherwise, roughly speaking,  the shell reads its input and divides
305 the input into words and operators, employing the quoting rules to
306 select which meanings to assign various words and characters.
307
308    The shell then parses these tokens into commands and other
309 constructs, removes the special meaning of certain words or characters,
310 expands others, redirects input and output as needed, executes the
311 specified command, waits for the command's exit status, and makes that
312 exit status available for further inspection or processing.
313
314 \1f
315 File: bashref.info,  Node: Shell Operation,  Next: Quoting,  Up: Shell Syntax
316
317 3.1.1 Shell Operation
318 ---------------------
319
320 The following is a brief description of the shell's operation when it
321 reads and executes a command.  Basically, the shell does the following:
322
323   1. Reads its input from a file (*note Shell Scripts::), from a string
324      supplied as an argument to the `-c' invocation option (*note
325      Invoking Bash::), or from the user's terminal.
326
327   2. Breaks the input into words and operators, obeying the quoting
328      rules described in *note Quoting::.  These tokens are separated by
329      `metacharacters'.  Alias expansion is performed by this step
330      (*note Aliases::).
331
332   3. Parses the tokens into simple and compound commands (*note Shell
333      Commands::).
334
335   4. Performs the various shell expansions (*note Shell Expansions::),
336      breaking the expanded tokens into lists of filenames (*note
337      Filename Expansion::) and commands and arguments.
338
339   5. Performs any necessary redirections (*note Redirections::) and
340      removes the redirection operators and their operands from the
341      argument list.
342
343   6. Executes the command (*note Executing Commands::).
344
345   7. Optionally waits for the command to complete and collects its exit
346      status (*note Exit Status::).
347
348
349 \1f
350 File: bashref.info,  Node: Quoting,  Next: Comments,  Prev: Shell Operation,  Up: Shell Syntax
351
352 3.1.2 Quoting
353 -------------
354
355 * Menu:
356
357 * Escape Character::    How to remove the special meaning from a single
358                         character.
359 * Single Quotes::       How to inhibit all interpretation of a sequence
360                         of characters.
361 * Double Quotes::       How to suppress most of the interpretation of a
362                         sequence of characters.
363 * ANSI-C Quoting::      How to expand ANSI-C sequences in quoted strings.
364 * Locale Translation::  How to translate strings into different languages.
365
366    Quoting is used to remove the special meaning of certain characters
367 or words to the shell.  Quoting can be used to disable special
368 treatment for special characters, to prevent reserved words from being
369 recognized as such, and to prevent parameter expansion.
370
371    Each of the shell metacharacters (*note Definitions::) has special
372 meaning to the shell and must be quoted if it is to represent itself.
373 When the command history expansion facilities are being used (*note
374 History Interaction::), the HISTORY EXPANSION character, usually `!',
375 must be quoted to prevent history expansion.  *Note Bash History
376 Facilities::, for more details concerning history expansion.
377
378    There are three quoting mechanisms: the ESCAPE CHARACTER, single
379 quotes, and double quotes.
380
381 \1f
382 File: bashref.info,  Node: Escape Character,  Next: Single Quotes,  Up: Quoting
383
384 3.1.2.1 Escape Character
385 ........................
386
387 A non-quoted backslash `\' is the Bash escape character.  It preserves
388 the literal value of the next character that follows, with the
389 exception of `newline'.  If a `\newline' pair appears, and the
390 backslash itself is not quoted, the `\newline' is treated as a line
391 continuation (that is, it is removed from the input stream and
392 effectively ignored).
393
394 \1f
395 File: bashref.info,  Node: Single Quotes,  Next: Double Quotes,  Prev: Escape Character,  Up: Quoting
396
397 3.1.2.2 Single Quotes
398 .....................
399
400 Enclosing characters in single quotes (`'') preserves the literal value
401 of each character within the quotes.  A single quote may not occur
402 between single quotes, even when preceded by a backslash.
403
404 \1f
405 File: bashref.info,  Node: Double Quotes,  Next: ANSI-C Quoting,  Prev: Single Quotes,  Up: Quoting
406
407 3.1.2.3 Double Quotes
408 .....................
409
410 Enclosing characters in double quotes (`"') preserves the literal value
411 of all characters within the quotes, with the exception of `$', ``',
412 `\', and, when history expansion is enabled, `!'.  The characters `$'
413 and ``' retain their special meaning within double quotes (*note Shell
414 Expansions::).  The backslash retains its special meaning only when
415 followed by one of the following characters: `$', ``', `"', `\', or
416 `newline'.  Within double quotes, backslashes that are followed by one
417 of these characters are removed.  Backslashes preceding characters
418 without a special meaning are left unmodified.  A double quote may be
419 quoted within double quotes by preceding it with a backslash.  If
420 enabled, history expansion will be performed unless an `!' appearing in
421 double quotes is escaped using a backslash.  The backslash preceding
422 the `!' is not removed.
423
424    The special parameters `*' and `@' have special meaning when in
425 double quotes (*note Shell Parameter Expansion::).
426
427 \1f
428 File: bashref.info,  Node: ANSI-C Quoting,  Next: Locale Translation,  Prev: Double Quotes,  Up: Quoting
429
430 3.1.2.4 ANSI-C Quoting
431 ......................
432
433 Words of the form `$'STRING'' are treated specially.  The word expands
434 to STRING, with backslash-escaped characters replaced as specified by
435 the ANSI C standard.  Backslash escape sequences, if present, are
436 decoded as follows:
437
438 `\a'
439      alert (bell)
440
441 `\b'
442      backspace
443
444 `\e'
445 `\E'
446      an escape character (not ANSI C)
447
448 `\f'
449      form feed
450
451 `\n'
452      newline
453
454 `\r'
455      carriage return
456
457 `\t'
458      horizontal tab
459
460 `\v'
461      vertical tab
462
463 `\\'
464      backslash
465
466 `\''
467      single quote
468
469 `\"'
470      double quote
471
472 `\NNN'
473      the eight-bit character whose value is the octal value NNN (one to
474      three digits)
475
476 `\xHH'
477      the eight-bit character whose value is the hexadecimal value HH
478      (one or two hex digits)
479
480 `\cX'
481      a control-X character
482
483 The expanded result is single-quoted, as if the dollar sign had not
484 been present.
485
486 \1f
487 File: bashref.info,  Node: Locale Translation,  Prev: ANSI-C Quoting,  Up: Quoting
488
489 3.1.2.5 Locale-Specific Translation
490 ...................................
491
492 A double-quoted string preceded by a dollar sign (`$') will cause the
493 string to be translated according to the current locale.  If the
494 current locale is `C' or `POSIX', the dollar sign is ignored.  If the
495 string is translated and replaced, the replacement is double-quoted.
496
497    Some systems use the message catalog selected by the `LC_MESSAGES'
498 shell variable.  Others create the name of the message catalog from the
499 value of the `TEXTDOMAIN' shell variable, possibly adding a suffix of
500 `.mo'.  If you use the `TEXTDOMAIN' variable, you may need to set the
501 `TEXTDOMAINDIR' variable to the location of the message catalog files.
502 Still others use both variables in this fashion:
503 `TEXTDOMAINDIR'/`LC_MESSAGES'/LC_MESSAGES/`TEXTDOMAIN'.mo.
504
505 \1f
506 File: bashref.info,  Node: Comments,  Prev: Quoting,  Up: Shell Syntax
507
508 3.1.3 Comments
509 --------------
510
511 In a non-interactive shell, or an interactive shell in which the
512 `interactive_comments' option to the `shopt' builtin is enabled (*note
513 The Shopt Builtin::), a word beginning with `#' causes that word and
514 all remaining characters on that line to be ignored.  An interactive
515 shell without the `interactive_comments' option enabled does not allow
516 comments.  The `interactive_comments' option is on by default in
517 interactive shells.  *Note Interactive Shells::, for a description of
518 what makes a shell interactive.
519
520 \1f
521 File: bashref.info,  Node: Shell Commands,  Next: Shell Functions,  Prev: Shell Syntax,  Up: Basic Shell Features
522
523 3.2 Shell Commands
524 ==================
525
526 A simple shell command such as `echo a b c' consists of the command
527 itself followed by arguments, separated by spaces.
528
529    More complex shell commands are composed of simple commands arranged
530 together in a variety of ways: in a pipeline in which the output of one
531 command becomes the input of a second, in a loop or conditional
532 construct, or in some other grouping.
533
534 * Menu:
535
536 * Simple Commands::             The most common type of command.
537 * Pipelines::                   Connecting the input and output of several
538                                 commands.
539 * Lists::                       How to execute commands sequentially.
540 * Compound Commands::           Shell commands for control flow.
541 * Coprocesses::                 Two-way communication between commands.
542
543 \1f
544 File: bashref.info,  Node: Simple Commands,  Next: Pipelines,  Up: Shell Commands
545
546 3.2.1 Simple Commands
547 ---------------------
548
549 A simple command is the kind of command encountered most often.  It's
550 just a sequence of words separated by `blank's, terminated by one of
551 the shell's control operators (*note Definitions::).  The first word
552 generally specifies a command to be executed, with the rest of the
553 words being that command's arguments.
554
555    The return status (*note Exit Status::) of a simple command is its
556 exit status as provided by the POSIX 1003.1 `waitpid' function, or
557 128+N if the command was terminated by signal N.
558
559 \1f
560 File: bashref.info,  Node: Pipelines,  Next: Lists,  Prev: Simple Commands,  Up: Shell Commands
561
562 3.2.2 Pipelines
563 ---------------
564
565 A `pipeline' is a sequence of simple commands separated by one of the
566 control operators `|' or `|&'.
567
568    The format for a pipeline is
569      [`time' [`-p']] [`!'] COMMAND1 [ [`|' or `|&'] COMMAND2 ...]
570
571 The output of each command in the pipeline is connected via a pipe to
572 the input of the next command.  That is, each command reads the
573 previous command's output.  This connection is performed before any
574 redirections specified by the command.
575
576    If `|&' is used, the standard error of COMMAND1 is connected to
577 COMMAND2's standard input through the pipe; it is shorthand for `2>&1
578 |'.  This implicit redirection of the standard error is performed after
579 any redirections specified by the command.
580
581    The reserved word `time' causes timing statistics to be printed for
582 the pipeline once it finishes.  The statistics currently consist of
583 elapsed (wall-clock) time and user and system time consumed by the
584 command's execution.  The `-p' option changes the output format to that
585 specified by POSIX.  The `TIMEFORMAT' variable may be set to a format
586 string that specifies how the timing information should be displayed.
587 *Note Bash Variables::, for a description of the available formats.
588 The use of `time' as a reserved word permits the timing of shell
589 builtins, shell functions, and pipelines.  An external `time' command
590 cannot time these easily.
591
592    If the pipeline is not executed asynchronously (*note Lists::), the
593 shell waits for all commands in the pipeline to complete.
594
595    Each command in a pipeline is executed in its own subshell (*note
596 Command Execution Environment::).  The exit status of a pipeline is the
597 exit status of the last command in the pipeline, unless the `pipefail'
598 option is enabled (*note The Set Builtin::).  If `pipefail' is enabled,
599 the pipeline's return status is the value of the last (rightmost)
600 command to exit with a non-zero status, or zero if all commands exit
601 successfully.  If the reserved word `!' precedes the pipeline, the exit
602 status is the logical negation of the exit status as described above.
603 The shell waits for all commands in the pipeline to terminate before
604 returning a value.
605
606 \1f
607 File: bashref.info,  Node: Lists,  Next: Compound Commands,  Prev: Pipelines,  Up: Shell Commands
608
609 3.2.3 Lists of Commands
610 -----------------------
611
612 A `list' is a sequence of one or more pipelines separated by one of the
613 operators `;', `&', `&&', or `||', and optionally terminated by one of
614 `;', `&', or a `newline'.
615
616    Of these list operators, `&&' and `||' have equal precedence,
617 followed by `;' and `&', which have equal precedence.
618
619    A sequence of one or more newlines may appear in a `list' to delimit
620 commands, equivalent to a semicolon.
621
622    If a command is terminated by the control operator `&', the shell
623 executes the command asynchronously in a subshell.  This is known as
624 executing the command in the BACKGROUND.  The shell does not wait for
625 the command to finish, and the return status is 0 (true).  When job
626 control is not active (*note Job Control::), the standard input for
627 asynchronous commands, in the absence of any explicit redirections, is
628 redirected from `/dev/null'.
629
630    Commands separated by a `;' are executed sequentially; the shell
631 waits for each command to terminate in turn.  The return status is the
632 exit status of the last command executed.
633
634    AND and OR lists are sequences of one or more pipelines separated by
635 the control operators `&&' and `||', respectively.  AND and OR lists
636 are executed with left associativity.
637
638    An AND list has the form
639      COMMAND1 && COMMAND2
640
641 COMMAND2 is executed if, and only if, COMMAND1 returns an exit status
642 of zero.
643
644    An OR list has the form
645      COMMAND1 || COMMAND2
646
647 COMMAND2 is executed if, and only if, COMMAND1 returns a non-zero exit
648 status.
649
650    The return status of AND and OR lists is the exit status of the last
651 command executed in the list.
652
653 \1f
654 File: bashref.info,  Node: Compound Commands,  Next: Coprocesses,  Prev: Lists,  Up: Shell Commands
655
656 3.2.4 Compound Commands
657 -----------------------
658
659 * Menu:
660
661 * Looping Constructs::          Shell commands for iterative action.
662 * Conditional Constructs::      Shell commands for conditional execution.
663 * Command Grouping::            Ways to group commands.
664
665    Compound commands are the shell programming constructs.  Each
666 construct begins with a reserved word or control operator and is
667 terminated by a corresponding reserved word or operator.  Any
668 redirections (*note Redirections::) associated with a compound command
669 apply to all commands within that compound command unless explicitly
670 overridden.
671
672    Bash provides looping constructs, conditional commands, and
673 mechanisms to group commands and execute them as a unit.
674
675 \1f
676 File: bashref.info,  Node: Looping Constructs,  Next: Conditional Constructs,  Up: Compound Commands
677
678 3.2.4.1 Looping Constructs
679 ..........................
680
681 Bash supports the following looping constructs.
682
683    Note that wherever a `;' appears in the description of a command's
684 syntax, it may be replaced with one or more newlines.
685
686 `until'
687      The syntax of the `until' command is:
688           until TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
689      Execute CONSEQUENT-COMMANDS as long as TEST-COMMANDS has an exit
690      status which is not zero.  The return status is the exit status of
691      the last command executed in CONSEQUENT-COMMANDS, or zero if none
692      was executed.
693
694 `while'
695      The syntax of the `while' command is:
696           while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
697
698      Execute CONSEQUENT-COMMANDS as long as TEST-COMMANDS has an exit
699      status of zero.  The return status is the exit status of the last
700      command executed in CONSEQUENT-COMMANDS, or zero if none was
701      executed.
702
703 `for'
704      The syntax of the `for' command is:
705
706           for NAME [ [in [WORDS ...] ] ; ] do COMMANDS; done
707      Expand WORDS, and execute COMMANDS once for each member in the
708      resultant list, with NAME bound to the current member.  If `in
709      WORDS' is not present, the `for' command executes the COMMANDS
710      once for each positional parameter that is set, as if `in "$@"'
711      had been specified (*note Special Parameters::).  The return
712      status is the exit status of the last command that executes.  If
713      there are no items in the expansion of WORDS, no commands are
714      executed, and the return status is zero.
715
716      An alternate form of the `for' command is also supported:
717
718           for (( EXPR1 ; EXPR2 ; EXPR3 )) ; do COMMANDS ; done
719      First, the arithmetic expression EXPR1 is evaluated according to
720      the rules described below (*note Shell Arithmetic::).  The
721      arithmetic expression EXPR2 is then evaluated repeatedly until it
722      evaluates to zero.  Each time EXPR2 evaluates to a non-zero value,
723      COMMANDS are executed and the arithmetic expression EXPR3 is
724      evaluated.  If any expression is omitted, it behaves as if it
725      evaluates to 1.  The return value is the exit status of the last
726      command in LIST that is executed, or false if any of the
727      expressions is invalid.
728
729
730    The `break' and `continue' builtins (*note Bourne Shell Builtins::)
731 may be used to control loop execution.
732
733 \1f
734 File: bashref.info,  Node: Conditional Constructs,  Next: Command Grouping,  Prev: Looping Constructs,  Up: Compound Commands
735
736 3.2.4.2 Conditional Constructs
737 ..............................
738
739 `if'
740      The syntax of the `if' command is:
741
742           if TEST-COMMANDS; then
743             CONSEQUENT-COMMANDS;
744           [elif MORE-TEST-COMMANDS; then
745             MORE-CONSEQUENTS;]
746           [else ALTERNATE-CONSEQUENTS;]
747           fi
748
749      The TEST-COMMANDS list is executed, and if its return status is
750      zero, the CONSEQUENT-COMMANDS list is executed.  If TEST-COMMANDS
751      returns a non-zero status, each `elif' list is executed in turn,
752      and if its exit status is zero, the corresponding MORE-CONSEQUENTS
753      is executed and the command completes.  If `else
754      ALTERNATE-CONSEQUENTS' is present, and the final command in the
755      final `if' or `elif' clause has a non-zero exit status, then
756      ALTERNATE-CONSEQUENTS is executed.  The return status is the exit
757      status of the last command executed, or zero if no condition
758      tested true.
759
760 `case'
761      The syntax of the `case' command is:
762
763           `case WORD in [ [(] PATTERN [| PATTERN]...) COMMAND-LIST ;;]... esac'
764
765      `case' will selectively execute the COMMAND-LIST corresponding to
766      the first PATTERN that matches WORD.  If the shell option
767      `nocasematch' (see the description of `shopt' in *note The Shopt
768      Builtin::) is enabled, the match is performed without regard to
769      the case of alphabetic characters.  The `|' is used to separate
770      multiple patterns, and the `)' operator terminates a pattern list.
771      A list of patterns and an associated command-list is known as a
772      CLAUSE.
773
774      Each clause must be terminated with `;;', `;&', or `;;&'.  The
775      WORD 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 `;;', `;&', or `;;&'.  The first pattern that matches
783      determines the 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      If the `;;' operator is used, no subsequent matches are attempted
799      after the first pattern match.  Using `;&'  in place of `;;'
800      causes execution to continue with the COMMAND-LIST associated with
801      the next clause, if any.  Using `;;&' in place of `;;' causes the
802      shell to test the patterns in the next clause, if any, and execute
803      any associated COMMAND-LIST on a successful match.
804
805      The return status is zero if no PATTERN is matched.  Otherwise, the
806      return status is the exit status of the COMMAND-LIST executed.
807
808 `select'
809      The `select' construct allows the easy generation of menus.  It
810      has almost the same syntax as the `for' command:
811
812           select NAME [in WORDS ...]; do COMMANDS; done
813
814      The list of words following `in' is expanded, generating a list of
815      items.  The set of expanded words is printed on the standard error
816      output stream, each preceded by a number.  If the `in WORDS' is
817      omitted, the positional parameters are printed, as if `in "$@"'
818      had been specified.  The `PS3' prompt is then displayed and a line
819      is read from the standard input.  If the line consists of a number
820      corresponding to one of the displayed words, then the value of
821      NAME is set to that word.  If the line is empty, the words and
822      prompt are displayed again.  If `EOF' is read, the `select'
823      command completes.  Any other value read causes NAME to be set to
824      null.  The line read is saved in the variable `REPLY'.
825
826      The COMMANDS are executed after each selection until a `break'
827      command is executed, at which point the `select' command completes.
828
829      Here is an example that allows the user to pick a filename from the
830      current directory, and displays the name and index of the file
831      selected.
832
833           select fname in *;
834           do
835                 echo you picked $fname \($REPLY\)
836                 break;
837           done
838
839 `((...))'
840           (( EXPRESSION ))
841
842      The arithmetic EXPRESSION is evaluated according to the rules
843      described below (*note Shell Arithmetic::).  If the value of the
844      expression is non-zero, the return status is 0; otherwise the
845      return status is 1.  This is exactly equivalent to
846           let "EXPRESSION"
847      *Note Bash Builtins::, for a full description of the `let' builtin.
848
849 `[[...]]'
850           [[ EXPRESSION ]]
851
852      Return a status of 0 or 1 depending on the evaluation of the
853      conditional expression EXPRESSION.  Expressions are composed of
854      the primaries described below in *note Bash Conditional
855      Expressions::.  Word splitting and filename expansion are not
856      performed on the words between the `[[' and `]]'; tilde expansion,
857      parameter and variable expansion, arithmetic expansion, command
858      substitution, process substitution, and quote removal are
859      performed.  Conditional operators such as `-f' must be unquoted to
860      be recognized as primaries.
861
862      When used with `[[', The `<' and `>' operators sort
863      lexicographically using the current locale.
864
865      When the `==' and `!=' operators are used, the string to the right
866      of the operator is considered a pattern and matched according to
867      the rules described below in *note Pattern Matching::.  If the
868      shell option `nocasematch' (see the description of `shopt' in
869      *note The Shopt Builtin::) is enabled, the match is performed
870      without regard to the case of alphabetic characters.  The return
871      value is 0 if the string matches (`==') or does not match
872      (`!=')the pattern, and 1 otherwise.  Any part of the pattern may
873      be quoted to force it to be matched as a string.
874
875      An additional binary operator, `=~', is available, with the same
876      precedence as `==' and `!='.  When it is used, the string to the
877      right of the operator is considered an extended regular expression
878      and matched accordingly (as in regex3)).  The return value is 0 if
879      the string matches the pattern, and 1 otherwise.  If the regular
880      expression is syntactically incorrect, the conditional
881      expression's return value is 2.  If the shell option `nocasematch'
882      (see the description of `shopt' in *note The Shopt Builtin::) is
883      enabled, the match is performed without regard to the case of
884      alphabetic characters.  Any part of the pattern may be quoted to
885      force it to be matched as a string.  Substrings matched by
886      parenthesized subexpressions within the regular expression are
887      saved in the array variable `BASH_REMATCH'.  The element of
888      `BASH_REMATCH' with index 0 is the portion of the string matching
889      the entire regular expression.  The element of `BASH_REMATCH' with
890      index N is the portion of the string matching the Nth
891      parenthesized subexpression.
892
893      Expressions may be combined using the following operators, listed
894      in decreasing order of precedence:
895
896     `( EXPRESSION )'
897           Returns the value of EXPRESSION.  This may be used to
898           override the normal precedence of operators.
899
900     `! EXPRESSION'
901           True if EXPRESSION is false.
902
903     `EXPRESSION1 && EXPRESSION2'
904           True if both EXPRESSION1 and EXPRESSION2 are true.
905
906     `EXPRESSION1 || EXPRESSION2'
907           True if either EXPRESSION1 or EXPRESSION2 is true.
908      The `&&' and `||' operators do not evaluate EXPRESSION2 if the
909      value of EXPRESSION1 is sufficient to determine the return value
910      of the entire conditional expression.
911
912
913 \1f
914 File: bashref.info,  Node: Command Grouping,  Prev: Conditional Constructs,  Up: Compound Commands
915
916 3.2.4.3 Grouping Commands
917 .........................
918
919 Bash provides two ways to group a list of commands to be executed as a
920 unit.  When commands are grouped, redirections may be applied to the
921 entire command list.  For example, the output of all the commands in
922 the list may be redirected to a single stream.
923
924 `()'
925           ( LIST )
926
927      Placing a list of commands between parentheses causes a subshell
928      environment to be created (*note Command Execution Environment::),
929      and each of the commands in LIST to be executed in that subshell.
930      Since the LIST is executed in a subshell, variable assignments do
931      not remain in effect after the subshell completes.
932
933 `{}'
934           { LIST; }
935
936      Placing a list of commands between curly braces causes the list to
937      be executed in the current shell context.  No subshell is created.
938      The semicolon (or newline) following LIST is required.
939
940    In addition to the creation of a subshell, there is a subtle
941 difference between these two constructs due to historical reasons.  The
942 braces are `reserved words', so they must be separated from the LIST by
943 `blank's or other shell metacharacters.  The parentheses are
944 `operators', and are recognized as separate tokens by the shell even if
945 they are not separated from the LIST by whitespace.
946
947    The exit status of both of these constructs is the exit status of
948 LIST.
949
950 \1f
951 File: bashref.info,  Node: Coprocesses,  Prev: Compound Commands,  Up: Shell Commands
952
953 3.2.5 Coprocesses
954 -----------------
955
956 A `coprocess' is a shell command preceded by the `coproc' reserved word.
957 A coprocess is executed asynchronously in a subshell, as if the command
958 had been terminated with the `&' control operator, with a two-way pipe
959 established between the executing shell and the coprocess.
960
961    The format for a coprocess is:
962      `coproc' [NAME] COMMAND [REDIRECTIONS]
963
964 This creates a coprocess named NAME.  If NAME is not supplied, the
965 default name is COPROC.  NAME must not be supplied if COMMAND is a
966 simple command (*note Simple Commands::); otherwise, it is interpreted
967 as the first word of the simple command.
968
969    When the coproc is executed, the shell creates an array variable
970 (*note Arrays::) named NAME in the context of the executing shell.  The
971 standard output of COMMAND is connected via a pipe to a file descriptor
972 in the executing shell, and that file descriptor is assigned to NAME[0].
973 The standard input of COMMAND is connected via a pipe to a file
974 descriptor in the executing shell, and that file descriptor is assigned
975 to NAME[1].  This pipe is established before any redirections specified
976 by the command (*note Redirections::).  The file descriptors can be
977 utilized as arguments to shell commands and redirections using standard
978 word expansions.
979
980    The process id of the shell spawned to execute the coprocess is
981 available as the value of the variable NAME_PID.  The `wait' builtin
982 command may be used to wait for the coprocess to terminate.
983
984    The return status of a coprocess is the exit status of COMMAND.
985
986 \1f
987 File: bashref.info,  Node: Shell Functions,  Next: Shell Parameters,  Prev: Shell Commands,  Up: Basic Shell Features
988
989 3.3 Shell Functions
990 ===================
991
992 Shell functions are a way to group commands for later execution using a
993 single name for the group.  They are executed just like a "regular"
994 command.  When the name of a shell function is used as a simple command
995 name, the list of commands associated with that function name is
996 executed.  Shell functions are executed in the current shell context;
997 no new process is created to interpret them.
998
999    Functions are declared using this syntax: 
1000      [ `function' ] NAME () COMPOUND-COMMAND [ REDIRECTIONS ]
1001
1002    This defines a shell function named NAME.  The reserved word
1003 `function' is optional.  If the `function' reserved word is supplied,
1004 the parentheses are optional.  The BODY of the function is the compound
1005 command COMPOUND-COMMAND (*note Compound Commands::).  That command is
1006 usually a LIST enclosed between { and }, but may be any compound
1007 command listed above.  COMPOUND-COMMAND is executed whenever NAME is
1008 specified as the name of a command.  Any redirections (*note
1009 Redirections::) associated with the shell function are performed when
1010 the function is executed.
1011
1012    A function definition may be deleted using the `-f' option to the
1013 `unset' builtin (*note Bourne Shell Builtins::).
1014
1015    The exit status of a function definition is zero unless a syntax
1016 error occurs or a readonly function with the same name already exists.
1017 When executed, the exit status of a function is the exit status of the
1018 last command executed in the body.
1019
1020    Note that for historical reasons, in the most common usage the curly
1021 braces that surround the body of the function must be separated from
1022 the body by `blank's or newlines.  This is because the braces are
1023 reserved words and are only recognized as such when they are separated
1024 from the command list by whitespace or another shell metacharacter.
1025 Also, when using the braces, the LIST must be terminated by a semicolon,
1026 a `&', or a newline.
1027
1028    When a function is executed, the arguments to the function become
1029 the positional parameters during its execution (*note Positional
1030 Parameters::).  The special parameter `#' that expands to the number of
1031 positional parameters is updated to reflect the change.  Special
1032 parameter `0' is unchanged.  The first element of the `FUNCNAME'
1033 variable is set to the name of the function while the function is
1034 executing.
1035
1036    All other aspects of the shell execution environment are identical
1037 between a function and its caller with these exceptions: the `DEBUG'
1038 and `RETURN' traps are not inherited unless the function has been given
1039 the `trace' attribute using the `declare' builtin or the `-o functrace'
1040 option has been enabled with the `set' builtin, (in which case all
1041 functions inherit the `DEBUG' and `RETURN' traps), and the `ERR' trap
1042 is not inherited unless the `-o errtrace' shell option has been enabled.
1043 *Note Bourne Shell Builtins::, for the description of the `trap'
1044 builtin.
1045
1046    If the builtin command `return' is executed in a function, the
1047 function completes and execution resumes with the next command after
1048 the function call.  Any command associated with the `RETURN' trap is
1049 executed before execution resumes.  When a function completes, the
1050 values of the positional parameters and the special parameter `#' are
1051 restored to the values they had prior to the function's execution.  If
1052 a numeric argument is given to `return', that is the function's return
1053 status; otherwise the function's return status is the exit status of
1054 the last command executed before the `return'.
1055
1056    Variables local to the function may be declared with the `local'
1057 builtin.  These variables are visible only to the function and the
1058 commands it invokes.
1059
1060    Function names and definitions may be listed with the `-f' option to
1061 the `declare' or `typeset' builtin commands (*note Bash Builtins::).
1062 The `-F' option to `declare' or `typeset' will list the function names
1063 only (and optionally the source file and line number, if the `extdebug'
1064 shell option is enabled).  Functions may be exported so that subshells
1065 automatically have them defined with the `-f' option to the `export'
1066 builtin (*note Bourne Shell Builtins::).  Note that shell functions and
1067 variables with the same name may result in multiple identically-named
1068 entries in the environment passed to the shell's children.  Care should
1069 be taken in cases where this may cause a problem.
1070
1071    Functions may be recursive.  No limit is placed on the number of
1072 recursive  calls.
1073
1074 \1f
1075 File: bashref.info,  Node: Shell Parameters,  Next: Shell Expansions,  Prev: Shell Functions,  Up: Basic Shell Features
1076
1077 3.4 Shell Parameters
1078 ====================
1079
1080 * Menu:
1081
1082 * Positional Parameters::       The shell's command-line arguments.
1083 * Special Parameters::          Parameters denoted by special characters.
1084
1085    A PARAMETER is an entity that stores values.  It can be a `name', a
1086 number, or one of the special characters listed below.  A VARIABLE is a
1087 parameter denoted by a `name'.  A variable has a VALUE and zero or more
1088 ATTRIBUTES.  Attributes are assigned using the `declare' builtin command
1089 (see the description of the `declare' builtin in *note Bash Builtins::).
1090
1091    A parameter is set if it has been assigned a value.  The null string
1092 is a valid value.  Once a variable is set, it may be unset only by using
1093 the `unset' builtin command.
1094
1095    A variable may be assigned to by a statement of the form
1096      NAME=[VALUE]
1097    If VALUE is not given, the variable is assigned the null string.  All
1098 VALUEs undergo tilde expansion, parameter and variable expansion,
1099 command substitution, arithmetic expansion, and quote removal (detailed
1100 below).  If the variable has its `integer' attribute set, then VALUE is
1101 evaluated as an arithmetic expression even if the `$((...))' expansion
1102 is not used (*note Arithmetic Expansion::).  Word splitting is not
1103 performed, with the exception of `"$@"' as explained below.  Filename
1104 expansion is not performed.  Assignment statements may also appear as
1105 arguments to the `alias', `declare', `typeset', `export', `readonly',
1106 and `local' builtin commands.
1107
1108    In the context where an assignment statement is assigning a value to
1109 a shell variable or array index (*note Arrays::), the `+=' operator can
1110 be used to append to or add to the variable's previous value.  When
1111 `+=' is applied to a variable for which the integer attribute has been
1112 set, VALUE is evaluated as an arithmetic expression and added to the
1113 variable's current value, which is also evaluated.  When `+=' is
1114 applied to an array variable using compound assignment (*note
1115 Arrays::), the variable's value is not unset (as it is when using `='),
1116 and new values are appended to the array beginning at one greater than
1117 the array's maximum index (for indexed arrays),  or added as additional
1118 key-value pairs in an associative array.  When applied to a
1119 string-valued variable, VALUE is expanded and appended to the
1120 variable's value.
1121
1122 \1f
1123 File: bashref.info,  Node: Positional Parameters,  Next: Special Parameters,  Up: Shell Parameters
1124
1125 3.4.1 Positional Parameters
1126 ---------------------------
1127
1128 A POSITIONAL PARAMETER is a parameter denoted by one or more digits,
1129 other than the single digit `0'.  Positional parameters are assigned
1130 from the shell's arguments when it is invoked, and may be reassigned
1131 using the `set' builtin command.  Positional parameter `N' may be
1132 referenced as `${N}', or as `$N' when `N' consists of a single digit.
1133 Positional parameters may not be assigned to with assignment statements.
1134 The `set' and `shift' builtins are used to set and unset them (*note
1135 Shell Builtin Commands::).  The positional parameters are temporarily
1136 replaced when a shell function is executed (*note Shell Functions::).
1137
1138    When a positional parameter consisting of more than a single digit
1139 is expanded, it must be enclosed in braces.
1140
1141 \1f
1142 File: bashref.info,  Node: Special Parameters,  Prev: Positional Parameters,  Up: Shell Parameters
1143
1144 3.4.2 Special Parameters
1145 ------------------------
1146
1147 The shell treats several parameters specially.  These parameters may
1148 only be referenced; assignment to them is not allowed.
1149
1150 `*'
1151      Expands to the positional parameters, starting from one.  When the
1152      expansion occurs within double quotes, it expands to a single word
1153      with the value of each parameter separated by the first character
1154      of the `IFS' special variable.  That is, `"$*"' is equivalent to
1155      `"$1C$2C..."', where C is the first character of the value of the
1156      `IFS' variable.  If `IFS' is unset, the parameters are separated
1157      by spaces.  If `IFS' is null, the parameters are joined without
1158      intervening separators.
1159
1160 `@'
1161      Expands to the positional parameters, starting from one.  When the
1162      expansion occurs within double quotes, each parameter expands to a
1163      separate word.  That is, `"$@"' is equivalent to `"$1" "$2" ...'.
1164      If the double-quoted expansion occurs within a word, the expansion
1165      of the first parameter is joined with the beginning part of the
1166      original word, and the expansion of the last parameter is joined
1167      with the last part of the original word.  When there are no
1168      positional parameters, `"$@"' and `$@' expand to nothing (i.e.,
1169      they are removed).
1170
1171 `#'
1172      Expands to the number of positional parameters in decimal.
1173
1174 `?'
1175      Expands to the exit status of the most recently executed foreground
1176      pipeline.
1177
1178 `-'
1179      (A hyphen.)  Expands to the current option flags as specified upon
1180      invocation, by the `set' builtin command, or those set by the
1181      shell itself (such as the `-i' option).
1182
1183 `$'
1184      Expands to the process ID of the shell.  In a `()' subshell, it
1185      expands to the process ID of the invoking shell, not the subshell.
1186
1187 `!'
1188      Expands to the process ID of the most recently executed background
1189      (asynchronous) command.
1190
1191 `0'
1192      Expands to the name of the shell or shell script.  This is set at
1193      shell initialization.  If Bash is invoked with a file of commands
1194      (*note Shell Scripts::), `$0' is set to the name of that file.  If
1195      Bash is started with the `-c' option (*note Invoking Bash::), then
1196      `$0' is set to the first argument after the string to be executed,
1197      if one is present.  Otherwise, it is set to the filename used to
1198      invoke Bash, as given by argument zero.
1199
1200 `_'
1201      (An underscore.)  At shell startup, set to the absolute pathname
1202      used to invoke the shell or shell script being executed as passed
1203      in the environment or argument list.  Subsequently, expands to the
1204      last argument to the previous command, after expansion.  Also set
1205      to the full pathname used to invoke each command executed and
1206      placed in the environment exported to that command.  When checking
1207      mail, this parameter holds the name of the mail file.
1208
1209 \1f
1210 File: bashref.info,  Node: Shell Expansions,  Next: Redirections,  Prev: Shell Parameters,  Up: Basic Shell Features
1211
1212 3.5 Shell Expansions
1213 ====================
1214
1215 Expansion is performed on the command line after it has been split into
1216 `token's.  There are seven kinds of expansion performed:
1217    * brace expansion
1218
1219    * tilde expansion
1220
1221    * parameter and variable expansion
1222
1223    * command substitution
1224
1225    * arithmetic expansion
1226
1227    * word splitting
1228
1229    * filename expansion
1230
1231 * Menu:
1232
1233 * Brace Expansion::             Expansion of expressions within braces.
1234 * Tilde Expansion::             Expansion of the ~ character.
1235 * Shell Parameter Expansion::   How Bash expands variables to their values.
1236 * Command Substitution::        Using the output of a command as an argument.
1237 * Arithmetic Expansion::        How to use arithmetic in shell expansions.
1238 * Process Substitution::        A way to write and read to and from a
1239                                 command.
1240 * Word Splitting::      How the results of expansion are split into separate
1241                         arguments.
1242 * Filename Expansion::  A shorthand for specifying filenames matching patterns.
1243 * Quote Removal::       How and when quote characters are removed from
1244                         words.
1245
1246    The order of expansions is: brace expansion, tilde expansion,
1247 parameter, variable, and arithmetic expansion and command substitution
1248 (done in a left-to-right fashion), word splitting, and filename
1249 expansion.
1250
1251    On systems that can support it, there is an additional expansion
1252 available: PROCESS SUBSTITUTION.  This is performed at the same time as
1253 parameter, variable, and arithmetic expansion and command substitution.
1254
1255    Only brace expansion, word splitting, and filename expansion can
1256 change the number of words of the expansion; other expansions expand a
1257 single word to a single word.  The only exceptions to this are the
1258 expansions of `"$@"' (*note Special Parameters::) and `"${NAME[@]}"'
1259 (*note Arrays::).
1260
1261    After all expansions, `quote removal' (*note Quote Removal::) is
1262 performed.
1263
1264 \1f
1265 File: bashref.info,  Node: Brace Expansion,  Next: Tilde Expansion,  Up: Shell Expansions
1266
1267 3.5.1 Brace Expansion
1268 ---------------------
1269
1270 Brace expansion is a mechanism by which arbitrary strings may be
1271 generated.  This mechanism is similar to FILENAME EXPANSION (*note
1272 Filename Expansion::), but the file names generated need not exist.
1273 Patterns to be brace expanded take the form of an optional PREAMBLE,
1274 followed by either a series of comma-separated strings or a seqeunce
1275 expression between a pair of braces, followed by an optional POSTSCRIPT.
1276 The preamble is prefixed to each string contained within the braces, and
1277 the postscript is then appended to each resulting string, expanding left
1278 to right.
1279
1280    Brace expansions may be nested.  The results of each expanded string
1281 are not sorted; left to right order is preserved.  For example,
1282      bash$ echo a{d,c,b}e
1283      ade ace abe
1284
1285    A sequence expression takes the form `{X..Y[..INCR]}', where X and Y
1286 are either integers or single characters, and INCR, an optional
1287 increment, is an integer.  When integers are supplied, the expression
1288 expands to each number between X and Y, inclusive.  Supplied integers
1289 may be prefixed with `0' to force each term to have the same width.
1290 When either X or Y begins with a zero, the shell attempts to force all
1291 generated terms to contain the same number of digits, zero-padding
1292 where necessary.  When characters are supplied, the expression expands
1293 to each character lexicographically between X and Y, inclusive.  Note
1294 that both X and Y must be of the same type.  When the increment is
1295 supplied, it is used as the difference between each term.  The default
1296 increment is 1 or -1 as appropriate.
1297
1298    Brace expansion is performed before any other expansions, and any
1299 characters special to other expansions are preserved in the result.  It
1300 is strictly textual.  Bash does not apply any syntactic interpretation
1301 to the context of the expansion or the text between the braces.  To
1302 avoid conflicts with parameter expansion, the string `${' is not
1303 considered eligible for brace expansion.
1304
1305    A correctly-formed brace expansion must contain unquoted opening and
1306 closing braces, and at least one unquoted comma or a valid sequence
1307 expression.  Any incorrectly formed brace expansion is left unchanged.
1308
1309    A { or `,' may be quoted with a backslash to prevent its being
1310 considered part of a brace expression.  To avoid conflicts with
1311 parameter expansion, the string `${' is not considered eligible for
1312 brace expansion.
1313
1314    This construct is typically used as shorthand when the common prefix
1315 of the strings to be generated is longer than in the above example:
1316      mkdir /usr/local/src/bash/{old,new,dist,bugs}
1317    or
1318      chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
1319
1320 \1f
1321 File: bashref.info,  Node: Tilde Expansion,  Next: Shell Parameter Expansion,  Prev: Brace Expansion,  Up: Shell Expansions
1322
1323 3.5.2 Tilde Expansion
1324 ---------------------
1325
1326 If a word begins with an unquoted tilde character (`~'), all of the
1327 characters up to the first unquoted slash (or all characters, if there
1328 is no unquoted slash) are considered a TILDE-PREFIX.  If none of the
1329 characters in the tilde-prefix are quoted, the characters in the
1330 tilde-prefix following the tilde are treated as a possible LOGIN NAME.
1331 If this login name is the null string, the tilde is replaced with the
1332 value of the `HOME' shell variable.  If `HOME' is unset, the home
1333 directory of the user executing the shell is substituted instead.
1334 Otherwise, the tilde-prefix is replaced with the home directory
1335 associated with the specified login name.
1336
1337    If the tilde-prefix is `~+', the value of the shell variable `PWD'
1338 replaces the tilde-prefix.  If the tilde-prefix is `~-', the value of
1339 the shell variable `OLDPWD', if it is set, is substituted.
1340
1341    If the characters following the tilde in the tilde-prefix consist of
1342 a number N, optionally prefixed by a `+' or a `-', the tilde-prefix is
1343 replaced with the corresponding element from the directory stack, as it
1344 would be displayed by the `dirs' builtin invoked with the characters
1345 following tilde in the tilde-prefix as an argument (*note The Directory
1346 Stack::).  If the tilde-prefix, sans the tilde, consists of a number
1347 without a leading `+' or `-', `+' is assumed.
1348
1349    If the login name is invalid, or the tilde expansion fails, the word
1350 is left unchanged.
1351
1352    Each variable assignment is checked for unquoted tilde-prefixes
1353 immediately following a `:' or the first `='.  In these cases, tilde
1354 expansion is also performed.  Consequently, one may use file names with
1355 tildes in assignments to `PATH', `MAILPATH', and `CDPATH', and the
1356 shell assigns the expanded value.
1357
1358    The following table shows how Bash treats unquoted tilde-prefixes:
1359
1360 `~'
1361      The value of `$HOME'
1362
1363 `~/foo'
1364      `$HOME/foo'
1365
1366 `~fred/foo'
1367      The subdirectory `foo' of the home directory of the user `fred'
1368
1369 `~+/foo'
1370      `$PWD/foo'
1371
1372 `~-/foo'
1373      `${OLDPWD-'~-'}/foo'
1374
1375 `~N'
1376      The string that would be displayed by `dirs +N'
1377
1378 `~+N'
1379      The string that would be displayed by `dirs +N'
1380
1381 `~-N'
1382      The string that would be displayed by `dirs -N'
1383
1384
1385 \1f
1386 File: bashref.info,  Node: Shell Parameter Expansion,  Next: Command Substitution,  Prev: Tilde Expansion,  Up: Shell Expansions
1387
1388 3.5.3 Shell Parameter Expansion
1389 -------------------------------
1390
1391 The `$' character introduces parameter expansion, command substitution,
1392 or arithmetic expansion.  The parameter name or symbol to be expanded
1393 may be enclosed in braces, which are optional but serve to protect the
1394 variable to be expanded from characters immediately following it which
1395 could be interpreted as part of the name.
1396
1397    When braces are used, the matching ending brace is the first `}' not
1398 escaped by a backslash or within a quoted string, and not within an
1399 embedded arithmetic expansion, command substitution, or parameter
1400 expansion.
1401
1402    The basic form of parameter expansion is ${PARAMETER}.  The value of
1403 PARAMETER is substituted.  The braces are required when PARAMETER is a
1404 positional parameter with more than one digit, or when PARAMETER is
1405 followed by a character that is not to be interpreted as part of its
1406 name.
1407
1408    If the first character of PARAMETER is an exclamation point (!), a
1409 level of variable indirection is introduced.  Bash uses the value of
1410 the variable formed from the rest of PARAMETER as the name of the
1411 variable; this variable is then expanded and that value is used in the
1412 rest of the substitution, rather than the value of PARAMETER itself.
1413 This is known as `indirect expansion'.  The exceptions to this are the
1414 expansions of ${!PREFIX*} and ${!NAME[@]} described below.  The
1415 exclamation point must immediately follow the left brace in order to
1416 introduce indirection.
1417
1418    In each of the cases below, WORD is subject to tilde expansion,
1419 parameter expansion, command substitution, and arithmetic expansion.
1420
1421    When not performing substring expansion, using the form described
1422 below, Bash tests for a parameter that is unset or null.  Omitting the
1423 colon results in a test only for a parameter that is unset.  Put
1424 another way, if the colon is included, the operator tests for both
1425 PARAMETER's existence and that its value is not null; if the colon is
1426 omitted, the operator tests only for existence.
1427
1428 `${PARAMETER:-WORD}'
1429      If PARAMETER is unset or null, the expansion of WORD is
1430      substituted.  Otherwise, the value of PARAMETER is substituted.
1431
1432 `${PARAMETER:=WORD}'
1433      If PARAMETER is unset or null, the expansion of WORD is assigned
1434      to PARAMETER.  The value of PARAMETER is then substituted.
1435      Positional parameters and special parameters may not be assigned to
1436      in this way.
1437
1438 `${PARAMETER:?WORD}'
1439      If PARAMETER is null or unset, the expansion of WORD (or a message
1440      to that effect if WORD is not present) is written to the standard
1441      error and the shell, if it is not interactive, exits.  Otherwise,
1442      the value of PARAMETER is substituted.
1443
1444 `${PARAMETER:+WORD}'
1445      If PARAMETER is null or unset, nothing is substituted, otherwise
1446      the expansion of WORD is substituted.
1447
1448 `${PARAMETER:OFFSET}'
1449 `${PARAMETER:OFFSET:LENGTH}'
1450      Expands to up to LENGTH characters of PARAMETER starting at the
1451      character specified by OFFSET.  If LENGTH is omitted, expands to
1452      the substring of PARAMETER starting at the character specified by
1453      OFFSET.  LENGTH and OFFSET are arithmetic expressions (*note Shell
1454      Arithmetic::).  This is referred to as Substring Expansion.
1455
1456      LENGTH must evaluate to a number greater than or equal to zero.
1457      If OFFSET evaluates to a number less than zero, the value is used
1458      as an offset from the end of the value of PARAMETER.  If PARAMETER
1459      is `@', the result is LENGTH positional parameters beginning at
1460      OFFSET.  If PARAMETER is an indexed array name subscripted by `@'
1461      or `*', the result is the LENGTH members of the array beginning
1462      with `${PARAMETER[OFFSET]}'.  A negative OFFSET is taken relative
1463      to one greater than the maximum index of the specified array.
1464      Substring expansion applied to an associative array produces
1465      undefined results.
1466
1467      Note that a negative offset must be separated from the colon by at
1468      least one space to avoid being confused with the `:-' expansion.
1469      Substring indexing is zero-based unless the positional parameters
1470      are used, in which case the indexing starts at 1 by default.  If
1471      OFFSET is 0, and the positional parameters are used, `$@' is
1472      prefixed to the list.
1473
1474 `${!PREFIX*}'
1475 `${!PREFIX@}'
1476      Expands to the names of variables whose names begin with PREFIX,
1477      separated by the first character of the `IFS' special variable.
1478      When `@' is used and the expansion appears within double quotes,
1479      each variable name expands to a separate word.
1480
1481 `${!NAME[@]}'
1482 `${!NAME[*]}'
1483      If NAME is an array variable, expands to the list of array indices
1484      (keys) assigned in NAME.  If NAME is not an array, expands to 0 if
1485      NAME is set and null otherwise.  When `@' is used and the
1486      expansion appears within double quotes, each key expands to a
1487      separate word.
1488
1489 `${#PARAMETER}'
1490      The length in characters of the expanded value of PARAMETER is
1491      substituted.  If PARAMETER is `*' or `@', the value substituted is
1492      the number of positional parameters.  If PARAMETER is an array
1493      name subscripted by `*' or `@', the value substituted is the
1494      number of elements in the array.
1495
1496 `${PARAMETER#WORD}'
1497 `${PARAMETER##WORD}'
1498      The WORD is expanded to produce a pattern just as in filename
1499      expansion (*note Filename Expansion::).  If the pattern matches
1500      the beginning of the expanded value of PARAMETER, then the result
1501      of the expansion is the expanded value of PARAMETER with the
1502      shortest matching pattern (the `#' case) or the longest matching
1503      pattern (the `##' case) deleted.  If PARAMETER is `@' or `*', the
1504      pattern removal operation is applied to each positional parameter
1505      in turn, and the expansion is the resultant list.  If PARAMETER is
1506      an array variable subscripted with `@' or `*', the pattern removal
1507      operation is applied to each member of the array in turn, and the
1508      expansion is the resultant list.
1509
1510 `${PARAMETER%WORD}'
1511 `${PARAMETER%%WORD}'
1512      The WORD is expanded to produce a pattern just as in filename
1513      expansion.  If the pattern matches a trailing portion of the
1514      expanded value of PARAMETER, then the result of the expansion is
1515      the value of PARAMETER with the shortest matching pattern (the `%'
1516      case) or the longest matching pattern (the `%%' case) deleted.  If
1517      PARAMETER is `@' or `*', the pattern removal operation is applied
1518      to each positional parameter in turn, and the expansion is the
1519      resultant list.  If PARAMETER is an array variable subscripted
1520      with `@' or `*', the pattern removal operation is applied to each
1521      member of the array in turn, and the expansion is the resultant
1522      list.
1523
1524 `${PARAMETER/PATTERN/STRING}'
1525      The PATTERN is expanded to produce a pattern just as in filename
1526      expansion.  PARAMETER is expanded and the longest match of PATTERN
1527      against its value is replaced with STRING.  If PATTERN begins with
1528      `/', all matches of PATTERN are replaced with STRING.  Normally
1529      only the first match is replaced.  If PATTERN begins with `#', it
1530      must match at the beginning of the expanded value of PARAMETER.
1531      If PATTERN begins with `%', it must match at the end of the
1532      expanded value of PARAMETER.  If STRING is null, matches of
1533      PATTERN are deleted and the `/' following PATTERN may be omitted.
1534      If PARAMETER is `@' or `*', the substitution operation is applied
1535      to each positional parameter in turn, and the expansion is the
1536      resultant list.  If PARAMETER is an array variable subscripted
1537      with `@' or `*', the substitution operation is applied to each
1538      member of the array in turn, and the expansion is the resultant
1539      list.
1540
1541 `${PARAMETER^PATTERN}'
1542 `${PARAMETER^^PATTERN}'
1543 `${PARAMETER,PATTERN}'
1544 `${PARAMETER,,PATTERN}'
1545      This expansion modifies the case of alphabetic characters in
1546      PARAMETER.  The PATTERN is expanded to produce a pattern just as in
1547      filename expansion.  The `^' operator converts lowercase letters
1548      matching PATTERN to uppercase; the `,' operator converts matching
1549      uppercase letters to lowercase.  The `^^' and `,,' expansions
1550      convert each matched character in the expanded value; the `^' and
1551      `,' expansions match and convert only the first character in the
1552      expanded value.  If PATTERN is omitted, it is treated like a `?',
1553      which matches every character.  If PARAMETER is `@' or `*', the
1554      case modification operation is applied to each positional
1555      parameter in turn, and the expansion is the resultant list.  If
1556      PARAMETER is an array variable subscripted with `@' or `*', the
1557      case modification operation is applied to each member of the array
1558      in turn, and the expansion is the resultant list.
1559
1560
1561 \1f
1562 File: bashref.info,  Node: Command Substitution,  Next: Arithmetic Expansion,  Prev: Shell Parameter Expansion,  Up: Shell Expansions
1563
1564 3.5.4 Command Substitution
1565 --------------------------
1566
1567 Command substitution allows the output of a command to replace the
1568 command itself.  Command substitution occurs when a command is enclosed
1569 as follows:
1570      $(COMMAND)
1571    or
1572      `COMMAND`
1573
1574 Bash performs the expansion by executing COMMAND and replacing the
1575 command substitution with the standard output of the command, with any
1576 trailing newlines deleted.  Embedded newlines are not deleted, but they
1577 may be removed during word splitting.  The command substitution `$(cat
1578 FILE)' can be replaced by the equivalent but faster `$(< FILE)'.
1579
1580    When the old-style backquote form of substitution is used, backslash
1581 retains its literal meaning except when followed by `$', ``', or `\'.
1582 The first backquote not preceded by a backslash terminates the command
1583 substitution.  When using the `$(COMMAND)' form, all characters between
1584 the parentheses make up the command; none are treated specially.
1585
1586    Command substitutions may be nested.  To nest when using the
1587 backquoted form, escape the inner backquotes with backslashes.
1588
1589    If the substitution appears within double quotes, word splitting and
1590 filename expansion are not performed on the results.
1591
1592 \1f
1593 File: bashref.info,  Node: Arithmetic Expansion,  Next: Process Substitution,  Prev: Command Substitution,  Up: Shell Expansions
1594
1595 3.5.5 Arithmetic Expansion
1596 --------------------------
1597
1598 Arithmetic expansion allows the evaluation of an arithmetic expression
1599 and the substitution of the result.  The format for arithmetic
1600 expansion is:
1601
1602      $(( EXPRESSION ))
1603
1604    The expression is treated as if it were within double quotes, but a
1605 double quote inside the parentheses is not treated specially.  All
1606 tokens in the expression undergo parameter expansion, command
1607 substitution, and quote removal.  Arithmetic expansions may be nested.
1608
1609    The evaluation is performed according to the rules listed below
1610 (*note Shell Arithmetic::).  If the expression is invalid, Bash prints
1611 a message indicating failure to the standard error and no substitution
1612 occurs.
1613
1614 \1f
1615 File: bashref.info,  Node: Process Substitution,  Next: Word Splitting,  Prev: Arithmetic Expansion,  Up: Shell Expansions
1616
1617 3.5.6 Process Substitution
1618 --------------------------
1619
1620 Process substitution is supported on systems that support named pipes
1621 (FIFOs) or the `/dev/fd' method of naming open files.  It takes the
1622 form of
1623      <(LIST)
1624    or
1625      >(LIST)
1626    The process LIST is run with its input or output connected to a FIFO
1627 or some file in `/dev/fd'.  The name of this file is passed as an
1628 argument to the current command as the result of the expansion.  If the
1629 `>(LIST)' form is used, writing to the file will provide input for
1630 LIST.  If the `<(LIST)' form is used, the file passed as an argument
1631 should be read to obtain the output of LIST.  Note that no space may
1632 appear between the `<' or `>' and the left parenthesis, otherwise the
1633 construct would be interpreted as a redirection.
1634
1635    When available, process substitution is performed simultaneously with
1636 parameter and variable expansion, command substitution, and arithmetic
1637 expansion.
1638
1639 \1f
1640 File: bashref.info,  Node: Word Splitting,  Next: Filename Expansion,  Prev: Process Substitution,  Up: Shell Expansions
1641
1642 3.5.7 Word Splitting
1643 --------------------
1644
1645 The shell scans the results of parameter expansion, command
1646 substitution, and arithmetic expansion that did not occur within double
1647 quotes for word splitting.
1648
1649    The shell treats each character of `$IFS' as a delimiter, and splits
1650 the results of the other expansions into words on these characters.  If
1651 `IFS' is unset, or its value is exactly `<space><tab><newline>', the
1652 default, then sequences of ` <space>', `<tab>', and `<newline>' at the
1653 beginning and end of the results of the previous expansions are
1654 ignored, and any sequence of `IFS' characters not at the beginning or
1655 end serves to delimit words.  If `IFS' has a value other than the
1656 default, then sequences of the whitespace characters `space' and `tab'
1657 are ignored at the beginning and end of the word, as long as the
1658 whitespace character is in the value of `IFS' (an `IFS' whitespace
1659 character).  Any character in `IFS' that is not `IFS' whitespace, along
1660 with any adjacent `IFS' whitespace characters, delimits a field.  A
1661 sequence of `IFS' whitespace characters is also treated as a delimiter.
1662 If the value of `IFS' is null, no word splitting occurs.
1663
1664    Explicit null arguments (`""' or `''') are retained.  Unquoted
1665 implicit null arguments, resulting from the expansion of parameters
1666 that have no values, are removed.  If a parameter with no value is
1667 expanded within double quotes, a null argument results and is retained.
1668
1669    Note that if no expansion occurs, no splitting is performed.
1670
1671 \1f
1672 File: bashref.info,  Node: Filename Expansion,  Next: Quote Removal,  Prev: Word Splitting,  Up: Shell Expansions
1673
1674 3.5.8 Filename Expansion
1675 ------------------------
1676
1677 * Menu:
1678
1679 * Pattern Matching::    How the shell matches patterns.
1680
1681    After word splitting, unless the `-f' option has been set (*note The
1682 Set Builtin::), Bash scans each word for the characters `*', `?', and
1683 `['.  If one of these characters appears, then the word is regarded as
1684 a PATTERN, and replaced with an alphabetically sorted list of file
1685 names matching the pattern. If no matching file names are found, and
1686 the shell option `nullglob' is disabled, the word is left unchanged.
1687 If the `nullglob' option is set, and no matches are found, the word is
1688 removed.  If the `failglob' shell option is set, and no matches are
1689 found, an error message is printed and the command is not executed.  If
1690 the shell option `nocaseglob' is enabled, the match is performed
1691 without regard to the case of alphabetic characters.
1692
1693    When a pattern is used for filename expansion, the character `.' at
1694 the start of a filename or immediately following a slash must be
1695 matched explicitly, unless the shell option `dotglob' is set.  When
1696 matching a file name, the slash character must always be matched
1697 explicitly.  In other cases, the `.' character is not treated specially.
1698
1699    See the description of `shopt' in *note The Shopt Builtin::, for a
1700 description of the `nocaseglob', `nullglob', `failglob', and `dotglob'
1701 options.
1702
1703    The `GLOBIGNORE' shell variable may be used to restrict the set of
1704 filenames matching a pattern.  If `GLOBIGNORE' is set, each matching
1705 filename that also matches one of the patterns in `GLOBIGNORE' is
1706 removed from the list of matches.  The filenames `.' and `..' are
1707 always ignored when `GLOBIGNORE' is set and not null.  However, setting
1708 `GLOBIGNORE' to a non-null value has the effect of enabling the
1709 `dotglob' shell option, so all other filenames beginning with a `.'
1710 will match.  To get the old behavior of ignoring filenames beginning
1711 with a `.', make `.*' one of the patterns in `GLOBIGNORE'.  The
1712 `dotglob' option is disabled when `GLOBIGNORE' is unset.
1713
1714 \1f
1715 File: bashref.info,  Node: Pattern Matching,  Up: Filename Expansion
1716
1717 3.5.8.1 Pattern Matching
1718 ........................
1719
1720 Any character that appears in a pattern, other than the special pattern
1721 characters described below, matches itself.  The NUL character may not
1722 occur in a pattern.  A backslash escapes the following character; the
1723 escaping backslash is discarded when matching.  The special pattern
1724 characters must be quoted if they are to be matched literally.
1725
1726    The special pattern characters have the following meanings:
1727 `*'
1728      Matches any string, including the null string.  When the
1729      `globstar' shell option is enabled, and `*' is used in a filename
1730      expansion context, two adjacent `*'s used as a single pattern will
1731      match all files and zero or more directories and subdirectories.
1732      If followed by a `/', two adjacent `*'s will match only
1733      directories and subdirectories.
1734
1735 `?'
1736      Matches any single character.
1737
1738 `[...]'
1739      Matches any one of the enclosed characters.  A pair of characters
1740      separated by a hyphen denotes a RANGE EXPRESSION; any character
1741      that sorts between those two characters, inclusive, using the
1742      current locale's collating sequence and character set, is matched.
1743      If the first character following the `[' is a `!'  or a `^' then
1744      any character not enclosed is matched.  A `-' may be matched by
1745      including it as the first or last character in the set.  A `]' may
1746      be matched by including it as the first character in the set.  The
1747      sorting order of characters in range expressions is determined by
1748      the current locale and the value of the `LC_COLLATE' shell
1749      variable, if set.
1750
1751      For example, in the default C locale, `[a-dx-z]' is equivalent to
1752      `[abcdxyz]'.  Many locales sort characters in dictionary order,
1753      and in these locales `[a-dx-z]' is typically not equivalent to
1754      `[abcdxyz]'; it might be equivalent to `[aBbCcDdxXyYz]', for
1755      example.  To obtain the traditional interpretation of ranges in
1756      bracket expressions, you can force the use of the C locale by
1757      setting the `LC_COLLATE' or `LC_ALL' environment variable to the
1758      value `C'.
1759
1760      Within `[' and `]', CHARACTER CLASSES can be specified using the
1761      syntax `[:'CLASS`:]', where CLASS is one of the following classes
1762      defined in the POSIX standard:
1763           alnum   alpha   ascii   blank   cntrl   digit   graph   lower
1764           print   punct   space   upper   word    xdigit
1765      A character class matches any character belonging to that class.
1766      The `word' character class matches letters, digits, and the
1767      character `_'.
1768
1769      Within `[' and `]', an EQUIVALENCE CLASS can be specified using
1770      the syntax `[='C`=]', which matches all characters with the same
1771      collation weight (as defined by the current locale) as the
1772      character C.
1773
1774      Within `[' and `]', the syntax `[.'SYMBOL`.]' matches the
1775      collating symbol SYMBOL.
1776
1777    If the `extglob' shell option is enabled using the `shopt' builtin,
1778 several extended pattern matching operators are recognized.  In the
1779 following description, a PATTERN-LIST is a list of one or more patterns
1780 separated by a `|'.  Composite patterns may be formed using one or more
1781 of the following sub-patterns:
1782
1783 `?(PATTERN-LIST)'
1784      Matches zero or one occurrence of the given patterns.
1785
1786 `*(PATTERN-LIST)'
1787      Matches zero or more occurrences of the given patterns.
1788
1789 `+(PATTERN-LIST)'
1790      Matches one or more occurrences of the given patterns.
1791
1792 `@(PATTERN-LIST)'
1793      Matches one of the given patterns.
1794
1795 `!(PATTERN-LIST)'
1796      Matches anything except one of the given patterns.
1797
1798 \1f
1799 File: bashref.info,  Node: Quote Removal,  Prev: Filename Expansion,  Up: Shell Expansions
1800
1801 3.5.9 Quote Removal
1802 -------------------
1803
1804 After the preceding expansions, all unquoted occurrences of the
1805 characters `\', `'', and `"' that did not result from one of the above
1806 expansions are removed.
1807
1808 \1f
1809 File: bashref.info,  Node: Redirections,  Next: Executing Commands,  Prev: Shell Expansions,  Up: Basic Shell Features
1810
1811 3.6 Redirections
1812 ================
1813
1814 Before a command is executed, its input and output may be REDIRECTED
1815 using a special notation interpreted by the shell.  Redirection may
1816 also be used to open and close files for the current shell execution
1817 environment.  The following redirection operators may precede or appear
1818 anywhere within a simple command or may follow a command.  Redirections
1819 are processed in the order they appear, from left to right.
1820
1821    Each redirection that may be preceded by a file descriptor number
1822 may instead be preceded by a word of the form {VARNAME}.  In this case,
1823 for each redirection operator except >&- and <&-, the shell will
1824 allocate a file descriptor greater than 10 and assign it to {VARNAME}.
1825 If >&- or <&- is preceded by {VARNAME}, the value of VARNAME defines
1826 the file descriptor to close.
1827
1828    In the following descriptions, if the file descriptor number is
1829 omitted, and the first character of the redirection operator is `<',
1830 the redirection refers to the standard input (file descriptor 0).  If
1831 the first character of the redirection operator is `>', the redirection
1832 refers to the standard output (file descriptor 1).
1833
1834    The word following the redirection operator in the following
1835 descriptions, unless otherwise noted, is subjected to brace expansion,
1836 tilde expansion, parameter expansion, command substitution, arithmetic
1837 expansion, quote removal, filename expansion, and word splitting.  If
1838 it expands to more than one word, Bash reports an error.
1839
1840    Note that the order of redirections is significant.  For example,
1841 the command
1842      ls > DIRLIST 2>&1
1843    directs both standard output (file descriptor 1) and standard error
1844 (file descriptor 2) to the file DIRLIST, while the command
1845      ls 2>&1 > DIRLIST
1846    directs only the standard output to file DIRLIST, because the
1847 standard error was made a copy of the standard output before the
1848 standard output was redirected to DIRLIST.
1849
1850    Bash handles several filenames specially when they are used in
1851 redirections, as described in the following table:
1852
1853 `/dev/fd/FD'
1854      If FD is a valid integer, file descriptor FD is duplicated.
1855
1856 `/dev/stdin'
1857      File descriptor 0 is duplicated.
1858
1859 `/dev/stdout'
1860      File descriptor 1 is duplicated.
1861
1862 `/dev/stderr'
1863      File descriptor 2 is duplicated.
1864
1865 `/dev/tcp/HOST/PORT'
1866      If HOST is a valid hostname or Internet address, and PORT is an
1867      integer port number or service name, Bash attempts to open a TCP
1868      connection to the corresponding socket.
1869
1870 `/dev/udp/HOST/PORT'
1871      If HOST is a valid hostname or Internet address, and PORT is an
1872      integer port number or service name, Bash attempts to open a UDP
1873      connection to the corresponding socket.
1874
1875
1876    A failure to open or create a file causes the redirection to fail.
1877
1878    Redirections using file descriptors greater than 9 should be used
1879 with care, as they may conflict with file descriptors the shell uses
1880 internally.
1881
1882 3.6.1 Redirecting Input
1883 -----------------------
1884
1885 Redirection of input causes the file whose name results from the
1886 expansion of WORD to be opened for reading on file descriptor `n', or
1887 the standard input (file descriptor 0) if `n' is not specified.
1888
1889    The general format for redirecting input is:
1890      [N]<WORD
1891
1892 3.6.2 Redirecting Output
1893 ------------------------
1894
1895 Redirection of output causes the file whose name results from the
1896 expansion of WORD to be opened for writing on file descriptor N, or the
1897 standard output (file descriptor 1) if N is not specified.  If the file
1898 does not exist it is created; if it does exist it is truncated to zero
1899 size.
1900
1901    The general format for redirecting output is:
1902      [N]>[|]WORD
1903
1904    If the redirection operator is `>', and the `noclobber' option to
1905 the `set' builtin has been enabled, the redirection will fail if the
1906 file whose name results from the expansion of WORD exists and is a
1907 regular file.  If the redirection operator is `>|', or the redirection
1908 operator is `>' and the `noclobber' option is not enabled, the
1909 redirection is attempted even if the file named by WORD exists.
1910
1911 3.6.3 Appending Redirected Output
1912 ---------------------------------
1913
1914 Redirection of output in this fashion causes the file whose name
1915 results from the expansion of WORD to be opened for appending on file
1916 descriptor N, or the standard output (file descriptor 1) if N is not
1917 specified.  If the file does not exist it is created.
1918
1919    The general format for appending output is:
1920      [N]>>WORD
1921
1922 3.6.4 Redirecting Standard Output and Standard Error
1923 ----------------------------------------------------
1924
1925 This construct allows both the standard output (file descriptor 1) and
1926 the standard error output (file descriptor 2) to be redirected to the
1927 file whose name is the expansion of WORD.
1928
1929    There are two formats for redirecting standard output and standard
1930 error:
1931      &>WORD
1932    and
1933      >&WORD
1934    Of the two forms, the first is preferred.  This is semantically
1935 equivalent to
1936      >WORD 2>&1
1937
1938 3.6.5 Appending Standard Output and Standard Error
1939 --------------------------------------------------
1940
1941 This construct allows both the standard output (file descriptor 1) and
1942 the standard error output (file descriptor 2) to be appended to the
1943 file whose name is the expansion of WORD.
1944
1945    The format for appending standard output and standard error is:
1946      &>>WORD
1947    This is semantically equivalent to
1948      >>WORD 2>&1
1949
1950 3.6.6 Here Documents
1951 --------------------
1952
1953 This type of redirection instructs the shell to read input from the
1954 current source until a line containing only WORD (with no trailing
1955 blanks) is seen.  All of the lines read up to that point are then used
1956 as the standard input for a command.
1957
1958    The format of here-documents is:
1959      <<[-]WORD
1960              HERE-DOCUMENT
1961      DELIMITER
1962
1963    No parameter expansion, command substitution, arithmetic expansion,
1964 or filename expansion is performed on WORD.  If any characters in WORD
1965 are quoted, the DELIMITER is the result of quote removal on WORD, and
1966 the lines in the here-document are not expanded.  If WORD is unquoted,
1967 all lines of the here-document are subjected to parameter expansion,
1968 command substitution, and arithmetic expansion.  In the latter case,
1969 the character sequence `\newline' is ignored, and `\' must be used to
1970 quote the characters `\', `$', and ``'.
1971
1972    If the redirection operator is `<<-', then all leading tab
1973 characters are stripped from input lines and the line containing
1974 DELIMITER.  This allows here-documents within shell scripts to be
1975 indented in a natural fashion.
1976
1977 3.6.7 Here Strings
1978 ------------------
1979
1980 A variant of here documents, the format is:
1981      <<< WORD
1982
1983    The WORD is expanded and supplied to the command on its standard
1984 input.
1985
1986 3.6.8 Duplicating File Descriptors
1987 ----------------------------------
1988
1989 The redirection operator
1990      [N]<&WORD
1991    is used to duplicate input file descriptors.  If WORD expands to one
1992 or more digits, the file descriptor denoted by N is made to be a copy
1993 of that file descriptor.  If the digits in WORD do not specify a file
1994 descriptor open for input, a redirection error occurs.  If WORD
1995 evaluates to `-', file descriptor N is closed.  If N is not specified,
1996 the standard input (file descriptor 0) is used.
1997
1998    The operator
1999      [N]>&WORD
2000    is used similarly to duplicate output file descriptors.  If N is not
2001 specified, the standard output (file descriptor 1) is used.  If the
2002 digits in WORD do not specify a file descriptor open for output, a
2003 redirection error occurs.  As a special case, if N is omitted, and WORD
2004 does not expand to one or more digits, the standard output and standard
2005 error are redirected as described previously.
2006
2007 3.6.9 Moving File Descriptors
2008 -----------------------------
2009
2010 The redirection operator
2011      [N]<&DIGIT-
2012    moves the file descriptor DIGIT to file descriptor N, or the
2013 standard input (file descriptor 0) if N is not specified.  DIGIT is
2014 closed after being duplicated to N.
2015
2016    Similarly, the redirection operator
2017      [N]>&DIGIT-
2018    moves the file descriptor DIGIT to file descriptor N, or the
2019 standard output (file descriptor 1) if N is not specified.
2020
2021 3.6.10 Opening File Descriptors for Reading and Writing
2022 -------------------------------------------------------
2023
2024 The redirection operator
2025      [N]<>WORD
2026    causes the file whose name is the expansion of WORD to be opened for
2027 both reading and writing on file descriptor N, or on file descriptor 0
2028 if N is not specified.  If the file does not exist, it is created.
2029
2030 \1f
2031 File: bashref.info,  Node: Executing Commands,  Next: Shell Scripts,  Prev: Redirections,  Up: Basic Shell Features
2032
2033 3.7 Executing Commands
2034 ======================
2035
2036 * Menu:
2037
2038 * Simple Command Expansion::    How Bash expands simple commands before
2039                                 executing them.
2040 * Command Search and Execution::        How Bash finds commands and runs them.
2041 * Command Execution Environment::       The environment in which Bash
2042                                         executes commands that are not
2043                                         shell builtins.
2044 * Environment::         The environment given to a command.
2045 * Exit Status::         The status returned by commands and how Bash
2046                         interprets it.
2047 * Signals::             What happens when Bash or a command it runs
2048                         receives a signal.
2049
2050 \1f
2051 File: bashref.info,  Node: Simple Command Expansion,  Next: Command Search and Execution,  Up: Executing Commands
2052
2053 3.7.1 Simple Command Expansion
2054 ------------------------------
2055
2056 When a simple command is executed, the shell performs the following
2057 expansions, assignments, and redirections, from left to right.
2058
2059   1. The words that the parser has marked as variable assignments (those
2060      preceding the command name) and redirections are saved for later
2061      processing.
2062
2063   2. The words that are not variable assignments or redirections are
2064      expanded (*note Shell Expansions::).  If any words remain after
2065      expansion, the first word is taken to be the name of the command
2066      and the remaining words are the arguments.
2067
2068   3. Redirections are performed as described above (*note
2069      Redirections::).
2070
2071   4. The text after the `=' in each variable assignment undergoes tilde
2072      expansion, parameter expansion, command substitution, arithmetic
2073      expansion, and quote removal before being assigned to the variable.
2074
2075    If no command name results, the variable assignments affect the
2076 current shell environment.  Otherwise, the variables are added to the
2077 environment of the executed command and do not affect the current shell
2078 environment.  If any of the assignments attempts to assign a value to a
2079 readonly variable, an error occurs, and the command exits with a
2080 non-zero status.
2081
2082    If no command name results, redirections are performed, but do not
2083 affect the current shell environment.  A redirection error causes the
2084 command to exit with a non-zero status.
2085
2086    If there is a command name left after expansion, execution proceeds
2087 as described below.  Otherwise, the command exits.  If one of the
2088 expansions contained a command substitution, the exit status of the
2089 command is the exit status of the last command substitution performed.
2090 If there were no command substitutions, the command exits with a status
2091 of zero.
2092
2093 \1f
2094 File: bashref.info,  Node: Command Search and Execution,  Next: Command Execution Environment,  Prev: Simple Command Expansion,  Up: Executing Commands
2095
2096 3.7.2 Command Search and Execution
2097 ----------------------------------
2098
2099 After a command has been split into words, if it results in a simple
2100 command and an optional list of arguments, the following actions are
2101 taken.
2102
2103   1. If the command name contains no slashes, the shell attempts to
2104      locate it.  If there exists a shell function by that name, that
2105      function is invoked as described in *note Shell Functions::.
2106
2107   2. If the name does not match a function, the shell searches for it
2108      in the list of shell builtins.  If a match is found, that builtin
2109      is invoked.
2110
2111   3. If the name is neither a shell function nor a builtin, and
2112      contains no slashes, Bash searches each element of `$PATH' for a
2113      directory containing an executable file by that name.  Bash uses a
2114      hash table to remember the full pathnames of executable files to
2115      avoid multiple `PATH' searches (see the description of `hash' in
2116      *note Bourne Shell Builtins::).  A full search of the directories
2117      in `$PATH' is performed only if the command is not found in the
2118      hash table.  If the search is unsuccessful, the shell searches for
2119      a defined shell function named `command_not_found_handle'.  If
2120      that function exists, it is invoked with the original command and
2121      the original command's arguments as its arguments, and the
2122      function's exit status becomes the exit status of the shell.  If
2123      that function is not defined, the shell prints an error message
2124      and returns an exit status of 127.
2125
2126   4. If the search is successful, or if the command name contains one
2127      or more slashes, the shell executes the named program in a
2128      separate execution environment.  Argument 0 is set to the name
2129      given, and the remaining arguments to the command are set to the
2130      arguments supplied, if any.
2131
2132   5. If this execution fails because the file is not in executable
2133      format, and the file is not a directory, it is assumed to be a
2134      SHELL SCRIPT and the shell executes it as described in *note Shell
2135      Scripts::.
2136
2137   6. If the command was not begun asynchronously, the shell waits for
2138      the command to complete and collects its exit status.
2139
2140
2141 \1f
2142 File: bashref.info,  Node: Command Execution Environment,  Next: Environment,  Prev: Command Search and Execution,  Up: Executing Commands
2143
2144 3.7.3 Command Execution Environment
2145 -----------------------------------
2146
2147 The shell has an EXECUTION ENVIRONMENT, which consists of the following:
2148
2149    * open files inherited by the shell at invocation, as modified by
2150      redirections supplied to the `exec' builtin
2151
2152    * the current working directory as set by `cd', `pushd', or `popd',
2153      or inherited by the shell at invocation
2154
2155    * the file creation mode mask as set by `umask' or inherited from
2156      the shell's parent
2157
2158    * current traps set by `trap'
2159
2160    * shell parameters that are set by variable assignment or with `set'
2161      or inherited from the shell's parent in the environment
2162
2163    * shell functions defined during execution or inherited from the
2164      shell's parent in the environment
2165
2166    * options enabled at invocation (either by default or with
2167      command-line arguments) or by `set'
2168
2169    * options enabled by `shopt' (*note The Shopt Builtin::)
2170
2171    * shell aliases defined with `alias' (*note Aliases::)
2172
2173    * various process IDs, including those of background jobs (*note
2174      Lists::), the value of `$$', and the value of `$PPID'
2175
2176
2177    When a simple command other than a builtin or shell function is to
2178 be executed, it is invoked in a separate execution environment that
2179 consists of the following.  Unless otherwise noted, the values are
2180 inherited from the shell.
2181
2182    * the shell's open files, plus any modifications and additions
2183      specified by redirections to the command
2184
2185    * the current working directory
2186
2187    * the file creation mode mask
2188
2189    * shell variables and functions marked for export, along with
2190      variables exported for the command, passed in the environment
2191      (*note Environment::)
2192
2193    * traps caught by the shell are reset to the values inherited from
2194      the shell's parent, and traps ignored by the shell are ignored
2195
2196
2197    A command invoked in this separate environment cannot affect the
2198 shell's execution environment.
2199
2200    Command substitution, commands grouped with parentheses, and
2201 asynchronous commands are invoked in a subshell environment that is a
2202 duplicate of the shell environment, except that traps caught by the
2203 shell are reset to the values that the shell inherited from its parent
2204 at invocation.  Builtin commands that are invoked as part of a pipeline
2205 are also executed in a subshell environment.  Changes made to the
2206 subshell environment cannot affect the shell's execution environment.
2207
2208    Subshells spawned to execute command substitutions inherit the value
2209 of the `-e' option from the parent shell.  When not in POSIX mode, Bash
2210 clears the `-e' option in such subshells.
2211
2212    If a command is followed by a `&' and job control is not active, the
2213 default standard input for the command is the empty file `/dev/null'.
2214 Otherwise, the invoked command inherits the file descriptors of the
2215 calling shell as modified by redirections.
2216
2217 \1f
2218 File: bashref.info,  Node: Environment,  Next: Exit Status,  Prev: Command Execution Environment,  Up: Executing Commands
2219
2220 3.7.4 Environment
2221 -----------------
2222
2223 When a program is invoked it is given an array of strings called the
2224 ENVIRONMENT.  This is a list of name-value pairs, of the form
2225 `name=value'.
2226
2227    Bash provides several ways to manipulate the environment.  On
2228 invocation, the shell scans its own environment and creates a parameter
2229 for each name found, automatically marking it for EXPORT to child
2230 processes.  Executed commands inherit the environment.  The `export'
2231 and `declare -x' commands allow parameters and functions to be added to
2232 and deleted from the environment.  If the value of a parameter in the
2233 environment is modified, the new value becomes part of the environment,
2234 replacing the old.  The environment inherited by any executed command
2235 consists of the shell's initial environment, whose values may be
2236 modified in the shell, less any pairs removed by the `unset' and
2237 `export -n' commands, plus any additions via the `export' and `declare
2238 -x' commands.
2239
2240    The environment for any simple command or function may be augmented
2241 temporarily by prefixing it with parameter assignments, as described in
2242 *note Shell Parameters::.  These assignment statements affect only the
2243 environment seen by that command.
2244
2245    If the `-k' option is set (*note The Set Builtin::), then all
2246 parameter assignments are placed in the environment for a command, not
2247 just those that precede the command name.
2248
2249    When Bash invokes an external command, the variable `$_' is set to
2250 the full path name of the command and passed to that command in its
2251 environment.
2252
2253 \1f
2254 File: bashref.info,  Node: Exit Status,  Next: Signals,  Prev: Environment,  Up: Executing Commands
2255
2256 3.7.5 Exit Status
2257 -----------------
2258
2259 The exit status of an executed command is the value returned by the
2260 WAITPID system call or equivalent function.  Exit statuses fall between
2261 0 and 255, though, as explained below, the shell may use values above
2262 125 specially.  Exit statuses from shell builtins and compound commands
2263 are also limited to this range. Under certain circumstances, the shell
2264 will use special values to indicate specific failure modes.
2265
2266    For the shell's purposes, a command which exits with a zero exit
2267 status has succeeded.  A non-zero exit status indicates failure.  This
2268 seemingly counter-intuitive scheme is used so there is one well-defined
2269 way to indicate success and a variety of ways to indicate various
2270 failure modes.  When a command terminates on a fatal signal whose
2271 number is N, Bash uses the value 128+N as the exit status.
2272
2273    If a command is not found, the child process created to execute it
2274 returns a status of 127.  If a command is found but is not executable,
2275 the return status is 126.
2276
2277    If a command fails because of an error during expansion or
2278 redirection, the exit status is greater than zero.
2279
2280    The exit status is used by the Bash conditional commands (*note
2281 Conditional Constructs::) and some of the list constructs (*note
2282 Lists::).
2283
2284    All of the Bash builtins return an exit status of zero if they
2285 succeed and a non-zero status on failure, so they may be used by the
2286 conditional and list constructs.  All builtins return an exit status of
2287 2 to indicate incorrect usage.
2288
2289 \1f
2290 File: bashref.info,  Node: Signals,  Prev: Exit Status,  Up: Executing Commands
2291
2292 3.7.6 Signals
2293 -------------
2294
2295 When Bash is interactive, in the absence of any traps, it ignores
2296 `SIGTERM' (so that `kill 0' does not kill an interactive shell), and
2297 `SIGINT' is caught and handled (so that the `wait' builtin is
2298 interruptible).  When Bash receives a `SIGINT', it breaks out of any
2299 executing loops.  In all cases, Bash ignores `SIGQUIT'.  If job control
2300 is in effect (*note Job Control::), Bash ignores `SIGTTIN', `SIGTTOU',
2301 and `SIGTSTP'.
2302
2303    Non-builtin commands started by Bash have signal handlers set to the
2304 values inherited by the shell from its parent.  When job control is not
2305 in effect, asynchronous commands ignore `SIGINT' and `SIGQUIT' in
2306 addition to these inherited handlers.  Commands run as a result of
2307 command substitution ignore the keyboard-generated job control signals
2308 `SIGTTIN', `SIGTTOU', and `SIGTSTP'.
2309
2310    The shell exits by default upon receipt of a `SIGHUP'.  Before
2311 exiting, an interactive shell resends the `SIGHUP' to all jobs, running
2312 or stopped.  Stopped jobs are sent `SIGCONT' to ensure that they receive
2313 the `SIGHUP'.  To prevent the shell from sending the `SIGHUP' signal to
2314 a particular job, it should be removed from the jobs table with the
2315 `disown' builtin (*note Job Control Builtins::) or marked to not
2316 receive `SIGHUP' using `disown -h'.
2317
2318    If the  `huponexit' shell option has been set with `shopt' (*note
2319 The Shopt Builtin::), Bash sends a `SIGHUP' to all jobs when an
2320 interactive login shell exits.
2321
2322    If Bash is waiting for a command to complete and receives a signal
2323 for which a trap has been set, the trap will not be executed until the
2324 command completes.  When Bash is waiting for an asynchronous command
2325 via the `wait' builtin, the reception of a signal for which a trap has
2326 been set will cause the `wait' builtin to return immediately with an
2327 exit status greater than 128, immediately after which the trap is
2328 executed.
2329
2330 \1f
2331 File: bashref.info,  Node: Shell Scripts,  Prev: Executing Commands,  Up: Basic Shell Features
2332
2333 3.8 Shell Scripts
2334 =================
2335
2336 A shell script is a text file containing shell commands.  When such a
2337 file is used as the first non-option argument when invoking Bash, and
2338 neither the `-c' nor `-s' option is supplied (*note Invoking Bash::),
2339 Bash reads and executes commands from the file, then exits.  This mode
2340 of operation creates a non-interactive shell.  The shell first searches
2341 for the file in the current directory, and looks in the directories in
2342 `$PATH' if not found there.
2343
2344    When Bash runs a shell script, it sets the special parameter `0' to
2345 the name of the file, rather than the name of the shell, and the
2346 positional parameters are set to the remaining arguments, if any are
2347 given.  If no additional arguments are supplied, the positional
2348 parameters are unset.
2349
2350    A shell script may be made executable by using the `chmod' command
2351 to turn on the execute bit.  When Bash finds such a file while
2352 searching the `$PATH' for a command, it spawns a subshell to execute
2353 it.  In other words, executing
2354      filename ARGUMENTS
2355    is equivalent to executing
2356      bash filename ARGUMENTS
2357
2358 if `filename' is an executable shell script.  This subshell
2359 reinitializes itself, so that the effect is as if a new shell had been
2360 invoked to interpret the script, with the exception that the locations
2361 of commands remembered by the parent (see the description of `hash' in
2362 *note Bourne Shell Builtins::) are retained by the child.
2363
2364    Most versions of Unix make this a part of the operating system's
2365 command execution mechanism.  If the first line of a script begins with
2366 the two characters `#!', the remainder of the line specifies an
2367 interpreter for the program.  Thus, you can specify Bash, `awk', Perl,
2368 or some other interpreter and write the rest of the script file in that
2369 language.
2370
2371    The arguments to the interpreter consist of a single optional
2372 argument following the interpreter name on the first line of the script
2373 file, followed by the name of the script file, followed by the rest of
2374 the arguments.  Bash will perform this action on operating systems that
2375 do not handle it themselves.  Note that some older versions of Unix
2376 limit the interpreter name and argument to a maximum of 32 characters.
2377
2378    Bash scripts often begin with `#! /bin/bash' (assuming that Bash has
2379 been installed in `/bin'), since this ensures that Bash will be used to
2380 interpret the script, even if it is executed under another shell.
2381
2382 \1f
2383 File: bashref.info,  Node: Shell Builtin Commands,  Next: Shell Variables,  Prev: Basic Shell Features,  Up: Top
2384
2385 4 Shell Builtin Commands
2386 ************************
2387
2388 * Menu:
2389
2390 * Bourne Shell Builtins::       Builtin commands inherited from the Bourne
2391                                 Shell.
2392 * Bash Builtins::               Table of builtins specific to Bash.
2393 * Modifying Shell Behavior::    Builtins to modify shell attributes and
2394                                 optional behavior.
2395 * Special Builtins::            Builtin commands classified specially by
2396                                 POSIX.
2397
2398    Builtin commands are contained within the shell itself.  When the
2399 name of a builtin command is used as the first word of a simple command
2400 (*note Simple Commands::), the shell executes the command directly,
2401 without invoking another program.  Builtin commands are necessary to
2402 implement functionality impossible or inconvenient to obtain with
2403 separate utilities.
2404
2405    This section briefly describes the builtins which Bash inherits from
2406 the Bourne Shell, as well as the builtin commands which are unique to
2407 or have been extended in Bash.
2408
2409    Several builtin commands are described in other chapters:  builtin
2410 commands which provide the Bash interface to the job control facilities
2411 (*note Job Control Builtins::), the directory stack (*note Directory
2412 Stack Builtins::), the command history (*note Bash History Builtins::),
2413 and the programmable completion facilities (*note Programmable
2414 Completion Builtins::).
2415
2416    Many of the builtins have been extended by POSIX or Bash.
2417
2418    Unless otherwise noted, each builtin command documented as accepting
2419 options preceded by `-' accepts `--' to signify the end of the options.
2420 The `:', `true', `false', and `test' builtins do not accept options and
2421 do not treat `--' specially.  The `exit', `logout', `break',
2422 `continue', `let', and `shift' builtins accept and process arguments
2423 beginning with `-' without requiring `--'.  Other builtins that accept
2424 arguments but are not specified as accepting options interpret
2425 arguments beginning with `-' as invalid options and require `--' to
2426 prevent this interpretation.
2427
2428 \1f
2429 File: bashref.info,  Node: Bourne Shell Builtins,  Next: Bash Builtins,  Up: Shell Builtin Commands
2430
2431 4.1 Bourne Shell Builtins
2432 =========================
2433
2434 The following shell builtin commands are inherited from the Bourne
2435 Shell.  These commands are implemented as specified by the POSIX
2436 standard.
2437
2438 `:    (a colon)'
2439           : [ARGUMENTS]
2440      Do nothing beyond expanding ARGUMENTS and performing redirections.
2441      The return status is zero.
2442
2443 `.    (a period)'
2444           . FILENAME [ARGUMENTS]
2445      Read and execute commands from the FILENAME argument in the
2446      current shell context.  If FILENAME does not contain a slash, the
2447      `PATH' variable is used to find FILENAME.  When Bash is not in
2448      POSIX mode, the current directory is searched if FILENAME is not
2449      found in `$PATH'.  If any ARGUMENTS are supplied, they become the
2450      positional parameters when FILENAME is executed.  Otherwise the
2451      positional parameters are unchanged.  The return status is the
2452      exit status of the last command executed, or zero if no commands
2453      are executed.  If FILENAME is not found, or cannot be read, the
2454      return status is non-zero.  This builtin is equivalent to `source'.
2455
2456 `break'
2457           break [N]
2458      Exit from a `for', `while', `until', or `select' loop.  If N is
2459      supplied, the Nth enclosing loop is exited.  N must be greater
2460      than or equal to 1.  The return status is zero unless N is not
2461      greater than or equal to 1.
2462
2463 `cd'
2464           cd [-L|-P] [DIRECTORY]
2465      Change the current working directory to DIRECTORY.  If DIRECTORY
2466      is not given, the value of the `HOME' shell variable is used.  If
2467      the shell variable `CDPATH' exists, it is used as a search path.
2468      If DIRECTORY begins with a slash, `CDPATH' is not used.
2469
2470      The `-P' option means to not follow symbolic links; symbolic links
2471      are followed by default or with the `-L' option.  If DIRECTORY is
2472      `-', it is equivalent to `$OLDPWD'.
2473
2474      If a non-empty directory name from `CDPATH' is used, or if `-' is
2475      the first argument, and the directory change is successful, the
2476      absolute pathname of the new working directory is written to the
2477      standard output.
2478
2479      The return status is zero if the directory is successfully changed,
2480      non-zero otherwise.
2481
2482 `continue'
2483           continue [N]
2484      Resume the next iteration of an enclosing `for', `while', `until',
2485      or `select' loop.  If N is supplied, the execution of the Nth
2486      enclosing loop is resumed.  N must be greater than or equal to 1.
2487      The return status is zero unless N is not greater than or equal to
2488      1.
2489
2490 `eval'
2491           eval [ARGUMENTS]
2492      The arguments are concatenated together into a single command,
2493      which is then read and executed, and its exit status returned as
2494      the exit status of `eval'.  If there are no arguments or only
2495      empty arguments, the return status is zero.
2496
2497 `exec'
2498           exec [-cl] [-a NAME] [COMMAND [ARGUMENTS]]
2499      If COMMAND is supplied, it replaces the shell without creating a
2500      new process.  If the `-l' option is supplied, the shell places a
2501      dash at the beginning of the zeroth argument passed to COMMAND.
2502      This is what the `login' program does.  The `-c' option causes
2503      COMMAND to be executed with an empty environment.  If `-a' is
2504      supplied, the shell passes NAME as the zeroth argument to COMMAND.
2505      If no COMMAND is specified, redirections may be used to affect the
2506      current shell environment.  If there are no redirection errors, the
2507      return status is zero; otherwise the return status is non-zero.
2508
2509 `exit'
2510           exit [N]
2511      Exit the shell, returning a status of N to the shell's parent.  If
2512      N is omitted, the exit status is that of the last command executed.
2513      Any trap on `EXIT' is executed before the shell terminates.
2514
2515 `export'
2516           export [-fn] [-p] [NAME[=VALUE]]
2517      Mark each NAME to be passed to child processes in the environment.
2518      If the `-f' option is supplied, the NAMEs refer to shell
2519      functions; otherwise the names refer to shell variables.  The `-n'
2520      option means to no longer mark each NAME for export.  If no NAMES
2521      are supplied, or if the `-p' option is given, a list of exported
2522      names is displayed.  The `-p' option displays output in a form
2523      that may be reused as input.  If a variable name is followed by
2524      =VALUE, the value of the variable is set to VALUE.
2525
2526      The return status is zero unless an invalid option is supplied,
2527      one of the names is not a valid shell variable name, or `-f' is
2528      supplied with a name that is not a shell function.
2529
2530 `getopts'
2531           getopts OPTSTRING NAME [ARGS]
2532      `getopts' is used by shell scripts to parse positional parameters.
2533      OPTSTRING contains the option characters to be recognized; if a
2534      character is followed by a colon, the option is expected to have an
2535      argument, which should be separated from it by white space.  The
2536      colon (`:') and question mark (`?') may not be used as option
2537      characters.  Each time it is invoked, `getopts' places the next
2538      option in the shell variable NAME, initializing NAME if it does
2539      not exist, and the index of the next argument to be processed into
2540      the variable `OPTIND'.  `OPTIND' is initialized to 1 each time the
2541      shell or a shell script is invoked.  When an option requires an
2542      argument, `getopts' places that argument into the variable
2543      `OPTARG'.  The shell does not reset `OPTIND' automatically; it
2544      must be manually reset between multiple calls to `getopts' within
2545      the same shell invocation if a new set of parameters is to be used.
2546
2547      When the end of options is encountered, `getopts' exits with a
2548      return value greater than zero.  `OPTIND' is set to the index of
2549      the first non-option argument, and `name' is set to `?'.
2550
2551      `getopts' normally parses the positional parameters, but if more
2552      arguments are given in ARGS, `getopts' parses those instead.
2553
2554      `getopts' can report errors in two ways.  If the first character of
2555      OPTSTRING is a colon, SILENT error reporting is used.  In normal
2556      operation diagnostic messages are printed when invalid options or
2557      missing option arguments are encountered.  If the variable `OPTERR'
2558      is set to 0, no error messages will be displayed, even if the first
2559      character of `optstring' is not a colon.
2560
2561      If an invalid option is seen, `getopts' places `?' into NAME and,
2562      if not silent, prints an error message and unsets `OPTARG'.  If
2563      `getopts' is silent, the option character found is placed in
2564      `OPTARG' and no diagnostic message is printed.
2565
2566      If a required argument is not found, and `getopts' is not silent,
2567      a question mark (`?') is placed in NAME, `OPTARG' is unset, and a
2568      diagnostic message is printed.  If `getopts' is silent, then a
2569      colon (`:') is placed in NAME and `OPTARG' is set to the option
2570      character found.
2571
2572 `hash'
2573           hash [-r] [-p FILENAME] [-dt] [NAME]
2574      Remember the full pathnames of commands specified as NAME
2575      arguments, so they need not be searched for on subsequent
2576      invocations.  The commands are found by searching through the
2577      directories listed in `$PATH'.  The `-p' option inhibits the path
2578      search, and FILENAME is used as the location of NAME.  The `-r'
2579      option causes the shell to forget all remembered locations.  The
2580      `-d' option causes the shell to forget the remembered location of
2581      each NAME.  If the `-t' option is supplied, the full pathname to
2582      which each NAME corresponds is printed.  If multiple NAME
2583      arguments are supplied with `-t' the NAME is printed before the
2584      hashed full pathname.  The `-l' option causes output to be
2585      displayed in a format that may be reused as input.  If no
2586      arguments are given, or if only `-l' is supplied, information
2587      about remembered commands is printed.  The return status is zero
2588      unless a NAME is not found or an invalid option is supplied.
2589
2590 `pwd'
2591           pwd [-LP]
2592      Print the absolute pathname of the current working directory.  If
2593      the `-P' option is supplied, the pathname printed will not contain
2594      symbolic links.  If the `-L' option is supplied, the pathname
2595      printed may contain symbolic links.  The return status is zero
2596      unless an error is encountered while determining the name of the
2597      current directory or an invalid option is supplied.
2598
2599 `readonly'
2600           readonly [-aApf] [NAME[=VALUE]] ...
2601      Mark each NAME as readonly.  The values of these names may not be
2602      changed by subsequent assignment.  If the `-f' option is supplied,
2603      each NAME refers to a shell function.  The `-a' option means each
2604      NAME refers to an indexed array variable; the `-A' option means
2605      each NAME refers to an associative array variable.  If no NAME
2606      arguments are given, or if the `-p' option is supplied, a list of
2607      all readonly names is printed.  The `-p' option causes output to
2608      be displayed in a format that may be reused as input.  If a
2609      variable name is followed by =VALUE, the value of the variable is
2610      set to VALUE.  The return status is zero unless an invalid option
2611      is supplied, one of the NAME arguments is not a valid shell
2612      variable or function name, or the `-f' option is supplied with a
2613      name that is not a shell function.
2614
2615 `return'
2616           return [N]
2617      Cause a shell function to exit with the return value N.  If N is
2618      not supplied, the return value is the exit status of the last
2619      command executed in the function.  This may also be used to
2620      terminate execution of a script being executed with the `.' (or
2621      `source') builtin, returning either N or the exit status of the
2622      last command executed within the script as the exit status of the
2623      script.  Any command associated with the `RETURN' trap is executed
2624      before execution resumes after the function or script.  The return
2625      status is non-zero if `return' is used outside a function and not
2626      during the execution of a script by `.' or `source'.
2627
2628 `shift'
2629           shift [N]
2630      Shift the positional parameters to the left by N.  The positional
2631      parameters from N+1 ... `$#' are renamed to `$1' ... `$#'-N.
2632      Parameters represented by the numbers `$#' to `$#'-N+1 are unset.
2633      N must be a non-negative number less than or equal to `$#'.  If N
2634      is zero or greater than `$#', the positional parameters are not
2635      changed.  If N is not supplied, it is assumed to be 1.  The return
2636      status is zero unless N is greater than `$#' or less than zero,
2637      non-zero otherwise.
2638
2639 `test'
2640 `['
2641      Evaluate a conditional expression EXPR.  Each operator and operand
2642      must be a separate argument.  Expressions are composed of the
2643      primaries described below in *note Bash Conditional Expressions::.
2644      `test' does not accept any options, nor does it accept and ignore
2645      an argument of `--' as signifying the end of options.
2646
2647      When the `[' form is used, the last argument to the command must
2648      be a `]'.
2649
2650      Expressions may be combined using the following operators, listed
2651      in decreasing order of precedence.  The evaluation depends on the
2652      number of arguments; see below.
2653
2654     `! EXPR'
2655           True if EXPR is false.
2656
2657     `( EXPR )'
2658           Returns the value of EXPR.  This may be used to override the
2659           normal precedence of operators.
2660
2661     `EXPR1 -a EXPR2'
2662           True if both EXPR1 and EXPR2 are true.
2663
2664     `EXPR1 -o EXPR2'
2665           True if either EXPR1 or EXPR2 is true.
2666
2667      The `test' and `[' builtins evaluate conditional expressions using
2668      a set of rules based on the number of arguments.
2669
2670     0 arguments
2671           The expression is false.
2672
2673     1 argument
2674           The expression is true if and only if the argument is not
2675           null.
2676
2677     2 arguments
2678           If the first argument is `!', the expression is true if and
2679           only if the second argument is null.  If the first argument
2680           is one of the unary conditional operators (*note Bash
2681           Conditional Expressions::), the expression is true if the
2682           unary test is true.  If the first argument is not a valid
2683           unary operator, the expression is false.
2684
2685     3 arguments
2686           If the second argument is one of the binary conditional
2687           operators (*note Bash Conditional Expressions::), the result
2688           of the expression is the result of the binary test using the
2689           first and third arguments as operands.  The `-a' and `-o'
2690           operators are considered binary operators when there are
2691           three arguments.  If the first argument is `!', the value is
2692           the negation of the two-argument test using the second and
2693           third arguments.  If the first argument is exactly `(' and
2694           the third argument is exactly `)', the result is the
2695           one-argument test of the second argument.  Otherwise, the
2696           expression is false.
2697
2698     4 arguments
2699           If the first argument is `!', the result is the negation of
2700           the three-argument expression composed of the remaining
2701           arguments.  Otherwise, the expression is parsed and evaluated
2702           according to precedence using the rules listed above.
2703
2704     5 or more arguments
2705           The expression is parsed and evaluated according to precedence
2706           using the rules listed above.
2707
2708 `times'
2709           times
2710      Print out the user and system times used by the shell and its
2711      children.  The return status is zero.
2712
2713 `trap'
2714           trap [-lp] [ARG] [SIGSPEC ...]
2715      The commands in ARG are to be read and executed when the shell
2716      receives signal SIGSPEC.  If ARG is absent (and there is a single
2717      SIGSPEC) or equal to `-', each specified signal's disposition is
2718      reset to the value it had when the shell was started.  If ARG is
2719      the null string, then the signal specified by each SIGSPEC is
2720      ignored by the shell and commands it invokes.  If ARG is not
2721      present and `-p' has been supplied, the shell displays the trap
2722      commands associated with each SIGSPEC.  If no arguments are
2723      supplied, or only `-p' is given, `trap' prints the list of commands
2724      associated with each signal number in a form that may be reused as
2725      shell input.  The `-l' option causes the shell to print a list of
2726      signal names and their corresponding numbers.  Each SIGSPEC is
2727      either a signal name or a signal number.  Signal names are case
2728      insensitive and the `SIG' prefix is optional.
2729
2730      If a SIGSPEC is `0' or `EXIT', ARG is executed when the shell
2731      exits.  If a SIGSPEC is `DEBUG', the command ARG is executed
2732      before every simple command, `for' command, `case' command,
2733      `select' command, every arithmetic `for' command, and before the
2734      first command executes in a shell function.  Refer to the
2735      description of the `extdebug' option to the `shopt' builtin (*note
2736      The Shopt Builtin::) for details of its effect on the `DEBUG' trap.
2737      If a SIGSPEC is `RETURN', the command ARG is executed each time a
2738      shell function or a script executed with the `.' or `source'
2739      builtins finishes executing.
2740
2741      If a SIGSPEC is `ERR', the command ARG is executed whenever a
2742      simple command has a non-zero exit status, subject to the
2743      following conditions.  The `ERR' trap is not executed if the
2744      failed command is part of the command list immediately following
2745      an `until' or `while' keyword, part of the test following the `if'
2746      or `elif' reserved words, part of a command executed in a `&&' or
2747      `||' list, or if the command's return status is being inverted
2748      using `!'.  These are the same conditions obeyed by the `errexit'
2749      option.
2750
2751      Signals ignored upon entry to the shell cannot be trapped or reset.
2752      Trapped signals that are not being ignored are reset to their
2753      original values in a subshell or subshell environment when one is
2754      created.
2755
2756      The return status is zero unless a SIGSPEC does not specify a
2757      valid signal.
2758
2759 `umask'
2760           umask [-p] [-S] [MODE]
2761      Set the shell process's file creation mask to MODE.  If MODE
2762      begins with a digit, it is interpreted as an octal number; if not,
2763      it is interpreted as a symbolic mode mask similar to that accepted
2764      by the `chmod' command.  If MODE is omitted, the current value of
2765      the mask is printed.  If the `-S' option is supplied without a
2766      MODE argument, the mask is printed in a symbolic format.  If the
2767      `-p' option is supplied, and MODE is omitted, the output is in a
2768      form that may be reused as input.  The return status is zero if
2769      the mode is successfully changed or if no MODE argument is
2770      supplied, and non-zero otherwise.
2771
2772      Note that when the mode is interpreted as an octal number, each
2773      number of the umask is subtracted from `7'.  Thus, a umask of `022'
2774      results in permissions of `755'.
2775
2776 `unset'
2777           unset [-fv] [NAME]
2778      Each variable or function NAME is removed.  If no options are
2779      supplied, or the `-v' option is given, each NAME refers to a shell
2780      variable.  If the `-f' option is given, the NAMEs refer to shell
2781      functions, and the function definition is removed.  Readonly
2782      variables and functions may not be unset.  The return status is
2783      zero unless a NAME is readonly.
2784
2785 \1f
2786 File: bashref.info,  Node: Bash Builtins,  Next: Modifying Shell Behavior,  Prev: Bourne Shell Builtins,  Up: Shell Builtin Commands
2787
2788 4.2 Bash Builtin Commands
2789 =========================
2790
2791 This section describes builtin commands which are unique to or have
2792 been extended in Bash.  Some of these commands are specified in the
2793 POSIX standard.
2794
2795 `alias'
2796           alias [`-p'] [NAME[=VALUE] ...]
2797
2798      Without arguments or with the `-p' option, `alias' prints the list
2799      of aliases on the standard output in a form that allows them to be
2800      reused as input.  If arguments are supplied, an alias is defined
2801      for each NAME whose VALUE is given.  If no VALUE is given, the name
2802      and value of the alias is printed.  Aliases are described in *note
2803      Aliases::.
2804
2805 `bind'
2806           bind [-m KEYMAP] [-lpsvPSV]
2807           bind [-m KEYMAP] [-q FUNCTION] [-u FUNCTION] [-r KEYSEQ]
2808           bind [-m KEYMAP] -f FILENAME
2809           bind [-m KEYMAP] -x KEYSEQ:SHELL-COMMAND
2810           bind [-m KEYMAP] KEYSEQ:FUNCTION-NAME
2811           bind READLINE-COMMAND
2812
2813      Display current Readline (*note Command Line Editing::) key and
2814      function bindings, bind a key sequence to a Readline function or
2815      macro, or set a Readline variable.  Each non-option argument is a
2816      command as it would appear in a Readline initialization file
2817      (*note Readline Init File::), but each binding or command must be
2818      passed as a separate argument;  e.g.,
2819      `"\C-x\C-r":re-read-init-file'.
2820
2821      Options, if supplied, have the following meanings:
2822
2823     `-m KEYMAP'
2824           Use KEYMAP as the keymap to be affected by the subsequent
2825           bindings.  Acceptable KEYMAP names are `emacs',
2826           `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
2827           `vi-command', and `vi-insert'.  `vi' is equivalent to
2828           `vi-command'; `emacs' is equivalent to `emacs-standard'.
2829
2830     `-l'
2831           List the names of all Readline functions.
2832
2833     `-p'
2834           Display Readline function names and bindings in such a way
2835           that they can be used as input or in a Readline
2836           initialization file.
2837
2838     `-P'
2839           List current Readline function names and bindings.
2840
2841     `-v'
2842           Display Readline variable names and values in such a way that
2843           they can be used as input or in a Readline initialization
2844           file.
2845
2846     `-V'
2847           List current Readline variable names and values.
2848
2849     `-s'
2850           Display Readline key sequences bound to macros and the
2851           strings they output in such a way that they can be used as
2852           input or in a Readline initialization file.
2853
2854     `-S'
2855           Display Readline key sequences bound to macros and the
2856           strings they output.
2857
2858     `-f FILENAME'
2859           Read key bindings from FILENAME.
2860
2861     `-q FUNCTION'
2862           Query about which keys invoke the named FUNCTION.
2863
2864     `-u FUNCTION'
2865           Unbind all keys bound to the named FUNCTION.
2866
2867     `-r KEYSEQ'
2868           Remove any current binding for KEYSEQ.
2869
2870     `-x KEYSEQ:SHELL-COMMAND'
2871           Cause SHELL-COMMAND to be executed whenever KEYSEQ is entered.
2872           When SHELL-COMMAND is executed, the shell sets the
2873           `READLINE_LINE' variable to the contents of the Readline line
2874           buffer and the `READLINE_POINT' variable to the current
2875           location of the insertion point.  If the executed command
2876           changes the value of `READLINE_LINE' or `READLINE_POINT',
2877           those new values will be reflected in the editing state.
2878
2879      The return status is zero unless an invalid option is supplied or
2880      an error occurs.
2881
2882 `builtin'
2883           builtin [SHELL-BUILTIN [ARGS]]
2884      Run a shell builtin, passing it ARGS, and return its exit status.
2885      This is useful when defining a shell function with the same name
2886      as a shell builtin, retaining the functionality of the builtin
2887      within the function.  The return status is non-zero if
2888      SHELL-BUILTIN is not a shell builtin command.
2889
2890 `caller'
2891           caller [EXPR]
2892      Returns the context of any active subroutine call (a shell
2893      function or a script executed with the `.' or `source' builtins).
2894
2895      Without EXPR, `caller' displays the line number and source
2896      filename of the current subroutine call.  If a non-negative
2897      integer is supplied as EXPR, `caller' displays the line number,
2898      subroutine name, and source file corresponding to that position in
2899      the current execution call stack.  This extra information may be
2900      used, for example, to print a stack trace.  The current frame is
2901      frame 0.
2902
2903      The return value is 0 unless the shell is not executing a
2904      subroutine call or EXPR does not correspond to a valid position in
2905      the call stack.
2906
2907 `command'
2908           command [-pVv] COMMAND [ARGUMENTS ...]
2909      Runs COMMAND with ARGUMENTS ignoring any shell function named
2910      COMMAND.  Only shell builtin commands or commands found by
2911      searching the `PATH' are executed.  If there is a shell function
2912      named `ls', running `command ls' within the function will execute
2913      the external command `ls' instead of calling the function
2914      recursively.  The `-p' option means to use a default value for
2915      `PATH' that is guaranteed to find all of the standard utilities.
2916      The return status in this case is 127 if COMMAND cannot be found
2917      or an error occurred, and the exit status of COMMAND otherwise.
2918
2919      If either the `-V' or `-v' option is supplied, a description of
2920      COMMAND is printed.  The `-v' option causes a single word
2921      indicating the command or file name used to invoke COMMAND to be
2922      displayed; the `-V' option produces a more verbose description.
2923      In this case, the return status is zero if COMMAND is found, and
2924      non-zero if not.
2925
2926 `declare'
2927           declare [-aAfFilrtux] [-p] [NAME[=VALUE] ...]
2928
2929      Declare variables and give them attributes.  If no NAMEs are
2930      given, then display the values of variables instead.
2931
2932      The `-p' option will display the attributes and values of each
2933      NAME.  When `-p' is used with NAME arguments, additional options
2934      are ignored.
2935
2936      When `-p' is supplied without NAME arguments, `declare' will
2937      display the attributes and values of all variables having the
2938      attributes specified by the additional options.  If no other
2939      options are supplied with `-p', `declare' will display the
2940      attributes and values of all shell variables.  The `-f' option
2941      will restrict the display to shell functions.
2942
2943      The `-F' option inhibits the display of function definitions; only
2944      the function name and attributes are printed.  If the `extdebug'
2945      shell option is enabled using `shopt' (*note The Shopt Builtin::),
2946      the source file name and line number where the function is defined
2947      are displayed as well.  `-F' implies `-f'.  The following options
2948      can be used to restrict output to variables with the specified
2949      attributes or to give variables attributes:
2950
2951     `-a'
2952           Each NAME is an indexed array variable (*note Arrays::).
2953
2954     `-A'
2955           Each NAME is an associative array variable (*note Arrays::).
2956
2957     `-f'
2958           Use function names only.
2959
2960     `-i'
2961           The variable is to be treated as an integer; arithmetic
2962           evaluation (*note Shell Arithmetic::) is performed when the
2963           variable is assigned a value.
2964
2965     `-l'
2966           When the variable is assigned a value, all upper-case
2967           characters are converted to lower-case.  The upper-case
2968           attribute is disabled.
2969
2970     `-r'
2971           Make NAMEs readonly.  These names cannot then be assigned
2972           values by subsequent assignment statements or unset.
2973
2974     `-t'
2975           Give each NAME the `trace' attribute.  Traced functions
2976           inherit the `DEBUG' and `RETURN' traps from the calling shell.
2977           The trace attribute has no special meaning for variables.
2978
2979     `-u'
2980           When the variable is assigned a value, all lower-case
2981           characters are converted to upper-case.  The lower-case
2982           attribute is disabled.
2983
2984     `-x'
2985           Mark each NAME for export to subsequent commands via the
2986           environment.
2987
2988      Using `+' instead of `-' turns off the attribute instead, with the
2989      exceptions that `+a' may not be used to destroy an array variable
2990      and `+r' will not remove the readonly attribute.  When used in a
2991      function, `declare' makes each NAME local, as with the `local'
2992      command.  If a variable name is followed by =VALUE, the value of
2993      the variable is set to VALUE.
2994
2995      The return status is zero unless an invalid option is encountered,
2996      an attempt is made to define a function using `-f foo=bar', an
2997      attempt is made to assign a value to a readonly variable, an
2998      attempt is made to assign a value to an array variable without
2999      using the compound assignment syntax (*note Arrays::), one of the
3000      NAMES is not a valid shell variable name, an attempt is made to
3001      turn off readonly status for a readonly variable, an attempt is
3002      made to turn off array status for an array variable, or an attempt
3003      is made to display a non-existent function with `-f'.
3004
3005 `echo'
3006           echo [-neE] [ARG ...]
3007      Output the ARGs, separated by spaces, terminated with a newline.
3008      The return status is always 0.  If `-n' is specified, the trailing
3009      newline is suppressed.  If the `-e' option is given,
3010      interpretation of the following backslash-escaped characters is
3011      enabled.  The `-E' option disables the interpretation of these
3012      escape characters, even on systems where they are interpreted by
3013      default.  The `xpg_echo' shell option may be used to dynamically
3014      determine whether or not `echo' expands these escape characters by
3015      default.  `echo' does not interpret `--' to mean the end of
3016      options.
3017
3018      `echo' interprets the following escape sequences:
3019     `\a'
3020           alert (bell)
3021
3022     `\b'
3023           backspace
3024
3025     `\c'
3026           suppress further output
3027
3028     `\e'
3029           escape
3030
3031     `\f'
3032           form feed
3033
3034     `\n'
3035           new line
3036
3037     `\r'
3038           carriage return
3039
3040     `\t'
3041           horizontal tab
3042
3043     `\v'
3044           vertical tab
3045
3046     `\\'
3047           backslash
3048
3049     `\0NNN'
3050           the eight-bit character whose value is the octal value NNN
3051           (zero to three octal digits)
3052
3053     `\xHH'
3054           the eight-bit character whose value is the hexadecimal value
3055           HH (one or two hex digits)
3056
3057 `enable'
3058           enable [-a] [-dnps] [-f FILENAME] [NAME ...]
3059      Enable and disable builtin shell commands.  Disabling a builtin
3060      allows a disk command which has the same name as a shell builtin
3061      to be executed without specifying a full pathname, even though the
3062      shell normally searches for builtins before disk commands.  If
3063      `-n' is used, the NAMEs become disabled.  Otherwise NAMEs are
3064      enabled.  For example, to use the `test' binary found via `$PATH'
3065      instead of the shell builtin version, type `enable -n test'.
3066
3067      If the `-p' option is supplied, or no NAME arguments appear, a
3068      list of shell builtins is printed.  With no other arguments, the
3069      list consists of all enabled shell builtins.  The `-a' option
3070      means to list each builtin with an indication of whether or not it
3071      is enabled.
3072
3073      The `-f' option means to load the new builtin command NAME from
3074      shared object FILENAME, on systems that support dynamic loading.
3075      The `-d' option will delete a builtin loaded with `-f'.
3076
3077      If there are no options, a list of the shell builtins is displayed.
3078      The `-s' option restricts `enable' to the POSIX special builtins.
3079      If `-s' is used with `-f', the new builtin becomes a special
3080      builtin (*note Special Builtins::).
3081
3082      The return status is zero unless a NAME is not a shell builtin or
3083      there is an error loading a new builtin from a shared object.
3084
3085 `help'
3086           help [-dms] [PATTERN]
3087      Display helpful information about builtin commands.  If PATTERN is
3088      specified, `help' gives detailed help on all commands matching
3089      PATTERN, otherwise a list of the builtins is printed.
3090
3091      Options, if supplied, have the following meanings:
3092
3093     `-d'
3094           Display a short description of each PATTERN
3095
3096     `-m'
3097           Display the description of each PATTERN in a manpage-like
3098           format
3099
3100     `-s'
3101           Display only a short usage synopsis for each PATTERN
3102
3103      The return status is zero unless no command matches PATTERN.
3104
3105 `let'
3106           let EXPRESSION [EXPRESSION]
3107      The `let' builtin allows arithmetic to be performed on shell
3108      variables.  Each EXPRESSION is evaluated according to the rules
3109      given below in *note Shell Arithmetic::.  If the last EXPRESSION
3110      evaluates to 0, `let' returns 1; otherwise 0 is returned.
3111
3112 `local'
3113           local [OPTION] NAME[=VALUE] ...
3114      For each argument, a local variable named NAME is created, and
3115      assigned VALUE.  The OPTION can be any of the options accepted by
3116      `declare'.  `local' can only be used within a function; it makes
3117      the variable NAME have a visible scope restricted to that function
3118      and its children.  The return status is zero unless `local' is
3119      used outside a function, an invalid NAME is supplied, or NAME is a
3120      readonly variable.
3121
3122 `logout'
3123           logout [N]
3124      Exit a login shell, returning a status of N to the shell's parent.
3125
3126 `mapfile'
3127           mapfile [-n COUNT] [-O ORIGIN] [-s COUNT] [-t] [-u FD] [
3128           -C CALLBACK] [-c QUANTUM] [ARRAY]
3129      Read lines from the standard input into the indexed array variable
3130      ARRAY, or from file descriptor FD if the `-u' option is supplied.
3131      The variable `MAPFILE' is the default ARRAY.  Options, if
3132      supplied, have the following meanings:
3133     `-n'
3134           Copy at most COUNT lines.  If COUNT is 0, all lines are
3135           copied.
3136
3137     `-O'
3138           Begin assigning to ARRAY at index ORIGIN.  The default index
3139           is 0.
3140
3141     `-s'
3142           Discard the first COUNT lines read.
3143
3144     `-t'
3145           Remove a trailing newline from each line read.
3146
3147     `-u'
3148           Read lines from file descriptor FD instead of the standard
3149           input.
3150
3151     `-C'
3152           Evaluate CALLBACK each time QUANTUMP lines are read.  The
3153           `-c' option specifies QUANTUM.
3154
3155     `-c'
3156           Specify the number of lines read between each call to
3157           CALLBACK.
3158
3159      If `-C' is specified without `-c', the default quantum is 5000.
3160      When CALLBACK  is evaluated, it is supplied the index of the next
3161      array element to be assigned as an additional argument.  CALLBACK
3162      is evaluated after the line is read but before the array element
3163      is assigned.
3164
3165      If not supplied with an explicit origin, `mapfile' will clear ARRAY
3166      before assigning to it.
3167
3168      `mapfile' returns successfully unless an invalid option or option
3169      argument is supplied, ARRAY is invalid or unassignable, or ARRAY
3170      is not an indexed array.
3171
3172 `printf'
3173           printf [-v VAR] FORMAT [ARGUMENTS]
3174      Write the formatted ARGUMENTS to the standard output under the
3175      control of the FORMAT.  The FORMAT is a character string which
3176      contains three types of objects: plain characters, which are
3177      simply copied to standard output, character escape sequences,
3178      which are converted and copied to the standard output, and format
3179      specifications, each of which causes printing of the next
3180      successive ARGUMENT.  In addition to the standard `printf(1)'
3181      formats, `%b' causes `printf' to expand backslash escape sequences
3182      in the corresponding ARGUMENT, (except that `\c' terminates
3183      output, backslashes in `\'', `\"', and `\?' are not removed, and
3184      octal escapes beginning with `\0' may contain up to four digits),
3185      and `%q' causes `printf' to output the corresponding ARGUMENT in a
3186      format that can be reused as shell input.
3187
3188      The `-v' option causes the output to be assigned to the variable
3189      VAR rather than being printed to the standard output.
3190
3191      The FORMAT is reused as necessary to consume all of the ARGUMENTS.
3192      If the FORMAT requires more ARGUMENTS than are supplied, the extra
3193      format specifications behave as if a zero value or null string, as
3194      appropriate, had been supplied.  The return value is zero on
3195      success, non-zero on failure.
3196
3197 `read'
3198           read [-ers] [-a ANAME] [-d DELIM] [-i TEXT] [-n NCHARS] [-N NCHARS] [-p PROMPT] [-t TIMEOUT] [-u FD] [NAME ...]
3199      One line is read from the standard input, or from the file
3200      descriptor FD supplied as an argument to the `-u' option, and the
3201      first word is assigned to the first NAME, the second word to the
3202      second NAME, and so on, with leftover words and their intervening
3203      separators assigned to the last NAME.  If there are fewer words
3204      read from the input stream than names, the remaining names are
3205      assigned empty values.  The characters in the value of the `IFS'
3206      variable are used to split the line into words.  The backslash
3207      character `\' may be used to remove any special meaning for the
3208      next character read and for line continuation.  If no names are
3209      supplied, the line read is assigned to the variable `REPLY'.  The
3210      return code is zero, unless end-of-file is encountered, `read'
3211      times out (in which case the return code is greater than 128), or
3212      an invalid file descriptor is supplied as the argument to `-u'.
3213
3214      Options, if supplied, have the following meanings:
3215
3216     `-a ANAME'
3217           The words are assigned to sequential indices of the array
3218           variable ANAME, starting at 0.  All elements are removed from
3219           ANAME before the assignment.  Other NAME arguments are
3220           ignored.
3221
3222     `-d DELIM'
3223           The first character of DELIM is used to terminate the input
3224           line, rather than newline.
3225
3226     `-e'
3227           Readline (*note Command Line Editing::) is used to obtain the
3228           line.  Readline uses the current (or default, if line editing
3229           was not previously active) editing settings.
3230
3231     `-i TEXT'
3232           If Readline is being used to read the line, TEXT is placed
3233           into the editing buffer before editing begins.
3234
3235     `-n NCHARS'
3236           `read' returns after reading NCHARS characters rather than
3237           waiting for a complete line of input, but honor a delimiter
3238           if fewer than NCHARS characters are read before the delimiter.
3239
3240     `-N NCHARS'
3241           `read' returns after reading exactly NCHARS characters rather
3242           than waiting for a complete line of input, unless EOF is
3243           encountered or `read' times out.  Delimiter characters
3244           encountered in the input are not treated specially and do not
3245           cause `read' to return until NCHARS characters are read.
3246
3247     `-p PROMPT'
3248           Display PROMPT, without a trailing newline, before attempting
3249           to read any input.  The prompt is displayed only if input is
3250           coming from a terminal.
3251
3252     `-r'
3253           If this option is given, backslash does not act as an escape
3254           character.  The backslash is considered to be part of the
3255           line.  In particular, a backslash-newline pair may not be
3256           used as a line continuation.
3257
3258     `-s'
3259           Silent mode.  If input is coming from a terminal, characters
3260           are not echoed.
3261
3262     `-t TIMEOUT'
3263           Cause `read' to time out and return failure if a complete
3264           line of input is not read within TIMEOUT seconds.  TIMEOUT
3265           may be a decimal number with a fractional portion following
3266           the decimal point.  This option is only effective if `read'
3267           is reading input from a terminal, pipe, or other special
3268           file; it has no effect when reading from regular files.  If
3269           TIMEOUT is 0, `read' returns success if input is available on
3270           the specified file descriptor, failure otherwise.  The exit
3271           status is greater than 128 if the timeout is exceeded.
3272
3273     `-u FD'
3274           Read input from file descriptor FD.
3275
3276
3277 `readarray'
3278           readarray [-n COUNT] [-O ORIGIN] [-s COUNT] [-t] [-u FD] [
3279           -C CALLBACK] [-c QUANTUM] [ARRAY]
3280      Read lines from the standard input into the indexed array variable
3281      ARRAY, or from file descriptor FD if the `-u' option is supplied.
3282
3283      A synonym for `mapfile'.
3284
3285 `source'
3286           source FILENAME
3287      A synonym for `.' (*note Bourne Shell Builtins::).
3288
3289 `type'
3290           type [-afptP] [NAME ...]
3291      For each NAME, indicate how it would be interpreted if used as a
3292      command name.
3293
3294      If the `-t' option is used, `type' prints a single word which is
3295      one of `alias', `function', `builtin', `file' or `keyword', if
3296      NAME is an alias, shell function, shell builtin, disk file, or
3297      shell reserved word, respectively.  If the NAME is not found, then
3298      nothing is printed, and `type' returns a failure status.
3299
3300      If the `-p' option is used, `type' either returns the name of the
3301      disk file that would be executed, or nothing if `-t' would not
3302      return `file'.
3303
3304      The `-P' option forces a path search for each NAME, even if `-t'
3305      would not return `file'.
3306
3307      If a command is hashed, `-p' and `-P' print the hashed value, not
3308      necessarily the file that appears first in `$PATH'.
3309
3310      If the `-a' option is used, `type' returns all of the places that
3311      contain an executable named FILE.  This includes aliases and
3312      functions, if and only if the `-p' option is not also used.
3313
3314      If the `-f' option is used, `type' does not attempt to find shell
3315      functions, as with the `command' builtin.
3316
3317      The return status is zero if all of the NAMES are found, non-zero
3318      if any are not found.
3319
3320 `typeset'
3321           typeset [-afFrxi] [-p] [NAME[=VALUE] ...]
3322      The `typeset' command is supplied for compatibility with the Korn
3323      shell; however, it has been deprecated in favor of the `declare'
3324      builtin command.
3325
3326 `ulimit'
3327           ulimit [-abcdefilmnpqrstuvxHST] [LIMIT]
3328      `ulimit' provides control over the resources available to processes
3329      started by the shell, on systems that allow such control.  If an
3330      option is given, it is interpreted as follows:
3331     `-S'
3332           Change and report the soft limit associated with a resource.
3333
3334     `-H'
3335           Change and report the hard limit associated with a resource.
3336
3337     `-a'
3338           All current limits are reported.
3339
3340     `-b'
3341           The maximum socket buffer size.
3342
3343     `-c'
3344           The maximum size of core files created.
3345
3346     `-d'
3347           The maximum size of a process's data segment.
3348
3349     `-e'
3350           The maximum scheduling priority ("nice").
3351
3352     `-f'
3353           The maximum size of files written by the shell and its
3354           children.
3355
3356     `-i'
3357           The maximum number of pending signals.
3358
3359     `-l'
3360           The maximum size that may be locked into memory.
3361
3362     `-m'
3363           The maximum resident set size (many systems do not honor this
3364           limit).
3365
3366     `-n'
3367           The maximum number of open file descriptors (most systems do
3368           not allow this value to be set).
3369
3370     `-p'
3371           The pipe buffer size.
3372
3373     `-q'
3374           The maximum number of bytes in POSIX message queues.
3375
3376     `-r'
3377           The maximum real-time scheduling priority.
3378
3379     `-s'
3380           The maximum stack size.
3381
3382     `-t'
3383           The maximum amount of cpu time in seconds.
3384
3385     `-u'
3386           The maximum number of processes available to a single user.
3387
3388     `-v'
3389           The maximum amount of virtual memory available to the process.
3390
3391     `-x'
3392           The maximum number of file locks.
3393
3394     `-T'
3395           The maximum number of threads.
3396
3397
3398      If LIMIT is given, it is the new value of the specified resource;
3399      the special LIMIT values `hard', `soft', and `unlimited' stand for
3400      the current hard limit, the current soft limit, and no limit,
3401      respectively.  A hard limit cannot be increased by a non-root user
3402      once it is set; a soft limit may be increased up to the value of
3403      the hard limit.  Otherwise, the current value of the soft limit
3404      for the specified resource is printed, unless the `-H' option is
3405      supplied.  When setting new limits, if neither `-H' nor `-S' is
3406      supplied, both the hard and soft limits are set.  If no option is
3407      given, then `-f' is assumed.  Values are in 1024-byte increments,
3408      except for `-t', which is in seconds, `-p', which is in units of
3409      512-byte blocks, and `-n' and `-u', which are unscaled values.
3410
3411      The return status is zero unless an invalid option or argument is
3412      supplied, or an error occurs while setting a new limit.
3413
3414 `unalias'
3415           unalias [-a] [NAME ... ]
3416
3417      Remove each NAME from the list of aliases.  If `-a' is supplied,
3418      all aliases are removed.  Aliases are described in *note Aliases::.
3419
3420
3421 \1f
3422 File: bashref.info,  Node: Modifying Shell Behavior,  Next: Special Builtins,  Prev: Bash Builtins,  Up: Shell Builtin Commands
3423
3424 4.3 Modifying Shell Behavior
3425 ============================
3426
3427 * Menu:
3428
3429 * The Set Builtin::             Change the values of shell attributes and
3430                                 positional parameters.
3431 * The Shopt Builtin::           Modify shell optional behavior.
3432
3433 \1f
3434 File: bashref.info,  Node: The Set Builtin,  Next: The Shopt Builtin,  Up: Modifying Shell Behavior
3435
3436 4.3.1 The Set Builtin
3437 ---------------------
3438
3439 This builtin is so complicated that it deserves its own section.  `set'
3440 allows you to change the values of shell options and set the positional
3441 parameters, or to display the names and values of shell variables.
3442
3443 `set'
3444           set [--abefhkmnptuvxBCEHPT] [-o OPTION] [ARGUMENT ...]
3445           set [+abefhkmnptuvxBCEHPT] [+o OPTION] [ARGUMENT ...]
3446
3447      If no options or arguments are supplied, `set' displays the names
3448      and values of all shell variables and functions, sorted according
3449      to the current locale, in a format that may be reused as input for
3450      setting or resetting the currently-set variables.  Read-only
3451      variables cannot be reset.  In POSIX mode, only shell variables
3452      are listed.
3453
3454      When options are supplied, they set or unset shell attributes.
3455      Options, if specified, have the following meanings:
3456
3457     `-a'
3458           Mark variables and function which are modified or created for
3459           export to the environment of subsequent commands.
3460
3461     `-b'
3462           Cause the status of terminated background jobs to be reported
3463           immediately, rather than before printing the next primary
3464           prompt.
3465
3466     `-e'
3467           Exit immediately if a pipeline (*note Pipelines::), which may
3468           consist of a single simple command (*note Simple Commands::),
3469           a subshell command enclosed in parentheses (*note Command
3470           Grouping::), or one of the commands executed as part of a
3471           command list enclosed by braces (*note Command Grouping::)
3472           returns a non-zero status.  The shell does not exit if the
3473           command that fails is part of the command list immediately
3474           following a `while' or `until' keyword, part of the test in
3475           an `if' statement, part of any command executed in a `&&' or
3476           `||' list except the command following the final `&&' or `||',
3477           any command in a pipeline but the last, or if the command's
3478           return status is being inverted with `!'.  A trap on `ERR',
3479           if set, is executed before the shell exits.
3480
3481           This option applies to the shell environment and each
3482           subshell environment separately (*note Command Execution
3483           Environment::), and may cause subshells to exit before
3484           executing all the commands in the subshell.
3485
3486     `-f'
3487           Disable filename expansion (globbing).
3488
3489     `-h'
3490           Locate and remember (hash) commands as they are looked up for
3491           execution.  This option is enabled by default.
3492
3493     `-k'
3494           All arguments in the form of assignment statements are placed
3495           in the environment for a command, not just those that precede
3496           the command name.
3497
3498     `-m'
3499           Job control is enabled (*note Job Control::).
3500
3501     `-n'
3502           Read commands but do not execute them; this may be used to
3503           check a script for syntax errors.  This option is ignored by
3504           interactive shells.
3505
3506     `-o OPTION-NAME'
3507           Set the option corresponding to OPTION-NAME:
3508
3509          `allexport'
3510                Same as `-a'.
3511
3512          `braceexpand'
3513                Same as `-B'.
3514
3515          `emacs'
3516                Use an `emacs'-style line editing interface (*note
3517                Command Line Editing::).  This also affects the editing
3518                interface used for `read -e'.
3519
3520          `errexit'
3521                Same as `-e'.
3522
3523          `errtrace'
3524                Same as `-E'.
3525
3526          `functrace'
3527                Same as `-T'.
3528
3529          `hashall'
3530                Same as `-h'.
3531
3532          `histexpand'
3533                Same as `-H'.
3534
3535          `history'
3536                Enable command history, as described in *note Bash
3537                History Facilities::.  This option is on by default in
3538                interactive shells.
3539
3540          `ignoreeof'
3541                An interactive shell will not exit upon reading EOF.
3542
3543          `keyword'
3544                Same as `-k'.
3545
3546          `monitor'
3547                Same as `-m'.
3548
3549          `noclobber'
3550                Same as `-C'.
3551
3552          `noexec'
3553                Same as `-n'.
3554
3555          `noglob'
3556                Same as `-f'.
3557
3558          `nolog'
3559                Currently ignored.
3560
3561          `notify'
3562                Same as `-b'.
3563
3564          `nounset'
3565                Same as `-u'.
3566
3567          `onecmd'
3568                Same as `-t'.
3569
3570          `physical'
3571                Same as `-P'.
3572
3573          `pipefail'
3574                If set, the return value of a pipeline is the value of
3575                the last (rightmost) command to exit with a non-zero
3576                status, or zero if all commands in the pipeline exit
3577                successfully.  This option is disabled by default.
3578
3579          `posix'
3580                Change the behavior of Bash where the default operation
3581                differs from the POSIX standard to match the standard
3582                (*note Bash POSIX Mode::).  This is intended to make
3583                Bash behave as a strict superset of that standard.
3584
3585          `privileged'
3586                Same as `-p'.
3587
3588          `verbose'
3589                Same as `-v'.
3590
3591          `vi'
3592                Use a `vi'-style line editing interface.  This also
3593                affects the editing interface used for `read -e'.
3594
3595          `xtrace'
3596                Same as `-x'.
3597
3598     `-p'
3599           Turn on privileged mode.  In this mode, the `$BASH_ENV' and
3600           `$ENV' files are not processed, shell functions are not
3601           inherited from the environment, and the `SHELLOPTS',
3602           `BASHOPTS', `CDPATH' and `GLOBIGNORE' variables, if they
3603           appear in the environment, are ignored.  If the shell is
3604           started with the effective user (group) id not equal to the
3605           real user (group) id, and the `-p' option is not supplied,
3606           these actions are taken and the effective user id is set to
3607           the real user id.  If the `-p' option is supplied at startup,
3608           the effective user id is not reset.  Turning this option off
3609           causes the effective user and group ids to be set to the real
3610           user and group ids.
3611
3612     `-t'
3613           Exit after reading and executing one command.
3614
3615     `-u'
3616           Treat unset variables and parameters other than the special
3617           parameters `@' or `*' as an error when performing parameter
3618           expansion.  An error message will be written to the standard
3619           error, and a non-interactive shell will exit.
3620
3621     `-v'
3622           Print shell input lines as they are read.
3623
3624     `-x'
3625           Print a trace of simple commands, `for' commands, `case'
3626           commands, `select' commands, and arithmetic `for' commands
3627           and their arguments or associated word lists after they are
3628           expanded and before they are executed.  The value of the `PS4'
3629           variable is expanded and the resultant value is printed before
3630           the command and its expanded arguments.
3631
3632     `-B'
3633           The shell will perform brace expansion (*note Brace
3634           Expansion::).  This option is on by default.
3635
3636     `-C'
3637           Prevent output redirection using `>', `>&', and `<>' from
3638           overwriting existing files.
3639
3640     `-E'
3641           If set, any trap on `ERR' is inherited by shell functions,
3642           command substitutions, and commands executed in a subshell
3643           environment.  The `ERR' trap is normally not inherited in
3644           such cases.
3645
3646     `-H'
3647           Enable `!' style history substitution (*note History
3648           Interaction::).  This option is on by default for interactive
3649           shells.
3650
3651     `-P'
3652           If set, do not follow symbolic links when performing commands
3653           such as `cd' which change the current directory.  The
3654           physical directory is used instead.  By default, Bash follows
3655           the logical chain of directories when performing commands
3656           which change the current directory.
3657
3658           For example, if `/usr/sys' is a symbolic link to
3659           `/usr/local/sys' then:
3660                $ cd /usr/sys; echo $PWD
3661                /usr/sys
3662                $ cd ..; pwd
3663                /usr
3664
3665           If `set -P' is on, then:
3666                $ cd /usr/sys; echo $PWD
3667                /usr/local/sys
3668                $ cd ..; pwd
3669                /usr/local
3670
3671     `-T'
3672           If set, any trap on `DEBUG' and `RETURN' are inherited by
3673           shell functions, command substitutions, and commands executed
3674           in a subshell environment.  The `DEBUG' and `RETURN' traps
3675           are normally not inherited in such cases.
3676
3677     `--'
3678           If no arguments follow this option, then the positional
3679           parameters are unset.  Otherwise, the positional parameters
3680           are set to the ARGUMENTS, even if some of them begin with a
3681           `-'.
3682
3683     `-'
3684           Signal the end of options, cause all remaining ARGUMENTS to
3685           be assigned to the positional parameters.  The `-x' and `-v'
3686           options are turned off.  If there are no arguments, the
3687           positional parameters remain unchanged.
3688
3689      Using `+' rather than `-' causes these options to be turned off.
3690      The options can also be used upon invocation of the shell.  The
3691      current set of options may be found in `$-'.
3692
3693      The remaining N ARGUMENTS are positional parameters and are
3694      assigned, in order, to `$1', `$2', ...  `$N'.  The special
3695      parameter `#' is set to N.
3696
3697      The return status is always zero unless an invalid option is
3698      supplied.
3699
3700 \1f
3701 File: bashref.info,  Node: The Shopt Builtin,  Prev: The Set Builtin,  Up: Modifying Shell Behavior
3702
3703 4.3.2 The Shopt Builtin
3704 -----------------------
3705
3706 This builtin allows you to change additional shell optional behavior.
3707
3708 `shopt'
3709           shopt [-pqsu] [-o] [OPTNAME ...]
3710      Toggle the values of variables controlling optional shell behavior.
3711      With no options, or with the `-p' option, a list of all settable
3712      options is displayed, with an indication of whether or not each is
3713      set.  The `-p' option causes output to be displayed in a form that
3714      may be reused as input.  Other options have the following meanings:
3715
3716     `-s'
3717           Enable (set) each OPTNAME.
3718
3719     `-u'
3720           Disable (unset) each OPTNAME.
3721
3722     `-q'
3723           Suppresses normal output; the return status indicates whether
3724           the OPTNAME is set or unset.  If multiple OPTNAME arguments
3725           are given with `-q', the return status is zero if all
3726           OPTNAMES are enabled; non-zero otherwise.
3727
3728     `-o'
3729           Restricts the values of OPTNAME to be those defined for the
3730           `-o' option to the `set' builtin (*note The Set Builtin::).
3731
3732      If either `-s' or `-u' is used with no OPTNAME arguments, the
3733      display is limited to those options which are set or unset,
3734      respectively.
3735
3736      Unless otherwise noted, the `shopt' options are disabled (off) by
3737      default.
3738
3739      The return status when listing options is zero if all OPTNAMES are
3740      enabled, non-zero otherwise.  When setting or unsetting options,
3741      the return status is zero unless an OPTNAME is not a valid shell
3742      option.
3743
3744      The list of `shopt' options is:
3745     `autocd'
3746           If set, a command name that is the name of a directory is
3747           executed as if it were the argument to the `cd' command.
3748           This option is only used by interactive shells.
3749
3750     `cdable_vars'
3751           If this is set, an argument to the `cd' builtin command that
3752           is not a directory is assumed to be the name of a variable
3753           whose value is the directory to change to.
3754
3755     `cdspell'
3756           If set, minor errors in the spelling of a directory component
3757           in a `cd' command will be corrected.  The errors checked for
3758           are transposed characters, a missing character, and a
3759           character too many.  If a correction is found, the corrected
3760           path is printed, and the command proceeds.  This option is
3761           only used by interactive shells.
3762
3763     `checkhash'
3764           If this is set, Bash checks that a command found in the hash
3765           table exists before trying to execute it.  If a hashed
3766           command no longer exists, a normal path search is performed.
3767
3768     `checkjobs'
3769           If set, Bash lists the status of any stopped and running jobs
3770           before exiting an interactive shell.  If any jobs are
3771           running, this causes the exit to be deferred until a second
3772           exit is attempted without an intervening command (*note Job
3773           Control::).  The shell always postpones exiting if any jobs
3774           are stopped.
3775
3776     `checkwinsize'
3777           If set, Bash checks the window size after each command and,
3778           if necessary, updates the values of `LINES' and `COLUMNS'.
3779
3780     `cmdhist'
3781           If set, Bash attempts to save all lines of a multiple-line
3782           command in the same history entry.  This allows easy
3783           re-editing of multi-line commands.
3784
3785     `compat31'
3786           If set, Bash changes its behavior to that of version 3.1 with
3787           respect to quoted arguments to the conditional command's =~
3788           operator.
3789
3790     `dirspell'
3791           If set, Bash attempts spelling correction on directory names
3792           during word completion if the directory name initially
3793           supplied does not exist.
3794
3795     `dotglob'
3796           If set, Bash includes filenames beginning with a `.' in the
3797           results of filename expansion.
3798
3799     `execfail'
3800           If this is set, a non-interactive shell will not exit if it
3801           cannot execute the file specified as an argument to the `exec'
3802           builtin command.  An interactive shell does not exit if `exec'
3803           fails.
3804
3805     `expand_aliases'
3806           If set, aliases are expanded as described below under Aliases,
3807           *note Aliases::.  This option is enabled by default for
3808           interactive shells.
3809
3810     `extdebug'
3811           If set, behavior intended for use by debuggers is enabled:
3812
3813             1. The `-F' option to the `declare' builtin (*note Bash
3814                Builtins::) displays the source file name and line
3815                number corresponding to each function name supplied as
3816                an argument.
3817
3818             2. If the command run by the `DEBUG' trap returns a
3819                non-zero value, the next command is skipped and not
3820                executed.
3821
3822             3. If the command run by the `DEBUG' trap returns a value
3823                of 2, and the shell is executing in a subroutine (a
3824                shell function or a shell script executed by the `.' or
3825                `source' builtins), a call to `return' is simulated.
3826
3827             4. `BASH_ARGC' and `BASH_ARGV' are updated as described in
3828                their descriptions (*note Bash Variables::).
3829
3830             5. Function tracing is enabled:  command substitution,
3831                shell functions, and subshells invoked with `( COMMAND
3832                )' inherit the `DEBUG' and `RETURN' traps.
3833
3834             6. Error tracing is enabled:  command substitution, shell
3835                functions, and subshells invoked with `( COMMAND )'
3836                inherit the `ERROR' trap.
3837
3838     `extglob'
3839           If set, the extended pattern matching features described above
3840           (*note Pattern Matching::) are enabled.
3841
3842     `extquote'
3843           If set, `$'STRING'' and `$"STRING"' quoting is performed
3844           within `${PARAMETER}' expansions enclosed in double quotes.
3845           This option is enabled by default.
3846
3847     `failglob'
3848           If set, patterns which fail to match filenames during
3849           filename expansion result in an expansion error.
3850
3851     `force_fignore'
3852           If set, the suffixes specified by the `FIGNORE' shell variable
3853           cause words to be ignored when performing word completion
3854           even if the ignored words are the only possible completions.
3855           *Note Bash Variables::, for a description of `FIGNORE'.  This
3856           option is enabled by default.
3857
3858     `globstar'
3859           If set, the pattern `**' used in a filename expansion context
3860           will match a files and zero or more directories and
3861           subdirectories.  If the pattern is followed by a `/', only
3862           directories and subdirectories match.
3863
3864     `gnu_errfmt'
3865           If set, shell error messages are written in the standard GNU
3866           error message format.
3867
3868     `histappend'
3869           If set, the history list is appended to the file named by the
3870           value of the `HISTFILE' variable when the shell exits, rather
3871           than overwriting the file.
3872
3873     `histreedit'
3874           If set, and Readline is being used, a user is given the
3875           opportunity to re-edit a failed history substitution.
3876
3877     `histverify'
3878           If set, and Readline is being used, the results of history
3879           substitution are not immediately passed to the shell parser.
3880           Instead, the resulting line is loaded into the Readline
3881           editing buffer, allowing further modification.
3882
3883     `hostcomplete'
3884           If set, and Readline is being used, Bash will attempt to
3885           perform hostname completion when a word containing a `@' is
3886           being completed (*note Commands For Completion::).  This
3887           option is enabled by default.
3888
3889     `huponexit'
3890           If set, Bash will send `SIGHUP' to all jobs when an
3891           interactive login shell exits (*note Signals::).
3892
3893     `interactive_comments'
3894           Allow a word beginning with `#' to cause that word and all
3895           remaining characters on that line to be ignored in an
3896           interactive shell.  This option is enabled by default.
3897
3898     `lithist'
3899           If enabled, and the `cmdhist' option is enabled, multi-line
3900           commands are saved to the history with embedded newlines
3901           rather than using semicolon separators where possible.
3902
3903     `login_shell'
3904           The shell sets this option if it is started as a login shell
3905           (*note Invoking Bash::).  The value may not be changed.
3906
3907     `mailwarn'
3908           If set, and a file that Bash is checking for mail has been
3909           accessed since the last time it was checked, the message
3910           `"The mail in MAILFILE has been read"' is displayed.
3911
3912     `no_empty_cmd_completion'
3913           If set, and Readline is being used, Bash will not attempt to
3914           search the `PATH' for possible completions when completion is
3915           attempted on an empty line.
3916
3917     `nocaseglob'
3918           If set, Bash matches filenames in a case-insensitive fashion
3919           when performing filename expansion.
3920
3921     `nocasematch'
3922           If set, Bash matches patterns in a case-insensitive fashion
3923           when performing matching while executing `case' or `[['
3924           conditional commands.
3925
3926     `nullglob'
3927           If set, Bash allows filename patterns which match no files to
3928           expand to a null string, rather than themselves.
3929
3930     `progcomp'
3931           If set, the programmable completion facilities (*note
3932           Programmable Completion::) are enabled.  This option is
3933           enabled by default.
3934
3935     `promptvars'
3936           If set, prompt strings undergo parameter expansion, command
3937           substitution, arithmetic expansion, and quote removal after
3938           being expanded as described below (*note Printing a Prompt::).
3939           This option is enabled by default.
3940
3941     `restricted_shell'
3942           The shell sets this option if it is started in restricted mode
3943           (*note The Restricted Shell::).  The value may not be changed.
3944           This is not reset when the startup files are executed,
3945           allowing the startup files to discover whether or not a shell
3946           is restricted.
3947
3948     `shift_verbose'
3949           If this is set, the `shift' builtin prints an error message
3950           when the shift count exceeds the number of positional
3951           parameters.
3952
3953     `sourcepath'
3954           If set, the `source' builtin uses the value of `PATH' to find
3955           the directory containing the file supplied as an argument.
3956           This option is enabled by default.
3957
3958     `xpg_echo'
3959           If set, the `echo' builtin expands backslash-escape sequences
3960           by default.
3961
3962
3963      The return status when listing options is zero if all OPTNAMES are
3964      enabled, non-zero otherwise.  When setting or unsetting options,
3965      the return status is zero unless an OPTNAME is not a valid shell
3966      option.
3967
3968
3969 \1f
3970 File: bashref.info,  Node: Special Builtins,  Prev: Modifying Shell Behavior,  Up: Shell Builtin Commands
3971
3972 4.4 Special Builtins
3973 ====================
3974
3975 For historical reasons, the POSIX standard has classified several
3976 builtin commands as _special_.  When Bash is executing in POSIX mode,
3977 the special builtins differ from other builtin commands in three
3978 respects:
3979
3980   1. Special builtins are found before shell functions during command
3981      lookup.
3982
3983   2. If a special builtin returns an error status, a non-interactive
3984      shell exits.
3985
3986   3. Assignment statements preceding the command stay in effect in the
3987      shell environment after the command completes.
3988
3989    When Bash is not executing in POSIX mode, these builtins behave no
3990 differently than the rest of the Bash builtin commands.  The Bash POSIX
3991 mode is described in *note Bash POSIX Mode::.
3992
3993    These are the POSIX special builtins:
3994      break : . continue eval exec exit export readonly return set
3995      shift trap unset
3996
3997 \1f
3998 File: bashref.info,  Node: Shell Variables,  Next: Bash Features,  Prev: Shell Builtin Commands,  Up: Top
3999
4000 5 Shell Variables
4001 *****************
4002
4003 * Menu:
4004
4005 * Bourne Shell Variables::      Variables which Bash uses in the same way
4006                                 as the Bourne Shell.
4007 * Bash Variables::              List of variables that exist in Bash.
4008
4009    This chapter describes the shell variables that Bash uses.  Bash
4010 automatically assigns default values to a number of variables.
4011
4012 \1f
4013 File: bashref.info,  Node: Bourne Shell Variables,  Next: Bash Variables,  Up: Shell Variables
4014
4015 5.1 Bourne Shell Variables
4016 ==========================
4017
4018 Bash uses certain shell variables in the same way as the Bourne shell.
4019 In some cases, Bash assigns a default value to the variable.
4020
4021 `CDPATH'
4022      A colon-separated list of directories used as a search path for
4023      the `cd' builtin command.
4024
4025 `HOME'
4026      The current user's home directory; the default for the `cd' builtin
4027      command.  The value of this variable is also used by tilde
4028      expansion (*note Tilde Expansion::).
4029
4030 `IFS'
4031      A list of characters that separate fields; used when the shell
4032      splits words as part of expansion.
4033
4034 `MAIL'
4035      If this parameter is set to a filename and the `MAILPATH' variable
4036      is not set, Bash informs the user of the arrival of mail in the
4037      specified file.
4038
4039 `MAILPATH'
4040      A colon-separated list of filenames which the shell periodically
4041      checks for new mail.  Each list entry can specify the message that
4042      is printed when new mail arrives in the mail file by separating
4043      the file name from the message with a `?'.  When used in the text
4044      of the message, `$_' expands to the name of the current mail file.
4045
4046 `OPTARG'
4047      The value of the last option argument processed by the `getopts'
4048      builtin.
4049
4050 `OPTIND'
4051      The index of the last option argument processed by the `getopts'
4052      builtin.
4053
4054 `PATH'
4055      A colon-separated list of directories in which the shell looks for
4056      commands.  A zero-length (null) directory name in the value of
4057      `PATH' indicates the current directory.  A null directory name may
4058      appear as two adjacent colons, or as an initial or trailing colon.
4059
4060 `PS1'
4061      The primary prompt string.  The default value is `\s-\v\$ '.
4062      *Note Printing a Prompt::, for the complete list of escape
4063      sequences that are expanded before `PS1' is displayed.
4064
4065 `PS2'
4066      The secondary prompt string.  The default value is `> '.
4067
4068
4069 \1f
4070 File: bashref.info,  Node: Bash Variables,  Prev: Bourne Shell Variables,  Up: Shell Variables
4071
4072 5.2 Bash Variables
4073 ==================
4074
4075 These variables are set or used by Bash, but other shells do not
4076 normally treat them specially.
4077
4078    A few variables used by Bash are described in different chapters:
4079 variables for controlling the job control facilities (*note Job Control
4080 Variables::).
4081
4082 `BASH'
4083      The full pathname used to execute the current instance of Bash.
4084
4085 `BASHOPTS'
4086      A colon-separated list of enabled shell options.  Each word in the
4087      list is a valid argument for the `-s' option to the `shopt'
4088      builtin command (*note The Shopt Builtin::).  The options
4089      appearing in `BASHOPTS' are those reported as `on' by `shopt'.  If
4090      this variable is in the environment when Bash starts up, each
4091      shell option in the list will be enabled before reading any
4092      startup files.  This variable is readonly.
4093
4094 `BASHPID'
4095      Expands to the process id of the current Bash process.  This
4096      differs from `$$' under certain circumstances, such as subshells
4097      that do not require Bash to be re-initialized.
4098
4099 `BASH_ALIASES'
4100      An associative array variable whose members correspond to the
4101      internal list of aliases as maintained by the `alias' builtin
4102      (*note Bourne Shell Builtins::).  Elements added to this array
4103      appear in the alias list; unsetting array elements cause aliases
4104      to be removed from the alias list.
4105
4106 `BASH_ARGC'
4107      An array variable whose values are the number of parameters in each
4108      frame of the current bash execution call stack.  The number of
4109      parameters to the current subroutine (shell function or script
4110      executed with `.' or `source') is at the top of the stack.  When a
4111      subroutine is executed, the number of parameters passed is pushed
4112      onto `BASH_ARGC'.  The shell sets `BASH_ARGC' only when in
4113      extended debugging mode (see *note The Shopt Builtin:: for a
4114      description of the `extdebug' option to the `shopt' builtin).
4115
4116 `BASH_ARGV'
4117      An array variable containing all of the parameters in the current
4118      bash execution call stack.  The final parameter of the last
4119      subroutine call is at the top of the stack; the first parameter of
4120      the initial call is at the bottom.  When a subroutine is executed,
4121      the parameters supplied are pushed onto `BASH_ARGV'.  The shell
4122      sets `BASH_ARGV' only when in extended debugging mode (see *note
4123      The Shopt Builtin:: for a description of the `extdebug' option to
4124      the `shopt' builtin).
4125
4126 `BASH_CMDS'
4127      An associative array variable whose members correspond to the
4128      internal hash table of commands as maintained by the `hash' builtin
4129      (*note Bourne Shell Builtins::).  Elements added to this array
4130      appear in the hash table; unsetting array elements cause commands
4131      to be removed from the hash table.
4132
4133 `BASH_COMMAND'
4134      The command currently being executed or about to be executed,
4135      unless the shell is executing a command as the result of a trap,
4136      in which case it is the command executing at the time of the trap.
4137
4138 `BASH_ENV'
4139      If this variable is set when Bash is invoked to execute a shell
4140      script, its value is expanded and used as the name of a startup
4141      file to read before executing the script.  *Note Bash Startup
4142      Files::.
4143
4144 `BASH_EXECUTION_STRING'
4145      The command argument to the `-c' invocation option.
4146
4147 `BASH_LINENO'
4148      An array variable whose members are the line numbers in source
4149      files corresponding to each member of FUNCNAME.
4150      `${BASH_LINENO[$i]}' is the line number in the source file where
4151      `${FUNCNAME[$i]}' was called (or `${BASH_LINENO[$i-1]}' if
4152      referenced within another shell function).  The corresponding
4153      source file name is `${BASH_SOURCE[$i]}'.  Use `LINENO' to obtain
4154      the current line number.
4155
4156 `BASH_REMATCH'
4157      An array variable whose members are assigned by the `=~' binary
4158      operator to the `[[' conditional command (*note Conditional
4159      Constructs::).  The element with index 0 is the portion of the
4160      string matching the entire regular expression.  The element with
4161      index N is the portion of the string matching the Nth
4162      parenthesized subexpression.  This variable is read-only.
4163
4164 `BASH_SOURCE'
4165      An array variable whose members are the source filenames
4166      corresponding to the elements in the `FUNCNAME' array variable.
4167
4168 `BASH_SUBSHELL'
4169      Incremented by one each time a subshell or subshell environment is
4170      spawned.  The initial value is 0.
4171
4172 `BASH_VERSINFO'
4173      A readonly array variable (*note Arrays::) whose members hold
4174      version information for this instance of Bash.  The values
4175      assigned to the array members are as follows:
4176
4177     `BASH_VERSINFO[0]'
4178           The major version number (the RELEASE).
4179
4180     `BASH_VERSINFO[1]'
4181           The minor version number (the VERSION).
4182
4183     `BASH_VERSINFO[2]'
4184           The patch level.
4185
4186     `BASH_VERSINFO[3]'
4187           The build version.
4188
4189     `BASH_VERSINFO[4]'
4190           The release status (e.g., BETA1).
4191
4192     `BASH_VERSINFO[5]'
4193           The value of `MACHTYPE'.
4194
4195
4196 `BASH_VERSION'
4197      The version number of the current instance of Bash.
4198
4199 `BASH_XTRACEFD'
4200      If set to an integer corresponding to a valid file descriptor, Bash
4201      will write the trace output generated when `set -x' is enabled to
4202      that file descriptor.  This allows tracing output to be separated
4203      from diagnostic and error messages.  The file descriptor is closed
4204      when `BASH_XTRACEFD' is unset or assigned a new value.  Unsetting
4205      `BASH_XTRACEFD' or assigning it the empty string causes the trace
4206      output to be sent to the standard error.  Note that setting
4207      `BASH_XTRACEFD' to 2 (the standard error file descriptor) and then
4208      unsetting it will result in the standard error being closed.
4209
4210 `COLUMNS'
4211      Used by the `select' builtin command to determine the terminal
4212      width when printing selection lists.  Automatically set upon
4213      receipt of a `SIGWINCH'.
4214
4215 `COMP_CWORD'
4216      An index into `${COMP_WORDS}' of the word containing the current
4217      cursor position.  This variable is available only in shell
4218      functions invoked by the programmable completion facilities (*note
4219      Programmable Completion::).
4220
4221 `COMP_LINE'
4222      The current command line.  This variable is available only in
4223      shell functions and external commands invoked by the programmable
4224      completion facilities (*note Programmable Completion::).
4225
4226 `COMP_POINT'
4227      The index of the current cursor position relative to the beginning
4228      of the current command.  If the current cursor position is at the
4229      end of the current command, the value of this variable is equal to
4230      `${#COMP_LINE}'.  This variable is available only in shell
4231      functions and external commands invoked by the programmable
4232      completion facilities (*note Programmable Completion::).
4233
4234 `COMP_TYPE'
4235      Set to an integer value corresponding to the type of completion
4236      attempted that caused a completion function to be called: TAB, for
4237      normal completion, `?', for listing completions after successive
4238      tabs, `!', for listing alternatives on partial word completion,
4239      `@', to list completions if the word is not unmodified, or `%',
4240      for menu completion.  This variable is available only in shell
4241      functions and external commands invoked by the programmable
4242      completion facilities (*note Programmable Completion::).
4243
4244 `COMP_KEY'
4245      The key (or final key of a key sequence) used to invoke the current
4246      completion function.
4247
4248 `COMP_WORDBREAKS'
4249      The set of characters that the Readline library treats as word
4250      separators when performing word completion.  If `COMP_WORDBREAKS'
4251      is unset, it loses its special properties, even if it is
4252      subsequently reset.
4253
4254 `COMP_WORDS'
4255      An array variable consisting of the individual words in the
4256      current command line.  The line is split into words as Readline
4257      would split it, using `COMP_WORDBREAKS' as described above.  This
4258      variable is available only in shell functions invoked by the
4259      programmable completion facilities (*note Programmable
4260      Completion::).
4261
4262 `COMPREPLY'
4263      An array variable from which Bash reads the possible completions
4264      generated by a shell function invoked by the programmable
4265      completion facility (*note Programmable Completion::).
4266
4267 `DIRSTACK'
4268      An array variable containing the current contents of the directory
4269      stack.  Directories appear in the stack in the order they are
4270      displayed by the `dirs' builtin.  Assigning to members of this
4271      array variable may be used to modify directories already in the
4272      stack, but the `pushd' and `popd' builtins must be used to add and
4273      remove directories.  Assignment to this variable will not change
4274      the current directory.  If `DIRSTACK' is unset, it loses its
4275      special properties, even if it is subsequently reset.
4276
4277 `EMACS'
4278      If Bash finds this variable in the environment when the shell
4279      starts with value `t', it assumes that the shell is running in an
4280      emacs shell buffer and disables line editing.
4281
4282 `EUID'
4283      The numeric effective user id of the current user.  This variable
4284      is readonly.
4285
4286 `FCEDIT'
4287      The editor used as a default by the `-e' option to the `fc'
4288      builtin command.
4289
4290 `FIGNORE'
4291      A colon-separated list of suffixes to ignore when performing
4292      filename completion.  A file name whose suffix matches one of the
4293      entries in `FIGNORE' is excluded from the list of matched file
4294      names.  A sample value is `.o:~'
4295
4296 `FUNCNAME'
4297      An array variable containing the names of all shell functions
4298      currently in the execution call stack.  The element with index 0
4299      is the name of any currently-executing shell function.  The
4300      bottom-most element is `"main"'.  This variable exists only when a
4301      shell function is executing.  Assignments to `FUNCNAME' have no
4302      effect and return an error status.  If `FUNCNAME' is unset, it
4303      loses its special properties, even if it is subsequently reset.
4304
4305 `GLOBIGNORE'
4306      A colon-separated list of patterns defining the set of filenames to
4307      be ignored by filename expansion.  If a filename matched by a
4308      filename expansion pattern also matches one of the patterns in
4309      `GLOBIGNORE', it is removed from the list of matches.
4310
4311 `GROUPS'
4312      An array variable containing the list of groups of which the
4313      current user is a member.  Assignments to `GROUPS' have no effect
4314      and return an error status.  If `GROUPS' is unset, it loses its
4315      special properties, even if it is subsequently reset.
4316
4317 `histchars'
4318      Up to three characters which control history expansion, quick
4319      substitution, and tokenization (*note History Interaction::).  The
4320      first character is the HISTORY EXPANSION character, that is, the
4321      character which signifies the start of a history expansion,
4322      normally `!'.  The second character is the character which
4323      signifies `quick substitution' when seen as the first character on
4324      a line, normally `^'.  The optional third character is the
4325      character which indicates that the remainder of the line is a
4326      comment when found as the first character of a word, usually `#'.
4327      The history comment character causes history substitution to be
4328      skipped for the remaining words on the line.  It does not
4329      necessarily cause the shell parser to treat the rest of the line
4330      as a comment.
4331
4332 `HISTCMD'
4333      The history number, or index in the history list, of the current
4334      command.  If `HISTCMD' is unset, it loses its special properties,
4335      even if it is subsequently reset.
4336
4337 `HISTCONTROL'
4338      A colon-separated list of values controlling how commands are
4339      saved on the history list.  If the list of values includes
4340      `ignorespace', lines which begin with a space character are not
4341      saved in the history list.  A value of `ignoredups' causes lines
4342      which match the previous history entry to not be saved.  A value
4343      of `ignoreboth' is shorthand for `ignorespace' and `ignoredups'.
4344      A value of `erasedups' causes all previous lines matching the
4345      current line to be removed from the history list before that line
4346      is saved.  Any value not in the above list is ignored.  If
4347      `HISTCONTROL' is unset, or does not include a valid value, all
4348      lines read by the shell parser are saved on the history list,
4349      subject to the value of `HISTIGNORE'.  The second and subsequent
4350      lines of a multi-line compound command are not tested, and are
4351      added to the history regardless of the value of `HISTCONTROL'.
4352
4353 `HISTFILE'
4354      The name of the file to which the command history is saved.  The
4355      default value is `~/.bash_history'.
4356
4357 `HISTFILESIZE'
4358      The maximum number of lines contained in the history file.  When
4359      this variable is assigned a value, the history file is truncated,
4360      if necessary, by removing the oldest entries, to contain no more
4361      than that number of lines.  The history file is also truncated to
4362      this size after writing it when an interactive shell exits.  The
4363      default value is 500.
4364
4365 `HISTIGNORE'
4366      A colon-separated list of patterns used to decide which command
4367      lines should be saved on the history list.  Each pattern is
4368      anchored at the beginning of the line and must match the complete
4369      line (no implicit `*' is appended).  Each pattern is tested
4370      against the line after the checks specified by `HISTCONTROL' are
4371      applied.  In addition to the normal shell pattern matching
4372      characters, `&' matches the previous history line.  `&' may be
4373      escaped using a backslash; the backslash is removed before
4374      attempting a match.  The second and subsequent lines of a
4375      multi-line compound command are not tested, and are added to the
4376      history regardless of the value of `HISTIGNORE'.
4377
4378      `HISTIGNORE' subsumes the function of `HISTCONTROL'.  A pattern of
4379      `&' is identical to `ignoredups', and a pattern of `[ ]*' is
4380      identical to `ignorespace'.  Combining these two patterns,
4381      separating them with a colon, provides the functionality of
4382      `ignoreboth'.
4383
4384 `HISTSIZE'
4385      The maximum number of commands to remember on the history list.
4386      The default value is 500.
4387
4388 `HISTTIMEFORMAT'
4389      If this variable is set and not null, its value is used as a
4390      format string for STRFTIME to print the time stamp associated with
4391      each history entry displayed by the `history' builtin.  If this
4392      variable is set, time stamps are written to the history file so
4393      they may be preserved across shell sessions.  This uses the
4394      history comment character to distinguish timestamps from other
4395      history lines.
4396
4397 `HOSTFILE'
4398      Contains the name of a file in the same format as `/etc/hosts' that
4399      should be read when the shell needs to complete a hostname.  The
4400      list of possible hostname completions may be changed while the
4401      shell is running; the next time hostname completion is attempted
4402      after the value is changed, Bash adds the contents of the new file
4403      to the existing list.  If `HOSTFILE' is set, but has no value, or
4404      does not name a readable file, Bash attempts to read `/etc/hosts'
4405      to obtain the list of possible hostname completions.  When
4406      `HOSTFILE' is unset, the hostname list is cleared.
4407
4408 `HOSTNAME'
4409      The name of the current host.
4410
4411 `HOSTTYPE'
4412      A string describing the machine Bash is running on.
4413
4414 `IGNOREEOF'
4415      Controls the action of the shell on receipt of an `EOF' character
4416      as the sole input.  If set, the value denotes the number of
4417      consecutive `EOF' characters that can be read as the first
4418      character on an input line before the shell will exit.  If the
4419      variable exists but does not have a numeric value (or has no
4420      value) then the default is 10.  If the variable does not exist,
4421      then `EOF' signifies the end of input to the shell.  This is only
4422      in effect for interactive shells.
4423
4424 `INPUTRC'
4425      The name of the Readline initialization file, overriding the
4426      default of `~/.inputrc'.
4427
4428 `LANG'
4429      Used to determine the locale category for any category not
4430      specifically selected with a variable starting with `LC_'.
4431
4432 `LC_ALL'
4433      This variable overrides the value of `LANG' and any other `LC_'
4434      variable specifying a locale category.
4435
4436 `LC_COLLATE'
4437      This variable determines the collation order used when sorting the
4438      results of filename expansion, and determines the behavior of
4439      range expressions, equivalence classes, and collating sequences
4440      within filename expansion and pattern matching (*note Filename
4441      Expansion::).
4442
4443 `LC_CTYPE'
4444      This variable determines the interpretation of characters and the
4445      behavior of character classes within filename expansion and pattern
4446      matching (*note Filename Expansion::).
4447
4448 `LC_MESSAGES'
4449      This variable determines the locale used to translate double-quoted
4450      strings preceded by a `$' (*note Locale Translation::).
4451
4452 `LC_NUMERIC'
4453      This variable determines the locale category used for number
4454      formatting.
4455
4456 `LINENO'
4457      The line number in the script or shell function currently
4458      executing.
4459
4460 `LINES'
4461      Used by the `select' builtin command to determine the column length
4462      for printing selection lists.  Automatically set upon receipt of a
4463      `SIGWINCH'.
4464
4465 `MACHTYPE'
4466      A string that fully describes the system type on which Bash is
4467      executing, in the standard GNU CPU-COMPANY-SYSTEM format.
4468
4469 `MAILCHECK'
4470      How often (in seconds) that the shell should check for mail in the
4471      files specified in the `MAILPATH' or `MAIL' variables.  The
4472      default is 60 seconds.  When it is time to check for mail, the
4473      shell does so before displaying the primary prompt.  If this
4474      variable is unset, or set to a value that is not a number greater
4475      than or equal to zero, the shell disables mail checking.
4476
4477 `OLDPWD'
4478      The previous working directory as set by the `cd' builtin.
4479
4480 `OPTERR'
4481      If set to the value 1, Bash displays error messages generated by
4482      the `getopts' builtin command.
4483
4484 `OSTYPE'
4485      A string describing the operating system Bash is running on.
4486
4487 `PIPESTATUS'
4488      An array variable (*note Arrays::) containing a list of exit
4489      status values from the processes in the most-recently-executed
4490      foreground pipeline (which may contain only a single command).
4491
4492 `POSIXLY_CORRECT'
4493      If this variable is in the environment when `bash' starts, the
4494      shell enters POSIX mode (*note Bash POSIX Mode::) before reading
4495      the startup files, as if the `--posix' invocation option had been
4496      supplied.  If it is set while the shell is running, `bash' enables
4497      POSIX mode, as if the command
4498           `set -o posix'
4499      had been executed.
4500
4501 `PPID'
4502      The process ID of the shell's parent process.  This variable is
4503      readonly.
4504
4505 `PROMPT_COMMAND'
4506      If set, the value is interpreted as a command to execute before
4507      the printing of each primary prompt (`$PS1').
4508
4509 `PROMPT_DIRTRIM'
4510      If set to a number greater than zero, the value is used as the
4511      number of trailing directory components to retain when expanding
4512      the `\w' and `\W' prompt string escapes (*note Printing a
4513      Prompt::).  Characters removed are replaced with an ellipsis.
4514
4515 `PS3'
4516      The value of this variable is used as the prompt for the `select'
4517      command.  If this variable is not set, the `select' command
4518      prompts with `#? '
4519
4520 `PS4'
4521      The value is the prompt printed before the command line is echoed
4522      when the `-x' option is set (*note The Set Builtin::).  The first
4523      character of `PS4' is replicated multiple times, as necessary, to
4524      indicate multiple levels of indirection.  The default is `+ '.
4525
4526 `PWD'
4527      The current working directory as set by the `cd' builtin.
4528
4529 `RANDOM'
4530      Each time this parameter is referenced, a random integer between 0
4531      and 32767 is generated.  Assigning a value to this variable seeds
4532      the random number generator.
4533
4534 `REPLY'
4535      The default variable for the `read' builtin.
4536
4537 `SECONDS'
4538      This variable expands to the number of seconds since the shell was
4539      started.  Assignment to this variable resets the count to the
4540      value assigned, and the expanded value becomes the value assigned
4541      plus the number of seconds since the assignment.
4542
4543 `SHELL'
4544      The full pathname to the shell is kept in this environment
4545      variable.  If it is not set when the shell starts, Bash assigns to
4546      it the full pathname of the current user's login shell.
4547
4548 `SHELLOPTS'
4549      A colon-separated list of enabled shell options.  Each word in the
4550      list is a valid argument for the `-o' option to the `set' builtin
4551      command (*note The Set Builtin::).  The options appearing in
4552      `SHELLOPTS' are those reported as `on' by `set -o'.  If this
4553      variable is in the environment when Bash starts up, each shell
4554      option in the list will be enabled before reading any startup
4555      files.  This variable is readonly.
4556
4557 `SHLVL'
4558      Incremented by one each time a new instance of Bash is started.
4559      This is intended to be a count of how deeply your Bash shells are
4560      nested.
4561
4562 `TIMEFORMAT'
4563      The value of this parameter is used as a format string specifying
4564      how the timing information for pipelines prefixed with the `time'
4565      reserved word should be displayed.  The `%' character introduces an
4566      escape sequence that is expanded to a time value or other
4567      information.  The escape sequences and their meanings are as
4568      follows; the braces denote optional portions.
4569
4570     `%%'
4571           A literal `%'.
4572
4573     `%[P][l]R'
4574           The elapsed time in seconds.
4575
4576     `%[P][l]U'
4577           The number of CPU seconds spent in user mode.
4578
4579     `%[P][l]S'
4580           The number of CPU seconds spent in system mode.
4581
4582     `%P'
4583           The CPU percentage, computed as (%U + %S) / %R.
4584
4585      The optional P is a digit specifying the precision, the number of
4586      fractional digits after a decimal point.  A value of 0 causes no
4587      decimal point or fraction to be output.  At most three places
4588      after the decimal point may be specified; values of P greater than
4589      3 are changed to 3.  If P is not specified, the value 3 is used.
4590
4591      The optional `l' specifies a longer format, including minutes, of
4592      the form MMmSS.FFs.  The value of P determines whether or not the
4593      fraction is included.
4594
4595      If this variable is not set, Bash acts as if it had the value
4596           `$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS''
4597      If the value is null, no timing information is displayed.  A
4598      trailing newline is added when the format string is displayed.
4599
4600 `TMOUT'
4601      If set to a value greater than zero, `TMOUT' is treated as the
4602      default timeout for the `read' builtin (*note Bash Builtins::).
4603      The `select' command (*note Conditional Constructs::) terminates
4604      if input does not arrive after `TMOUT' seconds when input is coming
4605      from a terminal.
4606
4607      In an interactive shell, the value is interpreted as the number of
4608      seconds to wait for input after issuing the primary prompt when
4609      the shell is interactive.  Bash terminates after that number of
4610      seconds if input does not arrive.
4611
4612 `TMPDIR'
4613      If set, Bash uses its value as the name of a directory in which
4614      Bash creates temporary files for the shell's use.
4615
4616 `UID'
4617      The numeric real user id of the current user.  This variable is
4618      readonly.
4619
4620
4621 \1f
4622 File: bashref.info,  Node: Bash Features,  Next: Job Control,  Prev: Shell Variables,  Up: Top
4623
4624 6 Bash Features
4625 ***************
4626
4627 This section describes features unique to Bash.
4628
4629 * Menu:
4630
4631 * Invoking Bash::               Command line options that you can give
4632                                 to Bash.
4633 * Bash Startup Files::          When and how Bash executes scripts.
4634 * Interactive Shells::          What an interactive shell is.
4635 * Bash Conditional Expressions::        Primitives used in composing expressions for
4636                                 the `test' builtin.
4637 * Shell Arithmetic::            Arithmetic on shell variables.
4638 * Aliases::                     Substituting one command for another.
4639 * Arrays::                      Array Variables.
4640 * The Directory Stack::         History of visited directories.
4641 * Printing a Prompt::           Controlling the PS1 string.
4642 * The Restricted Shell::        A more controlled mode of shell execution.
4643 * Bash POSIX Mode::             Making Bash behave more closely to what
4644                                 the POSIX standard specifies.
4645
4646 \1f
4647 File: bashref.info,  Node: Invoking Bash,  Next: Bash Startup Files,  Up: Bash Features
4648
4649 6.1 Invoking Bash
4650 =================
4651
4652      bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] [ARGUMENT ...]
4653      bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] -c STRING [ARGUMENT ...]
4654      bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] [ARGUMENT ...]
4655
4656    In addition to the single-character shell command-line options
4657 (*note The Set Builtin::), there are several multi-character options
4658 that you can use.  These options must appear on the command line before
4659 the single-character options to be recognized.
4660
4661 `--debugger'
4662      Arrange for the debugger profile to be executed before the shell
4663      starts.  Turns on extended debugging mode (see *note The Shopt
4664      Builtin:: for a description of the `extdebug' option to the `shopt'
4665      builtin) and shell function tracing (see *note The Set Builtin::
4666      for a description of the `-o functrace' option).
4667
4668 `--dump-po-strings'
4669      A list of all double-quoted strings preceded by `$' is printed on
4670      the standard output in the GNU `gettext' PO (portable object) file
4671      format.  Equivalent to `-D' except for the output format.
4672
4673 `--dump-strings'
4674      Equivalent to `-D'.
4675
4676 `--help'
4677      Display a usage message on standard output and exit successfully.
4678
4679 `--init-file FILENAME'
4680 `--rcfile FILENAME'
4681      Execute commands from FILENAME (instead of `~/.bashrc') in an
4682      interactive shell.
4683
4684 `--login'
4685      Equivalent to `-l'.
4686
4687 `--noediting'
4688      Do not use the GNU Readline library (*note Command Line Editing::)
4689      to read  command lines when the shell is interactive.
4690
4691 `--noprofile'
4692      Don't load the system-wide startup file `/etc/profile' or any of
4693      the personal initialization files `~/.bash_profile',
4694      `~/.bash_login', or `~/.profile' when Bash is invoked as a login
4695      shell.
4696
4697 `--norc'
4698      Don't read the `~/.bashrc' initialization file in an interactive
4699      shell.  This is on by default if the shell is invoked as `sh'.
4700
4701 `--posix'
4702      Change the behavior of Bash where the default operation differs
4703      from the POSIX standard to match the standard.  This is intended
4704      to make Bash behave as a strict superset of that standard.  *Note
4705      Bash POSIX Mode::, for a description of the Bash POSIX mode.
4706
4707 `--restricted'
4708      Make the shell a restricted shell (*note The Restricted Shell::).
4709
4710 `--verbose'
4711      Equivalent to `-v'.  Print shell input lines as they're read.
4712
4713 `--version'
4714      Show version information for this instance of Bash on the standard
4715      output and exit successfully.
4716
4717
4718    There are several single-character options that may be supplied at
4719 invocation which are not available with the `set' builtin.
4720
4721 `-c STRING'
4722      Read and execute commands from STRING after processing the
4723      options, then exit.  Any remaining arguments are assigned to the
4724      positional parameters, starting with `$0'.
4725
4726 `-i'
4727      Force the shell to run interactively.  Interactive shells are
4728      described in *note Interactive Shells::.
4729
4730 `-l'
4731      Make this shell act as if it had been directly invoked by login.
4732      When the shell is interactive, this is equivalent to starting a
4733      login shell with `exec -l bash'.  When the shell is not
4734      interactive, the login shell startup files will be executed.
4735      `exec bash -l' or `exec bash --login' will replace the current
4736      shell with a Bash login shell.  *Note Bash Startup Files::, for a
4737      description of the special behavior of a login shell.
4738
4739 `-r'
4740      Make the shell a restricted shell (*note The Restricted Shell::).
4741
4742 `-s'
4743      If this option is present, or if no arguments remain after option
4744      processing, then commands are read from the standard input.  This
4745      option allows the positional parameters to be set when invoking an
4746      interactive shell.
4747
4748 `-D'
4749      A list of all double-quoted strings preceded by `$' is printed on
4750      the standard output.  These are the strings that are subject to
4751      language translation when the current locale is not `C' or `POSIX'
4752      (*note Locale Translation::).  This implies the `-n' option; no
4753      commands will be executed.
4754
4755 `[-+]O [SHOPT_OPTION]'
4756      SHOPT_OPTION is one of the shell options accepted by the `shopt'
4757      builtin (*note The Shopt Builtin::).  If SHOPT_OPTION is present,
4758      `-O' sets the value of that option; `+O' unsets it.  If
4759      SHOPT_OPTION is not supplied, the names and values of the shell
4760      options accepted by `shopt' are printed on the standard output.
4761      If the invocation option is `+O', the output is displayed in a
4762      format that may be reused as input.
4763
4764 `--'
4765      A `--' signals the end of options and disables further option
4766      processing.  Any arguments after the `--' are treated as filenames
4767      and arguments.
4768
4769
4770    A _login_ shell is one whose first character of argument zero is
4771 `-', or one invoked with the `--login' option.
4772
4773    An _interactive_ shell is one started without non-option arguments,
4774 unless `-s' is specified, without specifying the `-c' option, and whose
4775 input and output are both connected to terminals (as determined by
4776 `isatty(3)'), or one started with the `-i' option.  *Note Interactive
4777 Shells::, for more information.
4778
4779    If arguments remain after option processing, and neither the `-c'
4780 nor the `-s' option has been supplied, the first argument is assumed to
4781 be the name of a file containing shell commands (*note Shell Scripts::).
4782 When Bash is invoked in this fashion, `$0' is set to the name of the
4783 file, and the positional parameters are set to the remaining arguments.
4784 Bash reads and executes commands from this file, then exits.  Bash's
4785 exit status is the exit status of the last command executed in the
4786 script.  If no commands are executed, the exit status is 0.
4787
4788 \1f
4789 File: bashref.info,  Node: Bash Startup Files,  Next: Interactive Shells,  Prev: Invoking Bash,  Up: Bash Features
4790
4791 6.2 Bash Startup Files
4792 ======================
4793
4794 This section describes how Bash executes its startup files.  If any of
4795 the files exist but cannot be read, Bash reports an error.  Tildes are
4796 expanded in file names as described above under Tilde Expansion (*note
4797 Tilde Expansion::).
4798
4799    Interactive shells are described in *note Interactive Shells::.
4800
4801 Invoked as an interactive login shell, or with `--login'
4802 ........................................................
4803
4804 When Bash is invoked as an interactive login shell, or as a
4805 non-interactive shell with the `--login' option, it first reads and
4806 executes commands from the file `/etc/profile', if that file exists.
4807 After reading that file, it looks for `~/.bash_profile',
4808 `~/.bash_login', and `~/.profile', in that order, and reads and
4809 executes commands from the first one that exists and is readable.  The
4810 `--noprofile' option may be used when the shell is started to inhibit
4811 this behavior.
4812
4813    When a login shell exits, Bash reads and executes commands from the
4814 file `~/.bash_logout', if it exists.
4815
4816 Invoked as an interactive non-login shell
4817 .........................................
4818
4819 When an interactive shell that is not a login shell is started, Bash
4820 reads and executes commands from `~/.bashrc', if that file exists.
4821 This may be inhibited by using the `--norc' option.  The `--rcfile
4822 FILE' option will force Bash to read and execute commands from FILE
4823 instead of `~/.bashrc'.
4824
4825    So, typically, your `~/.bash_profile' contains the line
4826      `if [ -f ~/.bashrc ]; then . ~/.bashrc; fi'
4827    after (or before) any login-specific initializations.
4828
4829 Invoked non-interactively
4830 .........................
4831
4832 When Bash is started non-interactively, to run a shell script, for
4833 example, it looks for the variable `BASH_ENV' in the environment,
4834 expands its value if it appears there, and uses the expanded value as
4835 the name of a file to read and execute.  Bash behaves as if the
4836 following command were executed:
4837      `if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi'
4838    but the value of the `PATH' variable is not used to search for the
4839 file name.
4840
4841    As noted above, if a non-interactive shell is invoked with the
4842 `--login' option, Bash attempts to read and execute commands from the
4843 login shell startup files.
4844
4845 Invoked with name `sh'
4846 ......................
4847
4848 If Bash is invoked with the name `sh', it tries to mimic the startup
4849 behavior of historical versions of `sh' as closely as possible, while
4850 conforming to the POSIX standard as well.
4851
4852    When invoked as an interactive login shell, or as a non-interactive
4853 shell with the `--login' option, it first attempts to read and execute
4854 commands from `/etc/profile' and `~/.profile', in that order.  The
4855 `--noprofile' option may be used to inhibit this behavior.  When
4856 invoked as an interactive shell with the name `sh', Bash looks for the
4857 variable `ENV', expands its value if it is defined, and uses the
4858 expanded value as the name of a file to read and execute.  Since a
4859 shell invoked as `sh' does not attempt to read and execute commands
4860 from any other startup files, the `--rcfile' option has no effect.  A
4861 non-interactive shell invoked with the name `sh' does not attempt to
4862 read any other startup files.
4863
4864    When invoked as `sh', Bash enters POSIX mode after the startup files
4865 are read.
4866
4867 Invoked in POSIX mode
4868 .....................
4869
4870 When Bash is started in POSIX mode, as with the `--posix' command line
4871 option, it follows the POSIX standard for startup files.  In this mode,
4872 interactive shells expand the `ENV' variable and commands are read and
4873 executed from the file whose name is the expanded value.  No other
4874 startup files are read.
4875
4876 Invoked by remote shell daemon
4877 ..............................
4878
4879 Bash attempts to determine when it is being run with its standard input
4880 connected to a a network connection, as if by the remote shell daemon,
4881 usually `rshd', or the secure shell daemon `sshd'.  If Bash determines
4882 it is being run in this fashion, it reads and executes commands from
4883 `~/.bashrc', if that file exists and is readable.  It will not do this
4884 if invoked as `sh'.  The `--norc' option may be used to inhibit this
4885 behavior, and the `--rcfile' option may be used to force another file
4886 to be read, but `rshd' does not generally invoke the shell with those
4887 options or allow them to be specified.
4888
4889 Invoked with unequal effective and real UID/GIDs
4890 ................................................
4891
4892 If Bash is started with the effective user (group) id not equal to the
4893 real user (group) id, and the `-p' option is not supplied, no startup
4894 files are read, shell functions are not inherited from the environment,
4895 the `SHELLOPTS', `BASHOPTS', `CDPATH', and `GLOBIGNORE' variables, if
4896 they appear in the environment, are ignored, and the effective user id
4897 is set to the real user id.  If the `-p' option is supplied at
4898 invocation, the startup behavior is the same, but the effective user id
4899 is not reset.
4900
4901 \1f
4902 File: bashref.info,  Node: Interactive Shells,  Next: Bash Conditional Expressions,  Prev: Bash Startup Files,  Up: Bash Features
4903
4904 6.3 Interactive Shells
4905 ======================
4906
4907 * Menu:
4908
4909 * What is an Interactive Shell?::       What determines whether a shell is Interactive.
4910 * Is this Shell Interactive?::  How to tell if a shell is interactive.
4911 * Interactive Shell Behavior::  What changes in a interactive shell?
4912
4913 \1f
4914 File: bashref.info,  Node: What is an Interactive Shell?,  Next: Is this Shell Interactive?,  Up: Interactive Shells
4915
4916 6.3.1 What is an Interactive Shell?
4917 -----------------------------------
4918
4919 An interactive shell is one started without non-option arguments,
4920 unless `-s' is specified, without specifying the `-c' option, and whose
4921 input and error output are both connected to terminals (as determined
4922 by `isatty(3)'), or one started with the `-i' option.
4923
4924    An interactive shell generally reads from and writes to a user's
4925 terminal.
4926
4927    The `-s' invocation option may be used to set the positional
4928 parameters when an interactive shell is started.
4929
4930 \1f
4931 File: bashref.info,  Node: Is this Shell Interactive?,  Next: Interactive Shell Behavior,  Prev: What is an Interactive Shell?,  Up: Interactive Shells
4932
4933 6.3.2 Is this Shell Interactive?
4934 --------------------------------
4935
4936 To determine within a startup script whether or not Bash is running
4937 interactively, test the value of the `-' special parameter.  It
4938 contains `i' when the shell is interactive.  For example:
4939
4940      case "$-" in
4941      *i*)       echo This shell is interactive ;;
4942      *) echo This shell is not interactive ;;
4943      esac
4944
4945    Alternatively, startup scripts may examine the variable `PS1'; it is
4946 unset in non-interactive shells, and set in interactive shells.  Thus:
4947
4948      if [ -z "$PS1" ]; then
4949              echo This shell is not interactive
4950      else
4951              echo This shell is interactive
4952      fi
4953
4954 \1f
4955 File: bashref.info,  Node: Interactive Shell Behavior,  Prev: Is this Shell Interactive?,  Up: Interactive Shells
4956
4957 6.3.3 Interactive Shell Behavior
4958 --------------------------------
4959
4960 When the shell is running interactively, it changes its behavior in
4961 several ways.
4962
4963   1. Startup files are read and executed as described in *note Bash
4964      Startup Files::.
4965
4966   2. Job Control (*note Job Control::) is enabled by default.  When job
4967      control is in effect, Bash ignores the keyboard-generated job
4968      control signals `SIGTTIN', `SIGTTOU', and `SIGTSTP'.
4969
4970   3. Bash expands and displays `PS1' before reading the first line of a
4971      command, and expands and displays `PS2' before reading the second
4972      and subsequent lines of a multi-line command.
4973
4974   4. Bash executes the value of the `PROMPT_COMMAND' variable as a
4975      command before printing the primary prompt, `$PS1' (*note Bash
4976      Variables::).
4977
4978   5. Readline (*note Command Line Editing::) is used to read commands
4979      from the user's terminal.
4980
4981   6. Bash inspects the value of the `ignoreeof' option to `set -o'
4982      instead of exiting immediately when it receives an `EOF' on its
4983      standard input when reading a command (*note The Set Builtin::).
4984
4985   7. Command history (*note Bash History Facilities::) and history
4986      expansion (*note History Interaction::) are enabled by default.
4987      Bash will save the command history to the file named by `$HISTFILE'
4988      when an interactive shell exits.
4989
4990   8. Alias expansion (*note Aliases::) is performed by default.
4991
4992   9. In the absence of any traps, Bash ignores `SIGTERM' (*note
4993      Signals::).
4994
4995  10. In the absence of any traps, `SIGINT' is caught and handled
4996      ((*note Signals::).  `SIGINT' will interrupt some shell builtins.
4997
4998  11. An interactive login shell sends a `SIGHUP' to all jobs on exit if
4999      the `huponexit' shell option has been enabled (*note Signals::).
5000
5001  12. The `-n' invocation option is ignored, and `set -n' has no effect
5002      (*note The Set Builtin::).
5003
5004  13. Bash will check for mail periodically, depending on the values of
5005      the `MAIL', `MAILPATH', and `MAILCHECK' shell variables (*note
5006      Bash Variables::).
5007
5008  14. Expansion errors due to references to unbound shell variables after
5009      `set -u' has been enabled will not cause the shell to exit (*note
5010      The Set Builtin::).
5011
5012  15. The shell will not exit on expansion errors caused by VAR being
5013      unset or null in `${VAR:?WORD}' expansions (*note Shell Parameter
5014      Expansion::).
5015
5016  16. Redirection errors encountered by shell builtins will not cause the
5017      shell to exit.
5018
5019  17. When running in POSIX mode, a special builtin returning an error
5020      status will not cause the shell to exit (*note Bash POSIX Mode::).
5021
5022  18. A failed `exec' will not cause the shell to exit (*note Bourne
5023      Shell Builtins::).
5024
5025  19. Parser syntax errors will not cause the shell to exit.
5026
5027  20. Simple spelling correction for directory arguments to the `cd'
5028      builtin is enabled by default (see the description of the `cdspell'
5029      option to the `shopt' builtin in *note The Shopt Builtin::).
5030
5031  21. The shell will check the value of the `TMOUT' variable and exit if
5032      a command is not read within the specified number of seconds after
5033      printing `$PS1' (*note Bash Variables::).
5034
5035
5036 \1f
5037 File: bashref.info,  Node: Bash Conditional Expressions,  Next: Shell Arithmetic,  Prev: Interactive Shells,  Up: Bash Features
5038
5039 6.4 Bash Conditional Expressions
5040 ================================
5041
5042 Conditional expressions are used by the `[[' compound command and the
5043 `test' and `[' builtin commands.
5044
5045    Expressions may be unary or binary.  Unary expressions are often
5046 used to examine the status of a file.  There are string operators and
5047 numeric comparison operators as well.  If the FILE argument to one of
5048 the primaries is of the form `/dev/fd/N', then file descriptor N is
5049 checked.  If the FILE argument to one of the primaries is one of
5050 `/dev/stdin', `/dev/stdout', or `/dev/stderr', file descriptor 0, 1, or
5051 2, respectively, is checked.
5052
5053    When used with `[[', The `<' and `>' operators sort
5054 lexicographically using the current locale.
5055
5056    Unless otherwise specified, primaries that operate on files follow
5057 symbolic links and operate on the target of the link, rather than the
5058 link itself.
5059
5060 `-a FILE'
5061      True if FILE exists.
5062
5063 `-b FILE'
5064      True if FILE exists and is a block special file.
5065
5066 `-c FILE'
5067      True if FILE exists and is a character special file.
5068
5069 `-d FILE'
5070      True if FILE exists and is a directory.
5071
5072 `-e FILE'
5073      True if FILE exists.
5074
5075 `-f FILE'
5076      True if FILE exists and is a regular file.
5077
5078 `-g FILE'
5079      True if FILE exists and its set-group-id bit is set.
5080
5081 `-h FILE'
5082      True if FILE exists and is a symbolic link.
5083
5084 `-k FILE'
5085      True if FILE exists and its "sticky" bit is set.
5086
5087 `-p FILE'
5088      True if FILE exists and is a named pipe (FIFO).
5089
5090 `-r FILE'
5091      True if FILE exists and is readable.
5092
5093 `-s FILE'
5094      True if FILE exists and has a size greater than zero.
5095
5096 `-t FD'
5097      True if file descriptor FD is open and refers to a terminal.
5098
5099 `-u FILE'
5100      True if FILE exists and its set-user-id bit is set.
5101
5102 `-w FILE'
5103      True if FILE exists and is writable.
5104
5105 `-x FILE'
5106      True if FILE exists and is executable.
5107
5108 `-O FILE'
5109      True if FILE exists and is owned by the effective user id.
5110
5111 `-G FILE'
5112      True if FILE exists and is owned by the effective group id.
5113
5114 `-L FILE'
5115      True if FILE exists and is a symbolic link.
5116
5117 `-S FILE'
5118      True if FILE exists and is a socket.
5119
5120 `-N FILE'
5121      True if FILE exists and has been modified since it was last read.
5122
5123 `FILE1 -nt FILE2'
5124      True if FILE1 is newer (according to modification date) than
5125      FILE2, or if FILE1 exists and FILE2 does not.
5126
5127 `FILE1 -ot FILE2'
5128      True if FILE1 is older than FILE2, or if FILE2 exists and FILE1
5129      does not.
5130
5131 `FILE1 -ef FILE2'
5132      True if FILE1 and FILE2 refer to the same device and inode numbers.
5133
5134 `-o OPTNAME'
5135      True if shell option OPTNAME is enabled.  The list of options
5136      appears in the description of the `-o' option to the `set' builtin
5137      (*note The Set Builtin::).
5138
5139 `-z STRING'
5140      True if the length of STRING is zero.
5141
5142 `-n STRING'
5143 `STRING'
5144      True if the length of STRING is non-zero.
5145
5146 `STRING1 == STRING2'
5147 `STRING1 = STRING2'
5148      True if the strings are equal.  `=' should be used with the `test'
5149      command for POSIX conformance.
5150
5151 `STRING1 != STRING2'
5152      True if the strings are not equal.
5153
5154 `STRING1 < STRING2'
5155      True if STRING1 sorts before STRING2 lexicographically.
5156
5157 `STRING1 > STRING2'
5158      True if STRING1 sorts after STRING2 lexicographically.
5159
5160 `ARG1 OP ARG2'
5161      `OP' is one of `-eq', `-ne', `-lt', `-le', `-gt', or `-ge'.  These
5162      arithmetic binary operators return true if ARG1 is equal to, not
5163      equal to, less than, less than or equal to, greater than, or
5164      greater than or equal to ARG2, respectively.  ARG1 and ARG2 may be
5165      positive or negative integers.
5166
5167
5168 \1f
5169 File: bashref.info,  Node: Shell Arithmetic,  Next: Aliases,  Prev: Bash Conditional Expressions,  Up: Bash Features
5170
5171 6.5 Shell Arithmetic
5172 ====================
5173
5174 The shell allows arithmetic expressions to be evaluated, as one of the
5175 shell expansions or by the `let' and the `-i' option to the `declare'
5176 builtins.
5177
5178    Evaluation is done in fixed-width integers with no check for
5179 overflow, though division by 0 is trapped and flagged as an error.  The
5180 operators and their precedence, associativity, and values are the same
5181 as in the C language.  The following list of operators is grouped into
5182 levels of equal-precedence operators.  The levels are listed in order
5183 of decreasing precedence.
5184
5185 `ID++ ID--'
5186      variable post-increment and post-decrement
5187
5188 `++ID --ID'
5189      variable pre-increment and pre-decrement
5190
5191 `- +'
5192      unary minus and plus
5193
5194 `! ~'
5195      logical and bitwise negation
5196
5197 `**'
5198      exponentiation
5199
5200 `* / %'
5201      multiplication, division, remainder
5202
5203 `+ -'
5204      addition, subtraction
5205
5206 `<< >>'
5207      left and right bitwise shifts
5208
5209 `<= >= < >'
5210      comparison
5211
5212 `== !='
5213      equality and inequality
5214
5215 `&'
5216      bitwise AND
5217
5218 `^'
5219      bitwise exclusive OR
5220
5221 `|'
5222      bitwise OR
5223
5224 `&&'
5225      logical AND
5226
5227 `||'
5228      logical OR
5229
5230 `expr ? expr : expr'
5231      conditional operator
5232
5233 `= *= /= %= += -= <<= >>= &= ^= |='
5234      assignment
5235
5236 `expr1 , expr2'
5237      comma
5238
5239    Shell variables are allowed as operands; parameter expansion is
5240 performed before the expression is evaluated.  Within an expression,
5241 shell variables may also be referenced by name without using the
5242 parameter expansion syntax.  A shell variable that is null or unset
5243 evaluates to 0 when referenced by name without using the parameter
5244 expansion syntax.  The value of a variable is evaluated as an
5245 arithmetic expression when it is referenced, or when a variable which
5246 has been given the INTEGER attribute using `declare -i' is assigned a
5247 value.  A null value evaluates to 0.  A shell variable need not have
5248 its integer attribute turned on to be used in an expression.
5249
5250    Constants with a leading 0 are interpreted as octal numbers.  A
5251 leading `0x' or `0X' denotes hexadecimal.  Otherwise, numbers take the
5252 form [BASE`#']N, where BASE is a decimal number between 2 and 64
5253 representing the arithmetic base, and N is a number in that base.  If
5254 BASE`#' is omitted, then base 10 is used.  The digits greater than 9
5255 are represented by the lowercase letters, the uppercase letters, `@',
5256 and `_', in that order.  If BASE is less than or equal to 36, lowercase
5257 and uppercase letters may be used interchangeably to represent numbers
5258 between 10 and 35.
5259
5260    Operators are evaluated in order of precedence.  Sub-expressions in
5261 parentheses are evaluated first and may override the precedence rules
5262 above.
5263
5264 \1f
5265 File: bashref.info,  Node: Aliases,  Next: Arrays,  Prev: Shell Arithmetic,  Up: Bash Features
5266
5267 6.6 Aliases
5268 ===========
5269
5270 ALIASES allow a string to be substituted for a word when it is used as
5271 the first word of a simple command.  The shell maintains a list of
5272 aliases that may be set and unset with the `alias' and `unalias'
5273 builtin commands.
5274
5275    The first word of each simple command, if unquoted, is checked to see
5276 if it has an alias.  If so, that word is replaced by the text of the
5277 alias.  The characters `/', `$', ``', `=' and any of the shell
5278 metacharacters or quoting characters listed above may not appear in an
5279 alias name.  The replacement text may contain any valid shell input,
5280 including shell metacharacters.  The first word of the replacement text
5281 is tested for aliases, but a word that is identical to an alias being
5282 expanded is not expanded a second time.  This means that one may alias
5283 `ls' to `"ls -F"', for instance, and Bash does not try to recursively
5284 expand the replacement text. If the last character of the alias value
5285 is a space or tab character, then the next command word following the
5286 alias is also checked for alias expansion.
5287
5288    Aliases are created and listed with the `alias' command, and removed
5289 with the `unalias' command.
5290
5291    There is no mechanism for using arguments in the replacement text,
5292 as in `csh'.  If arguments are needed, a shell function should be used
5293 (*note Shell Functions::).
5294
5295    Aliases are not expanded when the shell is not interactive, unless
5296 the `expand_aliases' shell option is set using `shopt' (*note The Shopt
5297 Builtin::).
5298
5299    The rules concerning the definition and use of aliases are somewhat
5300 confusing.  Bash always reads at least one complete line of input
5301 before executing any of the commands on that line.  Aliases are
5302 expanded when a command is read, not when it is executed.  Therefore, an
5303 alias definition appearing on the same line as another command does not
5304 take effect until the next line of input is read.  The commands
5305 following the alias definition on that line are not affected by the new
5306 alias.  This behavior is also an issue when functions are executed.
5307 Aliases are expanded when a function definition is read, not when the
5308 function is executed, because a function definition is itself a
5309 compound command.  As a consequence, aliases defined in a function are
5310 not available until after that function is executed.  To be safe,
5311 always put alias definitions on a separate line, and do not use `alias'
5312 in compound commands.
5313
5314    For almost every purpose, shell functions are preferred over aliases.
5315
5316 \1f
5317 File: bashref.info,  Node: Arrays,  Next: The Directory Stack,  Prev: Aliases,  Up: Bash Features
5318
5319 6.7 Arrays
5320 ==========
5321
5322 Bash provides one-dimensional indexed and associative array variables.
5323 Any variable may be used as an indexed array; the `declare' builtin
5324 will explicitly declare an array.  There is no maximum limit on the
5325 size of an array, nor any requirement that members be indexed or
5326 assigned contiguously.  Indexed arrays are referenced using integers
5327 (including arithmetic expressions (*note Shell Arithmetic::) and are
5328 zero-based; associative arrays use arbitrary strings.
5329
5330    An indexed array is created automatically if any variable is
5331 assigned to using the syntax
5332      name[SUBSCRIPT]=VALUE
5333
5334 The SUBSCRIPT is treated as an arithmetic expression that must evaluate
5335 to a number greater than or equal to zero.  To explicitly declare an
5336 array, use
5337      declare -a NAME
5338    The syntax
5339      declare -a NAME[SUBSCRIPT]
5340    is also accepted; the SUBSCRIPT is ignored.
5341
5342    Associative arrays are created using
5343      declare -A NAME.
5344
5345    Attributes may be specified for an array variable using the
5346 `declare' and `readonly' builtins.  Each attribute applies to all
5347 members of an array.
5348
5349    Arrays are assigned to using compound assignments of the form
5350      name=(value1 ... valueN)
5351    where each VALUE is of the form `[SUBSCRIPT]='STRING.  Indexed array
5352 assignments do not require the bracket and subscript.  When assigning
5353 to indexed arrays, if the optional subscript is supplied, that index is
5354 assigned to; otherwise the index of the element assigned is the last
5355 index assigned to by the statement plus one.  Indexing starts at zero.
5356
5357    When assigning to an associative array, the subscript is required.
5358
5359    This syntax is also accepted by the `declare' builtin.  Individual
5360 array elements may be assigned to using the `name['SUBSCRIPT`]='VALUE
5361 syntax introduced above.
5362
5363    Any element of an array may be referenced using
5364 `${name['SUBSCRIPT`]}'.  The braces are required to avoid conflicts
5365 with the shell's filename expansion operators.  If the SUBSCRIPT is `@'
5366 or `*', the word expands to all members of the array NAME.  These
5367 subscripts differ only when the word appears within double quotes.  If
5368 the word is double-quoted, `${name[*]}' expands to a single word with
5369 the value of each array member separated by the first character of the
5370 `IFS' variable, and `${name[@]}' expands each element of NAME to a
5371 separate word.  When there are no array members, `${name[@]}' expands
5372 to nothing.  If the double-quoted expansion occurs within a word, the
5373 expansion of the first parameter is joined with the beginning part of
5374 the original word, and the expansion of the last parameter is joined
5375 with the last part of the original word.  This is analogous to the
5376 expansion of the special parameters `@' and `*'.
5377 `${#name['SUBSCRIPT`]}' expands to the length of `${name['SUBSCRIPT`]}'.
5378 If SUBSCRIPT is `@' or `*', the expansion is the number of elements in
5379 the array.  Referencing an array variable without a subscript is
5380 equivalent to referencing with a subscript of 0.
5381
5382    An array variable is considered set if a subscript has been assigned
5383 a value.  The null string is a valid value.
5384
5385    The `unset' builtin is used to destroy arrays.  `unset'
5386 NAME[SUBSCRIPT] destroys the array element at index SUBSCRIPT.  Care
5387 must be taken to avoid unwanted side effects caused by filename
5388 expansion.  `unset' NAME, where NAME is an array, removes the entire
5389 array. A subscript of `*' or `@' also removes the entire array.
5390
5391    The `declare', `local', and `readonly' builtins each accept a `-a'
5392 option to specify an indexed array and a `-A' option to specify an
5393 associative array.  The `read' builtin accepts a `-a' option to assign
5394 a list of words read from the standard input to an array, and can read
5395 values from the standard input into individual array elements.  The
5396 `set' and `declare' builtins display array values in a way that allows
5397 them to be reused as input.
5398
5399 \1f
5400 File: bashref.info,  Node: The Directory Stack,  Next: Printing a Prompt,  Prev: Arrays,  Up: Bash Features
5401
5402 6.8 The Directory Stack
5403 =======================
5404
5405 * Menu:
5406
5407 * Directory Stack Builtins::            Bash builtin commands to manipulate
5408                                         the directory stack.
5409
5410    The directory stack is a list of recently-visited directories.  The
5411 `pushd' builtin adds directories to the stack as it changes the current
5412 directory, and the `popd' builtin removes specified directories from
5413 the stack and changes the current directory to the directory removed.
5414 The `dirs' builtin displays the contents of the directory stack.
5415
5416    The contents of the directory stack are also visible as the value of
5417 the `DIRSTACK' shell variable.
5418
5419 \1f
5420 File: bashref.info,  Node: Directory Stack Builtins,  Up: The Directory Stack
5421
5422 6.8.1 Directory Stack Builtins
5423 ------------------------------
5424
5425 `dirs'
5426           dirs [+N | -N] [-clpv]
5427      Display the list of currently remembered directories.  Directories
5428      are added to the list with the `pushd' command; the `popd' command
5429      removes directories from the list.
5430     `+N'
5431           Displays the Nth directory (counting from the left of the
5432           list printed by `dirs' when invoked without options), starting
5433           with zero.
5434
5435     `-N'
5436           Displays the Nth directory (counting from the right of the
5437           list printed by `dirs' when invoked without options), starting
5438           with zero.
5439
5440     `-c'
5441           Clears the directory stack by deleting all of the elements.
5442
5443     `-l'
5444           Produces a longer listing; the default listing format uses a
5445           tilde to denote the home directory.
5446
5447     `-p'
5448           Causes `dirs' to print the directory stack with one entry per
5449           line.
5450
5451     `-v'
5452           Causes `dirs' to print the directory stack with one entry per
5453           line, prefixing each entry with its index in the stack.
5454
5455 `popd'
5456           popd [+N | -N] [-n]
5457
5458      Remove the top entry from the directory stack, and `cd' to the new
5459      top directory.  When no arguments are given, `popd' removes the
5460      top directory from the stack and performs a `cd' to the new top
5461      directory.  The elements are numbered from 0 starting at the first
5462      directory listed with `dirs'; i.e., `popd' is equivalent to `popd
5463      +0'.
5464     `+N'
5465           Removes the Nth directory (counting from the left of the list
5466           printed by `dirs'), starting with zero.
5467
5468     `-N'
5469           Removes the Nth directory (counting from the right of the
5470           list printed by `dirs'), starting with zero.
5471
5472     `-n'
5473           Suppresses the normal change of directory when removing
5474           directories from the stack, so that only the stack is
5475           manipulated.
5476
5477 `pushd'
5478           pushd [-n] [+N | -N | DIR ]
5479
5480      Save the current directory on the top of the directory stack and
5481      then `cd' to DIR.  With no arguments, `pushd' exchanges the top
5482      two directories.
5483
5484     `-n'
5485           Suppresses the normal change of directory when adding
5486           directories to the stack, so that only the stack is
5487           manipulated.
5488
5489     `+N'
5490           Brings the Nth directory (counting from the left of the list
5491           printed by `dirs', starting with zero) to the top of the list
5492           by rotating the stack.
5493
5494     `-N'
5495           Brings the Nth directory (counting from the right of the list
5496           printed by `dirs', starting with zero) to the top of the list
5497           by rotating the stack.
5498
5499     `DIR'
5500           Makes the current working directory be the top of the stack,
5501           and then executes the equivalent of ``cd' DIR'.  `cd's to DIR.
5502
5503
5504 \1f
5505 File: bashref.info,  Node: Printing a Prompt,  Next: The Restricted Shell,  Prev: The Directory Stack,  Up: Bash Features
5506
5507 6.9 Controlling the Prompt
5508 ==========================
5509
5510 The value of the variable `PROMPT_COMMAND' is examined just before Bash
5511 prints each primary prompt.  If `PROMPT_COMMAND' is set and has a
5512 non-null value, then the value is executed just as if it had been typed
5513 on the command line.
5514
5515    In addition, the following table describes the special characters
5516 which can appear in the prompt variables:
5517
5518 `\a'
5519      A bell character.
5520
5521 `\d'
5522      The date, in "Weekday Month Date" format (e.g., "Tue May 26").
5523
5524 `\D{FORMAT}'
5525      The FORMAT is passed to `strftime'(3) and the result is inserted
5526      into the prompt string; an empty FORMAT results in a
5527      locale-specific time representation.  The braces are required.
5528
5529 `\e'
5530      An escape character.
5531
5532 `\h'
5533      The hostname, up to the first `.'.
5534
5535 `\H'
5536      The hostname.
5537
5538 `\j'
5539      The number of jobs currently managed by the shell.
5540
5541 `\l'
5542      The basename of the shell's terminal device name.
5543
5544 `\n'
5545      A newline.
5546
5547 `\r'
5548      A carriage return.
5549
5550 `\s'
5551      The name of the shell, the basename of `$0' (the portion following
5552      the final slash).
5553
5554 `\t'
5555      The time, in 24-hour HH:MM:SS format.
5556
5557 `\T'
5558      The time, in 12-hour HH:MM:SS format.
5559
5560 `\@'
5561      The time, in 12-hour am/pm format.
5562
5563 `\A'
5564      The time, in 24-hour HH:MM format.
5565
5566 `\u'
5567      The username of the current user.
5568
5569 `\v'
5570      The version of Bash (e.g., 2.00)
5571
5572 `\V'
5573      The release of Bash, version + patchlevel (e.g., 2.00.0)
5574
5575 `\w'
5576      The current working directory, with `$HOME' abbreviated with a
5577      tilde (uses the `$PROMPT_DIRTRIM' variable).
5578
5579 `\W'
5580      The basename of `$PWD', with `$HOME' abbreviated with a tilde.
5581
5582 `\!'
5583      The history number of this command.
5584
5585 `\#'
5586      The command number of this command.
5587
5588 `\$'
5589      If the effective uid is 0, `#', otherwise `$'.
5590
5591 `\NNN'
5592      The character whose ASCII code is the octal value NNN.
5593
5594 `\\'
5595      A backslash.
5596
5597 `\['
5598      Begin a sequence of non-printing characters.  This could be used to
5599      embed a terminal control sequence into the prompt.
5600
5601 `\]'
5602      End a sequence of non-printing characters.
5603
5604    The command number and the history number are usually different: the
5605 history number of a command is its position in the history list, which
5606 may include commands restored from the history file (*note Bash History
5607 Facilities::), while the command number is the position in the sequence
5608 of commands executed during the current shell session.
5609
5610    After the string is decoded, it is expanded via parameter expansion,
5611 command substitution, arithmetic expansion, and quote removal, subject
5612 to the value of the `promptvars' shell option (*note Bash Builtins::).
5613
5614 \1f
5615 File: bashref.info,  Node: The Restricted Shell,  Next: Bash POSIX Mode,  Prev: Printing a Prompt,  Up: Bash Features
5616
5617 6.10 The Restricted Shell
5618 =========================
5619
5620 If Bash is started with the name `rbash', or the `--restricted' or `-r'
5621 option is supplied at invocation, the shell becomes restricted.  A
5622 restricted shell is used to set up an environment more controlled than
5623 the standard shell.  A restricted shell behaves identically to `bash'
5624 with the exception that the following are disallowed or not performed:
5625
5626    * Changing directories with the `cd' builtin.
5627
5628    * Setting or unsetting the values of the `SHELL', `PATH', `ENV', or
5629      `BASH_ENV' variables.
5630
5631    * Specifying command names containing slashes.
5632
5633    * Specifying a filename containing a slash as an argument to the `.'
5634      builtin command.
5635
5636    * Specifying a filename containing a slash as an argument to the `-p'
5637      option to the `hash' builtin command.
5638
5639    * Importing function definitions from the shell environment at
5640      startup.
5641
5642    * Parsing the value of `SHELLOPTS' from the shell environment at
5643      startup.
5644
5645    * Redirecting output using the `>', `>|', `<>', `>&', `&>', and `>>'
5646      redirection operators.
5647
5648    * Using the `exec' builtin to replace the shell with another command.
5649
5650    * Adding or deleting builtin commands with the `-f' and `-d' options
5651      to the `enable' builtin.
5652
5653    * Using the `enable' builtin command to enable disabled shell
5654      builtins.
5655
5656    * Specifying the `-p' option to the `command' builtin.
5657
5658    * Turning off restricted mode with `set +r' or `set +o restricted'.
5659
5660    These restrictions are enforced after any startup files are read.
5661
5662    When a command that is found to be a shell script is executed (*note
5663 Shell Scripts::), `rbash' turns off any restrictions in the shell
5664 spawned to execute the script.
5665
5666 \1f
5667 File: bashref.info,  Node: Bash POSIX Mode,  Prev: The Restricted Shell,  Up: Bash Features
5668
5669 6.11 Bash POSIX Mode
5670 ====================
5671
5672 Starting Bash with the `--posix' command-line option or executing `set
5673 -o posix' while Bash is running will cause Bash to conform more closely
5674 to the POSIX standard by changing the behavior to match that specified
5675 by POSIX in areas where the Bash default differs.
5676
5677    When invoked as `sh', Bash enters POSIX mode after reading the
5678 startup files.
5679
5680    The following list is what's changed when `POSIX mode' is in effect:
5681
5682   1. When a command in the hash table no longer exists, Bash will
5683      re-search `$PATH' to find the new location.  This is also
5684      available with `shopt -s checkhash'.
5685
5686   2. The message printed by the job control code and builtins when a job
5687      exits with a non-zero status is `Done(status)'.
5688
5689   3. The message printed by the job control code and builtins when a job
5690      is stopped is `Stopped(SIGNAME)', where SIGNAME is, for example,
5691      `SIGTSTP'.
5692
5693   4. The `bg' builtin uses the required format to describe each job
5694      placed in the background, which does not include an indication of
5695      whether the job is the current or previous job.
5696
5697   5. Reserved words appearing in a context where reserved words are
5698      recognized do not undergo alias expansion.
5699
5700   6. The POSIX `PS1' and `PS2' expansions of `!' to the history number
5701      and `!!' to `!' are enabled, and parameter expansion is performed
5702      on the values of `PS1' and `PS2' regardless of the setting of the
5703      `promptvars' option.
5704
5705   7. The POSIX startup files are executed (`$ENV') rather than the
5706      normal Bash files.
5707
5708   8. Tilde expansion is only performed on assignments preceding a
5709      command name, rather than on all assignment statements on the line.
5710
5711   9. The default history file is `~/.sh_history' (this is the default
5712      value of `$HISTFILE').
5713
5714  10. The output of `kill -l' prints all the signal names on a single
5715      line, separated by spaces, without the `SIG' prefix.
5716
5717  11. The `kill' builtin does not accept signal names with a `SIG'
5718      prefix.
5719
5720  12. Non-interactive shells exit if FILENAME in `.' FILENAME is not
5721      found.
5722
5723  13. Non-interactive shells exit if a syntax error in an arithmetic
5724      expansion results in an invalid expression.
5725
5726  14. Redirection operators do not perform filename expansion on the word
5727      in the redirection unless the shell is interactive.
5728
5729  15. Redirection operators do not perform word splitting on the word in
5730      the redirection.
5731
5732  16. Function names must be valid shell `name's.  That is, they may not
5733      contain characters other than letters, digits, and underscores, and
5734      may not start with a digit.  Declaring a function with an invalid
5735      name causes a fatal syntax error in non-interactive shells.
5736
5737  17. POSIX special builtins are found before shell functions during
5738      command lookup.
5739
5740  18. If a POSIX special builtin returns an error status, a
5741      non-interactive shell exits.  The fatal errors are those listed in
5742      the POSIX standard, and include things like passing incorrect
5743      options, redirection errors, variable assignment errors for
5744      assignments preceding the command name, and so on.
5745
5746  19. If `CDPATH' is set, the `cd' builtin will not implicitly append
5747      the current directory to it.  This means that `cd' will fail if no
5748      valid directory name can be constructed from any of the entries in
5749      `$CDPATH', even if the a directory with the same name as the name
5750      given as an argument to `cd' exists in the current directory.
5751
5752  20. A non-interactive shell exits with an error status if a variable
5753      assignment error occurs when no command name follows the assignment
5754      statements.  A variable assignment error occurs, for example, when
5755      trying to assign a value to a readonly variable.
5756
5757  21. A non-interactive shell exits with an error status if the iteration
5758      variable in a `for' statement or the selection variable in a
5759      `select' statement is a readonly variable.
5760
5761  22. Process substitution is not available.
5762
5763  23. Assignment statements preceding POSIX special builtins persist in
5764      the shell environment after the builtin completes.
5765
5766  24. Assignment statements preceding shell function calls persist in the
5767      shell environment after the function returns, as if a POSIX
5768      special builtin command had been executed.
5769
5770  25. The `export' and `readonly' builtin commands display their output
5771      in the format required by POSIX.
5772
5773  26. The `trap' builtin displays signal names without the leading `SIG'.
5774
5775  27. The `trap' builtin doesn't check the first argument for a possible
5776      signal specification and revert the signal handling to the original
5777      disposition if it is, unless that argument consists solely of
5778      digits and is a valid signal number.  If users want to reset the
5779      handler for a given signal to the original disposition, they
5780      should use `-' as the first argument.
5781
5782  28. The `.' and `source' builtins do not search the current directory
5783      for the filename argument if it is not found by searching `PATH'.
5784
5785  29. Subshells spawned to execute command substitutions inherit the
5786      value of the `-e' option from the parent shell.  When not in POSIX
5787      mode, Bash clears the `-e' option in such subshells.
5788
5789  30. Alias expansion is always enabled, even in non-interactive shells.
5790
5791  31. When the `alias' builtin displays alias definitions, it does not
5792      display them with a leading `alias ' unless the `-p' option is
5793      supplied.
5794
5795  32. When the `set' builtin is invoked without options, it does not
5796      display shell function names and definitions.
5797
5798  33. When the `set' builtin is invoked without options, it displays
5799      variable values without quotes, unless they contain shell
5800      metacharacters, even if the result contains nonprinting characters.
5801
5802  34. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
5803      constructed from `$PWD' and the directory name supplied as an
5804      argument does not refer to an existing directory, `cd' will fail
5805      instead of falling back to PHYSICAL mode.
5806
5807  35. When the `pwd' builtin is supplied the `-P' option, it resets
5808      `$PWD' to a pathname containing no symlinks.
5809
5810  36. The `pwd' builtin verifies that the value it prints is the same as
5811      the current directory, even if it is not asked to check the file
5812      system with the `-P' option.
5813
5814  37. When listing the history, the `fc' builtin does not include an
5815      indication of whether or not a history entry has been modified.
5816
5817  38. The default editor used by `fc' is `ed'.
5818
5819  39. The `type' and `command' builtins will not report a non-executable
5820      file as having been found, though the shell will attempt to
5821      execute such a file if it is the only so-named file found in
5822      `$PATH'.
5823
5824  40. The `vi' editing mode will invoke the `vi' editor directly when
5825      the `v' command is run, instead of checking `$VISUAL' and
5826      `$EDITOR'.
5827
5828  41. When the `xpg_echo' option is enabled, Bash does not attempt to
5829      interpret any arguments to `echo' as options.  Each argument is
5830      displayed, after escape characters are converted.
5831
5832  42. The `ulimit' builtin uses a block size of 512 bytes for the `-c'
5833      and `-f' options.
5834
5835  43. The arrival of `SIGCHLD'  when a trap is set on `SIGCHLD' does not
5836      interrupt the `wait' builtin and cause it to return immediately.
5837      The trap command is run once for each child that exits.
5838
5839
5840    There is other POSIX behavior that Bash does not implement by
5841 default even when in POSIX mode.  Specifically:
5842
5843   1. The `fc' builtin checks `$EDITOR' as a program to edit history
5844      entries if `FCEDIT' is unset, rather than defaulting directly to
5845      `ed'.  `fc' uses `ed' if `EDITOR' is unset.
5846
5847   2. As noted above, Bash requires the `xpg_echo' option to be enabled
5848      for the `echo' builtin to be fully conformant.
5849
5850
5851    Bash can be configured to be POSIX-conformant by default, by
5852 specifying the `--enable-strict-posix-default' to `configure' when
5853 building (*note Optional Features::).
5854
5855 \1f
5856 File: bashref.info,  Node: Job Control,  Next: Command Line Editing,  Prev: Bash Features,  Up: Top
5857
5858 7 Job Control
5859 *************
5860
5861 This chapter discusses what job control is, how it works, and how Bash
5862 allows you to access its facilities.
5863
5864 * Menu:
5865
5866 * Job Control Basics::          How job control works.
5867 * Job Control Builtins::        Bash builtin commands used to interact
5868                                 with job control.
5869 * Job Control Variables::       Variables Bash uses to customize job
5870                                 control.
5871
5872 \1f
5873 File: bashref.info,  Node: Job Control Basics,  Next: Job Control Builtins,  Up: Job Control
5874
5875 7.1 Job Control Basics
5876 ======================
5877
5878 Job control refers to the ability to selectively stop (suspend) the
5879 execution of processes and continue (resume) their execution at a later
5880 point.  A user typically employs this facility via an interactive
5881 interface supplied jointly by the operating system kernel's terminal
5882 driver and Bash.
5883
5884    The shell associates a JOB with each pipeline.  It keeps a table of
5885 currently executing jobs, which may be listed with the `jobs' command.
5886 When Bash starts a job asynchronously, it prints a line that looks like:
5887      [1] 25647
5888    indicating that this job is job number 1 and that the process ID of
5889 the last process in the pipeline associated with this job is 25647.
5890 All of the processes in a single pipeline are members of the same job.
5891 Bash uses the JOB abstraction as the basis for job control.
5892
5893    To facilitate the implementation of the user interface to job
5894 control, the operating system maintains the notion of a current terminal
5895 process group ID.  Members of this process group (processes whose
5896 process group ID is equal to the current terminal process group ID)
5897 receive keyboard-generated signals such as `SIGINT'.  These processes
5898 are said to be in the foreground.  Background processes are those whose
5899 process group ID differs from the terminal's; such processes are immune
5900 to keyboard-generated signals.  Only foreground processes are allowed
5901 to read from or, if the user so specifies with `stty tostop', write to
5902 the terminal.  Background processes which attempt to read from (write
5903 to when `stty tostop' is in effect) the terminal are sent a `SIGTTIN'
5904 (`SIGTTOU') signal by the kernel's terminal driver, which, unless
5905 caught, suspends the process.
5906
5907    If the operating system on which Bash is running supports job
5908 control, Bash contains facilities to use it.  Typing the SUSPEND
5909 character (typically `^Z', Control-Z) while a process is running causes
5910 that process to be stopped and returns control to Bash.  Typing the
5911 DELAYED SUSPEND character (typically `^Y', Control-Y) causes the
5912 process to be stopped when it attempts to read input from the terminal,
5913 and control to be returned to Bash.  The user then manipulates the
5914 state of this job, using the `bg' command to continue it in the
5915 background, the `fg' command to continue it in the foreground, or the
5916 `kill' command to kill it.  A `^Z' takes effect immediately, and has
5917 the additional side effect of causing pending output and typeahead to
5918 be discarded.
5919
5920    There are a number of ways to refer to a job in the shell.  The
5921 character `%' introduces a job specification (JOBSPEC).
5922
5923    Job number `n' may be referred to as `%n'.  The symbols `%%' and
5924 `%+' refer to the shell's notion of the current job, which is the last
5925 job stopped while it was in the foreground or started in the background.
5926 A single `%' (with no accompanying job specification) also refers to
5927 the current job.  The previous job may be referenced using `%-'.  If
5928 there is only a single job, `%+' and `%-' can both be used to refer to
5929 that job.  In output pertaining to jobs (e.g., the output of the `jobs'
5930 command), the current job is always flagged with a `+', and the
5931 previous job with a `-'.
5932
5933    A job may also be referred to using a prefix of the name used to
5934 start it, or using a substring that appears in its command line.  For
5935 example, `%ce' refers to a stopped `ce' job. Using `%?ce', on the other
5936 hand, refers to any job containing the string `ce' in its command line.
5937 If the prefix or substring matches more than one job, Bash reports an
5938 error.
5939
5940    Simply naming a job can be used to bring it into the foreground:
5941 `%1' is a synonym for `fg %1', bringing job 1 from the background into
5942 the foreground.  Similarly, `%1 &' resumes job 1 in the background,
5943 equivalent to `bg %1'
5944
5945    The shell learns immediately whenever a job changes state.
5946 Normally, Bash waits until it is about to print a prompt before
5947 reporting changes in a job's status so as to not interrupt any other
5948 output.  If the `-b' option to the `set' builtin is enabled, Bash
5949 reports such changes immediately (*note The Set Builtin::).  Any trap
5950 on `SIGCHLD' is executed for each child process that exits.
5951
5952    If an attempt to exit Bash is made while jobs are stopped, (or
5953 running, if the `checkjobs' option is enabled - see *note The Shopt
5954 Builtin::), the shell prints a warning message, and if the `checkjobs'
5955 option is enabled, lists the jobs and their statuses.  The `jobs'
5956 command may then be used to inspect their status.  If a second attempt
5957 to exit is made without an intervening command, Bash does not print
5958 another warning, and any stopped jobs are terminated.
5959
5960 \1f
5961 File: bashref.info,  Node: Job Control Builtins,  Next: Job Control Variables,  Prev: Job Control Basics,  Up: Job Control
5962
5963 7.2 Job Control Builtins
5964 ========================
5965
5966 `bg'
5967           bg [JOBSPEC ...]
5968      Resume each suspended job JOBSPEC in the background, as if it had
5969      been started with `&'.  If JOBSPEC is not supplied, the current
5970      job is used.  The return status is zero unless it is run when job
5971      control is not enabled, or, when run with job control enabled, any
5972      JOBSPEC was not found or specifies a job that was started without
5973      job control.
5974
5975 `fg'
5976           fg [JOBSPEC]
5977      Resume the job JOBSPEC in the foreground and make it the current
5978      job.  If JOBSPEC is not supplied, the current job is used.  The
5979      return status is that of the command placed into the foreground,
5980      or non-zero if run when job control is disabled or, when run with
5981      job control enabled, JOBSPEC does not specify a valid job or
5982      JOBSPEC specifies a job that was started without job control.
5983
5984 `jobs'
5985           jobs [-lnprs] [JOBSPEC]
5986           jobs -x COMMAND [ARGUMENTS]
5987
5988      The first form lists the active jobs.  The options have the
5989      following meanings:
5990
5991     `-l'
5992           List process IDs in addition to the normal information.
5993
5994     `-n'
5995           Display information only about jobs that have changed status
5996           since the user was last notified of their status.
5997
5998     `-p'
5999           List only the process ID of the job's process group leader.
6000
6001     `-r'
6002           Restrict output to running jobs.
6003
6004     `-s'
6005           Restrict output to stopped jobs.
6006
6007      If JOBSPEC is given, output is restricted to information about
6008      that job.  If JOBSPEC is not supplied, the status of all jobs is
6009      listed.
6010
6011      If the `-x' option is supplied, `jobs' replaces any JOBSPEC found
6012      in COMMAND or ARGUMENTS with the corresponding process group ID,
6013      and executes COMMAND, passing it ARGUMENTs, returning its exit
6014      status.
6015
6016 `kill'
6017           kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] JOBSPEC or PID
6018           kill -l [EXIT_STATUS]
6019      Send a signal specified by SIGSPEC or SIGNUM to the process named
6020      by job specification JOBSPEC or process ID PID.  SIGSPEC is either
6021      a case-insensitive signal name such as `SIGINT' (with or without
6022      the `SIG' prefix) or a signal number; SIGNUM is a signal number.
6023      If SIGSPEC and SIGNUM are not present, `SIGTERM' is used.  The
6024      `-l' option lists the signal names.  If any arguments are supplied
6025      when `-l' is given, the names of the signals corresponding to the
6026      arguments are listed, and the return status is zero.  EXIT_STATUS
6027      is a number specifying a signal number or the exit status of a
6028      process terminated by a signal.  The return status is zero if at
6029      least one signal was successfully sent, or non-zero if an error
6030      occurs or an invalid option is encountered.
6031
6032 `wait'
6033           wait [JOBSPEC or PID ...]
6034      Wait until the child process specified by each process ID PID or
6035      job specification JOBSPEC exits and return the exit status of the
6036      last command waited for.  If a job spec is given, all processes in
6037      the job are waited for.  If no arguments are given, all currently
6038      active child processes are waited for, and the return status is
6039      zero.  If neither JOBSPEC nor PID specifies an active child process
6040      of the shell, the return status is 127.
6041
6042 `disown'
6043           disown [-ar] [-h] [JOBSPEC ...]
6044      Without options, each JOBSPEC is removed from the table of active
6045      jobs.  If the `-h' option is given, the job is not removed from
6046      the table, but is marked so that `SIGHUP' is not sent to the job
6047      if the shell receives a `SIGHUP'.  If JOBSPEC is not present, and
6048      neither the `-a' nor `-r' option is supplied, the current job is
6049      used.  If no JOBSPEC is supplied, the `-a' option means to remove
6050      or mark all jobs; the `-r' option without a JOBSPEC argument
6051      restricts operation to running jobs.
6052
6053 `suspend'
6054           suspend [-f]
6055      Suspend the execution of this shell until it receives a `SIGCONT'
6056      signal.  A login shell cannot be suspended; the `-f' option can be
6057      used to override this and force the suspension.
6058
6059
6060    When job control is not active, the `kill' and `wait' builtins do
6061 not accept JOBSPEC arguments.  They must be supplied process IDs.
6062
6063 \1f
6064 File: bashref.info,  Node: Job Control Variables,  Prev: Job Control Builtins,  Up: Job Control
6065
6066 7.3 Job Control Variables
6067 =========================
6068
6069 `auto_resume'
6070      This variable controls how the shell interacts with the user and
6071      job control.  If this variable exists then single word simple
6072      commands without redirections are treated as candidates for
6073      resumption of an existing job.  There is no ambiguity allowed; if
6074      there is more than one job beginning with the string typed, then
6075      the most recently accessed job will be selected.  The name of a
6076      stopped job, in this context, is the command line used to start
6077      it.  If this variable is set to the value `exact', the string
6078      supplied must match the name of a stopped job exactly; if set to
6079      `substring', the string supplied needs to match a substring of the
6080      name of a stopped job.  The `substring' value provides
6081      functionality analogous to the `%?' job ID (*note Job Control
6082      Basics::).  If set to any other value, the supplied string must be
6083      a prefix of a stopped job's name; this provides functionality
6084      analogous to the `%' job ID.
6085
6086
6087 \1f
6088 File: bashref.info,  Node: Command Line Editing,  Next: Using History Interactively,  Prev: Job Control,  Up: Top
6089
6090 8 Command Line Editing
6091 **********************
6092
6093 This chapter describes the basic features of the GNU command line
6094 editing interface.  Command line editing is provided by the Readline
6095 library, which is used by several different programs, including Bash.
6096 Command line editing is enabled by default when using an interactive
6097 shell, unless the `--noediting' option is supplied at shell invocation.
6098 Line editing is also used when using the `-e' option to the `read'
6099 builtin command (*note Bash Builtins::).  By default, the line editing
6100 commands are similar to those of emacs.  A vi-style line editing
6101 interface is also available.  Line editing can be enabled at any time
6102 using the `-o emacs' or `-o vi' options to the `set' builtin command
6103 (*note The Set Builtin::), or disabled using the `+o emacs' or `+o vi'
6104 options to `set'.
6105
6106 * Menu:
6107
6108 * Introduction and Notation::   Notation used in this text.
6109 * Readline Interaction::        The minimum set of commands for editing a line.
6110 * Readline Init File::          Customizing Readline from a user's view.
6111 * Bindable Readline Commands::  A description of most of the Readline commands
6112                                 available for binding
6113 * Readline vi Mode::            A short description of how to make Readline
6114                                 behave like the vi editor.
6115
6116 * Programmable Completion::     How to specify the possible completions for
6117                                 a specific command.
6118 * Programmable Completion Builtins::    Builtin commands to specify how to
6119                                 complete arguments for a particular command.
6120
6121 \1f
6122 File: bashref.info,  Node: Introduction and Notation,  Next: Readline Interaction,  Up: Command Line Editing
6123
6124 8.1 Introduction to Line Editing
6125 ================================
6126
6127 The following paragraphs describe the notation used to represent
6128 keystrokes.
6129
6130    The text `C-k' is read as `Control-K' and describes the character
6131 produced when the <k> key is pressed while the Control key is depressed.
6132
6133    The text `M-k' is read as `Meta-K' and describes the character
6134 produced when the Meta key (if you have one) is depressed, and the <k>
6135 key is pressed.  The Meta key is labeled <ALT> on many keyboards.  On
6136 keyboards with two keys labeled <ALT> (usually to either side of the
6137 space bar), the <ALT> on the left side is generally set to work as a
6138 Meta key.  The <ALT> key on the right may also be configured to work as
6139 a Meta key or may be configured as some other modifier, such as a
6140 Compose key for typing accented characters.
6141
6142    If you do not have a Meta or <ALT> key, or another key working as a
6143 Meta key, the identical keystroke can be generated by typing <ESC>
6144 _first_, and then typing <k>.  Either process is known as "metafying"
6145 the <k> key.
6146
6147    The text `M-C-k' is read as `Meta-Control-k' and describes the
6148 character produced by "metafying" `C-k'.
6149
6150    In addition, several keys have their own names.  Specifically,
6151 <DEL>, <ESC>, <LFD>, <SPC>, <RET>, and <TAB> all stand for themselves
6152 when seen in this text, or in an init file (*note Readline Init File::).
6153 If your keyboard lacks a <LFD> key, typing <C-j> will produce the
6154 desired character.  The <RET> key may be labeled <Return> or <Enter> on
6155 some keyboards.
6156
6157 \1f
6158 File: bashref.info,  Node: Readline Interaction,  Next: Readline Init File,  Prev: Introduction and Notation,  Up: Command Line Editing
6159
6160 8.2 Readline Interaction
6161 ========================
6162
6163 Often during an interactive session you type in a long line of text,
6164 only to notice that the first word on the line is misspelled.  The
6165 Readline library gives you a set of commands for manipulating the text
6166 as you type it in, allowing you to just fix your typo, and not forcing
6167 you to retype the majority of the line.  Using these editing commands,
6168 you move the cursor to the place that needs correction, and delete or
6169 insert the text of the corrections.  Then, when you are satisfied with
6170 the line, you simply press <RET>.  You do not have to be at the end of
6171 the line to press <RET>; the entire line is accepted regardless of the
6172 location of the cursor within the line.
6173
6174 * Menu:
6175
6176 * Readline Bare Essentials::    The least you need to know about Readline.
6177 * Readline Movement Commands::  Moving about the input line.
6178 * Readline Killing Commands::   How to delete text, and how to get it back!
6179 * Readline Arguments::          Giving numeric arguments to commands.
6180 * Searching::                   Searching through previous lines.
6181
6182 \1f
6183 File: bashref.info,  Node: Readline Bare Essentials,  Next: Readline Movement Commands,  Up: Readline Interaction
6184
6185 8.2.1 Readline Bare Essentials
6186 ------------------------------
6187
6188 In order to enter characters into the line, simply type them.  The typed
6189 character appears where the cursor was, and then the cursor moves one
6190 space to the right.  If you mistype a character, you can use your erase
6191 character to back up and delete the mistyped character.
6192
6193    Sometimes you may mistype a character, and not notice the error
6194 until you have typed several other characters.  In that case, you can
6195 type `C-b' to move the cursor to the left, and then correct your
6196 mistake.  Afterwards, you can move the cursor to the right with `C-f'.
6197
6198    When you add text in the middle of a line, you will notice that
6199 characters to the right of the cursor are `pushed over' to make room
6200 for the text that you have inserted.  Likewise, when you delete text
6201 behind the cursor, characters to the right of the cursor are `pulled
6202 back' to fill in the blank space created by the removal of the text.  A
6203 list of the bare essentials for editing the text of an input line
6204 follows.
6205
6206 `C-b'
6207      Move back one character.
6208
6209 `C-f'
6210      Move forward one character.
6211
6212 <DEL> or <Backspace>
6213      Delete the character to the left of the cursor.
6214
6215 `C-d'
6216      Delete the character underneath the cursor.
6217
6218 Printing characters
6219      Insert the character into the line at the cursor.
6220
6221 `C-_' or `C-x C-u'
6222      Undo the last editing command.  You can undo all the way back to an
6223      empty line.
6224
6225 (Depending on your configuration, the <Backspace> key be set to delete
6226 the character to the left of the cursor and the <DEL> key set to delete
6227 the character underneath the cursor, like `C-d', rather than the
6228 character to the left of the cursor.)
6229
6230 \1f
6231 File: bashref.info,  Node: Readline Movement Commands,  Next: Readline Killing Commands,  Prev: Readline Bare Essentials,  Up: Readline Interaction
6232
6233 8.2.2 Readline Movement Commands
6234 --------------------------------
6235
6236 The above table describes the most basic keystrokes that you need in
6237 order to do editing of the input line.  For your convenience, many
6238 other commands have been added in addition to `C-b', `C-f', `C-d', and
6239 <DEL>.  Here are some commands for moving more rapidly about the line.
6240
6241 `C-a'
6242      Move to the start of the line.
6243
6244 `C-e'
6245      Move to the end of the line.
6246
6247 `M-f'
6248      Move forward a word, where a word is composed of letters and
6249      digits.
6250
6251 `M-b'
6252      Move backward a word.
6253
6254 `C-l'
6255      Clear the screen, reprinting the current line at the top.
6256
6257    Notice how `C-f' moves forward a character, while `M-f' moves
6258 forward a word.  It is a loose convention that control keystrokes
6259 operate on characters while meta keystrokes operate on words.
6260
6261 \1f
6262 File: bashref.info,  Node: Readline Killing Commands,  Next: Readline Arguments,  Prev: Readline Movement Commands,  Up: Readline Interaction
6263
6264 8.2.3 Readline Killing Commands
6265 -------------------------------
6266
6267 "Killing" text means to delete the text from the line, but to save it
6268 away for later use, usually by "yanking" (re-inserting) it back into
6269 the line.  (`Cut' and `paste' are more recent jargon for `kill' and
6270 `yank'.)
6271
6272    If the description for a command says that it `kills' text, then you
6273 can be sure that you can get the text back in a different (or the same)
6274 place later.
6275
6276    When you use a kill command, the text is saved in a "kill-ring".
6277 Any number of consecutive kills save all of the killed text together, so
6278 that when you yank it back, you get it all.  The kill ring is not line
6279 specific; the text that you killed on a previously typed line is
6280 available to be yanked back later, when you are typing another line.  
6281
6282    Here is the list of commands for killing text.
6283
6284 `C-k'
6285      Kill the text from the current cursor position to the end of the
6286      line.
6287
6288 `M-d'
6289      Kill from the cursor to the end of the current word, or, if between
6290      words, to the end of the next word.  Word boundaries are the same
6291      as those used by `M-f'.
6292
6293 `M-<DEL>'
6294      Kill from the cursor the start of the current word, or, if between
6295      words, to the start of the previous word.  Word boundaries are the
6296      same as those used by `M-b'.
6297
6298 `C-w'
6299      Kill from the cursor to the previous whitespace.  This is
6300      different than `M-<DEL>' because the word boundaries differ.
6301
6302
6303    Here is how to "yank" the text back into the line.  Yanking means to
6304 copy the most-recently-killed text from the kill buffer.
6305
6306 `C-y'
6307      Yank the most recently killed text back into the buffer at the
6308      cursor.
6309
6310 `M-y'
6311      Rotate the kill-ring, and yank the new top.  You can only do this
6312      if the prior command is `C-y' or `M-y'.
6313
6314 \1f
6315 File: bashref.info,  Node: Readline Arguments,  Next: Searching,  Prev: Readline Killing Commands,  Up: Readline Interaction
6316
6317 8.2.4 Readline Arguments
6318 ------------------------
6319
6320 You can pass numeric arguments to Readline commands.  Sometimes the
6321 argument acts as a repeat count, other times it is the sign of the
6322 argument that is significant.  If you pass a negative argument to a
6323 command which normally acts in a forward direction, that command will
6324 act in a backward direction.  For example, to kill text back to the
6325 start of the line, you might type `M-- C-k'.
6326
6327    The general way to pass numeric arguments to a command is to type
6328 meta digits before the command.  If the first `digit' typed is a minus
6329 sign (`-'), then the sign of the argument will be negative.  Once you
6330 have typed one meta digit to get the argument started, you can type the
6331 remainder of the digits, and then the command.  For example, to give
6332 the `C-d' command an argument of 10, you could type `M-1 0 C-d', which
6333 will delete the next ten characters on the input line.
6334
6335 \1f
6336 File: bashref.info,  Node: Searching,  Prev: Readline Arguments,  Up: Readline Interaction
6337
6338 8.2.5 Searching for Commands in the History
6339 -------------------------------------------
6340
6341 Readline provides commands for searching through the command history
6342 (*note Bash History Facilities::) for lines containing a specified
6343 string.  There are two search modes:  "incremental" and
6344 "non-incremental".
6345
6346    Incremental searches begin before the user has finished typing the
6347 search string.  As each character of the search string is typed,
6348 Readline displays the next entry from the history matching the string
6349 typed so far.  An incremental search requires only as many characters
6350 as needed to find the desired history entry.  To search backward in the
6351 history for a particular string, type `C-r'.  Typing `C-s' searches
6352 forward through the history.  The characters present in the value of
6353 the `isearch-terminators' variable are used to terminate an incremental
6354 search.  If that variable has not been assigned a value, the <ESC> and
6355 `C-J' characters will terminate an incremental search.  `C-g' will
6356 abort an incremental search and restore the original line.  When the
6357 search is terminated, the history entry containing the search string
6358 becomes the current line.
6359
6360    To find other matching entries in the history list, type `C-r' or
6361 `C-s' as appropriate.  This will search backward or forward in the
6362 history for the next entry matching the search string typed so far.
6363 Any other key sequence bound to a Readline command will terminate the
6364 search and execute that command.  For instance, a <RET> will terminate
6365 the search and accept the line, thereby executing the command from the
6366 history list.  A movement command will terminate the search, make the
6367 last line found the current line, and begin editing.
6368
6369    Readline remembers the last incremental search string.  If two
6370 `C-r's are typed without any intervening characters defining a new
6371 search string, any remembered search string is used.
6372
6373    Non-incremental searches read the entire search string before
6374 starting to search for matching history lines.  The search string may be
6375 typed by the user or be part of the contents of the current line.
6376
6377 \1f
6378 File: bashref.info,  Node: Readline Init File,  Next: Bindable Readline Commands,  Prev: Readline Interaction,  Up: Command Line Editing
6379
6380 8.3 Readline Init File
6381 ======================
6382
6383 Although the Readline library comes with a set of Emacs-like
6384 keybindings installed by default, it is possible to use a different set
6385 of keybindings.  Any user can customize programs that use Readline by
6386 putting commands in an "inputrc" file, conventionally in his home
6387 directory.  The name of this file is taken from the value of the shell
6388 variable `INPUTRC'.  If that variable is unset, the default is
6389 `~/.inputrc'.  If that file does not exist or cannot be read, the
6390 ultimate default is `/etc/inputrc'.
6391
6392    When a program which uses the Readline library starts up, the init
6393 file is read, and the key bindings are set.
6394
6395    In addition, the `C-x C-r' command re-reads this init file, thus
6396 incorporating any changes that you might have made to it.
6397
6398 * Menu:
6399
6400 * Readline Init File Syntax::   Syntax for the commands in the inputrc file.
6401
6402 * Conditional Init Constructs:: Conditional key bindings in the inputrc file.
6403
6404 * Sample Init File::            An example inputrc file.
6405
6406 \1f
6407 File: bashref.info,  Node: Readline Init File Syntax,  Next: Conditional Init Constructs,  Up: Readline Init File
6408
6409 8.3.1 Readline Init File Syntax
6410 -------------------------------
6411
6412 There are only a few basic constructs allowed in the Readline init
6413 file.  Blank lines are ignored.  Lines beginning with a `#' are
6414 comments.  Lines beginning with a `$' indicate conditional constructs
6415 (*note Conditional Init Constructs::).  Other lines denote variable
6416 settings and key bindings.
6417
6418 Variable Settings
6419      You can modify the run-time behavior of Readline by altering the
6420      values of variables in Readline using the `set' command within the
6421      init file.  The syntax is simple:
6422
6423           set VARIABLE VALUE
6424
6425      Here, for example, is how to change from the default Emacs-like
6426      key binding to use `vi' line editing commands:
6427
6428           set editing-mode vi
6429
6430      Variable names and values, where appropriate, are recognized
6431      without regard to case.  Unrecognized variable names are ignored.
6432
6433      Boolean variables (those that can be set to on or off) are set to
6434      on if the value is null or empty, ON (case-insensitive), or 1.
6435      Any other value results in the variable being set to off.
6436
6437      The `bind -V' command lists the current Readline variable names
6438      and values.  *Note Bash Builtins::.
6439
6440      A great deal of run-time behavior is changeable with the following
6441      variables.
6442
6443     `bell-style'
6444           Controls what happens when Readline wants to ring the
6445           terminal bell.  If set to `none', Readline never rings the
6446           bell.  If set to `visible', Readline uses a visible bell if
6447           one is available.  If set to `audible' (the default),
6448           Readline attempts to ring the terminal's bell.
6449
6450     `bind-tty-special-chars'
6451           If set to `on', Readline attempts to bind the control
6452           characters treated specially by the kernel's terminal driver
6453           to their Readline equivalents.
6454
6455     `comment-begin'
6456           The string to insert at the beginning of the line when the
6457           `insert-comment' command is executed.  The default value is
6458           `"#"'.
6459
6460     `completion-ignore-case'
6461           If set to `on', Readline performs filename matching and
6462           completion in a case-insensitive fashion.  The default value
6463           is `off'.
6464
6465     `completion-prefix-display-length'
6466           The length in characters of the common prefix of a list of
6467           possible completions that is displayed without modification.
6468           When set to a value greater than zero, common prefixes longer
6469           than this value are replaced with an ellipsis when displaying
6470           possible completions.
6471
6472     `completion-query-items'
6473           The number of possible completions that determines when the
6474           user is asked whether the list of possibilities should be
6475           displayed.  If the number of possible completions is greater
6476           than this value, Readline will ask the user whether or not he
6477           wishes to view them; otherwise, they are simply listed.  This
6478           variable must be set to an integer value greater than or
6479           equal to 0.  A negative value means Readline should never ask.
6480           The default limit is `100'.
6481
6482     `convert-meta'
6483           If set to `on', Readline will convert characters with the
6484           eighth bit set to an ASCII key sequence by stripping the
6485           eighth bit and prefixing an <ESC> character, converting them
6486           to a meta-prefixed key sequence.  The default value is `on'.
6487
6488     `disable-completion'
6489           If set to `On', Readline will inhibit word completion.
6490           Completion  characters will be inserted into the line as if
6491           they had been mapped to `self-insert'.  The default is `off'.
6492
6493     `editing-mode'
6494           The `editing-mode' variable controls which default set of key
6495           bindings is used.  By default, Readline starts up in Emacs
6496           editing mode, where the keystrokes are most similar to Emacs.
6497           This variable can be set to either `emacs' or `vi'.
6498
6499     `echo-control-characters'
6500           When set to `on', on operating systems that indicate they
6501           support it, readline echoes a character corresponding to a
6502           signal generated from the keyboard.  The default is `on'.
6503
6504     `enable-keypad'
6505           When set to `on', Readline will try to enable the application
6506           keypad when it is called.  Some systems need this to enable
6507           the arrow keys.  The default is `off'.
6508
6509     `enable-meta-key'
6510           When set to `on', Readline will try to enable any meta
6511           modifier key the terminal claims to support when it is
6512           called.  On many terminals, the meta key is used to send
6513           eight-bit characters.  The default is `on'.
6514
6515     `expand-tilde'
6516           If set to `on', tilde expansion is performed when Readline
6517           attempts word completion.  The default is `off'.
6518
6519     `history-preserve-point'
6520           If set to `on', the history code attempts to place the point
6521           (the current cursor position) at the same location on each
6522           history line retrieved with `previous-history' or
6523           `next-history'.  The default is `off'.
6524
6525     `history-size'
6526           Set the maximum number of history entries saved in the
6527           history list.  If set to zero, the number of entries in the
6528           history list is not limited.
6529
6530     `horizontal-scroll-mode'
6531           This variable can be set to either `on' or `off'.  Setting it
6532           to `on' means that the text of the lines being edited will
6533           scroll horizontally on a single screen line when they are
6534           longer than the width of the screen, instead of wrapping onto
6535           a new screen line.  By default, this variable is set to `off'.
6536
6537     `input-meta'
6538           If set to `on', Readline will enable eight-bit input (it will
6539           not clear the eighth bit in the characters it reads),
6540           regardless of what the terminal claims it can support.  The
6541           default value is `off'.  The name `meta-flag' is a synonym
6542           for this variable.
6543
6544     `isearch-terminators'
6545           The string of characters that should terminate an incremental
6546           search without subsequently executing the character as a
6547           command (*note Searching::).  If this variable has not been
6548           given a value, the characters <ESC> and `C-J' will terminate
6549           an incremental search.
6550
6551     `keymap'
6552           Sets Readline's idea of the current keymap for key binding
6553           commands.  Acceptable `keymap' names are `emacs',
6554           `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
6555           `vi-command', and `vi-insert'.  `vi' is equivalent to
6556           `vi-command'; `emacs' is equivalent to `emacs-standard'.  The
6557           default value is `emacs'.  The value of the `editing-mode'
6558           variable also affects the default keymap.
6559
6560     `mark-directories'
6561           If set to `on', completed directory names have a slash
6562           appended.  The default is `on'.
6563
6564     `mark-modified-lines'
6565           This variable, when set to `on', causes Readline to display an
6566           asterisk (`*') at the start of history lines which have been
6567           modified.  This variable is `off' by default.
6568
6569     `mark-symlinked-directories'
6570           If set to `on', completed names which are symbolic links to
6571           directories have a slash appended (subject to the value of
6572           `mark-directories').  The default is `off'.
6573
6574     `match-hidden-files'
6575           This variable, when set to `on', causes Readline to match
6576           files whose names begin with a `.' (hidden files) when
6577           performing filename completion, unless the leading `.' is
6578           supplied by the user in the filename to be completed.  This
6579           variable is `on' by default.
6580
6581     `output-meta'
6582           If set to `on', Readline will display characters with the
6583           eighth bit set directly rather than as a meta-prefixed escape
6584           sequence.  The default is `off'.
6585
6586     `page-completions'
6587           If set to `on', Readline uses an internal `more'-like pager
6588           to display a screenful of possible completions at a time.
6589           This variable is `on' by default.
6590
6591     `print-completions-horizontally'
6592           If set to `on', Readline will display completions with matches
6593           sorted horizontally in alphabetical order, rather than down
6594           the screen.  The default is `off'.
6595
6596     `revert-all-at-newline'
6597           If set to `on', Readline will undo all changes to history
6598           lines before returning when `accept-line' is executed.  By
6599           default, history lines may be modified and retain individual
6600           undo lists across calls to `readline'.  The default is `off'.
6601
6602     `show-all-if-ambiguous'
6603           This alters the default behavior of the completion functions.
6604           If set to `on', words which have more than one possible
6605           completion cause the matches to be listed immediately instead
6606           of ringing the bell.  The default value is `off'.
6607
6608     `show-all-if-unmodified'
6609           This alters the default behavior of the completion functions
6610           in a fashion similar to SHOW-ALL-IF-AMBIGUOUS.  If set to
6611           `on', words which have more than one possible completion
6612           without any possible partial completion (the possible
6613           completions don't share a common prefix) cause the matches to
6614           be listed immediately instead of ringing the bell.  The
6615           default value is `off'.
6616
6617     `skip-completed-text'
6618           If set to `on', this alters the default completion behavior
6619           when inserting a single match into the line.  It's only
6620           active when performing completion in the middle of a word.
6621           If enabled, readline does not insert characters from the
6622           completion that match characters after point in the word
6623           being completed, so portions of the word following the cursor
6624           are not duplicated.  For instance, if this is enabled,
6625           attempting completion when the cursor is after the `e' in
6626           `Makefile' will result in `Makefile' rather than
6627           `Makefilefile', assuming there is a single possible
6628           completion.  The default value is `off'.
6629
6630     `visible-stats'
6631           If set to `on', a character denoting a file's type is
6632           appended to the filename when listing possible completions.
6633           The default is `off'.
6634
6635
6636 Key Bindings
6637      The syntax for controlling key bindings in the init file is
6638      simple.  First you need to find the name of the command that you
6639      want to change.  The following sections contain tables of the
6640      command name, the default keybinding, if any, and a short
6641      description of what the command does.
6642
6643      Once you know the name of the command, simply place on a line in
6644      the init file the name of the key you wish to bind the command to,
6645      a colon, and then the name of the command.  There can be no space
6646      between the key name and the colon - that will be interpreted as
6647      part of the key name.  The name of the key can be expressed in
6648      different ways, depending on what you find most comfortable.
6649
6650      In addition to command names, readline allows keys to be bound to
6651      a string that is inserted when the key is pressed (a MACRO).
6652
6653      The `bind -p' command displays Readline function names and
6654      bindings in a format that can put directly into an initialization
6655      file.  *Note Bash Builtins::.
6656
6657     KEYNAME: FUNCTION-NAME or MACRO
6658           KEYNAME is the name of a key spelled out in English.  For
6659           example:
6660                Control-u: universal-argument
6661                Meta-Rubout: backward-kill-word
6662                Control-o: "> output"
6663
6664           In the above example, `C-u' is bound to the function
6665           `universal-argument', `M-DEL' is bound to the function
6666           `backward-kill-word', and `C-o' is bound to run the macro
6667           expressed on the right hand side (that is, to insert the text
6668           `> output' into the line).
6669
6670           A number of symbolic character names are recognized while
6671           processing this key binding syntax: DEL, ESC, ESCAPE, LFD,
6672           NEWLINE, RET, RETURN, RUBOUT, SPACE, SPC, and TAB.
6673
6674     "KEYSEQ": FUNCTION-NAME or MACRO
6675           KEYSEQ differs from KEYNAME above in that strings denoting an
6676           entire key sequence can be specified, by placing the key
6677           sequence in double quotes.  Some GNU Emacs style key escapes
6678           can be used, as in the following example, but the special
6679           character names are not recognized.
6680
6681                "\C-u": universal-argument
6682                "\C-x\C-r": re-read-init-file
6683                "\e[11~": "Function Key 1"
6684
6685           In the above example, `C-u' is again bound to the function
6686           `universal-argument' (just as it was in the first example),
6687           `C-x C-r' is bound to the function `re-read-init-file', and
6688           `<ESC> <[> <1> <1> <~>' is bound to insert the text `Function
6689           Key 1'.
6690
6691
6692      The following GNU Emacs style escape sequences are available when
6693      specifying key sequences:
6694
6695     `\C-'
6696           control prefix
6697
6698     `\M-'
6699           meta prefix
6700
6701     `\e'
6702           an escape character
6703
6704     `\\'
6705           backslash
6706
6707     `\"'
6708           <">, a double quotation mark
6709
6710     `\''
6711           <'>, a single quote or apostrophe
6712
6713      In addition to the GNU Emacs style escape sequences, a second set
6714      of backslash escapes is available:
6715
6716     `\a'
6717           alert (bell)
6718
6719     `\b'
6720           backspace
6721
6722     `\d'
6723           delete
6724
6725     `\f'
6726           form feed
6727
6728     `\n'
6729           newline
6730
6731     `\r'
6732           carriage return
6733
6734     `\t'
6735           horizontal tab
6736
6737     `\v'
6738           vertical tab
6739
6740     `\NNN'
6741           the eight-bit character whose value is the octal value NNN
6742           (one to three digits)
6743
6744     `\xHH'
6745           the eight-bit character whose value is the hexadecimal value
6746           HH (one or two hex digits)
6747
6748      When entering the text of a macro, single or double quotes must be
6749      used to indicate a macro definition.  Unquoted text is assumed to
6750      be a function name.  In the macro body, the backslash escapes
6751      described above are expanded.  Backslash will quote any other
6752      character in the macro text, including `"' and `''.  For example,
6753      the following binding will make `C-x \' insert a single `\' into
6754      the line:
6755           "\C-x\\": "\\"
6756
6757
6758 \1f
6759 File: bashref.info,  Node: Conditional Init Constructs,  Next: Sample Init File,  Prev: Readline Init File Syntax,  Up: Readline Init File
6760
6761 8.3.2 Conditional Init Constructs
6762 ---------------------------------
6763
6764 Readline implements a facility similar in spirit to the conditional
6765 compilation features of the C preprocessor which allows key bindings
6766 and variable settings to be performed as the result of tests.  There
6767 are four parser directives used.
6768
6769 `$if'
6770      The `$if' construct allows bindings to be made based on the
6771      editing mode, the terminal being used, or the application using
6772      Readline.  The text of the test extends to the end of the line; no
6773      characters are required to isolate it.
6774
6775     `mode'
6776           The `mode=' form of the `$if' directive is used to test
6777           whether Readline is in `emacs' or `vi' mode.  This may be
6778           used in conjunction with the `set keymap' command, for
6779           instance, to set bindings in the `emacs-standard' and
6780           `emacs-ctlx' keymaps only if Readline is starting out in
6781           `emacs' mode.
6782
6783     `term'
6784           The `term=' form may be used to include terminal-specific key
6785           bindings, perhaps to bind the key sequences output by the
6786           terminal's function keys.  The word on the right side of the
6787           `=' is tested against both the full name of the terminal and
6788           the portion of the terminal name before the first `-'.  This
6789           allows `sun' to match both `sun' and `sun-cmd', for instance.
6790
6791     `application'
6792           The APPLICATION construct is used to include
6793           application-specific settings.  Each program using the
6794           Readline library sets the APPLICATION NAME, and you can test
6795           for a particular value.  This could be used to bind key
6796           sequences to functions useful for a specific program.  For
6797           instance, the following command adds a key sequence that
6798           quotes the current or previous word in Bash:
6799                $if Bash
6800                # Quote the current or previous word
6801                "\C-xq": "\eb\"\ef\""
6802                $endif
6803
6804 `$endif'
6805      This command, as seen in the previous example, terminates an `$if'
6806      command.
6807
6808 `$else'
6809      Commands in this branch of the `$if' directive are executed if the
6810      test fails.
6811
6812 `$include'
6813      This directive takes a single filename as an argument and reads
6814      commands and bindings from that file.  For example, the following
6815      directive reads from `/etc/inputrc':
6816           $include /etc/inputrc
6817
6818 \1f
6819 File: bashref.info,  Node: Sample Init File,  Prev: Conditional Init Constructs,  Up: Readline Init File
6820
6821 8.3.3 Sample Init File
6822 ----------------------
6823
6824 Here is an example of an INPUTRC file.  This illustrates key binding,
6825 variable assignment, and conditional syntax.
6826
6827
6828      # This file controls the behaviour of line input editing for
6829      # programs that use the GNU Readline library.  Existing
6830      # programs include FTP, Bash, and GDB.
6831      #
6832      # You can re-read the inputrc file with C-x C-r.
6833      # Lines beginning with '#' are comments.
6834      #
6835      # First, include any systemwide bindings and variable
6836      # assignments from /etc/Inputrc
6837      $include /etc/Inputrc
6838
6839      #
6840      # Set various bindings for emacs mode.
6841
6842      set editing-mode emacs
6843
6844      $if mode=emacs
6845
6846      Meta-Control-h:    backward-kill-word      Text after the function name is ignored
6847
6848      #
6849      # Arrow keys in keypad mode
6850      #
6851      #"\M-OD":        backward-char
6852      #"\M-OC":        forward-char
6853      #"\M-OA":        previous-history
6854      #"\M-OB":        next-history
6855      #
6856      # Arrow keys in ANSI mode
6857      #
6858      "\M-[D":        backward-char
6859      "\M-[C":        forward-char
6860      "\M-[A":        previous-history
6861      "\M-[B":        next-history
6862      #
6863      # Arrow keys in 8 bit keypad mode
6864      #
6865      #"\M-\C-OD":       backward-char
6866      #"\M-\C-OC":       forward-char
6867      #"\M-\C-OA":       previous-history
6868      #"\M-\C-OB":       next-history
6869      #
6870      # Arrow keys in 8 bit ANSI mode
6871      #
6872      #"\M-\C-[D":       backward-char
6873      #"\M-\C-[C":       forward-char
6874      #"\M-\C-[A":       previous-history
6875      #"\M-\C-[B":       next-history
6876
6877      C-q: quoted-insert
6878
6879      $endif
6880
6881      # An old-style binding.  This happens to be the default.
6882      TAB: complete
6883
6884      # Macros that are convenient for shell interaction
6885      $if Bash
6886      # edit the path
6887      "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
6888      # prepare to type a quoted word --
6889      # insert open and close double quotes
6890      # and move to just after the open quote
6891      "\C-x\"": "\"\"\C-b"
6892      # insert a backslash (testing backslash escapes
6893      # in sequences and macros)
6894      "\C-x\\": "\\"
6895      # Quote the current or previous word
6896      "\C-xq": "\eb\"\ef\""
6897      # Add a binding to refresh the line, which is unbound
6898      "\C-xr": redraw-current-line
6899      # Edit variable on current line.
6900      "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
6901      $endif
6902
6903      # use a visible bell if one is available
6904      set bell-style visible
6905
6906      # don't strip characters to 7 bits when reading
6907      set input-meta on
6908
6909      # allow iso-latin1 characters to be inserted rather
6910      # than converted to prefix-meta sequences
6911      set convert-meta off
6912
6913      # display characters with the eighth bit set directly
6914      # rather than as meta-prefixed characters
6915      set output-meta on
6916
6917      # if there are more than 150 possible completions for
6918      # a word, ask the user if he wants to see all of them
6919      set completion-query-items 150
6920
6921      # For FTP
6922      $if Ftp
6923      "\C-xg": "get \M-?"
6924      "\C-xt": "put \M-?"
6925      "\M-.": yank-last-arg
6926      $endif
6927
6928 \1f
6929 File: bashref.info,  Node: Bindable Readline Commands,  Next: Readline vi Mode,  Prev: Readline Init File,  Up: Command Line Editing
6930
6931 8.4 Bindable Readline Commands
6932 ==============================
6933
6934 * Menu:
6935
6936 * Commands For Moving::         Moving about the line.
6937 * Commands For History::        Getting at previous lines.
6938 * Commands For Text::           Commands for changing text.
6939 * Commands For Killing::        Commands for killing and yanking.
6940 * Numeric Arguments::           Specifying numeric arguments, repeat counts.
6941 * Commands For Completion::     Getting Readline to do the typing for you.
6942 * Keyboard Macros::             Saving and re-executing typed characters
6943 * Miscellaneous Commands::      Other miscellaneous commands.
6944
6945    This section describes Readline commands that may be bound to key
6946 sequences.  You can list your key bindings by executing `bind -P' or,
6947 for a more terse format, suitable for an INPUTRC file, `bind -p'.
6948 (*Note Bash Builtins::.)  Command names without an accompanying key
6949 sequence are unbound by default.
6950
6951    In the following descriptions, "point" refers to the current cursor
6952 position, and "mark" refers to a cursor position saved by the
6953 `set-mark' command.  The text between the point and mark is referred to
6954 as the "region".
6955
6956 \1f
6957 File: bashref.info,  Node: Commands For Moving,  Next: Commands For History,  Up: Bindable Readline Commands
6958
6959 8.4.1 Commands For Moving
6960 -------------------------
6961
6962 `beginning-of-line (C-a)'
6963      Move to the start of the current line.
6964
6965 `end-of-line (C-e)'
6966      Move to the end of the line.
6967
6968 `forward-char (C-f)'
6969      Move forward a character.
6970
6971 `backward-char (C-b)'
6972      Move back a character.
6973
6974 `forward-word (M-f)'
6975      Move forward to the end of the next word.  Words are composed of
6976      letters and digits.
6977
6978 `backward-word (M-b)'
6979      Move back to the start of the current or previous word.  Words are
6980      composed of letters and digits.
6981
6982 `shell-forward-word ()'
6983      Move forward to the end of the next word.  Words are delimited by
6984      non-quoted shell metacharacters.
6985
6986 `shell-backward-word ()'
6987      Move back to the start of the current or previous word.  Words are
6988      delimited by non-quoted shell metacharacters.
6989
6990 `clear-screen (C-l)'
6991      Clear the screen and redraw the current line, leaving the current
6992      line at the top of the screen.
6993
6994 `redraw-current-line ()'
6995      Refresh the current line.  By default, this is unbound.
6996
6997
6998 \1f
6999 File: bashref.info,  Node: Commands For History,  Next: Commands For Text,  Prev: Commands For Moving,  Up: Bindable Readline Commands
7000
7001 8.4.2 Commands For Manipulating The History
7002 -------------------------------------------
7003
7004 `accept-line (Newline or Return)'
7005      Accept the line regardless of where the cursor is.  If this line is
7006      non-empty, add it to the history list according to the setting of
7007      the `HISTCONTROL' and `HISTIGNORE' variables.  If this line is a
7008      modified history line, then restore the history line to its
7009      original state.
7010
7011 `previous-history (C-p)'
7012      Move `back' through the history list, fetching the previous
7013      command.
7014
7015 `next-history (C-n)'
7016      Move `forward' through the history list, fetching the next command.
7017
7018 `beginning-of-history (M-<)'
7019      Move to the first line in the history.
7020
7021 `end-of-history (M->)'
7022      Move to the end of the input history, i.e., the line currently
7023      being entered.
7024
7025 `reverse-search-history (C-r)'
7026      Search backward starting at the current line and moving `up'
7027      through the history as necessary.  This is an incremental search.
7028
7029 `forward-search-history (C-s)'
7030      Search forward starting at the current line and moving `down'
7031      through the the history as necessary.  This is an incremental
7032      search.
7033
7034 `non-incremental-reverse-search-history (M-p)'
7035      Search backward starting at the current line and moving `up'
7036      through the history as necessary using a non-incremental search
7037      for a string supplied by the user.
7038
7039 `non-incremental-forward-search-history (M-n)'
7040      Search forward starting at the current line and moving `down'
7041      through the the history as necessary using a non-incremental search
7042      for a string supplied by the user.
7043
7044 `history-search-forward ()'
7045      Search forward through the history for the string of characters
7046      between the start of the current line and the point.  This is a
7047      non-incremental search.  By default, this command is unbound.
7048
7049 `history-search-backward ()'
7050      Search backward through the history for the string of characters
7051      between the start of the current line and the point.  This is a
7052      non-incremental search.  By default, this command is unbound.
7053
7054 `yank-nth-arg (M-C-y)'
7055      Insert the first argument to the previous command (usually the
7056      second word on the previous line) at point.  With an argument N,
7057      insert the Nth word from the previous command (the words in the
7058      previous command begin with word 0).  A negative argument inserts
7059      the Nth word from the end of the previous command.  Once the
7060      argument N is computed, the argument is extracted as if the `!N'
7061      history expansion had been specified.
7062
7063 `yank-last-arg (M-. or M-_)'
7064      Insert last argument to the previous command (the last word of the
7065      previous history entry).  With an argument, behave exactly like
7066      `yank-nth-arg'.  Successive calls to `yank-last-arg' move back
7067      through the history list, inserting the last argument of each line
7068      in turn.  The history expansion facilities are used to extract the
7069      last argument, as if the `!$' history expansion had been specified.
7070
7071
7072 \1f
7073 File: bashref.info,  Node: Commands For Text,  Next: Commands For Killing,  Prev: Commands For History,  Up: Bindable Readline Commands
7074
7075 8.4.3 Commands For Changing Text
7076 --------------------------------
7077
7078 `delete-char (C-d)'
7079      Delete the character at point.  If point is at the beginning of
7080      the line, there are no characters in the line, and the last
7081      character typed was not bound to `delete-char', then return EOF.
7082
7083 `backward-delete-char (Rubout)'
7084      Delete the character behind the cursor.  A numeric argument means
7085      to kill the characters instead of deleting them.
7086
7087 `forward-backward-delete-char ()'
7088      Delete the character under the cursor, unless the cursor is at the
7089      end of the line, in which case the character behind the cursor is
7090      deleted.  By default, this is not bound to a key.
7091
7092 `quoted-insert (C-q or C-v)'
7093      Add the next character typed to the line verbatim.  This is how to
7094      insert key sequences like `C-q', for example.
7095
7096 `self-insert (a, b, A, 1, !, ...)'
7097      Insert yourself.
7098
7099 `transpose-chars (C-t)'
7100      Drag the character before the cursor forward over the character at
7101      the cursor, moving the cursor forward as well.  If the insertion
7102      point is at the end of the line, then this transposes the last two
7103      characters of the line.  Negative arguments have no effect.
7104
7105 `transpose-words (M-t)'
7106      Drag the word before point past the word after point, moving point
7107      past that word as well.  If the insertion point is at the end of
7108      the line, this transposes the last two words on the line.
7109
7110 `upcase-word (M-u)'
7111      Uppercase the current (or following) word.  With a negative
7112      argument, uppercase the previous word, but do not move the cursor.
7113
7114 `downcase-word (M-l)'
7115      Lowercase the current (or following) word.  With a negative
7116      argument, lowercase the previous word, but do not move the cursor.
7117
7118 `capitalize-word (M-c)'
7119      Capitalize the current (or following) word.  With a negative
7120      argument, capitalize the previous word, but do not move the cursor.
7121
7122 `overwrite-mode ()'
7123      Toggle overwrite mode.  With an explicit positive numeric argument,
7124      switches to overwrite mode.  With an explicit non-positive numeric
7125      argument, switches to insert mode.  This command affects only
7126      `emacs' mode; `vi' mode does overwrite differently.  Each call to
7127      `readline()' starts in insert mode.
7128
7129      In overwrite mode, characters bound to `self-insert' replace the
7130      text at point rather than pushing the text to the right.
7131      Characters bound to `backward-delete-char' replace the character
7132      before point with a space.
7133
7134      By default, this command is unbound.
7135
7136
7137 \1f
7138 File: bashref.info,  Node: Commands For Killing,  Next: Numeric Arguments,  Prev: Commands For Text,  Up: Bindable Readline Commands
7139
7140 8.4.4 Killing And Yanking
7141 -------------------------
7142
7143 `kill-line (C-k)'
7144      Kill the text from point to the end of the line.
7145
7146 `backward-kill-line (C-x Rubout)'
7147      Kill backward to the beginning of the line.
7148
7149 `unix-line-discard (C-u)'
7150      Kill backward from the cursor to the beginning of the current line.
7151
7152 `kill-whole-line ()'
7153      Kill all characters on the current line, no matter where point is.
7154      By default, this is unbound.
7155
7156 `kill-word (M-d)'
7157      Kill from point to the end of the current word, or if between
7158      words, to the end of the next word.  Word boundaries are the same
7159      as `forward-word'.
7160
7161 `backward-kill-word (M-<DEL>)'
7162      Kill the word behind point.  Word boundaries are the same as
7163      `backward-word'.
7164
7165 `shell-kill-word ()'
7166      Kill from point to the end of the current word, or if between
7167      words, to the end of the next word.  Word boundaries are the same
7168      as `shell-forward-word'.
7169
7170 `backward-kill-word ()'
7171      Kill the word behind point.  Word boundaries are the same as
7172      `shell-backward-word'.
7173
7174 `unix-word-rubout (C-w)'
7175      Kill the word behind point, using white space as a word boundary.
7176      The killed text is saved on the kill-ring.
7177
7178 `unix-filename-rubout ()'
7179      Kill the word behind point, using white space and the slash
7180      character as the word boundaries.  The killed text is saved on the
7181      kill-ring.
7182
7183 `delete-horizontal-space ()'
7184      Delete all spaces and tabs around point.  By default, this is
7185      unbound.
7186
7187 `kill-region ()'
7188      Kill the text in the current region.  By default, this command is
7189      unbound.
7190
7191 `copy-region-as-kill ()'
7192      Copy the text in the region to the kill buffer, so it can be yanked
7193      right away.  By default, this command is unbound.
7194
7195 `copy-backward-word ()'
7196      Copy the word before point to the kill buffer.  The word
7197      boundaries are the same as `backward-word'.  By default, this
7198      command is unbound.
7199
7200 `copy-forward-word ()'
7201      Copy the word following point to the kill buffer.  The word
7202      boundaries are the same as `forward-word'.  By default, this
7203      command is unbound.
7204
7205 `yank (C-y)'
7206      Yank the top of the kill ring into the buffer at point.
7207
7208 `yank-pop (M-y)'
7209      Rotate the kill-ring, and yank the new top.  You can only do this
7210      if the prior command is `yank' or `yank-pop'.
7211
7212 \1f
7213 File: bashref.info,  Node: Numeric Arguments,  Next: Commands For Completion,  Prev: Commands For Killing,  Up: Bindable Readline Commands
7214
7215 8.4.5 Specifying Numeric Arguments
7216 ----------------------------------
7217
7218 `digit-argument (M-0, M-1, ... M--)'
7219      Add this digit to the argument already accumulating, or start a new
7220      argument.  `M--' starts a negative argument.
7221
7222 `universal-argument ()'
7223      This is another way to specify an argument.  If this command is
7224      followed by one or more digits, optionally with a leading minus
7225      sign, those digits define the argument.  If the command is
7226      followed by digits, executing `universal-argument' again ends the
7227      numeric argument, but is otherwise ignored.  As a special case, if
7228      this command is immediately followed by a character that is
7229      neither a digit or minus sign, the argument count for the next
7230      command is multiplied by four.  The argument count is initially
7231      one, so executing this function the first time makes the argument
7232      count four, a second time makes the argument count sixteen, and so
7233      on.  By default, this is not bound to a key.
7234
7235 \1f
7236 File: bashref.info,  Node: Commands For Completion,  Next: Keyboard Macros,  Prev: Numeric Arguments,  Up: Bindable Readline Commands
7237
7238 8.4.6 Letting Readline Type For You
7239 -----------------------------------
7240
7241 `complete (<TAB>)'
7242      Attempt to perform completion on the text before point.  The
7243      actual completion performed is application-specific.  Bash
7244      attempts completion treating the text as a variable (if the text
7245      begins with `$'), username (if the text begins with `~'), hostname
7246      (if the text begins with `@'), or command (including aliases and
7247      functions) in turn.  If none of these produces a match, filename
7248      completion is attempted.
7249
7250 `possible-completions (M-?)'
7251      List the possible completions of the text before point.
7252
7253 `insert-completions (M-*)'
7254      Insert all completions of the text before point that would have
7255      been generated by `possible-completions'.
7256
7257 `menu-complete ()'
7258      Similar to `complete', but replaces the word to be completed with
7259      a single match from the list of possible completions.  Repeated
7260      execution of `menu-complete' steps through the list of possible
7261      completions, inserting each match in turn.  At the end of the list
7262      of completions, the bell is rung (subject to the setting of
7263      `bell-style') and the original text is restored.  An argument of N
7264      moves N positions forward in the list of matches; a negative
7265      argument may be used to move backward through the list.  This
7266      command is intended to be bound to <TAB>, but is unbound by
7267      default.
7268
7269 `menu-complete-backward ()'
7270      Identical to `menu-complete', but moves backward through the list
7271      of possible completions, as if `menu-complete' had been given a
7272      negative argument.
7273
7274 `delete-char-or-list ()'
7275      Deletes the character under the cursor if not at the beginning or
7276      end of the line (like `delete-char').  If at the end of the line,
7277      behaves identically to `possible-completions'.  This command is
7278      unbound by default.
7279
7280 `complete-filename (M-/)'
7281      Attempt filename completion on the text before point.
7282
7283 `possible-filename-completions (C-x /)'
7284      List the possible completions of the text before point, treating
7285      it as a filename.
7286
7287 `complete-username (M-~)'
7288      Attempt completion on the text before point, treating it as a
7289      username.
7290
7291 `possible-username-completions (C-x ~)'
7292      List the possible completions of the text before point, treating
7293      it as a username.
7294
7295 `complete-variable (M-$)'
7296      Attempt completion on the text before point, treating it as a
7297      shell variable.
7298
7299 `possible-variable-completions (C-x $)'
7300      List the possible completions of the text before point, treating
7301      it as a shell variable.
7302
7303 `complete-hostname (M-@)'
7304      Attempt completion on the text before point, treating it as a
7305      hostname.
7306
7307 `possible-hostname-completions (C-x @)'
7308      List the possible completions of the text before point, treating
7309      it as a hostname.
7310
7311 `complete-command (M-!)'
7312      Attempt completion on the text before point, treating it as a
7313      command name.  Command completion attempts to match the text
7314      against aliases, reserved words, shell functions, shell builtins,
7315      and finally executable filenames, in that order.
7316
7317 `possible-command-completions (C-x !)'
7318      List the possible completions of the text before point, treating
7319      it as a command name.
7320
7321 `dynamic-complete-history (M-<TAB>)'
7322      Attempt completion on the text before point, comparing the text
7323      against lines from the history list for possible completion
7324      matches.
7325
7326 `dabbrev-expand ()'
7327      Attempt menu completion on the text before point, comparing the
7328      text against lines from the history list for possible completion
7329      matches.
7330
7331 `complete-into-braces (M-{)'
7332      Perform filename completion and insert the list of possible
7333      completions enclosed within braces so the list is available to the
7334      shell (*note Brace Expansion::).
7335
7336
7337 \1f
7338 File: bashref.info,  Node: Keyboard Macros,  Next: Miscellaneous Commands,  Prev: Commands For Completion,  Up: Bindable Readline Commands
7339
7340 8.4.7 Keyboard Macros
7341 ---------------------
7342
7343 `start-kbd-macro (C-x ()'
7344      Begin saving the characters typed into the current keyboard macro.
7345
7346 `end-kbd-macro (C-x ))'
7347      Stop saving the characters typed into the current keyboard macro
7348      and save the definition.
7349
7350 `call-last-kbd-macro (C-x e)'
7351      Re-execute the last keyboard macro defined, by making the
7352      characters in the macro appear as if typed at the keyboard.
7353
7354
7355 \1f
7356 File: bashref.info,  Node: Miscellaneous Commands,  Prev: Keyboard Macros,  Up: Bindable Readline Commands
7357
7358 8.4.8 Some Miscellaneous Commands
7359 ---------------------------------
7360
7361 `re-read-init-file (C-x C-r)'
7362      Read in the contents of the INPUTRC file, and incorporate any
7363      bindings or variable assignments found there.
7364
7365 `abort (C-g)'
7366      Abort the current editing command and ring the terminal's bell
7367      (subject to the setting of `bell-style').
7368
7369 `do-uppercase-version (M-a, M-b, M-X, ...)'
7370      If the metafied character X is lowercase, run the command that is
7371      bound to the corresponding uppercase character.
7372
7373 `prefix-meta (<ESC>)'
7374      Metafy the next character typed.  This is for keyboards without a
7375      meta key.  Typing `<ESC> f' is equivalent to typing `M-f'.
7376
7377 `undo (C-_ or C-x C-u)'
7378      Incremental undo, separately remembered for each line.
7379
7380 `revert-line (M-r)'
7381      Undo all changes made to this line.  This is like executing the
7382      `undo' command enough times to get back to the beginning.
7383
7384 `tilde-expand (M-&)'
7385      Perform tilde expansion on the current word.
7386
7387 `set-mark (C-@)'
7388      Set the mark to the point.  If a numeric argument is supplied, the
7389      mark is set to that position.
7390
7391 `exchange-point-and-mark (C-x C-x)'
7392      Swap the point with the mark.  The current cursor position is set
7393      to the saved position, and the old cursor position is saved as the
7394      mark.
7395
7396 `character-search (C-])'
7397      A character is read and point is moved to the next occurrence of
7398      that character.  A negative count searches for previous
7399      occurrences.
7400
7401 `character-search-backward (M-C-])'
7402      A character is read and point is moved to the previous occurrence
7403      of that character.  A negative count searches for subsequent
7404      occurrences.
7405
7406 `skip-csi-sequence ()'
7407      Read enough characters to consume a multi-key sequence such as
7408      those defined for keys like Home and End.  Such sequences begin
7409      with a Control Sequence Indicator (CSI), usually ESC-[.  If this
7410      sequence is bound to "\e[", keys producing such sequences will
7411      have no effect unless explicitly bound to a readline command,
7412      instead of inserting stray characters into the editing buffer.
7413      This is unbound by default, but usually bound to ESC-[.
7414
7415 `insert-comment (M-#)'
7416      Without a numeric argument, the value of the `comment-begin'
7417      variable is inserted at the beginning of the current line.  If a
7418      numeric argument is supplied, this command acts as a toggle:  if
7419      the characters at the beginning of the line do not match the value
7420      of `comment-begin', the value is inserted, otherwise the
7421      characters in `comment-begin' are deleted from the beginning of
7422      the line.  In either case, the line is accepted as if a newline
7423      had been typed.  The default value of `comment-begin' causes this
7424      command to make the current line a shell comment.  If a numeric
7425      argument causes the comment character to be removed, the line will
7426      be executed by the shell.
7427
7428 `dump-functions ()'
7429      Print all of the functions and their key bindings to the Readline
7430      output stream.  If a numeric argument is supplied, the output is
7431      formatted in such a way that it can be made part of an INPUTRC
7432      file.  This command is unbound by default.
7433
7434 `dump-variables ()'
7435      Print all of the settable variables and their values to the
7436      Readline output stream.  If a numeric argument is supplied, the
7437      output is formatted in such a way that it can be made part of an
7438      INPUTRC file.  This command is unbound by default.
7439
7440 `dump-macros ()'
7441      Print all of the Readline key sequences bound to macros and the
7442      strings they output.  If a numeric argument is supplied, the
7443      output is formatted in such a way that it can be made part of an
7444      INPUTRC file.  This command is unbound by default.
7445
7446 `glob-complete-word (M-g)'
7447      The word before point is treated as a pattern for pathname
7448      expansion, with an asterisk implicitly appended.  This pattern is
7449      used to generate a list of matching file names for possible
7450      completions.
7451
7452 `glob-expand-word (C-x *)'
7453      The word before point is treated as a pattern for pathname
7454      expansion, and the list of matching file names is inserted,
7455      replacing the word.  If a numeric argument is supplied, a `*' is
7456      appended before pathname expansion.
7457
7458 `glob-list-expansions (C-x g)'
7459      The list of expansions that would have been generated by
7460      `glob-expand-word' is displayed, and the line is redrawn.  If a
7461      numeric argument is supplied, a `*' is appended before pathname
7462      expansion.
7463
7464 `display-shell-version (C-x C-v)'
7465      Display version information about the current instance of Bash.
7466
7467 `shell-expand-line (M-C-e)'
7468      Expand the line as the shell does.  This performs alias and
7469      history expansion as well as all of the shell word expansions
7470      (*note Shell Expansions::).
7471
7472 `history-expand-line (M-^)'
7473      Perform history expansion on the current line.
7474
7475 `magic-space ()'
7476      Perform history expansion on the current line and insert a space
7477      (*note History Interaction::).
7478
7479 `alias-expand-line ()'
7480      Perform alias expansion on the current line (*note Aliases::).
7481
7482 `history-and-alias-expand-line ()'
7483      Perform history and alias expansion on the current line.
7484
7485 `insert-last-argument (M-. or M-_)'
7486      A synonym for `yank-last-arg'.
7487
7488 `operate-and-get-next (C-o)'
7489      Accept the current line for execution and fetch the next line
7490      relative to the current line from the history for editing.  Any
7491      argument is ignored.
7492
7493 `edit-and-execute-command (C-xC-e)'
7494      Invoke an editor on the current command line, and execute the
7495      result as shell commands.  Bash attempts to invoke `$VISUAL',
7496      `$EDITOR', and `emacs' as the editor, in that order.
7497
7498
7499 \1f
7500 File: bashref.info,  Node: Readline vi Mode,  Next: Programmable Completion,  Prev: Bindable Readline Commands,  Up: Command Line Editing
7501
7502 8.5 Readline vi Mode
7503 ====================
7504
7505 While the Readline library does not have a full set of `vi' editing
7506 functions, it does contain enough to allow simple editing of the line.
7507 The Readline `vi' mode behaves as specified in the POSIX 1003.2
7508 standard.
7509
7510    In order to switch interactively between `emacs' and `vi' editing
7511 modes, use the `set -o emacs' and `set -o vi' commands (*note The Set
7512 Builtin::).  The Readline default is `emacs' mode.
7513
7514    When you enter a line in `vi' mode, you are already placed in
7515 `insertion' mode, as if you had typed an `i'.  Pressing <ESC> switches
7516 you into `command' mode, where you can edit the text of the line with
7517 the standard `vi' movement keys, move to previous history lines with
7518 `k' and subsequent lines with `j', and so forth.
7519
7520 \1f
7521 File: bashref.info,  Node: Programmable Completion,  Next: Programmable Completion Builtins,  Prev: Readline vi Mode,  Up: Command Line Editing
7522
7523 8.6 Programmable Completion
7524 ===========================
7525
7526 When word completion is attempted for an argument to a command for
7527 which a completion specification (a COMPSPEC) has been defined using
7528 the `complete' builtin (*note Programmable Completion Builtins::), the
7529 programmable completion facilities are invoked.
7530
7531    First, the command name is identified.  If a compspec has been
7532 defined for that command, the compspec is used to generate the list of
7533 possible completions for the word.  If the command word is the empty
7534 string (completion attempted at the beginning of an empty line), any
7535 compspec defined with the `-E' option to `complete' is used.  If the
7536 command word is a full pathname, a compspec for the full pathname is
7537 searched for first.  If no compspec is found for the full pathname, an
7538 attempt is made to find a compspec for the portion following the final
7539 slash.  If those searches do not result in a compspec, any compspec
7540 defined with the `-D' option to `complete' is used as the default.
7541
7542    Once a compspec has been found, it is used to generate the list of
7543 matching words.  If a compspec is not found, the default Bash completion
7544 described above (*note Commands For Completion::) is performed.
7545
7546    First, the actions specified by the compspec are used.  Only matches
7547 which are prefixed by the word being completed are returned.  When the
7548 `-f' or `-d' option is used for filename or directory name completion,
7549 the shell variable `FIGNORE' is used to filter the matches.  *Note Bash
7550 Variables::, for a description of `FIGNORE'.
7551
7552    Any completions specified by a filename expansion pattern to the
7553 `-G' option are generated next.  The words generated by the pattern
7554 need not match the word being completed.  The `GLOBIGNORE' shell
7555 variable is not used to filter the matches, but the `FIGNORE' shell
7556 variable is used.
7557
7558    Next, the string specified as the argument to the `-W' option is
7559 considered.  The string is first split using the characters in the `IFS'
7560 special variable as delimiters.  Shell quoting is honored.  Each word
7561 is then expanded using brace expansion, tilde expansion, parameter and
7562 variable expansion, command substitution, and arithmetic expansion, as
7563 described above (*note Shell Expansions::).  The results are split
7564 using the rules described above (*note Word Splitting::).  The results
7565 of the expansion are prefix-matched against the word being completed,
7566 and the matching words become the possible completions.
7567
7568    After these matches have been generated, any shell function or
7569 command specified with the `-F' and `-C' options is invoked.  When the
7570 command or function is invoked, the `COMP_LINE', `COMP_POINT',
7571 `COMP_KEY', and `COMP_TYPE' variables are assigned values as described
7572 above (*note Bash Variables::).  If a shell function is being invoked,
7573 the `COMP_WORDS' and `COMP_CWORD' variables are also set.  When the
7574 function or command is invoked, the first argument is the name of the
7575 command whose arguments are being completed, the second argument is the
7576 word being completed, and the third argument is the word preceding the
7577 word being completed on the current command line.  No filtering of the
7578 generated completions against the word being completed is performed;
7579 the function or command has complete freedom in generating the matches.
7580
7581    Any function specified with `-F' is invoked first.  The function may
7582 use any of the shell facilities, including the `compgen' and `compopt'
7583 builtins described below (*note Programmable Completion Builtins::), to
7584 generate the matches.  It must put the possible completions in the
7585 `COMPREPLY' array variable.
7586
7587    Next, any command specified with the `-C' option is invoked in an
7588 environment equivalent to command substitution.  It should print a list
7589 of completions, one per line, to the standard output.  Backslash may be
7590 used to escape a newline, if necessary.
7591
7592    After all of the possible completions are generated, any filter
7593 specified with the `-X' option is applied to the list.  The filter is a
7594 pattern as used for pathname expansion; a `&' in the pattern is
7595 replaced with the text of the word being completed.  A literal `&' may
7596 be escaped with a backslash; the backslash is removed before attempting
7597 a match.  Any completion that matches the pattern will be removed from
7598 the list.  A leading `!' negates the pattern; in this case any
7599 completion not matching the pattern will be removed.
7600
7601    Finally, any prefix and suffix specified with the `-P' and `-S'
7602 options are added to each member of the completion list, and the result
7603 is returned to the Readline completion code as the list of possible
7604 completions.
7605
7606    If the previously-applied actions do not generate any matches, and
7607 the `-o dirnames' option was supplied to `complete' when the compspec
7608 was defined, directory name completion is attempted.
7609
7610    If the `-o plusdirs' option was supplied to `complete' when the
7611 compspec was defined, directory name completion is attempted and any
7612 matches are added to the results of the other actions.
7613
7614    By default, if a compspec is found, whatever it generates is
7615 returned to the completion code as the full set of possible completions.
7616 The default Bash completions are not attempted, and the Readline default
7617 of filename completion is disabled.  If the `-o bashdefault' option was
7618 supplied to `complete' when the compspec was defined, the default Bash
7619 completions are attempted if the compspec generates no matches.  If the
7620 `-o default' option was supplied to `complete' when the compspec was
7621 defined, Readline's default completion will be performed if the
7622 compspec (and, if attempted, the default Bash completions) generate no
7623 matches.
7624
7625    When a compspec indicates that directory name completion is desired,
7626 the programmable completion functions force Readline to append a slash
7627 to completed names which are symbolic links to directories, subject to
7628 the value of the MARK-DIRECTORIES Readline variable, regardless of the
7629 setting of the MARK-SYMLINKED-DIRECTORIES Readline variable.
7630
7631    There is some support for dynamically modifying completions.  This is
7632 most useful when used in combination with a default completion specified
7633 with `-D'.  It's possible for shell functions executed as completion
7634 handlers to indicate that completion should be retried by returning an
7635 exit status of 124.  If a shell function returns 124, and changes the
7636 compspec associated with the command on which completion is being
7637 attempted (supplied as the first argument when the function is
7638 executed), programmable completion restarts from the beginning, with an
7639 attempt to find a compspec for that command.  This allows a set of
7640 completions to be built dynamically as completion is attempted, rather
7641 than being loaded all at once.
7642
7643    For instance, assuming that there is a library of compspecs, each
7644 kept in a file corresponding to the name of the command, the following
7645 default completion function would load completions dynamically:
7646
7647      _completion_loader()
7648      {
7649         . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
7650      }
7651      complete -D -F _completion_loader
7652
7653 \1f
7654 File: bashref.info,  Node: Programmable Completion Builtins,  Prev: Programmable Completion,  Up: Command Line Editing
7655
7656 8.7 Programmable Completion Builtins
7657 ====================================
7658
7659 Two builtin commands are available to manipulate the programmable
7660 completion facilities.
7661
7662 `compgen'
7663           `compgen [OPTION] [WORD]'
7664
7665      Generate possible completion matches for WORD according to the
7666      OPTIONs, which may be any option accepted by the `complete'
7667      builtin with the exception of `-p' and `-r', and write the matches
7668      to the standard output.  When using the `-F' or `-C' options, the
7669      various shell variables set by the programmable completion
7670      facilities, while available, will not have useful values.
7671
7672      The matches will be generated in the same way as if the
7673      programmable completion code had generated them directly from a
7674      completion specification with the same flags.  If WORD is
7675      specified, only those completions matching WORD will be displayed.
7676
7677      The return value is true unless an invalid option is supplied, or
7678      no matches were generated.
7679
7680 `complete'
7681           `complete [-abcdefgjksuv] [-o COMP-OPTION] [-DE] [-A ACTION] [-G GLOBPAT] [-W WORDLIST]
7682           [-F FUNCTION] [-C COMMAND] [-X FILTERPAT]
7683           [-P PREFIX] [-S SUFFIX] NAME [NAME ...]'
7684           `complete -pr [-DE] [NAME ...]'
7685
7686      Specify how arguments to each NAME should be completed.  If the
7687      `-p' option is supplied, or if no options are supplied, existing
7688      completion specifications are printed in a way that allows them to
7689      be reused as input.  The `-r' option removes a completion
7690      specification for each NAME, or, if no NAMEs are supplied, all
7691      completion specifications.  The `-D' option indicates that the
7692      remaining options and actions should apply to the "default"
7693      command completion; that is, completion attempted on a command for
7694      which no completion has previously been defined.  The `-E' option
7695      indicates that the remaining options and actions should apply to
7696      "empty" command completion; that is, completion attempted on a
7697      blank line.
7698
7699      The process of applying these completion specifications when word
7700      completion is attempted is described above (*note Programmable
7701      Completion::).  The `-D' option takes precedence over `-E'.
7702
7703      Other options, if specified, have the following meanings.  The
7704      arguments to the `-G', `-W', and `-X' options (and, if necessary,
7705      the `-P' and `-S' options) should be quoted to protect them from
7706      expansion before the `complete' builtin is invoked.
7707
7708     `-o COMP-OPTION'
7709           The COMP-OPTION controls several aspects of the compspec's
7710           behavior beyond the simple generation of completions.
7711           COMP-OPTION may be one of:
7712
7713          `bashdefault'
7714                Perform the rest of the default Bash completions if the
7715                compspec generates no matches.
7716
7717          `default'
7718                Use Readline's default filename completion if the
7719                compspec generates no matches.
7720
7721          `dirnames'
7722                Perform directory name completion if the compspec
7723                generates no matches.
7724
7725          `filenames'
7726                Tell Readline that the compspec generates filenames, so
7727                it can perform any filename-specific processing (like
7728                adding a slash to directory names quoting special
7729                characters, or suppressing trailing spaces).  This
7730                option is intended to be used with shell functions
7731                specified with `-F'.
7732
7733          `nospace'
7734                Tell Readline not to append a space (the default) to
7735                words completed at the end of the line.
7736
7737          `plusdirs'
7738                After any matches defined by the compspec are generated,
7739                directory name completion is attempted and any matches
7740                are added to the results of the other actions.
7741
7742
7743     `-A ACTION'
7744           The ACTION may be one of the following to generate a list of
7745           possible completions:
7746
7747          `alias'
7748                Alias names.  May also be specified as `-a'.
7749
7750          `arrayvar'
7751                Array variable names.
7752
7753          `binding'
7754                Readline key binding names (*note Bindable Readline
7755                Commands::).
7756
7757          `builtin'
7758                Names of shell builtin commands.  May also be specified
7759                as `-b'.
7760
7761          `command'
7762                Command names.  May also be specified as `-c'.
7763
7764          `directory'
7765                Directory names.  May also be specified as `-d'.
7766
7767          `disabled'
7768                Names of disabled shell builtins.
7769
7770          `enabled'
7771                Names of enabled shell builtins.
7772
7773          `export'
7774                Names of exported shell variables.  May also be
7775                specified as `-e'.
7776
7777          `file'
7778                File names.  May also be specified as `-f'.
7779
7780          `function'
7781                Names of shell functions.
7782
7783          `group'
7784                Group names.  May also be specified as `-g'.
7785
7786          `helptopic'
7787                Help topics as accepted by the `help' builtin (*note
7788                Bash Builtins::).
7789
7790          `hostname'
7791                Hostnames, as taken from the file specified by the
7792                `HOSTFILE' shell variable (*note Bash Variables::).
7793
7794          `job'
7795                Job names, if job control is active.  May also be
7796                specified as `-j'.
7797
7798          `keyword'
7799                Shell reserved words.  May also be specified as `-k'.
7800
7801          `running'
7802                Names of running jobs, if job control is active.
7803
7804          `service'
7805                Service names.  May also be specified as `-s'.
7806
7807          `setopt'
7808                Valid arguments for the `-o' option to the `set' builtin
7809                (*note The Set Builtin::).
7810
7811          `shopt'
7812                Shell option names as accepted by the `shopt' builtin
7813                (*note Bash Builtins::).
7814
7815          `signal'
7816                Signal names.
7817
7818          `stopped'
7819                Names of stopped jobs, if job control is active.
7820
7821          `user'
7822                User names.  May also be specified as `-u'.
7823
7824          `variable'
7825                Names of all shell variables.  May also be specified as
7826                `-v'.
7827
7828     `-G GLOBPAT'
7829           The filename expansion pattern GLOBPAT is expanded to generate
7830           the possible completions.
7831
7832     `-W WORDLIST'
7833           The WORDLIST is split using the characters in the `IFS'
7834           special variable as delimiters, and each resultant word is
7835           expanded.  The possible completions are the members of the
7836           resultant list which match the word being completed.
7837
7838     `-C COMMAND'
7839           COMMAND is executed in a subshell environment, and its output
7840           is used as the possible completions.
7841
7842     `-F FUNCTION'
7843           The shell function FUNCTION is executed in the current shell
7844           environment.  When it finishes, the possible completions are
7845           retrieved from the value of the `COMPREPLY' array variable.
7846
7847     `-X FILTERPAT'
7848           FILTERPAT is a pattern as used for filename expansion.  It is
7849           applied to the list of possible completions generated by the
7850           preceding options and arguments, and each completion matching
7851           FILTERPAT is removed from the list.  A leading `!' in
7852           FILTERPAT negates the pattern; in this case, any completion
7853           not matching FILTERPAT is removed.
7854
7855     `-P PREFIX'
7856           PREFIX is added at the beginning of each possible completion
7857           after all other options have been applied.
7858
7859     `-S SUFFIX'
7860           SUFFIX is appended to each possible completion after all
7861           other options have been applied.
7862
7863      The return value is true unless an invalid option is supplied, an
7864      option other than `-p' or `-r' is supplied without a NAME
7865      argument, an attempt is made to remove a completion specification
7866      for a NAME for which no specification exists, or an error occurs
7867      adding a completion specification.
7868
7869 `compopt'
7870           `compopt' [-o OPTION] [-DE] [+o OPTION] [NAME]
7871      Modify completion options for each NAME according to the OPTIONs,
7872      or for the currently-execution completion if no NAMEs are supplied.
7873      If no OPTIONs are given, display the completion options for each
7874      NAME or the current completion.  The possible values of OPTION are
7875      those valid for the `complete' builtin described above.  The `-D'
7876      option indicates that the remaining options should apply to the
7877      "default" command completion; that is, completion attempted on a
7878      command for which no completion has previously been defined.  The
7879      `-E' option indicates that the remaining options should apply to
7880      "empty" command completion; that is, completion attempted on a
7881      blank line.
7882
7883      The `-D' option takes precedence over `-E'.
7884
7885      The return value is true unless an invalid option is supplied, an
7886      attempt is made to modify the options for a NAME for which no
7887      completion specification exists, or an output error occurs.
7888
7889
7890 \1f
7891 File: bashref.info,  Node: Using History Interactively,  Next: Installing Bash,  Prev: Command Line Editing,  Up: Top
7892
7893 9 Using History Interactively
7894 *****************************
7895
7896 This chapter describes how to use the GNU History Library
7897 interactively, from a user's standpoint.  It should be considered a
7898 user's guide.  For information on using the GNU History Library in
7899 other programs, see the GNU Readline Library Manual.
7900
7901 * Menu:
7902
7903 * Bash History Facilities::     How Bash lets you manipulate your command
7904                                 history.
7905 * Bash History Builtins::       The Bash builtin commands that manipulate
7906                                 the command history.
7907 * History Interaction::         What it feels like using History as a user.
7908
7909 \1f
7910 File: bashref.info,  Node: Bash History Facilities,  Next: Bash History Builtins,  Up: Using History Interactively
7911
7912 9.1 Bash History Facilities
7913 ===========================
7914
7915 When the `-o history' option to the `set' builtin is enabled (*note The
7916 Set Builtin::), the shell provides access to the "command history", the
7917 list of commands previously typed.  The value of the `HISTSIZE' shell
7918 variable is used as the number of commands to save in a history list.
7919 The text of the last `$HISTSIZE' commands (default 500) is saved.  The
7920 shell stores each command in the history list prior to parameter and
7921 variable expansion but after history expansion is performed, subject to
7922 the values of the shell variables `HISTIGNORE' and `HISTCONTROL'.
7923
7924    When the shell starts up, the history is initialized from the file
7925 named by the `HISTFILE' variable (default `~/.bash_history').  The file
7926 named by the value of `HISTFILE' is truncated, if necessary, to contain
7927 no more than the number of lines specified by the value of the
7928 `HISTFILESIZE' variable.  When an interactive shell exits, the last
7929 `$HISTSIZE' lines are copied from the history list to the file named by
7930 `$HISTFILE'.  If the `histappend' shell option is set (*note Bash
7931 Builtins::), the lines are appended to the history file, otherwise the
7932 history file is overwritten.  If `HISTFILE' is unset, or if the history
7933 file is unwritable, the history is not saved.  After saving the
7934 history, the history file is truncated to contain no more than
7935 `$HISTFILESIZE' lines.  If `HISTFILESIZE' is not set, no truncation is
7936 performed.
7937
7938    If the `HISTTIMEFORMAT' is set, the time stamp information
7939 associated with each history entry is written to the history file,
7940 marked with the history comment character.  When the history file is
7941 read, lines beginning with the history comment character followed
7942 immediately by a digit are interpreted as timestamps for the previous
7943 history line.
7944
7945    The builtin command `fc' may be used to list or edit and re-execute
7946 a portion of the history list.  The `history' builtin may be used to
7947 display or modify the history list and manipulate the history file.
7948 When using command-line editing, search commands are available in each
7949 editing mode that provide access to the history list (*note Commands
7950 For History::).
7951
7952    The shell allows control over which commands are saved on the history
7953 list.  The `HISTCONTROL' and `HISTIGNORE' variables may be set to cause
7954 the shell to save only a subset of the commands entered.  The `cmdhist'
7955 shell option, if enabled, causes the shell to attempt to save each line
7956 of a multi-line command in the same history entry, adding semicolons
7957 where necessary to preserve syntactic correctness.  The `lithist' shell
7958 option causes the shell to save the command with embedded newlines
7959 instead of semicolons.  The `shopt' builtin is used to set these
7960 options.  *Note Bash Builtins::, for a description of `shopt'.
7961
7962 \1f
7963 File: bashref.info,  Node: Bash History Builtins,  Next: History Interaction,  Prev: Bash History Facilities,  Up: Using History Interactively
7964
7965 9.2 Bash History Builtins
7966 =========================
7967
7968 Bash provides two builtin commands which manipulate the history list
7969 and history file.
7970
7971 `fc'
7972           `fc [-e ENAME] [-lnr] [FIRST] [LAST]'
7973           `fc -s [PAT=REP] [COMMAND]'
7974
7975      Fix Command.  In the first form, a range of commands from FIRST to
7976      LAST is selected from the history list.  Both FIRST and LAST may
7977      be specified as a string (to locate the most recent command
7978      beginning with that string) or as a number (an index into the
7979      history list, where a negative number is used as an offset from the
7980      current command number).  If LAST is not specified it is set to
7981      FIRST.  If FIRST is not specified it is set to the previous
7982      command for editing and -16 for listing.  If the `-l' flag is
7983      given, the commands are listed on standard output.  The `-n' flag
7984      suppresses the command numbers when listing.  The `-r' flag
7985      reverses the order of the listing.  Otherwise, the editor given by
7986      ENAME is invoked on a file containing those commands.  If ENAME is
7987      not given, the value of the following variable expansion is used:
7988      `${FCEDIT:-${EDITOR:-vi}}'.  This says to use the value of the
7989      `FCEDIT' variable if set, or the value of the `EDITOR' variable if
7990      that is set, or `vi' if neither is set.  When editing is complete,
7991      the edited commands are echoed and executed.
7992
7993      In the second form, COMMAND is re-executed after each instance of
7994      PAT in the selected command is replaced by REP.
7995
7996      A useful alias to use with the `fc' command is `r='fc -s'', so
7997      that typing `r cc' runs the last command beginning with `cc' and
7998      typing `r' re-executes the last command (*note Aliases::).
7999
8000 `history'
8001           history [N]
8002           history -c
8003           history -d OFFSET
8004           history [-anrw] [FILENAME]
8005           history -ps ARG
8006
8007      With no options, display the history list with line numbers.
8008      Lines prefixed with a `*' have been modified.  An argument of N
8009      lists only the last N lines.  If the shell variable
8010      `HISTTIMEFORMAT' is set and not null, it is used as a format
8011      string for STRFTIME to display the time stamp associated with each
8012      displayed history entry.  No intervening blank is printed between
8013      the formatted time stamp and the history line.
8014
8015      Options, if supplied, have the following meanings:
8016
8017     `-c'
8018           Clear the history list.  This may be combined with the other
8019           options to replace the history list completely.
8020
8021     `-d OFFSET'
8022           Delete the history entry at position OFFSET.  OFFSET should
8023           be specified as it appears when the history is displayed.
8024
8025     `-a'
8026           Append the new history lines (history lines entered since the
8027           beginning of the current Bash session) to the history file.
8028
8029     `-n'
8030           Append the history lines not already read from the history
8031           file to the current history list.  These are lines appended
8032           to the history file since the beginning of the current Bash
8033           session.
8034
8035     `-r'
8036           Read the current history file and append its contents to the
8037           history list.
8038
8039     `-w'
8040           Write out the current history to the history file.
8041
8042     `-p'
8043           Perform history substitution on the ARGs and display the
8044           result on the standard output, without storing the results in
8045           the history list.
8046
8047     `-s'
8048           The ARGs are added to the end of the history list as a single
8049           entry.
8050
8051
8052      When any of the `-w', `-r', `-a', or `-n' options is used, if
8053      FILENAME is given, then it is used as the history file.  If not,
8054      then the value of the `HISTFILE' variable is used.
8055
8056
8057 \1f
8058 File: bashref.info,  Node: History Interaction,  Prev: Bash History Builtins,  Up: Using History Interactively
8059
8060 9.3 History Expansion
8061 =====================
8062
8063 The History library provides a history expansion feature that is similar
8064 to the history expansion provided by `csh'.  This section describes the
8065 syntax used to manipulate the history information.
8066
8067    History expansions introduce words from the history list into the
8068 input stream, making it easy to repeat commands, insert the arguments
8069 to a previous command into the current input line, or fix errors in
8070 previous commands quickly.
8071
8072    History expansion takes place in two parts.  The first is to
8073 determine which line from the history list should be used during
8074 substitution.  The second is to select portions of that line for
8075 inclusion into the current one.  The line selected from the history is
8076 called the "event", and the portions of that line that are acted upon
8077 are called "words".  Various "modifiers" are available to manipulate
8078 the selected words.  The line is broken into words in the same fashion
8079 that Bash does, so that several words surrounded by quotes are
8080 considered one word.  History expansions are introduced by the
8081 appearance of the history expansion character, which is `!' by default.
8082 Only `\' and `'' may be used to escape the history expansion character.
8083
8084    Several shell options settable with the `shopt' builtin (*note Bash
8085 Builtins::) may be used to tailor the behavior of history expansion.
8086 If the `histverify' shell option is enabled, and Readline is being
8087 used, history substitutions are not immediately passed to the shell
8088 parser.  Instead, the expanded line is reloaded into the Readline
8089 editing buffer for further modification.  If Readline is being used,
8090 and the `histreedit' shell option is enabled, a failed history
8091 expansion will be reloaded into the Readline editing buffer for
8092 correction.  The `-p' option to the `history' builtin command may be
8093 used to see what a history expansion will do before using it.  The `-s'
8094 option to the `history' builtin may be used to add commands to the end
8095 of the history list without actually executing them, so that they are
8096 available for subsequent recall.  This is most useful in conjunction
8097 with Readline.
8098
8099    The shell allows control of the various characters used by the
8100 history expansion mechanism with the `histchars' variable, as explained
8101 above (*note Bash Variables::).  The shell uses the history comment
8102 character to mark history timestamps when writing the history file.
8103
8104 * Menu:
8105
8106 * Event Designators::   How to specify which history line to use.
8107 * Word Designators::    Specifying which words are of interest.
8108 * Modifiers::           Modifying the results of substitution.
8109
8110 \1f
8111 File: bashref.info,  Node: Event Designators,  Next: Word Designators,  Up: History Interaction
8112
8113 9.3.1 Event Designators
8114 -----------------------
8115
8116 An event designator is a reference to a command line entry in the
8117 history list.  
8118
8119 `!'
8120      Start a history substitution, except when followed by a space, tab,
8121      the end of the line, `=' or `(' (when the `extglob' shell option
8122      is enabled using the `shopt' builtin).
8123
8124 `!N'
8125      Refer to command line N.
8126
8127 `!-N'
8128      Refer to the command N lines back.
8129
8130 `!!'
8131      Refer to the previous command.  This is a synonym for `!-1'.
8132
8133 `!STRING'
8134      Refer to the most recent command starting with STRING.
8135
8136 `!?STRING[?]'
8137      Refer to the most recent command containing STRING.  The trailing
8138      `?' may be omitted if the STRING is followed immediately by a
8139      newline.
8140
8141 `^STRING1^STRING2^'
8142      Quick Substitution.  Repeat the last command, replacing STRING1
8143      with STRING2.  Equivalent to `!!:s/STRING1/STRING2/'.
8144
8145 `!#'
8146      The entire command line typed so far.
8147
8148
8149 \1f
8150 File: bashref.info,  Node: Word Designators,  Next: Modifiers,  Prev: Event Designators,  Up: History Interaction
8151
8152 9.3.2 Word Designators
8153 ----------------------
8154
8155 Word designators are used to select desired words from the event.  A
8156 `:' separates the event specification from the word designator.  It may
8157 be omitted if the word designator begins with a `^', `$', `*', `-', or
8158 `%'.  Words are numbered from the beginning of the line, with the first
8159 word being denoted by 0 (zero).  Words are inserted into the current
8160 line separated by single spaces.
8161
8162    For example,
8163
8164 `!!'
8165      designates the preceding command.  When you type this, the
8166      preceding command is repeated in toto.
8167
8168 `!!:$'
8169      designates the last argument of the preceding command.  This may be
8170      shortened to `!$'.
8171
8172 `!fi:2'
8173      designates the second argument of the most recent command starting
8174      with the letters `fi'.
8175
8176    Here are the word designators:
8177
8178 `0 (zero)'
8179      The `0'th word.  For many applications, this is the command word.
8180
8181 `N'
8182      The Nth word.
8183
8184 `^'
8185      The first argument; that is, word 1.
8186
8187 `$'
8188      The last argument.
8189
8190 `%'
8191      The word matched by the most recent `?STRING?' search.
8192
8193 `X-Y'
8194      A range of words; `-Y' abbreviates `0-Y'.
8195
8196 `*'
8197      All of the words, except the `0'th.  This is a synonym for `1-$'.
8198      It is not an error to use `*' if there is just one word in the
8199      event; the empty string is returned in that case.
8200
8201 `X*'
8202      Abbreviates `X-$'
8203
8204 `X-'
8205      Abbreviates `X-$' like `X*', but omits the last word.
8206
8207
8208    If a word designator is supplied without an event specification, the
8209 previous command is used as the event.
8210
8211 \1f
8212 File: bashref.info,  Node: Modifiers,  Prev: Word Designators,  Up: History Interaction
8213
8214 9.3.3 Modifiers
8215 ---------------
8216
8217 After the optional word designator, you can add a sequence of one or
8218 more of the following modifiers, each preceded by a `:'.
8219
8220 `h'
8221      Remove a trailing pathname component, leaving only the head.
8222
8223 `t'
8224      Remove all leading pathname components, leaving the tail.
8225
8226 `r'
8227      Remove a trailing suffix of the form `.SUFFIX', leaving the
8228      basename.
8229
8230 `e'
8231      Remove all but the trailing suffix.
8232
8233 `p'
8234      Print the new command but do not execute it.
8235
8236 `q'
8237      Quote the substituted words, escaping further substitutions.
8238
8239 `x'
8240      Quote the substituted words as with `q', but break into words at
8241      spaces, tabs, and newlines.
8242
8243 `s/OLD/NEW/'
8244      Substitute NEW for the first occurrence of OLD in the event line.
8245      Any delimiter may be used in place of `/'.  The delimiter may be
8246      quoted in OLD and NEW with a single backslash.  If `&' appears in
8247      NEW, it is replaced by OLD.  A single backslash will quote the
8248      `&'.  The final delimiter is optional if it is the last character
8249      on the input line.
8250
8251 `&'
8252      Repeat the previous substitution.
8253
8254 `g'
8255 `a'
8256      Cause changes to be applied over the entire event line.  Used in
8257      conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
8258
8259 `G'
8260      Apply the following `s' modifier once to each word in the event.
8261
8262
8263 \1f
8264 File: bashref.info,  Node: Installing Bash,  Next: Reporting Bugs,  Prev: Using History Interactively,  Up: Top
8265
8266 10 Installing Bash
8267 ******************
8268
8269 This chapter provides basic instructions for installing Bash on the
8270 various supported platforms.  The distribution supports the GNU
8271 operating systems, nearly every version of Unix, and several non-Unix
8272 systems such as BeOS and Interix.  Other independent ports exist for
8273 MS-DOS, OS/2, and Windows platforms.
8274
8275 * Menu:
8276
8277 * Basic Installation::  Installation instructions.
8278 * Compilers and Options::       How to set special options for various
8279                                 systems.
8280 * Compiling For Multiple Architectures::        How to compile Bash for more
8281                                                 than one kind of system from
8282                                                 the same source tree.
8283 * Installation Names::  How to set the various paths used by the installation.
8284 * Specifying the System Type::  How to configure Bash for a particular system.
8285 * Sharing Defaults::    How to share default configuration values among GNU
8286                         programs.
8287 * Operation Controls::  Options recognized by the configuration program.
8288 * Optional Features::   How to enable and disable optional features when
8289                         building Bash.
8290
8291 \1f
8292 File: bashref.info,  Node: Basic Installation,  Next: Compilers and Options,  Up: Installing Bash
8293
8294 10.1 Basic Installation
8295 =======================
8296
8297 These are installation instructions for Bash.
8298
8299    The simplest way to compile Bash is:
8300
8301   1. `cd' to the directory containing the source code and type
8302      `./configure' to configure Bash for your system.  If you're using
8303      `csh' on an old version of System V, you might need to type `sh
8304      ./configure' instead to prevent `csh' from trying to execute
8305      `configure' itself.
8306
8307      Running `configure' takes some time.  While running, it prints
8308      messages telling which features it is checking for.
8309
8310   2. Type `make' to compile Bash and build the `bashbug' bug reporting
8311      script.
8312
8313   3. Optionally, type `make tests' to run the Bash test suite.
8314
8315   4. Type `make install' to install `bash' and `bashbug'.  This will
8316      also install the manual pages and Info file.
8317
8318
8319    The `configure' shell script attempts to guess correct values for
8320 various system-dependent variables used during compilation.  It uses
8321 those values to create a `Makefile' in each directory of the package
8322 (the top directory, the `builtins', `doc', and `support' directories,
8323 each directory under `lib', and several others).  It also creates a
8324 `config.h' file containing system-dependent definitions.  Finally, it
8325 creates a shell script named `config.status' that you can run in the
8326 future to recreate the current configuration, a file `config.cache'
8327 that saves the results of its tests to speed up reconfiguring, and a
8328 file `config.log' containing compiler output (useful mainly for
8329 debugging `configure').  If at some point `config.cache' contains
8330 results you don't want to keep, you may remove or edit it.
8331
8332    To find out more about the options and arguments that the
8333 `configure' script understands, type
8334
8335      bash-2.04$ ./configure --help
8336
8337 at the Bash prompt in your Bash source directory.
8338
8339    If you need to do unusual things to compile Bash, please try to
8340 figure out how `configure' could check whether or not to do them, and
8341 mail diffs or instructions to <bash-maintainers@gnu.org> so they can be
8342 considered for the next release.
8343
8344    The file `configure.in' is used to create `configure' by a program
8345 called Autoconf.  You only need `configure.in' if you want to change it
8346 or regenerate `configure' using a newer version of Autoconf.  If you do
8347 this, make sure you are using Autoconf version 2.50 or newer.
8348
8349    You can remove the program binaries and object files from the source
8350 code directory by typing `make clean'.  To also remove the files that
8351 `configure' created (so you can compile Bash for a different kind of
8352 computer), type `make distclean'.
8353
8354 \1f
8355 File: bashref.info,  Node: Compilers and Options,  Next: Compiling For Multiple Architectures,  Prev: Basic Installation,  Up: Installing Bash
8356
8357 10.2 Compilers and Options
8358 ==========================
8359
8360 Some systems require unusual options for compilation or linking that
8361 the `configure' script does not know about.  You can give `configure'
8362 initial values for variables by setting them in the environment.  Using
8363 a Bourne-compatible shell, you can do that on the command line like
8364 this:
8365
8366      CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
8367
8368    On systems that have the `env' program, you can do it like this:
8369
8370      env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
8371
8372    The configuration process uses GCC to build Bash if it is available.
8373
8374 \1f
8375 File: bashref.info,  Node: Compiling For Multiple Architectures,  Next: Installation Names,  Prev: Compilers and Options,  Up: Installing Bash
8376
8377 10.3 Compiling For Multiple Architectures
8378 =========================================
8379
8380 You can compile Bash for more than one kind of computer at the same
8381 time, by placing the object files for each architecture in their own
8382 directory.  To do this, you must use a version of `make' that supports
8383 the `VPATH' variable, such as GNU `make'.  `cd' to the directory where
8384 you want the object files and executables to go and run the `configure'
8385 script from the source directory.  You may need to supply the
8386 `--srcdir=PATH' argument to tell `configure' where the source files
8387 are.  `configure' automatically checks for the source code in the
8388 directory that `configure' is in and in `..'.
8389
8390    If you have to use a `make' that does not supports the `VPATH'
8391 variable, you can compile Bash for one architecture at a time in the
8392 source code directory.  After you have installed Bash for one
8393 architecture, use `make distclean' before reconfiguring for another
8394 architecture.
8395
8396    Alternatively, if your system supports symbolic links, you can use
8397 the `support/mkclone' script to create a build tree which has symbolic
8398 links back to each file in the source directory.  Here's an example
8399 that creates a build directory in the current directory from a source
8400 directory `/usr/gnu/src/bash-2.0':
8401
8402      bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
8403
8404 The `mkclone' script requires Bash, so you must have already built Bash
8405 for at least one architecture before you can create build directories
8406 for other architectures.
8407
8408 \1f
8409 File: bashref.info,  Node: Installation Names,  Next: Specifying the System Type,  Prev: Compiling For Multiple Architectures,  Up: Installing Bash
8410
8411 10.4 Installation Names
8412 =======================
8413
8414 By default, `make install' will install into `/usr/local/bin',
8415 `/usr/local/man', etc.  You can specify an installation prefix other
8416 than `/usr/local' by giving `configure' the option `--prefix=PATH', or
8417 by specifying a value for the `DESTDIR' `make' variable when running
8418 `make install'.
8419
8420    You can specify separate installation prefixes for
8421 architecture-specific files and architecture-independent files.  If you
8422 give `configure' the option `--exec-prefix=PATH', `make install' will
8423 use PATH as the prefix for installing programs and libraries.
8424 Documentation and other data files will still use the regular prefix.
8425
8426 \1f
8427 File: bashref.info,  Node: Specifying the System Type,  Next: Sharing Defaults,  Prev: Installation Names,  Up: Installing Bash
8428
8429 10.5 Specifying the System Type
8430 ===============================
8431
8432 There may be some features `configure' can not figure out
8433 automatically, but need to determine by the type of host Bash will run
8434 on.  Usually `configure' can figure that out, but if it prints a
8435 message saying it can not guess the host type, give it the
8436 `--host=TYPE' option.  `TYPE' can either be a short name for the system
8437 type, such as `sun4', or a canonical name with three fields:
8438 `CPU-COMPANY-SYSTEM' (e.g., `i386-unknown-freebsd4.2').
8439
8440    See the file `support/config.sub' for the possible values of each
8441 field.
8442
8443 \1f
8444 File: bashref.info,  Node: Sharing Defaults,  Next: Operation Controls,  Prev: Specifying the System Type,  Up: Installing Bash
8445
8446 10.6 Sharing Defaults
8447 =====================
8448
8449 If you want to set default values for `configure' scripts to share, you
8450 can create a site shell script called `config.site' that gives default
8451 values for variables like `CC', `cache_file', and `prefix'.  `configure'
8452 looks for `PREFIX/share/config.site' if it exists, then
8453 `PREFIX/etc/config.site' if it exists.  Or, you can set the
8454 `CONFIG_SITE' environment variable to the location of the site script.
8455 A warning: the Bash `configure' looks for a site script, but not all
8456 `configure' scripts do.
8457
8458 \1f
8459 File: bashref.info,  Node: Operation Controls,  Next: Optional Features,  Prev: Sharing Defaults,  Up: Installing Bash
8460
8461 10.7 Operation Controls
8462 =======================
8463
8464 `configure' recognizes the following options to control how it operates.
8465
8466 `--cache-file=FILE'
8467      Use and save the results of the tests in FILE instead of
8468      `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
8469      debugging `configure'.
8470
8471 `--help'
8472      Print a summary of the options to `configure', and exit.
8473
8474 `--quiet'
8475 `--silent'
8476 `-q'
8477      Do not print messages saying which checks are being made.
8478
8479 `--srcdir=DIR'
8480      Look for the Bash source code in directory DIR.  Usually
8481      `configure' can determine that directory automatically.
8482
8483 `--version'
8484      Print the version of Autoconf used to generate the `configure'
8485      script, and exit.
8486
8487    `configure' also accepts some other, not widely used, boilerplate
8488 options.  `configure --help' prints the complete list.
8489
8490 \1f
8491 File: bashref.info,  Node: Optional Features,  Prev: Operation Controls,  Up: Installing Bash
8492
8493 10.8 Optional Features
8494 ======================
8495
8496 The Bash `configure' has a number of `--enable-FEATURE' options, where
8497 FEATURE indicates an optional part of Bash.  There are also several
8498 `--with-PACKAGE' options, where PACKAGE is something like `bash-malloc'
8499 or `purify'.  To turn off the default use of a package, use
8500 `--without-PACKAGE'.  To configure Bash without a feature that is
8501 enabled by default, use `--disable-FEATURE'.
8502
8503    Here is a complete list of the `--enable-' and `--with-' options
8504 that the Bash `configure' recognizes.
8505
8506 `--with-afs'
8507      Define if you are using the Andrew File System from Transarc.
8508
8509 `--with-bash-malloc'
8510      Use the Bash version of `malloc' in the directory `lib/malloc'.
8511      This is not the same `malloc' that appears in GNU libc, but an
8512      older version originally derived from the 4.2 BSD `malloc'.  This
8513      `malloc' is very fast, but wastes some space on each allocation.
8514      This option is enabled by default.  The `NOTES' file contains a
8515      list of systems for which this should be turned off, and
8516      `configure' disables this option automatically for a number of
8517      systems.
8518
8519 `--with-curses'
8520      Use the curses library instead of the termcap library.  This should
8521      be supplied if your system has an inadequate or incomplete termcap
8522      database.
8523
8524 `--with-gnu-malloc'
8525      A synonym for `--with-bash-malloc'.
8526
8527 `--with-installed-readline[=PREFIX]'
8528      Define this to make Bash link with a locally-installed version of
8529      Readline rather than the version in `lib/readline'.  This works
8530      only with Readline 5.0 and later versions.  If PREFIX is `yes' or
8531      not supplied, `configure' uses the values of the make variables
8532      `includedir' and `libdir', which are subdirectories of `prefix' by
8533      default, to find the installed version of Readline if it is not in
8534      the standard system include and library directories.  If PREFIX is
8535      `no', Bash links with the version in `lib/readline'.  If PREFIX is
8536      set to any other value, `configure' treats it as a directory
8537      pathname and looks for the installed version of Readline in
8538      subdirectories of that directory (include files in
8539      PREFIX/`include' and the library in PREFIX/`lib').
8540
8541 `--with-purify'
8542      Define this to use the Purify memory allocation checker from
8543      Rational Software.
8544
8545 `--enable-minimal-config'
8546      This produces a shell with minimal features, close to the
8547      historical Bourne shell.
8548
8549    There are several `--enable-' options that alter how Bash is
8550 compiled and linked, rather than changing run-time features.
8551
8552 `--enable-largefile'
8553      Enable support for large files
8554      (http://www.sas.com/standards/large_file/x_open.20Mar96.html) if
8555      the operating system requires special compiler options to build
8556      programs which can access large files.  This is enabled by
8557      default, if the operating system provides large file support.
8558
8559 `--enable-profiling'
8560      This builds a Bash binary that produces profiling information to be
8561      processed by `gprof' each time it is executed.
8562
8563 `--enable-static-link'
8564      This causes Bash to be linked statically, if `gcc' is being used.
8565      This could be used to build a version to use as root's shell.
8566
8567    The `minimal-config' option can be used to disable all of the
8568 following options, but it is processed first, so individual options may
8569 be enabled using `enable-FEATURE'.
8570
8571    All of the following options except for `disabled-builtins' and
8572 `xpg-echo-default' are enabled by default, unless the operating system
8573 does not provide the necessary support.
8574
8575 `--enable-alias'
8576      Allow alias expansion and include the `alias' and `unalias'
8577      builtins (*note Aliases::).
8578
8579 `--enable-arith-for-command'
8580      Include support for the alternate form of the `for' command that
8581      behaves like the C language `for' statement (*note Looping
8582      Constructs::).
8583
8584 `--enable-array-variables'
8585      Include support for one-dimensional array shell variables (*note
8586      Arrays::).
8587
8588 `--enable-bang-history'
8589      Include support for `csh'-like history substitution (*note History
8590      Interaction::).
8591
8592 `--enable-brace-expansion'
8593      Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
8594      See *note Brace Expansion::, for a complete description.
8595
8596 `--enable-casemod-attributes'
8597      Include support for case-modifying attributes in the `declare'
8598      builtin and assignment statements.  Variables with the UPPERCASE
8599      attribute, for example, will have their values converted to
8600      uppercase upon assignment.
8601
8602 `--enable-casemod-expansion'
8603      Include support for case-modifying word expansions.
8604
8605 `--enable-command-timing'
8606      Include support for recognizing `time' as a reserved word and for
8607      displaying timing statistics for the pipeline following `time'
8608      (*note Pipelines::).  This allows pipelines as well as shell
8609      builtins and functions to be timed.
8610
8611 `--enable-cond-command'
8612      Include support for the `[[' conditional command.  (*note
8613      Conditional Constructs::).
8614
8615 `--enable-cond-regexp'
8616      Include support for matching POSIX regular expressions using the
8617      `=~' binary operator in the `[[' conditional command.  (*note
8618      Conditional Constructs::).
8619
8620 `--enable-coprocesses'
8621      Include support for coprocesses and the `coproc' reserved word
8622      (*note Pipelines::).
8623
8624 `--enable-debugger'
8625      Include support for the bash debugger (distributed separately).
8626
8627 `--enable-directory-stack'
8628      Include support for a `csh'-like directory stack and the `pushd',
8629      `popd', and `dirs' builtins (*note The Directory Stack::).
8630
8631 `--enable-disabled-builtins'
8632      Allow builtin commands to be invoked via `builtin xxx' even after
8633      `xxx' has been disabled using `enable -n xxx'.  See *note Bash
8634      Builtins::, for details of the `builtin' and `enable' builtin
8635      commands.
8636
8637 `--enable-dparen-arithmetic'
8638      Include support for the `((...))' command (*note Conditional
8639      Constructs::).
8640
8641 `--enable-extended-glob'
8642      Include support for the extended pattern matching features
8643      described above under *note Pattern Matching::.
8644
8645 `--enable-extended-glob-default'
8646      Set the default value of the EXTGLOB shell option described above
8647      under *note The Shopt Builtin:: to be enabled.
8648
8649 `--enable-help-builtin'
8650      Include the `help' builtin, which displays help on shell builtins
8651      and variables (*note Bash Builtins::).
8652
8653 `--enable-history'
8654      Include command history and the `fc' and `history' builtin
8655      commands (*note Bash History Facilities::).
8656
8657 `--enable-job-control'
8658      This enables the job control features (*note Job Control::), if
8659      the operating system supports them.
8660
8661 `--enable-multibyte'
8662      This enables support for multibyte characters if the operating
8663      system provides the necessary support.
8664
8665 `--enable-net-redirections'
8666      This enables the special handling of filenames of the form
8667      `/dev/tcp/HOST/PORT' and `/dev/udp/HOST/PORT' when used in
8668      redirections (*note Redirections::).
8669
8670 `--enable-process-substitution'
8671      This enables process substitution (*note Process Substitution::) if
8672      the operating system provides the necessary support.
8673
8674 `--enable-progcomp'
8675      Enable the programmable completion facilities (*note Programmable
8676      Completion::).  If Readline is not enabled, this option has no
8677      effect.
8678
8679 `--enable-prompt-string-decoding'
8680      Turn on the interpretation of a number of backslash-escaped
8681      characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
8682      strings.  See *note Printing a Prompt::, for a complete list of
8683      prompt string escape sequences.
8684
8685 `--enable-readline'
8686      Include support for command-line editing and history with the Bash
8687      version of the Readline library (*note Command Line Editing::).
8688
8689 `--enable-restricted'
8690      Include support for a "restricted shell".  If this is enabled,
8691      Bash, when called as `rbash', enters a restricted mode.  See *note
8692      The Restricted Shell::, for a description of restricted mode.
8693
8694 `--enable-select'
8695      Include the `select' builtin, which allows the generation of simple
8696      menus (*note Conditional Constructs::).
8697
8698 `--enable-separate-helpfiles'
8699      Use external files for the documentation displayed by the `help'
8700      builtin instead of storing the text internally.
8701
8702 `--enable-single-help-strings'
8703      Store the text displayed by the `help' builtin as a single string
8704      for each help topic.  This aids in translating the text to
8705      different languages.  You may need to disable this if your
8706      compiler cannot handle very long string literals.
8707
8708 `--enable-strict-posix-default'
8709      Make Bash POSIX-conformant by default (*note Bash POSIX Mode::).
8710
8711 `--enable-usg-echo-default'
8712      A synonym for `--enable-xpg-echo-default'.
8713
8714 `--enable-xpg-echo-default'
8715      Make the `echo' builtin expand backslash-escaped characters by
8716      default, without requiring the `-e' option.  This sets the default
8717      value of the `xpg_echo' shell option to `on', which makes the Bash
8718      `echo' behave more like the version specified in the Single Unix
8719      Specification, version 3.  *Note Bash Builtins::, for a
8720      description of the escape sequences that `echo' recognizes.
8721
8722
8723    The file `config-top.h' contains C Preprocessor `#define' statements
8724 for options which are not settable from `configure'.  Some of these are
8725 not meant to be changed; beware of the consequences if you do.  Read
8726 the comments associated with each definition for more information about
8727 its effect.
8728
8729 \1f
8730 File: bashref.info,  Node: Reporting Bugs,  Next: Major Differences From The Bourne Shell,  Prev: Installing Bash,  Up: Top
8731
8732 Appendix A Reporting Bugs
8733 *************************
8734
8735 Please report all bugs you find in Bash.  But first, you should make
8736 sure that it really is a bug, and that it appears in the latest version
8737 of Bash.  The latest version of Bash is always available for FTP from
8738 `ftp://ftp.gnu.org/pub/gnu/bash/'.
8739
8740    Once you have determined that a bug actually exists, use the
8741 `bashbug' command to submit a bug report.  If you have a fix, you are
8742 encouraged to mail that as well!  Suggestions and `philosophical' bug
8743 reports may be mailed to <bug-bash@gnu.org> or posted to the Usenet
8744 newsgroup `gnu.bash.bug'.
8745
8746    All bug reports should include:
8747    * The version number of Bash.
8748
8749    * The hardware and operating system.
8750
8751    * The compiler used to compile Bash.
8752
8753    * A description of the bug behaviour.
8754
8755    * A short script or `recipe' which exercises the bug and may be used
8756      to reproduce it.
8757
8758 `bashbug' inserts the first three items automatically into the template
8759 it provides for filing a bug report.
8760
8761    Please send all reports concerning this manual to
8762 <chet.ramey@case.edu>.
8763
8764 \1f
8765 File: bashref.info,  Node: Major Differences From The Bourne Shell,  Next: GNU Free Documentation License,  Prev: Reporting Bugs,  Up: Top
8766
8767 Appendix B Major Differences From The Bourne Shell
8768 **************************************************
8769
8770 Bash implements essentially the same grammar, parameter and variable
8771 expansion, redirection, and quoting as the Bourne Shell.  Bash uses the
8772 POSIX standard as the specification of how these features are to be
8773 implemented.  There are some differences between the traditional Bourne
8774 shell and Bash; this section quickly details the differences of
8775 significance.  A number of these differences are explained in greater
8776 depth in previous sections.  This section uses the version of `sh'
8777 included in SVR4.2 (the last version of the historical Bourne shell) as
8778 the baseline reference.
8779
8780    * Bash is POSIX-conformant, even where the POSIX specification
8781      differs from traditional `sh' behavior (*note Bash POSIX Mode::).
8782
8783    * Bash has multi-character invocation options (*note Invoking
8784      Bash::).
8785
8786    * Bash has command-line editing (*note Command Line Editing::) and
8787      the `bind' builtin.
8788
8789    * Bash provides a programmable word completion mechanism (*note
8790      Programmable Completion::), and builtin commands `complete',
8791      `compgen', and `compopt', to manipulate it.
8792
8793    * Bash has command history (*note Bash History Facilities::) and the
8794      `history' and `fc' builtins to manipulate it.  The Bash history
8795      list maintains timestamp information and uses the value of the
8796      `HISTTIMEFORMAT' variable to display it.
8797
8798    * Bash implements `csh'-like history expansion (*note History
8799      Interaction::).
8800
8801    * Bash has one-dimensional array variables (*note Arrays::), and the
8802      appropriate variable expansions and assignment syntax to use them.
8803      Several of the Bash builtins take options to act on arrays.  Bash
8804      provides a number of built-in array variables.
8805
8806    * The `$'...'' quoting syntax, which expands ANSI-C
8807      backslash-escaped characters in the text between the single quotes,
8808      is supported (*note ANSI-C Quoting::).
8809
8810    * Bash supports the `$"..."' quoting syntax to do locale-specific
8811      translation of the characters between the double quotes.  The
8812      `-D', `--dump-strings', and `--dump-po-strings' invocation options
8813      list the translatable strings found in a script (*note Locale
8814      Translation::).
8815
8816    * Bash implements the `!' keyword to negate the return value of a
8817      pipeline (*note Pipelines::).  Very useful when an `if' statement
8818      needs to act only if a test fails.  The Bash `-o pipefail' option
8819      to `set' will cause a pipeline to return a failure status if any
8820      command fails.
8821
8822    * Bash has the `time' reserved word and command timing (*note
8823      Pipelines::).  The display of the timing statistics may be
8824      controlled with the `TIMEFORMAT' variable.
8825
8826    * Bash implements the `for (( EXPR1 ; EXPR2 ; EXPR3 ))' arithmetic
8827      for command, similar to the C language (*note Looping
8828      Constructs::).
8829
8830    * Bash includes the `select' compound command, which allows the
8831      generation of simple menus (*note Conditional Constructs::).
8832
8833    * Bash includes the `[[' compound command, which makes conditional
8834      testing part of the shell grammar (*note Conditional
8835      Constructs::), including optional regular expression matching.
8836
8837    * Bash provides optional case-insensitive matching for the `case' and
8838      `[[' constructs.
8839
8840    * Bash includes brace expansion (*note Brace Expansion::) and tilde
8841      expansion (*note Tilde Expansion::).
8842
8843    * Bash implements command aliases and the `alias' and `unalias'
8844      builtins (*note Aliases::).
8845
8846    * Bash provides shell arithmetic, the `((' compound command (*note
8847      Conditional Constructs::), and arithmetic expansion (*note Shell
8848      Arithmetic::).
8849
8850    * Variables present in the shell's initial environment are
8851      automatically exported to child processes.  The Bourne shell does
8852      not normally do this unless the variables are explicitly marked
8853      using the `export' command.
8854
8855    * Bash supports the `+=' assignment operator, which appends to the
8856      value of the variable named on the left hand side.
8857
8858    * Bash includes the POSIX pattern removal `%', `#', `%%' and `##'
8859      expansions to remove leading or trailing substrings from variable
8860      values (*note Shell Parameter Expansion::).
8861
8862    * The expansion `${#xx}', which returns the length of `${xx}', is
8863      supported (*note Shell Parameter Expansion::).
8864
8865    * The expansion `${var:'OFFSET`[:'LENGTH`]}', which expands to the
8866      substring of `var''s value of length LENGTH, beginning at OFFSET,
8867      is present (*note Shell Parameter Expansion::).
8868
8869    * The expansion `${var/[/]'PATTERN`[/'REPLACEMENT`]}', which matches
8870      PATTERN and replaces it with REPLACEMENT in the value of `var', is
8871      available (*note Shell Parameter Expansion::).
8872
8873    * The expansion `${!PREFIX}*' expansion, which expands to the names
8874      of all shell variables whose names begin with PREFIX, is available
8875      (*note Shell Parameter Expansion::).
8876
8877    * Bash has INDIRECT variable expansion using `${!word}' (*note Shell
8878      Parameter Expansion::).
8879
8880    * Bash can expand positional parameters beyond `$9' using `${NUM}'.
8881
8882    * The POSIX `$()' form of command substitution is implemented (*note
8883      Command Substitution::), and preferred to the Bourne shell's ```'
8884      (which is also implemented for backwards compatibility).
8885
8886    * Bash has process substitution (*note Process Substitution::).
8887
8888    * Bash automatically assigns variables that provide information
8889      about the current user (`UID', `EUID', and `GROUPS'), the current
8890      host (`HOSTTYPE', `OSTYPE', `MACHTYPE', and `HOSTNAME'), and the
8891      instance of Bash that is running (`BASH', `BASH_VERSION', and
8892      `BASH_VERSINFO').  *Note Bash Variables::, for details.
8893
8894    * The `IFS' variable is used to split only the results of expansion,
8895      not all words (*note Word Splitting::).  This closes a
8896      longstanding shell security hole.
8897
8898    * Bash implements the full set of POSIX filename expansion operators,
8899      including CHARACTER CLASSES, EQUIVALENCE CLASSES, and COLLATING
8900      SYMBOLS (*note Filename Expansion::).
8901
8902    * Bash implements extended pattern matching features when the
8903      `extglob' shell option is enabled (*note Pattern Matching::).
8904
8905    * It is possible to have a variable and a function with the same
8906      name; `sh' does not separate the two name spaces.
8907
8908    * Bash functions are permitted to have local variables using the
8909      `local' builtin, and thus useful recursive functions may be written
8910      (*note Bash Builtins::).
8911
8912    * Variable assignments preceding commands affect only that command,
8913      even builtins and functions (*note Environment::).  In `sh', all
8914      variable assignments preceding commands are global unless the
8915      command is executed from the file system.
8916
8917    * Bash performs filename expansion on filenames specified as operands
8918      to input and output redirection operators (*note Redirections::).
8919
8920    * Bash contains the `<>' redirection operator, allowing a file to be
8921      opened for both reading and writing, and the `&>' redirection
8922      operator, for directing standard output and standard error to the
8923      same file (*note Redirections::).
8924
8925    * Bash includes the `<<<' redirection operator, allowing a string to
8926      be used as the standard input to a command.
8927
8928    * Bash implements the `[n]<&WORD' and `[n]>&WORD' redirection
8929      operators, which move one file descriptor to another.
8930
8931    * Bash treats a number of filenames specially when they are used in
8932      redirection operators (*note Redirections::).
8933
8934    * Bash can open network connections to arbitrary machines and
8935      services with the redirection operators (*note Redirections::).
8936
8937    * The `noclobber' option is available to avoid overwriting existing
8938      files with output redirection (*note The Set Builtin::).  The `>|'
8939      redirection operator may be used to override `noclobber'.
8940
8941    * The Bash `cd' and `pwd' builtins (*note Bourne Shell Builtins::)
8942      each take `-L' and `-P' options to switch between logical and
8943      physical modes.
8944
8945    * Bash allows a function to override a builtin with the same name,
8946      and provides access to that builtin's functionality within the
8947      function via the `builtin' and `command' builtins (*note Bash
8948      Builtins::).
8949
8950    * The `command' builtin allows selective disabling of functions when
8951      command lookup is performed (*note Bash Builtins::).
8952
8953    * Individual builtins may be enabled or disabled using the `enable'
8954      builtin (*note Bash Builtins::).
8955
8956    * The Bash `exec' builtin takes additional options that allow users
8957      to control the contents of the environment passed to the executed
8958      command, and what the zeroth argument to the command is to be
8959      (*note Bourne Shell Builtins::).
8960
8961    * Shell functions may be exported to children via the environment
8962      using `export -f' (*note Shell Functions::).
8963
8964    * The Bash `export', `readonly', and `declare' builtins can take a
8965      `-f' option to act on shell functions, a `-p' option to display
8966      variables with various attributes set in a format that can be used
8967      as shell input, a `-n' option to remove various variable
8968      attributes, and `name=value' arguments to set variable attributes
8969      and values simultaneously.
8970
8971    * The Bash `hash' builtin allows a name to be associated with an
8972      arbitrary filename, even when that filename cannot be found by
8973      searching the `$PATH', using `hash -p' (*note Bourne Shell
8974      Builtins::).
8975
8976    * Bash includes a `help' builtin for quick reference to shell
8977      facilities (*note Bash Builtins::).
8978
8979    * The `printf' builtin is available to display formatted output
8980      (*note Bash Builtins::).
8981
8982    * The Bash `read' builtin (*note Bash Builtins::) will read a line
8983      ending in `\' with the `-r' option, and will use the `REPLY'
8984      variable as a default if no non-option arguments are supplied.
8985      The Bash `read' builtin also accepts a prompt string with the `-p'
8986      option and will use Readline to obtain the line when given the
8987      `-e' option.  The `read' builtin also has additional options to
8988      control input: the `-s' option will turn off echoing of input
8989      characters as they are read, the `-t' option will allow `read' to
8990      time out if input does not arrive within a specified number of
8991      seconds, the `-n' option will allow reading only a specified
8992      number of characters rather than a full line, and the `-d' option
8993      will read until a particular character rather than newline.
8994
8995    * The `return' builtin may be used to abort execution of scripts
8996      executed with the `.' or `source' builtins (*note Bourne Shell
8997      Builtins::).
8998
8999    * Bash includes the `shopt' builtin, for finer control of shell
9000      optional capabilities (*note The Shopt Builtin::), and allows
9001      these options to be set and unset at shell invocation (*note
9002      Invoking Bash::).
9003
9004    * Bash has much more optional behavior controllable with the `set'
9005      builtin (*note The Set Builtin::).
9006
9007    * The `-x' (`xtrace') option displays commands other than simple
9008      commands when performing an execution trace (*note The Set
9009      Builtin::).
9010
9011    * The `test' builtin (*note Bourne Shell Builtins::) is slightly
9012      different, as it implements the POSIX algorithm, which specifies
9013      the behavior based on the number of arguments.
9014
9015    * Bash includes the `caller' builtin, which displays the context of
9016      any active subroutine call (a shell function or a script executed
9017      with the `.' or `source' builtins).  This supports the bash
9018      debugger.
9019
9020    * The `trap' builtin (*note Bourne Shell Builtins::) allows a
9021      `DEBUG' pseudo-signal specification, similar to `EXIT'.  Commands
9022      specified with a `DEBUG' trap are executed before every simple
9023      command, `for' command, `case' command, `select' command, every
9024      arithmetic `for' command, and before the first command executes in
9025      a shell function.  The `DEBUG' trap is not inherited by shell
9026      functions unless the function has been given the `trace' attribute
9027      or the `functrace' option has been enabled using the `shopt'
9028      builtin.  The `extdebug' shell option has additional effects on the
9029      `DEBUG' trap.
9030
9031      The `trap' builtin (*note Bourne Shell Builtins::) allows an `ERR'
9032      pseudo-signal specification, similar to `EXIT' and `DEBUG'.
9033      Commands specified with an `ERR' trap are executed after a simple
9034      command fails, with a few exceptions.  The `ERR' trap is not
9035      inherited by shell functions unless the `-o errtrace' option to
9036      the `set' builtin is enabled.
9037
9038      The `trap' builtin (*note Bourne Shell Builtins::) allows a
9039      `RETURN' pseudo-signal specification, similar to `EXIT' and
9040      `DEBUG'.  Commands specified with an `RETURN' trap are executed
9041      before execution resumes after a shell function or a shell script
9042      executed with `.' or `source' returns.  The `RETURN' trap is not
9043      inherited by shell functions unless the function has been given
9044      the `trace' attribute or the `functrace' option has been enabled
9045      using the `shopt' builtin.
9046
9047    * The Bash `type' builtin is more extensive and gives more
9048      information about the names it finds (*note Bash Builtins::).
9049
9050    * The Bash `umask' builtin permits a `-p' option to cause the output
9051      to be displayed in the form of a `umask' command that may be
9052      reused as input (*note Bourne Shell Builtins::).
9053
9054    * Bash implements a `csh'-like directory stack, and provides the
9055      `pushd', `popd', and `dirs' builtins to manipulate it (*note The
9056      Directory Stack::).  Bash also makes the directory stack visible
9057      as the value of the `DIRSTACK' shell variable.
9058
9059    * Bash interprets special backslash-escaped characters in the prompt
9060      strings when interactive (*note Printing a Prompt::).
9061
9062    * The Bash restricted mode is more useful (*note The Restricted
9063      Shell::); the SVR4.2 shell restricted mode is too limited.
9064
9065    * The `disown' builtin can remove a job from the internal shell job
9066      table (*note Job Control Builtins::) or suppress the sending of
9067      `SIGHUP' to a job when the shell exits as the result of a `SIGHUP'.
9068
9069    * Bash includes a number of features to support a separate debugger
9070      for shell scripts.
9071
9072    * The SVR4.2 shell has two privilege-related builtins (`mldmode' and
9073      `priv') not present in Bash.
9074
9075    * Bash does not have the `stop' or `newgrp' builtins.
9076
9077    * Bash does not use the `SHACCT' variable or perform shell
9078      accounting.
9079
9080    * The SVR4.2 `sh' uses a `TIMEOUT' variable like Bash uses `TMOUT'.
9081
9082
9083 More features unique to Bash may be found in *note Bash Features::.
9084
9085 B.1 Implementation Differences From The SVR4.2 Shell
9086 ====================================================
9087
9088 Since Bash is a completely new implementation, it does not suffer from
9089 many of the limitations of the SVR4.2 shell.  For instance:
9090
9091    * Bash does not fork a subshell when redirecting into or out of a
9092      shell control structure such as  an `if' or `while' statement.
9093
9094    * Bash does not allow unbalanced quotes.  The SVR4.2 shell will
9095      silently insert a needed closing quote at `EOF' under certain
9096      circumstances.  This can be the cause of some hard-to-find errors.
9097
9098    * The SVR4.2 shell uses a baroque memory management scheme based on
9099      trapping `SIGSEGV'.  If the shell is started from a process with
9100      `SIGSEGV' blocked (e.g., by using the `system()' C library
9101      function call), it misbehaves badly.
9102
9103    * In a questionable attempt at security, the SVR4.2 shell, when
9104      invoked without the `-p' option, will alter its real and effective
9105      UID and GID if they are less than some magic threshold value,
9106      commonly 100.  This can lead to unexpected results.
9107
9108    * The SVR4.2 shell does not allow users to trap `SIGSEGV',
9109      `SIGALRM', or `SIGCHLD'.
9110
9111    * The SVR4.2 shell does not allow the `IFS', `MAILCHECK', `PATH',
9112      `PS1', or `PS2' variables to be unset.
9113
9114    * The SVR4.2 shell treats `^' as the undocumented equivalent of `|'.
9115
9116    * Bash allows multiple option arguments when it is invoked (`-x -v');
9117      the SVR4.2 shell allows only one option argument (`-xv').  In
9118      fact, some versions of the shell dump core if the second argument
9119      begins with a `-'.
9120
9121    * The SVR4.2 shell exits a script if any builtin fails; Bash exits a
9122      script only if one of the POSIX special builtins fails, and only
9123      for certain failures, as enumerated in the POSIX standard.
9124
9125    * The SVR4.2 shell behaves differently when invoked as `jsh' (it
9126      turns on job control).
9127
9128 \1f
9129 File: bashref.info,  Node: GNU Free Documentation License,  Next: Indexes,  Prev: Major Differences From The Bourne Shell,  Up: Top
9130
9131 Appendix C GNU Free Documentation License
9132 *****************************************
9133
9134                      Version 1.3, 3 November 2008
9135
9136      Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
9137      `http://fsf.org/'
9138
9139      Everyone is permitted to copy and distribute verbatim copies
9140      of this license document, but changing it is not allowed.
9141
9142   0. PREAMBLE
9143
9144      The purpose of this License is to make a manual, textbook, or other
9145      functional and useful document "free" in the sense of freedom: to
9146      assure everyone the effective freedom to copy and redistribute it,
9147      with or without modifying it, either commercially or
9148      noncommercially.  Secondarily, this License preserves for the
9149      author and publisher a way to get credit for their work, while not
9150      being considered responsible for modifications made by others.
9151
9152      This License is a kind of "copyleft", which means that derivative
9153      works of the document must themselves be free in the same sense.
9154      It complements the GNU General Public License, which is a copyleft
9155      license designed for free software.
9156
9157      We have designed this License in order to use it for manuals for
9158      free software, because free software needs free documentation: a
9159      free program should come with manuals providing the same freedoms
9160      that the software does.  But this License is not limited to
9161      software manuals; it can be used for any textual work, regardless
9162      of subject matter or whether it is published as a printed book.
9163      We recommend this License principally for works whose purpose is
9164      instruction or reference.
9165
9166   1. APPLICABILITY AND DEFINITIONS
9167
9168      This License applies to any manual or other work, in any medium,
9169      that contains a notice placed by the copyright holder saying it
9170      can be distributed under the terms of this License.  Such a notice
9171      grants a world-wide, royalty-free license, unlimited in duration,
9172      to use that work under the conditions stated herein.  The
9173      "Document", below, refers to any such manual or work.  Any member
9174      of the public is a licensee, and is addressed as "you".  You
9175      accept the license if you copy, modify or distribute the work in a
9176      way requiring permission under copyright law.
9177
9178      A "Modified Version" of the Document means any work containing the
9179      Document or a portion of it, either copied verbatim, or with
9180      modifications and/or translated into another language.
9181
9182      A "Secondary Section" is a named appendix or a front-matter section
9183      of the Document that deals exclusively with the relationship of the
9184      publishers or authors of the Document to the Document's overall
9185      subject (or to related matters) and contains nothing that could
9186      fall directly within that overall subject.  (Thus, if the Document
9187      is in part a textbook of mathematics, a Secondary Section may not
9188      explain any mathematics.)  The relationship could be a matter of
9189      historical connection with the subject or with related matters, or
9190      of legal, commercial, philosophical, ethical or political position
9191      regarding them.
9192
9193      The "Invariant Sections" are certain Secondary Sections whose
9194      titles are designated, as being those of Invariant Sections, in
9195      the notice that says that the Document is released under this
9196      License.  If a section does not fit the above definition of
9197      Secondary then it is not allowed to be designated as Invariant.
9198      The Document may contain zero Invariant Sections.  If the Document
9199      does not identify any Invariant Sections then there are none.
9200
9201      The "Cover Texts" are certain short passages of text that are
9202      listed, as Front-Cover Texts or Back-Cover Texts, in the notice
9203      that says that the Document is released under this License.  A
9204      Front-Cover Text may be at most 5 words, and a Back-Cover Text may
9205      be at most 25 words.
9206
9207      A "Transparent" copy of the Document means a machine-readable copy,
9208      represented in a format whose specification is available to the
9209      general public, that is suitable for revising the document
9210      straightforwardly with generic text editors or (for images
9211      composed of pixels) generic paint programs or (for drawings) some
9212      widely available drawing editor, and that is suitable for input to
9213      text formatters or for automatic translation to a variety of
9214      formats suitable for input to text formatters.  A copy made in an
9215      otherwise Transparent file format whose markup, or absence of
9216      markup, has been arranged to thwart or discourage subsequent
9217      modification by readers is not Transparent.  An image format is
9218      not Transparent if used for any substantial amount of text.  A
9219      copy that is not "Transparent" is called "Opaque".
9220
9221      Examples of suitable formats for Transparent copies include plain
9222      ASCII without markup, Texinfo input format, LaTeX input format,
9223      SGML or XML using a publicly available DTD, and
9224      standard-conforming simple HTML, PostScript or PDF designed for
9225      human modification.  Examples of transparent image formats include
9226      PNG, XCF and JPG.  Opaque formats include proprietary formats that
9227      can be read and edited only by proprietary word processors, SGML or
9228      XML for which the DTD and/or processing tools are not generally
9229      available, and the machine-generated HTML, PostScript or PDF
9230      produced by some word processors for output purposes only.
9231
9232      The "Title Page" means, for a printed book, the title page itself,
9233      plus such following pages as are needed to hold, legibly, the
9234      material this License requires to appear in the title page.  For
9235      works in formats which do not have any title page as such, "Title
9236      Page" means the text near the most prominent appearance of the
9237      work's title, preceding the beginning of the body of the text.
9238
9239      The "publisher" means any person or entity that distributes copies
9240      of the Document to the public.
9241
9242      A section "Entitled XYZ" means a named subunit of the Document
9243      whose title either is precisely XYZ or contains XYZ in parentheses
9244      following text that translates XYZ in another language.  (Here XYZ
9245      stands for a specific section name mentioned below, such as
9246      "Acknowledgements", "Dedications", "Endorsements", or "History".)
9247      To "Preserve the Title" of such a section when you modify the
9248      Document means that it remains a section "Entitled XYZ" according
9249      to this definition.
9250
9251      The Document may include Warranty Disclaimers next to the notice
9252      which states that this License applies to the Document.  These
9253      Warranty Disclaimers are considered to be included by reference in
9254      this License, but only as regards disclaiming warranties: any other
9255      implication that these Warranty Disclaimers may have is void and
9256      has no effect on the meaning of this License.
9257
9258   2. VERBATIM COPYING
9259
9260      You may copy and distribute the Document in any medium, either
9261      commercially or noncommercially, provided that this License, the
9262      copyright notices, and the license notice saying this License
9263      applies to the Document are reproduced in all copies, and that you
9264      add no other conditions whatsoever to those of this License.  You
9265      may not use technical measures to obstruct or control the reading
9266      or further copying of the copies you make or distribute.  However,
9267      you may accept compensation in exchange for copies.  If you
9268      distribute a large enough number of copies you must also follow
9269      the conditions in section 3.
9270
9271      You may also lend copies, under the same conditions stated above,
9272      and you may publicly display copies.
9273
9274   3. COPYING IN QUANTITY
9275
9276      If you publish printed copies (or copies in media that commonly
9277      have printed covers) of the Document, numbering more than 100, and
9278      the Document's license notice requires Cover Texts, you must
9279      enclose the copies in covers that carry, clearly and legibly, all
9280      these Cover Texts: Front-Cover Texts on the front cover, and
9281      Back-Cover Texts on the back cover.  Both covers must also clearly
9282      and legibly identify you as the publisher of these copies.  The
9283      front cover must present the full title with all words of the
9284      title equally prominent and visible.  You may add other material
9285      on the covers in addition.  Copying with changes limited to the
9286      covers, as long as they preserve the title of the Document and
9287      satisfy these conditions, can be treated as verbatim copying in
9288      other respects.
9289
9290      If the required texts for either cover are too voluminous to fit
9291      legibly, you should put the first ones listed (as many as fit
9292      reasonably) on the actual cover, and continue the rest onto
9293      adjacent pages.
9294
9295      If you publish or distribute Opaque copies of the Document
9296      numbering more than 100, you must either include a
9297      machine-readable Transparent copy along with each Opaque copy, or
9298      state in or with each Opaque copy a computer-network location from
9299      which the general network-using public has access to download
9300      using public-standard network protocols a complete Transparent
9301      copy of the Document, free of added material.  If you use the
9302      latter option, you must take reasonably prudent steps, when you
9303      begin distribution of Opaque copies in quantity, to ensure that
9304      this Transparent copy will remain thus accessible at the stated
9305      location until at least one year after the last time you
9306      distribute an Opaque copy (directly or through your agents or
9307      retailers) of that edition to the public.
9308
9309      It is requested, but not required, that you contact the authors of
9310      the Document well before redistributing any large number of
9311      copies, to give them a chance to provide you with an updated
9312      version of the Document.
9313
9314   4. MODIFICATIONS
9315
9316      You may copy and distribute a Modified Version of the Document
9317      under the conditions of sections 2 and 3 above, provided that you
9318      release the Modified Version under precisely this License, with
9319      the Modified Version filling the role of the Document, thus
9320      licensing distribution and modification of the Modified Version to
9321      whoever possesses a copy of it.  In addition, you must do these
9322      things in the Modified Version:
9323
9324        A. Use in the Title Page (and on the covers, if any) a title
9325           distinct from that of the Document, and from those of
9326           previous versions (which should, if there were any, be listed
9327           in the History section of the Document).  You may use the
9328           same title as a previous version if the original publisher of
9329           that version gives permission.
9330
9331        B. List on the Title Page, as authors, one or more persons or
9332           entities responsible for authorship of the modifications in
9333           the Modified Version, together with at least five of the
9334           principal authors of the Document (all of its principal
9335           authors, if it has fewer than five), unless they release you
9336           from this requirement.
9337
9338        C. State on the Title page the name of the publisher of the
9339           Modified Version, as the publisher.
9340
9341        D. Preserve all the copyright notices of the Document.
9342
9343        E. Add an appropriate copyright notice for your modifications
9344           adjacent to the other copyright notices.
9345
9346        F. Include, immediately after the copyright notices, a license
9347           notice giving the public permission to use the Modified
9348           Version under the terms of this License, in the form shown in
9349           the Addendum below.
9350
9351        G. Preserve in that license notice the full lists of Invariant
9352           Sections and required Cover Texts given in the Document's
9353           license notice.
9354
9355        H. Include an unaltered copy of this License.
9356
9357        I. Preserve the section Entitled "History", Preserve its Title,
9358           and add to it an item stating at least the title, year, new
9359           authors, and publisher of the Modified Version as given on
9360           the Title Page.  If there is no section Entitled "History" in
9361           the Document, create one stating the title, year, authors,
9362           and publisher of the Document as given on its Title Page,
9363           then add an item describing the Modified Version as stated in
9364           the previous sentence.
9365
9366        J. Preserve the network location, if any, given in the Document
9367           for public access to a Transparent copy of the Document, and
9368           likewise the network locations given in the Document for
9369           previous versions it was based on.  These may be placed in
9370           the "History" section.  You may omit a network location for a
9371           work that was published at least four years before the
9372           Document itself, or if the original publisher of the version
9373           it refers to gives permission.
9374
9375        K. For any section Entitled "Acknowledgements" or "Dedications",
9376           Preserve the Title of the section, and preserve in the
9377           section all the substance and tone of each of the contributor
9378           acknowledgements and/or dedications given therein.
9379
9380        L. Preserve all the Invariant Sections of the Document,
9381           unaltered in their text and in their titles.  Section numbers
9382           or the equivalent are not considered part of the section
9383           titles.
9384
9385        M. Delete any section Entitled "Endorsements".  Such a section
9386           may not be included in the Modified Version.
9387
9388        N. Do not retitle any existing section to be Entitled
9389           "Endorsements" or to conflict in title with any Invariant
9390           Section.
9391
9392        O. Preserve any Warranty Disclaimers.
9393
9394      If the Modified Version includes new front-matter sections or
9395      appendices that qualify as Secondary Sections and contain no
9396      material copied from the Document, you may at your option
9397      designate some or all of these sections as invariant.  To do this,
9398      add their titles to the list of Invariant Sections in the Modified
9399      Version's license notice.  These titles must be distinct from any
9400      other section titles.
9401
9402      You may add a section Entitled "Endorsements", provided it contains
9403      nothing but endorsements of your Modified Version by various
9404      parties--for example, statements of peer review or that the text
9405      has been approved by an organization as the authoritative
9406      definition of a standard.
9407
9408      You may add a passage of up to five words as a Front-Cover Text,
9409      and a passage of up to 25 words as a Back-Cover Text, to the end
9410      of the list of Cover Texts in the Modified Version.  Only one
9411      passage of Front-Cover Text and one of Back-Cover Text may be
9412      added by (or through arrangements made by) any one entity.  If the
9413      Document already includes a cover text for the same cover,
9414      previously added by you or by arrangement made by the same entity
9415      you are acting on behalf of, you may not add another; but you may
9416      replace the old one, on explicit permission from the previous
9417      publisher that added the old one.
9418
9419      The author(s) and publisher(s) of the Document do not by this
9420      License give permission to use their names for publicity for or to
9421      assert or imply endorsement of any Modified Version.
9422
9423   5. COMBINING DOCUMENTS
9424
9425      You may combine the Document with other documents released under
9426      this License, under the terms defined in section 4 above for
9427      modified versions, provided that you include in the combination
9428      all of the Invariant Sections of all of the original documents,
9429      unmodified, and list them all as Invariant Sections of your
9430      combined work in its license notice, and that you preserve all
9431      their Warranty Disclaimers.
9432
9433      The combined work need only contain one copy of this License, and
9434      multiple identical Invariant Sections may be replaced with a single
9435      copy.  If there are multiple Invariant Sections with the same name
9436      but different contents, make the title of each such section unique
9437      by adding at the end of it, in parentheses, the name of the
9438      original author or publisher of that section if known, or else a
9439      unique number.  Make the same adjustment to the section titles in
9440      the list of Invariant Sections in the license notice of the
9441      combined work.
9442
9443      In the combination, you must combine any sections Entitled
9444      "History" in the various original documents, forming one section
9445      Entitled "History"; likewise combine any sections Entitled
9446      "Acknowledgements", and any sections Entitled "Dedications".  You
9447      must delete all sections Entitled "Endorsements."
9448
9449   6. COLLECTIONS OF DOCUMENTS
9450
9451      You may make a collection consisting of the Document and other
9452      documents released under this License, and replace the individual
9453      copies of this License in the various documents with a single copy
9454      that is included in the collection, provided that you follow the
9455      rules of this License for verbatim copying of each of the
9456      documents in all other respects.
9457
9458      You may extract a single document from such a collection, and
9459      distribute it individually under this License, provided you insert
9460      a copy of this License into the extracted document, and follow
9461      this License in all other respects regarding verbatim copying of
9462      that document.
9463
9464   7. AGGREGATION WITH INDEPENDENT WORKS
9465
9466      A compilation of the Document or its derivatives with other
9467      separate and independent documents or works, in or on a volume of
9468      a storage or distribution medium, is called an "aggregate" if the
9469      copyright resulting from the compilation is not used to limit the
9470      legal rights of the compilation's users beyond what the individual
9471      works permit.  When the Document is included in an aggregate, this
9472      License does not apply to the other works in the aggregate which
9473      are not themselves derivative works of the Document.
9474
9475      If the Cover Text requirement of section 3 is applicable to these
9476      copies of the Document, then if the Document is less than one half
9477      of the entire aggregate, the Document's Cover Texts may be placed
9478      on covers that bracket the Document within the aggregate, or the
9479      electronic equivalent of covers if the Document is in electronic
9480      form.  Otherwise they must appear on printed covers that bracket
9481      the whole aggregate.
9482
9483   8. TRANSLATION
9484
9485      Translation is considered a kind of modification, so you may
9486      distribute translations of the Document under the terms of section
9487      4.  Replacing Invariant Sections with translations requires special
9488      permission from their copyright holders, but you may include
9489      translations of some or all Invariant Sections in addition to the
9490      original versions of these Invariant Sections.  You may include a
9491      translation of this License, and all the license notices in the
9492      Document, and any Warranty Disclaimers, provided that you also
9493      include the original English version of this License and the
9494      original versions of those notices and disclaimers.  In case of a
9495      disagreement between the translation and the original version of
9496      this License or a notice or disclaimer, the original version will
9497      prevail.
9498
9499      If a section in the Document is Entitled "Acknowledgements",
9500      "Dedications", or "History", the requirement (section 4) to
9501      Preserve its Title (section 1) will typically require changing the
9502      actual title.
9503
9504   9. TERMINATION
9505
9506      You may not copy, modify, sublicense, or distribute the Document
9507      except as expressly provided under this License.  Any attempt
9508      otherwise to copy, modify, sublicense, or distribute it is void,
9509      and will automatically terminate your rights under this License.
9510
9511      However, if you cease all violation of this License, then your
9512      license from a particular copyright holder is reinstated (a)
9513      provisionally, unless and until the copyright holder explicitly
9514      and finally terminates your license, and (b) permanently, if the
9515      copyright holder fails to notify you of the violation by some
9516      reasonable means prior to 60 days after the cessation.
9517
9518      Moreover, your license from a particular copyright holder is
9519      reinstated permanently if the copyright holder notifies you of the
9520      violation by some reasonable means, this is the first time you have
9521      received notice of violation of this License (for any work) from
9522      that copyright holder, and you cure the violation prior to 30 days
9523      after your receipt of the notice.
9524
9525      Termination of your rights under this section does not terminate
9526      the licenses of parties who have received copies or rights from
9527      you under this License.  If your rights have been terminated and
9528      not permanently reinstated, receipt of a copy of some or all of
9529      the same material does not give you any rights to use it.
9530
9531  10. FUTURE REVISIONS OF THIS LICENSE
9532
9533      The Free Software Foundation may publish new, revised versions of
9534      the GNU Free Documentation License from time to time.  Such new
9535      versions will be similar in spirit to the present version, but may
9536      differ in detail to address new problems or concerns.  See
9537      `http://www.gnu.org/copyleft/'.
9538
9539      Each version of the License is given a distinguishing version
9540      number.  If the Document specifies that a particular numbered
9541      version of this License "or any later version" applies to it, you
9542      have the option of following the terms and conditions either of
9543      that specified version or of any later version that has been
9544      published (not as a draft) by the Free Software Foundation.  If
9545      the Document does not specify a version number of this License,
9546      you may choose any version ever published (not as a draft) by the
9547      Free Software Foundation.  If the Document specifies that a proxy
9548      can decide which future versions of this License can be used, that
9549      proxy's public statement of acceptance of a version permanently
9550      authorizes you to choose that version for the Document.
9551
9552  11. RELICENSING
9553
9554      "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
9555      World Wide Web server that publishes copyrightable works and also
9556      provides prominent facilities for anybody to edit those works.  A
9557      public wiki that anybody can edit is an example of such a server.
9558      A "Massive Multiauthor Collaboration" (or "MMC") contained in the
9559      site means any set of copyrightable works thus published on the MMC
9560      site.
9561
9562      "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
9563      license published by Creative Commons Corporation, a not-for-profit
9564      corporation with a principal place of business in San Francisco,
9565      California, as well as future copyleft versions of that license
9566      published by that same organization.
9567
9568      "Incorporate" means to publish or republish a Document, in whole or
9569      in part, as part of another Document.
9570
9571      An MMC is "eligible for relicensing" if it is licensed under this
9572      License, and if all works that were first published under this
9573      License somewhere other than this MMC, and subsequently
9574      incorporated in whole or in part into the MMC, (1) had no cover
9575      texts or invariant sections, and (2) were thus incorporated prior
9576      to November 1, 2008.
9577
9578      The operator of an MMC Site may republish an MMC contained in the
9579      site under CC-BY-SA on the same site at any time before August 1,
9580      2009, provided the MMC is eligible for relicensing.
9581
9582
9583 ADDENDUM: How to use this License for your documents
9584 ====================================================
9585
9586 To use this License in a document you have written, include a copy of
9587 the License in the document and put the following copyright and license
9588 notices just after the title page:
9589
9590        Copyright (C)  YEAR  YOUR NAME.
9591        Permission is granted to copy, distribute and/or modify this document
9592        under the terms of the GNU Free Documentation License, Version 1.3
9593        or any later version published by the Free Software Foundation;
9594        with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
9595        Texts.  A copy of the license is included in the section entitled ``GNU
9596        Free Documentation License''.
9597
9598    If you have Invariant Sections, Front-Cover Texts and Back-Cover
9599 Texts, replace the "with...Texts." line with this:
9600
9601          with the Invariant Sections being LIST THEIR TITLES, with
9602          the Front-Cover Texts being LIST, and with the Back-Cover Texts
9603          being LIST.
9604
9605    If you have Invariant Sections without Cover Texts, or some other
9606 combination of the three, merge those two alternatives to suit the
9607 situation.
9608
9609    If your document contains nontrivial examples of program code, we
9610 recommend releasing these examples in parallel under your choice of
9611 free software license, such as the GNU General Public License, to
9612 permit their use in free software.
9613
9614 \1f
9615 File: bashref.info,  Node: Indexes,  Prev: GNU Free Documentation License,  Up: Top
9616
9617 Appendix D Indexes
9618 ******************
9619
9620 * Menu:
9621
9622 * Builtin Index::               Index of Bash builtin commands.
9623 * Reserved Word Index::         Index of Bash reserved words.
9624 * Variable Index::              Quick reference helps you find the
9625                                 variable you want.
9626 * Function Index::              Index of bindable Readline functions.
9627 * Concept Index::               General index for concepts described in
9628                                 this manual.
9629
9630 \1f
9631 File: bashref.info,  Node: Builtin Index,  Next: Reserved Word Index,  Up: Indexes
9632
9633 D.1 Index of Shell Builtin Commands
9634 ===================================
9635
9636 \0\b[index\0\b]
9637 * Menu:
9638
9639 * .:                                     Bourne Shell Builtins.
9640                                                               (line  16)
9641 * ::                                     Bourne Shell Builtins.
9642                                                               (line  11)
9643 * [:                                     Bourne Shell Builtins.
9644                                                               (line 213)
9645 * alias:                                 Bash Builtins.       (line  11)
9646 * bg:                                    Job Control Builtins.
9647                                                               (line   7)
9648 * bind:                                  Bash Builtins.       (line  21)
9649 * break:                                 Bourne Shell Builtins.
9650                                                               (line  29)
9651 * builtin:                               Bash Builtins.       (line  98)
9652 * caller:                                Bash Builtins.       (line 106)
9653 * cd:                                    Bourne Shell Builtins.
9654                                                               (line  36)
9655 * command:                               Bash Builtins.       (line 123)
9656 * compgen:                               Programmable Completion Builtins.
9657                                                               (line  10)
9658 * complete:                              Programmable Completion Builtins.
9659                                                               (line  28)
9660 * compopt:                               Programmable Completion Builtins.
9661                                                               (line 217)
9662 * continue:                              Bourne Shell Builtins.
9663                                                               (line  55)
9664 * declare:                               Bash Builtins.       (line 142)
9665 * dirs:                                  Directory Stack Builtins.
9666                                                               (line   7)
9667 * disown:                                Job Control Builtins.
9668                                                               (line  83)
9669 * echo:                                  Bash Builtins.       (line 221)
9670 * enable:                                Bash Builtins.       (line 273)
9671 * eval:                                  Bourne Shell Builtins.
9672                                                               (line  63)
9673 * exec:                                  Bourne Shell Builtins.
9674                                                               (line  70)
9675 * exit:                                  Bourne Shell Builtins.
9676                                                               (line  82)
9677 * export:                                Bourne Shell Builtins.
9678                                                               (line  88)
9679 * fc:                                    Bash History Builtins.
9680                                                               (line  10)
9681 * fg:                                    Job Control Builtins.
9682                                                               (line  16)
9683 * getopts:                               Bourne Shell Builtins.
9684                                                               (line 103)
9685 * hash:                                  Bourne Shell Builtins.
9686                                                               (line 145)
9687 * help:                                  Bash Builtins.       (line 301)
9688 * history:                               Bash History Builtins.
9689                                                               (line  39)
9690 * jobs:                                  Job Control Builtins.
9691                                                               (line  25)
9692 * kill:                                  Job Control Builtins.
9693                                                               (line  57)
9694 * let:                                   Bash Builtins.       (line 321)
9695 * local:                                 Bash Builtins.       (line 328)
9696 * logout:                                Bash Builtins.       (line 338)
9697 * mapfile:                               Bash Builtins.       (line 342)
9698 * popd:                                  Directory Stack Builtins.
9699                                                               (line  37)
9700 * printf:                                Bash Builtins.       (line 388)
9701 * pushd:                                 Directory Stack Builtins.
9702                                                               (line  58)
9703 * pwd:                                   Bourne Shell Builtins.
9704                                                               (line 163)
9705 * read:                                  Bash Builtins.       (line 413)
9706 * readarray:                             Bash Builtins.       (line 493)
9707 * readonly:                              Bourne Shell Builtins.
9708                                                               (line 172)
9709 * return:                                Bourne Shell Builtins.
9710                                                               (line 188)
9711 * set:                                   The Set Builtin.     (line  11)
9712 * shift:                                 Bourne Shell Builtins.
9713                                                               (line 201)
9714 * shopt:                                 The Shopt Builtin.   (line   9)
9715 * source:                                Bash Builtins.       (line 501)
9716 * suspend:                               Job Control Builtins.
9717                                                               (line  94)
9718 * test:                                  Bourne Shell Builtins.
9719                                                               (line 213)
9720 * times:                                 Bourne Shell Builtins.
9721                                                               (line 281)
9722 * trap:                                  Bourne Shell Builtins.
9723                                                               (line 286)
9724 * type:                                  Bash Builtins.       (line 505)
9725 * typeset:                               Bash Builtins.       (line 536)
9726 * ulimit:                                Bash Builtins.       (line 542)
9727 * umask:                                 Bourne Shell Builtins.
9728                                                               (line 332)
9729 * unalias:                               Bash Builtins.       (line 630)
9730 * unset:                                 Bourne Shell Builtins.
9731                                                               (line 349)
9732 * wait:                                  Job Control Builtins.
9733                                                               (line  73)
9734
9735 \1f
9736 File: bashref.info,  Node: Reserved Word Index,  Next: Variable Index,  Prev: Builtin Index,  Up: Indexes
9737
9738 D.2 Index of Shell Reserved Words
9739 =================================
9740
9741 \0\b[index\0\b]
9742 * Menu:
9743
9744 * !:                                     Pipelines.           (line   9)
9745 * [[:                                    Conditional Constructs.
9746                                                               (line 117)
9747 * ]]:                                    Conditional Constructs.
9748                                                               (line 117)
9749 * case:                                  Conditional Constructs.
9750                                                               (line  28)
9751 * do:                                    Looping Constructs.  (line  12)
9752 * done:                                  Looping Constructs.  (line  12)
9753 * elif:                                  Conditional Constructs.
9754                                                               (line   7)
9755 * else:                                  Conditional Constructs.
9756                                                               (line   7)
9757 * esac:                                  Conditional Constructs.
9758                                                               (line  28)
9759 * fi:                                    Conditional Constructs.
9760                                                               (line   7)
9761 * for:                                   Looping Constructs.  (line  29)
9762 * function:                              Shell Functions.     (line  13)
9763 * if:                                    Conditional Constructs.
9764                                                               (line   7)
9765 * in:                                    Conditional Constructs.
9766                                                               (line  28)
9767 * select:                                Conditional Constructs.
9768                                                               (line  76)
9769 * then:                                  Conditional Constructs.
9770                                                               (line   7)
9771 * time:                                  Pipelines.           (line   9)
9772 * until:                                 Looping Constructs.  (line  12)
9773 * while:                                 Looping Constructs.  (line  20)
9774 * {:                                     Command Grouping.    (line  21)
9775 * }:                                     Command Grouping.    (line  21)
9776
9777 \1f
9778 File: bashref.info,  Node: Variable Index,  Next: Function Index,  Prev: Reserved Word Index,  Up: Indexes
9779
9780 D.3 Parameter and Variable Index
9781 ================================
9782
9783 \0\b[index\0\b]
9784 * Menu:
9785
9786 * !:                                     Special Parameters.  (line  46)
9787 * #:                                     Special Parameters.  (line  30)
9788 * $:                                     Special Parameters.  (line  42)
9789 * *:                                     Special Parameters.  (line   9)
9790 * -:                                     Special Parameters.  (line  37)
9791 * 0:                                     Special Parameters.  (line  50)
9792 * ?:                                     Special Parameters.  (line  33)
9793 * @:                                     Special Parameters.  (line  19)
9794 * _:                                     Special Parameters.  (line  59)
9795 * auto_resume:                           Job Control Variables.
9796                                                               (line   6)
9797 * BASH:                                  Bash Variables.      (line  13)
9798 * BASH_ALIASES:                          Bash Variables.      (line  30)
9799 * BASH_ARGC:                             Bash Variables.      (line  37)
9800 * BASH_ARGV:                             Bash Variables.      (line  47)
9801 * BASH_CMDS:                             Bash Variables.      (line  57)
9802 * BASH_COMMAND:                          Bash Variables.      (line  64)
9803 * BASH_ENV:                              Bash Variables.      (line  69)
9804 * BASH_EXECUTION_STRING:                 Bash Variables.      (line  75)
9805 * BASH_LINENO:                           Bash Variables.      (line  78)
9806 * BASH_REMATCH:                          Bash Variables.      (line  87)
9807 * BASH_SOURCE:                           Bash Variables.      (line  95)
9808 * BASH_SUBSHELL:                         Bash Variables.      (line  99)
9809 * BASH_VERSINFO:                         Bash Variables.      (line 103)
9810 * BASH_VERSION:                          Bash Variables.      (line 127)
9811 * BASH_XTRACEFD:                         Bash Variables.      (line 130)
9812 * BASHOPTS:                              Bash Variables.      (line  16)
9813 * BASHPID:                               Bash Variables.      (line  25)
9814 * bell-style:                            Readline Init File Syntax.
9815                                                               (line  38)
9816 * bind-tty-special-chars:                Readline Init File Syntax.
9817                                                               (line  45)
9818 * CDPATH:                                Bourne Shell Variables.
9819                                                               (line   9)
9820 * COLUMNS:                               Bash Variables.      (line 141)
9821 * comment-begin:                         Readline Init File Syntax.
9822                                                               (line  50)
9823 * COMP_CWORD:                            Bash Variables.      (line 146)
9824 * COMP_KEY:                              Bash Variables.      (line 175)
9825 * COMP_LINE:                             Bash Variables.      (line 152)
9826 * COMP_POINT:                            Bash Variables.      (line 157)
9827 * COMP_TYPE:                             Bash Variables.      (line 165)
9828 * COMP_WORDBREAKS:                       Bash Variables.      (line 179)
9829 * COMP_WORDS:                            Bash Variables.      (line 185)
9830 * completion-prefix-display-length:      Readline Init File Syntax.
9831                                                               (line  60)
9832 * completion-query-items:                Readline Init File Syntax.
9833                                                               (line  67)
9834 * COMPREPLY:                             Bash Variables.      (line 193)
9835 * convert-meta:                          Readline Init File Syntax.
9836                                                               (line  77)
9837 * DIRSTACK:                              Bash Variables.      (line 198)
9838 * disable-completion:                    Readline Init File Syntax.
9839                                                               (line  83)
9840 * editing-mode:                          Readline Init File Syntax.
9841                                                               (line  88)
9842 * EMACS:                                 Bash Variables.      (line 208)
9843 * enable-keypad:                         Readline Init File Syntax.
9844                                                               (line  99)
9845 * EUID:                                  Bash Variables.      (line 213)
9846 * expand-tilde:                          Readline Init File Syntax.
9847                                                               (line 110)
9848 * FCEDIT:                                Bash Variables.      (line 217)
9849 * FIGNORE:                               Bash Variables.      (line 221)
9850 * FUNCNAME:                              Bash Variables.      (line 227)
9851 * GLOBIGNORE:                            Bash Variables.      (line 236)
9852 * GROUPS:                                Bash Variables.      (line 242)
9853 * histchars:                             Bash Variables.      (line 248)
9854 * HISTCMD:                               Bash Variables.      (line 263)
9855 * HISTCONTROL:                           Bash Variables.      (line 268)
9856 * HISTFILE:                              Bash Variables.      (line 284)
9857 * HISTFILESIZE:                          Bash Variables.      (line 288)
9858 * HISTIGNORE:                            Bash Variables.      (line 296)
9859 * history-preserve-point:                Readline Init File Syntax.
9860                                                               (line 114)
9861 * history-size:                          Readline Init File Syntax.
9862                                                               (line 120)
9863 * HISTSIZE:                              Bash Variables.      (line 315)
9864 * HISTTIMEFORMAT:                        Bash Variables.      (line 319)
9865 * HOME:                                  Bourne Shell Variables.
9866                                                               (line  13)
9867 * horizontal-scroll-mode:                Readline Init File Syntax.
9868                                                               (line 125)
9869 * HOSTFILE:                              Bash Variables.      (line 328)
9870 * HOSTNAME:                              Bash Variables.      (line 339)
9871 * HOSTTYPE:                              Bash Variables.      (line 342)
9872 * IFS:                                   Bourne Shell Variables.
9873                                                               (line  18)
9874 * IGNOREEOF:                             Bash Variables.      (line 345)
9875 * input-meta:                            Readline Init File Syntax.
9876                                                               (line 132)
9877 * INPUTRC:                               Bash Variables.      (line 355)
9878 * isearch-terminators:                   Readline Init File Syntax.
9879                                                               (line 139)
9880 * keymap:                                Readline Init File Syntax.
9881                                                               (line 146)
9882 * LANG:                                  Bash Variables.      (line 359)
9883 * LC_ALL:                                Bash Variables.      (line 363)
9884 * LC_COLLATE:                            Bash Variables.      (line 367)
9885 * LC_CTYPE:                              Bash Variables.      (line 374)
9886 * LC_MESSAGES <1>:                       Locale Translation.  (line  11)
9887 * LC_MESSAGES:                           Bash Variables.      (line 379)
9888 * LC_NUMERIC:                            Bash Variables.      (line 383)
9889 * LINENO:                                Bash Variables.      (line 387)
9890 * LINES:                                 Bash Variables.      (line 391)
9891 * MACHTYPE:                              Bash Variables.      (line 396)
9892 * MAIL:                                  Bourne Shell Variables.
9893                                                               (line  22)
9894 * MAILCHECK:                             Bash Variables.      (line 400)
9895 * MAILPATH:                              Bourne Shell Variables.
9896                                                               (line  27)
9897 * mark-modified-lines:                   Readline Init File Syntax.
9898                                                               (line 159)
9899 * mark-symlinked-directories:            Readline Init File Syntax.
9900                                                               (line 164)
9901 * match-hidden-files:                    Readline Init File Syntax.
9902                                                               (line 169)
9903 * meta-flag:                             Readline Init File Syntax.
9904                                                               (line 132)
9905 * OLDPWD:                                Bash Variables.      (line 408)
9906 * OPTARG:                                Bourne Shell Variables.
9907                                                               (line  34)
9908 * OPTERR:                                Bash Variables.      (line 411)
9909 * OPTIND:                                Bourne Shell Variables.
9910                                                               (line  38)
9911 * OSTYPE:                                Bash Variables.      (line 415)
9912 * output-meta:                           Readline Init File Syntax.
9913                                                               (line 176)
9914 * page-completions:                      Readline Init File Syntax.
9915                                                               (line 181)
9916 * PATH:                                  Bourne Shell Variables.
9917                                                               (line  42)
9918 * PIPESTATUS:                            Bash Variables.      (line 418)
9919 * POSIXLY_CORRECT:                       Bash Variables.      (line 423)
9920 * PPID:                                  Bash Variables.      (line 432)
9921 * PROMPT_COMMAND:                        Bash Variables.      (line 436)
9922 * PROMPT_DIRTRIM:                        Bash Variables.      (line 440)
9923 * PS1:                                   Bourne Shell Variables.
9924                                                               (line  48)
9925 * PS2:                                   Bourne Shell Variables.
9926                                                               (line  53)
9927 * PS3:                                   Bash Variables.      (line 446)
9928 * PS4:                                   Bash Variables.      (line 451)
9929 * PWD:                                   Bash Variables.      (line 457)
9930 * RANDOM:                                Bash Variables.      (line 460)
9931 * REPLY:                                 Bash Variables.      (line 465)
9932 * revert-all-at-newline:                 Readline Init File Syntax.
9933                                                               (line 191)
9934 * SECONDS:                               Bash Variables.      (line 468)
9935 * SHELL:                                 Bash Variables.      (line 474)
9936 * SHELLOPTS:                             Bash Variables.      (line 479)
9937 * SHLVL:                                 Bash Variables.      (line 488)
9938 * show-all-if-ambiguous:                 Readline Init File Syntax.
9939                                                               (line 197)
9940 * show-all-if-unmodified:                Readline Init File Syntax.
9941                                                               (line 203)
9942 * skip-completed-text:                   Readline Init File Syntax.
9943                                                               (line 212)
9944 * TEXTDOMAIN:                            Locale Translation.  (line  11)
9945 * TEXTDOMAINDIR:                         Locale Translation.  (line  11)
9946 * TIMEFORMAT:                            Bash Variables.      (line 493)
9947 * TMOUT:                                 Bash Variables.      (line 531)
9948 * TMPDIR:                                Bash Variables.      (line 543)
9949 * UID:                                   Bash Variables.      (line 547)
9950 * visible-stats:                         Readline Init File Syntax.
9951                                                               (line 225)
9952
9953 \1f
9954 File: bashref.info,  Node: Function Index,  Next: Concept Index,  Prev: Variable Index,  Up: Indexes
9955
9956 D.4 Function Index
9957 ==================
9958
9959 \0\b[index\0\b]
9960 * Menu:
9961
9962 * abort (C-g):                           Miscellaneous Commands.
9963                                                                (line 10)
9964 * accept-line (Newline or Return):       Commands For History. (line  6)
9965 * backward-char (C-b):                   Commands For Moving.  (line 15)
9966 * backward-delete-char (Rubout):         Commands For Text.    (line 11)
9967 * backward-kill-line (C-x Rubout):       Commands For Killing. (line  9)
9968 * backward-kill-word (M-<DEL>):          Commands For Killing. (line 24)
9969 * backward-word (M-b):                   Commands For Moving.  (line 22)
9970 * beginning-of-history (M-<):            Commands For History. (line 20)
9971 * beginning-of-line (C-a):               Commands For Moving.  (line  6)
9972 * call-last-kbd-macro (C-x e):           Keyboard Macros.      (line 13)
9973 * capitalize-word (M-c):                 Commands For Text.    (line 46)
9974 * character-search (C-]):                Miscellaneous Commands.
9975                                                                (line 41)
9976 * character-search-backward (M-C-]):     Miscellaneous Commands.
9977                                                                (line 46)
9978 * clear-screen (C-l):                    Commands For Moving.  (line 34)
9979 * complete (<TAB>):                      Commands For Completion.
9980                                                                (line  6)
9981 * copy-backward-word ():                 Commands For Killing. (line 58)
9982 * copy-forward-word ():                  Commands For Killing. (line 63)
9983 * copy-region-as-kill ():                Commands For Killing. (line 54)
9984 * delete-char (C-d):                     Commands For Text.    (line  6)
9985 * delete-char-or-list ():                Commands For Completion.
9986                                                                (line 39)
9987 * delete-horizontal-space ():            Commands For Killing. (line 46)
9988 * digit-argument (M-0, M-1, ... M--):    Numeric Arguments.    (line  6)
9989 * do-uppercase-version (M-a, M-b, M-X, ...): Miscellaneous Commands.
9990                                                                (line 14)
9991 * downcase-word (M-l):                   Commands For Text.    (line 42)
9992 * dump-functions ():                     Miscellaneous Commands.
9993                                                                (line 73)
9994 * dump-macros ():                        Miscellaneous Commands.
9995                                                                (line 85)
9996 * dump-variables ():                     Miscellaneous Commands.
9997                                                                (line 79)
9998 * end-kbd-macro (C-x )):                 Keyboard Macros.      (line  9)
9999 * end-of-history (M->):                  Commands For History. (line 23)
10000 * end-of-line (C-e):                     Commands For Moving.  (line  9)
10001 * exchange-point-and-mark (C-x C-x):     Miscellaneous Commands.
10002                                                                (line 36)
10003 * forward-backward-delete-char ():       Commands For Text.    (line 15)
10004 * forward-char (C-f):                    Commands For Moving.  (line 12)
10005 * forward-search-history (C-s):          Commands For History. (line 31)
10006 * forward-word (M-f):                    Commands For Moving.  (line 18)
10007 * history-search-backward ():            Commands For History. (line 51)
10008 * history-search-forward ():             Commands For History. (line 46)
10009 * insert-comment (M-#):                  Miscellaneous Commands.
10010                                                                (line 60)
10011 * insert-completions (M-*):              Commands For Completion.
10012                                                                (line 18)
10013 * kill-line (C-k):                       Commands For Killing. (line  6)
10014 * kill-region ():                        Commands For Killing. (line 50)
10015 * kill-whole-line ():                    Commands For Killing. (line 15)
10016 * kill-word (M-d):                       Commands For Killing. (line 19)
10017 * menu-complete ():                      Commands For Completion.
10018                                                                (line 22)
10019 * menu-complete-backward ():             Commands For Completion.
10020                                                                (line 34)
10021 * next-history (C-n):                    Commands For History. (line 17)
10022 * non-incremental-forward-search-history (M-n): Commands For History.
10023                                                                (line 41)
10024 * non-incremental-reverse-search-history (M-p): Commands For History.
10025                                                                (line 36)
10026 * overwrite-mode ():                     Commands For Text.    (line 50)
10027 * possible-completions (M-?):            Commands For Completion.
10028                                                                (line 15)
10029 * prefix-meta (<ESC>):                   Miscellaneous Commands.
10030                                                                (line 18)
10031 * previous-history (C-p):                Commands For History. (line 13)
10032 * quoted-insert (C-q or C-v):            Commands For Text.    (line 20)
10033 * re-read-init-file (C-x C-r):           Miscellaneous Commands.
10034                                                                (line  6)
10035 * redraw-current-line ():                Commands For Moving.  (line 38)
10036 * reverse-search-history (C-r):          Commands For History. (line 27)
10037 * revert-line (M-r):                     Miscellaneous Commands.
10038                                                                (line 25)
10039 * self-insert (a, b, A, 1, !, ...):      Commands For Text.    (line 24)
10040 * set-mark (C-@):                        Miscellaneous Commands.
10041                                                                (line 32)
10042 * skip-csi-sequence ():                  Miscellaneous Commands.
10043                                                                (line 51)
10044 * start-kbd-macro (C-x ():               Keyboard Macros.      (line  6)
10045 * transpose-chars (C-t):                 Commands For Text.    (line 27)
10046 * transpose-words (M-t):                 Commands For Text.    (line 33)
10047 * undo (C-_ or C-x C-u):                 Miscellaneous Commands.
10048                                                                (line 22)
10049 * universal-argument ():                 Numeric Arguments.    (line 10)
10050 * unix-filename-rubout ():               Commands For Killing. (line 41)
10051 * unix-line-discard (C-u):               Commands For Killing. (line 12)
10052 * unix-word-rubout (C-w):                Commands For Killing. (line 37)
10053 * upcase-word (M-u):                     Commands For Text.    (line 38)
10054 * yank (C-y):                            Commands For Killing. (line 68)
10055 * yank-last-arg (M-. or M-_):            Commands For History. (line 65)
10056 * yank-nth-arg (M-C-y):                  Commands For History. (line 56)
10057 * yank-pop (M-y):                        Commands For Killing. (line 71)
10058
10059 \1f
10060 File: bashref.info,  Node: Concept Index,  Prev: Function Index,  Up: Indexes
10061
10062 D.5 Concept Index
10063 =================
10064
10065 \0\b[index\0\b]
10066 * Menu:
10067
10068 * alias expansion:                       Aliases.             (line   6)
10069 * arithmetic evaluation:                 Shell Arithmetic.    (line   6)
10070 * arithmetic expansion:                  Arithmetic Expansion.
10071                                                               (line   6)
10072 * arithmetic, shell:                     Shell Arithmetic.    (line   6)
10073 * arrays:                                Arrays.              (line   6)
10074 * background:                            Job Control Basics.  (line   6)
10075 * Bash configuration:                    Basic Installation.  (line   6)
10076 * Bash installation:                     Basic Installation.  (line   6)
10077 * Bourne shell:                          Basic Shell Features.
10078                                                               (line   6)
10079 * brace expansion:                       Brace Expansion.     (line   6)
10080 * builtin:                               Definitions.         (line  17)
10081 * command editing:                       Readline Bare Essentials.
10082                                                               (line   6)
10083 * command execution:                     Command Search and Execution.
10084                                                               (line   6)
10085 * command expansion:                     Simple Command Expansion.
10086                                                               (line   6)
10087 * command history:                       Bash History Facilities.
10088                                                               (line   6)
10089 * command search:                        Command Search and Execution.
10090                                                               (line   6)
10091 * command substitution:                  Command Substitution.
10092                                                               (line   6)
10093 * command timing:                        Pipelines.           (line   9)
10094 * commands, compound:                    Compound Commands.   (line   6)
10095 * commands, conditional:                 Conditional Constructs.
10096                                                               (line   6)
10097 * commands, grouping:                    Command Grouping.    (line   6)
10098 * commands, lists:                       Lists.               (line   6)
10099 * commands, looping:                     Looping Constructs.  (line   6)
10100 * commands, pipelines:                   Pipelines.           (line   6)
10101 * commands, shell:                       Shell Commands.      (line   6)
10102 * commands, simple:                      Simple Commands.     (line   6)
10103 * comments, shell:                       Comments.            (line   6)
10104 * completion builtins:                   Programmable Completion Builtins.
10105                                                               (line   6)
10106 * configuration:                         Basic Installation.  (line   6)
10107 * control operator:                      Definitions.         (line  21)
10108 * coprocess:                             Coprocesses.         (line   6)
10109 * directory stack:                       The Directory Stack. (line   6)
10110 * editing command lines:                 Readline Bare Essentials.
10111                                                               (line   6)
10112 * environment:                           Environment.         (line   6)
10113 * evaluation, arithmetic:                Shell Arithmetic.    (line   6)
10114 * event designators:                     Event Designators.   (line   6)
10115 * execution environment:                 Command Execution Environment.
10116                                                               (line   6)
10117 * exit status <1>:                       Exit Status.         (line   6)
10118 * exit status:                           Definitions.         (line  26)
10119 * expansion:                             Shell Expansions.    (line   6)
10120 * expansion, arithmetic:                 Arithmetic Expansion.
10121                                                               (line   6)
10122 * expansion, brace:                      Brace Expansion.     (line   6)
10123 * expansion, filename:                   Filename Expansion.  (line   9)
10124 * expansion, parameter:                  Shell Parameter Expansion.
10125                                                               (line   6)
10126 * expansion, pathname:                   Filename Expansion.  (line   9)
10127 * expansion, tilde:                      Tilde Expansion.     (line   6)
10128 * expressions, arithmetic:               Shell Arithmetic.    (line   6)
10129 * expressions, conditional:              Bash Conditional Expressions.
10130                                                               (line   6)
10131 * field:                                 Definitions.         (line  30)
10132 * filename:                              Definitions.         (line  35)
10133 * filename expansion:                    Filename Expansion.  (line   9)
10134 * foreground:                            Job Control Basics.  (line   6)
10135 * functions, shell:                      Shell Functions.     (line   6)
10136 * history builtins:                      Bash History Builtins.
10137                                                               (line   6)
10138 * history events:                        Event Designators.   (line   7)
10139 * history expansion:                     History Interaction. (line   6)
10140 * history list:                          Bash History Facilities.
10141                                                               (line   6)
10142 * History, how to use:                   Programmable Completion Builtins.
10143                                                               (line 237)
10144 * identifier:                            Definitions.         (line  51)
10145 * initialization file, readline:         Readline Init File.  (line   6)
10146 * installation:                          Basic Installation.  (line   6)
10147 * interaction, readline:                 Readline Interaction.
10148                                                               (line   6)
10149 * interactive shell <1>:                 Interactive Shells.  (line   6)
10150 * interactive shell:                     Invoking Bash.       (line 127)
10151 * internationalization:                  Locale Translation.  (line   6)
10152 * job:                                   Definitions.         (line  38)
10153 * job control <1>:                       Job Control Basics.  (line   6)
10154 * job control:                           Definitions.         (line  42)
10155 * kill ring:                             Readline Killing Commands.
10156                                                               (line  19)
10157 * killing text:                          Readline Killing Commands.
10158                                                               (line   6)
10159 * localization:                          Locale Translation.  (line   6)
10160 * login shell:                           Invoking Bash.       (line 124)
10161 * matching, pattern:                     Pattern Matching.    (line   6)
10162 * metacharacter:                         Definitions.         (line  46)
10163 * name:                                  Definitions.         (line  51)
10164 * native languages:                      Locale Translation.  (line   6)
10165 * notation, readline:                    Readline Bare Essentials.
10166                                                               (line   6)
10167 * operator, shell:                       Definitions.         (line  57)
10168 * parameter expansion:                   Shell Parameter Expansion.
10169                                                               (line   6)
10170 * parameters:                            Shell Parameters.    (line   6)
10171 * parameters, positional:                Positional Parameters.
10172                                                               (line   6)
10173 * parameters, special:                   Special Parameters.  (line   6)
10174 * pathname expansion:                    Filename Expansion.  (line   9)
10175 * pattern matching:                      Pattern Matching.    (line   6)
10176 * pipeline:                              Pipelines.           (line   6)
10177 * POSIX:                                 Definitions.         (line   9)
10178 * POSIX Mode:                            Bash POSIX Mode.     (line   6)
10179 * process group:                         Definitions.         (line  62)
10180 * process group ID:                      Definitions.         (line  66)
10181 * process substitution:                  Process Substitution.
10182                                                               (line   6)
10183 * programmable completion:               Programmable Completion.
10184                                                               (line   6)
10185 * prompting:                             Printing a Prompt.   (line   6)
10186 * quoting:                               Quoting.             (line   6)
10187 * quoting, ANSI:                         ANSI-C Quoting.      (line   6)
10188 * Readline, how to use:                  Job Control Variables.
10189                                                               (line  24)
10190 * redirection:                           Redirections.        (line   6)
10191 * reserved word:                         Definitions.         (line  70)
10192 * restricted shell:                      The Restricted Shell.
10193                                                               (line   6)
10194 * return status:                         Definitions.         (line  75)
10195 * shell arithmetic:                      Shell Arithmetic.    (line   6)
10196 * shell function:                        Shell Functions.     (line   6)
10197 * shell script:                          Shell Scripts.       (line   6)
10198 * shell variable:                        Shell Parameters.    (line   6)
10199 * shell, interactive:                    Interactive Shells.  (line   6)
10200 * signal:                                Definitions.         (line  78)
10201 * signal handling:                       Signals.             (line   6)
10202 * special builtin <1>:                   Special Builtins.    (line   6)
10203 * special builtin:                       Definitions.         (line  82)
10204 * startup files:                         Bash Startup Files.  (line   6)
10205 * suspending jobs:                       Job Control Basics.  (line   6)
10206 * tilde expansion:                       Tilde Expansion.     (line   6)
10207 * token:                                 Definitions.         (line  86)
10208 * translation, native languages:         Locale Translation.  (line   6)
10209 * variable, shell:                       Shell Parameters.    (line   6)
10210 * variables, readline:                   Readline Init File Syntax.
10211                                                               (line  37)
10212 * word:                                  Definitions.         (line  90)
10213 * word splitting:                        Word Splitting.      (line   6)
10214 * yanking text:                          Readline Killing Commands.
10215                                                               (line   6)
10216
10217
10218 \1f
10219 Tag Table:
10220 Node: Top\7f1346
10221 Node: Introduction\7f3185
10222 Node: What is Bash?\7f3413
10223 Node: What is a shell?\7f4526
10224 Node: Definitions\7f7066
10225 Node: Basic Shell Features\7f9984
10226 Node: Shell Syntax\7f11203
10227 Node: Shell Operation\7f12233
10228 Node: Quoting\7f13527
10229 Node: Escape Character\7f14830
10230 Node: Single Quotes\7f15315
10231 Node: Double Quotes\7f15663
10232 Node: ANSI-C Quoting\7f16788
10233 Node: Locale Translation\7f17773
10234 Node: Comments\7f18669
10235 Node: Shell Commands\7f19287
10236 Node: Simple Commands\7f20111
10237 Node: Pipelines\7f20742
10238 Node: Lists\7f22998
10239 Node: Compound Commands\7f24727
10240 Node: Looping Constructs\7f25531
10241 Node: Conditional Constructs\7f27986
10242 Node: Command Grouping\7f36099
10243 Node: Coprocesses\7f37578
10244 Node: Shell Functions\7f39222
10245 Node: Shell Parameters\7f43776
10246 Node: Positional Parameters\7f46192
10247 Node: Special Parameters\7f47092
10248 Node: Shell Expansions\7f50056
10249 Node: Brace Expansion\7f51981
10250 Node: Tilde Expansion\7f54736
10251 Node: Shell Parameter Expansion\7f57087
10252 Node: Command Substitution\7f65988
10253 Node: Arithmetic Expansion\7f67321
10254 Node: Process Substitution\7f68171
10255 Node: Word Splitting\7f69221
10256 Node: Filename Expansion\7f70844
10257 Node: Pattern Matching\7f72983
10258 Node: Quote Removal\7f76622
10259 Node: Redirections\7f76917
10260 Node: Executing Commands\7f85442
10261 Node: Simple Command Expansion\7f86112
10262 Node: Command Search and Execution\7f88042
10263 Node: Command Execution Environment\7f90379
10264 Node: Environment\7f93365
10265 Node: Exit Status\7f95025
10266 Node: Signals\7f96646
10267 Node: Shell Scripts\7f98614
10268 Node: Shell Builtin Commands\7f101132
10269 Node: Bourne Shell Builtins\7f103160
10270 Node: Bash Builtins\7f120536
10271 Node: Modifying Shell Behavior\7f145364
10272 Node: The Set Builtin\7f145709
10273 Node: The Shopt Builtin\7f155233
10274 Node: Special Builtins\7f166095
10275 Node: Shell Variables\7f167074
10276 Node: Bourne Shell Variables\7f167514
10277 Node: Bash Variables\7f169495
10278 Node: Bash Features\7f192981
10279 Node: Invoking Bash\7f193864
10280 Node: Bash Startup Files\7f199673
10281 Node: Interactive Shells\7f204685
10282 Node: What is an Interactive Shell?\7f205095
10283 Node: Is this Shell Interactive?\7f205744
10284 Node: Interactive Shell Behavior\7f206559
10285 Node: Bash Conditional Expressions\7f209839
10286 Node: Shell Arithmetic\7f213488
10287 Node: Aliases\7f216234
10288 Node: Arrays\7f218806
10289 Node: The Directory Stack\7f222764
10290 Node: Directory Stack Builtins\7f223478
10291 Node: Printing a Prompt\7f226370
10292 Node: The Restricted Shell\7f229122
10293 Node: Bash POSIX Mode\7f230954
10294 Node: Job Control\7f239011
10295 Node: Job Control Basics\7f239471
10296 Node: Job Control Builtins\7f244188
10297 Node: Job Control Variables\7f248552
10298 Node: Command Line Editing\7f249710
10299 Node: Introduction and Notation\7f251277
10300 Node: Readline Interaction\7f252899
10301 Node: Readline Bare Essentials\7f254090
10302 Node: Readline Movement Commands\7f255879
10303 Node: Readline Killing Commands\7f256844
10304 Node: Readline Arguments\7f258764
10305 Node: Searching\7f259808
10306 Node: Readline Init File\7f261994
10307 Node: Readline Init File Syntax\7f263141
10308 Node: Conditional Init Constructs\7f277628
10309 Node: Sample Init File\7f280161
10310 Node: Bindable Readline Commands\7f283278
10311 Node: Commands For Moving\7f284485
10312 Node: Commands For History\7f285629
10313 Node: Commands For Text\7f288784
10314 Node: Commands For Killing\7f291457
10315 Node: Numeric Arguments\7f293908
10316 Node: Commands For Completion\7f295047
10317 Node: Keyboard Macros\7f299007
10318 Node: Miscellaneous Commands\7f299578
10319 Node: Readline vi Mode\7f305384
10320 Node: Programmable Completion\7f306298
10321 Node: Programmable Completion Builtins\7f313504
10322 Node: Using History Interactively\7f322640
10323 Node: Bash History Facilities\7f323324
10324 Node: Bash History Builtins\7f326238
10325 Node: History Interaction\7f330095
10326 Node: Event Designators\7f332800
10327 Node: Word Designators\7f333815
10328 Node: Modifiers\7f335454
10329 Node: Installing Bash\7f336858
10330 Node: Basic Installation\7f337995
10331 Node: Compilers and Options\7f340687
10332 Node: Compiling For Multiple Architectures\7f341428
10333 Node: Installation Names\7f343092
10334 Node: Specifying the System Type\7f343910
10335 Node: Sharing Defaults\7f344626
10336 Node: Operation Controls\7f345299
10337 Node: Optional Features\7f346257
10338 Node: Reporting Bugs\7f355816
10339 Node: Major Differences From The Bourne Shell\7f357017
10340 Node: GNU Free Documentation License\7f373704
10341 Node: Indexes\7f398900
10342 Node: Builtin Index\7f399354
10343 Node: Reserved Word Index\7f406181
10344 Node: Variable Index\7f408629
10345 Node: Function Index\7f420722
10346 Node: Concept Index\7f427731
10347 \1f
10348 End Tag Table