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