Imported from ../bash-2.0.tar.gz.
[platform/upstream/bash.git] / doc / bashref.info
1 This is Info file bashref.info, produced by Makeinfo-1.64 from the
2 input file ./bashref.texi.
3
4 This text is a brief description of the features that are present in
5 the Bash shell.
6
7 This is Edition 2.0, last updated 25 November 1996,
8 of `The GNU Bash Reference Manual',
9 for `Bash', Version 2.0.
10
11 Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
12
13 Permission is granted to make and distribute verbatim copies of
14 this manual provided the copyright notice and this permission notice
15 are preserved on all copies.
16
17 Permission is granted to copy and distribute modified versions of this
18 manual under the conditions for verbatim copying, provided that the entire
19 resulting derived work is distributed under the terms of a permission
20 notice identical to this one.
21
22 Permission is granted to copy and distribute translations of this manual
23 into another language, under the above conditions for modified versions,
24 except that this permission notice may be stated in a translation approved
25 by the Foundation.
26
27 \1f
28 File: bashref.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
29
30 Bash Features
31 *************
32
33    This text is a brief description of the features that are present in
34 the Bash shell.
35
36    This is Edition 2.0, last updated 25 November 1996, of `The GNU Bash
37 Reference Manual', for `Bash', Version 2.0.
38
39    Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
40
41    Bash contains features that appear in other popular shells, and some
42 features that only appear in Bash.  Some of the shells that Bash has
43 borrowed concepts from are the Bourne Shell (`sh'), the Korn Shell
44 (`ksh'), and the C-shell (`csh' and its successor, `tcsh'). The
45 following menu breaks the features up into categories based upon which
46 one of these other shells inspired the feature.
47
48    This manual is meant as a brief introduction to features found in
49 Bash.  The Bash manual page should be used as the definitive reference
50 on shell behavior.
51
52 * Menu:
53
54 * Introduction::                An introduction to the shell.
55
56 * Definitions::                 Some definitions used in the rest of this
57                                 manual.
58
59 * Basic Shell Features::        The shell "building blocks".
60
61 * Bourne Shell Features::       Features similar to those found in the
62                                 Bourne shell.
63
64 * Csh Features::                Features originally found in the
65                                 Berkeley C-Shell.
66
67 * Korn Shell Features::         Features originally found in the Korn
68                                 Shell.
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 * Builtin Index::               Index of Bash builtin commands.
86
87 * Reserved Word Index::         Index of Bash reserved words.
88
89 * Variable Index::              Quick reference helps you find the
90                                 variable you want.
91
92 * Function Index::              Index of bindable Readline functions.
93
94 * Concept Index::               General index for concepts described in
95                                 this manual.
96
97 \1f
98 File: bashref.info,  Node: Introduction,  Next: Definitions,  Prev: Top,  Up: Top
99
100 Introduction
101 ************
102
103 * Menu:
104
105 * What is Bash?::               A short description of Bash.
106
107 * What is a shell?::            A brief introduction to shells.
108
109 \1f
110 File: bashref.info,  Node: What is Bash?,  Next: What is a shell?,  Up: Introduction
111
112 What is Bash?
113 =============
114
115    Bash is the shell, or command language interpreter, that will appear
116 in the GNU operating system.  The name is an acronym for the
117 `Bourne-Again SHell', a pun on Steve Bourne, the author of the direct
118 ancestor of the current Unix shell `/bin/sh', which appeared in the
119 Seventh Edition Bell Labs Research version of Unix.
120
121    Bash is an `sh'-compatible shell that incorporates useful features
122 from the Korn shell `ksh' and the C shell `csh'.  It is ultimately
123 intended to be a conformant implementation of the IEEE POSIX Shell and
124 Tools specification (IEEE Working Group 1003.2).  It offers functional
125 improvements over `sh' for both interactive and programming use.
126
127    While the GNU operating system will include a version of `csh', Bash
128 will be the default shell.  Like other GNU software, Bash is quite
129 portable.  It currently runs on nearly every version of Unix and a few
130 other operating systems - independently-supported ports exist for OS/2
131 and Windows NT.
132
133 \1f
134 File: bashref.info,  Node: What is a shell?,  Prev: What is Bash?,  Up: Introduction
135
136 What is a shell?
137 ================
138
139    At its base, a shell is simply a macro processor that executes
140 commands.  A Unix shell is both a command interpreter, which provides
141 the user interface to the rich set of Unix utilities, and a programming
142 language, allowing these utilitites to be combined.  The shell reads
143 commands either from a terminal or a file.  Files containing commands
144 can be created, and become commands themselves.  These new commands
145 have the same status as system commands in directories like `/bin',
146 allowing users or groups to establish custom environments.
147
148    A shell allows execution of Unix commands, both synchronously and
149 asynchronously.  The "redirection" constructs permit fine-grained
150 control of the input and output of those commands, and the shell allows
151 control over the contents of their environment.  Unix shells also
152 provide a small set of built-in commands ("builtins") implementing
153 functionality impossible (e.g., `cd', `break', `continue', and `exec'),
154 or inconvenient (`history', `getopts', `kill', or `pwd', for example)
155 to obtain via separate utilities.  Shells may be used interactively or
156 non-interactively: they accept input typed from the keyboard or from a
157 file.  All of the shell builtins are described in subsequent sections.
158
159    While executing commands is essential, most of the power (and
160 complexity) of shells is due to their embedded programming languages.
161 Like any high-level language, the shell provides variables, flow
162 control constructs, quoting, and functions.
163
164    Shells have begun offering features geared specifically for
165 interactive use rather than to augment the programming language.  These
166 interactive features include job control, command line editing, history
167 and aliases.  Each of these features is described in this manual.
168
169 \1f
170 File: bashref.info,  Node: Definitions,  Next: Basic Shell Features,  Prev: Introduction,  Up: Top
171
172 Definitions
173 ***********
174
175    These definitions are used throughout the remainder of this manual.
176
177 `POSIX'
178      A family of open system standards based on Unix.  Bash is
179      concerned with POSIX 1003.2, the Shell and Tools Standard.
180
181 `blank'
182      A space or tab character.
183
184 `builtin'
185      A command that is implemented internally by the shell itself,
186      rather than by an executable program somewhere in the file system.
187
188 `control operator'
189      A `word' that performs a control function.  It is a `newline' or
190      one of the following: `||', `&&', `&', `;', `;;', `|', `(', or `)'.
191
192 `exit status'
193      The value returned by a command to its caller.
194
195 `field'
196      A unit of text that is the result of one of the shell expansions.
197      After expansion, when executing a command, the resulting fields
198      are used as the command name and arguments.
199
200 `filename'
201      A string of characters used to identify a file.
202
203 `job'
204      A set of processes comprising a pipeline, and any processes
205      descended from it, that are all in the same process group.
206
207 `job control'
208      A mechanism by which users can selectively start and stop execution
209      of processes.
210
211 `metacharacter'
212      A character that, when unquoted, separates words.  A metacharacter
213      is a `blank' or one of the following characters: `|', `&', `;',
214      `(', `)', `<', or `>'.
215
216 `name'
217      A `word' consisting solely of letters, numbers, and underscores,
218      and beginning with a letter or underscore.  `Name's are used as
219      shell variable and function names.  Also referred to as an
220      `identifier'.
221
222 `operator'
223      A `control operator' or a `redirection operator'.  *Note
224      Redirections::, for a list of redirection operators.
225
226 `process group'
227      A collection of related processes each having the same process
228      group ID.
229
230 `process group ID'
231      A unique identifer that represents a `process group' during its
232      lifetime.
233
234 `reserved word'
235      A `word' that has a special meaning to the shell.  Most reserved
236      words introduce shell flow control constructs, such as `for' and
237      `while'.
238
239 `return status'
240      A synonym for `exit status'.
241
242 `signal'
243      A mechanism by which a process may be notified by the kernal of an
244      event occurring in the system.
245
246 `special builtin'
247      A shell builtin command that has been classified as special by the
248      POSIX.2 standard.
249
250 `token'
251      A sequence of characters considered a single unit by the shell.
252      It is either a `word' or an `operator'.
253
254 `word'
255      A `token' that is not an `operator'.
256
257 \1f
258 File: bashref.info,  Node: Basic Shell Features,  Next: Bourne Shell Features,  Prev: Definitions,  Up: Top
259
260 Basic Shell Features
261 ********************
262
263    Bash is an acronym for `Bourne-Again SHell'.  The Bourne shell is
264 the traditional Unix shell originally written by Stephen Bourne.  All
265 of the Bourne shell builtin commands are available in Bash, and the
266 rules for evaluation and quoting are taken from the POSIX 1003.2
267 specification for the `standard' Unix shell.
268
269    This chapter briefly summarizes the shell's "building blocks":
270 commands, control structures, shell functions, shell parameters, shell
271 expansions, redirections, which are a way to direct input and output
272 from and to named files, and how the shell executes commands.
273
274 * Menu:
275
276 * Shell Syntax::                What your input means to the shell.
277 * Simple Commands::             The most common type of command.
278 * Pipelines::                   Connecting the input and output of several
279                                 commands.
280 * Lists::                       How to execute commands sequentially.
281 * Looping Constructs::          Shell commands for iterative action.
282 * Conditional Constructs::      Shell commands for conditional execution.
283 * Command Grouping::            Ways to group commands.
284 * Shell Functions::             Grouping commands by name.
285 * Shell Parameters::            Special shell variables.
286 * Shell Expansions::            How Bash expands variables and the various
287                                 expansions available.
288 * Redirections::                A way to control where input and output go.
289 * Executing Commands::          What happens when you run a command.
290 * Shell Scripts::               Executing files of shell commands.
291
292 \1f
293 File: bashref.info,  Node: Shell Syntax,  Next: Simple Commands,  Up: Basic Shell Features
294
295 Shell Syntax
296 ============
297
298 * Menu:
299
300 * Shell Operation::     The basic operation of the shell.
301
302 * Quoting::             How to remove the special meaning from characters.
303
304 * Comments::            How to specify comments.
305
306 \1f
307 File: bashref.info,  Node: Shell Operation,  Next: Quoting,  Up: Shell Syntax
308
309 Shell Operation
310 ---------------
311
312    The following is a brief description of the shell's operation when it
313 reads and executes a command.  Basically, the shell does the following:
314
315   1. Reads its input from a file (*note Shell Scripts::.), from a string
316      supplied as an argument to the `-c' invocation option (*note
317      Invoking Bash::.), or from the user's terminal.
318
319   2. Breaks the input into words and operators, obeying the quoting
320      rules described in *Note Quoting::.  Tokens are separated by
321      `metacharacters'.  Alias expansion is performed by this step
322      (*note Aliases::.).
323
324   3. Parses the tokens into simple and compound commands.
325
326   4. Performs the various shell expansions (*note Shell Expansions::.),
327      breaking the expanded tokens into lists of filenames (*note
328      Filename Expansion::.) and commands and arguments.
329
330   5. Performs any necessary redirections (*note Redirections::.) and
331      removes the redirection operators and their operands from the
332      argument list.
333
334   6. Executes the command (*note Executing Commands::.).
335
336   7. Optionally waits for the command to complete and collects its exit
337      status.
338
339
340 \1f
341 File: bashref.info,  Node: Quoting,  Next: Comments,  Prev: Shell Operation,  Up: Shell Syntax
342
343 Quoting
344 -------
345
346 * Menu:
347
348 * Escape Character::    How to remove the special meaning from a single
349                         character.
350 * Single Quotes::       How to inhibit all interpretation of a sequence
351                         of characters.
352 * Double Quotes::       How to suppress most of the interpretation of a
353                         sequence of characters.
354 * ANSI-C Quoting::      How to expand ANSI-C sequences in quoted strings.
355
356 * Locale Translation::  How to translate strings into different languages.
357
358    Quoting is used to remove the special meaning of certain characters
359 or words to the shell.  Quoting can be used to disable special
360 treatment for special characters, to prevent reserved words from being
361 recognized as such, and to prevent parameter expansion.
362
363    Each of the shell `metacharacters' (*note Definitions::.) has
364 special meaning to the shell and must be quoted if they are to
365 represent themselves.  There are three quoting mechanisms: the ESCAPE
366 CHARACTER, single quotes, and double quotes.
367
368 \1f
369 File: bashref.info,  Node: Escape Character,  Next: Single Quotes,  Up: Quoting
370
371 Escape Character
372 ................
373
374    A non-quoted backslash `\' is the Bash escape character.  It
375 preserves the literal value of the next character that follows, with
376 the exception of `newline'.  If a `\newline' pair appears, and the
377 backslash is not quoted, the `\newline' is treated as a line
378 continuation (that is, it is effectively ignored).
379
380 \1f
381 File: bashref.info,  Node: Single Quotes,  Next: Double Quotes,  Prev: Escape Character,  Up: Quoting
382
383 Single Quotes
384 .............
385
386    Enclosing characters in single quotes preserves the literal value of
387 each character within the quotes.  A single quote may not occur between
388 single quotes, even when preceded by a backslash.
389
390 \1f
391 File: bashref.info,  Node: Double Quotes,  Next: ANSI-C Quoting,  Prev: Single Quotes,  Up: Quoting
392
393 Double Quotes
394 .............
395
396    Enclosing characters in double quotes preserves the literal value of
397 all characters within the quotes, with the exception of `$', ``', and
398 `\'.  The characters `$' and ``' retain their special meaning within
399 double quotes.  The backslash retains its special meaning only when
400 followed by one of the following characters: `$', ``', `"', `\', or
401 `newline'.  A double quote may be quoted within double quotes by
402 preceding it with a backslash.
403
404    The special parameters `*' and `@' have special meaning when in
405 double quotes (*note Shell Parameter Expansion::.).
406
407 \1f
408 File: bashref.info,  Node: ANSI-C Quoting,  Next: Locale Translation,  Prev: Double Quotes,  Up: Quoting
409
410 ANSI-C Quoting
411 ..............
412
413    Words of the form `$'STRING'' are treated specially.  The word
414 expands to STRING, with backslash-escaped characters replaced as
415 specifed by the ANSI C standard.  Backslash escape sequences, if
416 present, are decoded as follows:
417
418 `\a'
419      alert (bell)
420
421 `\b'
422      backspace
423
424 `\e'
425      an escape character (not ANSI C)
426
427 `\f'
428      form feed
429
430 `\n'
431      newline
432
433 `\r'
434      carriage return
435
436 `\t'
437      horizontal tab
438
439 `\v'
440      vertical tab
441
442 `\\'
443      backslash
444
445 `\NNN'
446      the character whose `ASCII' code is NNN in octal
447
448 The result is single-quoted, as if the dollar sign had not been present.
449
450 \1f
451 File: bashref.info,  Node: Locale Translation,  Prev: ANSI-C Quoting,  Up: Quoting
452
453 Locale-Specific Translation
454 ...........................
455
456    A double-quoted string preceded by a dollar sign (`$') will cause
457 the string to be translated according to the current locale.  If the
458 current locale is `C' or `POSIX', the dollar sign is ignored.  If the
459 string is translated and replaced, the replacement is double-quoted.
460
461 \1f
462 File: bashref.info,  Node: Comments,  Prev: Quoting,  Up: Shell Syntax
463
464 Comments
465 --------
466
467    In a non-interactive shell, or an interactive shell in which the
468 `interactive_comments' option to the `shopt' builtin is enabled (*note
469 Bash Builtins::.), a word beginning with `#' causes that word and all
470 remaining characters on that line to be ignored.  An interactive shell
471 without the `interactive_comments' option enabled does not allow
472 comments.  The `interactive_comments' option is on by default in
473 interactive shells.
474
475 \1f
476 File: bashref.info,  Node: Simple Commands,  Next: Pipelines,  Prev: Shell Syntax,  Up: Basic Shell Features
477
478 Simple Commands
479 ===============
480
481    A simple command is the kind of command you'll encounter most often.
482 It's just a sequence of words separated by `blank's, terminated by one
483 of the shell control operators (*note Definitions::.).  The first word
484 generally specifies a command to be executed.
485
486    The return status (*note Exit Status::.) of a simple command is its
487 exit status as provided by the POSIX.1 `waitpid' function, or 128+N if
488 the command was terminated by signal N.
489
490 \1f
491 File: bashref.info,  Node: Pipelines,  Next: Lists,  Prev: Simple Commands,  Up: Basic Shell Features
492
493 Pipelines
494 =========
495
496    A `pipeline' is a sequence of simple commands separated by `|'.
497
498    The format for a pipeline is
499      [`time' [`-p']] [`!'] COMMAND1 [`|' COMMAND2 ...]
500
501 The output of each command in the pipeline is connected to the input of
502 the next command.  That is, each command reads the previous command's
503 output.
504
505    The reserved word `time' causes timing statistics to be printed for
506 the pipeline once it finishes.  The `-p' option changes the output
507 format to that specified by POSIX.  The `TIMEFORMAT' variable may be
508 set to a format string that specifies how the timing information should
509 be displayed.  *Note Bash Variables::, for a description of the
510 available formats.
511
512    Each command in a pipeline is executed in its own subshell.  The exit
513 status of a pipeline is the exit status of the last command in the
514 pipeline.  If the reserved word `!' precedes the pipeline, the exit
515 status is the logical NOT of the exit status of the last command.
516
517 \1f
518 File: bashref.info,  Node: Lists,  Next: Looping Constructs,  Prev: Pipelines,  Up: Basic Shell Features
519
520 Lists of Commands
521 =================
522
523    A `list' is a sequence of one or more pipelines separated by one of
524 the operators `;', `&', `&&', or `||', and optionally terminated by one
525 of `;', `&', or a `newline'.
526
527    Of these list operators, `&&' and `||' have equal precedence,
528 followed by `;' and `&', which have equal precedence.
529
530    If a command is terminated by the control operator `&', the shell
531 executes the command in the BACKGROUND in a subshell.  The shell does
532 not wait for the command to finish, and the return status is 0 (true).
533 Commands separated by a `;' are executed sequentially; the shell waits
534 for each command to terminate in turn.  The return status is the exit
535 status of the last command executed.
536
537    The control operators `&&' and `||' denote AND lists and OR lists,
538 respectively.  An AND list has the form
539      COMMAND && COMMAND2
540
541 COMMAND2 is executed if, and only if, COMMAND returns an exit status of
542 zero.
543
544    An OR list has the form
545      COMMAND || COMMAND2
546
547 COMMAND2 is executed if and only if COMMAND returns a non-zero exit
548 status.
549
550    The return status of AND and OR lists is the exit status of the last
551 command executed in the list.
552
553 \1f
554 File: bashref.info,  Node: Looping Constructs,  Next: Conditional Constructs,  Prev: Lists,  Up: Basic Shell Features
555
556 Looping Constructs
557 ==================
558
559    Note that wherever you see a `;' in the description of a command's
560 syntax, it may be replaced indiscriminately with one or more newlines.
561
562    Bash supports the following looping constructs.
563
564 `until'
565      The syntax of the `until' command is:
566           until TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
567      Execute CONSEQUENT-COMMANDS as long as the final command in
568      TEST-COMMANDS has an exit status which is not zero.
569
570 `while'
571      The syntax of the `while' command is:
572           while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
573
574      Execute CONSEQUENT-COMMANDS as long as the final command in
575      TEST-COMMANDS has an exit status of zero.
576
577 `for'
578      The syntax of the `for' command is:
579
580           for NAME [in WORDS ...]; do COMMANDS; done
581      Execute COMMANDS for each member in WORDS, with NAME bound to the
582      current member.  If `in WORDS' is not present, `in "$@"' is
583      assumed.
584
585    The `break' and `continue' builtins (*note Bourne Shell Builtins::.)
586 may be used to control loop execution.
587
588 \1f
589 File: bashref.info,  Node: Conditional Constructs,  Next: Command Grouping,  Prev: Looping Constructs,  Up: Basic Shell Features
590
591 Conditional Constructs
592 ======================
593
594 `if'
595      The syntax of the `if' command is:
596
597           if TEST-COMMANDS; then
598             CONSEQUENT-COMMANDS;
599           [elif MORE-TEST-COMMANDS; then
600             MORE-CONSEQUENTS;]
601           [else ALTERNATE-CONSEQUENTS;]
602           fi
603
604      Execute CONSEQUENT-COMMANDS only if the final command in
605      TEST-COMMANDS has an exit status of zero.  Otherwise, each `elif'
606      list is executed in turn, and if its exit status is zero, the
607      corresponding MORE-CONSEQUENTS is executed and the command
608      completes.  If `else ALTERNATE-CONSEQUENTS' is present, and the
609      final command in the final `if' or `elif' clause has a non-zero
610      exit status, then execute ALTERNATE-CONSEQUENTS.
611
612 `case'
613      The syntax of the `case' command is:
614
615           `case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac'
616
617      Selectively execute COMMANDS based upon WORD matching PATTERN.
618      The `|' is used to separate multiple patterns.
619
620      Here is an example using `case' in a script that could be used to
621      describe one interesting feature of an animal:
622
623           echo -n "Enter the name of an animal: "
624           read ANIMAL
625           echo -n "The $ANIMAL has "
626           case $ANIMAL in
627             horse | dog | cat) echo -n "four";;
628             man | kangaroo ) echo -n "two";;
629             *) echo -n "an unknown number of";;
630           esac
631           echo " legs."
632
633 `((...))'
634           (( EXPRESSION ))
635
636      The EXPRESSION is evaluated according to the rules described below
637      ((*note Arithmetic Evaluation::.).  If the value of the expression
638      is non-zero, the return status is 0; otherwise the return status
639      is 1.  This is exactly equivalent to
640           let "EXPRESSION"
641
642    The `select' construct, which allows users to choose from a list of
643 items presented as a menu, is also available.  *Note Korn Shell
644 Constructs::, for a full description of `select'.
645
646 \1f
647 File: bashref.info,  Node: Command Grouping,  Next: Shell Functions,  Prev: Conditional Constructs,  Up: Basic Shell Features
648
649 Grouping Commands
650 =================
651
652    Bash provides two ways to group a list of commands to be executed as
653 a unit.  When commands are grouped, redirections may be applied to the
654 entire command list.  For example, the output of all the commands in
655 the list may be redirected to a single stream.
656
657 `()'
658           ( LIST )
659
660      Placing a list of commands between parentheses causes a subshell
661      to be created, and each of the commands to be executed in that
662      subshell.  Since the LIST is executed in a subshell, variable
663      assignments do not remain in effect after the subshell completes.
664
665 `{}'
666           { LIST; }
667
668      Placing a list of commands between curly braces causes the list to
669      be executed in the current shell context.  No subshell is created.
670      The semicolon following LIST is required.
671
672    In addition to the creation of a subshell, there is a subtle
673 difference between these two constructs due to historical reasons.  The
674 braces are `reserved words', so they must be separated from the LIST by
675 `blank's.  The parentheses are `operators', and are recognized as
676 separate tokens by the shell even if they are not separated from `list'
677 by whitespace.
678
679    The exit status of both of these constructs is the exit status of
680 LIST.
681
682 \1f
683 File: bashref.info,  Node: Shell Functions,  Next: Shell Parameters,  Prev: Command Grouping,  Up: Basic Shell Features
684
685 Shell Functions
686 ===============
687
688    Shell functions are a way to group commands for later execution
689 using a single name for the group.  They are executed just like a
690 "regular" command.  Shell functions are executed in the current shell
691 context; no new process is created to interpret them.
692
693    Functions are declared using this syntax:
694      [ `function' ] NAME () { COMMAND-LIST; }
695
696    This defines a shell function named NAME.  The reserved word
697 `function' is optional.  The BODY of the function is the COMMAND-LIST
698 between { and }.  This list is executed whenever NAME is specified as
699 the name of a command.  The exit status of a function is the exit
700 status of the last command executed in the body.
701
702    When a function is executed, the arguments to the function become
703 the positional parameters during its execution (*note Positional
704 Parameters::.).  The special parameter `#' that gives the number of
705 positional parameters is updated to reflect the change.  Positional
706 parameter `0' is unchanged.
707
708    If the builtin command `return' is executed in a function, the
709 function completes and execution resumes with the next command after
710 the function call.  When a function completes, the values of the
711 positional parameters and the special parameter `#' are restored to the
712 values they had prior to function execution.  If a numeric argument is
713 given to `return', that is the function return status.
714
715    Variables local to the function may be declared with the `local'
716 builtin.  These variables are visible only to the function and the
717 commands it invokes.
718
719    Functions may be recursive.  No limit is placed on the number of
720 recursive  calls.
721
722 \1f
723 File: bashref.info,  Node: Shell Parameters,  Next: Shell Expansions,  Prev: Shell Functions,  Up: Basic Shell Features
724
725 Shell Parameters
726 ================
727
728 * Menu:
729
730 * Positional Parameters::       The shell's command-line arguments.
731 * Special Parameters::          Parameters with special meanings.
732
733    A PARAMETER is an entity that stores values.  It can be a `name', a
734 number, or one of the special characters listed below.  For the shell's
735 purposes, a VARIABLE is a parameter denoted by a `name'.
736
737    A parameter is set if it has been assigned a value.  The null string
738 is a valid value.  Once a variable is set, it may be unset only by using
739 the `unset' builtin command.
740
741    A variable may be assigned to by a statement of the form
742      NAME=[VALUE]
743
744 If VALUE is not given, the variable is assigned the null string.  All
745 VALUEs undergo tilde expansion, parameter and variable expansion,
746 command substitution, arithmetic expansion, and quote removal (detailed
747 below).  If the variable has its `-i' attribute set (see the
748 description of the `declare' builtin in *Note Bash Builtins::), then
749 VALUE is subject to arithmetic expansion even if the `$((...))' syntax
750 does not appear (*note Arithmetic Expansion::.).  Word splitting is not
751 performed, with the exception of `"$@"' as explained below.  Filename
752 expansion is not performed.
753
754 \1f
755 File: bashref.info,  Node: Positional Parameters,  Next: Special Parameters,  Up: Shell Parameters
756
757 Positional Parameters
758 ---------------------
759
760    A POSITIONAL PARAMETER is a parameter denoted by one or more digits,
761 other than the single digit `0'.  Positional parameters are assigned
762 from the shell's arguments when it is invoked, and may be reassigned
763 using the `set' builtin command.  Positional parameters may not be
764 assigned to with assignment statements.  The positional parameters are
765 temporarily replaced when a shell function is executed (*note Shell
766 Functions::.).
767
768    When a positional parameter consisting of more than a single digit
769 is expanded, it must be enclosed in braces.
770
771 \1f
772 File: bashref.info,  Node: Special Parameters,  Prev: Positional Parameters,  Up: Shell Parameters
773
774 Special Parameters
775 ------------------
776
777    The shell treats several parameters specially.  These parameters may
778 only be referenced; assignment to them is not allowed.
779
780 `*'
781      Expands to the positional parameters, starting from one.  When the
782      expansion occurs within double quotes, it expands to a single word
783      with the value of each parameter separated by the first character
784      of the `IFS' special variable.  That is, `"$*"' is equivalent to
785      `"$1C$2C..."', where C is the first character of the value of the
786      `IFS' variable.  If `IFS' is null or unset, the parameters are
787      separated by spaces.
788
789 `@'
790      Expands to the positional parameters, starting from one.  When the
791      expansion occurs within double quotes, each parameter expands as a
792      separate word.  That is, `"$@"' is equivalent to `"$1" "$2" ...'.
793      When there are no positional parameters, `"$@"' and `$@' expand to
794      nothing (i.e., they are removed).
795
796 `#'
797      Expands to the number of positional parameters in decimal.
798
799 `?'
800      Expands to the exit status of the most recently executed foreground
801      pipeline.
802
803 `-'
804      Expands to the current option flags as specified upon invocation,
805      by the `set' builtin command, or those set by the shell itself
806      (such as the `-i' option).
807
808 `$'
809      Expands to the process ID of the shell.  In a `()' subshell, it
810      expands to the process ID of the current shell, not the subshell.
811
812 `!'
813      Expands to the process ID of the most recently executed background
814      (asynchronous) command.
815
816 `0'
817      Expands to the name of the shell or shell script.  This is set at
818      shell initialization.  If Bash is invoked with a file of commands,
819      `$0' is set to the name of that file.  If Bash is started with the
820      `-c' option, then `$0' is set to the first argument after the
821      string to be executed, if one is present.  Otherwise, it is set to
822      the filename used to invoke Bash, as given by argument zero.
823
824 `_'
825      At shell startup, set to the absolute filename of the shell or
826      shell script being executed as passed in the argument list.
827      Subsequently, expands to the last argument to the previous command,
828      after expansion.  Also set to the full filename of each command
829      executed and placed in the environment exported to that command.
830      When checking mail, this parameter holds the name of the mail file.
831
832 \1f
833 File: bashref.info,  Node: Shell Expansions,  Next: Redirections,  Prev: Shell Parameters,  Up: Basic Shell Features
834
835 Shell Expansions
836 ================
837
838    Expansion is performed on the command line after it has been split
839 into `token's.  There are seven kinds of expansion performed:
840    * brace expansion
841
842    * tilde expansion
843
844    * parameter and variable expansion
845
846    * command substitution
847
848    * arithmetic expansion
849
850    * word splitting
851
852    * filename expansion
853
854 * Menu:
855
856 * Shell Parameter Expansion::   How Bash expands variables to their values.
857 * Command Substitution::        Using the output of a command as an argument.
858 * Process Substitution::        A way to write and read to and from a
859                                 command.
860 * Word Splitting::      How the results of expansion are split into separate
861                         arguments.
862 * Filename Expansion::  A shorthand for specifying filenames matching patterns.
863 * Quote Removal::       How and when quote characters are removed from
864                         words.
865
866    Brace expansion, tilde expansion, and arithmetic expansion are
867 described in other sections.  For brace expansion, see *Note Brace
868 Expansion::; for tilde expansion, see *Note Tilde Expansion::; and for
869 arithmetic expansion, see *Note Arithmetic Expansion::.
870
871    The order of expansions is: brace expansion, tilde expansion,
872 parameter, variable, and arithmetic expansion and command substitution
873 (done in a left-to-right fashion), word splitting, and filename
874 expansion.
875
876    On systems that can support it, there is an additional expansion
877 available: PROCESS SUBSTITUTION.  This is performed at the same time as
878 parameter, variable, and arithemtic expansion and command substitution.
879
880    Only brace expansion, word splitting, and filename expansion can
881 change the number of words of the expansion; other expansions expand a
882 single word to a single word.  The only exceptions to this are the
883 expansions of `"$@"' (*note Special Parameters::.) and `"${[@]}"'
884 (*note Arrays::.).
885
886    After all expansions, `quote removal' (*note Quote Removal::.) is
887 performed.
888
889 \1f
890 File: bashref.info,  Node: Shell Parameter Expansion,  Next: Command Substitution,  Up: Shell Expansions
891
892 Shell Parameter Expansion
893 -------------------------
894
895    The `$' character introduces parameter expansion, command
896 substitution, or arithmetic expansion.  The parameter name or symbol to
897 be expanded may be enclosed in braces, which are optional but serve to
898 protect the variable to be expanded from characters immediately
899 following it which could be interpreted as part of the name.
900
901    The basic form of parameter expansion is ${PARAMETER}.  The value of
902 PARAMETER is substituted.  The braces are required when PARAMETER is a
903 positional parameter with more than one digit, or when PARAMETER is
904 followed by a character that is not to be interpreted as part of its
905 name.
906
907    If the first character of PARAMETER is an exclamation point, a level
908 of variable indirection is introduced.  Bash uses the value of the
909 variable formed from the rest of PARAMETER as the name of the variable;
910 this variable is then expanded and that value used in the rest of the
911 substitution, rather than the value of PARAMETER itself.  This is known
912 as `indirect expansion'.
913
914    In each of the cases below, WORD is subject to tilde expansion,
915 parameter expansion, command substitution, and arithmetic expansion.
916 When not performing substring expansion, Bash tests for a parameter
917 that is unset or null; omitting the colon results in a test only for a
918 parameter that is unset.
919
920 `${PARAMETER:-WORD}'
921      If PARAMETER is unset or null, the expansion of WORD is
922      substituted.  Otherwise, the value of PARAMETER is substituted.
923
924 `${PARAMETER:=WORD}'
925      If PARAMETER is unset or null, the expansion of WORD is assigned
926      to PARAMETER.  The value of PARAMETER is then substituted.
927      Positional parameters and special parameters may not be assigned
928      to in this way.
929
930 `${PARAMETER:?WORD}'
931      If PARAMETER is null or unset, the expansion of WORD (or a message
932      to that effect if WORD is not present) is written to the standard
933      error and the shell, if it is not interactive, exits.  Otherwise,
934      the value of PARAMETER is substituted.
935
936 `${PARAMETER:+WORD}'
937      If PARAMETER is null or unset, nothing is substituted, otherwise
938      the expansion of WORD is substituted.
939
940 `${PARAMETER:OFFSET}'
941 `${PARAMETER:OFFSET:LENGTH}'
942      Expands to up to LENGTH characters of PARAMETER, starting at
943      OFFSET.  If LENGTH is omitted, expands to the substring of
944      PARAMETER, starting at the character specified by OFFSET.  LENGTH
945      and OFFSET are arithmetic expressions (*note Arithmetic
946      Evaluation::.).  This is referred to as Substring Expansion.
947
948      LENGTH must evaluate to a number greater than or equal to zero.
949      If OFFSET evaluates to a number less than zero, the value is used
950      as an offset from the end of the value of PARAMETER.  If PARAMETER
951      is `@', the result is LENGTH positional parameters beginning at
952      OFFSET.  If PARAMETER is an array name indexed by `@' or `*', the
953      result is the LENGTH members of the array beginning with
954      ${PARAMETER[OFFSET]}.  Substring indexing is zero-based unless the
955      positional parameters are used, in which case the indexing starts
956      at 1.
957
958 `${#PARAMETER}'
959      The length in characters of the value of PARAMETER is substituted.
960      If PARAMETER is `*' or `@', the length substituted is the number
961      of positional parameters.  If PARAMETER is an array name
962      subscripted by `*' or `@', the length substituted is the number of
963      elements in the array.
964
965 `${PARAMETER#WORD}'
966 `${PARAMETER##WORD}'
967      The WORD is expanded to produce a pattern just as in filename
968      expansion (*note Filename Expansion::.).  If the pattern matches
969      the beginning of the value of PARAMETER, then the expansion is the
970      value of PARAMETER with the shortest matching pattern (the `#'
971      case) or the longest matching pattern (the `##' case) deleted.  If
972      PARAMETER is `@' or `*', the pattern removal operation is applied
973      to each positional parameter in turn, and the expansion is the
974      resultant list.  If PARAMETER is an array variable subscripted with
975      `@' or `*', the pattern removal operation is applied to each
976      member of the array in turn, and the expansion is the resultant
977      list.
978
979 `${PARAMETER%WORD}'
980 `${PARAMETER%%WORD}'
981      The WORD is expanded to produce a pattern just as in filename
982      expansion.  If the pattern matches a trailing portion of the value
983      of PARAMETER, then the expansion is the value of PARAMETER with
984      the shortest matching pattern (the `%' case) or the longest
985      matching pattern (the `%%' case) deleted.  If PARAMETER is `@' or
986      `*', the pattern removal operation is applied to each positional
987      parameter in turn, and the expansion is the resultant list.  If
988      PARAMETER is an array variable subscripted with `@' or `*', the
989      pattern removal operation is applied to each member of the array
990      in turn, and the expansion is the resultant list.
991
992 `${PARAMETER/PATTERN/STRING}'
993 `${PARAMETER//PATTERN/STRING}'
994      The PATTERN is expanded to produce a pattern just as in filename
995      expansion.  PARAMETER is expanded and the longest match of PATTERN
996      against its value is replaced with STRING.  In the first form,
997      only the first match is replaced.  The second form causes all
998      matches of PATTERN to be replaced with STRING.  If PATTERN begins
999      with `#', it must match at the beginning of STRING.  If PATTERN
1000      begins with `%', it must match at the end of STRING.  If STRING is
1001      null, matches of PATTERN are deleted and the `/' following PATTERN
1002      may be omitted.  If PARAMETER is `@' or `*', the substitution
1003      operation is applied to each positional parameter in turn, and the
1004      expansion is the resultant list.  If PARAMETER is an array
1005      variable subscripted with `@' or `*', the substitution operation
1006      is applied to each member of the array in turn, and the expansion
1007      is the resultant list.
1008
1009 \1f
1010 File: bashref.info,  Node: Command Substitution,  Next: Process Substitution,  Prev: Shell Parameter Expansion,  Up: Shell Expansions
1011
1012 Command Substitution
1013 --------------------
1014
1015    Command substitution allows the output of a command to replace the
1016 command name.  There are two forms:
1017      $(COMMAND)
1018
1019 or
1020      `COMMAND`
1021
1022 Bash performs the expansion by executing COMMAND and replacing the
1023 command substitution with the standard output of the command, with any
1024 trailing newlines deleted.
1025
1026    When the old-style backquote form of substitution is used, backslash
1027 retains its literal meaning except when followed by `$', ``', or `\'.
1028 When using the `$(COMMAND)' form, all characters between the
1029 parentheses make up the command; none are treated specially.
1030
1031    Command substitutions may be nested.  To nest when using the old
1032 form, escape the inner backquotes with backslashes.
1033
1034    If the substitution appears within double quotes, word splitting and
1035 filename expansion are not performed on the results.
1036
1037 \1f
1038 File: bashref.info,  Node: Process Substitution,  Next: Word Splitting,  Prev: Command Substitution,  Up: Shell Expansions
1039
1040 Process Substitution
1041 --------------------
1042
1043    Process substitution is supported on systems that support named
1044 pipes (FIFOs) or the `/dev/fd' method of naming open files.  It takes
1045 the form of
1046      <(LIST)
1047
1048 or
1049      >(LIST)
1050
1051 The process LIST is run with its input or output connected to a FIFO or
1052 some file in `/dev/fd'.  The name of this file is passed as an argument
1053 to the current command as the result of the expansion.  If the
1054 `>(LIST)' form is used, writing to the file will provide input for
1055 LIST.  If the `<(LIST)' form is used, the file passed as an argument
1056 should be read to obtain the output of LIST.
1057
1058    On systems that support it, process substitution is performed
1059 simultaneously with parameter and variable expansion, command
1060 substitution, and arithmetic expansion.
1061
1062 \1f
1063 File: bashref.info,  Node: Word Splitting,  Next: Filename Expansion,  Prev: Process Substitution,  Up: Shell Expansions
1064
1065 Word Splitting
1066 --------------
1067
1068    The shell scans the results of parameter expansion, command
1069 substitution, and arithmetic expansion that did not occur within double
1070 quotes for word splitting.
1071
1072    The shell treats each character of `$IFS' as a delimiter, and splits
1073 the results of the other expansions into words on these characters.  If
1074 `IFS' is unset, or its value is exactly `<space><tab><newline>', the
1075 default, then any sequence of `IFS' characters serves to delimit words.
1076 If `IFS' has a value other than the default, then sequences of the
1077 whitespace characters `space' and `tab' are ignored at the beginning
1078 and end of the word, as long as the whitespace character is in the
1079 value of `IFS' (an `IFS' whitespace character).  Any character in `IFS'
1080 that is not `IFS' whitespace, along with any adjacent `IFS' whitespace
1081 characters, delimits a field.  A sequence of `IFS' whitespace
1082 characters is also treated as a delimiter.  If the value of `IFS' is
1083 null, no word splitting occurs.
1084
1085    Explicit null arguments (`""' or `''') are retained.  Unquoted
1086 implicit null arguments, resulting from the expansion of PARAMETERs
1087 that have no values, are removed.  If a parameter with no value is
1088 expanded within double quotes, a null argument results and is retained.
1089
1090    Note that if no expansion occurs, no splitting is performed.
1091
1092 \1f
1093 File: bashref.info,  Node: Filename Expansion,  Next: Quote Removal,  Prev: Word Splitting,  Up: Shell Expansions
1094
1095 Filename Expansion
1096 ------------------
1097
1098    After word splitting, unless the `-f' option has been set (*note The
1099 Set Builtin::.), Bash scans each word for the characters `*', `?', and
1100 `['.  If one of these characters appears, then the word is regarded as
1101 a PATTERN, and replaced with an alphabetically sorted list of file
1102 names matching the pattern. If no matching file names are found, and
1103 the shell option `nullglob' is disabled, the word is left unchanged. If
1104 the option is set, and no matches are found, the word is removed.  When
1105 a pattern is used for filename generation, the character `.' at the
1106 start of a filename or immediately following a slash must be matched
1107 explicitly, unless the shell option `dotglob' is set.  The slash
1108 character must always be matched explicitly.  In other cases, the `.'
1109 character is not treated specially.  See the description of `shopt' in
1110 *Note Bash Builtins::, for a description of the `nullglob' and
1111 `dotglob' options.
1112
1113    The `GLOBIGNORE' shell variable may be used to restrict the set of
1114 filenames matching a PATTERN.  If `GLOBIGNORE' is set, each matching
1115 filename that also matches one of the patterns in `GLOBIGNORE' is
1116 removed from the list of matches.  The filenames `.' and `..' are
1117 always ignored, even when `GLOBIGNORE'.  is set.  However, setting
1118 `GLOBIGNORE' has the effect of enabling the `dotglob' shell option, so
1119 all other filenames beginning with a `.' will match.  To get the old
1120 behavior of ignoring filenames beginning with a `.', make `.*' one of
1121 the patterns in `GLOBIGNORE'.  The `dotglob' option is disabled when
1122 `GLOBIGNORE' is unset.
1123
1124    The special pattern characters have the following meanings:
1125 `*'
1126      Matches any string, including the null string.
1127
1128 `?'
1129      Matches any single character.
1130
1131 `[...]'
1132      Matches any one of the enclosed characters.  A pair of characters
1133      separated by a minus sign denotes a RANGE; any character lexically
1134      between those two characters, inclusive, is matched.  If the first
1135      character following the `[' is a `!'  or a `^' then any character
1136      not enclosed is matched.  A `-' may be matched by including it as
1137      the first or last character in the set.  A `]' may be matched by
1138      including it as the first character in the set.
1139
1140 \1f
1141 File: bashref.info,  Node: Quote Removal,  Prev: Filename Expansion,  Up: Shell Expansions
1142
1143 Quote Removal
1144 -------------
1145
1146    After the preceding expansions, all unquoted occurrences of the
1147 characters `\', `'', and `"' that did not result from one of the above
1148 expansions are removed.
1149
1150 \1f
1151 File: bashref.info,  Node: Redirections,  Next: Executing Commands,  Prev: Shell Expansions,  Up: Basic Shell Features
1152
1153 Redirections
1154 ============
1155
1156    Before a command is executed, its input and output may be REDIRECTED
1157 using a special notation interpreted by the shell.  Redirection may
1158 also be used to open and close files for the current shell execution
1159 environment.  The following redirection operators may precede or appear
1160 anywhere within a simple command or may follow a command.  Redirections
1161 are processed in the order they appear, from left to right.
1162
1163    In the following descriptions, if the file descriptor number is
1164 omitted, and the first character of the redirection operator is `<',
1165 the redirection refers to the standard input (file descriptor 0).  If
1166 the first character of the redirection operator is `>', the redirection
1167 refers to the standard output (file descriptor 1).
1168
1169    The word that follows the redirection operator in the following
1170 descriptions is subjected to brace expansion, tilde expansion,
1171 parameter expansion, command substitution, arithmetic expansion, quote
1172 removal, and filename expansion.  If it expands to more than one word,
1173 Bash reports an error.
1174
1175    Note that the order of redirections is significant.  For example,
1176 the command
1177      ls > DIRLIST 2>&1
1178
1179 directs both standard output and standard error to the file DIRLIST,
1180 while the command
1181      ls 2>&1 > DIRLIST
1182
1183 directs only the standard output to file DIRLIST, because the standard
1184 error was duplicated as standard output before the standard output was
1185 redirected to DIRLIST.
1186
1187 Redirecting Input
1188 -----------------
1189
1190    Redirection of input causes the file whose name results from the
1191 expansion of WORD to be opened for reading on file descriptor `n', or
1192 the standard input (file descriptor 0) if `n' is not specified.
1193
1194    The general format for redirecting input is:
1195      [n]<WORD
1196
1197 Redirecting Output
1198 ------------------
1199
1200    Redirection of output causes the file whose name results from the
1201 expansion of WORD to be opened for writing on file descriptor `n', or
1202 the standard output (file descriptor 1) if `n' is not specified.  If
1203 the file does not exist it is created; if it does exist it is truncated
1204 to zero size.
1205
1206    The general format for redirecting output is:
1207      [n]>[|]WORD
1208
1209    If the redirection operator is `>', and the `-C' option to the `set'
1210 builtin has been enabled, the redirection will fail if the filename
1211 whose name results from the expansion of WORD exists.  If the
1212 redirection operator is `>|', then the value of the `-C' option to the
1213 `set' builtin command is not tested, and the redirection is attempted
1214 even if the file named by WORD exists.
1215
1216 Appending Redirected Output
1217 ---------------------------
1218
1219    Redirection of output in this fashion causes the file whose name
1220 results from the expansion of WORD to be opened for appending on file
1221 descriptor `n', or the standard output (file descriptor 1) if `n' is
1222 not specified.  If the file does not exist it is created.
1223
1224    The general format for appending output is:
1225      [n]>>WORD
1226
1227 Redirecting Standard Output and Standard Error
1228 ----------------------------------------------
1229
1230    Bash allows both the standard output (file descriptor 1) and the
1231 standard error output (file descriptor 2) to be redirected to the file
1232 whose name is the expansion of WORD with this construct.
1233
1234    There are two formats for redirecting standard output and standard
1235 error:
1236      &>WORD
1237
1238 and
1239      >&WORD
1240
1241 Of the two forms, the first is preferred.  This is semantically
1242 equivalent to
1243      >WORD 2>&1
1244
1245 Here Documents
1246 --------------
1247
1248    This type of redirection instructs the shell to read input from the
1249 current source until a line containing only WORD (with no trailing
1250 blanks) is seen.  All of the lines read up to that point are then used
1251 as the standard input for a command.
1252
1253    The format of here-documents is as follows:
1254      <<[-]WORD
1255              HERE-DOCUMENT
1256      DELIMITER
1257
1258    No parameter expansion, command substitution, filename expansion, or
1259 arithmetic expansion is performed on WORD.  If any characters in WORD
1260 are quoted, the DELIMITER is the result of quote removal on WORD, and
1261 the lines in the here-document are not expanded.  Otherwise, all lines
1262 of the here-document are subjected to parameter expansion, command
1263 substitution, and arithmetic expansion.  In the latter case, the pair
1264 `\newline' is ignored, and `\' must be used to quote the characters
1265 `\', `$', and ``'.
1266
1267    If the redirection operator is `<<-', then all leading tab
1268 characters are stripped from input lines and the line containing
1269 DELIMITER.  This allows here-documents within shell scripts to be
1270 indented in a natural fashion.
1271
1272 Duplicating File Descriptors
1273 ----------------------------
1274
1275    The redirection operator
1276      [n]<&WORD
1277
1278 is used to duplicate input file descriptors.  If WORD expands to one or
1279 more digits, the file descriptor denoted by `n' is made to be a copy of
1280 that file descriptor.  If WORD evaluates to `-', file descriptor `n' is
1281 closed.  If `n' is not specified, the standard input (file descriptor
1282 0) is used.
1283
1284    The operator
1285      [n]>&WORD
1286
1287 is used similarly to duplicate output file descriptors.  If `n' is not
1288 specified, the standard output (file descriptor 1) is used.  As a
1289 special case, if `n' is omitted, and WORD does not expand to one or
1290 more digits, the standard output and standard error are redirected as
1291 described previously.
1292
1293 Opening File Descriptors for Reading and Writing
1294 ------------------------------------------------
1295
1296    The redirection operator
1297      [n]<>WORD
1298
1299 causes the file whose name is the expansion of WORD to be opened for
1300 both reading and writing on file descriptor `n', or on file descriptor
1301 0 if `n' is not specified.  If the file does not exist, it is created.
1302
1303 \1f
1304 File: bashref.info,  Node: Executing Commands,  Next: Shell Scripts,  Prev: Redirections,  Up: Basic Shell Features
1305
1306 Executing Commands
1307 ==================
1308
1309 * Menu:
1310
1311 * Command Search and Execution::        How Bash finds commands and runs them.
1312
1313 * Environment::         The environment given to a command.
1314
1315 * Exit Status::         The status returned by commands and how Bash
1316                         interprets it.
1317
1318 * Signals::             What happens when Bash or a command it runs
1319                         receives a signal.
1320
1321 \1f
1322 File: bashref.info,  Node: Command Search and Execution,  Next: Environment,  Up: Executing Commands
1323
1324 Command Search and Execution
1325 ----------------------------
1326
1327    After a command has been split into words, if it results in a simple
1328 command and an optional list of arguments, the following actions are
1329 taken.
1330
1331   1. If the command name contains no slashes, the shell attempts to
1332      locate it.  If there exists a shell function by that name, that
1333      function is invoked as described above in *Note Shell Functions::.
1334
1335   2. If the name does not match a function, the shell searches for it
1336      in the list of shell builtins.  If a match is found, that builtin
1337      is invoked.
1338
1339   3. If the name is neither a shell function nor a builtin, and
1340      contains no slashes, Bash searches each element of `$PATH' for a
1341      directory containing an executable file by that name.  Bash uses a
1342      hash table to remember the full filenames of executable files (see
1343      the description of `hash' in *Note Bourne Shell Builtins::) to
1344      avoid multiple `PATH' searches.  A full search of the directories
1345      in `$PATH' is performed only if the command is not found in the
1346      hash table.  If the search is unsuccessful, the shell prints an
1347      error message and returns a nonzero exit status.
1348
1349   4. If the search is successful, or if the command name contains one
1350      or more slashes, the shell executes the named program.  Argument 0
1351      is set to the name given, and the remaining arguments to the
1352      command are set to the arguments supplied, if any.
1353
1354   5. If this execution fails because the file is not in executable
1355      format, and the file is not a directory, it is assumed to be SHELL
1356      SCRIPT (*note Shell Scripts::.).
1357
1358 \1f
1359 File: bashref.info,  Node: Environment,  Next: Exit Status,  Prev: Command Search and Execution,  Up: Executing Commands
1360
1361 Environment
1362 -----------
1363
1364    When a program is invoked it is given an array of strings called the
1365 ENVIRONMENT.  This is a list of name-value pairs, of the form
1366 `name=value'.
1367
1368    Bash allows you to manipulate the environment in several ways.  On
1369 invocation, the shell scans its own environment and creates a parameter
1370 for each name found, automatically marking it for EXPORT to child
1371 processes.  Executed commands inherit the environment.  The `export'
1372 and `declare -x' commands allow parameters and functions to be added to
1373 and deleted from the environment.  If the value of a parameter in the
1374 environment is modified, the new value becomes part of the environment,
1375 replacing the old.  The environment inherited by any executed command
1376 consists of the shell's initial environment, whose values may be
1377 modified in the shell, less any pairs removed by the `unset' command,
1378 plus any additions via the `export' and `declare -x' commands.
1379
1380    The environment for any simple command or function may be augmented
1381 temporarily by prefixing it with parameter assignments, as described in
1382 *Note Shell Parameters::.  These assignment statements affect only the
1383 environment seen by that command.
1384
1385    If the `-k' flag is set (*note The Set Builtin::., then all
1386 parameter assignments are placed in the environment for a command, not
1387 just those that precede the command name.
1388
1389    When Bash invokes an external command, the variable `$_' is set to
1390 the full path name of the command and passed to that command in its
1391 environment.
1392
1393 \1f
1394 File: bashref.info,  Node: Exit Status,  Next: Signals,  Prev: Environment,  Up: Executing Commands
1395
1396 Exit Status
1397 -----------
1398
1399    For the purposes of the shell, a command which exits with a zero
1400 exit status has succeeded.  A non-zero exit status indicates failure.
1401 This seemingly counter-intuitive scheme is used so there is one
1402 well-defined way to indicate success and a variety of ways to indicate
1403 various failure modes.  When a command terminates on a fatal signal
1404 whose number is N, Bash uses the value 128+N as the exit status.
1405
1406    If a command is not found, the child process created to execute it
1407 returns a status of 127.  If a command is found but is not executable,
1408 the return status is 126.
1409
1410    The exit status is used by the Bash conditional commands (*note
1411 Conditional Constructs::.) and some of the list constructs (*note
1412 Lists::.).
1413
1414    All of the Bash builtins return an exit status of zero if they
1415 succeed and a non-zero status on failure, so they may be used by the
1416 conditional and list constructs.
1417
1418 \1f
1419 File: bashref.info,  Node: Signals,  Prev: Exit Status,  Up: Executing Commands
1420
1421 Signals
1422 -------
1423
1424    When Bash is interactive, it ignores `SIGTERM' (so that `kill 0'
1425 does not kill an interactive shell), and `SIGINT' is caught and handled
1426 (so that the `wait' builtin is interruptible).  When Bash receives a
1427 `SIGINT', it breaks out of any executing loops.  In all cases, Bash
1428 ignores `SIGQUIT'.  If job control is in effect (*note Job Control::.),
1429 Bash ignores `SIGTTIN', `SIGTTOU', and `SIGTSTP'.
1430
1431    Synchronous jobs started by Bash have signals set to the values
1432 inherited by the shell from its parent.  When job control is not in
1433 effect, background jobs (commands terminated with `&') ignore `SIGINT'
1434 and `SIGQUIT'.  Commands run as a result of command substitution ignore
1435 the keyboard-generated job control signals `SIGTTIN', `SIGTTOU', and
1436 `SIGTSTP'.
1437
1438    The shell exits by default upon receipt of a `SIGHUP'.  Before
1439 exiting, it resends the `SIGHUP' to all jobs, running or stopped.  To
1440 prevent the shell from sending the `SIGHUP' signal to a particular job,
1441 remove it from the jobs table with the `disown' builtin (*note Job
1442 Control Builtins::.) or use `disown -h' to mark it to not receive
1443 `SIGHUP'.
1444
1445 \1f
1446 File: bashref.info,  Node: Shell Scripts,  Prev: Executing Commands,  Up: Basic Shell Features
1447
1448 Shell Scripts
1449 =============
1450
1451    A shell script is a text file containing shell commands.  When such
1452 a file is used as the first non-option argument when invoking Bash, and
1453 neither the `-c' nor `-s' option is supplied (*note Invoking Bash::.),
1454 Bash reads and executes commands from the file, then exits.  This mode
1455 of operation creates a non-interactive shell.  When Bash runs a shell
1456 script, it sets the special parameter `0' to the name of the file,
1457 rather than the name of the shell, and the positional parameters are
1458 set to the remaining arguments, if any are given.  If no additional
1459 arguments are supplied, the positional parameters are unset.
1460
1461    A shell script may be made executable by using the `chmod' command
1462 to turn on the execute bit.  When Bash finds such a file while
1463 searching the `$PATH' for a command, it spawns a subshell to execute
1464 it.  In other words, executing
1465      filename ARGUMENTS
1466
1467 is equivalent to executing
1468      bash filename ARGUMENTS
1469
1470 if `filename' is an executable shell script.  This subshell
1471 reinitializes itself, so that the effect is as if a new shell had been
1472 invoked to interpret the script.
1473
1474    Most versions of Unix make this a part of the kernel's command
1475 execution mechanism.  If the first line of a script begins with the two
1476 characters `#!', the remainder of the line specifies an interpreter for
1477 the program.  The arguments to the interpreter consist of a single
1478 optional argument following the interpreter name on the first line of
1479 the script file, followed by the name of the script file, followed by
1480 the rest of the arguments.  Bash will perform this action on operating
1481 systems that do not handle it themselves.  Note that some older
1482 versions of Unix limit the interpreter name and argument to a maximum
1483 of 32 characters.
1484
1485 \1f
1486 File: bashref.info,  Node: Bourne Shell Features,  Next: Csh Features,  Prev: Basic Shell Features,  Up: Top
1487
1488 Bourne Shell Style Features
1489 ***************************
1490
1491 * Menu:
1492
1493 * Bourne Shell Builtins::       Builtin commands inherited from the Bourne
1494                                 Shell.
1495 * Bourne Shell Variables::      Variables which Bash uses in the same way
1496                                 as the Bourne Shell.
1497 * Other Bourne Shell Features:: Addtional aspects of Bash which behave in
1498                                 the same way as the Bourne Shell.
1499
1500    This section briefly summarizes things which Bash inherits from the
1501 Bourne Shell: builtins, variables, and other features.  It also lists
1502 the significant differences between Bash and the Bourne Shell.
1503
1504 \1f
1505 File: bashref.info,  Node: Bourne Shell Builtins,  Next: Bourne Shell Variables,  Up: Bourne Shell Features
1506
1507 Bourne Shell Builtins
1508 =====================
1509
1510    The following shell builtin commands are inherited from the Bourne
1511 Shell.  These commands are implemented as specified by the POSIX 1003.2
1512 standard.
1513
1514 `:'
1515           : [ARGUMENTS]
1516      Do nothing beyond expanding ARGUMENTS and performing redirections.
1517
1518 `.'
1519           . FILENAME
1520      Read and execute commands from the FILENAME argument in the
1521      current shell context.
1522
1523 `break'
1524           break [N]
1525      Exit from a `for', `while', `until', or `select' loop.  If N is
1526      supplied, the Nth enclosing loop is exited.
1527
1528 `cd'
1529           cd [-LP] [DIRECTORY]
1530      Change the current working directory to DIRECTORY.  If DIRECTORY
1531      is not given, the value of the `HOME' shell variable is used.  If
1532      the shell variable `CDPATH' exists, it is used as a search path.
1533      If DIRECTORY begins with a slash, `CDPATH' is not used.  The `-P'
1534      option means to not follow symbolic links; symlinks are followed
1535      by default or with the `-L' option.
1536
1537 `continue'
1538           continue [N]
1539      Resume the next iteration of an enclosing `for', `while', `until',
1540      or `select' loop.  If N is supplied, the execution of the Nth
1541      enclosing loop is resumed.
1542
1543 `eval'
1544           eval [ARGUMENTS]
1545      The arguments are concatenated together into a single command,
1546      which is then read and executed.
1547
1548 `exec'
1549           exec [-cl] [-a NAME] [COMMAND] [ARGUMENTS]
1550      If COMMAND is supplied, it replaces the shell.  If the `-l' option
1551      is supplied, the shell places a dash in the zeroth arg passed to
1552      COMMAND.  This is what the `login' program does.  The `-c' option
1553      causes COMMAND to be executed with an empty environment.  If `-a'
1554      is supplied, the shell passes NAME as the zeroth argument to
1555      COMMAND.  If no COMMAND is specified, redirections may be used to
1556      affect the current shell environment.
1557
1558 `exit'
1559           exit [N]
1560      Exit the shell, returning a status of N to the shell's parent.
1561
1562 `export'
1563           export [-fn] [-p] [NAME[=VALUE]]
1564      Mark each NAME to be passed to child processes in the environment.
1565      If the `-f' option is supplied, the NAMEs refer to shell
1566      functions.  The `-n' option means to no longer mark each NAME for
1567      export.  If no NAMES are supplied, or if the `-p' option is given,
1568      a list of exported names is displayed.
1569
1570 `getopts'
1571           getopts OPTSTRING NAME [ARGS]
1572      `getopts' is used by shell scripts to parse positional parameters.
1573      OPTSTRING contains the option letters to be recognized; if a letter
1574      is followed by a colon, the option is expected to have an
1575      argument, which should be separated from it by white space.  Each
1576      time it is invoked, `getopts' places the next option in the shell
1577      variable NAME, initializing NAME if it does not exist, and the
1578      index of the next argument to be processed into the variable
1579      `OPTIND'.  `OPTIND' is initialized to 1 each time the shell or a
1580      shell script is invoked.  When an option requires an argument,
1581      `getopts' places that argument into the variable `OPTARG'.  The
1582      shell does not reset `OPTIND' automatically; it must be manually
1583      reset between multiple calls to `getopts' within the same shell
1584      invocation if a new set of parameters is to be used.
1585
1586      `getopts' can report errors in two ways.  If the first character of
1587      OPTSTRING is a colon, SILENT error reporting is used.  In normal
1588      operation diagnostic messages are printed when illegal options or
1589      missing option arguments are encountered.  If the variable `OPTERR'
1590      is set to 0, no error message will be displayed, even if the first
1591      character of `optstring' is not a colon.
1592
1593      If an illegal option is seen, `getopts' places `?' into NAME and,
1594      if not silent, prints an error message and unsets `OPTARG'.  If
1595      `getopts' is silent, the option character found is placed in
1596      `OPTARG' and no diagnostic message is printed.
1597
1598      If a required argument is not found, and `getopts' is not silent,
1599      a question mark (`?') is placed in NAME, `OPTARG' is unset, and a
1600      diagnostic message is printed.  If `getopts' is silent, then a
1601      colon (`:') is placed in NAME and `OPTARG' is set to the option
1602      character found.
1603
1604      `getopts' normally parses the positional parameters, but if more
1605      arguments are given in ARGS, `getopts' parses those instead.
1606
1607 `hash'
1608           hash [-r] [-p FILENAME] [NAME]
1609      Remember the full filenames of commands specified as arguments, so
1610      they need not be searched for on subsequent invocations.  The
1611      commands are found by searching through the directories listed in
1612      `$PATH'.  The `-p' option inhibits the path search, and FILENAME
1613      is used as the location of NAME.  The `-r' option causes the shell
1614      to forget all remembered locations.  If no arguments are given,
1615      information about remembered commands is printed.
1616
1617 `pwd'
1618           pwd [-LP]
1619      Print the current working directory.  If the `-P' option is
1620      supplied, the path printed will not contain symbolic links.  If
1621      the `-L' option is supplied, the path printed may contain symbolic
1622      links.
1623
1624 `readonly'
1625           readonly [-apf] [NAME] ...
1626      Mark each NAME as unchangable.  The values of these names may not
1627      be changed by subsequent assignment.  If the `-f' option is
1628      supplied, each NAME refers to a shell function.  The `-a' option
1629      means each NAME refers to an array variable.  If no NAME arguments
1630      are given, or if the `-p' option is supplied, a list of all
1631      readonly names is printed.
1632
1633 `return'
1634           return [N]
1635      Cause a shell function to exit with value N.  This may also be used
1636      to terminate execution of a script being executed with the `.'
1637      builtin.
1638
1639 `shift'
1640           shift [N]
1641      Shift positional parameters to the left by N.  The positional
1642      parameters from N+1 ...  are renamed to `$1' ... .  Parameters
1643      represented by the numbers `$#' to N+1 are unset.  N must be a
1644      non-negative number less than or equal to `$#'.
1645
1646 `test'
1647 `['
1648      Evaluate a conditional expression (*note Bash Conditional
1649      Expressions::.).
1650
1651 `times'
1652           times
1653      Print out the user and system times used by the shell and its
1654      children.
1655
1656 `trap'
1657           trap [-lp] [ARG] [SIGSPEC]
1658      The commands in ARG are to be read and executed when the shell
1659      receives signal SIGSPEC.  If ARG is absent or equal to `-', all
1660      specified signals are reset to the values they had when the shell
1661      was started.  If ARG is the null string, then SIGSPEC is ignored by
1662      the shell and commands it invokes.  If ARG is `-p', the shell
1663      displays the trap commands associated with each SIGSPEC.  If no
1664      arguments are supplied, or only `-p' is given, `trap' prints the
1665      list of commands associated with each signal number.  SIGSPEC is
1666      either a signal name such as `SIGINT' or a signal number.  If
1667      SIGSPEC is `0' or `EXIT', ARG is executed when the shell exits.
1668      If SIGSPEC is `DEBUG', the command ARG is executed after every
1669      simple command.  The `-l' option causes the shell to print a list
1670      of signal names and their corresponding numbers.
1671
1672      Signals ignored upon entry to the shell cannot be trapped or reset.
1673      Trapped signals are reset to their original values in a child
1674      process when it is created.
1675
1676 `umask'
1677           umask [-S] [MODE]
1678      Set the shell process's file creation mask to MODE.  If MODE
1679      begins with a digit, it is interpreted as an octal number; if not,
1680      it is interpreted as a symbolic mode mask similar to that accepted
1681      by the `chmod' command.  If MODE is omitted, the current value of
1682      the mask is printed.  If the `-S' option is supplied without a
1683      MODE argument, the mask is printed in a symbolic format.
1684
1685 `unset'
1686           unset [-fv] [NAME]
1687      Each variable or function NAME is removed.  If no options are
1688      supplied, or the `-v' option is given, each NAME refers to a shell
1689      variable.  If the `-f' option is given, the NAMEs refer to shell
1690      functions, and the function definition is removed.  Read-only
1691      variables and functions may not be unset.
1692
1693 \1f
1694 File: bashref.info,  Node: Bourne Shell Variables,  Next: Other Bourne Shell Features,  Prev: Bourne Shell Builtins,  Up: Bourne Shell Features
1695
1696 Bourne Shell Variables
1697 ======================
1698
1699    Bash uses certain shell variables in the same way as the Bourne
1700 shell.  In some cases, Bash assigns a default value to the variable.
1701
1702 `IFS'
1703      A list of characters that separate fields; used when the shell
1704      splits words as part of expansion.
1705
1706 `PATH'
1707      A colon-separated list of directories in which the shell looks for
1708      commands.
1709
1710 `HOME'
1711      The current user's home directory; the default for the `cd' builtin
1712      command.
1713
1714 `CDPATH'
1715      A colon-separated list of directories used as a search path for
1716      the `cd' command.
1717
1718 `MAILPATH'
1719      A colon-separated list of files which the shell periodically checks
1720      for new mail.    You can also specify what message is printed by
1721      separating the file name from the message with a `?'.  When used
1722      in the text of the message, `$_' stands for the name of the
1723      current mailfile.
1724
1725 `MAIL'
1726      If this parameter is set to a filename and the `MAILPATH' variable
1727      is not set, Bash informs the user of the arrival of mail in the
1728      specified file.
1729
1730 `PS1'
1731      The primary prompt string.  The default value is `\s-\v\$ '.
1732
1733 `PS2'
1734      The secondary prompt string.  The default value is `> '.
1735
1736 `OPTIND'
1737      The index of the last option processed by the `getopts' builtin.
1738
1739 `OPTARG'
1740      The value of the last option argument processed by the `getopts'
1741      builtin.
1742
1743 \1f
1744 File: bashref.info,  Node: Other Bourne Shell Features,  Prev: Bourne Shell Variables,  Up: Bourne Shell Features
1745
1746 Other Bourne Shell Features
1747 ===========================
1748
1749 * Menu:
1750
1751 * Major Differences From The Bourne Shell::     Major differences between
1752                                                 Bash and the Bourne shell.
1753
1754    Bash implements essentially the same grammar, parameter and variable
1755 expansion, redirection, and quoting as the Bourne Shell.  Bash uses the
1756 POSIX 1003.2 standard as the specification of how these features are to
1757 be implemented.  There are some differences between the traditional
1758 Bourne shell and the POSIX standard; this section quickly details the
1759 differences of significance.  A number of these differences are
1760 explained in greater depth in subsequent sections.
1761
1762 \1f
1763 File: bashref.info,  Node: Major Differences From The Bourne Shell,  Up: Other Bourne Shell Features
1764
1765 Major Differences From The SVR4.2 Bourne Shell
1766 ----------------------------------------------
1767
1768    Bash is POSIX-conformant, even where the POSIX specification differs
1769 from traditional `sh' behavior.
1770
1771    Bash has multi-character invocation options (*note Invoking Bash::.).
1772
1773    Bash has command-line editing (*note Command Line Editing::.) and
1774 the `bind' builtin.
1775
1776    Bash has command history (*note Bash History Facilities::.) and the
1777 `history' and `fc' builtins to manipulate it.
1778
1779    Bash implements `csh'-like history expansion (*note History
1780 Interaction::.).
1781
1782    Bash has one-dimensional array variables (*note Arrays::.), and the
1783 appropriate variable expansions and assignment syntax to use them.
1784 Some of the Bash builtins take options to act on arrays.  Bash provides
1785 some built-in array variables.
1786
1787    Bash implements the `!' keyword to negate the return value of a
1788 pipeline (*note Pipelines::.).  Very useful when an `if' statement
1789 needs to act only if a test fails.
1790
1791    Bash includes the `select' compound command, which allows the
1792 generation of simple menus (*note Korn Shell Constructs::.).
1793
1794    Bash includes brace expansion (*note Brace Expansion::.) and tilde
1795 expansion (*note Tilde Expansion::.).
1796
1797    Bash implements command aliases and the `alias' and `unalias'
1798 builtins (*note Aliases::.).
1799
1800    Bash provides shell arithmetic and arithmetic expansion (*note Shell
1801 Arithmetic::.).
1802
1803    The POSIX and `ksh'-style `$()' form of command substitution is
1804 implemented (*note Command Substitution::.), and preferred to the
1805 Bourne shell's ```' (which is also implemented for backwards
1806 compatibility).
1807
1808    Variables present in the shell's initial environment are
1809 automatically exported to child processes.  The Bourne shell does not
1810 normally do this unless the variables are explicitly marked using the
1811 `export' command.
1812
1813    Bash includes the POSIX and `ksh'-style pattern removal `%', `#',
1814 `%%' and `##' constructs to remove leading or trailing substrings from
1815 variable values (*note Shell Parameter Expansion::.).
1816
1817    The expansion `${#xx}', which returns the length of `$xx', is
1818 supported (*note Shell Parameter Expansion::.).
1819
1820    The `$'...'' quoting syntax, which expands ANSI-C backslash-escaped
1821 characters in the text between the single quotes, is supported (*note
1822 ANSI-C Quoting::.).
1823
1824    Bash supports the `$"..."' quoting syntax to do locale-specific
1825 translation of the characters between the double quotes.  The `-D' and
1826 `--dump-strings' invocation options list the translatable strings found
1827 in a script (*note Locale Translation::.).
1828
1829    The expansion `${var:'LENGTH`[:'OFFSET`]}', which expands to the
1830 substring of `var''s value of length LENGTH, optionally beginning at
1831 OFFSET, is present (*note Shell Parameter Expansion::.).
1832
1833    The expansion `${var/[/]'PATTERN`[/'REPLACEMENT`]}', which matches
1834 PATTERN and replaces it with REPLACEMENT in the value of `var', is
1835 available (*note Shell Parameter Expansion::.).
1836
1837    Bash has INDIRECT variable expansion using `${!word}' (*note Shell
1838 Parameter Expansion::.).
1839
1840    Bash can expand positional parameters beyond `$9' using `${NUM}'.
1841
1842    Bash has process substitution (*note Process Substitution::.).
1843
1844    Bash automatically assigns variables that provide information about
1845 the current user (`UID' and `EUID'), the current host (`HOSTTYPE',
1846 `OSTYPE', `MACHTYPE', and `HOSTNAME'), and the instance of Bash that is
1847 running (`BASH', `BASH_VERSION', and `BASH_VERSINFO'.  *Note Bash
1848 Variables::, for details.
1849
1850    The `IFS' variable is used to split only the results of expansion,
1851 not all words (*note Word Splitting::.).  This closes a longstanding
1852 shell security hole.
1853
1854    It is possible to have a variable and a function with the same name;
1855 `sh' does not separate the two name spaces.
1856
1857    Bash functions are permitted to have local variables using the
1858 `local' builtin, and thus useful recursive functions may be written.
1859
1860    Variable assignments preceding commands affect only that command,
1861 even builtins and functions.  In `sh', all variable assignments
1862 preceding commands are global unless the command is executed from the
1863 file system.
1864
1865    Bash performs filename expansion on filenames specified as operands
1866 to output redirection operators.
1867
1868    Bash contains the `<>' redirection operator, allowing a file to be
1869 opened for both reading and writing, and the `&>' redirection operator,
1870 for directing standard output and standard error to the same file
1871 (*note Redirections::.).
1872
1873    The `noclobber' option is available to avoid overwriting existing
1874 files with output redirection (*note The Set Builtin::.).  The `>|'
1875 redirection operator may be used to override `noclobber'.
1876
1877    Bash interprets special backslash-escaped characters in the prompt
1878 strings when interactive (*note Printing a Prompt::.).
1879
1880    Bash allows you to write a function to override a builtin, and
1881 provides access to that builtin's functionality within the function via
1882 the `builtin' and `command' builtins (*note Bash Builtins::.).
1883
1884    The `command' builtin allows selective disabling of functions when
1885 command lookup is performed (*note Bash Builtins::.).
1886
1887    Individual builtins may be enabled or disabled using the `enable'
1888 builtin (*note Bash Builtins::.).
1889
1890    The Bash `hash' builtin allows a name to be associated with an
1891 arbitrary filename, even when that filename cannot be found by
1892 searching the `$PATH', using `hash -p'.
1893
1894    Shell functions may be exported to children via the environment
1895 (*note Shell Functions::.).
1896
1897    Bash includes a `help' builtin for quick reference to shell
1898 facilities (*note Bash Builtins::.).
1899
1900    The Bash `read' builtin (*note Bash Builtins::.) will read a line
1901 ending in `\' with the `-r' option, and will use the `REPLY' variable
1902 as a default if no arguments are supplied.  The Bash `read' builtin
1903 also accepts a prompt string with the `-p' option and will use Readline
1904 to obtain the line when given the `-e' option.
1905
1906    Bash includes the `shopt' builtin, for finer control of shell
1907 optional capabilities (*note Bash Builtins::.).
1908
1909    Bash has much more optional behavior controllable with the `set'
1910 builtin (*note The Set Builtin::.).
1911
1912    The `disown' builtin can remove a job from the internal shell job
1913 table (*note Job Control Builtins::.).
1914
1915    The `return' builtin may be used to abort execution of scripts
1916 executed with the `.' or `source' builtins (*note Bourne Shell
1917 Builtins::.).
1918
1919    The `test' builtin (*note Bourne Shell Builtins::.) is slightly
1920 different, as it implements the POSIX 1003.2 algorithm, which specifies
1921 the behavior based on the number of arguments.
1922
1923    The `trap' builtin (*note Bourne Shell Builtins::.) allows a `DEBUG'
1924 pseudo-signal specification, similar to `EXIT'.  Commands specified
1925 with a `DEBUG' trap are executed after every simple command.  The
1926 `DEBUG' trap is not inherited by shell functions.
1927
1928    The Bash `export', `readonly', and `declare' builtins can take a
1929 `-f' option to act on shell functions, a `-p' option to display
1930 variables with various attributes set in a format that can be used as
1931 shell input, a `-n' option to remove various variable attributes, and
1932 `name=value' arguments to set variable attributes and values
1933 simultaneously.
1934
1935    The Bash `cd' and `pwd' builtins each take `-L' and `-P' builtins to
1936 switch between logical and physical modes.
1937
1938    The Bash `type' builtin is more extensive and gives more information
1939 about the names it finds.
1940
1941    Bash implements a `csh'-like directory stack, and provides the
1942 `pushd', `popd', and `dirs' builtins to manipulate it.  Bash also makes
1943 the directory stack visible as the value of the `DIRSTACK' shell
1944 variable.
1945
1946    The Bash restricted mode is more useful (*note The Restricted
1947 Shell::.); the SVR4.2 shell restricted mode is too limited.
1948
1949    Bash has the `time' reserved word and command timing (*note
1950 Pipelines::.).  The display of the timing statistics may be controlled
1951 with the `TIMEFORMAT' variable.
1952
1953    The SVR4.2 shell has two privilege-related builtins (`mldmode' and
1954 `priv') not present in Bash.
1955
1956    Bash does not have the `stop' or `newgrp' builtins.
1957
1958    Bash does not use the `SHACCT' variable or perform shell accounting.
1959
1960    The SVR4.2 `sh' uses a `TIMEOUT' variable like Bash uses `TMOUT'.
1961
1962    More features unique to Bash may be found in *Note Bash Features::.
1963
1964 Implementation Differences From The SVR4.2 Shell
1965 ------------------------------------------------
1966
1967    Since Bash is a completely new implementation, it does not suffer
1968 from many of the limitations of the SVR4.2 shell.  For instance:
1969
1970    * Bash does not fork a subshell when redirecting into or out of a
1971      shell control structure such as  an `if' or `while' statement.
1972
1973    * Bash does not allow unbalanced quotes.  The SVR4.2 shell will
1974      silently insert a needed closing quote at `EOF' under certain
1975      circumstances.  This can be the cause of some hard-to-find errors.
1976
1977    * The SVR4.2 shell uses a baroque memory management scheme based on
1978      trapping `SIGSEGV'.  If the shell is started from a process with
1979      `SIGSEGV' blocked (e.g., by using the `system()' C library
1980      function call), the shell misbehaves badly.
1981
1982    * In a questionable attempt at security, the SVR4.2 shell will alter
1983      its real and effective UID and GID if they are less than some
1984      threshold value, commonly 100.  This can lead to unexpected
1985      results.
1986
1987    * The SVR4.2 shell does not allow users to trap `SIGALRM' or
1988      `SIGCHLD'.
1989
1990    * For some reason, the SVR4.2 shell does not allow the `MAILCHECK'
1991      variable to be unset.
1992
1993    * The SVR4.2 shell treats `^' as the undocumented equivalent of `|'.
1994
1995    * Bash allows multiple option arguments when it is invoked (`-x -v');
1996      the SVR4.2 shell allows only one option argument (`-xv').  In
1997      fact, some versions of the shell dump core if the second argument
1998      begins with a `-'.
1999
2000    * The SVR4.2 shell exits a script if any builtin fails; Bash exits a
2001      script only if one of the POSIX.2 special builtins fails, and only
2002      for certain failures, as enumerated in the `POSIX.2' standard.
2003
2004    * The SVR4.2 shell behaves differently when invoked as `jsh' (it
2005      turns on job control).
2006
2007 \1f
2008 File: bashref.info,  Node: Csh Features,  Next: Korn Shell Features,  Prev: Bourne Shell Features,  Up: Top
2009
2010 C-Shell Style Features
2011 **********************
2012
2013    The C-Shell ("`csh'") was created by Bill Joy at The University of
2014 California at Berkeley.  It is generally considered to have better
2015 features for interactive use than the original Bourne shell.  Some of
2016 the `csh' features present in Bash include job control, history
2017 expansion, `protected' redirection, and several variables to control
2018 the interactive behaviour of the shell (e.g., `IGNOREEOF').
2019
2020    *Note Using History Interactively::, for details on history
2021 expansion.
2022
2023 * Menu:
2024
2025 * Brace Expansion::             Expansion of expressions within braces.
2026 * Tilde Expansion::             Expansion of the ~ character.
2027 * C Shell Builtins::            Builtin commands adopted from the C Shell.
2028 * C Shell Variables::           Variables which Bash uses in essentially
2029                                 the same way as the C Shell.
2030
2031 \1f
2032 File: bashref.info,  Node: Brace Expansion,  Next: Tilde Expansion,  Up: Csh Features
2033
2034 Brace Expansion
2035 ===============
2036
2037    Brace expansion is a mechanism by which arbitrary strings may be
2038 generated.  This mechanism is similar to FILENAME EXPANSION (*note
2039 Filename Expansion::.), but the file names generated need not exist.
2040 Patterns to be brace expanded take the form of an optional PREAMBLE,
2041 followed by a series of comma-separated strings between a pair of
2042 braces, followed by an optional POSTAMBLE.  The preamble is prepended
2043 to each string contained within the braces, and the postamble is then
2044 appended to each resulting string, expanding left to right.
2045
2046    Brace expansions may be nested.  The results of each expanded string
2047 are not sorted; left to right order is preserved.  For example,
2048      bash$ echo a{d,c,b}e
2049      ade ace abe
2050
2051    Brace expansion is performed before any other expansions, and any
2052 characters special to other expansions are preserved in the result.  It
2053 is strictly textual.  Bash does not apply any syntactic interpretation
2054 to the context of the expansion or the text between the braces.
2055
2056    A correctly-formed brace expansion must contain unquoted opening and
2057 closing braces, and at least one unquoted comma.  Any incorrectly
2058 formed brace expansion is left unchanged.
2059
2060    This construct is typically used as shorthand when the common prefix
2061 of the strings to be generated is longer than in the above example:
2062      mkdir /usr/local/src/bash/{old,new,dist,bugs}
2063    or
2064      chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2065
2066 \1f
2067 File: bashref.info,  Node: Tilde Expansion,  Next: C Shell Builtins,  Prev: Brace Expansion,  Up: Csh Features
2068
2069 Tilde Expansion
2070 ===============
2071
2072    Bash has tilde (~) expansion, similar, but not identical, to that of
2073 `csh'.  The following table shows what unquoted words beginning with a
2074 tilde expand to.
2075
2076 `~'
2077      The current value of `$HOME'.
2078
2079 `~/foo'
2080      `$HOME/foo'
2081
2082 `~fred/foo'
2083      The subdirectory `foo' of the home directory of the user `fred'.
2084
2085 `~+/foo'
2086      `$PWD/foo'
2087
2088 `~-/foo'
2089      `$OLDPWD/foo'
2090
2091    Bash will also tilde expand words following redirection operators
2092 and words following `=' in assignment statements.
2093
2094 \1f
2095 File: bashref.info,  Node: C Shell Builtins,  Next: C Shell Variables,  Prev: Tilde Expansion,  Up: Csh Features
2096
2097 C Shell Builtins
2098 ================
2099
2100    Bash has several builtin commands whose definition is very similar
2101 to `csh'.
2102
2103 `pushd'
2104           pushd [DIR | +N | -N] [-n]
2105
2106      Save the current directory on a list and then `cd' to DIR.  With no
2107      arguments, exchanges the top two directories.
2108
2109     `+N'
2110           Brings the Nth directory (counting from the left of the list
2111           printed by `dirs') to the top of the list by rotating the
2112           stack.
2113
2114     `-N'
2115           Brings the Nth directory (counting from the right of the list
2116           printed by `dirs') to the top of the list by rotating the
2117           stack.
2118
2119     `-n'
2120           Suppresses the normal change of directory when adding
2121           directories to the stack, so that only the stack is
2122           manipulated.
2123
2124     `DIR'
2125           Makes the current working directory be the top of the stack,
2126           and then `cd's to DIR.  You can see the saved directory list
2127           with the `dirs' command.
2128
2129 `popd'
2130           popd [+N | -N] [-n]
2131
2132      Pop the directory stack, and `cd' to the new top directory.  When
2133      no arguments are given, `popd' removes the top directory from the
2134      stack and performs a `cd' to the new top directory.  The elements
2135      are numbered from 0 starting at the first directory listed with
2136      `dirs'; i.e., `popd' is equivalent to `popd +0'.
2137     `+N'
2138           Removes the Nth directory (counting from the left of the list
2139           printed by `dirs'), starting with zero.
2140
2141     `-N'
2142           Removes the Nth directory (counting from the right of the
2143           list printed by `dirs'), starting with zero.
2144
2145     `-n'
2146           Suppresses the normal change of directory when removing
2147           directories from the stack, so that only the stack is
2148           manipulated.
2149
2150 `dirs'
2151           dirs [+N | -N] [-clvp]
2152      Display the list of currently remembered directories.  Directories
2153      find their way onto the list with the `pushd' command; you can get
2154      back up through the list with the `popd' command.
2155     `+N'
2156           Displays the Nth directory (counting from the left of the
2157           list printed by `dirs' when invoked without options), starting
2158           with zero.
2159
2160     `-N'
2161           Displays the Nth directory (counting from the right of the
2162           list printed by `dirs' when invoked without options), starting
2163           with zero.
2164
2165     `-c'
2166           Clears the directory stack by deleting all of the elements.
2167
2168     `-l'
2169           Produces a longer listing; the default listing format uses a
2170           tilde to denote the home directory.
2171
2172     `-p'
2173           Causes `dirs' to print the directory stack with one entry per
2174           line.
2175
2176     `-v'
2177           Causes `dirs' to print the directory stack with one entry per
2178           line, prepending each entry with its index in the stack.
2179
2180 `history'
2181           history [-c] [N]
2182           history [-anrw] [FILENAME]
2183           history -ps ARG
2184
2185      Display the history list with line numbers.  Lines prefixed with
2186      with a `*' have been modified.  An argument of N says to list only
2187      the last N lines.  Options, if supplied, have the following
2188      meanings:
2189
2190     `-w'
2191           Write out the current history to the history file.
2192
2193     `-r'
2194           Read the current history file and append its contents to the
2195           history list.
2196
2197     `-a'
2198           Append the new history lines (history lines entered since the
2199           beginning of the current Bash session) to the history file.
2200
2201     `-n'
2202           Append the history lines not already read from the history
2203           file to the current history list.  These are lines appended
2204           to the history file since the beginning of the current Bash
2205           session.
2206
2207     `-c'
2208           Clear the history list.  This may be combined with the other
2209           options to replace the history list completely.
2210
2211     `-s'
2212           The ARGs are added to the end of the history list as a single
2213           entry.
2214
2215     `-p'
2216           Perform history substitution on the ARGs and display the
2217           result on the standard output, without storing the results in
2218           the history list.
2219
2220      When the `-w', `-r', `-a', or `-n' option is used, if FILENAME is
2221      given, then it is used as the history file.  If not, then the
2222      value of the `HISTFILE' variable is used.
2223
2224 `logout'
2225      Exit a login shell.
2226
2227 `source'
2228      A synonym for `.' (*note Bourne Shell Builtins::.).
2229
2230 \1f
2231 File: bashref.info,  Node: C Shell Variables,  Prev: C Shell Builtins,  Up: Csh Features
2232
2233 C Shell Variables
2234 =================
2235
2236 `IGNOREEOF'
2237      If this variable is set, its value is used the number of
2238      consecutive `EOF's Bash will read before exiting.  By default,
2239      Bash will exit upon reading a single `EOF'.  If `IGNOREEOF' is not
2240      set to a numeric value, Bash acts as if its value were 10.
2241
2242 \1f
2243 File: bashref.info,  Node: Korn Shell Features,  Next: Bash Features,  Prev: Csh Features,  Up: Top
2244
2245 Korn Shell Style Features
2246 *************************
2247
2248    This section describes features primarily inspired by the Korn Shell
2249 (`ksh').  In some cases, the POSIX 1003.2 standard has adopted these
2250 commands and variables from the Korn Shell; Bash implements those
2251 features using the POSIX standard as a guide.
2252
2253 * Menu:
2254
2255 * Korn Shell Constructs::       Shell grammar constructs adopted from the
2256                                 Korn Shell
2257 * Korn Shell Builtins::         Builtin commands adopted from the Korn Shell.
2258 * Korn Shell Variables::        Variables which Bash uses in essentially
2259                                 the same way as the Korn Shell.
2260 * Aliases::                     Substituting one command for another.
2261
2262 \1f
2263 File: bashref.info,  Node: Korn Shell Constructs,  Next: Korn Shell Builtins,  Up: Korn Shell Features
2264
2265 Korn Shell Constructs
2266 =====================
2267
2268    Bash includes the Korn Shell `select' construct.  This construct
2269 allows the easy generation of menus.  It has almost the same syntax as
2270 the `for' command.
2271
2272    The syntax of the `select' command is:
2273      select NAME [in WORDS ...]; do COMMANDS; done
2274
2275    The list of words following `in' is expanded, generating a list of
2276 items.  The set of expanded words is printed on the standard error,
2277 each preceded by a number.  If the `in WORDS' is omitted, the
2278 positional parameters are printed.  The `PS3' prompt is then displayed
2279 and a line is read from the standard input. If the line consists of a
2280 number corresponding to one of the displayed words, then the value of
2281 NAME is set to that word.  If the line is empty, the words and prompt
2282 are displayed again.  If `EOF' is read, the `select' command completes.
2283 Any other value read causes NAME to be set to null.  The line read is
2284 saved in the variable `REPLY'.
2285
2286    The COMMANDS are executed after each selection until a `break' or
2287 `return' command is executed, at which point the `select' command
2288 completes.
2289
2290    Bash also has adopted command timing from the Korn shell.  If the
2291 `time' reserved word precedes a pipeline or simple command, timing
2292 statistics for the pipeline are displayed when it completes.  The
2293 statistics currently consist of elapsed (wall-clock) time and user and
2294 system time consumed by the command's execution.
2295
2296    The use of `time' as a reserved word permits the timing of shell
2297 builtins, shell functions, and pipelines.  An external `time' command
2298 cannot time these easily.
2299
2300 \1f
2301 File: bashref.info,  Node: Korn Shell Builtins,  Next: Korn Shell Variables,  Prev: Korn Shell Constructs,  Up: Korn Shell Features
2302
2303 Korn Shell Builtins
2304 ===================
2305
2306    This section describes Bash builtin commands taken from `ksh'.
2307
2308 `fc'
2309           `fc [-e ENAME] [-nlr] [FIRST] [LAST]'
2310           `fc -s [PAT=REP] [COMMAND]'
2311
2312      Fix Command.  In the first form, a range of commands from FIRST to
2313      LAST is selected from the history list.  Both FIRST and LAST may
2314      be specified as a string (to locate the most recent command
2315      beginning with that string) or as a number (an index into the
2316      history list, where a negative number is used as an offset from the
2317      current command number).  If LAST is not specified it is set to
2318      FIRST.  If FIRST is not specified it is set to the previous
2319      command for editing and -16 for listing.  If the `-l' flag is
2320      given, the commands are listed on standard output.  The `-n' flag
2321      suppresses the command numbers when listing.  The `-r' flag
2322      reverses the order of the listing.  Otherwise, the editor given by
2323      ENAME is invoked on a file containing those commands.  If ENAME is
2324      not given, the value of the following variable expansion is used:
2325      `${FCEDIT:-${EDITOR:-vi}}'.  This says to use the value of the
2326      `FCEDIT' variable if set, or the value of the `EDITOR' variable if
2327      that is set, or `vi' if neither is set.  When editing is complete,
2328      the edited commands are echoed and executed.
2329
2330      In the second form, COMMAND is re-executed after each instance of
2331      PAT in the selected command is replaced by REP.
2332
2333      A useful alias to use with the `fc' command is `r='fc -s'', so
2334      that typing `r cc' runs the last command beginning with `cc' and
2335      typing `r' re-executes the last command (*note Aliases::.).
2336
2337 `let'
2338      The `let' builtin allows arithmetic to be performed on shell
2339      variables.  For details, refer to *Note Arithmetic Builtins::.
2340
2341 `typeset'
2342      The `typeset' command is supplied for compatibility with the Korn
2343      shell; however, it has been deprecated in favor of the `declare'
2344      command (*note Bash Builtins::.).
2345
2346 \1f
2347 File: bashref.info,  Node: Korn Shell Variables,  Next: Aliases,  Prev: Korn Shell Builtins,  Up: Korn Shell Features
2348
2349 Korn Shell Variables
2350 ====================
2351
2352 `REPLY'
2353      The default variable for the `read' builtin.
2354
2355 `RANDOM'
2356      Each time this parameter is referenced, a random integer between 0
2357      and 32767 is generated.  Assigning a value to this variable seeds
2358      the random number generator.
2359
2360 `SECONDS'
2361      This variable expands to the number of seconds since the shell was
2362      started.  Assignment to this variable resets the count to the
2363      value assigned, and the expanded value becomes the value assigned
2364      plus the number of seconds since the assignment.
2365
2366 `PS3'
2367      The value of this variable is used as the prompt for the `select'
2368      command.  If this variable is not set, the `select' command
2369      prompts with `#? '
2370
2371 `PS4'
2372      This is the prompt printed before the command line is echoed when
2373      the `-x' option is set (*note The Set Builtin::.).  The default is
2374      `+ '.
2375
2376 `PWD'
2377      The current working directory as set by the `cd' builtin.
2378
2379 `OLDPWD'
2380      The previous working directory as set by the `cd' builtin.
2381
2382 `TMOUT'
2383      If set to a value greater than zero, the value is interpreted as
2384      the number of seconds to wait for input after issuing the primary
2385      prompt.  Bash terminates after that number of seconds if input does
2386      not arrive.
2387
2388 `LINENO'
2389      The line number in the script or shell function currently
2390      executing.
2391
2392 `ENV'
2393      If this variable is set when Bash is invoked to execute a shell
2394      script, its value is expanded and used as the name of a startup
2395      file to read before executing the script.  *Note Bash Startup
2396      Files::.
2397
2398 `FCEDIT'
2399      The editor used as a default by the `fc' builtin command.
2400
2401 \1f
2402 File: bashref.info,  Node: Aliases,  Prev: Korn Shell Variables,  Up: Korn Shell Features
2403
2404 Aliases
2405 =======
2406
2407 * Menu:
2408
2409 * Alias Builtins::              Builtins commands to maniuplate aliases.
2410
2411    The shell maintains a list of ALIASES that may be set and unset with
2412 the `alias' and `unalias' builtin commands.
2413
2414    The first word of each command, if unquoted, is checked to see if it
2415 has an alias.  If so, that word is replaced by the text of the alias.
2416 The alias name and the replacement text may contain any valid shell
2417 input, including shell metacharacters, with the exception that the
2418 alias name may not contain =.  The first word of the replacement text
2419 is tested for aliases, but a word that is identical to an alias being
2420 expanded is not expanded a second time.  This means that one may alias
2421 `ls' to `"ls -F"', for instance, and Bash does not try to recursively
2422 expand the replacement text. If the last character of the alias value
2423 is a space or tab character, then the next command word following the
2424 alias is also checked for alias expansion.
2425
2426    Aliases are created and listed with the `alias' command, and removed
2427 with the `unalias' command.
2428
2429    There is no mechanism for using arguments in the replacement text,
2430 as in `csh'.  If arguments are needed, a shell function should be used
2431 (*note Shell Functions::.).
2432
2433    Aliases are not expanded when the shell is not interactive, unless
2434 the `expand_aliases' shell option is set using `shopt' (*note Bash
2435 Builtins::.).
2436
2437    The rules concerning the definition and use of aliases are somewhat
2438 confusing.  Bash always reads at least one complete line of input
2439 before executing any of the commands on that line.  Aliases are
2440 expanded when a command is read, not when it is executed.  Therefore, an
2441 alias definition appearing on the same line as another command does not
2442 take effect until the next line of input is read.  The commands
2443 following the alias definition on that line are not affected by the new
2444 alias.  This behavior is also an issue when functions are executed.
2445 Aliases are expanded when the function definition is read, not when the
2446 function is executed, because a function definition is itself a
2447 compound command.  As a consequence, aliases defined in a function are
2448 not available until after that function is executed.  To be safe,
2449 always put alias definitions on a separate line, and do not use `alias'
2450 in compound commands.
2451
2452    Note that for almost every purpose, aliases are superseded by shell
2453 functions.
2454
2455 \1f
2456 File: bashref.info,  Node: Alias Builtins,  Up: Aliases
2457
2458 Alias Builtins
2459 --------------
2460
2461 `alias'
2462           alias [`-p'] [NAME[=VALUE] ...]
2463
2464      Without arguments or with the `-p' option, `alias' prints the list
2465      of aliases on the standard output in a form that allows them to be
2466      reused as input.  If arguments are supplied, an alias is defined
2467      for each NAME whose VALUE is given.  If no VALUE is given, the name
2468      and value of the alias is printed.
2469
2470 `unalias'
2471           unalias [-a] [NAME ... ]
2472
2473      Remove each NAME from the list of aliases.  If `-a' is supplied,
2474      all aliases are removed.
2475
2476 \1f
2477 File: bashref.info,  Node: Bash Features,  Next: Job Control,  Prev: Korn Shell Features,  Up: Top
2478
2479 Bash Features
2480 *************
2481
2482    This section describes features unique to Bash.
2483
2484 * Menu:
2485
2486 * Invoking Bash::               Command line options that you can give
2487                                 to Bash.
2488 * Bash Startup Files::          When and how Bash executes scripts.
2489 * Is This Shell Interactive?::  Determining the state of a running Bash.
2490 * Bash Builtins::               Table of builtins specific to Bash.
2491 * The Set Builtin::             This builtin is so overloaded it
2492                                 deserves its own section.
2493 * Bash Conditional Expressions::        Primitives used in composing expressions for
2494                                 the `test' builtin.
2495 * Bash Variables::              List of variables that exist in Bash.
2496 * Shell Arithmetic::            Arithmetic on shell variables.
2497 * Arrays::                      Array Variables
2498 * Printing a Prompt::           Controlling the PS1 string.
2499 * The Restricted Shell::        A more controlled mode of shell execution.
2500 * Bash POSIX Mode::             Making Bash behave more closely to what
2501                                 the POSIX standard specifies.
2502
2503 \1f
2504 File: bashref.info,  Node: Invoking Bash,  Next: Bash Startup Files,  Up: Bash Features
2505
2506 Invoking Bash
2507 =============
2508
2509      bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
2510      bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o OPTION] -c STRING [ARGUMENT ...]
2511      bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
2512
2513    In addition to the single-character shell command-line options
2514 (*note The Set Builtin::.), there are several multi-character options
2515 that you can use.  These options must appear on the command line before
2516 the single-character options in order for them to be recognized.
2517
2518 `--dump-strings'
2519      Equivalent to `-D'.
2520
2521 `--help'
2522      Display a usage message on standard output and exit sucessfully.
2523
2524 `--login'
2525      Make this shell act as if it were directly invoked by login.  This
2526      is equivalent to `exec -l bash' but can be issued from another
2527      shell, such as `csh'.  If you wanted to replace your current login
2528      shell with a Bash login shell, you would say `exec bash --login'.
2529
2530 `--noediting'
2531      Do not use the GNU Readline library (*note Command Line Editing::.)
2532      to read interactive command lines.
2533
2534 `--noprofile'
2535      Don't load the system-wide startup file `/etc/profile' or any of
2536      the personal initialization files `~/.bash_profile',
2537      `~/.bash_login', or `~/.profile' when Bash is invoked as a login
2538      shell.
2539
2540 `--norc'
2541      Don't read the `~/.bashrc' initialization file in an interactive
2542      shell.  This is on by default if the shell is invoked as `sh'.
2543
2544 `--posix'
2545      Change the behavior of Bash where the default operation differs
2546      from the POSIX 1003.2 standard to match the standard.  This is
2547      intended to make Bash behave as a strict superset of that
2548      standard.  *Note Bash POSIX Mode::, for a description of the Bash
2549      POSIX mode.
2550
2551 `--rcfile FILENAME'
2552      Execute commands from FILENAME (instead of `~/.bashrc') in an
2553      interactive shell.
2554
2555 `--restricted'
2556      Make the shell a restricted shell (*note The Restricted Shell::.).
2557
2558 `--verbose'
2559      Equivalent to `-v'.
2560
2561 `--version'
2562      Show version information for this instance of Bash on the standard
2563      output and exit successfully.
2564
2565    There are several single-character options you can give which are
2566 not available with the `set' builtin.
2567
2568 `-c STRING'
2569      Read and execute commands from STRING after processing the
2570      options, then exit.  Any remaining arguments are assigned to the
2571      positional parameters, starting with `$0'.
2572
2573 `-i'
2574      Force the shell to run interactively.
2575
2576 `-r'
2577      Make the shell restricted.
2578
2579 `-s'
2580      If this flag is present, or if no arguments remain after option
2581      processing, then commands are read from the standard input.  This
2582      option allows the positional parameters to be set when invoking an
2583      interactive shell.
2584
2585 `-D'
2586      A list of all double-quoted strings preceded by `$' is printed on
2587      the standard ouput.  These are the strings that are subject to
2588      language translation when the current locale is not `C' or `POSIX'
2589      (*note Locale Translation::.).  This implies the `-n' option; no
2590      commands will be executed.
2591
2592    An *interactive* shell is one whose input and output are both
2593 connected to terminals (as determined by `isatty()'), or one started
2594 with the `-i' option.
2595
2596    If arguments remain after option processing, and neither the `-c'
2597 nor the `-s' option has been supplied, the first argument is assumed to
2598 be the name of a file containing shell commands (*note Shell
2599 Scripts::.).  When Bash is invoked in this fashion, `$0' is set to the
2600 name of the file, and the positional parameters are set to the
2601 remaining arguments.  Bash reads and executes commands from this file,
2602 then exits.  Bash's exit status is the exit status of the last command
2603 executed in the script.  If no commands are executed, the exit status
2604 is 0.
2605
2606 \1f
2607 File: bashref.info,  Node: Bash Startup Files,  Next: Is This Shell Interactive?,  Prev: Invoking Bash,  Up: Bash Features
2608
2609 Bash Startup Files
2610 ==================
2611
2612    This section describs how bash executes its startup files.  If any
2613 of the files exist but cannot be read, bash reports an error.  Tildes
2614 are expanded in file names as described above under Tilde Expansion
2615 (*note Tilde Expansion::.).
2616
2617    When Bash is invoked as a login shell, it first reads and executes
2618 commands from the file `/etc/profile', if that file exists.  After
2619 reading that file, it looks for `~/.bash_profile', `~/.bash_login', and
2620 `~/.profile', in that order, and reads and executes commands from the
2621 first one that exists and is readable.  The `--noprofile' option may be
2622 used when the shell is started to inhibit this behavior.
2623
2624    When a login shell exits, Bash reads and executes commands from the
2625 file `~/.bash_logout', if it exists.
2626
2627    When an interactive shell that is not a login shell is started, Bash
2628 reads and executes commands from `~/.bashrc', if that file exists.
2629 This may be inhibited by using the `--norc' option.  The `--rcfile
2630 FILE' option will force Bash to read and execute commands from FILE
2631 instead of `~/.bashrc'.
2632
2633    So, typically, your `~/.bash_profile' contains the line
2634      `if [ -f `~/.bashrc' ]; then . `~/.bashrc'; fi'
2635
2636 after (or before) any login-specific initializations.
2637
2638    When Bash is started non-interactively, to run a shell script, for
2639 example, it looks for the variable `BASH_ENV' in the environment,
2640 expands its value if it appears there, and uses the expanded value as
2641 the name of a file to read and execute.  Bash behaves as if the
2642 following command were executed:
2643      `if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi'
2644
2645 but the value of the `PATH' variable is not used to search for the file
2646 name.
2647
2648    If Bash is invoked with the name `sh', it tries to mimic the startup
2649 behavior of historical versions of `sh' as closely as possible, while
2650 conforming to the POSIX standard as well.
2651
2652    When invoked as a login shell, it first attempts to read and execute
2653 commands from `/etc/profile' and `~/.profile', in that order.  The
2654 `--noprofile' option may be used to inhibit this behavior.  When
2655 invoked as an interactive shell with the name `sh', `bash' looks for
2656 the variable `ENV', expands its value if it is defined, and uses the
2657 expanded value as the name of a file to read and execute.  Since a
2658 shell invoked as `sh' does not attempt to read and execute commands
2659 from any other startup files, the `--rcfile' option has no effect.  A
2660 non-interactive shell invoked with the name `sh' does not attempt to
2661 read any startup files.
2662
2663    When invoked as `sh', Bash enters POSIX mode after the startup files
2664 are read.
2665
2666    When Bash is started in POSIX mode, as with the `--posix' command
2667 line option, it follows the POSIX standard for startup files.  In this
2668 mode, the `ENV' variable is expanded and commands are read and executed
2669 from the file whose name is the expanded value.  No other startup files
2670 are read.  This is done by both interactive and non-interactive shells.
2671
2672    Bash attempts to determine when it is being run by the remote shell
2673 daemon, usually `rshd'.  If Bash determines it is being run by rshd, it
2674 reads and executes commands from `~/.bashrc', if that file exists and
2675 is readable.  It will not do this if invoked as `sh'.  The `--norc'
2676 option may be used to inhibit this behavior, and the `--rcfile' option
2677 may be used to force another file to be read, but rshd does not
2678 generally invoke the shell with those options or allow them to be
2679 specified.
2680
2681 \1f
2682 File: bashref.info,  Node: Is This Shell Interactive?,  Next: Bash Builtins,  Prev: Bash Startup Files,  Up: Bash Features
2683
2684 Is This Shell Interactive?
2685 ==========================
2686
2687    As defined in *Note Invoking Bash::, an interactive shell is one
2688 whose input and output are both connected to terminals (as determined
2689 by `isatty(3)'), or one started with the `-i' option.
2690
2691    You may wish to determine within a startup script whether Bash is
2692 running interactively or not.  To do this, examine the variable `$PS1';
2693 it is unset in non-interactive shells, and set in interactive shells.
2694 Thus:
2695
2696      if [ -z "$PS1" ]; then
2697              echo This shell is not interactive
2698      else
2699              echo This shell is interactive
2700      fi
2701
2702 \1f
2703 File: bashref.info,  Node: Bash Builtins,  Next: The Set Builtin,  Prev: Is This Shell Interactive?,  Up: Bash Features
2704
2705 Bash Builtin Commands
2706 =====================
2707
2708    This section describes builtin commands which are unique to or have
2709 been extended in Bash.
2710
2711 `bind'
2712           bind [-m KEYMAP] [-lpsvPSV] [-q NAME] [-r KEYSEQ]
2713           bind [-m KEYMAP] -f FILENAME
2714           bind [-m KEYMAP] KEYSEQ:FUNCTION-NAME
2715
2716      Display current Readline (*note Command Line Editing::.) key and
2717      function bindings, or bind a key sequence to a Readline function
2718      or macro.  The binding syntax accepted is identical to that of
2719      `.inputrc' (*note Readline Init File::.), but each binding must be
2720      passed as a separate argument:  e.g.,
2721      `"\C-x\C-r":re-read-init-file'.  Options, if supplied, have the
2722      following meanings:
2723
2724     `-m KEYMAP'
2725           Use KEYMAP as the keymap to be affected by the subsequent
2726           bindings.  Acceptable KEYMAP names are `emacs',
2727           `emacs-standard', `emacs-meta', `emacs-ctlx', `vi',
2728           `vi-command', and `vi-insert'.  `vi' is equivalent to
2729           `vi-command'; `emacs' is equivalent to `emacs-standard'.
2730
2731     `-l'
2732           List the names of all Readline functions
2733
2734     `-p'
2735           Display Readline function names and bindings in such a way
2736           that they can be re-read
2737
2738     `-P'
2739           List current Readline function names and bindings
2740
2741     `-v'
2742           Display Readline variable names and values in such a way that
2743           they can be re-read
2744
2745     `-V'
2746           List current Readline variable names and values
2747
2748     `-s'
2749           Display Readline key sequences bound to macros and the
2750           strings they output in such a way that they can be re-read
2751
2752     `-S'
2753           Display Readline key sequences bound to macros and the
2754           strings they output
2755
2756     `-f FILENAME'
2757           Read key bindings from FILENAME
2758
2759     `-q'
2760           Query about which keys invoke the named FUNCTION
2761
2762     `-r KEYSEQ'
2763           Remove any current binding for KEYSEQ
2764
2765 `builtin'
2766           builtin [SHELL-BUILTIN [ARGS]]
2767      Run a shell builtin.  This is useful when you wish to rename a
2768      shell builtin to be a function, but need the functionality of the
2769      builtin within the function itself.
2770
2771 `command'
2772           command [-pVv] COMMAND [ARGS ...]
2773      Runs COMMAND with ARG ignoring shell functions.  If you have a
2774      shell function called `ls', and you wish to call the command `ls',
2775      you can say `command ls'.  The `-p' option means to use a default
2776      value for `$PATH' that is guaranteed to find all of the standard
2777      utilities.
2778
2779      If either the `-V' or `-v' option is supplied, a description of
2780      COMMAND is printed.  The `-v' option causes a single word
2781      indicating the command or file name used to invoke COMMAND to be
2782      printed; the `-V' option produces a more verbose description.
2783
2784 `declare'
2785           declare [-afFrxi] [-p] [NAME[=VALUE]]
2786
2787      Declare variables and give them attributes.  If no NAMEs are
2788      given, then display the values of variables instead.
2789
2790      The `-p' option will display the attributes and values of each
2791      NAME.  When `-p' is used, additional options are ignored.  The
2792      `-F' option inhibits the display of function definitions; only the
2793      function name and attributes are printed.  `-F' implies `-f'.  The
2794      following options can be used to restrict output to variables with
2795      the specified attributes or to give variables attributes:
2796
2797     `-a'
2798           Each NAME is an array variable (*note Arrays::.).
2799
2800     `-f'
2801           Use function names only.
2802
2803     `-i'
2804           The variable is to be treated as an integer; arithmetic
2805           evaluation (*note Shell Arithmetic::.) is performed when the
2806           variable is assigned a value.
2807
2808     `-r'
2809           Make NAMEs readonly.  These names cannot then be assigned
2810           values by subsequent assignment statements.
2811
2812     `-x'
2813           Mark each NAME for export to subsequent commands via the
2814           environment.
2815
2816      Using `+' instead of `-' turns off the attribute instead.  When
2817      used in a function, `declare' makes each NAME local, as with the
2818      `local' command.
2819
2820 `echo'
2821           echo [-neE] [arg ...]
2822      Output the `arg's, separated by spaces, terminated with a newline.
2823      The return status is always 0.  If `-n' is specified, the
2824      trailing newline is suppressed.  If the `-e' option is given,
2825      interpretation of the following backslash-escaped characters is
2826      enabled.  The `-E' option disables the interpretation of these
2827      escape characters, even on systems where they are interpreted by
2828      default.  `echo' interprets the following escape sequences:
2829     `\a'
2830           alert (bell)
2831
2832     `\b'
2833           backspace
2834
2835     `\c'
2836           suppress trailing newline
2837
2838     `\e'
2839           escape
2840
2841     `\f'
2842           form feed
2843
2844     `\n'
2845           new line
2846
2847     `\r'
2848           carriage return
2849
2850     `\t'
2851           horizontal tab
2852
2853     `\v'
2854           vertical tab
2855
2856     `\\'
2857           backslash
2858
2859     `\nnn'
2860           the character whose ASCII code is `nnn' (octal)
2861
2862 `enable'
2863           enable [-n] [-p] [-f FILENAME] [-ads] [NAME ...]
2864      Enable and disable builtin shell commands.  This allows you to use
2865      a disk command which has the same name as a shell builtin.  If
2866      `-n' is used, the NAMEs become disabled.  Otherwise NAMEs are
2867      enabled.  For example, to use the `test' binary found via `$PATH'
2868      instead of the shell builtin version, type `enable -n test'.
2869
2870      If the `-p' option is supplied, or no NAME arguments appear, a
2871      list of shell builtins is printed.  With no other arguments, the
2872      list consists of all enabled shell builtins.  The `-a' option
2873      means to list each builtin with an indication of whether or not it
2874      is enabled.
2875
2876      The `-f' option means to load the new builtin command NAME from
2877      shared object FILENAME, on systems that support dynamic loading.
2878      The `-d' option will delete a builtin loaded with `-f'.  If there
2879      are no options, a list of the shell builtins is displayed.  The
2880      `-s' option restricts `enable' to the POSIX.2 special builtins.
2881      If `-s' is used with `-f', the new builtin becomes a special
2882      builtin.
2883
2884 `help'
2885           help [PATTERN]
2886      Display helpful information about builtin commands.  If PATTERN is
2887      specified, `help' gives detailed help on all commands matching
2888      PATTERN, otherwise a list of the builtins is printed.
2889
2890 `local'
2891           local NAME[=VALUE]
2892      For each argument, create a local variable called NAME, and give
2893      it VALUE.  `local' can only be used within a function; it makes
2894      the variable NAME have a visible scope restricted to that function
2895      and its children.
2896
2897 `logout'
2898           logout [N]
2899      Exit a login shell, returning a status of N to the shell's parent.
2900
2901 `read'
2902           read [-a ANAME] [-p PROMPT] [-er] [NAME ...]
2903      One line is read from the standard input, and the first word is
2904      assigned to the first NAME, the second word to the second NAME,
2905      and so on, with leftover words assigned to the last NAME.  Only
2906      the characters in the value of the `IFS' variable are recognized
2907      as word delimiters.  If no names are supplied, the line read is
2908      assigned to the variable `REPLY'.  The return code is zero, unless
2909      end-of-file is encountered.  Options, if supplied, have the
2910      following meanings:
2911
2912     `-r'
2913           If this option is given, a backslash-newline pair is not
2914           ignored, and the backslash is considered to be part of the
2915           line.
2916
2917     `-p PROMPT'
2918           Display `prompt', without a trailing newline, before
2919           attempting to read any input.  The prompt is displayed only
2920           if input is coming from a terminal.
2921
2922     `-a ANAME'
2923           The words are assigned to sequential indices of the array
2924           variable ANAME, starting at 0.
2925
2926     `-e'
2927           Readline (*note Command Line Editing::.) is used to obtain
2928           the line.
2929
2930 `shopt'
2931           shopt [-pqsu] [-o] [OPTNAME ...]
2932      Toggle the values of variables controlling optional shell behavior.
2933      With no options, or with the `-p' option, a list of all settable
2934      options is displayed, with an indication of whether or not each is
2935      set.  Other options have the following meanings:
2936
2937     `-s'
2938           Enable (set) each OPTNAME
2939
2940     `-u'
2941           Disable (unset) each OPTNAME.
2942
2943     `-q'
2944           Suppresses normal output; the return status indicates whether
2945           the OPTNAME is set or unset.  If multiple OPTNAME arguments
2946           are given with `-q', the return status is zero if all
2947           OPTNAMES are enabled; non-zero otherwise.
2948
2949     `-o'
2950           Restricts the values of OPTNAME to be those defined for the
2951           `-o' option to the `set' builtin (*note The Set Builtin::.).
2952
2953      If either of `-s' or `-u' is used with no OPTNAME arguments, the
2954      display is limited to those options which are set or unset,
2955      respectively.
2956
2957      Unless otherwise noted, the `shopt' options are disabled (off) by
2958      default.
2959
2960      The return status when listing options is zero if all OPTNAMES are
2961      enabled, non-zero otherwise.  When setting or unsetting options,
2962      the return status is zero unless an OPTNAME is not a legal shell
2963      option.
2964
2965      The list of `shopt' options is:
2966     `cdable_vars'
2967           If this is set, an argument to the `cd' builtin command that
2968           is not a directory is assumed to be the name of a variable
2969           whose value is the directory to change to.
2970
2971     `cdspell'
2972           If set, minor errors in the spelling of a directory component
2973           in a `cd' command will be corrected.  The errors checked for
2974           are transposed characters, a missing character, and a
2975           character too many.  If a correction is found, the corrected
2976           path is printed, and the command proceeds.  This option is
2977           enabled by default, but is only used by interactive shells.
2978
2979     `checkhash'
2980           If this is set, Bash checks that a command found in the hash
2981           table exists before trying to execute it.  If a hashed
2982           command no longer exists, a normal path search is performed.
2983
2984     `checkwinsize'
2985           If set, Bash checks the window size after each command and,
2986           if necessary, updates the values of `LINES' and `COLUMNS'.
2987
2988     `cmdhist'
2989           If set, Bash attempts to save all lines of a multiple-line
2990           command in the same history entry.  This allows easy
2991           re-editing of multi-line commands.
2992
2993     `dotglob'
2994           If set, Bash includes filenames beginning with a `.' in the
2995           results of filename expansion.
2996
2997     `execfail'
2998           If this is set, a non-interactive shell will not exit if it
2999           cannot execute the file specified as an argument to the `exec'
3000           builtin command.  An interactive shell does not exit if `exec'
3001           fails.
3002
3003     `histappend'
3004           If set, the history list is appended to the file named by the
3005           value of the `HISTFILE' variable when the shell exits, rather
3006           than overwriting the file.
3007
3008     `histreedit'
3009           If set, and Readline is being used, a user is given the
3010           opportunity to re-edit a failed history substitution.
3011
3012     `histverify'
3013           If set, and Readline is being used, the results of history
3014           substitution are not immediately passed to the shell parser.
3015           Instead, the resulting line is loaded into the Readline
3016           editing buffer, allowing further modification.
3017
3018     `hostcomplete'
3019           If set, and Readline is being used, Bash will attempt to
3020           perform hostname completion when a word beginning with `@' is
3021           being completed (*note Commands For Completion::.).
3022
3023     `interactive_comments'
3024           Allow a word beginning with `#' to cause that word and all
3025           remaining characters on that line to be ignored in an
3026           interactive shell.  This option is enabled by default.
3027
3028     `lithist'
3029           If enabled, and the `cmdhist' option is enabled, multi-line
3030           commands are saved to the history with embedded newlines
3031           rather than using semicolon separators where possible.
3032
3033     `mailwarn'
3034           If set, and a file that Bash is checking for mail has been
3035           accessed since the last time it was checked, the message
3036           `"The mail in MAILFILE has been read"' is displayed.
3037
3038     `nullglob'
3039           If set, Bash allows filename patterns which match no files to
3040           expand to a null string, rather than themselves.
3041
3042     `promptvars'
3043           If set, prompt strings undergo variable and parameter
3044           expansion after being expanded (*note Printing a Prompt::.).
3045           This option is enabled by default.
3046
3047     `shift_verbose'
3048           If this is set, the `shift' builtin prints an error message
3049           when the shift count exceeds the number of positional
3050           parameters.
3051
3052     `sourcepath'
3053           If set, the `source' builtin uses the value of `PATH' to find
3054           the directory containing the file supplied as an argument.
3055           This is enabled by default.
3056
3057 `type'
3058           type [-all] [-type | -path] [NAME ...]
3059      For each NAME, indicate how it would be interpreted if used as a
3060      command name.
3061
3062      If the `-type' flag is used, `type' returns a single word which is
3063      one of `alias', `function', `builtin', `file' or `keyword', if
3064      NAME is an alias, shell function, shell builtin, disk file, or
3065      shell reserved word, respectively.  If the NAME is not found, then
3066      nothing is printed, and `type' returns a failure status.
3067
3068      If the `-path' flag is used, `type' either returns the name of the
3069      disk file that would be executed, or nothing if `-type' would not
3070      return `file'.
3071
3072      If the `-all' flag is used, returns all of the places that contain
3073      an executable named FILE.  This includes aliases and functions, if
3074      and only if the `-path' flag is not also used.
3075
3076      `type' accepts `-a', `-t', and `-p' as equivalent to `-all',
3077      `-type', and `-path', respectively.
3078
3079 `ulimit'
3080           ulimit [-acdflmnpstuvSH] [LIMIT]
3081      `ulimit' provides control over the resources available to processes
3082      started by the shell, on systems that allow such control.  If an
3083      option is given, it is interpreted as follows:
3084     `-S'
3085           change and report the soft limit associated with a resource.
3086
3087     `-H'
3088           change and report the hard limit associated with a resource.
3089
3090     `-a'
3091           all current limits are reported.
3092
3093     `-c'
3094           the maximum size of core files created.
3095
3096     `-d'
3097           the maximum size of a process's data segment.
3098
3099     `-f'
3100           the maximum size of files created by the shell.
3101
3102     `-l'
3103           The maximum size that may be locked into memory.
3104
3105     `-m'
3106           the maximum resident set size.
3107
3108     `-n'
3109           the maximum number of open file descriptors.
3110
3111     `-p'
3112           the pipe buffer size.
3113
3114     `-s'
3115           the maximum stack size.
3116
3117     `-t'
3118           the maximum amount of cpu time in seconds.
3119
3120     `-u'
3121           the maximum number of processes available to a single user.
3122
3123     `-v'
3124           the maximum amount of virtual memory available to the process.
3125
3126      If LIMIT is given, it is the new value of the specified resource.
3127      Otherwise, the current value of the soft limit for the specified
3128      resource is printed, unless the `-H' option is supplied.  When
3129      setting new limits, if neither `-H' nor `-S' is supplied, both the
3130      hard and soft limits are set.  If no option is given, then `-f' is
3131      assumed.  Values are in 1024-byte increments, except for `-t',
3132      which is in seconds, `-p', which is in units of 512-byte blocks,
3133      and `-n' and `-u', which are unscaled values.
3134
3135 \1f
3136 File: bashref.info,  Node: The Set Builtin,  Next: Bash Conditional Expressions,  Prev: Bash Builtins,  Up: Bash Features
3137
3138 The Set Builtin
3139 ===============
3140
3141    This builtin is so overloaded that it deserves its own section.
3142
3143 `set'
3144           set [-abefhkmnptuvxdBCHP] [-o OPTION] [ARGUMENT ...]
3145
3146     `-a'
3147           Mark variables which are modified or created for export.
3148
3149     `-b'
3150           Cause the status of terminated background jobs to be reported
3151           immediately, rather than before printing the next primary
3152           prompt.
3153
3154     `-e'
3155           Exit immediately if a simple command exits with a non-zero
3156           status.
3157
3158     `-f'
3159           Disable file name generation (globbing).
3160
3161     `-h'
3162           Locate and remember (hash) commands as they are looked up for
3163           execution.
3164
3165     `-k'
3166           All arguments in the form of assignment statements are placed
3167           in the environment for a command, not just those that precede
3168           the command name.
3169
3170     `-m'
3171           Job control is enabled (*note Job Control::.).
3172
3173     `-n'
3174           Read commands but do not execute them.
3175
3176     `-o OPTION-NAME'
3177           Set the flag corresponding to OPTION-NAME:
3178
3179          `allexport'
3180                same as `-a'.
3181
3182          `braceexpand'
3183                same as `-B'.
3184
3185          `emacs'
3186                use an `emacs'-style line editing interface (*note
3187                Command Line Editing::.).
3188
3189          `errexit'
3190                same as `-e'.
3191
3192          `hashall'
3193                same as `-h'.
3194
3195          `histexpand'
3196                same as `-H'.
3197
3198          `history'
3199                Enable command history, as described in *Note Bash
3200                History Facilities::.  This option is on by default in
3201                interactive shells.
3202
3203          `ignoreeof'
3204                the shell will not exit upon reading EOF.
3205
3206          `keyword'
3207                same as `-k'.
3208
3209          `monitor'
3210                same as `-m'.
3211
3212          `noclobber'
3213                same as `-C'.
3214
3215          `noexec'
3216                same as `-n'.
3217
3218          `noglob'
3219                same as `-f'.
3220
3221          `notify'
3222                same as `-b'.
3223
3224          `nounset'
3225                same as `-u'.
3226
3227          `onecmd'
3228                same as `-t'.
3229
3230          `physical'
3231                same as `-P'.
3232
3233          `posix'
3234                change the behavior of Bash where the default operation
3235                differs from the POSIX 1003.2 standard to match the
3236                standard.  This is intended to make Bash behave as a
3237                strict superset of that standard.
3238
3239          `privileged'
3240                same as `-p'.
3241
3242          `verbose'
3243                same as `-v'.
3244
3245          `vi'
3246                use a `vi'-style line editing interface.
3247
3248          `xtrace'
3249                same as `-x'.
3250
3251     `-p'
3252           Turn on privileged mode.  In this mode, the `$ENV' file is
3253           not processed, and shell functions are not inherited from the
3254           environment.  This is enabled automatically on startup if the
3255           effective user (group) id is not equal to the real user
3256           (group) id.  Turning this option off causes the effective user
3257           and group ids to be set to the real user and group ids.
3258
3259     `-t'
3260           Exit after reading and executing one command.
3261
3262     `-u'
3263           Treat unset variables as an error when substituting.
3264
3265     `-v'
3266           Print shell input lines as they are read.
3267
3268     `-x'
3269           Print commands and their arguments as they are executed.
3270
3271     `-B'
3272           The shell will perform brace expansion (*note Brace
3273           Expansion::.).  This option is on by default.
3274
3275     `-C'
3276           Disallow output redirection to existing files.
3277
3278     `-H'
3279           Enable `!' style history substitution (*note History
3280           Interaction::.).  This flag is on by default for interactive
3281           shells.
3282
3283     `-P'
3284           If set, do not follow symbolic links when performing commands
3285           such as `cd' which change the current directory.  The
3286           physical directory is used instead.  By default, Bash follows
3287           the logical chain of directories when performing commands
3288           which change the current directory.
3289
3290           For example, if `/usr/sys' is a link to `/usr/local/sys' then:
3291                $ cd /usr/sys; echo $PWD
3292                /usr/sys
3293                $ cd ..; pwd
3294                /usr
3295
3296           If `set -P' is on, then:
3297                $ cd /usr/sys; echo $PWD
3298                /usr/local/sys
3299                $ cd ..; pwd
3300                /usr/local
3301
3302     `--'
3303           If no arguments follow this flag, then the positional
3304           parameters are unset.  Otherwise, the positional parameters
3305           are set to the ARGUMENTS, even if some of them begin with a
3306           `-'.
3307
3308     `-'
3309           Signal the end of options, cause all remaining ARGUMENTS to
3310           be assigned to the positional parameters.  The `-x' and `-v'
3311           options are turned off.  If there are no arguments, the
3312           positional parameters remain unchanged.
3313
3314      Using `+' rather than `-' causes these flags to be turned off.
3315      The flags can also be used upon invocation of the shell.  The
3316      current set of flags may be found in `$-'.
3317
3318      The remaining N ARGUMENTS are positional parameters and are
3319      assigned, in order, to `$1', `$2', ...  `$N'.  If no arguments are
3320      given, all shell variables are printed.
3321
3322 \1f
3323 File: bashref.info,  Node: Bash Conditional Expressions,  Next: Bash Variables,  Prev: The Set Builtin,  Up: Bash Features
3324
3325 Bash Conditional Expressions
3326 ============================
3327
3328    Conditional expressions are used by the `test' and `[' builtins.
3329
3330    Expressions may be unary or binary.  Unary expressions are often
3331 used to examine the status of a file.  There are string operators and
3332 numeric comparison operators as well.  Each operator and operand must
3333 be a separate argument.  If FILE is of the form `/dev/fd/N', then file
3334 descriptor N is checked.  Expressions are composed of the following
3335 primaries:
3336
3337 `-b FILE'
3338      True if FILE exists and is a block special file.
3339
3340 `-c FILE'
3341      True if FILE exists and is a character special file.
3342
3343 `-d FILE'
3344      True if FILE exists and is a directory.
3345
3346 `-e FILE'
3347      True if FILE exists.
3348
3349 `-f FILE'
3350      True if FILE exists and is a regular file.
3351
3352 `-g FILE'
3353      True if FILE exists and is set-group-id.
3354
3355 `-k FILE'
3356      True if FILE has its "sticky" bit set.
3357
3358 `-L FILE'
3359      True if FILE exists and is a symbolic link.
3360
3361 `-p FILE'
3362      True if FILE exists and is a named pipe.
3363
3364 `-r FILE'
3365      True if FILE exists and is readable.
3366
3367 `-s FILE'
3368      True if FILE exists and has a size greater than zero.
3369
3370 `-S FILE'
3371      True if FILE exists and is a socket.
3372
3373 `-t FD'
3374      True if FD is opened on a terminal.
3375
3376 `-u FILE'
3377      True if FILE exists and its set-user-id bit is set.
3378
3379 `-w FILE'
3380      True if FILE exists and is writable.
3381
3382 `-x FILE'
3383      True if FILE exists and is executable.
3384
3385 `-O FILE'
3386      True if FILE exists and is owned by the effective user id.
3387
3388 `-G FILE'
3389      True if FILE exists and is owned by the effective group id.
3390
3391 `FILE1 -nt FILE2'
3392      True if FILE1 is newer (according to modification date) than FILE2.
3393
3394 `FILE1 -ot FILE2'
3395      True if FILE1 is older than FILE2.
3396
3397 `FILE1 -ef FILE2'
3398      True if FILE1 and FILE2 have the same device and inode numbers.
3399
3400 `-o OPTNAME'
3401      True if shell option OPTNAME is enabled.  The list of options
3402      appears in the description of the `-o' option to the `set' builtin
3403      (*note The Set Builtin::.).
3404
3405 `-z STRING'
3406      True if the length of STRING is zero.
3407
3408 `-n STRING'
3409 `STRING'
3410      True if the length of STRING is non-zero.
3411
3412 `STRING1 = STRING2'
3413      True if the strings are equal.  `==' may be used in place of `='.
3414
3415 `STRING1 != STRING2'
3416      True if the strings are not equal.
3417
3418 `STRING1 < STRING2'
3419      True if STRING1 sorts before STRING2 lexicographically.
3420
3421 `STRING1 > STRING2'
3422      True if STRING1 sorts after STRING2 lexicographically.
3423
3424 `! EXPR'
3425      True if EXPR is false.
3426
3427 `EXPR1 -a EXPR2'
3428      True if both EXPR1 and EXPR2 are true.
3429
3430 `EXPR1 -o EXPR2'
3431      True if either EXPR1 and EXPR2 is true.
3432
3433 `ARG1 OP ARG2'
3434      `OP' is one of `-eq', `-ne', `-lt', `-le', `-gt', or `-ge'.  These
3435      arithmetic binary operators return true if ARG1 is equal to, not
3436      equal to, less than, less than or equal to, greater than, or
3437      greater than or equal to ARG2, respectively.  ARG1 and ARG2 may be
3438      positive or negative integers.
3439
3440    The Bash `test' and `[' builtins evaluate conditional expressions
3441 using a set of rules based on the number of arguments.  These are the
3442 rules:
3443
3444 0 arguments
3445      The expression is false.
3446
3447 1 argument
3448      The expression is true if and only if the argument is not null.
3449
3450 2 arguments
3451      If the first argument is `!', the expression is true if and only
3452      if the second argument is null.  If the first argument is one of
3453      the listed unary operators, the expression is true if the unary
3454      test is true.  If the first argument is not a legal unary
3455      operator, the expression is false.
3456
3457 3 arguments
3458      If the first argument is `!', the value is the negation of the
3459      two-argument test using the second and third arguments.  If the
3460      second argument is one of the binary operators, the result of the
3461      expression is the result of the binary test using the first and
3462      third arguments as operands.  If the first argument is exactly `('
3463      and the third argument is exactly `)', the result is the
3464      one-argument test of the second argument.  Otherwise, the
3465      expression is false.  The `-a' and `-o' operators are considered
3466      binary operators in this case.
3467
3468 4 arguments
3469      If the first argument is `!', the result is the negation of the
3470      three-argument expression composed of the remaining arguments.
3471      Otherwise, the expression is parsed and evaluated according to
3472      precedence.  `-a' has a higher precedence than `-o'.
3473
3474 5 or more arguments
3475      The expression is parsed and evaluated according to precedence,
3476      with `-a' having a higher precedence than `-o'.
3477
3478 \1f
3479 File: bashref.info,  Node: Bash Variables,  Next: Shell Arithmetic,  Prev: Bash Conditional Expressions,  Up: Bash Features
3480
3481 Bash Variables
3482 ==============
3483
3484    These variables are set or used by Bash, but other shells do not
3485 normally treat them specially.
3486
3487 `TIMEFORMAT'
3488      The value of this parameter is used as a format string specifying
3489      how the timing information for pipelines prefixed with the `time'
3490      reserved word should be displayed.  The `%' character introduces an
3491      escape sequence that is expanded to a time value or other
3492      information.  The escape sequences and their meanings are as
3493      follows; the braces denote optional portions.
3494
3495     `%%'
3496           A literal `%'.
3497
3498     `%[P][l]R'
3499           The elapsed time in seconds.
3500
3501     `%[P][l]U'
3502           The number of CPU seconds spent in user mode.
3503
3504     `%[P][l]S'
3505           The number of CPU seconds spent in system mode.
3506
3507     `%P'
3508           The CPU percentage, computed as (%U + %S) / %R.
3509
3510      The optional P is a digit specifying the precision, the number of
3511      fractional digits after a decimal point.  A value of 0 causes no
3512      decimal point or fraction to be output.  At most three places
3513      after the decimal point may be specified; values of P greater than
3514      3 are changed to 3.  If P is not specified, the value 3 is used.
3515
3516      The optional `l' specifies a longer format, including minutes, of
3517      the form MMmSS.FFs.  The value of P determines whether or not the
3518      fraction is included.
3519
3520      If this variable is not set, bash acts as if it had the value
3521      `$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS''.  If the value is null,
3522      no timing information is displayed.  A trailing newline is added
3523      when the format string is displayed.
3524
3525 `HISTCONTROL'
3526      Set to a value of `ignorespace', it means don't enter lines which
3527      begin with a space or tab into the history list.  Set to a value
3528      of `ignoredups', it means don't enter lines which match the last
3529      entered line.  A value of `ignoreboth' combines the two options.
3530      Unset, or set to any other value than those above, means to save
3531      all lines on the history list.
3532
3533 `HISTIGNORE'
3534      A colon-separated list of patterns used to decide which command
3535      lines should be saved on the history list.  Each pattern is
3536      anchored at the beginning of the line and must fully specify the
3537      line (no implicit `*' is appended).  Each pattern is tested
3538      against the line after the checks specified by `HISTCONTROL' are
3539      applied.  In addition to the normal shell pattern matching
3540      characters, `&' matches the previous history line.  `&' may be
3541      escaped using a backslash.  The backslash is removed before
3542      attempting a match.
3543
3544      `HISTIGNORE' subsumes the function of `HISTCONTROL'.  A pattern of
3545      `&' is identical to `ignoredups', and a pattern of `[ ]*' is
3546      identical to `ignorespace'.  Combining these two patterns,
3547      separating them with a colon, provides the functionality of
3548      `ignoreboth'.
3549
3550 `HISTFILE'
3551      The name of the file to which the command history is saved.  The
3552      default is `~/.bash_history'.
3553
3554 `HISTSIZE'
3555      If set, this is the maximum number of commands to remember in the
3556      history.
3557
3558 `HISTFILESIZE'
3559      The maximum number of lines contained in the history file.  When
3560      this variable is assigned a value, the history file is truncated,
3561      if necessary, to contain no more than that number of lines.  The
3562      default value is 500.  The history file is also truncated to this
3563      size after writing it when an interactive shell exits.
3564
3565 `histchars'
3566      Up to three characters which control history expansion, quick
3567      substitution, and tokenization (*note History Interaction::.).
3568      The first character is the "history-expansion-char", that is, the
3569      character which signifies the start of a history expansion,
3570      normally `!'.  The second character is the character which
3571      signifies `quick substitution' when seen as the first character on
3572      a line, normally `^'.  The optional third character is the
3573      character which signifies the remainder of the line is a comment,
3574      when found as the first character of a word, usually `#'.  The
3575      history comment character causes history substitution to be
3576      skipped for the remaining words on the line.  It does not
3577      necessarily cause the shell parser to treat the rest of the line
3578      as a comment.
3579
3580 `HISTCMD'
3581      The history number, or index in the history list, of the current
3582      command.  If `HISTCMD' is unset, it loses its special properties,
3583      even if it is subsequently reset.
3584
3585 `HOSTFILE'
3586      Contains the name of a file in the same format as `/etc/hosts' that
3587      should be read when the shell needs to complete a hostname.  You
3588      can change the file interactively; the next time you attempt to
3589      complete a hostname, Bash will add the contents of the new file to
3590      the already existing database.
3591
3592 `MAILCHECK'
3593      How often (in seconds) that the shell should check for mail in the
3594      files specified in `MAILPATH'.
3595
3596 `PROMPT_COMMAND'
3597      If present, this contains a string which is a command to execute
3598      before the printing of each primary prompt (`$PS1').
3599
3600 `UID'
3601      The numeric real user id of the current user.
3602
3603 `EUID'
3604      The numeric effective user id of the current user.
3605
3606 `PPID'
3607      The process id of the shell's parent process.
3608
3609 `HOSTNAME'
3610      The name of the current host.
3611
3612 `HOSTTYPE'
3613      A string describing the machine Bash is running on.
3614
3615 `OSTYPE'
3616      A string describing the operating system Bash is running on.
3617
3618 `MACHTYPE'
3619      A string that fully describes the system type on which Bash is
3620      executing, in the standard GNU CPU-COMPANY-SYSTEM format.
3621
3622 `SHELLOPTS'
3623      A colon-separated list of enabled shell options.  Each word in the
3624      list is a valid argument for the `-o' option to the `set' builtin
3625      command (*note The Set Builtin::.).  The options appearing in
3626      `SHELLOPTS' are those reported as `on' by `set -o'.  If this
3627      variable is in the environment when Bash starts up, each shell
3628      option in the list will be enabled before reading any startup
3629      files.  This variable is readonly.
3630
3631 `FIGNORE'
3632      A colon-separated list of suffixes to ignore when performing
3633      filename completion.  A file name whose suffix matches one of the
3634      entries in `FIGNORE' is excluded from the list of matched file
3635      names.  A sample value is `.o:~'
3636
3637 `GLOBIGNORE'
3638      A colon-separated list of patterns defining the set of filenames to
3639      be ignored by filename expansion.  If a filename matched by a
3640      filename expansion pattern also matches one of the patterns in
3641      `GLOBIGNORE', it is removed from the list of matches.
3642
3643 `DIRSTACK'
3644      An array variable (*note Arrays::.) containing the current
3645      contents of the directory stack.  Directories appear in the stack
3646      in the order they are displayed by the `dirs' builtin.  Assigning
3647      to members of this array variable may be used to modify
3648      directories already in the stack, but the `pushd' and `popd'
3649      builtins must be used to add and remove directories.  Assignment
3650      to this variable will not change the current directory.  If
3651      `DIRSTACK' is unset, it loses its special properties, even if it
3652      is subsequently reset.
3653
3654 `PIPESTATUS'
3655      An array variable (*note Arrays::.) containing a list of exit
3656      status values from the processes in the most-recently-executed
3657      foreground pipeline (which may contain only a single command).
3658
3659 `INPUTRC'
3660      The name of the Readline startup file, overriding the default of
3661      `~/.inputrc'.
3662
3663 `BASH'
3664      The full filename used to execute the current instance of Bash.
3665
3666 `BASH_VERSION'
3667      The version number of the current instance of Bash.
3668
3669 `BASH_VERSINFO'
3670      An array variable whose members hold version information for this
3671      instance of Bash.  The values assigned to the array members are as
3672      follows:
3673
3674     `BASH_VERSINFO[0]'
3675           The major version number (the RELEASE).
3676
3677     `BASH_VERSINFO[1]'
3678           The minor version number (the VERSION).
3679
3680     `BASH_VERSINFO[2]'
3681           The patch level.
3682
3683     `BASH_VERSINFO[3]'
3684           The build version.
3685
3686     `BASH_VERSINFO[4]'
3687           The release status (e.g., BETA1).
3688
3689     `BASH_VERSINFO[5]'
3690           The value of `MACHTYPE'.
3691
3692 `SHLVL'
3693      Incremented by one each time a new instance of Bash is started.
3694      This is intended to be an account of how deeply your Bash shells
3695      are nested.
3696
3697 `OPTERR'
3698      If set to the value 1, Bash displays error messages generated by
3699      the `getopts' builtin command.
3700
3701 `LANG'
3702      Used to determine the locale category for any category not
3703      specifically selected with a variable starting with `LC_'.
3704
3705 `LC_ALL'
3706      This variable overrides the value of `LANG' and any other `LC_'
3707      variable specifying a locale category.
3708
3709 `LC_MESSAGES'
3710      This variable determines the locale used to translate double-quoted
3711      strings preceded by a `$'.
3712
3713 `IGNOREEOF'
3714      Controls the action of the shell on receipt of an `EOF' character
3715      as the sole input.  If set, then the value of it is the number of
3716      consecutive `EOF' characters that can be read as the first
3717      character on an input line before the shell will exit.  If the
3718      variable exists but does not have a numeric value (or has no
3719      value) then the default is 10.  If the variable does not exist,
3720      then `EOF' signifies the end of input to the shell.  This is only
3721      in effect for interactive shells.
3722
3723 \1f
3724 File: bashref.info,  Node: Shell Arithmetic,  Next: Arrays,  Prev: Bash Variables,  Up: Bash Features
3725
3726 Shell Arithmetic
3727 ================
3728
3729 * Menu:
3730
3731 * Arithmetic Evaluation::       How shell arithmetic works.
3732 * Arithmetic Expansion::        How to use arithmetic in shell expansions.
3733 * Arithmetic Builtins::         Builtin commands that use shell arithmetic.
3734
3735    Bash includes several mechanisms to evaluate arithmetic expressions
3736 and display the result or use it as part of a command.
3737
3738 \1f
3739 File: bashref.info,  Node: Arithmetic Evaluation,  Next: Arithmetic Expansion,  Up: Shell Arithmetic
3740
3741 Arithmetic Evaluation
3742 ---------------------
3743
3744    The shell allows arithmetic expressions to be evaluated, as one of
3745 the shell expansions or by the `let' builtin.
3746
3747    Evaluation is done in long integers with no check for overflow,
3748 though division by 0 is trapped and flagged as an error.  The following
3749 list of operators is grouped into levels of equal-precedence operators.
3750 The levels are listed in order of decreasing precedence.
3751
3752 `- +'
3753      unary minus and plus
3754
3755 `! ~'
3756      logical and bitwise negation
3757
3758 `* / %'
3759      multiplication, division, remainder
3760
3761 `+ -'
3762      addition, subtraction
3763
3764 `<< >>'
3765      left and right bitwise shifts
3766
3767 `<= >= < >'
3768      comparison
3769
3770 `== !='
3771      equality and inequality
3772
3773 `&'
3774      bitwise AND
3775
3776 `^'
3777      bitwise exclusive OR
3778
3779 `|'
3780      bitwise OR
3781
3782 `&&'
3783      logical AND
3784
3785 `||'
3786      logical OR
3787
3788 `expr ? expr : expr'
3789      conditional evaluation
3790
3791 `= *= /= %= += -= <<= >>= &= ^= |='
3792      assignment
3793
3794    Shell variables are allowed as operands; parameter expansion is
3795 performed before the expression is evaluated.  The value of a parameter
3796 is coerced to a long integer within an expression.  A shell variable
3797 need not have its integer attribute turned on to be used in an
3798 expression.
3799
3800    Constants with a leading 0 are interpreted as octal numbers.  A
3801 leading `0x' or `0X' denotes hexadecimal.  Otherwise, numbers take the
3802 form [BASE`#']N, where BASE is a decimal number between 2 and 64
3803 representing the arithmetic base, and N is a number in that base.  If
3804 BASE is omitted, then base 10 is used.  The digits greater than 9 are
3805 represented by the lowercase letters, the uppercase letters, `_', and
3806 `@', in that order.  If BASE is less than or equal to 36, lowercase and
3807 uppercase letters may be used interchangably to represent numbers
3808 between 10 and 35.
3809
3810    Operators are evaluated in order of precedence.  Sub-expressions in
3811 parentheses are evaluated first and may override the precedence rules
3812 above.
3813
3814 \1f
3815 File: bashref.info,  Node: Arithmetic Expansion,  Next: Arithmetic Builtins,  Prev: Arithmetic Evaluation,  Up: Shell Arithmetic
3816
3817 Arithmetic Expansion
3818 --------------------
3819
3820    Arithmetic expansion allows the evaluation of an arithmetic
3821 expression and the substitution of the result.  The format for
3822 arithmetic expansion is:
3823
3824      $(( EXPRESSION ))
3825
3826    The expression is treated as if it were within double quotes, but a
3827 double quote inside the braces or parentheses is not treated specially.
3828 All tokens in the expression undergo parameter expansion, command
3829 substitution, and quote removal.  Arithmetic substitutions may be
3830 nested.
3831
3832    The evaluation is performed according to the rules listed above.  If
3833 the expression is invalid, Bash prints a message indicating failure and
3834 no substitution occurs.
3835
3836 \1f
3837 File: bashref.info,  Node: Arithmetic Builtins,  Prev: Arithmetic Expansion,  Up: Shell Arithmetic
3838
3839 Arithmetic Builtins
3840 -------------------
3841
3842 `let'
3843           let EXPRESSION [EXPRESSION]
3844      The `let' builtin allows arithmetic to be performed on shell
3845      variables.  Each EXPRESSION is evaluated according to the rules
3846      given previously (*note Arithmetic Evaluation::.).  If the last
3847      EXPRESSION evaluates to 0, `let' returns 1; otherwise 0 is
3848      returned.
3849
3850 \1f
3851 File: bashref.info,  Node: Arrays,  Next: Printing a Prompt,  Prev: Shell Arithmetic,  Up: Bash Features
3852
3853 Arrays
3854 ======
3855
3856    Bash provides one-dimensional array variables.  Any variable may be
3857 used as an array; the `declare' builtin will explicitly declare an
3858 array.  There is no maximum limit on the size of an array, nor any
3859 requirement that members be indexed or assigned contiguously.  Arrays
3860 are zero-based.
3861
3862    An array is created automatically if any variable is assigned to
3863 using the syntax
3864      name[SUBSCRIPT]=VALUE
3865
3866 The SUBSCRIPT is treated as an arithmetic expression that must evaluate
3867 to a number greater than or equal to zero.  To explicitly declare an
3868 array, use
3869      declare -a NAME
3870
3871 The syntax
3872      declare -a NAME[SUBSCRIPT]
3873
3874 is also accepted; the SUBSCRIPT is ignored.  Attributes may be
3875 specified for an array variable using the `declare' and `readonly'
3876 builtins.  Each attribute applies to all members of an array.
3877
3878    Arrays are assigned to using compound assignments of the form
3879      name=(value1 ... valueN)
3880
3881 where each VALUE is of the form `[[SUBSCRIPT]=]'STRING.  If the
3882 optional subscript is supplied, that index is assigned to; otherwise
3883 the index of the element assigned is the last index assigned to by the
3884 statement plus one.  Indexing starts at zero.  This syntax is also
3885 accepted by the `declare' builtin.  Individual array elements may be
3886 assigned to using the `name['SUBSCRIPT`]='VALUE syntax introduced above.
3887
3888    Any element of an array may be referenced using
3889 `${name['SUBSCRIPT`]}'.  The braces are required to avoid conflicts
3890 with the shell's filename expansion operators.  If the SUBSCRIPT is `@'
3891 or `*', the word expands to all members of the array NAME.  These
3892 subscripts differ only when the word appears within double quotes.  If
3893 the word is double-quoted, `${name[*]}' expands to a single word with
3894 the value of each array member separated by the first character of the
3895 `IFS' variable, and `${name[@]}' expands each element of NAME to a
3896 separate word.  When there are no array members, `${name[@]}' expands
3897 to nothing.  This is analogous to the expansion of the special
3898 parameters `@' and `*'.  `${#name['SUBSCRIPT`]}' expands to the length
3899 of `${name['SUBSCRIPT`]}'.  If SUBSCRIPT is `@' or `*', the expansion
3900 is the number of elements in the array.  Referencing an array variable
3901 without a subscript is equivalent to referencing element zero.
3902
3903    The `unset' builtin is used to destroy arrays.  `unset'
3904 NAME[SUBSCRIPT] destroys the array element at index SUBSCRIPT.  `unset'
3905 NAME, where NAME is an array, removes the entire array. A subscript of
3906 `*' or `@' also removes the entire array.
3907
3908    The `declare', `local', and `readonly' builtins each accept a `-a'
3909 option to specify an array.  The `read' builtin accepts a `-a' option
3910 to assign a list of words read from the standard input to an array, and
3911 can read values from the standard input into individual array elements.
3912 The `set' and `declare' builtins display array values in a way that
3913 allows them to be reused as input.
3914
3915 \1f
3916 File: bashref.info,  Node: Printing a Prompt,  Next: The Restricted Shell,  Prev: Arrays,  Up: Bash Features
3917
3918 Controlling the Prompt
3919 ======================
3920
3921    The value of the variable `PROMPT_COMMAND' is examined just before
3922 Bash prints each primary prompt.  If it is set and non-null, then the
3923 value is executed just as if you had typed it on the command line.
3924
3925    In addition, the following table describes the special characters
3926 which can appear in the prompt variables:
3927
3928 `\a'
3929      a bell character.
3930
3931 `\d'
3932      the date, in "Weekday Month Date" format (e.g., "Tue May 26").
3933
3934 `\e'
3935      an escape character.
3936
3937 `\h'
3938      the hostname, up to the first `.'.
3939
3940 `\H'
3941      the hostname.
3942
3943 `\n'
3944      newline.
3945
3946 `\s'
3947      the name of the shell, the basename of `$0' (the portion following
3948      the final slash).
3949
3950 `\t'
3951      the time, in 24-hour HH:MM:SS format.
3952
3953 `\T'
3954      the time, in 12-hour HH:MM:SS format.
3955
3956 `\@'
3957      the time, in 12-hour am/pm format.
3958
3959 `\v'
3960      the version of Bash (e.g., 2.00)
3961
3962 `\V'
3963      the release of Bash, version + patchlevel (e.g., 2.00.0)
3964
3965 `\w'
3966      the current working directory.
3967
3968 `\W'
3969      the basename of `$PWD'.
3970
3971 `\u'
3972      your username.
3973
3974 `\!'
3975      the history number of this command.
3976
3977 `\#'
3978      the command number of this command.
3979
3980 `\$'
3981      if the effective uid is 0, `#', otherwise `$'.
3982
3983 `\nnn'
3984      the character corresponding to the octal number `nnn'.
3985
3986 `\\'
3987      a backslash.
3988
3989 `\['
3990      begin a sequence of non-printing characters.  This could be used to
3991      embed a terminal control sequence into the prompt.
3992
3993 `\]'
3994      end a sequence of non-printing characters.
3995
3996 \1f
3997 File: bashref.info,  Node: The Restricted Shell,  Next: Bash POSIX Mode,  Prev: Printing a Prompt,  Up: Bash Features
3998
3999 The Restricted Shell
4000 ====================
4001
4002    If Bash is started with the name `rbash', or the `--restricted'
4003 option is supplied at invocation, the shell becomes restricted.  A
4004 restricted shell is used to set up an environment more controlled than
4005 the standard shell.  A restricted shell behaves identically to `bash'
4006 with the exception that the following are disallowed:
4007    * Changing directories with the `cd' builtin.
4008
4009    * Setting or unsetting the values of the `SHELL' or `PATH' variables.
4010
4011    * Specifying command names containing slashes.
4012
4013    * Specifying a filename containing a slash as an argument to the `.'
4014      builtin command.
4015
4016    * Importing function definitions from the shell environment at
4017      startup.
4018
4019    * Redirecting output using the `>', `>|', `<>', `>&', `&>', and `>>'
4020      redirection operators.
4021
4022    * Using the `exec' builtin to replace the shell with another command.
4023
4024    * Adding or deleting builtin commands with the `-f' and `-d' options
4025      to the `enable' builtin.
4026
4027    * Specifying the `-p' option to the `command' builtin.
4028
4029    * Turning off restricted mode with `set +r'.
4030
4031 \1f
4032 File: bashref.info,  Node: Bash POSIX Mode,  Prev: The Restricted Shell,  Up: Bash Features
4033
4034 Bash POSIX Mode
4035 ===============
4036
4037    Starting Bash with the `--posix' command-line option or executing
4038 `set -o posix' while Bash is running will cause Bash to conform more
4039 closely to the POSIX.2 standard by changing the behavior to match that
4040 specified by POSIX.2 in areas where the Bash default differs.
4041
4042    The following list is what's changed when `POSIX mode' is in effect:
4043
4044   1. When a command in the hash table no longer exists, Bash will
4045      re-search `$PATH' to find the new location.  This is also
4046      available with `shopt -s checkhash'.
4047
4048   2. The `>&' redirection does not redirect stdout and stderr.
4049
4050   3. The message printed by the job control code and builtins when a job
4051      exits with a non-zero status is `Done(status)'.
4052
4053   4. Reserved words may not be aliased.
4054
4055   5. The POSIX.2 `PS1' and `PS2' expansions of `!' to the history
4056      number and `!!' to `!' are enabled, and parameter expansion is
4057      performed on the value regardless of the setting of the
4058      `promptvars' option.
4059
4060   6. Interactive comments are enabled by default.  (Note that Bash has
4061      them on by default anyway.)
4062
4063   7. The POSIX.2 startup files are executed (`$ENV') rather than the
4064      normal Bash files.
4065
4066   8. Tilde expansion is only performed on assignments preceding a
4067      command name, rather than on all assignment statements on the line.
4068
4069   9. The default history file is `~/.sh_history' (this is the default
4070      value of `$HISTFILE').
4071
4072  10. The output of `kill -l' prints all the signal names on a single
4073      line, separated by spaces.
4074
4075  11. Non-interactive shells exit if FILENAME in `.' FILENAME is not
4076      found.
4077
4078  12. Redirection operators do not perform filename expansion on the word
4079      in the redirection unless the shell is interactive.
4080
4081  13. Function names must be valid shell `name's.  That is, they may not
4082      contain characters other than letters, digits, and underscores, and
4083      may not start with a digit.  Declaring a function with an illegal
4084      name causes a fatal syntax error in non-interactive shells.
4085
4086  14. POSIX.2 `special' builtins are found before shell functions during
4087      command lookup.
4088
4089  15. If a POSIX.2 special builtin returns an error status, a
4090      non-interactive shell exits.  The fatal errors are those listed in
4091      the POSIX.2 standard, and include things like passing incorrect
4092      options, redirection errors, variable assignment errors for
4093      assignments preceding the command name, and so on.
4094
4095  16. If the `cd' builtin finds a directory to change to using
4096      `$CDPATH', the value it assigns to the `PWD' variable does not
4097      contain any symbolic links, as if `cd -P' had been executed.
4098
4099  17. A non-interactive shell exits with an error status if a variable
4100      assignment error occurs when no command name follows the assignment
4101      statements.  A variable assignment error occurs, for example, when
4102      trying to assign a value to a read-only variable.
4103
4104  18. A non-interactive shell exits with an error status if the iteration
4105      variable in a `for' statement or the selection variable in a
4106      `select' statement is a read-only variable.
4107
4108  19. Process substitution is not available.
4109
4110  20. Assignment statements preceding POSIX.2 `special' builtins persist
4111      in the shell environment after the builtin completes.
4112
4113
4114    There is other POSIX.2 behavior that Bash does not implement.
4115 Specifically:
4116
4117   1. Assignment statements affect the execution environment of all
4118      builtins, not just special ones.
4119
4120 \1f
4121 File: bashref.info,  Node: Job Control,  Next: Using History Interactively,  Prev: Bash Features,  Up: Top
4122
4123 Job Control
4124 ***********
4125
4126    This chapter disusses what job control is, how it works, and how
4127 Bash allows you to access its facilities.
4128
4129 * Menu:
4130
4131 * Job Control Basics::          How job control works.
4132 * Job Control Builtins::        Bash builtin commands used to interact
4133                                 with job control.
4134 * Job Control Variables::       Variables Bash uses to customize job
4135                                 control.
4136
4137 \1f
4138 File: bashref.info,  Node: Job Control Basics,  Next: Job Control Builtins,  Up: Job Control
4139
4140 Job Control Basics
4141 ==================
4142
4143    Job control refers to the ability to selectively stop (suspend) the
4144 execution of processes and continue (resume) their execution at a later
4145 point.  A user typically employs this facility via an interactive
4146 interface supplied jointly by the system's terminal driver and Bash.
4147
4148    The shell associates a JOB with each pipeline.  It keeps a table of
4149 currently executing jobs, which may be listed with the `jobs' command.
4150 When Bash starts a job asynchronously (in the background), it prints a
4151 line that looks like:
4152      [1] 25647
4153
4154 indicating that this job is job number 1 and that the process ID of the
4155 last process in the pipeline associated with this job is 25647.  All of
4156 the processes in a single pipeline are members of the same job.  Bash
4157 uses the JOB abstraction as the basis for job control.
4158
4159    To facilitate the implementation of the user interface to job
4160 control, the system maintains the notion of a current terminal process
4161 group ID.  Members of this process group (processes whose process group
4162 ID is equal to the current terminal process group ID) receive
4163 keyboard-generated signals such as `SIGINT'.  These processes are said
4164 to be in the foreground.  Background processes are those whose process
4165 group ID differs from the terminal's; such processes are immune to
4166 keyboard-generated signals.  Only foreground processes are allowed to
4167 read from or write to the terminal.  Background processes which attempt
4168 to read from (write to) the terminal are sent a `SIGTTIN' (`SIGTTOU')
4169 signal by the terminal driver, which, unless caught, suspends the
4170 process.
4171
4172    If the operating system on which Bash is running supports job
4173 control, Bash allows you to use it.  Typing the SUSPEND character
4174 (typically `^Z', Control-Z) while a process is running causes that
4175 process to be stopped and returns you to Bash.  Typing the DELAYED
4176 SUSPEND character (typically `^Y', Control-Y) causes the process to be
4177 stopped when it attempts to read input from the terminal, and control to
4178 be returned to Bash.  You may then manipulate the state of this job,
4179 using the `bg' command to continue it in the background, the `fg'
4180 command to continue it in the foreground, or the `kill' command to kill
4181 it.  A `^Z' takes effect immediately, and has the additional side
4182 effect of causing pending output and typeahead to be discarded.
4183
4184    There are a number of ways to refer to a job in the shell.  The
4185 character `%' introduces a job name.  Job number `n' may be referred to
4186 as `%n'.  A job may also be referred to using a prefix of the name used
4187 to start it, or using a substring that appears in its command line.
4188 For example, `%ce' refers to a stopped `ce' job. Using `%?ce', on the
4189 other hand, refers to any job containing the string `ce' in its command
4190 line.  If the prefix or substring matches more than one job, Bash
4191 reports an error.  The symbols `%%' and `%+' refer to the shell's
4192 notion of the current job, which is the last job stopped while it was
4193 in the foreground.  The previous job may be referenced using `%-'.  In
4194 output pertaining to jobs (e.g., the output of the `jobs' command), the
4195 current job is always flagged with a `+', and the previous job with a
4196 `-'.
4197
4198    Simply naming a job can be used to bring it into the foreground:
4199 `%1' is a synonym for `fg %1', bringing job 1 from the background into
4200 the foreground.  Similarly, `%1 &' resumes job 1 in the background,
4201 equivalent to `bg %1'
4202
4203    The shell learns immediately whenever a job changes state.
4204 Normally, Bash waits until it is about to print a prompt before
4205 reporting changes in a job's status so as to not interrupt any other
4206 output.  If the the `-b' option to the `set' builtin is set, Bash
4207 reports such changes immediately (*note The Set Builtin::.).
4208
4209    If you attempt to exit Bash while jobs are stopped, the shell prints
4210 a message warning you that you have stopped jobs.  You may then use the
4211 `jobs' command to inspect their status.  If you do this, or try to exit
4212 again immediately, you are not warned again, and the stopped jobs are
4213 terminated.
4214
4215 \1f
4216 File: bashref.info,  Node: Job Control Builtins,  Next: Job Control Variables,  Prev: Job Control Basics,  Up: Job Control
4217
4218 Job Control Builtins
4219 ====================
4220
4221 `bg'
4222           bg [JOBSPEC]
4223      Place JOBSPEC into the background, as if it had been started with
4224      `&'.  If JOBSPEC is not supplied, the current job is used.
4225
4226 `fg'
4227           fg [JOBSPEC]
4228      Bring JOBSPEC into the foreground and make it the current job.  If
4229      JOBSPEC is not supplied, the current job is used.
4230
4231 `jobs'
4232           jobs [-lpnrs] [JOBSPEC]
4233           jobs -x COMMAND [JOBSPEC]
4234
4235      The first form lists the active jobs.  The options have the
4236      following meanings:
4237
4238     `-l'
4239           List process IDs in addition to the normal information
4240
4241     `-n'
4242           Display information only about jobs that have changed status
4243           since you were last notified of their status.
4244
4245     `-p'
4246           List only the process ID of the job's process group leader.
4247
4248     `-r'
4249           Restrict output to running jobs.
4250
4251     `-s'
4252           Restrict output to stopped jobs.
4253
4254      If JOBSPEC is given, output is restricted to information about
4255      that job.  If JOBSPEC is not supplied, the status of all jobs is
4256      listed.
4257
4258      If the `-x' option is supplied, `jobs' replaces any JOBSPEC found
4259      in COMMAND or ARGUMENTS with the corresponding process group ID,
4260      and executes COMMAND, passing it ARGUMENTs, returning its exit
4261      status.
4262
4263 `kill'
4264           kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] JOBSPEC
4265           kill -l [SIGSPEC]
4266      Send a signal specified by SIGSPEC or SIGNUM to the process named
4267      by JOBSPEC.  SIGSPEC is either a signal name such as `SIGINT' or a
4268      signal number; SIGNUM is a signal number.  If SIGSPEC and SIGNUM
4269      are not present, `SIGTERM' is used.  The `-l' option lists the
4270      signal names, or the signal name corresponding to SIGSPEC.
4271
4272 `wait'
4273           wait [JOBSPEC|PID]
4274      Wait until the child process specified by process ID PID or job
4275      specification JOBSPEC  exits and report its exit status.  If a job
4276      spec is given, all processes in the job are waited for.  If no
4277      arguments are given, all currently active child processes are
4278      waited for.
4279
4280 `disown'
4281           disown [-h] [JOBSPEC ...]
4282      Without options, each JOBSPEC is removed from the table of active
4283      jobs.  If the `-h' option is given, the job is not removed from
4284      the table, but is marked so that `SIGHUP' is not sent to the job
4285      if the shell receives a `SIGHUP'.  If JOBSPEC is not present, the
4286      current job is used.
4287
4288 `suspend'
4289           suspend [-f]
4290      Suspend the execution of this shell until it receives a `SIGCONT'
4291      signal.  The `-f' option means to suspend even if the shell is a
4292      login shell.
4293
4294    When job control is not active, the `kill' and `wait' builtins do
4295 not accept JOBSPEC arguments.  They must be supplied process IDs.
4296
4297 \1f
4298 File: bashref.info,  Node: Job Control Variables,  Prev: Job Control Builtins,  Up: Job Control
4299
4300 Job Control Variables
4301 =====================
4302
4303 `auto_resume'
4304      This variable controls how the shell interacts with the user and
4305      job control.  If this variable exists then single word simple
4306      commands without redirects are treated as candidates for resumption
4307      of an existing job.  There is no ambiguity allowed; if you have
4308      more than one job beginning with the string that you have typed,
4309      then the most recently accessed job will be selected.  The name of
4310      a stopped job, in this context, is the command line used to start
4311      it.  If this variable is set to the value `exact', the string
4312      supplied must match the name of a stopped job exactly; if set to
4313      `substring', the string supplied needs to match a substring of the
4314      name of a stopped job.  The `substring' value provides
4315      functionality analogous to the `%?' job ID (*note Job Control
4316      Basics::.).  If set to any other value, the supplied string must
4317      be a prefix of a stopped job's name; this provides functionality
4318      analogous to the `%' job ID.
4319
4320 \1f
4321 File: bashref.info,  Node: Using History Interactively,  Next: Command Line Editing,  Prev: Job Control,  Up: Top
4322
4323 Using History Interactively
4324 ***************************
4325
4326    This chapter describes how to use the GNU History Library
4327 interactively, from a user's standpoint.  It should be considered a
4328 user's guide.  For information on using the GNU History Library in your
4329 own programs, see the GNU Readline Library Manual.
4330
4331 * Menu:
4332
4333 * Bash History Facilities::     How Bash lets you manipulate your command
4334                                 history.
4335 * History Interaction::         What it feels like using History as a user.
4336
4337 \1f
4338 File: bashref.info,  Node: Bash History Facilities,  Next: History Interaction,  Up: Using History Interactively
4339
4340 Bash History Facilities
4341 =======================
4342
4343    When the `-o history' option to the `set' builtin is enabled (*note
4344 The Set Builtin::.), the shell provides access to the COMMAND HISTORY,
4345 the list of commands previously typed.  The text of the last `HISTSIZE'
4346 commands (default 500) is saved in a history list.  The shell stores
4347 each command in the history list prior to parameter and variable
4348 expansion but after history expansion is performed, subject to the
4349 values of the shell variables `HISTIGNORE' and `HISTCONTROL'.  When the
4350 shell starts up, the history is initialized from the file named by the
4351 `HISTFILE' variable (default `~/.bash_history').  `HISTFILE' is
4352 truncated, if necessary, to contain no more than the number of lines
4353 specified by the value of the `HISTFILESIZE' variable.  When an
4354 interactive shell exits, the last `HISTSIZE' lines are copied from the
4355 history list to `HISTFILE'.  If the `histappend' shell option is set
4356 (*note Bash Builtins::.), the lines are appended to the history file,
4357 otherwise the history file is overwritten.  If `HISTFILE' is unset, or
4358 if the history file is unwritable, the history is not saved.  After
4359 saving the history, the history file is truncated to contain no more
4360 than `$HISTFILESIZE' lines.  If `HISTFILESIZE' is not set, no
4361 truncation is performed.
4362
4363    The builtin command `fc' (*note Korn Shell Builtins::.) may be used
4364 to list or edit and re-execute a portion of the history list.  The
4365 `history' builtin (*note C Shell Builtins::.) can be used to display or
4366 modify the history list and manipulate the history file.  When using
4367 the command-line editing, search commands are available in each editing
4368 mode that provide access to the history list.
4369
4370    The shell allows control over which commands are saved on the history
4371 list.  The `HISTCONTROL' and `HISTIGNORE' variables may be set to cause
4372 the shell to save only a subset of the commands entered.  The `cmdhist'
4373 shell option, if enabled, causes the shell to attempt to save each line
4374 of a multi-line command in the same history entry, adding semicolons
4375 where necessary to preserve syntactic correctness.  The `lithist' shell
4376 option causes the shell to save the command with embedded newlines
4377 instead of semicolons.  *Note Bash Builtins:: for a description of
4378 `shopt'.
4379
4380 \1f
4381 File: bashref.info,  Node: History Interaction,  Prev: Bash History Facilities,  Up: Using History Interactively
4382
4383 Interactive History Expansion
4384 =============================
4385
4386    The History library provides a history expansion feature that is
4387 similar to the history expansion provided by `csh'.  This section
4388 describes the syntax used to manipulate the history information.
4389
4390    History expansions introduce words from the history list into the
4391 input stream, making it easy to repeat commands, insert the arguments
4392 to a previous command into the current input line, or fix errors in
4393 previous commands quickly.
4394
4395    History expansion takes place in two parts.  The first is to
4396 determine which line from the previous history should be used during
4397 substitution.  The second is to select portions of that line for
4398 inclusion into the current one.  The line selected from the previous
4399 history is called the "event", and the portions of that line that are
4400 acted upon are called "words".  Various "modifiers" are available to
4401 manipulate the selected words.  The line is broken into words in the
4402 same fashion that Bash does, so that several English (or Unix) words
4403 surrounded by quotes are considered as one word.  History expansions
4404 are introduced by the appearance of the history expansion character,
4405 which is `!' by default.  Only `\' and `'' may be used to escape the
4406 history expansion character.
4407
4408    Several shell options settable with the `shopt' builtin (*note Bash
4409 Builtins::.) may be used to tailor the behavior of history expansion.
4410 If the `histverify' shell option is enabled, and Readline is being
4411 used, history substitutions are not immediately passed to the shell
4412 parser.  Instead, the expanded line is reloaded into the Readline
4413 editing buffer for further modification.  If Readline is being used,
4414 and the `histreedit' shell option is enabled, a failed history
4415 expansion will be reloaded into the Readline editing buffer for
4416 correction.  The `-p' option to the `history' builtin command may be
4417 used to see what a history expansion will do before using it.  The `-s'
4418 option to the `history' builtin may be used to add commands to the end
4419 of the history list without actually executing them, so that they are
4420 available for subsequent recall.
4421
4422    The shell allows control of the various characters used by the
4423 history expansion mechanism with the `histchars' variable.
4424
4425 * Menu:
4426
4427 * Event Designators::   How to specify which history line to use.
4428 * Word Designators::    Specifying which words are of interest.
4429 * Modifiers::           Modifying the results of substitution.
4430
4431 \1f
4432 File: bashref.info,  Node: Event Designators,  Next: Word Designators,  Up: History Interaction
4433
4434 Event Designators
4435 -----------------
4436
4437    An event designator is a reference to a command line entry in the
4438 history list.
4439
4440 `!'
4441      Start a history substitution, except when followed by a space, tab,
4442      the end of the line, = or (.
4443
4444 `!N'
4445      Refer to command line N.
4446
4447 `!-N'
4448      Refer to the command N lines back.
4449
4450 `!!'
4451      Refer to the previous command.  This is a synonym for `!-1'.
4452
4453 `!STRING'
4454      Refer to the most recent command starting with STRING.
4455
4456 `!?STRING[?]'
4457      Refer to the most recent command containing STRING.  The trailing
4458      `?' may be omitted if the STRING is followed immediately by a
4459      newline.
4460
4461 `^STRING1^STRING2^'
4462      Quick Substitution.  Repeat the last command, replacing STRING1
4463      with STRING2.  Equivalent to `!!:s/STRING1/STRING2/'.
4464
4465 `!#'
4466      The entire command line typed so far.
4467
4468 \1f
4469 File: bashref.info,  Node: Word Designators,  Next: Modifiers,  Prev: Event Designators,  Up: History Interaction
4470
4471 Word Designators
4472 ----------------
4473
4474    Word designators are used to select desired words from the event.  A
4475 `:' separates the event specification from the word designator.  It can
4476 be omitted if the word designator begins with a `^', `$', `*', `-', or
4477 `%'.  Words are numbered from the beginning of the line, with the first
4478 word being denoted by 0 (zero).  Words are inserted into the current
4479 line separated by single spaces.
4480
4481 `0 (zero)'
4482      The `0'th word.  For many applications, this is the command word.
4483
4484 `N'
4485      The Nth word.
4486
4487 `^'
4488      The first argument; that is, word 1.
4489
4490 `$'
4491      The last argument.
4492
4493 `%'
4494      The word matched by the most recent `?STRING?' search.
4495
4496 `X-Y'
4497      A range of words; `-Y' abbreviates `0-Y'.
4498
4499 `*'
4500      All of the words, except the `0'th.  This is a synonym for `1-$'.
4501      It is not an error to use `*' if there is just one word in the
4502      event; the empty string is returned in that case.
4503
4504 `X*'
4505      Abbreviates `X-$'
4506
4507 `X-'
4508      Abbreviates `X-$' like `X*', but omits the last word.
4509
4510    If a word designator is supplied without an event specification, the
4511 previous command is used as the event.
4512
4513 \1f
4514 File: bashref.info,  Node: Modifiers,  Prev: Word Designators,  Up: History Interaction
4515
4516 Modifiers
4517 ---------
4518
4519    After the optional word designator, you can add a sequence of one or
4520 more of the following modifiers, each preceded by a `:'.
4521
4522 `h'
4523      Remove a trailing pathname component, leaving only the head.
4524
4525 `t'
4526      Remove all leading  pathname  components, leaving the tail.
4527
4528 `r'
4529      Remove a trailing suffix of the form `.SUFFIX', leaving the
4530      basename.
4531
4532 `e'
4533      Remove all but the trailing suffix.
4534
4535 `p'
4536      Print the new command but do not execute it.
4537
4538 `q'
4539      Quote the substituted words, escaping further substitutions.
4540
4541 `x'
4542      Quote the substituted words as with `q', but break into words at
4543      spaces, tabs, and newlines.
4544
4545 `s/OLD/NEW/'
4546      Substitute NEW for the first occurrence of OLD in the event line.
4547      Any delimiter may be used in place of `/'.  The delimiter may be
4548      quoted in OLD and NEW with a single backslash.  If `&' appears in
4549      NEW, it is replaced by OLD.  A single backslash will quote the
4550      `&'.  The final delimiter is optional if it is the last character
4551      on the input line.
4552
4553 `&'
4554      Repeat the previous substitution.
4555
4556 `g'
4557      Cause changes to be applied over the entire event line.  Used in
4558      conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
4559
4560 \1f
4561 File: bashref.info,  Node: Command Line Editing,  Next: Installing Bash,  Prev: Using History Interactively,  Up: Top
4562
4563 Command Line Editing
4564 ********************
4565
4566    This chapter describes the basic features of the GNU command line
4567 editing interface.
4568
4569 * Menu:
4570
4571 * Introduction and Notation::   Notation used in this text.
4572 * Readline Interaction::        The minimum set of commands for editing a line.
4573 * Readline Init File::          Customizing Readline from a user's view.
4574 * Bindable Readline Commands::  A description of most of the Readline commands
4575                                 available for binding
4576 * Readline vi Mode::            A short description of how to make Readline
4577                                 behave like the vi editor.
4578
4579 \1f
4580 File: bashref.info,  Node: Introduction and Notation,  Next: Readline Interaction,  Up: Command Line Editing
4581
4582 Introduction to Line Editing
4583 ============================
4584
4585    The following paragraphs describe the notation used to represent
4586 keystrokes.
4587
4588    The text C-k is read as `Control-K' and describes the character
4589 produced when the k key is pressed while the Control key is depressed.
4590
4591    The text M-k is read as `Meta-K' and describes the character
4592 produced when the meta key (if you have one) is depressed, and the k
4593 key is pressed.  If you do not have a meta key, the identical keystroke
4594 can be generated by typing ESC first, and then typing k.  Either
4595 process is known as "metafying" the k key.
4596
4597    The text M-C-k is read as `Meta-Control-k' and describes the
4598 character produced by "metafying" C-k.
4599
4600    In addition, several keys have their own names.  Specifically, DEL,
4601 ESC, LFD, SPC, RET, and TAB all stand for themselves when seen in this
4602 text, or in an init file (*note Readline Init File::.).
4603
4604 \1f
4605 File: bashref.info,  Node: Readline Interaction,  Next: Readline Init File,  Prev: Introduction and Notation,  Up: Command Line Editing
4606
4607 Readline Interaction
4608 ====================
4609
4610    Often during an interactive session you type in a long line of text,
4611 only to notice that the first word on the line is misspelled.  The
4612 Readline library gives you a set of commands for manipulating the text
4613 as you type it in, allowing you to just fix your typo, and not forcing
4614 you to retype the majority of the line.  Using these editing commands,
4615 you move the cursor to the place that needs correction, and delete or
4616 insert the text of the corrections.  Then, when you are satisfied with
4617 the line, you simply press RETURN.  You do not have to be at the end of
4618 the line to press RETURN; the entire line is accepted regardless of the
4619 location of the cursor within the line.
4620
4621 * Menu:
4622
4623 * Readline Bare Essentials::    The least you need to know about Readline.
4624 * Readline Movement Commands::  Moving about the input line.
4625 * Readline Killing Commands::   How to delete text, and how to get it back!
4626 * Readline Arguments::          Giving numeric arguments to commands.
4627 * Searching::                   Searching through previous lines.
4628
4629 \1f
4630 File: bashref.info,  Node: Readline Bare Essentials,  Next: Readline Movement Commands,  Up: Readline Interaction
4631
4632 Readline Bare Essentials
4633 ------------------------
4634
4635    In order to enter characters into the line, simply type them.  The
4636 typed character appears where the cursor was, and then the cursor moves
4637 one space to the right.  If you mistype a character, you can use your
4638 erase character to back up and delete the mistyped character.
4639
4640    Sometimes you may miss typing a character that you wanted to type,
4641 and not notice your error until you have typed several other
4642 characters.  In that case, you can type C-b to move the cursor to the
4643 left, and then correct your mistake.  Afterwards, you can move the
4644 cursor to the right with C-f.
4645
4646    When you add text in the middle of a line, you will notice that
4647 characters to the right of the cursor are `pushed over' to make room
4648 for the text that you have inserted.  Likewise, when you delete text
4649 behind the cursor, characters to the right of the cursor are `pulled
4650 back' to fill in the blank space created by the removal of the text.  A
4651 list of the basic bare essentials for editing the text of an input line
4652 follows.
4653
4654 C-b
4655      Move back one character.
4656
4657 C-f
4658      Move forward one character.
4659
4660 DEL
4661      Delete the character to the left of the cursor.
4662
4663 C-d
4664      Delete the character underneath the cursor.
4665
4666 Printing characters
4667      Insert the character into the line at the cursor.
4668
4669 C-_
4670      Undo the last thing that you did.  You can undo all the way back
4671      to an empty line.
4672
4673 \1f
4674 File: bashref.info,  Node: Readline Movement Commands,  Next: Readline Killing Commands,  Prev: Readline Bare Essentials,  Up: Readline Interaction
4675
4676 Readline Movement Commands
4677 --------------------------
4678
4679    The above table describes the most basic possible keystrokes that
4680 you need in order to do editing of the input line.  For your
4681 convenience, many other commands have been added in addition to C-b,
4682 C-f, C-d, and DEL.  Here are some commands for moving more rapidly
4683 about the line.
4684
4685 C-a
4686      Move to the start of the line.
4687
4688 C-e
4689      Move to the end of the line.
4690
4691 M-f
4692      Move forward a word.
4693
4694 M-b
4695      Move backward a word.
4696
4697 C-l
4698      Clear the screen, reprinting the current line at the top.
4699
4700    Notice how C-f moves forward a character, while M-f moves forward a
4701 word.  It is a loose convention that control keystrokes operate on
4702 characters while meta keystrokes operate on words.
4703
4704 \1f
4705 File: bashref.info,  Node: Readline Killing Commands,  Next: Readline Arguments,  Prev: Readline Movement Commands,  Up: Readline Interaction
4706
4707 Readline Killing Commands
4708 -------------------------
4709
4710    "Killing" text means to delete the text from the line, but to save
4711 it away for later use, usually by "yanking" (re-inserting) it back into
4712 the line.  If the description for a command says that it `kills' text,
4713 then you can be sure that you can get the text back in a different (or
4714 the same) place later.
4715
4716    When you use a kill command, the text is saved in a "kill-ring".
4717 Any number of consecutive kills save all of the killed text together, so
4718 that when you yank it back, you get it all.  The kill ring is not line
4719 specific; the text that you killed on a previously typed line is
4720 available to be yanked back later, when you are typing another line.
4721
4722    Here is the list of commands for killing text.
4723
4724 C-k
4725      Kill the text from the current cursor position to the end of the
4726      line.
4727
4728 M-d
4729      Kill from the cursor to the end of the current word, or if between
4730      words, to the end of the next word.
4731
4732 M-DEL
4733      Kill from the cursor the start of the previous word, or if between
4734      words, to the start of the previous word.
4735
4736 C-w
4737      Kill from the cursor to the previous whitespace.  This is
4738      different than M-DEL because the word boundaries differ.
4739
4740    And, here is how to "yank" the text back into the line.  Yanking
4741 means to copy the most-recently-killed text from the kill buffer.
4742
4743 C-y
4744      Yank the most recently killed text back into the buffer at the
4745      cursor.
4746
4747 M-y
4748      Rotate the kill-ring, and yank the new top.  You can only do this
4749      if the prior command is C-y or M-y.
4750
4751 \1f
4752 File: bashref.info,  Node: Readline Arguments,  Next: Searching,  Prev: Readline Killing Commands,  Up: Readline Interaction
4753
4754 Readline Arguments
4755 ------------------
4756
4757    You can pass numeric arguments to Readline commands.  Sometimes the
4758 argument acts as a repeat count, other times it is the sign of the
4759 argument that is significant.  If you pass a negative argument to a
4760 command which normally acts in a forward direction, that command will
4761 act in a backward direction.  For example, to kill text back to the
4762 start of the line, you might type `M-- C-k'.
4763
4764    The general way to pass numeric arguments to a command is to type
4765 meta digits before the command.  If the first `digit' you type is a
4766 minus sign (-), then the sign of the argument will be negative.  Once
4767 you have typed one meta digit to get the argument started, you can type
4768 the remainder of the digits, and then the command.  For example, to give
4769 the C-d command an argument of 10, you could type `M-1 0 C-d'.
4770
4771 \1f
4772 File: bashref.info,  Node: Searching,  Prev: Readline Arguments,  Up: Readline Interaction
4773
4774 Searching for Commands in the History
4775 -------------------------------------
4776
4777    Readline provides commands for searching through the command history
4778 (*note Bash History Facilities::.) for lines containing a specified
4779 string.  There are two search modes:  INCREMENTAL and NON-INCREMENTAL.
4780
4781    Incremental searches begin before the user has finished typing the
4782 search string.  As each character of the search string is typed,
4783 readline displays the next entry from the history matching the string
4784 typed so far.  An incremental search requires only as many characters
4785 as needed to find the desired history entry.  The Escape character is
4786 used to terminate an incremental search.  Control-J will also terminate
4787 the search.  Control-G will abort an incremental search and restore the
4788 original line.  When the search is terminated, the history entry
4789 containing the search string becomes the current line.  To find other
4790 matching entries in the history list, type Control-S or Control-R as
4791 appropriate.  This will search backward or forward in the history for
4792 the next entry matching the search string typed so far.  Any other key
4793 sequence bound to a readline command will terminate the search and
4794 execute that command.  For instance, a `newline' will terminate the
4795 search and accept the line, thereby executing the command from the
4796 history list.
4797
4798    Non-incremental searches read the entire search string before
4799 starting to search for matching history lines.  The search string may be
4800 typed by the user or part of the contents of the current line.
4801
4802 \1f
4803 File: bashref.info,  Node: Readline Init File,  Next: Bindable Readline Commands,  Prev: Readline Interaction,  Up: Command Line Editing
4804
4805 Readline Init File
4806 ==================
4807
4808    Although the Readline library comes with a set of `emacs'-like
4809 keybindings installed by default, it is possible that you would like to
4810 use a different set of keybindings.  You can customize programs that
4811 use Readline by putting commands in an "inputrc" file in your home
4812 directory.  The name of this file is taken from the value of the shell
4813 variable `INPUTRC'.  If that variable is unset, the default is
4814 `~/.inputrc'.
4815
4816    When a program which uses the Readline library starts up, the init
4817 file is read, and the key bindings are set.
4818
4819    In addition, the `C-x C-r' command re-reads this init file, thus
4820 incorporating any changes that you might have made to it.
4821
4822 * Menu:
4823
4824 * Readline Init File Syntax::   Syntax for the commands in the inputrc file.
4825
4826 * Conditional Init Constructs:: Conditional key bindings in the inputrc file.
4827
4828 * Sample Init File::            An example inputrc file.
4829
4830 \1f
4831 File: bashref.info,  Node: Readline Init File Syntax,  Next: Conditional Init Constructs,  Up: Readline Init File
4832
4833 Readline Init File Syntax
4834 -------------------------
4835
4836    There are only a few basic constructs allowed in the Readline init
4837 file.  Blank lines are ignored.  Lines beginning with a `#' are
4838 comments.  Lines beginning with a `$' indicate conditional constructs
4839 (*note Conditional Init Constructs::.).  Other lines denote variable
4840 settings and key bindings.
4841
4842 Variable Settings
4843      You can change the state of a few variables in Readline by using
4844      the `set' command within the init file.  Here is how you would
4845      specify that you wish to use `vi' line editing commands:
4846
4847           set editing-mode vi
4848
4849      Right now, there are only a few variables which can be set; so
4850      few, in fact, that we just list them here:
4851
4852     `bell-style'
4853           Controls what happens when Readline wants to ring the
4854           terminal bell.  If set to `none', Readline never rings the
4855           bell.  If set to `visible', Readline uses a visible bell if
4856           one is available.  If set to `audible' (the default),
4857           Readline attempts to ring the terminal's bell.
4858
4859     `comment-begin'
4860           The string to insert at the beginning of the line when the
4861           `insert-comment' command is executed.  The default value is
4862           `"#"'.
4863
4864     `completion-query-items'
4865           The number of possible completions that determines when the
4866           user is asked whether he wants to see the list of
4867           possibilities.  If the number of possible completions is
4868           greater than this value, Readline will ask the user whether
4869           or not he wishes to view them; otherwise, they are simply
4870           listed.  The default limit is `100'.
4871
4872     `convert-meta'
4873           If set to `on', Readline will convert characters with the
4874           eigth bit set to an ASCII key sequence by stripping the eigth
4875           bit and prepending an ESC character, converting them to a
4876           meta-prefixed key sequence.  The default value is `on'.
4877
4878     `disable-completion'
4879           If set to `On', readline will inhibit word completion.
4880           Completion  characters will be inserted into the line as if
4881           they had been mapped to `self-insert'.  The default is `off'.
4882
4883     `editing-mode'
4884           The `editing-mode' variable controls which editing mode you
4885           are using.  By default, Readline starts up in Emacs editing
4886           mode, where the keystrokes are most similar to Emacs.  This
4887           variable can be set to either `emacs' or `vi'.
4888
4889     `enable-keypad'
4890           When set to `on', readline will try to enable the application
4891           keypad when it is called.  Some systems need this to enable
4892           the arrow keys.  The default is `off'.
4893
4894     `expand-tilde'
4895           If set to `on', tilde expansion is performed when Readline
4896           attempts word completion.  The default is `off'.
4897
4898     `horizontal-scroll-mode'
4899           This variable can be set to either `on' or `off'.  Setting it
4900           to `on' means that the text of the lines that you edit will
4901           scroll horizontally on a single screen line when they are
4902           longer than the width of the screen, instead of wrapping onto
4903           a new screen line.  By default, this variable is set to `off'.
4904
4905     `keymap'
4906           Sets Readline's idea of the current keymap for key binding
4907           commands.  Acceptable `keymap' names are `emacs',
4908           `emacs-standard', `emacs-meta', `emacs-ctlx', `vi',
4909           `vi-command', and `vi-insert'.  `vi' is equivalent to
4910           `vi-command'; `emacs' is equivalent to `emacs-standard'.  The
4911           default value is `emacs'.  The value of the `editing-mode'
4912           variable also affects the default keymap.
4913
4914     `mark-directories'
4915           If set to `on', completed directory names have a slash
4916           appended.  The default is `on'.
4917
4918     `mark-modified-lines'
4919           This variable, when set to `on', says to display an asterisk
4920           (`*') at the start of history lines which have been modified.
4921           This variable is `off' by default.
4922
4923     `input-meta'
4924           If set to `on', Readline will enable eight-bit input (it will
4925           not strip the eighth bit from the characters it reads),
4926           regardless of what the terminal claims it can support.  The
4927           default value is `off'.  The name `meta-flag' is a synonym
4928           for this variable.
4929
4930     `output-meta'
4931           If set to `on', Readline will display characters with the
4932           eighth bit set directly rather than as a meta-prefixed escape
4933           sequence.  The default is `off'.
4934
4935     `show-all-if-ambiguous'
4936           This alters the default behavior of the completion functions.
4937           If set to `on', words which have more than one possible
4938           completion cause the matches to be listed immediately instead
4939           of ringing the bell.  The default value is `off'.
4940
4941     `visible-stats'
4942           If set to `on', a character denoting a file's type is
4943           appended to the filename when listing possible completions.
4944           The default is `off'.
4945
4946 Key Bindings
4947      The syntax for controlling key bindings in the init file is
4948      simple.  First you have to know the name of the command that you
4949      want to change.  The following pages contain tables of the command
4950      name, the default keybinding, and a short description of what the
4951      command does.
4952
4953      Once you know the name of the command, simply place the name of
4954      the key you wish to bind the command to, a colon, and then the
4955      name of the command on a line in the init file.  The name of the
4956      key can be expressed in different ways, depending on which is most
4957      comfortable for you.
4958
4959     KEYNAME: FUNCTION-NAME or MACRO
4960           KEYNAME is the name of a key spelled out in English.  For
4961           example:
4962                Control-u: universal-argument
4963                Meta-Rubout: backward-kill-word
4964                Control-o: "> output"
4965
4966           In the above example, `C-u' is bound to the function
4967           `universal-argument', and `C-o' is bound to run the macro
4968           expressed on the right hand side (that is, to insert the text
4969           `> output' into the line).
4970
4971     "KEYSEQ": FUNCTION-NAME or MACRO
4972           KEYSEQ differs from KEYNAME above in that strings denoting an
4973           entire key sequence can be specified, by placing the key
4974           sequence in double quotes.  Some GNU Emacs style key escapes
4975           can be used, as in the following example, but the special
4976           character names are not recognized.
4977
4978                "\C-u": universal-argument
4979                "\C-x\C-r": re-read-init-file
4980                "\e[11~": "Function Key 1"
4981
4982           In the above example, `C-u' is bound to the function
4983           `universal-argument' (just as it was in the first example),
4984           `C-x C-r' is bound to the function `re-read-init-file', and
4985           `ESC [ 1 1 ~' is bound to insert the text `Function Key 1'.
4986           The following escape sequences are available when specifying
4987           key sequences:
4988
4989          ``\C-''
4990                control prefix
4991
4992          ``\M-''
4993                meta prefix
4994
4995          ``\e''
4996                an escape character
4997
4998          ``\\''
4999                backslash
5000
5001          ``\"''
5002                "
5003
5004          ``\'''
5005                '
5006
5007           When entering the text of a macro, single or double quotes
5008           should be used to indicate a macro definition.  Unquoted text
5009           is assumed to be a function name.  Backslash will quote any
5010           character in the macro text, including `"' and `''.  For
5011           example, the following binding will make `C-x \' insert a
5012           single `\' into the line:
5013                "\C-x\\": "\\"
5014
5015 \1f
5016 File: bashref.info,  Node: Conditional Init Constructs,  Next: Sample Init File,  Prev: Readline Init File Syntax,  Up: Readline Init File
5017
5018 Conditional Init Constructs
5019 ---------------------------
5020
5021    Readline implements a facility similar in spirit to the conditional
5022 compilation features of the C preprocessor which allows key bindings
5023 and variable settings to be performed as the result of tests.  There
5024 are three parser directives used.
5025
5026 `$if'
5027      The `$if' construct allows bindings to be made based on the
5028      editing mode, the terminal being used, or the application using
5029      Readline.  The text of the test extends to the end of the line; no
5030      characters are required to isolate it.
5031
5032     `mode'
5033           The `mode=' form of the `$if' directive is used to test
5034           whether Readline is in `emacs' or `vi' mode.  This may be
5035           used in conjunction with the `set keymap' command, for
5036           instance, to set bindings in the `emacs-standard' and
5037           `emacs-ctlx' keymaps only if Readline is starting out in
5038           `emacs' mode.
5039
5040     `term'
5041           The `term=' form may be used to include terminal-specific key
5042           bindings, perhaps to bind the key sequences output by the
5043           terminal's function keys.  The word on the right side of the
5044           `=' is tested against the full name of the terminal and the
5045           portion of the terminal name before the first `-'.  This
5046           allows `sun' to match both `sun' and `sun-cmd', for instance.
5047
5048     `application'
5049           The APPLICATION construct is used to include
5050           application-specific settings.  Each program using the
5051           Readline library sets the APPLICATION NAME, and you can test
5052           for it.  This could be used to bind key sequences to
5053           functions useful for a specific program.  For instance, the
5054           following command adds a key sequence that quotes the current
5055           or previous word in Bash:
5056                $if Bash
5057                # Quote the current or previous word
5058                "\C-xq": "\eb\"\ef\""
5059                $endif
5060
5061 `$endif'
5062      This command, as you saw in the previous example, terminates an
5063      `$if' command.
5064
5065 `$else'
5066      Commands in this branch of the `$if' directive are executed if the
5067      test fails.
5068
5069 \1f
5070 File: bashref.info,  Node: Sample Init File,  Prev: Conditional Init Constructs,  Up: Readline Init File
5071
5072 Sample Init File
5073 ----------------
5074
5075    Here is an example of an inputrc file.  This illustrates key
5076 binding, variable assignment, and conditional syntax.
5077
5078
5079      # This file controls the behaviour of line input editing for
5080      # programs that use the Gnu Readline library.  Existing programs
5081      # include FTP, Bash, and Gdb.
5082      #
5083      # You can re-read the inputrc file with C-x C-r.
5084      # Lines beginning with '#' are comments.
5085      #
5086      # Set various bindings for emacs mode.
5087      
5088      set editing-mode emacs
5089      
5090      $if mode=emacs
5091      
5092      Meta-Control-h:    backward-kill-word      Text after the function name is ignored
5093      
5094      #
5095      # Arrow keys in keypad mode
5096      #
5097      #"\M-OD"        backward-char
5098      #"\M-OC"        forward-char
5099      #"\M-OA"        previous-history
5100      #"\M-OB"        next-history
5101      #
5102      # Arrow keys in ANSI mode
5103      #
5104      "\M-[D"        backward-char
5105      "\M-[C"        forward-char
5106      "\M-[A"        previous-history
5107      "\M-[B"        next-history
5108      #
5109      # Arrow keys in 8 bit keypad mode
5110      #
5111      #"\M-\C-OD"       backward-char
5112      #"\M-\C-OC"       forward-char
5113      #"\M-\C-OA"       previous-history
5114      #"\M-\C-OB"       next-history
5115      #
5116      # Arrow keys in 8 bit ANSI mode
5117      #
5118      #"\M-\C-[D"       backward-char
5119      #"\M-\C-[C"       forward-char
5120      #"\M-\C-[A"       previous-history
5121      #"\M-\C-[B"       next-history
5122      
5123      C-q: quoted-insert
5124      
5125      $endif
5126      
5127      # An old-style binding.  This happens to be the default.
5128      TAB: complete
5129      
5130      # Macros that are convenient for shell interaction
5131      $if Bash
5132      # edit the path
5133      "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
5134      # prepare to type a quoted word -- insert open and close double quotes
5135      # and move to just after the open quote
5136      "\C-x\"": "\"\"\C-b"
5137      # insert a backslash (testing backslash escapes in sequences and macros)
5138      "\C-x\\": "\\"
5139      # Quote the current or previous word
5140      "\C-xq": "\eb\"\ef\""
5141      # Add a binding to refresh the line, which is unbound
5142      "\C-xr": redraw-current-line
5143      # Edit variable on current line.
5144      "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
5145      $endif
5146      
5147      # use a visible bell if one is available
5148      set bell-style visible
5149      
5150      # don't strip characters to 7 bits when reading
5151      set input-meta on
5152      
5153      # allow iso-latin1 characters to be inserted rather than converted to
5154      # prefix-meta sequences
5155      set convert-meta off
5156      
5157      # display characters with the eighth bit set directly rather than
5158      # as meta-prefixed characters
5159      set output-meta on
5160      
5161      # if there are more than 150 possible completions for a word, ask the
5162      # user if he wants to see all of them
5163      set completion-query-items 150
5164      
5165      # For FTP
5166      $if Ftp
5167      "\C-xg": "get \M-?"
5168      "\C-xt": "put \M-?"
5169      "\M-.": yank-last-arg
5170      $endif
5171
5172 \1f
5173 File: bashref.info,  Node: Bindable Readline Commands,  Next: Readline vi Mode,  Prev: Readline Init File,  Up: Command Line Editing
5174
5175 Bindable Readline Commands
5176 ==========================
5177
5178 * Menu:
5179
5180 * Commands For Moving::         Moving about the line.
5181 * Commands For History::        Getting at previous lines.
5182 * Commands For Text::           Commands for changing text.
5183 * Commands For Killing::        Commands for killing and yanking.
5184 * Numeric Arguments::           Specifying numeric arguments, repeat counts.
5185 * Commands For Completion::     Getting Readline to do the typing for you.
5186 * Keyboard Macros::             Saving and re-executing typed characters
5187 * Miscellaneous Commands::      Other miscellaneous commands.
5188
5189    This section describes Readline commands that may be bound to key
5190 sequences.
5191
5192 \1f
5193 File: bashref.info,  Node: Commands For Moving,  Next: Commands For History,  Up: Bindable Readline Commands
5194
5195 Commands For Moving
5196 -------------------
5197
5198 `beginning-of-line (C-a)'
5199      Move to the start of the current line.
5200
5201 `end-of-line (C-e)'
5202      Move to the end of the line.
5203
5204 `forward-char (C-f)'
5205      Move forward a character.
5206
5207 `backward-char (C-b)'
5208      Move back a character.
5209
5210 `forward-word (M-f)'
5211      Move forward to the end of the next word.  Words are composed of
5212      letters and digits.
5213
5214 `backward-word (M-b)'
5215      Move back to the start of this, or the previous, word.  Words are
5216      composed of letters and digits.
5217
5218 `clear-screen (C-l)'
5219      Clear the screen and redraw the current line, leaving the current
5220      line at the top of the screen.
5221
5222 `redraw-current-line ()'
5223      Refresh the current line.  By default, this is unbound.
5224
5225 \1f
5226 File: bashref.info,  Node: Commands For History,  Next: Commands For Text,  Prev: Commands For Moving,  Up: Bindable Readline Commands
5227
5228 Commands For Manipulating The History
5229 -------------------------------------
5230
5231 `accept-line (Newline, Return)'
5232      Accept the line regardless of where the cursor is.  If this line is
5233      non-empty, add it to the history list according to the setting of
5234      the `HISTCONTROL' variable.  If this line was a history line, then
5235      restore the history line to its original state.
5236
5237 `previous-history (C-p)'
5238      Move `up' through the history list.
5239
5240 `next-history (C-n)'
5241      Move `down' through the history list.
5242
5243 `beginning-of-history (M-<)'
5244      Move to the first line in the history.
5245
5246 `end-of-history (M->)'
5247      Move to the end of the input history, i.e., the line you are
5248      entering.
5249
5250 `reverse-search-history (C-r)'
5251      Search backward starting at the current line and moving `up'
5252      through the history as necessary.  This is an incremental search.
5253
5254 `forward-search-history (C-s)'
5255      Search forward starting at the current line and moving `down'
5256      through the the history as necessary.  This is an incremental
5257      search.
5258
5259 `non-incremental-reverse-search-history (M-p)'
5260      Search backward starting at the current line and moving `up'
5261      through the history as necessary using a non-incremental search
5262      for a string supplied by the user.
5263
5264 `non-incremental-forward-search-history (M-n)'
5265      Search forward starting at the current line and moving `down'
5266      through the the history as necessary using a non-incremental search
5267      for a string supplied by the user.
5268
5269 `history-search-forward ()'
5270      Search forward through the history for the string of characters
5271      between the start of the current line and the current cursor
5272      position (the `point').  This is a non-incremental search.  By
5273      default, this command is unbound.
5274
5275 `history-search-backward ()'
5276      Search backward through the history for the string of characters
5277      between the start of the current line and the point.  This is a
5278      non-incremental search.  By default, this command is unbound.
5279
5280 `yank-nth-arg (M-C-y)'
5281      Insert the first argument to the previous command (usually the
5282      second word on the previous line).  With an argument N, insert the
5283      Nth word from the previous command (the words in the previous
5284      command begin with word 0).  A negative argument inserts the Nth
5285      word from the end of the previous command.
5286
5287 `yank-last-arg (M-., M-_)'
5288      Insert last argument to the previous command (the last word of the
5289      previous history entry).  With an argument, behave exactly like
5290      `yank-nth-arg'.
5291
5292 \1f
5293 File: bashref.info,  Node: Commands For Text,  Next: Commands For Killing,  Prev: Commands For History,  Up: Bindable Readline Commands
5294
5295 Commands For Changing Text
5296 --------------------------
5297
5298 `delete-char (C-d)'
5299      Delete the character under the cursor.  If the cursor is at the
5300      beginning of the line, there are no characters in the line, and
5301      the last character typed was not `C-d', then return `EOF'.
5302
5303 `backward-delete-char (Rubout)'
5304      Delete the character behind the cursor.  A numeric arg says to kill
5305      the characters instead of deleting them.
5306
5307 `quoted-insert (C-q, C-v)'
5308      Add the next character that you type to the line verbatim.  This is
5309      how to insert key sequences like C-q, for example.
5310
5311 `tab-insert (M-TAB)'
5312      Insert a tab character.
5313
5314 `self-insert (a, b, A, 1, !, ...)'
5315      Insert yourself.
5316
5317 `transpose-chars (C-t)'
5318      Drag the character before the cursor forward over the character at
5319      the cursor, moving the cursor forward as well.  If the insertion
5320      point is at the end of the line, then this transposes the last two
5321      characters of the line.  Negative argumentss don't work.
5322
5323 `transpose-words (M-t)'
5324      Drag the word behind the cursor past the word in front of the
5325      cursor moving the cursor over that word as well.
5326
5327 `upcase-word (M-u)'
5328      Uppercase the current (or following) word.  With a negative
5329      argument, do the previous word, but do not move the cursor.
5330
5331 `downcase-word (M-l)'
5332      Lowercase the current (or following) word.  With a negative
5333      argument, do the previous word, but do not move the cursor.
5334
5335 `capitalize-word (M-c)'
5336      Capitalize the current (or following) word.  With a negative
5337      argument, do the previous word, but do not move the cursor.
5338
5339 \1f
5340 File: bashref.info,  Node: Commands For Killing,  Next: Numeric Arguments,  Prev: Commands For Text,  Up: Bindable Readline Commands
5341
5342 Killing And Yanking
5343 -------------------
5344
5345 `kill-line (C-k)'
5346      Kill the text from the current cursor position to the end of the
5347      line.
5348
5349 `backward-kill-line (C-x Rubout)'
5350      Kill backward to the beginning of the line.
5351
5352 `unix-line-discard (C-u)'
5353      Kill backward from the cursor to the beginning of the current line.
5354      Save the killed text on the kill-ring.
5355
5356 `kill-whole-line ()'
5357      Kill all characters on the current line, no matter where the
5358      cursor is.  By default, this is unbound.
5359
5360 `kill-word (M-d)'
5361      Kill from the cursor to the end of the current word, or if between
5362      words, to the end of the next word.  Word boundaries are the same
5363      as `forward-word'.
5364
5365 `backward-kill-word (M-DEL)'
5366      Kill the word behind the cursor.  Word boundaries are the same as
5367      `backward-word'.
5368
5369 `unix-word-rubout (C-w)'
5370      Kill the word behind the cursor, using white space as a word
5371      boundary.  The killed text is saved on the kill-ring.
5372
5373 `delete-horizontal-space ()'
5374      Delete all spaces and tabs around point.  By default, this is
5375      unbound.
5376
5377 `kill-region ()'
5378      Kill the text between the point and the *mark* (saved cursor
5379      position.  This text is referred to as the REGION.  By default,
5380      this command is unbound.
5381
5382 `copy-region-as-kill ()'
5383      Copy the text in the region to the kill buffer, so you can yank it
5384      right away.  By default, this command is unbound.
5385
5386 `copy-backward-word ()'
5387      Copy the word before point to the kill buffer.  By default, this
5388      command is unbound.
5389
5390 `copy-forward-word ()'
5391      Copy the word following point to the kill buffer.  By default,
5392      this command is unbound.
5393
5394 `yank (C-y)'
5395      Yank the top of the kill ring into the buffer at the current
5396      cursor position.
5397
5398 `yank-pop (M-y)'
5399      Rotate the kill-ring, and yank the new top.  You can only do this
5400      if the prior command is yank or yank-pop.
5401
5402 \1f
5403 File: bashref.info,  Node: Numeric Arguments,  Next: Commands For Completion,  Prev: Commands For Killing,  Up: Bindable Readline Commands
5404
5405 Specifying Numeric Arguments
5406 ----------------------------
5407
5408 `digit-argument (M-0, M-1, ... M--)'
5409      Add this digit to the argument already accumulating, or start a new
5410      argument.  M- starts a negative argument.
5411
5412 `universal-argument ()'
5413      Each time this is executed, the argument count is multiplied by
5414      four.  The argument count is initially one, so executing this
5415      function the first time makes the argument count four.  By
5416      default, this is not bound to a key.
5417
5418 \1f
5419 File: bashref.info,  Node: Commands For Completion,  Next: Keyboard Macros,  Prev: Numeric Arguments,  Up: Bindable Readline Commands
5420
5421 Letting Readline Type For You
5422 -----------------------------
5423
5424 `complete (TAB)'
5425      Attempt to do completion on the text before the cursor.  This is
5426      application-specific.  Generally, if you are typing a filename
5427      argument, you can do filename completion; if you are typing a
5428      command, you can do command completion, if you are typing in a
5429      symbol to GDB, you can do symbol name completion, if you are
5430      typing in a variable to Bash, you can do variable name completion,
5431      and so on.  Bash attempts completion treating the text as a
5432      variable (if the text begins with `$'), username (if the text
5433      begins with `~'), hostname (if the text begins with `@'), or
5434      command (including aliases and functions) in turn.  If none of
5435      these produces a match, filename completion is attempted.
5436
5437 `possible-completions (M-?)'
5438      List the possible completions of the text before the cursor.
5439
5440 `insert-completions (M-*)'
5441      Insert all completions of the text before point that would have
5442      been generated by `possible-completions'.
5443
5444 `complete-filename (M-/)'
5445      Attempt filename completion on the text before point.
5446
5447 `possible-filename-completions (C-x /)'
5448      List the possible completions of the text before point, treating
5449      it as a filename.
5450
5451 `complete-username (M-~)'
5452      Attempt completion on the text before point, treating it as a
5453      username.
5454
5455 `possible-username-completions (C-x ~)'
5456      List the possible completions of the text before point, treating
5457      it as a username.
5458
5459 `complete-variable (M-$)'
5460      Attempt completion on the text before point, treating it as a
5461      shell variable.
5462
5463 `possible-variable-completions (C-x $)'
5464      List the possible completions of the text before point, treating
5465      it as a shell variable.
5466
5467 `complete-hostname (M-@)'
5468      Attempt completion on the text before point, treating it as a
5469      hostname.
5470
5471 `possible-hostname-completions (C-x @)'
5472      List the possible completions of the text before point, treating
5473      it as a hostname.
5474
5475 `complete-command (M-!)'
5476      Attempt completion on the text before point, treating it as a
5477      command name.  Command completion attempts to match the text
5478      against aliases, reserved words, shell functions, builtins, and
5479      finally executable filenames, in that order.
5480
5481 `possible-command-completions (C-x !)'
5482      List the possible completions of the text before point, treating
5483      it as a command name.
5484
5485 `dynamic-complete-history (M-TAB)'
5486      Attempt completion on the text before point, comparing the text
5487      against lines from the history list for possible completion
5488      matches.
5489
5490 `complete-into-braces (M-{)'
5491      Perform filename completion and return the list of possible
5492      completions enclosed within braces so the list is available to the
5493      shell (*note Brace Expansion::.).
5494
5495 \1f
5496 File: bashref.info,  Node: Keyboard Macros,  Next: Miscellaneous Commands,  Prev: Commands For Completion,  Up: Bindable Readline Commands
5497
5498 Keyboard Macros
5499 ---------------
5500
5501 `start-kbd-macro (C-x ()'
5502      Begin saving the characters typed into the current keyboard macro.
5503
5504 `end-kbd-macro (C-x ))'
5505      Stop saving the characters typed into the current keyboard macro
5506      and save the definition.
5507
5508 `call-last-kbd-macro (C-x e)'
5509      Re-execute the last keyboard macro defined, by making the
5510      characters in the macro appear as if typed at the keyboard.
5511
5512 \1f
5513 File: bashref.info,  Node: Miscellaneous Commands,  Prev: Keyboard Macros,  Up: Bindable Readline Commands
5514
5515 Some Miscellaneous Commands
5516 ---------------------------
5517
5518 `re-read-init-file (C-x C-r)'
5519      Read in the contents of the inputrc file, and incorporate any
5520      bindings or variable assignments found there.
5521
5522 `abort (C-g)'
5523      Abort the current editing command and ring the terminal's bell
5524      (subject to the setting of `bell-style').
5525
5526 `do-uppercase-version (M-a, M-b, M-X, ...)'
5527      If the metafied character X is lowercase, run the command that is
5528      bound to the corresponding uppercase character.
5529
5530 `prefix-meta (ESC)'
5531      Make the next character that you type be metafied.  This is for
5532      people without a meta key.  Typing `ESC f' is equivalent to typing
5533      `M-f'.
5534
5535 `undo (C-_, C-x C-u)'
5536      Incremental undo, separately remembered for each line.
5537
5538 `revert-line (M-r)'
5539      Undo all changes made to this line.  This is like typing the `undo'
5540      command enough times to get back to the beginning.
5541
5542 `tilde-expand (M-~)'
5543      Perform tilde expansion on the current word.
5544
5545 `set-mark (C-@)'
5546      Set the mark to the current point.  If a numeric argument is
5547      supplied, the mark is set to that position.
5548
5549 `exchange-point-and-mark (C-x C-x)'
5550      Swap the point with the mark.  The current cursor position is set
5551      to the saved position, and the old cursor position is saved as the
5552      mark.
5553
5554 `character-search (C-])'
5555      A character is read and point is moved to the next occurrence of
5556      that character.  A negative count searches for previous
5557      occurrences.
5558
5559 `character-search-backward (M-C-])'
5560      A character is read and point is moved to the previous occurrence
5561      of that character.  A negative count searches for subsequent
5562      occurrences.
5563
5564 `insert-comment (M-#)'
5565      The value of the `comment-begin' variable is inserted at the
5566      beginning of the current line, and the line is accepted as if a
5567      newline had been typed.  This makes the current line a shell
5568      comment.
5569
5570 `dump-functions ()'
5571      Print all of the functions and their key bindings to the readline
5572      output stream.  If a numeric argument is supplied, the output is
5573      formatted in such a way that it can be made part of an INPUTRC
5574      file.  This command is unbound by default.
5575
5576 `dump-variables ()'
5577      Print all of the settable variables and their values to the
5578      readline output stream.  If a numeric argument is supplied, the
5579      output is formatted in such a way that it can be made part of an
5580      INPUTRC file.  This command is unbound by default.
5581
5582 `dump-macros ()'
5583      Print all of the readline key sequences bound to macros and the
5584      strings they ouput.  If a numeric argument is supplied, the output
5585      is formatted in such a way that it can be made part of an INPUTRC
5586      file.  This command is unbound by default.
5587
5588 `glob-expand-word (C-x *)'
5589      The word before point is treated as a pattern for pathname
5590      expansion, and the list of matching file names is inserted,
5591      replacing the word.
5592
5593 `glob-list-expansions (C-x g)'
5594      The list of expansions that would have been generated by
5595      `glob-expand-word' is inserted into the line, replacing the word
5596      before point.
5597
5598 `display-shell-version (C-x C-v)'
5599      Display version information about the current instance of Bash.
5600
5601 `shell-expand-line (M-C-e)'
5602      Expand the line the way the shell does when it reads it.  This
5603      performs alias and history expansion as well as all of the shell
5604      word expansions.
5605
5606 `history-expand-line (M-^)'
5607      Perform history expansion on the current line.
5608
5609 `insert-last-argument (M-., M-_)'
5610      A synonym for `yank-last-arg'.
5611
5612 `operate-and-get-next (C-o)'
5613      Accept the current line for execution and fetch the next line
5614      relative to the current line from the history for editing.  Any
5615      argument is ignored.
5616
5617 `emacs-editing-mode (C-e)'
5618      When in `vi' editing mode, this causes a switch back to `emacs'
5619      editing mode, as if the command `set -o emacs' had been executed.
5620
5621 \1f
5622 File: bashref.info,  Node: Readline vi Mode,  Prev: Bindable Readline Commands,  Up: Command Line Editing
5623
5624 Readline vi Mode
5625 ================
5626
5627    While the Readline library does not have a full set of `vi' editing
5628 functions, it does contain enough to allow simple editing of the line.
5629 The Readline `vi' mode behaves as specified in the POSIX 1003.2
5630 standard.
5631
5632    In order to switch interactively between `emacs' and `vi' editing
5633 modes, use the `set -o emacs' and `set -o vi' commands (*note The Set
5634 Builtin::.).  The Readline default is `emacs' mode.
5635
5636    When you enter a line in `vi' mode, you are already placed in
5637 `insertion' mode, as if you had typed an `i'.  Pressing ESC switches
5638 you into `command' mode, where you can edit the text of the line with
5639 the standard `vi' movement keys, move to previous history lines with
5640 `k' and subsequent lines with `j', and so forth.
5641
5642 \1f
5643 File: bashref.info,  Node: Installing Bash,  Next: Reporting Bugs,  Prev: Command Line Editing,  Up: Top
5644
5645 Installing Bash
5646 ***************
5647
5648    This chapter provides basic instructions for installing Bash on the
5649 various supported platforms.  The distribution supports nearly every
5650 version of Unix (and, someday, GNU).  Other independent ports exist for
5651 OS/2, Windows 95, and Windows NT.
5652
5653 * Menu:
5654
5655 * Basic Installation::  Generic installation instructions.
5656
5657 * Compilers and Options::       How to set special options for various
5658                                 systems.
5659
5660 * Compiling For Multiple Architectures::        How to compile Bash for more
5661                                                 than one kind of system from
5662                                                 the same source tree.
5663
5664 * Installation Names::  How to set the various paths used by the installation.
5665
5666 * Specifying the System Type::  How to configure Bash for a particular system.
5667
5668 * Sharing Defaults::    How to share default configuration values among GNU
5669                         programs.
5670
5671 * Operation Controls::  Options recognized by the configuration program.
5672
5673 * Optional Features::   How to enable and disable optional features when
5674                         building Bash.
5675
5676 \1f
5677 File: bashref.info,  Node: Basic Installation,  Next: Compilers and Options,  Up: Installing Bash
5678
5679 Basic Installation
5680 ==================
5681
5682    These are generic installation instructions for Bash.
5683
5684    The `configure' shell script attempts to guess correct values for
5685 various system-dependent variables used during compilation.  It uses
5686 those values to create a `Makefile' in each directory of the package
5687 (the top directory, the `builtins' and `doc' directories, and the each
5688 directory under `lib').  It also creates a `config.h' file containing
5689 system-dependent definitions.  Finally, it creates a shell script named
5690 `config.status' that you can run in the future to recreate the current
5691 configuration, a file `config.cache' that saves the results of its
5692 tests to speed up reconfiguring, and a file `config.log' containing
5693 compiler output (useful mainly for debugging `configure').  If at some
5694 point `config.cache' contains results you don't want to keep, you may
5695 remove or edit it.
5696
5697    If you need to do unusual things to compile the package, please try
5698 to figure out how `configure' could check whether or not to do them,
5699 and mail diffs or instructions to `bash-maintainers@prep.ai.mit.edu' so
5700 they can be considered for the next release.
5701
5702    The file `configure.in' is used to create `configure' by a program
5703 called Autoconf.  You only need `configure.in' if you want to change it
5704 or regenerate `configure' using a newer version of Autoconf.  If you do
5705 this, make sure you are using Autoconf version 2.9 or newer.
5706
5707    The simplest way to compile Bash is:
5708
5709   1. `cd' to the directory containing the source code and type
5710      `./configure' to configure Bash for your system.  If you're using
5711      `csh' on an old version of System V, you might need to type `sh
5712      ./configure' instead to prevent `csh' from trying to execute
5713      `configure' itself.
5714
5715      Running `configure' takes awhile.  While running, it prints some
5716      messages telling which features it is checking for.
5717
5718   2. Type `make' to compile Bash and build the `bashbug' bug reporting
5719      script.
5720
5721   3. Optionally, type `make tests' to run the Bash test suite.
5722
5723   4. Type `make install' to install `bash' and `bashbug'.  This will
5724      also install the manual pages and Info file.
5725
5726
5727    You can remove the program binaries and object files from the source
5728 code directory by typing `make clean'.  To also remove the files that
5729 `configure' created (so you can compile Bash for a different kind of
5730 computer), type `make distclean'.
5731
5732 \1f
5733 File: bashref.info,  Node: Compilers and Options,  Next: Compiling For Multiple Architectures,  Prev: Basic Installation,  Up: Installing Bash
5734
5735 Compilers and Options
5736 =====================
5737
5738    Some systems require unusual options for compilation or linking that
5739 the `configure' script does not know about.  You can give `configure'
5740 initial values for variables by setting them in the environment.  Using
5741 a Bourne-compatible shell, you can do that on the command line like
5742 this:
5743
5744      CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
5745
5746    On systems that have the `env' program, you can do it like this:
5747
5748      env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
5749
5750    The configuration process uses GCC to build Bash if it is available.
5751
5752 \1f
5753 File: bashref.info,  Node: Compiling For Multiple Architectures,  Next: Installation Names,  Prev: Compilers and Options,  Up: Installing Bash
5754
5755 Compiling For Multiple Architectures
5756 ====================================
5757
5758    You can compile Bash for more than one kind of computer at the same
5759 time, by placing the object files for each architecture in their own
5760 directory.  To do this, you must use a version of `make' that supports
5761 the `VPATH' variable, such as GNU `make'.  `cd' to the directory where
5762 you want the object files and executables to go and run the `configure'
5763 script from the source directory.  You may need to supply the
5764 `--srcdir=PATH' argument to tell `configure' where the source files
5765 are.  `configure' automatically checks for the source code in the
5766 directory that `configure' is in and in `..'.
5767
5768    If you have to use a `make' that does not supports the `VPATH'
5769 variable, you can compile Bash for one architecture at a time in the
5770 source code directory.  After you have installed Bash for one
5771 architecture, use `make distclean' before reconfiguring for another
5772 architecture.
5773
5774    Alternatively, if your system supports symbolic links, you can use
5775 the `support/mkclone' script to create a build tree which has symbolic
5776 links back to each file in the source directory.  Here's an example
5777 that creates a build directory in the current directory from a source
5778 directory `/usr/gnu/src/bash-2.0':
5779
5780      bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
5781
5782 The `mkclone' script requires Bash, so you must have already built Bash
5783 for at least one architecture before you can create build directories
5784 for other architectures.
5785
5786 \1f
5787 File: bashref.info,  Node: Installation Names,  Next: Specifying the System Type,  Prev: Compiling For Multiple Architectures,  Up: Installing Bash
5788
5789 Installation Names
5790 ==================
5791
5792    By default, `make install' will install into `/usr/local/bin',
5793 `/usr/local/man', etc.  You can specify an installation prefix other
5794 than `/usr/local' by giving `configure' the option `--prefix=PATH'.
5795
5796    You can specify separate installation prefixes for
5797 architecture-specific files and architecture-independent files.  If you
5798 give `configure' the option `--exec-prefix=PATH', the package will use
5799 `PATH' as the prefix for installing programs and libraries.
5800 Documentation and other data files will still use the regular prefix.
5801
5802 \1f
5803 File: bashref.info,  Node: Specifying the System Type,  Next: Sharing Defaults,  Prev: Installation Names,  Up: Installing Bash
5804
5805 Specifying the System Type
5806 ==========================
5807
5808    There may be some features `configure' can not figure out
5809 automatically, but needs to determine by the type of host the package
5810 will run on.  Usually `configure' can figure that out, but if it prints
5811 a message saying it can not guess the host type, give it the
5812 `--host=TYPE' option.  `TYPE' can either be a short name for the system
5813 type, such as `sun4', or a canonical name with three fields:
5814 `CPU-COMPANY-SYSTEM' (e.g., `sparc-sun-sunos4.1.2').
5815
5816 See the file `support/config.sub' for the possible values of each field.
5817
5818 \1f
5819 File: bashref.info,  Node: Sharing Defaults,  Next: Operation Controls,  Prev: Specifying the System Type,  Up: Installing Bash
5820
5821 Sharing Defaults
5822 ================
5823
5824    If you want to set default values for `configure' scripts to share,
5825 you can create a site shell script called `config.site' that gives
5826 default values for variables like `CC', `cache_file', and `prefix'.
5827 `configure' looks for `PREFIX/share/config.site' if it exists, then
5828 `PREFIX/etc/config.site' if it exists.  Or, you can set the
5829 `CONFIG_SITE' environment variable to the location of the site script.
5830 A warning: the Bash `configure' looks for a site script, but not all
5831 `configure' scripts do.
5832
5833 \1f
5834 File: bashref.info,  Node: Operation Controls,  Next: Optional Features,  Prev: Sharing Defaults,  Up: Installing Bash
5835
5836 Operation Controls
5837 ==================
5838
5839    `configure' recognizes the following options to control how it
5840 operates.
5841
5842 `--cache-file=FILE'
5843      Use and save the results of the tests in FILE instead of
5844      `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
5845      debugging `configure'.
5846
5847 `--help'
5848      Print a summary of the options to `configure', and exit.
5849
5850 `--quiet'
5851 `--silent'
5852 `-q'
5853      Do not print messages saying which checks are being made.
5854
5855 `--srcdir=DIR'
5856      Look for the Bash source code in directory DIR.  Usually
5857      `configure' can determine that directory automatically.
5858
5859 `--version'
5860      Print the version of Autoconf used to generate the `configure'
5861      script, and exit.
5862
5863    `configure' also accepts some other, not widely used, boilerplate
5864 options.
5865
5866 \1f
5867 File: bashref.info,  Node: Optional Features,  Prev: Operation Controls,  Up: Installing Bash
5868
5869 Optional Features
5870 =================
5871
5872    The Bash `configure' has a number of `--enable-FEATURE' options,
5873 where FEATURE indicates an optional part of the package.  There are
5874 also several `--with-PACKAGE' options, where PACKAGE is something like
5875 `gnu-malloc' or `purify' (for the Purify memory allocation checker).  To
5876 turn off the default use of a package, use `--without-PACKAGE'.  To
5877 configure Bash without a feature that is enabled by default, use
5878 `--disable-FEATURE'.
5879
5880    Here is a complete list of the `--enable-' and `--with-' options
5881 that the Bash `configure' recognizes.
5882
5883 `--with-gnu-malloc'
5884      Use the GNU version of `malloc' in `lib/malloc/malloc.c'.  This is
5885      not the same `malloc' that appears in GNU libc, but an older
5886      version derived from the 4.2 BSD `malloc'.  This `malloc' is very
5887      fast, but wastes a lot of space.  This option is enabled by
5888      default.  The `NOTES' file contains a list of systems for which
5889      this should be turned off.
5890
5891 `--with-glibc-malloc'
5892      Use the GNU libc version of `malloc' in `lib/malloc/gmalloc.c'.
5893      This is somewhat slower than the default `malloc', but wastes
5894      considerably less space.
5895
5896 `--with-afs'
5897      Define if you are using the Andrew File System from Transarc.
5898
5899 `--with-purify'
5900      Define this to use the Purify memory allocation checker from Pure
5901      Software.
5902
5903 `--enable-minimal-config'
5904      This produces a shell with minimal features, close to the
5905      historical Bourne shell.
5906
5907 The `minimal-config' option can be used to disable all of the following
5908 options, but it is processed first, so individual options may be
5909 enabled using `enable-FEATURE'.
5910
5911    All of the following options except for `disabled-builtins' and
5912 `usg-echo-default' are enabled by default, unless the operating system
5913 does not provide the necessary support.
5914
5915 `--enable-job-control'
5916      This enables job control features, if the OS supports them.
5917
5918 `--enable-alias'
5919      Allow alias expansion and include the `alias' and `unalias'
5920      builtins.
5921
5922 `--enable-readline'
5923      Include support for command-line editing and history with the Bash
5924      version of the Readline library.
5925
5926 `--enable-history'
5927      Include command history and the `fc' and `history' builtin
5928      commands.
5929
5930 `--enable-bang-history'
5931      Include support for `csh'-like history substitution.
5932
5933 `--enable-directory-stack'
5934      Include support for a `csh'-like directory stack and the `pushd',
5935      `popd', and `dirs' builtins.
5936
5937 `--enable-restricted'
5938      Include support for a "restricted shell".  If this is enabled,
5939      Bash, when called as `rbash', enters a restricted mode.  See *Note
5940      The Restricted Shell::, for a description of restricted mode.
5941
5942 `--enable-process-substitution'
5943      This enables process substitution (*note Process Substitution::.)
5944      if the OS provides the necessary support.
5945
5946 `--enable-prompt-string-decoding'
5947      Turn on the interpretation of a number of backslash-escaped
5948      characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
5949      strings.
5950
5951 `--enable-select'
5952      Include the `ksh' `select' builtin, which allows the generation of
5953      simple menus.
5954
5955 `--enable-help-builtin'
5956      Include the `help' builtin, which displays help on shell builtins
5957      and variables.
5958
5959 `--enable-array-variables'
5960      Include support for one-dimensional array shell variables.
5961
5962 `--enable-dparen-arithmetic'
5963      Include support for the `ksh' `((...))' command.
5964
5965 `--enable-brace-expansion'
5966      Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
5967
5968 `--enable-disabled-builtins'
5969      Allow builtin commands to be invoked via `builtin xxx' even after
5970      `xxx' has been disabled using `enable -n xxx'.  See *Note Bash
5971      Builtins::, for details of the `builtin' and `enable' builtin
5972      commands.
5973
5974 `--enable-command-timing'
5975      Include support for recognizing `time' as a reserved word and for
5976      displaying timing statistics for the pipeline following `time'.
5977      This allows pipelines as well as shell builtins and functions to
5978      be timed.
5979
5980 `--enable-usg-echo-default'
5981      Make the `echo' builtin expand backslash-escaped characters by
5982      default, without requiring the `-e' option.  This makes the Bash
5983      `echo' behave more like the System V version.
5984
5985    The file `config.h.top' contains C Preprocessor `#define' statements
5986 for options which are not settable from `configure'.  Some of these are
5987 not meant to be changed; beware of the consequences if you do.  Read
5988 the comments associated with each definition for more information about
5989 its effect.
5990
5991 \1f
5992 File: bashref.info,  Node: Reporting Bugs,  Next: Builtin Index,  Prev: Installing Bash,  Up: Top
5993
5994 Reporting Bugs
5995 **************
5996
5997    Please report all bugs you find in Bash.  But first, you should make
5998 sure that it really is a bug, and that it appears in the latest version
5999 of Bash that you have.
6000
6001    Once you have determined that a bug actually exists, use the
6002 `bashbug' command to submit a bug report.  If you have a fix, you are
6003 welcome to mail that as well!  Suggestions and `philosophical' bug
6004 reports may be mailed to `bug-bash@prep.ai.MIT.Edu' or posted to the
6005 Usenet newsgroup `gnu.bash.bug'.
6006
6007    All bug reports should include:
6008    * The version number of Bash.
6009
6010    * The hardware and operating system.
6011
6012    * The compiler used to compile Bash.
6013
6014    * A description of the bug behaviour.
6015
6016    * A short script or `recipe' which exercises the bug and may be used
6017      to reproduce it.
6018
6019 `bashbug' inserts the first three items automatically into the template
6020 it provides for filing a bug report.
6021
6022    Please send all reports concerning this manual to
6023 `chet@ins.CWRU.Edu'.
6024
6025 \1f
6026 File: bashref.info,  Node: Builtin Index,  Next: Reserved Word Index,  Prev: Reporting Bugs,  Up: Top
6027
6028 Index of Shell Builtin Commands
6029 *******************************
6030
6031 * Menu:
6032
6033 * .:                                    Bourne Shell Builtins.
6034 * ::                                    Bourne Shell Builtins.
6035 * [:                                    Bourne Shell Builtins.
6036 * alias:                                Alias Builtins.
6037 * bg:                                   Job Control Builtins.
6038 * bind:                                 Bash Builtins.
6039 * break:                                Bourne Shell Builtins.
6040 * builtin:                              Bash Builtins.
6041 * cd:                                   Bourne Shell Builtins.
6042 * command:                              Bash Builtins.
6043 * continue:                             Bourne Shell Builtins.
6044 * declare:                              Bash Builtins.
6045 * dirs:                                 C Shell Builtins.
6046 * disown:                               Job Control Builtins.
6047 * echo:                                 Bash Builtins.
6048 * enable:                               Bash Builtins.
6049 * eval:                                 Bourne Shell Builtins.
6050 * exec:                                 Bourne Shell Builtins.
6051 * exit:                                 Bourne Shell Builtins.
6052 * export:                               Bourne Shell Builtins.
6053 * fc:                                   Korn Shell Builtins.
6054 * fg:                                   Job Control Builtins.
6055 * getopts:                              Bourne Shell Builtins.
6056 * hash:                                 Bourne Shell Builtins.
6057 * help:                                 Bash Builtins.
6058 * history:                              C Shell Builtins.
6059 * jobs:                                 Job Control Builtins.
6060 * kill:                                 Job Control Builtins.
6061 * let <1>:                              Arithmetic Builtins.
6062 * let:                                  Korn Shell Builtins.
6063 * local:                                Bash Builtins.
6064 * logout <1>:                           Bash Builtins.
6065 * logout:                               C Shell Builtins.
6066 * popd:                                 C Shell Builtins.
6067 * pushd:                                C Shell Builtins.
6068 * pwd:                                  Bourne Shell Builtins.
6069 * read:                                 Bash Builtins.
6070 * readonly:                             Bourne Shell Builtins.
6071 * return:                               Bourne Shell Builtins.
6072 * set:                                  The Set Builtin.
6073 * shift:                                Bourne Shell Builtins.
6074 * shopt:                                Bash Builtins.
6075 * source:                               C Shell Builtins.
6076 * suspend:                              Job Control Builtins.
6077 * test:                                 Bourne Shell Builtins.
6078 * times:                                Bourne Shell Builtins.
6079 * trap:                                 Bourne Shell Builtins.
6080 * type:                                 Bash Builtins.
6081 * typeset:                              Korn Shell Builtins.
6082 * ulimit:                               Bash Builtins.
6083 * umask:                                Bourne Shell Builtins.
6084 * unalias:                              Alias Builtins.
6085 * unset:                                Bourne Shell Builtins.
6086 * wait:                                 Job Control Builtins.
6087
6088 \1f
6089 File: bashref.info,  Node: Reserved Word Index,  Next: Variable Index,  Prev: Builtin Index,  Up: Top
6090
6091 Shell Reserved Words
6092 ********************
6093
6094 * Menu:
6095
6096 * !:                                    Pipelines.
6097 * {:                                    Command Grouping.
6098 * }:                                    Command Grouping.
6099 * case:                                 Conditional Constructs.
6100 * do:                                   Looping Constructs.
6101 * done:                                 Looping Constructs.
6102 * elif:                                 Conditional Constructs.
6103 * else:                                 Conditional Constructs.
6104 * esac:                                 Conditional Constructs.
6105 * fi:                                   Conditional Constructs.
6106 * for:                                  Looping Constructs.
6107 * function:                             Shell Functions.
6108 * if:                                   Conditional Constructs.
6109 * in:                                   Conditional Constructs.
6110 * select:                               Korn Shell Constructs.
6111 * then:                                 Conditional Constructs.
6112 * time:                                 Pipelines.
6113 * until:                                Looping Constructs.
6114 * while:                                Looping Constructs.
6115
6116 \1f
6117 File: bashref.info,  Node: Variable Index,  Next: Function Index,  Prev: Reserved Word Index,  Up: Top
6118
6119 Parameter and Variable Index
6120 ****************************
6121
6122 * Menu:
6123
6124 * !:                                    Special Parameters.
6125 * #:                                    Special Parameters.
6126 * $:                                    Special Parameters.
6127 * *:                                    Special Parameters.
6128 * -:                                    Special Parameters.
6129 * 0:                                    Special Parameters.
6130 * ?:                                    Special Parameters.
6131 * @:                                    Special Parameters.
6132 * _:                                    Special Parameters.
6133 * auto_resume:                          Job Control Variables.
6134 * BASH:                                 Bash Variables.
6135 * BASH_VERSINFO:                        Bash Variables.
6136 * BASH_VERSION:                         Bash Variables.
6137 * bell-style:                           Readline Init File Syntax.
6138 * CDPATH:                               Bourne Shell Variables.
6139 * comment-begin:                        Readline Init File Syntax.
6140 * completion-query-items:               Readline Init File Syntax.
6141 * convert-meta:                         Readline Init File Syntax.
6142 * DIRSTACK:                             Bash Variables.
6143 * disable-completion:                   Readline Init File Syntax.
6144 * editing-mode:                         Readline Init File Syntax.
6145 * enable-keypad:                        Readline Init File Syntax.
6146 * ENV:                                  Korn Shell Variables.
6147 * EUID:                                 Bash Variables.
6148 * expand-tilde:                         Readline Init File Syntax.
6149 * FCEDIT:                               Korn Shell Variables.
6150 * FIGNORE:                              Bash Variables.
6151 * GLOBIGNORE:                           Bash Variables.
6152 * histchars:                            Bash Variables.
6153 * HISTCMD:                              Bash Variables.
6154 * HISTCONTROL:                          Bash Variables.
6155 * HISTFILE:                             Bash Variables.
6156 * HISTFILESIZE:                         Bash Variables.
6157 * HISTIGNORE:                           Bash Variables.
6158 * HISTSIZE:                             Bash Variables.
6159 * HOME:                                 Bourne Shell Variables.
6160 * horizontal-scroll-mode:               Readline Init File Syntax.
6161 * HOSTFILE:                             Bash Variables.
6162 * HOSTNAME:                             Bash Variables.
6163 * HOSTTYPE:                             Bash Variables.
6164 * IFS:                                  Bourne Shell Variables.
6165 * IGNOREEOF <1>:                        Bash Variables.
6166 * IGNOREEOF:                            C Shell Variables.
6167 * input-meta:                           Readline Init File Syntax.
6168 * INPUTRC:                              Bash Variables.
6169 * keymap:                               Readline Init File Syntax.
6170 * LANG:                                 Bash Variables.
6171 * LC_ALL:                               Bash Variables.
6172 * LC_MESSAGES:                          Bash Variables.
6173 * LINENO:                               Korn Shell Variables.
6174 * MACHTYPE:                             Bash Variables.
6175 * MAIL:                                 Bourne Shell Variables.
6176 * MAILCHECK:                            Bash Variables.
6177 * MAILPATH:                             Bourne Shell Variables.
6178 * mark-modified-lines:                  Readline Init File Syntax.
6179 * meta-flag:                            Readline Init File Syntax.
6180 * OLDPWD:                               Korn Shell Variables.
6181 * OPTARG:                               Bourne Shell Variables.
6182 * OPTERR:                               Bash Variables.
6183 * OPTIND:                               Bourne Shell Variables.
6184 * OSTYPE:                               Bash Variables.
6185 * output-meta:                          Readline Init File Syntax.
6186 * PATH:                                 Bourne Shell Variables.
6187 * PIPESTATUS:                           Bash Variables.
6188 * PPID:                                 Bash Variables.
6189 * PROMPT_COMMAND:                       Bash Variables.
6190 * PS1:                                  Bourne Shell Variables.
6191 * PS2:                                  Bourne Shell Variables.
6192 * PS3:                                  Korn Shell Variables.
6193 * PS4:                                  Korn Shell Variables.
6194 * PWD:                                  Korn Shell Variables.
6195 * RANDOM:                               Korn Shell Variables.
6196 * REPLY:                                Korn Shell Variables.
6197 * SECONDS:                              Korn Shell Variables.
6198 * SHELLOPTS:                            Bash Variables.
6199 * SHLVL:                                Bash Variables.
6200 * show-all-if-ambiguous:                Readline Init File Syntax.
6201 * TIMEFORMAT:                           Bash Variables.
6202 * TMOUT:                                Korn Shell Variables.
6203 * UID:                                  Bash Variables.
6204 * visible-stats:                        Readline Init File Syntax.
6205
6206 \1f
6207 File: bashref.info,  Node: Function Index,  Next: Concept Index,  Prev: Variable Index,  Up: Top
6208
6209 Function Index
6210 **************
6211
6212 * Menu:
6213
6214 * abort (C-g):                          Miscellaneous Commands.
6215 * accept-line (Newline, Return):        Commands For History.
6216 * backward-char (C-b):                  Commands For Moving.
6217 * backward-delete-char (Rubout):        Commands For Text.
6218 * backward-kill-line (C-x Rubout):      Commands For Killing.
6219 * backward-kill-word (M-DEL):           Commands For Killing.
6220 * backward-word (M-b):                  Commands For Moving.
6221 * beginning-of-history (M-<):           Commands For History.
6222 * beginning-of-line (C-a):              Commands For Moving.
6223 * call-last-kbd-macro (C-x e):          Keyboard Macros.
6224 * capitalize-word (M-c):                Commands For Text.
6225 * character-search (C-]):               Miscellaneous Commands.
6226 * character-search-backward (M-C-]):    Miscellaneous Commands.
6227 * clear-screen (C-l):                   Commands For Moving.
6228 * complete (TAB):                       Commands For Completion.
6229 * copy-backward-word ():                Commands For Killing.
6230 * copy-forward-word ():                 Commands For Killing.
6231 * copy-region-as-kill ():               Commands For Killing.
6232 * delete-char (C-d):                    Commands For Text.
6233 * delete-horizontal-space ():           Commands For Killing.
6234 * digit-argument (M-0, M-1, ... M-):    Numeric Arguments.
6235 * do-uppercase-version (M-a, M-b, M-X, ...): Miscellaneous Commands.
6236 * downcase-word (M-l):                  Commands For Text.
6237 * dump-functions ():                    Miscellaneous Commands.
6238 * dump-macros ():                       Miscellaneous Commands.
6239 * dump-variables ():                    Miscellaneous Commands.
6240 * end-kbd-macro (C-x )):                Keyboard Macros.
6241 * end-of-history (M->):                 Commands For History.
6242 * end-of-line (C-e):                    Commands For Moving.
6243 * exchange-point-and-mark (C-x C-x):    Miscellaneous Commands.
6244 * forward-char (C-f):                   Commands For Moving.
6245 * forward-search-history (C-s):         Commands For History.
6246 * forward-word (M-f):                   Commands For Moving.
6247 * history-search-backward ():           Commands For History.
6248 * history-search-forward ():            Commands For History.
6249 * insert-comment (M-#):                 Miscellaneous Commands.
6250 * insert-completions (M-*):             Commands For Completion.
6251 * kill-line (C-k):                      Commands For Killing.
6252 * kill-region ():                       Commands For Killing.
6253 * kill-whole-line ():                   Commands For Killing.
6254 * kill-word (M-d):                      Commands For Killing.
6255 * next-history (C-n):                   Commands For History.
6256 * non-incremental-forward-search-history (M-n): Commands For History.
6257 * non-incremental-reverse-search-history (M-p): Commands For History.
6258 * possible-completions (M-?):           Commands For Completion.
6259 * prefix-meta (ESC):                    Miscellaneous Commands.
6260 * previous-history (C-p):               Commands For History.
6261 * quoted-insert (C-q, C-v):             Commands For Text.
6262 * re-read-init-file (C-x C-r):          Miscellaneous Commands.
6263 * redraw-current-line ():               Commands For Moving.
6264 * reverse-search-history (C-r):         Commands For History.
6265 * revert-line (M-r):                    Miscellaneous Commands.
6266 * self-insert (a, b, A, 1, !, ...):     Commands For Text.
6267 * set-mark (C-@):                       Miscellaneous Commands.
6268 * start-kbd-macro (C-x ():              Keyboard Macros.
6269 * tab-insert (M-TAB):                   Commands For Text.
6270 * tilde-expand (M-~):                   Miscellaneous Commands.
6271 * transpose-chars (C-t):                Commands For Text.
6272 * transpose-words (M-t):                Commands For Text.
6273 * undo (C-_, C-x C-u):                  Miscellaneous Commands.
6274 * universal-argument ():                Numeric Arguments.
6275 * unix-line-discard (C-u):              Commands For Killing.
6276 * unix-word-rubout (C-w):               Commands For Killing.
6277 * upcase-word (M-u):                    Commands For Text.
6278 * yank (C-y):                           Commands For Killing.
6279 * yank-last-arg (M-., M-_):             Commands For History.
6280 * yank-nth-arg (M-C-y):                 Commands For History.
6281 * yank-pop (M-y):                       Commands For Killing.
6282
6283 \1f
6284 File: bashref.info,  Node: Concept Index,  Prev: Function Index,  Up: Top
6285
6286 Concept Index
6287 *************
6288
6289 * Menu:
6290
6291 * alias expansion:                      Aliases.
6292 * arithmetic evaluation:                Arithmetic Evaluation.
6293 * arithmetic expansion:                 Arithmetic Expansion.
6294 * arithmetic, shell:                    Shell Arithmetic.
6295 * arrays:                               Arrays.
6296 * background:                           Job Control Basics.
6297 * Bash configuration:                   Basic Installation.
6298 * Bash installation:                    Basic Installation.
6299 * Bourne shell:                         Basic Shell Features.
6300 * brace expansion:                      Brace Expansion.
6301 * builtin:                              Definitions.
6302 * command editing:                      Readline Bare Essentials.
6303 * command execution:                    Command Search and Execution.
6304 * command history:                      Bash History Facilities.
6305 * command search:                       Command Search and Execution.
6306 * command substitution:                 Command Substitution.
6307 * command timing:                       Pipelines.
6308 * commands, conditional:                Conditional Constructs.
6309 * commands, grouping:                   Command Grouping.
6310 * commands, lists:                      Lists.
6311 * commands, looping:                    Looping Constructs.
6312 * commands, pipelines:                  Pipelines.
6313 * commands, simple:                     Simple Commands.
6314 * comments, shell:                      Comments.
6315 * configuration:                        Basic Installation.
6316 * control operator:                     Definitions.
6317 * editing command lines:                Readline Bare Essentials.
6318 * environment:                          Environment.
6319 * evaluation, arithmetic:               Arithmetic Evaluation.
6320 * event designators:                    Event Designators.
6321 * exit status <1>:                      Definitions.
6322 * exit status:                          Exit Status.
6323 * expansion:                            Shell Expansions.
6324 * expansion, arithmetic:                Arithmetic Expansion.
6325 * expansion, brace:                     Brace Expansion.
6326 * expansion, filename:                  Filename Expansion.
6327 * expansion, parameter:                 Shell Parameter Expansion.
6328 * expansion, pathname:                  Filename Expansion.
6329 * expansion, tilde:                     Tilde Expansion.
6330 * expressions, arithmetic:              Arithmetic Evaluation.
6331 * expressions, conditional:             Bash Conditional Expressions.
6332 * field:                                Definitions.
6333 * filename:                             Definitions.
6334 * filename expansion:                   Filename Expansion.
6335 * foreground:                           Job Control Basics.
6336 * functions, shell:                     Shell Functions.
6337 * history events:                       Event Designators.
6338 * history expansion:                    History Interaction.
6339 * history list:                         Bash History Facilities.
6340 * History, how to use:                  Job Control Variables.
6341 * identifier:                           Definitions.
6342 * initialization file, readline:        Readline Init File.
6343 * installation:                         Basic Installation.
6344 * interaction, readline:                Readline Interaction.
6345 * interactive shell <1>:                Is This Shell Interactive?.
6346 * interactive shell:                    Invoking Bash.
6347 * job:                                  Definitions.
6348 * job control <1>:                      Definitions.
6349 * job control:                          Job Control Basics.
6350 * kill ring:                            Readline Killing Commands.
6351 * killing text:                         Readline Killing Commands.
6352 * localization:                         Locale Translation.
6353 * metacharacter:                        Definitions.
6354 * name:                                 Definitions.
6355 * notation, readline:                   Readline Bare Essentials.
6356 * operator, shell:                      Definitions.
6357 * parameter expansion:                  Shell Parameter Expansion.
6358 * parameters:                           Shell Parameters.
6359 * parameters, positional:               Positional Parameters.
6360 * parameters, special:                  Special Parameters.
6361 * pathname expansion:                   Filename Expansion.
6362 * pipeline:                             Pipelines.
6363 * POSIX:                                Definitions.
6364 * POSIX Mode:                           Bash POSIX Mode.
6365 * process group:                        Definitions.
6366 * process group ID:                     Definitions.
6367 * process substitution:                 Process Substitution.
6368 * prompting:                            Printing a Prompt.
6369 * quoting:                              Quoting.
6370 * quoting, ANSI:                        ANSI-C Quoting.
6371 * Readline, how to use:                 Modifiers.
6372 * redirection:                          Redirections.
6373 * reserved word:                        Definitions.
6374 * restricted shell:                     The Restricted Shell.
6375 * return status:                        Definitions.
6376 * shell function:                       Shell Functions.
6377 * shell script:                         Shell Scripts.
6378 * shell variable:                       Shell Parameters.
6379 * signal:                               Definitions.
6380 * signal handling:                      Signals.
6381 * special builtin:                      Definitions.
6382 * startup files:                        Bash Startup Files.
6383 * suspending jobs:                      Job Control Basics.
6384 * tilde expansion:                      Tilde Expansion.
6385 * token:                                Definitions.
6386 * variable, shell:                      Shell Parameters.
6387 * word:                                 Definitions.
6388 * word splitting:                       Word Splitting.
6389 * yanking text:                         Readline Killing Commands.
6390
6391
6392 \1f
6393 Tag Table:
6394 Node: Top\7f1009
6395 Node: Introduction\7f3117
6396 Node: What is Bash?\7f3342
6397 Node: What is a shell?\7f4426
6398 Node: Definitions\7f6307
6399 Node: Basic Shell Features\7f8947
6400 Node: Shell Syntax\7f10468
6401 Node: Shell Operation\7f10758
6402 Node: Quoting\7f11992
6403 Node: Escape Character\7f13027
6404 Node: Single Quotes\7f13458
6405 Node: Double Quotes\7f13787
6406 Node: ANSI-C Quoting\7f14483
6407 Node: Locale Translation\7f15215
6408 Node: Comments\7f15636
6409 Node: Simple Commands\7f16160
6410 Node: Pipelines\7f16749
6411 Node: Lists\7f17820
6412 Node: Looping Constructs\7f19095
6413 Node: Conditional Constructs\7f20272
6414 Node: Command Grouping\7f22337
6415 Node: Shell Functions\7f23721
6416 Node: Shell Parameters\7f25489
6417 Node: Positional Parameters\7f26812
6418 Node: Special Parameters\7f27506
6419 Node: Shell Expansions\7f29998
6420 Node: Shell Parameter Expansion\7f31998
6421 Node: Command Substitution\7f38003
6422 Node: Process Substitution\7f39003
6423 Node: Word Splitting\7f39909
6424 Node: Filename Expansion\7f41361
6425 Node: Quote Removal\7f43727
6426 Node: Redirections\7f44013
6427 Node: Executing Commands\7f49754
6428 Node: Command Search and Execution\7f50209
6429 Node: Environment\7f51943
6430 Node: Exit Status\7f53579
6431 Node: Signals\7f54596
6432 Node: Shell Scripts\7f55807
6433 Node: Bourne Shell Features\7f57676
6434 Node: Bourne Shell Builtins\7f58346
6435 Node: Bourne Shell Variables\7f66619
6436 Node: Other Bourne Shell Features\7f68156
6437 Node: Major Differences From The Bourne Shell\7f68913
6438 Node: Csh Features\7f79111
6439 Node: Brace Expansion\7f80029
6440 Node: Tilde Expansion\7f81584
6441 Node: C Shell Builtins\7f82216
6442 Node: C Shell Variables\7f86732
6443 Node: Korn Shell Features\7f87140
6444 Node: Korn Shell Constructs\7f87868
6445 Node: Korn Shell Builtins\7f89562
6446 Node: Korn Shell Variables\7f91720
6447 Node: Aliases\7f93505
6448 Node: Alias Builtins\7f95969
6449 Node: Bash Features\7f96585
6450 Node: Invoking Bash\7f97576
6451 Node: Bash Startup Files\7f101441
6452 Node: Is This Shell Interactive?\7f105024
6453 Node: Bash Builtins\7f105755
6454 Node: The Set Builtin\7f121569
6455 Node: Bash Conditional Expressions\7f126939
6456 Node: Bash Variables\7f131590
6457 Node: Shell Arithmetic\7f141103
6458 Node: Arithmetic Evaluation\7f141571
6459 Node: Arithmetic Expansion\7f143601
6460 Node: Arithmetic Builtins\7f144405
6461 Node: Arrays\7f144876
6462 Node: Printing a Prompt\7f147903
6463 Node: The Restricted Shell\7f149501
6464 Node: Bash POSIX Mode\7f150731
6465 Node: Job Control\7f154303
6466 Node: Job Control Basics\7f154768
6467 Node: Job Control Builtins\7f158911
6468 Node: Job Control Variables\7f161794
6469 Node: Using History Interactively\7f162955
6470 Node: Bash History Facilities\7f163544
6471 Node: History Interaction\7f165942
6472 Node: Event Designators\7f168504
6473 Node: Word Designators\7f169427
6474 Node: Modifiers\7f170676
6475 Node: Command Line Editing\7f171993
6476 Node: Introduction and Notation\7f172653
6477 Node: Readline Interaction\7f173661
6478 Node: Readline Bare Essentials\7f174849
6479 Node: Readline Movement Commands\7f176378
6480 Node: Readline Killing Commands\7f177268
6481 Node: Readline Arguments\7f178970
6482 Node: Searching\7f179943
6483 Node: Readline Init File\7f181579
6484 Node: Readline Init File Syntax\7f182635
6485 Node: Conditional Init Constructs\7f190424
6486 Node: Sample Init File\7f192705
6487 Node: Bindable Readline Commands\7f195722
6488 Node: Commands For Moving\7f196472
6489 Node: Commands For History\7f197319
6490 Node: Commands For Text\7f199992
6491 Node: Commands For Killing\7f201734
6492 Node: Numeric Arguments\7f203760
6493 Node: Commands For Completion\7f204386
6494 Node: Keyboard Macros\7f207348
6495 Node: Miscellaneous Commands\7f207906
6496 Node: Readline vi Mode\7f211937
6497 Node: Installing Bash\7f212813
6498 Node: Basic Installation\7f213890
6499 Node: Compilers and Options\7f216389
6500 Node: Compiling For Multiple Architectures\7f217123
6501 Node: Installation Names\7f218780
6502 Node: Specifying the System Type\7f219502
6503 Node: Sharing Defaults\7f220213
6504 Node: Operation Controls\7f220878
6505 Node: Optional Features\7f221783
6506 Node: Reporting Bugs\7f226408
6507 Node: Builtin Index\7f227485
6508 Node: Reserved Word Index\7f230898
6509 Node: Variable Index\7f232206
6510 Node: Function Index\7f237285
6511 Node: Concept Index\7f241643
6512 \1f
6513 End Tag Table