1 This is bashref.info, produced by makeinfo version 4.13 from
2 /usr/homes/chet/src/bash/src/doc/bashref.texi.
4 This text is a brief description of the features that are present in
5 the Bash shell (version 4.3, 2 February 2014).
7 This is Edition 4.3, last updated 2 February 2014, of `The GNU Bash
8 Reference Manual', for `Bash', Version 4.3.
10 Copyright (C) 1988-2014 Free Software Foundation, Inc.
12 Permission is granted to copy, distribute and/or modify this
13 document under the terms of the GNU Free Documentation License,
14 Version 1.3 or any later version published by the Free Software
15 Foundation; with no Invariant Sections, no Front-Cover Texts, and
16 no Back-Cover Texts. A copy of the license is included in the
17 section entitled "GNU Free Documentation License".
19 INFO-DIR-SECTION Basics
21 * Bash: (bash). The GNU Bourne-Again SHell.
25 File: bashref.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir)
30 This text is a brief description of the features that are present in
31 the Bash shell (version 4.3, 2 February 2014). The Bash home page is
32 `http://www.gnu.org/software/bash/'.
34 This is Edition 4.3, last updated 2 February 2014, of `The GNU Bash
35 Reference Manual', for `Bash', Version 4.3.
37 Bash contains features that appear in other popular shells, and some
38 features that only appear in Bash. Some of the shells that Bash has
39 borrowed concepts from are the Bourne Shell (`sh'), the Korn Shell
40 (`ksh'), and the C-shell (`csh' and its successor, `tcsh'). The
41 following menu breaks the features up into categories, noting which
42 features were inspired by other shells and which are specific to Bash.
44 This manual is meant as a brief introduction to features found in
45 Bash. The Bash manual page should be used as the definitive reference
50 * Introduction:: An introduction to the shell.
51 * Definitions:: Some definitions used in the rest of this
53 * Basic Shell Features:: The shell "building blocks".
54 * Shell Builtin Commands:: Commands that are a part of the shell.
55 * Shell Variables:: Variables used or set by Bash.
56 * Bash Features:: Features found only in Bash.
57 * Job Control:: What job control is and how Bash allows you
59 * Command Line Editing:: Chapter describing the command line
61 * Using History Interactively:: Command History Expansion
62 * Installing Bash:: How to build and install Bash on your system.
63 * Reporting Bugs:: How to report bugs in Bash.
64 * Major Differences From The Bourne Shell:: A terse list of the differences
65 between Bash and historical
67 * GNU Free Documentation License:: Copying and sharing this documentation.
68 * Indexes:: Various indexes for this manual.
71 File: bashref.info, Node: Introduction, Next: Definitions, Prev: Top, Up: Top
78 * What is Bash?:: A short description of Bash.
79 * What is a shell?:: A brief introduction to shells.
82 File: bashref.info, Node: What is Bash?, Next: What is a shell?, Up: Introduction
87 Bash is the shell, or command language interpreter, for the GNU
88 operating system. The name is an acronym for the `Bourne-Again SHell',
89 a pun on Stephen Bourne, the author of the direct ancestor of the
90 current Unix shell `sh', which appeared in the Seventh Edition Bell
91 Labs Research version of Unix.
93 Bash is largely compatible with `sh' and incorporates useful
94 features from the Korn shell `ksh' and the C shell `csh'. It is
95 intended to be a conformant implementation of the IEEE POSIX Shell and
96 Tools portion of the IEEE POSIX specification (IEEE Standard 1003.1).
97 It offers functional improvements over `sh' for both interactive and
100 While the GNU operating system provides other shells, including a
101 version of `csh', Bash is the default shell. Like other GNU software,
102 Bash is quite portable. It currently runs on nearly every version of
103 Unix and a few other operating systems - independently-supported ports
104 exist for MS-DOS, OS/2, and Windows platforms.
107 File: bashref.info, Node: What is a shell?, Prev: What is Bash?, Up: Introduction
112 At its base, a shell is simply a macro processor that executes
113 commands. The term macro processor means functionality where text and
114 symbols are expanded to create larger expressions.
116 A Unix shell is both a command interpreter and a programming
117 language. As a command interpreter, the shell provides the user
118 interface to the rich set of GNU utilities. The programming language
119 features allow these utilities to be combined. Files containing
120 commands can be created, and become commands themselves. These new
121 commands have the same status as system commands in directories such as
122 `/bin', allowing users or groups to establish custom environments to
123 automate their common tasks.
125 Shells may be used interactively or non-interactively. In
126 interactive mode, they accept input typed from the keyboard. When
127 executing non-interactively, shells execute commands read from a file.
129 A shell allows execution of GNU commands, both synchronously and
130 asynchronously. The shell waits for synchronous commands to complete
131 before accepting more input; asynchronous commands continue to execute
132 in parallel with the shell while it reads and executes additional
133 commands. The "redirection" constructs permit fine-grained control of
134 the input and output of those commands. Moreover, the shell allows
135 control over the contents of commands' environments.
137 Shells also provide a small set of built-in commands ("builtins")
138 implementing functionality impossible or inconvenient to obtain via
139 separate utilities. For example, `cd', `break', `continue', and `exec'
140 cannot be implemented outside of the shell because they directly
141 manipulate the shell itself. The `history', `getopts', `kill', or `pwd'
142 builtins, among others, could be implemented in separate utilities, but
143 they are more convenient to use as builtin commands. All of the shell
144 builtins are described in subsequent sections.
146 While executing commands is essential, most of the power (and
147 complexity) of shells is due to their embedded programming languages.
148 Like any high-level language, the shell provides variables, flow
149 control constructs, quoting, and functions.
151 Shells offer features geared specifically for interactive use rather
152 than to augment the programming language. These interactive features
153 include job control, command line editing, command history and aliases.
154 Each of these features is described in this manual.
157 File: bashref.info, Node: Definitions, Next: Basic Shell Features, Prev: Introduction, Up: Top
162 These definitions are used throughout the remainder of this manual.
165 A family of open system standards based on Unix. Bash is
166 primarily concerned with the Shell and Utilities portion of the
167 POSIX 1003.1 standard.
170 A space or tab character.
173 A command that is implemented internally by the shell itself,
174 rather than by an executable program somewhere in the file system.
177 A `token' that performs a control function. It is a `newline' or
178 one of the following: `||', `&&', `&', `;', `;;', `|', `|&', `(',
182 The value returned by a command to its caller. The value is
183 restricted to eight bits, so the maximum value is 255.
186 A unit of text that is the result of one of the shell expansions.
187 After expansion, when executing a command, the resulting fields
188 are used as the command name and arguments.
191 A string of characters used to identify a file.
194 A set of processes comprising a pipeline, and any processes
195 descended from it, that are all in the same process group.
198 A mechanism by which users can selectively stop (suspend) and
199 restart (resume) execution of processes.
202 A character that, when unquoted, separates words. A metacharacter
203 is a `blank' or one of the following characters: `|', `&', `;',
204 `(', `)', `<', or `>'.
207 A `word' consisting solely of letters, numbers, and underscores,
208 and beginning with a letter or underscore. `Name's are used as
209 shell variable and function names. Also referred to as an
213 A `control operator' or a `redirection operator'. *Note
214 Redirections::, for a list of redirection operators. Operators
215 contain at least one unquoted `metacharacter'.
218 A collection of related processes each having the same process
222 A unique identifier that represents a `process group' during its
226 A `word' that has a special meaning to the shell. Most reserved
227 words introduce shell flow control constructs, such as `for' and
231 A synonym for `exit status'.
234 A mechanism by which a process may be notified by the kernel of an
235 event occurring in the system.
238 A shell builtin command that has been classified as special by the
242 A sequence of characters considered a single unit by the shell.
243 It is either a `word' or an `operator'.
246 A sequence of characters treated as a unit by the shell. Words
247 may not include unquoted `metacharacters'.
250 File: bashref.info, Node: Basic Shell Features, Next: Shell Builtin Commands, Prev: Definitions, Up: Top
252 3 Basic Shell Features
253 **********************
255 Bash is an acronym for `Bourne-Again SHell'. The Bourne shell is the
256 traditional Unix shell originally written by Stephen Bourne. All of
257 the Bourne shell builtin commands are available in Bash, The rules for
258 evaluation and quoting are taken from the POSIX specification for the
259 `standard' Unix shell.
261 This chapter briefly summarizes the shell's `building blocks':
262 commands, control structures, shell functions, shell parameters, shell
263 expansions, redirections, which are a way to direct input and output
264 from and to named files, and how the shell executes commands.
268 * Shell Syntax:: What your input means to the shell.
269 * Shell Commands:: The types of commands you can use.
270 * Shell Functions:: Grouping commands by name.
271 * Shell Parameters:: How the shell stores values.
272 * Shell Expansions:: How Bash expands parameters and the various
273 expansions available.
274 * Redirections:: A way to control where input and output go.
275 * Executing Commands:: What happens when you run a command.
276 * Shell Scripts:: Executing files of shell commands.
279 File: bashref.info, Node: Shell Syntax, Next: Shell Commands, Up: Basic Shell Features
286 * Shell Operation:: The basic operation of the shell.
287 * Quoting:: How to remove the special meaning from characters.
288 * Comments:: How to specify comments.
290 When the shell reads input, it proceeds through a sequence of
291 operations. If the input indicates the beginning of a comment, the
292 shell ignores the comment symbol (`#'), and the rest of that line.
294 Otherwise, roughly speaking, the shell reads its input and divides
295 the input into words and operators, employing the quoting rules to
296 select which meanings to assign various words and characters.
298 The shell then parses these tokens into commands and other
299 constructs, removes the special meaning of certain words or characters,
300 expands others, redirects input and output as needed, executes the
301 specified command, waits for the command's exit status, and makes that
302 exit status available for further inspection or processing.
305 File: bashref.info, Node: Shell Operation, Next: Quoting, Up: Shell Syntax
307 3.1.1 Shell Operation
308 ---------------------
310 The following is a brief description of the shell's operation when it
311 reads and executes a command. Basically, the shell does the following:
313 1. Reads its input from a file (*note Shell Scripts::), from a string
314 supplied as an argument to the `-c' invocation option (*note
315 Invoking Bash::), or from the user's terminal.
317 2. Breaks the input into words and operators, obeying the quoting
318 rules described in *note Quoting::. These tokens are separated by
319 `metacharacters'. Alias expansion is performed by this step
322 3. Parses the tokens into simple and compound commands (*note Shell
325 4. Performs the various shell expansions (*note Shell Expansions::),
326 breaking the expanded tokens into lists of filenames (*note
327 Filename Expansion::) and commands and arguments.
329 5. Performs any necessary redirections (*note Redirections::) and
330 removes the redirection operators and their operands from the
333 6. Executes the command (*note Executing Commands::).
335 7. Optionally waits for the command to complete and collects its exit
336 status (*note Exit Status::).
340 File: bashref.info, Node: Quoting, Next: Comments, Prev: Shell Operation, Up: Shell Syntax
347 * Escape Character:: How to remove the special meaning from a single
349 * Single Quotes:: How to inhibit all interpretation of a sequence
351 * Double Quotes:: How to suppress most of the interpretation of a
352 sequence of characters.
353 * ANSI-C Quoting:: How to expand ANSI-C sequences in quoted strings.
354 * Locale Translation:: How to translate strings into different languages.
356 Quoting is used to remove the special meaning of certain characters
357 or words to the shell. Quoting can be used to disable special
358 treatment for special characters, to prevent reserved words from being
359 recognized as such, and to prevent parameter expansion.
361 Each of the shell metacharacters (*note Definitions::) has special
362 meaning to the shell and must be quoted if it is to represent itself.
363 When the command history expansion facilities are being used (*note
364 History Interaction::), the HISTORY EXPANSION character, usually `!',
365 must be quoted to prevent history expansion. *Note Bash History
366 Facilities::, for more details concerning history expansion.
368 There are three quoting mechanisms: the ESCAPE CHARACTER, single
369 quotes, and double quotes.
372 File: bashref.info, Node: Escape Character, Next: Single Quotes, Up: Quoting
374 3.1.2.1 Escape Character
375 ........................
377 A non-quoted backslash `\' is the Bash escape character. It preserves
378 the literal value of the next character that follows, with the
379 exception of `newline'. If a `\newline' pair appears, and the
380 backslash itself is not quoted, the `\newline' is treated as a line
381 continuation (that is, it is removed from the input stream and
382 effectively ignored).
385 File: bashref.info, Node: Single Quotes, Next: Double Quotes, Prev: Escape Character, Up: Quoting
387 3.1.2.2 Single Quotes
388 .....................
390 Enclosing characters in single quotes (`'') preserves the literal value
391 of each character within the quotes. A single quote may not occur
392 between single quotes, even when preceded by a backslash.
395 File: bashref.info, Node: Double Quotes, Next: ANSI-C Quoting, Prev: Single Quotes, Up: Quoting
397 3.1.2.3 Double Quotes
398 .....................
400 Enclosing characters in double quotes (`"') preserves the literal value
401 of all characters within the quotes, with the exception of `$', ``',
402 `\', and, when history expansion is enabled, `!'. The characters `$'
403 and ``' retain their special meaning within double quotes (*note Shell
404 Expansions::). The backslash retains its special meaning only when
405 followed by one of the following characters: `$', ``', `"', `\', or
406 `newline'. Within double quotes, backslashes that are followed by one
407 of these characters are removed. Backslashes preceding characters
408 without a special meaning are left unmodified. A double quote may be
409 quoted within double quotes by preceding it with a backslash. If
410 enabled, history expansion will be performed unless an `!' appearing in
411 double quotes is escaped using a backslash. The backslash preceding
412 the `!' is not removed.
414 The special parameters `*' and `@' have special meaning when in
415 double quotes (*note Shell Parameter Expansion::).
418 File: bashref.info, Node: ANSI-C Quoting, Next: Locale Translation, Prev: Double Quotes, Up: Quoting
420 3.1.2.4 ANSI-C Quoting
421 ......................
423 Words of the form `$'STRING'' are treated specially. The word expands
424 to STRING, with backslash-escaped characters replaced as specified by
425 the ANSI C standard. Backslash escape sequences, if present, are
436 an escape character (not ANSI C)
463 the eight-bit character whose value is the octal value NNN (one to
467 the eight-bit character whose value is the hexadecimal value HH
468 (one or two hex digits)
471 the Unicode (ISO/IEC 10646) character whose value is the
472 hexadecimal value HHHH (one to four hex digits)
475 the Unicode (ISO/IEC 10646) character whose value is the
476 hexadecimal value HHHHHHHH (one to eight hex digits)
479 a control-X character
481 The expanded result is single-quoted, as if the dollar sign had not
485 File: bashref.info, Node: Locale Translation, Prev: ANSI-C Quoting, Up: Quoting
487 3.1.2.5 Locale-Specific Translation
488 ...................................
490 A double-quoted string preceded by a dollar sign (`$') will cause the
491 string to be translated according to the current locale. If the
492 current locale is `C' or `POSIX', the dollar sign is ignored. If the
493 string is translated and replaced, the replacement is double-quoted.
495 Some systems use the message catalog selected by the `LC_MESSAGES'
496 shell variable. Others create the name of the message catalog from the
497 value of the `TEXTDOMAIN' shell variable, possibly adding a suffix of
498 `.mo'. If you use the `TEXTDOMAIN' variable, you may need to set the
499 `TEXTDOMAINDIR' variable to the location of the message catalog files.
500 Still others use both variables in this fashion:
501 `TEXTDOMAINDIR'/`LC_MESSAGES'/LC_MESSAGES/`TEXTDOMAIN'.mo.
504 File: bashref.info, Node: Comments, Prev: Quoting, Up: Shell Syntax
509 In a non-interactive shell, or an interactive shell in which the
510 `interactive_comments' option to the `shopt' builtin is enabled (*note
511 The Shopt Builtin::), a word beginning with `#' causes that word and
512 all remaining characters on that line to be ignored. An interactive
513 shell without the `interactive_comments' option enabled does not allow
514 comments. The `interactive_comments' option is on by default in
515 interactive shells. *Note Interactive Shells::, for a description of
516 what makes a shell interactive.
519 File: bashref.info, Node: Shell Commands, Next: Shell Functions, Prev: Shell Syntax, Up: Basic Shell Features
524 A simple shell command such as `echo a b c' consists of the command
525 itself followed by arguments, separated by spaces.
527 More complex shell commands are composed of simple commands arranged
528 together in a variety of ways: in a pipeline in which the output of one
529 command becomes the input of a second, in a loop or conditional
530 construct, or in some other grouping.
534 * Simple Commands:: The most common type of command.
535 * Pipelines:: Connecting the input and output of several
537 * Lists:: How to execute commands sequentially.
538 * Compound Commands:: Shell commands for control flow.
539 * Coprocesses:: Two-way communication between commands.
540 * GNU Parallel:: Running commands in parallel.
543 File: bashref.info, Node: Simple Commands, Next: Pipelines, Up: Shell Commands
545 3.2.1 Simple Commands
546 ---------------------
548 A simple command is the kind of command encountered most often. It's
549 just a sequence of words separated by `blank's, terminated by one of
550 the shell's control operators (*note Definitions::). The first word
551 generally specifies a command to be executed, with the rest of the
552 words being that command's arguments.
554 The return status (*note Exit Status::) of a simple command is its
555 exit status as provided by the POSIX 1003.1 `waitpid' function, or
556 128+N if the command was terminated by signal N.
559 File: bashref.info, Node: Pipelines, Next: Lists, Prev: Simple Commands, Up: Shell Commands
564 A `pipeline' is a sequence of simple commands separated by one of the
565 control operators `|' or `|&'.
567 The format for a pipeline is
568 [time [-p]] [!] COMMAND1 [ | or |& COMMAND2 ] ...
570 The output of each command in the pipeline is connected via a pipe to
571 the input of the next command. That is, each command reads the
572 previous command's output. This connection is performed before any
573 redirections specified by the command.
575 If `|&' is used, COMMAND1's standard error, in addition to its
576 standard output, is connected to COMMAND2's standard input through the
577 pipe; it is shorthand for `2>&1 |'. This implicit redirection of the
578 standard error to the standard output is performed after any
579 redirections specified by the command.
581 The reserved word `time' causes timing statistics to be printed for
582 the pipeline once it finishes. The statistics currently consist of
583 elapsed (wall-clock) time and user and system time consumed by the
584 command's execution. The `-p' option changes the output format to that
585 specified by POSIX. When the shell is in POSIX mode (*note Bash POSIX
586 Mode::), it does not recognize `time' as a reserved word if the next
587 token begins with a `-'. The `TIMEFORMAT' variable may be set to a
588 format string that specifies how the timing information should be
589 displayed. *Note Bash Variables::, for a description of the available
590 formats. The use of `time' as a reserved word permits the timing of
591 shell builtins, shell functions, and pipelines. An external `time'
592 command cannot time these easily.
594 When the shell is in POSIX mode (*note Bash POSIX Mode::), `time'
595 may be followed by a newline. In this case, the shell displays the
596 total user and system time consumed by the shell and its children. The
597 `TIMEFORMAT' variable may be used to specify the format of the time
600 If the pipeline is not executed asynchronously (*note Lists::), the
601 shell waits for all commands in the pipeline to complete.
603 Each command in a pipeline is executed in its own subshell (*note
604 Command Execution Environment::). The exit status of a pipeline is the
605 exit status of the last command in the pipeline, unless the `pipefail'
606 option is enabled (*note The Set Builtin::). If `pipefail' is enabled,
607 the pipeline's return status is the value of the last (rightmost)
608 command to exit with a non-zero status, or zero if all commands exit
609 successfully. If the reserved word `!' precedes the pipeline, the exit
610 status is the logical negation of the exit status as described above.
611 The shell waits for all commands in the pipeline to terminate before
615 File: bashref.info, Node: Lists, Next: Compound Commands, Prev: Pipelines, Up: Shell Commands
617 3.2.3 Lists of Commands
618 -----------------------
620 A `list' is a sequence of one or more pipelines separated by one of the
621 operators `;', `&', `&&', or `||', and optionally terminated by one of
622 `;', `&', or a `newline'.
624 Of these list operators, `&&' and `||' have equal precedence,
625 followed by `;' and `&', which have equal precedence.
627 A sequence of one or more newlines may appear in a `list' to delimit
628 commands, equivalent to a semicolon.
630 If a command is terminated by the control operator `&', the shell
631 executes the command asynchronously in a subshell. This is known as
632 executing the command in the BACKGROUND. The shell does not wait for
633 the command to finish, and the return status is 0 (true). When job
634 control is not active (*note Job Control::), the standard input for
635 asynchronous commands, in the absence of any explicit redirections, is
636 redirected from `/dev/null'.
638 Commands separated by a `;' are executed sequentially; the shell
639 waits for each command to terminate in turn. The return status is the
640 exit status of the last command executed.
642 AND and OR lists are sequences of one or more pipelines separated by
643 the control operators `&&' and `||', respectively. AND and OR lists
644 are executed with left associativity.
646 An AND list has the form
649 COMMAND2 is executed if, and only if, COMMAND1 returns an exit status
652 An OR list has the form
655 COMMAND2 is executed if, and only if, COMMAND1 returns a non-zero exit
658 The return status of AND and OR lists is the exit status of the last
659 command executed in the list.
662 File: bashref.info, Node: Compound Commands, Next: Coprocesses, Prev: Lists, Up: Shell Commands
664 3.2.4 Compound Commands
665 -----------------------
669 * Looping Constructs:: Shell commands for iterative action.
670 * Conditional Constructs:: Shell commands for conditional execution.
671 * Command Grouping:: Ways to group commands.
673 Compound commands are the shell programming constructs. Each
674 construct begins with a reserved word or control operator and is
675 terminated by a corresponding reserved word or operator. Any
676 redirections (*note Redirections::) associated with a compound command
677 apply to all commands within that compound command unless explicitly
680 In most cases a list of commands in a compound command's description
681 may be separated from the rest of the command by one or more newlines,
682 and may be followed by a newline in place of a semicolon.
684 Bash provides looping constructs, conditional commands, and
685 mechanisms to group commands and execute them as a unit.
688 File: bashref.info, Node: Looping Constructs, Next: Conditional Constructs, Up: Compound Commands
690 3.2.4.1 Looping Constructs
691 ..........................
693 Bash supports the following looping constructs.
695 Note that wherever a `;' appears in the description of a command's
696 syntax, it may be replaced with one or more newlines.
699 The syntax of the `until' command is:
701 until TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
703 Execute CONSEQUENT-COMMANDS as long as TEST-COMMANDS has an exit
704 status which is not zero. The return status is the exit status of
705 the last command executed in CONSEQUENT-COMMANDS, or zero if none
709 The syntax of the `while' command is:
711 while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done
713 Execute CONSEQUENT-COMMANDS as long as TEST-COMMANDS has an exit
714 status of zero. The return status is the exit status of the last
715 command executed in CONSEQUENT-COMMANDS, or zero if none was
719 The syntax of the `for' command is:
721 for NAME [ [in [WORDS ...] ] ; ] do COMMANDS; done
723 Expand WORDS, and execute COMMANDS once for each member in the
724 resultant list, with NAME bound to the current member. If `in
725 WORDS' is not present, the `for' command executes the COMMANDS
726 once for each positional parameter that is set, as if `in "$@"'
727 had been specified (*note Special Parameters::). The return
728 status is the exit status of the last command that executes. If
729 there are no items in the expansion of WORDS, no commands are
730 executed, and the return status is zero.
732 An alternate form of the `for' command is also supported:
734 for (( EXPR1 ; EXPR2 ; EXPR3 )) ; do COMMANDS ; done
736 First, the arithmetic expression EXPR1 is evaluated according to
737 the rules described below (*note Shell Arithmetic::). The
738 arithmetic expression EXPR2 is then evaluated repeatedly until it
739 evaluates to zero. Each time EXPR2 evaluates to a non-zero value,
740 COMMANDS are executed and the arithmetic expression EXPR3 is
741 evaluated. If any expression is omitted, it behaves as if it
742 evaluates to 1. The return value is the exit status of the last
743 command in COMMANDS that is executed, or false if any of the
744 expressions is invalid.
746 The `break' and `continue' builtins (*note Bourne Shell Builtins::)
747 may be used to control loop execution.
750 File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Prev: Looping Constructs, Up: Compound Commands
752 3.2.4.2 Conditional Constructs
753 ..............................
756 The syntax of the `if' command is:
758 if TEST-COMMANDS; then
760 [elif MORE-TEST-COMMANDS; then
762 [else ALTERNATE-CONSEQUENTS;]
765 The TEST-COMMANDS list is executed, and if its return status is
766 zero, the CONSEQUENT-COMMANDS list is executed. If TEST-COMMANDS
767 returns a non-zero status, each `elif' list is executed in turn,
768 and if its exit status is zero, the corresponding MORE-CONSEQUENTS
769 is executed and the command completes. If `else
770 ALTERNATE-CONSEQUENTS' is present, and the final command in the
771 final `if' or `elif' clause has a non-zero exit status, then
772 ALTERNATE-CONSEQUENTS is executed. The return status is the exit
773 status of the last command executed, or zero if no condition
777 The syntax of the `case' command is:
779 case WORD in [ [(] PATTERN [| PATTERN]...) COMMAND-LIST ;;]... esac
781 `case' will selectively execute the COMMAND-LIST corresponding to
782 the first PATTERN that matches WORD. If the shell option
783 `nocasematch' (see the description of `shopt' in *note The Shopt
784 Builtin::) is enabled, the match is performed without regard to
785 the case of alphabetic characters. The `|' is used to separate
786 multiple patterns, and the `)' operator terminates a pattern list.
787 A list of patterns and an associated command-list is known as a
790 Each clause must be terminated with `;;', `;&', or `;;&'. The
791 WORD undergoes tilde expansion, parameter expansion, command
792 substitution, arithmetic expansion, and quote removal before
793 matching is attempted. Each PATTERN undergoes tilde expansion,
794 parameter expansion, command substitution, and arithmetic
797 There may be an arbitrary number of `case' clauses, each terminated
798 by a `;;', `;&', or `;;&'. The first pattern that matches
799 determines the command-list that is executed. It's a common idiom
800 to use `*' as the final pattern to define the default case, since
801 that pattern will always match.
803 Here is an example using `case' in a script that could be used to
804 describe one interesting feature of an animal:
806 echo -n "Enter the name of an animal: "
808 echo -n "The $ANIMAL has "
810 horse | dog | cat) echo -n "four";;
811 man | kangaroo ) echo -n "two";;
812 *) echo -n "an unknown number of";;
816 If the `;;' operator is used, no subsequent matches are attempted
817 after the first pattern match. Using `;&' in place of `;;'
818 causes execution to continue with the COMMAND-LIST associated with
819 the next clause, if any. Using `;;&' in place of `;;' causes the
820 shell to test the patterns in the next clause, if any, and execute
821 any associated COMMAND-LIST on a successful match.
823 The return status is zero if no PATTERN is matched. Otherwise, the
824 return status is the exit status of the COMMAND-LIST executed.
827 The `select' construct allows the easy generation of menus. It
828 has almost the same syntax as the `for' command:
830 select NAME [in WORDS ...]; do COMMANDS; done
832 The list of words following `in' is expanded, generating a list of
833 items. The set of expanded words is printed on the standard error
834 output stream, each preceded by a number. If the `in WORDS' is
835 omitted, the positional parameters are printed, as if `in "$@"'
836 had been specified. The `PS3' prompt is then displayed and a line
837 is read from the standard input. If the line consists of a number
838 corresponding to one of the displayed words, then the value of
839 NAME is set to that word. If the line is empty, the words and
840 prompt are displayed again. If `EOF' is read, the `select'
841 command completes. Any other value read causes NAME to be set to
842 null. The line read is saved in the variable `REPLY'.
844 The COMMANDS are executed after each selection until a `break'
845 command is executed, at which point the `select' command completes.
847 Here is an example that allows the user to pick a filename from the
848 current directory, and displays the name and index of the file
853 echo you picked $fname \($REPLY\)
860 The arithmetic EXPRESSION is evaluated according to the rules
861 described below (*note Shell Arithmetic::). If the value of the
862 expression is non-zero, the return status is 0; otherwise the
863 return status is 1. This is exactly equivalent to
865 *Note Bash Builtins::, for a full description of the `let' builtin.
870 Return a status of 0 or 1 depending on the evaluation of the
871 conditional expression EXPRESSION. Expressions are composed of
872 the primaries described below in *note Bash Conditional
873 Expressions::. Word splitting and filename expansion are not
874 performed on the words between the `[[' and `]]'; tilde expansion,
875 parameter and variable expansion, arithmetic expansion, command
876 substitution, process substitution, and quote removal are
877 performed. Conditional operators such as `-f' must be unquoted to
878 be recognized as primaries.
880 When used with `[[', the `<' and `>' operators sort
881 lexicographically using the current locale.
883 When the `==' and `!=' operators are used, the string to the right
884 of the operator is considered a pattern and matched according to
885 the rules described below in *note Pattern Matching::, as if the
886 `extglob' shell option were enabled. The `=' operator is
887 identical to `=='. If the shell option `nocasematch' (see the
888 description of `shopt' in *note The Shopt Builtin::) is enabled,
889 the match is performed without regard to the case of alphabetic
890 characters. The return value is 0 if the string matches (`==') or
891 does not match (`!=')the pattern, and 1 otherwise. Any part of
892 the pattern may be quoted to force the quoted portion to be
895 An additional binary operator, `=~', is available, with the same
896 precedence as `==' and `!='. When it is used, the string to the
897 right of the operator is considered an extended regular expression
898 and matched accordingly (as in regex3)). The return value is 0 if
899 the string matches the pattern, and 1 otherwise. If the regular
900 expression is syntactically incorrect, the conditional
901 expression's return value is 2. If the shell option `nocasematch'
902 (see the description of `shopt' in *note The Shopt Builtin::) is
903 enabled, the match is performed without regard to the case of
904 alphabetic characters. Any part of the pattern may be quoted to
905 force the quoted portion to be matched as a string. Bracket
906 expressions in regular expressions must be treated carefully,
907 since normal quoting characters lose their meanings between
908 brackets. If the pattern is stored in a shell variable, quoting
909 the variable expansion forces the entire pattern to be matched as
910 a string. Substrings matched by parenthesized subexpressions
911 within the regular expression are saved in the array variable
912 `BASH_REMATCH'. The element of `BASH_REMATCH' with index 0 is the
913 portion of the string matching the entire regular expression. The
914 element of `BASH_REMATCH' with index N is the portion of the
915 string matching the Nth parenthesized subexpression.
917 For example, the following will match a line (stored in the shell
918 variable LINE) if there is a sequence of characters in the value
919 consisting of any number, including zero, of space characters,
920 zero or one instances of `a', then a `b':
921 [[ $line =~ [[:space:]]*(a)?b ]]
923 That means values like `aab' and ` aaaaaab' will match, as will a
924 line containing a `b' anywhere in its value.
926 Storing the regular expression in a shell variable is often a
927 useful way to avoid problems with quoting characters that are
928 special to the shell. It is sometimes difficult to specify a
929 regular expression literally without using quotes, or to keep
930 track of the quoting used by regular expressions while paying
931 attention to the shell's quote removal. Using a shell variable to
932 store the pattern decreases these problems. For example, the
933 following is equivalent to the above:
934 pattern='[[:space:]]*(a)?b'
935 [[ $line =~ $pattern ]]
937 If you want to match a character that's special to the regular
938 expression grammar, it has to be quoted to remove its special
939 meaning. This means that in the pattern `xxx.txt', the `.'
940 matches any character in the string (its usual regular expression
941 meaning), but in the pattern `"xxx.txt"' it can only match a
942 literal `.'. Shell programmers should take special care with
943 backslashes, since backslashes are used both by the shell and
944 regular expressions to remove the special meaning from the
945 following character. The following two sets of commands are _not_
952 [[ . =~ "$pattern" ]]
955 The first two matches will succeed, but the second two will not,
956 because in the second two the backslash will be part of the
957 pattern to be matched. In the first two examples, the backslash
958 removes the special meaning from `.', so the literal `.' matches.
959 If the string in the first examples were anything other than `.',
960 say `a', the pattern would not match, because the quoted `.' in the
961 pattern loses its special meaning of matching any single character.
963 Expressions may be combined using the following operators, listed
964 in decreasing order of precedence:
967 Returns the value of EXPRESSION. This may be used to
968 override the normal precedence of operators.
971 True if EXPRESSION is false.
973 `EXPRESSION1 && EXPRESSION2'
974 True if both EXPRESSION1 and EXPRESSION2 are true.
976 `EXPRESSION1 || EXPRESSION2'
977 True if either EXPRESSION1 or EXPRESSION2 is true.
979 The `&&' and `||' operators do not evaluate EXPRESSION2 if the
980 value of EXPRESSION1 is sufficient to determine the return value
981 of the entire conditional expression.
984 File: bashref.info, Node: Command Grouping, Prev: Conditional Constructs, Up: Compound Commands
986 3.2.4.3 Grouping Commands
987 .........................
989 Bash provides two ways to group a list of commands to be executed as a
990 unit. When commands are grouped, redirections may be applied to the
991 entire command list. For example, the output of all the commands in
992 the list may be redirected to a single stream.
997 Placing a list of commands between parentheses causes a subshell
998 environment to be created (*note Command Execution Environment::),
999 and each of the commands in LIST to be executed in that subshell.
1000 Since the LIST is executed in a subshell, variable assignments do
1001 not remain in effect after the subshell completes.
1006 Placing a list of commands between curly braces causes the list to
1007 be executed in the current shell context. No subshell is created.
1008 The semicolon (or newline) following LIST is required.
1010 In addition to the creation of a subshell, there is a subtle
1011 difference between these two constructs due to historical reasons. The
1012 braces are `reserved words', so they must be separated from the LIST by
1013 `blank's or other shell metacharacters. The parentheses are
1014 `operators', and are recognized as separate tokens by the shell even if
1015 they are not separated from the LIST by whitespace.
1017 The exit status of both of these constructs is the exit status of
1021 File: bashref.info, Node: Coprocesses, Next: GNU Parallel, Prev: Compound Commands, Up: Shell Commands
1026 A `coprocess' is a shell command preceded by the `coproc' reserved word.
1027 A coprocess is executed asynchronously in a subshell, as if the command
1028 had been terminated with the `&' control operator, with a two-way pipe
1029 established between the executing shell and the coprocess.
1031 The format for a coprocess is:
1032 coproc [NAME] COMMAND [REDIRECTIONS]
1034 This creates a coprocess named NAME. If NAME is not supplied, the
1035 default name is COPROC. NAME must not be supplied if COMMAND is a
1036 simple command (*note Simple Commands::); otherwise, it is interpreted
1037 as the first word of the simple command.
1039 When the coprocess is executed, the shell creates an array variable
1040 (*note Arrays::) named `NAME' in the context of the executing shell.
1041 The standard output of COMMAND is connected via a pipe to a file
1042 descriptor in the executing shell, and that file descriptor is assigned
1043 to `NAME'[0]. The standard input of COMMAND is connected via a pipe to
1044 a file descriptor in the executing shell, and that file descriptor is
1045 assigned to `NAME'[1]. This pipe is established before any
1046 redirections specified by the command (*note Redirections::). The file
1047 descriptors can be utilized as arguments to shell commands and
1048 redirections using standard word expansions. The file descriptors are
1049 not available in subshells.
1051 The process ID of the shell spawned to execute the coprocess is
1052 available as the value of the variable `NAME'_PID. The `wait' builtin
1053 command may be used to wait for the coprocess to terminate.
1055 Since the coprocess is created as an asynchronous command, the
1056 `coproc' command always returns success. The return status of a
1057 coprocess is the exit status of COMMAND.
1060 File: bashref.info, Node: GNU Parallel, Prev: Coprocesses, Up: Shell Commands
1065 There are ways to run commands in parallel that are not built into Bash.
1066 GNU Parallel is a tool to do just that.
1068 GNU Parallel, as its name suggests, can be used to build and run
1069 commands in parallel. You may run the same command with different
1070 arguments, whether they are filenames, usernames, hostnames, or lines
1071 read from files. GNU Parallel provides shorthand references to many of
1072 the most common operations (input lines, various portions of the input
1073 line, different ways to specify the input source, and so on). Parallel
1074 can replace `xargs' or feed commands from its input sources to several
1075 different instances of Bash.
1077 For a complete description, refer to the GNU Parallel documentation.
1078 A few examples should provide a brief introduction to its use.
1080 For example, it is easy to replace `xargs' to gzip all html files in
1081 the current directory and its subdirectories:
1082 find . -type f -name '*.html' -print | parallel gzip
1083 If you need to protect special characters such as newlines in file
1084 names, use find's `-print0' option and parallel's `-0' option.
1086 You can use Parallel to move files from the current directory when
1087 the number of files is too large to process with one `mv' invocation:
1088 ls | parallel mv {} destdir
1090 As you can see, the {} is replaced with each line read from standard
1091 input. While using `ls' will work in most instances, it is not
1092 sufficient to deal with all filenames. If you need to accommodate
1093 special characters in filenames, you can use
1095 find . -depth 1 \! -name '.*' -print0 | parallel -0 mv {} destdir
1097 as alluded to above.
1099 This will run as many `mv' commands as there are files in the current
1100 directory. You can emulate a parallel `xargs' by adding the `-X'
1102 find . -depth 1 \! -name '.*' -print0 | parallel -0 -X mv {} destdir
1104 GNU Parallel can replace certain common idioms that operate on lines
1105 read from a file (in this case, filenames listed one per line):
1106 while IFS= read -r x; do
1107 do-something1 "$x" "config-$x"
1108 do-something2 < "$x"
1109 done < file | process-output
1111 with a more compact syntax reminiscent of lambdas:
1112 cat list | parallel "do-something1 {} config-{} ; do-something2 < {}" | process-output
1114 Parallel provides a built-in mechanism to remove filename
1115 extensions, which lends itself to batch file transformations or
1117 ls *.gz | parallel -j+0 "zcat {} | bzip2 >{.}.bz2 && rm {}"
1118 This will recompress all files in the current directory with names
1119 ending in .gz using bzip2, running one job per CPU (-j+0) in parallel.
1120 (We use `ls' for brevity here; using `find' as above is more robust in
1121 the face of filenames containing unexpected characters.) Parallel can
1122 take arguments from the command line; the above can also be written as
1124 parallel "zcat {} | bzip2 >{.}.bz2 && rm {}" ::: *.gz
1126 If a command generates output, you may want to preserve the input
1127 order in the output. For instance, the following command
1128 { echo foss.org.my ; echo debian.org; echo freenetproject.org; } | parallel traceroute
1129 will display as output the traceroute invocation that finishes first.
1130 Adding the `-k' option
1131 { echo foss.org.my ; echo debian.org; echo freenetproject.org; } | parallel -k traceroute
1132 will ensure that the output of `traceroute foss.org.my' is displayed
1135 Finally, Parallel can be used to run a sequence of shell commands in
1136 parallel, similar to `cat file | bash'. It is not uncommon to take a
1137 list of filenames, create a series of shell commands to operate on
1138 them, and feed that list of commnds to a shell. Parallel can speed
1139 this up. Assuming that `file' contains a list of shell commands, one
1142 parallel -j 10 < file
1144 will evaluate the commands using the shell (since no explicit command is
1145 supplied as an argument), in blocks of ten shell jobs at a time.
1148 File: bashref.info, Node: Shell Functions, Next: Shell Parameters, Prev: Shell Commands, Up: Basic Shell Features
1153 Shell functions are a way to group commands for later execution using a
1154 single name for the group. They are executed just like a "regular"
1155 command. When the name of a shell function is used as a simple command
1156 name, the list of commands associated with that function name is
1157 executed. Shell functions are executed in the current shell context;
1158 no new process is created to interpret them.
1160 Functions are declared using this syntax:
1161 NAME () COMPOUND-COMMAND [ REDIRECTIONS ]
1165 function NAME [()] COMPOUND-COMMAND [ REDIRECTIONS ]
1167 This defines a shell function named NAME. The reserved word
1168 `function' is optional. If the `function' reserved word is supplied,
1169 the parentheses are optional. The BODY of the function is the compound
1170 command COMPOUND-COMMAND (*note Compound Commands::). That command is
1171 usually a LIST enclosed between { and }, but may be any compound
1172 command listed above. COMPOUND-COMMAND is executed whenever NAME is
1173 specified as the name of a command. When the shell is in POSIX mode
1174 (*note Bash POSIX Mode::), NAME may not be the same as one of the
1175 special builtins (*note Special Builtins::). Any redirections (*note
1176 Redirections::) associated with the shell function are performed when
1177 the function is executed.
1179 A function definition may be deleted using the `-f' option to the
1180 `unset' builtin (*note Bourne Shell Builtins::).
1182 The exit status of a function definition is zero unless a syntax
1183 error occurs or a readonly function with the same name already exists.
1184 When executed, the exit status of a function is the exit status of the
1185 last command executed in the body.
1187 Note that for historical reasons, in the most common usage the curly
1188 braces that surround the body of the function must be separated from
1189 the body by `blank's or newlines. This is because the braces are
1190 reserved words and are only recognized as such when they are separated
1191 from the command list by whitespace or another shell metacharacter.
1192 Also, when using the braces, the LIST must be terminated by a semicolon,
1193 a `&', or a newline.
1195 When a function is executed, the arguments to the function become
1196 the positional parameters during its execution (*note Positional
1197 Parameters::). The special parameter `#' that expands to the number of
1198 positional parameters is updated to reflect the change. Special
1199 parameter `0' is unchanged. The first element of the `FUNCNAME'
1200 variable is set to the name of the function while the function is
1203 All other aspects of the shell execution environment are identical
1204 between a function and its caller with these exceptions: the `DEBUG'
1205 and `RETURN' traps are not inherited unless the function has been given
1206 the `trace' attribute using the `declare' builtin or the `-o functrace'
1207 option has been enabled with the `set' builtin, (in which case all
1208 functions inherit the `DEBUG' and `RETURN' traps), and the `ERR' trap
1209 is not inherited unless the `-o errtrace' shell option has been enabled.
1210 *Note Bourne Shell Builtins::, for the description of the `trap'
1213 The `FUNCNEST' variable, if set to a numeric value greater than 0,
1214 defines a maximum function nesting level. Function invocations that
1215 exceed the limit cause the entire command to abort.
1217 If the builtin command `return' is executed in a function, the
1218 function completes and execution resumes with the next command after
1219 the function call. Any command associated with the `RETURN' trap is
1220 executed before execution resumes. When a function completes, the
1221 values of the positional parameters and the special parameter `#' are
1222 restored to the values they had prior to the function's execution. If
1223 a numeric argument is given to `return', that is the function's return
1224 status; otherwise the function's return status is the exit status of
1225 the last command executed before the `return'.
1227 Variables local to the function may be declared with the `local'
1228 builtin. These variables are visible only to the function and the
1229 commands it invokes.
1231 Function names and definitions may be listed with the `-f' option to
1232 the `declare' (`typeset') builtin command (*note Bash Builtins::). The
1233 `-F' option to `declare' or `typeset' will list the function names only
1234 (and optionally the source file and line number, if the `extdebug'
1235 shell option is enabled). Functions may be exported so that subshells
1236 automatically have them defined with the `-f' option to the `export'
1237 builtin (*note Bourne Shell Builtins::). Note that shell functions and
1238 variables with the same name may result in multiple identically-named
1239 entries in the environment passed to the shell's children. Care should
1240 be taken in cases where this may cause a problem.
1242 Functions may be recursive. The `FUNCNEST' variable may be used to
1243 limit the depth of the function call stack and restrict the number of
1244 function invocations. By default, no limit is placed on the number of
1248 File: bashref.info, Node: Shell Parameters, Next: Shell Expansions, Prev: Shell Functions, Up: Basic Shell Features
1250 3.4 Shell Parameters
1251 ====================
1255 * Positional Parameters:: The shell's command-line arguments.
1256 * Special Parameters:: Parameters denoted by special characters.
1258 A PARAMETER is an entity that stores values. It can be a `name', a
1259 number, or one of the special characters listed below. A VARIABLE is a
1260 parameter denoted by a `name'. A variable has a VALUE and zero or more
1261 ATTRIBUTES. Attributes are assigned using the `declare' builtin command
1262 (see the description of the `declare' builtin in *note Bash Builtins::).
1264 A parameter is set if it has been assigned a value. The null string
1265 is a valid value. Once a variable is set, it may be unset only by using
1266 the `unset' builtin command.
1268 A variable may be assigned to by a statement of the form
1270 If VALUE is not given, the variable is assigned the null string. All
1271 VALUEs undergo tilde expansion, parameter and variable expansion,
1272 command substitution, arithmetic expansion, and quote removal (detailed
1273 below). If the variable has its `integer' attribute set, then VALUE is
1274 evaluated as an arithmetic expression even if the `$((...))' expansion
1275 is not used (*note Arithmetic Expansion::). Word splitting is not
1276 performed, with the exception of `"$@"' as explained below. Filename
1277 expansion is not performed. Assignment statements may also appear as
1278 arguments to the `alias', `declare', `typeset', `export', `readonly',
1279 and `local' builtin commands. When in POSIX mode (*note Bash POSIX
1280 Mode::), these builtins may appear in a command after one or more
1281 instances of the `command' builtin and retain these assignment
1282 statement properties.
1284 In the context where an assignment statement is assigning a value to
1285 a shell variable or array index (*note Arrays::), the `+=' operator can
1286 be used to append to or add to the variable's previous value. When
1287 `+=' is applied to a variable for which the INTEGER attribute has been
1288 set, VALUE is evaluated as an arithmetic expression and added to the
1289 variable's current value, which is also evaluated. When `+=' is
1290 applied to an array variable using compound assignment (*note
1291 Arrays::), the variable's value is not unset (as it is when using `='),
1292 and new values are appended to the array beginning at one greater than
1293 the array's maximum index (for indexed arrays), or added as additional
1294 key-value pairs in an associative array. When applied to a
1295 string-valued variable, VALUE is expanded and appended to the
1298 A variable can be assigned the NAMEREF attribute using the `-n'
1299 option to the \fBdeclare\fP or \fBlocal\fP builtin commands (*note Bash
1300 Builtins::) to create a NAMEREF, or a reference to another variable.
1301 This allows variables to be manipulated indirectly. Whenever the
1302 nameref variable is referenced or assigned to, the operation is
1303 actually performed on the variable specified by the nameref variable's
1304 value. A nameref is commonly used within shell functions to refer to a
1305 variable whose name is passed as an argument to the function. For
1306 instance, if a variable name is passed to a shell function as its first
1309 inside the function creates a nameref variable REF whose value is
1310 the variable name passed as the first argument. References and
1311 assignments to REF are treated as references and assignments to the
1312 variable whose name was passed as `$1'.
1314 If the control variable in a `for' loop has the nameref attribute,
1315 the list of words can be a list of shell variables, and a name reference
1316 will be established for each word in the list, in turn, when the loop is
1317 executed. Array variables cannot be given the `-n' attribute.
1318 However, nameref variables can reference array variables and subscripted
1319 array variables. Namerefs can be unset using the `-n' option to the
1320 `unset' builtin (*note Bourne Shell Builtins::). Otherwise, if `unset'
1321 is executed with the name of a nameref variable as an argument, the
1322 variable referenced by the nameref variable will be unset.
1325 File: bashref.info, Node: Positional Parameters, Next: Special Parameters, Up: Shell Parameters
1327 3.4.1 Positional Parameters
1328 ---------------------------
1330 A POSITIONAL PARAMETER is a parameter denoted by one or more digits,
1331 other than the single digit `0'. Positional parameters are assigned
1332 from the shell's arguments when it is invoked, and may be reassigned
1333 using the `set' builtin command. Positional parameter `N' may be
1334 referenced as `${N}', or as `$N' when `N' consists of a single digit.
1335 Positional parameters may not be assigned to with assignment statements.
1336 The `set' and `shift' builtins are used to set and unset them (*note
1337 Shell Builtin Commands::). The positional parameters are temporarily
1338 replaced when a shell function is executed (*note Shell Functions::).
1340 When a positional parameter consisting of more than a single digit
1341 is expanded, it must be enclosed in braces.
1344 File: bashref.info, Node: Special Parameters, Prev: Positional Parameters, Up: Shell Parameters
1346 3.4.2 Special Parameters
1347 ------------------------
1349 The shell treats several parameters specially. These parameters may
1350 only be referenced; assignment to them is not allowed.
1353 ($*) Expands to the positional parameters, starting from one.
1354 When the expansion is not within double quotes, each positional
1355 parameter expands to a separate word. In contexts where it is
1356 performed, those words are subject to further word splitting and
1357 pathname expansion. When the expansion occurs within double
1358 quotes, it expands to a single word with the value of each
1359 parameter separated by the first character of the `IFS' special
1360 variable. That is, `"$*"' is equivalent to `"$1C$2C..."', where C
1361 is the first character of the value of the `IFS' variable. If
1362 `IFS' is unset, the parameters are separated by spaces. If `IFS'
1363 is null, the parameters are joined without intervening separators.
1366 ($@) Expands to the positional parameters, starting from one.
1367 When the expansion occurs within double quotes, each parameter
1368 expands to a separate word. That is, `"$@"' is equivalent to
1369 `"$1" "$2" ...'. If the double-quoted expansion occurs within a
1370 word, the expansion of the first parameter is joined with the
1371 beginning part of the original word, and the expansion of the last
1372 parameter is joined with the last part of the original word. When
1373 there are no positional parameters, `"$@"' and `$@' expand to
1374 nothing (i.e., they are removed).
1377 ($#) Expands to the number of positional parameters in decimal.
1380 ($?) Expands to the exit status of the most recently executed
1381 foreground pipeline.
1384 ($-, a hyphen.) Expands to the current option flags as specified
1385 upon invocation, by the `set' builtin command, or those set by the
1386 shell itself (such as the `-i' option).
1389 ($$) Expands to the process ID of the shell. In a `()' subshell,
1390 it expands to the process ID of the invoking shell, not the
1394 ($!) Expands to the process ID of the job most recently placed
1395 into the background, whether executed as an asynchronous command
1396 or using the `bg' builtin (*note Job Control Builtins::).
1399 ($0) Expands to the name of the shell or shell script. This is
1400 set at shell initialization. If Bash is invoked with a file of
1401 commands (*note Shell Scripts::), `$0' is set to the name of that
1402 file. If Bash is started with the `-c' option (*note Invoking
1403 Bash::), then `$0' is set to the first argument after the string
1404 to be executed, if one is present. Otherwise, it is set to the
1405 filename used to invoke Bash, as given by argument zero.
1408 ($_, an underscore.) At shell startup, set to the absolute
1409 pathname used to invoke the shell or shell script being executed
1410 as passed in the environment or argument list. Subsequently,
1411 expands to the last argument to the previous command, after
1412 expansion. Also set to the full pathname used to invoke each
1413 command executed and placed in the environment exported to that
1414 command. When checking mail, this parameter holds the name of the
1418 File: bashref.info, Node: Shell Expansions, Next: Redirections, Prev: Shell Parameters, Up: Basic Shell Features
1420 3.5 Shell Expansions
1421 ====================
1423 Expansion is performed on the command line after it has been split into
1424 `token's. There are seven kinds of expansion performed:
1430 * parameter and variable expansion
1432 * command substitution
1434 * arithmetic expansion
1438 * filename expansion
1442 * Brace Expansion:: Expansion of expressions within braces.
1443 * Tilde Expansion:: Expansion of the ~ character.
1444 * Shell Parameter Expansion:: How Bash expands variables to their values.
1445 * Command Substitution:: Using the output of a command as an argument.
1446 * Arithmetic Expansion:: How to use arithmetic in shell expansions.
1447 * Process Substitution:: A way to write and read to and from a
1449 * Word Splitting:: How the results of expansion are split into separate
1451 * Filename Expansion:: A shorthand for specifying filenames matching patterns.
1452 * Quote Removal:: How and when quote characters are removed from
1455 The order of expansions is: brace expansion; tilde expansion,
1456 parameter and variable expansion, arithmetic expansion, and command
1457 substitution (done in a left-to-right fashion); word splitting; and
1460 On systems that can support it, there is an additional expansion
1461 available: PROCESS SUBSTITUTION. This is performed at the same time as
1462 tilde, parameter, variable, and arithmetic expansion and command
1465 Only brace expansion, word splitting, and filename expansion can
1466 change the number of words of the expansion; other expansions expand a
1467 single word to a single word. The only exceptions to this are the
1468 expansions of `"$@"' (*note Special Parameters::) and `"${NAME[@]}"'
1471 After all expansions, `quote removal' (*note Quote Removal::) is
1475 File: bashref.info, Node: Brace Expansion, Next: Tilde Expansion, Up: Shell Expansions
1477 3.5.1 Brace Expansion
1478 ---------------------
1480 Brace expansion is a mechanism by which arbitrary strings may be
1481 generated. This mechanism is similar to FILENAME EXPANSION (*note
1482 Filename Expansion::), but the filenames generated need not exist.
1483 Patterns to be brace expanded take the form of an optional PREAMBLE,
1484 followed by either a series of comma-separated strings or a sequence
1485 expression between a pair of braces, followed by an optional POSTSCRIPT.
1486 The preamble is prefixed to each string contained within the braces, and
1487 the postscript is then appended to each resulting string, expanding left
1490 Brace expansions may be nested. The results of each expanded string
1491 are not sorted; left to right order is preserved. For example,
1492 bash$ echo a{d,c,b}e
1495 A sequence expression takes the form `{X..Y[..INCR]}', where X and Y
1496 are either integers or single characters, and INCR, an optional
1497 increment, is an integer. When integers are supplied, the expression
1498 expands to each number between X and Y, inclusive. Supplied integers
1499 may be prefixed with `0' to force each term to have the same width.
1500 When either X or Y begins with a zero, the shell attempts to force all
1501 generated terms to contain the same number of digits, zero-padding
1502 where necessary. When characters are supplied, the expression expands
1503 to each character lexicographically between X and Y, inclusive, using
1504 the default C locale. Note that both X and Y must be of the same type.
1505 When the increment is supplied, it is used as the difference between
1506 each term. The default increment is 1 or -1 as appropriate.
1508 Brace expansion is performed before any other expansions, and any
1509 characters special to other expansions are preserved in the result. It
1510 is strictly textual. Bash does not apply any syntactic interpretation
1511 to the context of the expansion or the text between the braces. To
1512 avoid conflicts with parameter expansion, the string `${' is not
1513 considered eligible for brace expansion.
1515 A correctly-formed brace expansion must contain unquoted opening and
1516 closing braces, and at least one unquoted comma or a valid sequence
1517 expression. Any incorrectly formed brace expansion is left unchanged.
1519 A { or `,' may be quoted with a backslash to prevent its being
1520 considered part of a brace expression. To avoid conflicts with
1521 parameter expansion, the string `${' is not considered eligible for
1524 This construct is typically used as shorthand when the common prefix
1525 of the strings to be generated is longer than in the above example:
1526 mkdir /usr/local/src/bash/{old,new,dist,bugs}
1528 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
1531 File: bashref.info, Node: Tilde Expansion, Next: Shell Parameter Expansion, Prev: Brace Expansion, Up: Shell Expansions
1533 3.5.2 Tilde Expansion
1534 ---------------------
1536 If a word begins with an unquoted tilde character (`~'), all of the
1537 characters up to the first unquoted slash (or all characters, if there
1538 is no unquoted slash) are considered a TILDE-PREFIX. If none of the
1539 characters in the tilde-prefix are quoted, the characters in the
1540 tilde-prefix following the tilde are treated as a possible LOGIN NAME.
1541 If this login name is the null string, the tilde is replaced with the
1542 value of the `HOME' shell variable. If `HOME' is unset, the home
1543 directory of the user executing the shell is substituted instead.
1544 Otherwise, the tilde-prefix is replaced with the home directory
1545 associated with the specified login name.
1547 If the tilde-prefix is `~+', the value of the shell variable `PWD'
1548 replaces the tilde-prefix. If the tilde-prefix is `~-', the value of
1549 the shell variable `OLDPWD', if it is set, is substituted.
1551 If the characters following the tilde in the tilde-prefix consist of
1552 a number N, optionally prefixed by a `+' or a `-', the tilde-prefix is
1553 replaced with the corresponding element from the directory stack, as it
1554 would be displayed by the `dirs' builtin invoked with the characters
1555 following tilde in the tilde-prefix as an argument (*note The Directory
1556 Stack::). If the tilde-prefix, sans the tilde, consists of a number
1557 without a leading `+' or `-', `+' is assumed.
1559 If the login name is invalid, or the tilde expansion fails, the word
1562 Each variable assignment is checked for unquoted tilde-prefixes
1563 immediately following a `:' or the first `='. In these cases, tilde
1564 expansion is also performed. Consequently, one may use filenames with
1565 tildes in assignments to `PATH', `MAILPATH', and `CDPATH', and the
1566 shell assigns the expanded value.
1568 The following table shows how Bash treats unquoted tilde-prefixes:
1571 The value of `$HOME'
1577 The subdirectory `foo' of the home directory of the user `fred'
1583 `${OLDPWD-'~-'}/foo'
1586 The string that would be displayed by `dirs +N'
1589 The string that would be displayed by `dirs +N'
1592 The string that would be displayed by `dirs -N'
1595 File: bashref.info, Node: Shell Parameter Expansion, Next: Command Substitution, Prev: Tilde Expansion, Up: Shell Expansions
1597 3.5.3 Shell Parameter Expansion
1598 -------------------------------
1600 The `$' character introduces parameter expansion, command substitution,
1601 or arithmetic expansion. The parameter name or symbol to be expanded
1602 may be enclosed in braces, which are optional but serve to protect the
1603 variable to be expanded from characters immediately following it which
1604 could be interpreted as part of the name.
1606 When braces are used, the matching ending brace is the first `}' not
1607 escaped by a backslash or within a quoted string, and not within an
1608 embedded arithmetic expansion, command substitution, or parameter
1611 The basic form of parameter expansion is ${PARAMETER}. The value of
1612 PARAMETER is substituted. The PARAMETER is a shell parameter as
1613 described above (*note Shell Parameters::) or an array reference (*note
1614 Arrays::). The braces are required when PARAMETER is a positional
1615 parameter with more than one digit, or when PARAMETER is followed by a
1616 character that is not to be interpreted as part of its name.
1618 If the first character of PARAMETER is an exclamation point (!), it
1619 introduces a level of variable indirection. Bash uses the value of the
1620 variable formed from the rest of PARAMETER as the name of the variable;
1621 this variable is then expanded and that value is used in the rest of
1622 the substitution, rather than the value of PARAMETER itself. This is
1623 known as `indirect expansion'. The exceptions to this are the
1624 expansions of ${!PREFIX*} and ${!NAME[@]} described below. The
1625 exclamation point must immediately follow the left brace in order to
1626 introduce indirection.
1628 In each of the cases below, WORD is subject to tilde expansion,
1629 parameter expansion, command substitution, and arithmetic expansion.
1631 When not performing substring expansion, using the form described
1632 below (e.g., `:-'), Bash tests for a parameter that is unset or null.
1633 Omitting the colon results in a test only for a parameter that is unset.
1634 Put another way, if the colon is included, the operator tests for both
1635 PARAMETER's existence and that its value is not null; if the colon is
1636 omitted, the operator tests only for existence.
1638 `${PARAMETER:-WORD}'
1639 If PARAMETER is unset or null, the expansion of WORD is
1640 substituted. Otherwise, the value of PARAMETER is substituted.
1642 `${PARAMETER:=WORD}'
1643 If PARAMETER is unset or null, the expansion of WORD is assigned
1644 to PARAMETER. The value of PARAMETER is then substituted.
1645 Positional parameters and special parameters may not be assigned to
1648 `${PARAMETER:?WORD}'
1649 If PARAMETER is null or unset, the expansion of WORD (or a message
1650 to that effect if WORD is not present) is written to the standard
1651 error and the shell, if it is not interactive, exits. Otherwise,
1652 the value of PARAMETER is substituted.
1654 `${PARAMETER:+WORD}'
1655 If PARAMETER is null or unset, nothing is substituted, otherwise
1656 the expansion of WORD is substituted.
1658 `${PARAMETER:OFFSET}'
1659 `${PARAMETER:OFFSET:LENGTH}'
1660 This is referred to as Substring Expansion. It expands to up to
1661 LENGTH characters of the value of PARAMETER starting at the
1662 character specified by OFFSET. If PARAMETER is `@', an indexed
1663 array subscripted by `@' or `*', or an associative array name, the
1664 results differ as described below. If LENGTH is omitted, it
1665 expands to the substring of the value of PARAMETER starting at the
1666 character specified by OFFSET and extending to the end of the
1667 value. LENGTH and OFFSET are arithmetic expressions (*note Shell
1670 If OFFSET evaluates to a number less than zero, the value is used
1671 as an offset in characters from the end of the value of PARAMETER.
1672 If LENGTH evaluates to a number less than zero, it is interpreted
1673 as an offset in characters from the end of the value of PARAMETER
1674 rather than a number of characters, and the expansion is the
1675 characters between OFFSET and that result. Note that a negative
1676 offset must be separated from the colon by at least one space to
1677 avoid being confused with the `:-' expansion.
1679 Here are some examples illustrating substring expansion on
1680 parameters and subscripted arrays:
1682 $ string=01234567890abcdefgh
1685 $ echo ${string:7:0}
1687 $ echo ${string:7:2}
1689 $ echo ${string:7:-2}
1691 $ echo ${string: -7}
1693 $ echo ${string: -7:0}
1695 $ echo ${string: -7:2}
1697 $ echo ${string: -7:-2}
1699 $ set -- 01234567890abcdefgh
1716 $ array[0]=01234567890abcdefgh
1717 $ echo ${array[0]:7}
1719 $ echo ${array[0]:7:0}
1721 $ echo ${array[0]:7:2}
1723 $ echo ${array[0]:7:-2}
1725 $ echo ${array[0]: -7}
1727 $ echo ${array[0]: -7:0}
1729 $ echo ${array[0]: -7:2}
1731 $ echo ${array[0]: -7:-2}
1734 If PARAMETER is `@', the result is LENGTH positional parameters
1735 beginning at OFFSET. A negative OFFSET is taken relative to one
1736 greater than the greatest positional parameter, so an offset of -1
1737 evaluates to the last positional parameter. It is an expansion
1738 error if LENGTH evaluates to a number less than zero.
1740 The following examples illustrate substring expansion using
1741 positional parameters:
1743 $ set -- 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
1745 7 8 9 0 a b c d e f g h
1751 bash: -2: substring expression < 0
1755 ./bash 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
1760 If PARAMETER is an indexed array name subscripted by `@' or `*',
1761 the result is the LENGTH members of the array beginning with
1762 `${PARAMETER[OFFSET]}'. A negative OFFSET is taken relative to
1763 one greater than the maximum index of the specified array. It is
1764 an expansion error if LENGTH evaluates to a number less than zero.
1766 These examples show how you can use substring expansion with
1769 $ array=(0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h)
1770 $ echo ${array[@]:7}
1771 7 8 9 0 a b c d e f g h
1772 $ echo ${array[@]:7:2}
1774 $ echo ${array[@]: -7:2}
1776 $ echo ${array[@]: -7:-2}
1777 bash: -2: substring expression < 0
1778 $ echo ${array[@]:0}
1779 0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
1780 $ echo ${array[@]:0:2}
1782 $ echo ${array[@]: -7:0}
1784 Substring expansion applied to an associative array produces
1787 Substring indexing is zero-based unless the positional parameters
1788 are used, in which case the indexing starts at 1 by default. If
1789 OFFSET is 0, and the positional parameters are used, `$@' is
1790 prefixed to the list.
1794 Expands to the names of variables whose names begin with PREFIX,
1795 separated by the first character of the `IFS' special variable.
1796 When `@' is used and the expansion appears within double quotes,
1797 each variable name expands to a separate word.
1801 If NAME is an array variable, expands to the list of array indices
1802 (keys) assigned in NAME. If NAME is not an array, expands to 0 if
1803 NAME is set and null otherwise. When `@' is used and the
1804 expansion appears within double quotes, each key expands to a
1808 The length in characters of the expanded value of PARAMETER is
1809 substituted. If PARAMETER is `*' or `@', the value substituted is
1810 the number of positional parameters. If PARAMETER is an array
1811 name subscripted by `*' or `@', the value substituted is the
1812 number of elements in the array. If PARAMETER is an indexed array
1813 name subscripted by a negative number, that number is interpreted
1814 as relative to one greater than the maximum index of PARAMETER, so
1815 negative indices count back from the end of the array, and an
1816 index of -1 references the last element.
1819 `${PARAMETER##WORD}'
1820 The WORD is expanded to produce a pattern just as in filename
1821 expansion (*note Filename Expansion::). If the pattern matches
1822 the beginning of the expanded value of PARAMETER, then the result
1823 of the expansion is the expanded value of PARAMETER with the
1824 shortest matching pattern (the `#' case) or the longest matching
1825 pattern (the `##' case) deleted. If PARAMETER is `@' or `*', the
1826 pattern removal operation is applied to each positional parameter
1827 in turn, and the expansion is the resultant list. If PARAMETER is
1828 an array variable subscripted with `@' or `*', the pattern removal
1829 operation is applied to each member of the array in turn, and the
1830 expansion is the resultant list.
1833 `${PARAMETER%%WORD}'
1834 The WORD is expanded to produce a pattern just as in filename
1835 expansion. If the pattern matches a trailing portion of the
1836 expanded value of PARAMETER, then the result of the expansion is
1837 the value of PARAMETER with the shortest matching pattern (the `%'
1838 case) or the longest matching pattern (the `%%' case) deleted. If
1839 PARAMETER is `@' or `*', the pattern removal operation is applied
1840 to each positional parameter in turn, and the expansion is the
1841 resultant list. If PARAMETER is an array variable subscripted
1842 with `@' or `*', the pattern removal operation is applied to each
1843 member of the array in turn, and the expansion is the resultant
1846 `${PARAMETER/PATTERN/STRING}'
1847 The PATTERN is expanded to produce a pattern just as in filename
1848 expansion. PARAMETER is expanded and the longest match of PATTERN
1849 against its value is replaced with STRING. If PATTERN begins with
1850 `/', all matches of PATTERN are replaced with STRING. Normally
1851 only the first match is replaced. If PATTERN begins with `#', it
1852 must match at the beginning of the expanded value of PARAMETER.
1853 If PATTERN begins with `%', it must match at the end of the
1854 expanded value of PARAMETER. If STRING is null, matches of
1855 PATTERN are deleted and the `/' following PATTERN may be omitted.
1856 If PARAMETER is `@' or `*', the substitution operation is applied
1857 to each positional parameter in turn, and the expansion is the
1858 resultant list. If PARAMETER is an array variable subscripted
1859 with `@' or `*', the substitution operation is applied to each
1860 member of the array in turn, and the expansion is the resultant
1863 `${PARAMETER^PATTERN}'
1864 `${PARAMETER^^PATTERN}'
1865 `${PARAMETER,PATTERN}'
1866 `${PARAMETER,,PATTERN}'
1867 This expansion modifies the case of alphabetic characters in
1868 PARAMETER. The PATTERN is expanded to produce a pattern just as in
1869 filename expansion. Each character in the expanded value of
1870 PARAMETER is tested against PATTERN, and, if it matches the
1871 pattern, its case is converted. The pattern should not attempt to
1872 match more than one character. The `^' operator converts
1873 lowercase letters matching PATTERN to uppercase; the `,' operator
1874 converts matching uppercase letters to lowercase. The `^^' and
1875 `,,' expansions convert each matched character in the expanded
1876 value; the `^' and `,' expansions match and convert only the first
1877 character in the expanded value. If PATTERN is omitted, it is
1878 treated like a `?', which matches every character. If PARAMETER
1879 is `@' or `*', the case modification operation is applied to each
1880 positional parameter in turn, and the expansion is the resultant
1881 list. If PARAMETER is an array variable subscripted with `@' or
1882 `*', the case modification operation is applied to each member of
1883 the array in turn, and the expansion is the resultant list.
1886 File: bashref.info, Node: Command Substitution, Next: Arithmetic Expansion, Prev: Shell Parameter Expansion, Up: Shell Expansions
1888 3.5.4 Command Substitution
1889 --------------------------
1891 Command substitution allows the output of a command to replace the
1892 command itself. Command substitution occurs when a command is enclosed
1898 Bash performs the expansion by executing COMMAND and replacing the
1899 command substitution with the standard output of the command, with any
1900 trailing newlines deleted. Embedded newlines are not deleted, but they
1901 may be removed during word splitting. The command substitution `$(cat
1902 FILE)' can be replaced by the equivalent but faster `$(< FILE)'.
1904 When the old-style backquote form of substitution is used, backslash
1905 retains its literal meaning except when followed by `$', ``', or `\'.
1906 The first backquote not preceded by a backslash terminates the command
1907 substitution. When using the `$(COMMAND)' form, all characters between
1908 the parentheses make up the command; none are treated specially.
1910 Command substitutions may be nested. To nest when using the
1911 backquoted form, escape the inner backquotes with backslashes.
1913 If the substitution appears within double quotes, word splitting and
1914 filename expansion are not performed on the results.
1917 File: bashref.info, Node: Arithmetic Expansion, Next: Process Substitution, Prev: Command Substitution, Up: Shell Expansions
1919 3.5.5 Arithmetic Expansion
1920 --------------------------
1922 Arithmetic expansion allows the evaluation of an arithmetic expression
1923 and the substitution of the result. The format for arithmetic
1928 The expression is treated as if it were within double quotes, but a
1929 double quote inside the parentheses is not treated specially. All
1930 tokens in the expression undergo parameter and variable expansion,
1931 command substitution, and quote removal. The result is treated as the
1932 arithmetic expression to be evaluated. Arithmetic expansions may be
1935 The evaluation is performed according to the rules listed below
1936 (*note Shell Arithmetic::). If the expression is invalid, Bash prints
1937 a message indicating failure to the standard error and no substitution
1941 File: bashref.info, Node: Process Substitution, Next: Word Splitting, Prev: Arithmetic Expansion, Up: Shell Expansions
1943 3.5.6 Process Substitution
1944 --------------------------
1946 Process substitution is supported on systems that support named pipes
1947 (FIFOs) or the `/dev/fd' method of naming open files. It takes the
1952 The process LIST is run with its input or output connected to a FIFO
1953 or some file in `/dev/fd'. The name of this file is passed as an
1954 argument to the current command as the result of the expansion. If the
1955 `>(LIST)' form is used, writing to the file will provide input for
1956 LIST. If the `<(LIST)' form is used, the file passed as an argument
1957 should be read to obtain the output of LIST. Note that no space may
1958 appear between the `<' or `>' and the left parenthesis, otherwise the
1959 construct would be interpreted as a redirection.
1961 When available, process substitution is performed simultaneously with
1962 parameter and variable expansion, command substitution, and arithmetic
1966 File: bashref.info, Node: Word Splitting, Next: Filename Expansion, Prev: Process Substitution, Up: Shell Expansions
1968 3.5.7 Word Splitting
1969 --------------------
1971 The shell scans the results of parameter expansion, command
1972 substitution, and arithmetic expansion that did not occur within double
1973 quotes for word splitting.
1975 The shell treats each character of `$IFS' as a delimiter, and splits
1976 the results of the other expansions into words using these characters
1977 as field terminators. If `IFS' is unset, or its value is exactly
1978 `<space><tab><newline>', the default, then sequences of ` <space>',
1979 `<tab>', and `<newline>' at the beginning and end of the results of the
1980 previous expansions are ignored, and any sequence of `IFS' characters
1981 not at the beginning or end serves to delimit words. If `IFS' has a
1982 value other than the default, then sequences of the whitespace
1983 characters `space' and `tab' are ignored at the beginning and end of the
1984 word, as long as the whitespace character is in the value of `IFS' (an
1985 `IFS' whitespace character). Any character in `IFS' that is not `IFS'
1986 whitespace, along with any adjacent `IFS' whitespace characters,
1987 delimits a field. A sequence of `IFS' whitespace characters is also
1988 treated as a delimiter. If the value of `IFS' is null, no word
1991 Explicit null arguments (`""' or `''') are retained. Unquoted
1992 implicit null arguments, resulting from the expansion of parameters
1993 that have no values, are removed. If a parameter with no value is
1994 expanded within double quotes, a null argument results and is retained.
1996 Note that if no expansion occurs, no splitting is performed.
1999 File: bashref.info, Node: Filename Expansion, Next: Quote Removal, Prev: Word Splitting, Up: Shell Expansions
2001 3.5.8 Filename Expansion
2002 ------------------------
2006 * Pattern Matching:: How the shell matches patterns.
2008 After word splitting, unless the `-f' option has been set (*note The
2009 Set Builtin::), Bash scans each word for the characters `*', `?', and
2010 `['. If one of these characters appears, then the word is regarded as
2011 a PATTERN, and replaced with an alphabetically sorted list of filenames
2012 matching the pattern (*note Pattern Matching::). If no matching
2013 filenames are found, and the shell option `nullglob' is disabled, the
2014 word is left unchanged. If the `nullglob' option is set, and no
2015 matches are found, the word is removed. If the `failglob' shell option
2016 is set, and no matches are found, an error message is printed and the
2017 command is not executed. If the shell option `nocaseglob' is enabled,
2018 the match is performed without regard to the case of alphabetic
2021 When a pattern is used for filename expansion, the character `.' at
2022 the start of a filename or immediately following a slash must be
2023 matched explicitly, unless the shell option `dotglob' is set. When
2024 matching a filename, the slash character must always be matched
2025 explicitly. In other cases, the `.' character is not treated specially.
2027 See the description of `shopt' in *note The Shopt Builtin::, for a
2028 description of the `nocaseglob', `nullglob', `failglob', and `dotglob'
2031 The `GLOBIGNORE' shell variable may be used to restrict the set of
2032 filenames matching a pattern. If `GLOBIGNORE' is set, each matching
2033 filename that also matches one of the patterns in `GLOBIGNORE' is
2034 removed from the list of matches. The filenames `.' and `..' are
2035 always ignored when `GLOBIGNORE' is set and not null. However, setting
2036 `GLOBIGNORE' to a non-null value has the effect of enabling the
2037 `dotglob' shell option, so all other filenames beginning with a `.'
2038 will match. To get the old behavior of ignoring filenames beginning
2039 with a `.', make `.*' one of the patterns in `GLOBIGNORE'. The
2040 `dotglob' option is disabled when `GLOBIGNORE' is unset.
2043 File: bashref.info, Node: Pattern Matching, Up: Filename Expansion
2045 3.5.8.1 Pattern Matching
2046 ........................
2048 Any character that appears in a pattern, other than the special pattern
2049 characters described below, matches itself. The NUL character may not
2050 occur in a pattern. A backslash escapes the following character; the
2051 escaping backslash is discarded when matching. The special pattern
2052 characters must be quoted if they are to be matched literally.
2054 The special pattern characters have the following meanings:
2056 Matches any string, including the null string. When the
2057 `globstar' shell option is enabled, and `*' is used in a filename
2058 expansion context, two adjacent `*'s used as a single pattern will
2059 match all files and zero or more directories and subdirectories.
2060 If followed by a `/', two adjacent `*'s will match only
2061 directories and subdirectories.
2064 Matches any single character.
2067 Matches any one of the enclosed characters. A pair of characters
2068 separated by a hyphen denotes a RANGE EXPRESSION; any character
2069 that falls between those two characters, inclusive, using the
2070 current locale's collating sequence and character set, is matched.
2071 If the first character following the `[' is a `!' or a `^' then
2072 any character not enclosed is matched. A `-' may be matched by
2073 including it as the first or last character in the set. A `]' may
2074 be matched by including it as the first character in the set. The
2075 sorting order of characters in range expressions is determined by
2076 the current locale and the values of the `LC_COLLATE' and `LC_ALL'
2077 shell variables, if set.
2079 For example, in the default C locale, `[a-dx-z]' is equivalent to
2080 `[abcdxyz]'. Many locales sort characters in dictionary order,
2081 and in these locales `[a-dx-z]' is typically not equivalent to
2082 `[abcdxyz]'; it might be equivalent to `[aBbCcDdxXyYz]', for
2083 example. To obtain the traditional interpretation of ranges in
2084 bracket expressions, you can force the use of the C locale by
2085 setting the `LC_COLLATE' or `LC_ALL' environment variable to the
2086 value `C', or enable the `globasciiranges' shell option.
2088 Within `[' and `]', CHARACTER CLASSES can be specified using the
2089 syntax `[:'CLASS`:]', where CLASS is one of the following classes
2090 defined in the POSIX standard:
2091 alnum alpha ascii blank cntrl digit graph lower
2092 print punct space upper word xdigit
2093 A character class matches any character belonging to that class.
2094 The `word' character class matches letters, digits, and the
2097 Within `[' and `]', an EQUIVALENCE CLASS can be specified using
2098 the syntax `[='C`=]', which matches all characters with the same
2099 collation weight (as defined by the current locale) as the
2102 Within `[' and `]', the syntax `[.'SYMBOL`.]' matches the
2103 collating symbol SYMBOL.
2105 If the `extglob' shell option is enabled using the `shopt' builtin,
2106 several extended pattern matching operators are recognized. In the
2107 following description, a PATTERN-LIST is a list of one or more patterns
2108 separated by a `|'. Composite patterns may be formed using one or more
2109 of the following sub-patterns:
2112 Matches zero or one occurrence of the given patterns.
2115 Matches zero or more occurrences of the given patterns.
2118 Matches one or more occurrences of the given patterns.
2121 Matches one of the given patterns.
2124 Matches anything except one of the given patterns.
2127 File: bashref.info, Node: Quote Removal, Prev: Filename Expansion, Up: Shell Expansions
2132 After the preceding expansions, all unquoted occurrences of the
2133 characters `\', `'', and `"' that did not result from one of the above
2134 expansions are removed.
2137 File: bashref.info, Node: Redirections, Next: Executing Commands, Prev: Shell Expansions, Up: Basic Shell Features
2142 Before a command is executed, its input and output may be REDIRECTED
2143 using a special notation interpreted by the shell. Redirection allows
2144 commands' file handles to be duplicated, opened, closed, made to refer
2145 to different files, and can change the files the command reads from and
2146 writes to. Redirection may also be used to modify file handles in the
2147 current shell execution environment. The following redirection
2148 operators may precede or appear anywhere within a simple command or may
2149 follow a command. Redirections are processed in the order they appear,
2152 Each redirection that may be preceded by a file descriptor number
2153 may instead be preceded by a word of the form {VARNAME}. In this case,
2154 for each redirection operator except >&- and <&-, the shell will
2155 allocate a file descriptor greater than 10 and assign it to {VARNAME}.
2156 If >&- or <&- is preceded by {VARNAME}, the value of VARNAME defines
2157 the file descriptor to close.
2159 In the following descriptions, if the file descriptor number is
2160 omitted, and the first character of the redirection operator is `<',
2161 the redirection refers to the standard input (file descriptor 0). If
2162 the first character of the redirection operator is `>', the redirection
2163 refers to the standard output (file descriptor 1).
2165 The word following the redirection operator in the following
2166 descriptions, unless otherwise noted, is subjected to brace expansion,
2167 tilde expansion, parameter expansion, command substitution, arithmetic
2168 expansion, quote removal, filename expansion, and word splitting. If
2169 it expands to more than one word, Bash reports an error.
2171 Note that the order of redirections is significant. For example,
2174 directs both standard output (file descriptor 1) and standard error
2175 (file descriptor 2) to the file DIRLIST, while the command
2177 directs only the standard output to file DIRLIST, because the
2178 standard error was made a copy of the standard output before the
2179 standard output was redirected to DIRLIST.
2181 Bash handles several filenames specially when they are used in
2182 redirections, as described in the following table:
2185 If FD is a valid integer, file descriptor FD is duplicated.
2188 File descriptor 0 is duplicated.
2191 File descriptor 1 is duplicated.
2194 File descriptor 2 is duplicated.
2196 `/dev/tcp/HOST/PORT'
2197 If HOST is a valid hostname or Internet address, and PORT is an
2198 integer port number or service name, Bash attempts to open the
2199 corresponding TCP socket.
2201 `/dev/udp/HOST/PORT'
2202 If HOST is a valid hostname or Internet address, and PORT is an
2203 integer port number or service name, Bash attempts to open the
2204 corresponding UDP socket.
2206 A failure to open or create a file causes the redirection to fail.
2208 Redirections using file descriptors greater than 9 should be used
2209 with care, as they may conflict with file descriptors the shell uses
2212 3.6.1 Redirecting Input
2213 -----------------------
2215 Redirection of input causes the file whose name results from the
2216 expansion of WORD to be opened for reading on file descriptor `n', or
2217 the standard input (file descriptor 0) if `n' is not specified.
2219 The general format for redirecting input is:
2222 3.6.2 Redirecting Output
2223 ------------------------
2225 Redirection of output causes the file whose name results from the
2226 expansion of WORD to be opened for writing on file descriptor N, or the
2227 standard output (file descriptor 1) if N is not specified. If the file
2228 does not exist it is created; if it does exist it is truncated to zero
2231 The general format for redirecting output is:
2234 If the redirection operator is `>', and the `noclobber' option to
2235 the `set' builtin has been enabled, the redirection will fail if the
2236 file whose name results from the expansion of WORD exists and is a
2237 regular file. If the redirection operator is `>|', or the redirection
2238 operator is `>' and the `noclobber' option is not enabled, the
2239 redirection is attempted even if the file named by WORD exists.
2241 3.6.3 Appending Redirected Output
2242 ---------------------------------
2244 Redirection of output in this fashion causes the file whose name
2245 results from the expansion of WORD to be opened for appending on file
2246 descriptor N, or the standard output (file descriptor 1) if N is not
2247 specified. If the file does not exist it is created.
2249 The general format for appending output is:
2252 3.6.4 Redirecting Standard Output and Standard Error
2253 ----------------------------------------------------
2255 This construct allows both the standard output (file descriptor 1) and
2256 the standard error output (file descriptor 2) to be redirected to the
2257 file whose name is the expansion of WORD.
2259 There are two formats for redirecting standard output and standard
2264 Of the two forms, the first is preferred. This is semantically
2267 When using the second form, WORD may not expand to a number or `-'.
2268 If it does, other redirection operators apply (see Duplicating File
2269 Descriptors below) for compatibility reasons.
2271 3.6.5 Appending Standard Output and Standard Error
2272 --------------------------------------------------
2274 This construct allows both the standard output (file descriptor 1) and
2275 the standard error output (file descriptor 2) to be appended to the
2276 file whose name is the expansion of WORD.
2278 The format for appending standard output and standard error is:
2280 This is semantically equivalent to
2282 (see Duplicating File Descriptors below).
2284 3.6.6 Here Documents
2285 --------------------
2287 This type of redirection instructs the shell to read input from the
2288 current source until a line containing only WORD (with no trailing
2289 blanks) is seen. All of the lines read up to that point are then used
2290 as the standard input for a command.
2292 The format of here-documents is:
2297 No parameter and variable expansion, command substitution,
2298 arithmetic expansion, or filename expansion is performed on WORD. If
2299 any characters in WORD are quoted, the DELIMITER is the result of quote
2300 removal on WORD, and the lines in the here-document are not expanded.
2301 If WORD is unquoted, all lines of the here-document are subjected to
2302 parameter expansion, command substitution, and arithmetic expansion,
2303 the character sequence `\newline' is ignored, and `\' must be used to
2304 quote the characters `\', `$', and ``'.
2306 If the redirection operator is `<<-', then all leading tab
2307 characters are stripped from input lines and the line containing
2308 DELIMITER. This allows here-documents within shell scripts to be
2309 indented in a natural fashion.
2314 A variant of here documents, the format is:
2317 The WORD undergoes brace expansion, tilde expansion, parameter and
2318 variable expansion, command substitution, arithmetic expansion, and
2319 quote removal. Pathname expansion and word splitting are not performed.
2320 The result is supplied as a single string to the command on its
2323 3.6.8 Duplicating File Descriptors
2324 ----------------------------------
2326 The redirection operator
2328 is used to duplicate input file descriptors. If WORD expands to one
2329 or more digits, the file descriptor denoted by N is made to be a copy
2330 of that file descriptor. If the digits in WORD do not specify a file
2331 descriptor open for input, a redirection error occurs. If WORD
2332 evaluates to `-', file descriptor N is closed. If N is not specified,
2333 the standard input (file descriptor 0) is used.
2337 is used similarly to duplicate output file descriptors. If N is not
2338 specified, the standard output (file descriptor 1) is used. If the
2339 digits in WORD do not specify a file descriptor open for output, a
2340 redirection error occurs. If WORD evaluates to `-', file descriptor N
2341 is closed. As a special case, if N is omitted, and WORD does not
2342 expand to one or more digits or `-', the standard output and standard
2343 error are redirected as described previously.
2345 3.6.9 Moving File Descriptors
2346 -----------------------------
2348 The redirection operator
2350 moves the file descriptor DIGIT to file descriptor N, or the
2351 standard input (file descriptor 0) if N is not specified. DIGIT is
2352 closed after being duplicated to N.
2354 Similarly, the redirection operator
2356 moves the file descriptor DIGIT to file descriptor N, or the
2357 standard output (file descriptor 1) if N is not specified.
2359 3.6.10 Opening File Descriptors for Reading and Writing
2360 -------------------------------------------------------
2362 The redirection operator
2364 causes the file whose name is the expansion of WORD to be opened for
2365 both reading and writing on file descriptor N, or on file descriptor 0
2366 if N is not specified. If the file does not exist, it is created.
2369 File: bashref.info, Node: Executing Commands, Next: Shell Scripts, Prev: Redirections, Up: Basic Shell Features
2371 3.7 Executing Commands
2372 ======================
2376 * Simple Command Expansion:: How Bash expands simple commands before
2378 * Command Search and Execution:: How Bash finds commands and runs them.
2379 * Command Execution Environment:: The environment in which Bash
2380 executes commands that are not
2382 * Environment:: The environment given to a command.
2383 * Exit Status:: The status returned by commands and how Bash
2385 * Signals:: What happens when Bash or a command it runs
2389 File: bashref.info, Node: Simple Command Expansion, Next: Command Search and Execution, Up: Executing Commands
2391 3.7.1 Simple Command Expansion
2392 ------------------------------
2394 When a simple command is executed, the shell performs the following
2395 expansions, assignments, and redirections, from left to right.
2397 1. The words that the parser has marked as variable assignments (those
2398 preceding the command name) and redirections are saved for later
2401 2. The words that are not variable assignments or redirections are
2402 expanded (*note Shell Expansions::). If any words remain after
2403 expansion, the first word is taken to be the name of the command
2404 and the remaining words are the arguments.
2406 3. Redirections are performed as described above (*note
2409 4. The text after the `=' in each variable assignment undergoes tilde
2410 expansion, parameter expansion, command substitution, arithmetic
2411 expansion, and quote removal before being assigned to the variable.
2413 If no command name results, the variable assignments affect the
2414 current shell environment. Otherwise, the variables are added to the
2415 environment of the executed command and do not affect the current shell
2416 environment. If any of the assignments attempts to assign a value to a
2417 readonly variable, an error occurs, and the command exits with a
2420 If no command name results, redirections are performed, but do not
2421 affect the current shell environment. A redirection error causes the
2422 command to exit with a non-zero status.
2424 If there is a command name left after expansion, execution proceeds
2425 as described below. Otherwise, the command exits. If one of the
2426 expansions contained a command substitution, the exit status of the
2427 command is the exit status of the last command substitution performed.
2428 If there were no command substitutions, the command exits with a status
2432 File: bashref.info, Node: Command Search and Execution, Next: Command Execution Environment, Prev: Simple Command Expansion, Up: Executing Commands
2434 3.7.2 Command Search and Execution
2435 ----------------------------------
2437 After a command has been split into words, if it results in a simple
2438 command and an optional list of arguments, the following actions are
2441 1. If the command name contains no slashes, the shell attempts to
2442 locate it. If there exists a shell function by that name, that
2443 function is invoked as described in *note Shell Functions::.
2445 2. If the name does not match a function, the shell searches for it
2446 in the list of shell builtins. If a match is found, that builtin
2449 3. If the name is neither a shell function nor a builtin, and
2450 contains no slashes, Bash searches each element of `$PATH' for a
2451 directory containing an executable file by that name. Bash uses a
2452 hash table to remember the full pathnames of executable files to
2453 avoid multiple `PATH' searches (see the description of `hash' in
2454 *note Bourne Shell Builtins::). A full search of the directories
2455 in `$PATH' is performed only if the command is not found in the
2456 hash table. If the search is unsuccessful, the shell searches for
2457 a defined shell function named `command_not_found_handle'. If
2458 that function exists, it is invoked with the original command and
2459 the original command's arguments as its arguments, and the
2460 function's exit status becomes the exit status of the shell. If
2461 that function is not defined, the shell prints an error message
2462 and returns an exit status of 127.
2464 4. If the search is successful, or if the command name contains one
2465 or more slashes, the shell executes the named program in a
2466 separate execution environment. Argument 0 is set to the name
2467 given, and the remaining arguments to the command are set to the
2468 arguments supplied, if any.
2470 5. If this execution fails because the file is not in executable
2471 format, and the file is not a directory, it is assumed to be a
2472 SHELL SCRIPT and the shell executes it as described in *note Shell
2475 6. If the command was not begun asynchronously, the shell waits for
2476 the command to complete and collects its exit status.
2480 File: bashref.info, Node: Command Execution Environment, Next: Environment, Prev: Command Search and Execution, Up: Executing Commands
2482 3.7.3 Command Execution Environment
2483 -----------------------------------
2485 The shell has an EXECUTION ENVIRONMENT, which consists of the following:
2487 * open files inherited by the shell at invocation, as modified by
2488 redirections supplied to the `exec' builtin
2490 * the current working directory as set by `cd', `pushd', or `popd',
2491 or inherited by the shell at invocation
2493 * the file creation mode mask as set by `umask' or inherited from
2496 * current traps set by `trap'
2498 * shell parameters that are set by variable assignment or with `set'
2499 or inherited from the shell's parent in the environment
2501 * shell functions defined during execution or inherited from the
2502 shell's parent in the environment
2504 * options enabled at invocation (either by default or with
2505 command-line arguments) or by `set'
2507 * options enabled by `shopt' (*note The Shopt Builtin::)
2509 * shell aliases defined with `alias' (*note Aliases::)
2511 * various process IDs, including those of background jobs (*note
2512 Lists::), the value of `$$', and the value of `$PPID'
2515 When a simple command other than a builtin or shell function is to
2516 be executed, it is invoked in a separate execution environment that
2517 consists of the following. Unless otherwise noted, the values are
2518 inherited from the shell.
2520 * the shell's open files, plus any modifications and additions
2521 specified by redirections to the command
2523 * the current working directory
2525 * the file creation mode mask
2527 * shell variables and functions marked for export, along with
2528 variables exported for the command, passed in the environment
2529 (*note Environment::)
2531 * traps caught by the shell are reset to the values inherited from
2532 the shell's parent, and traps ignored by the shell are ignored
2535 A command invoked in this separate environment cannot affect the
2536 shell's execution environment.
2538 Command substitution, commands grouped with parentheses, and
2539 asynchronous commands are invoked in a subshell environment that is a
2540 duplicate of the shell environment, except that traps caught by the
2541 shell are reset to the values that the shell inherited from its parent
2542 at invocation. Builtin commands that are invoked as part of a pipeline
2543 are also executed in a subshell environment. Changes made to the
2544 subshell environment cannot affect the shell's execution environment.
2546 Subshells spawned to execute command substitutions inherit the value
2547 of the `-e' option from the parent shell. When not in POSIX mode, Bash
2548 clears the `-e' option in such subshells.
2550 If a command is followed by a `&' and job control is not active, the
2551 default standard input for the command is the empty file `/dev/null'.
2552 Otherwise, the invoked command inherits the file descriptors of the
2553 calling shell as modified by redirections.
2556 File: bashref.info, Node: Environment, Next: Exit Status, Prev: Command Execution Environment, Up: Executing Commands
2561 When a program is invoked it is given an array of strings called the
2562 ENVIRONMENT. This is a list of name-value pairs, of the form
2565 Bash provides several ways to manipulate the environment. On
2566 invocation, the shell scans its own environment and creates a parameter
2567 for each name found, automatically marking it for EXPORT to child
2568 processes. Executed commands inherit the environment. The `export'
2569 and `declare -x' commands allow parameters and functions to be added to
2570 and deleted from the environment. If the value of a parameter in the
2571 environment is modified, the new value becomes part of the environment,
2572 replacing the old. The environment inherited by any executed command
2573 consists of the shell's initial environment, whose values may be
2574 modified in the shell, less any pairs removed by the `unset' and
2575 `export -n' commands, plus any additions via the `export' and `declare
2578 The environment for any simple command or function may be augmented
2579 temporarily by prefixing it with parameter assignments, as described in
2580 *note Shell Parameters::. These assignment statements affect only the
2581 environment seen by that command.
2583 If the `-k' option is set (*note The Set Builtin::), then all
2584 parameter assignments are placed in the environment for a command, not
2585 just those that precede the command name.
2587 When Bash invokes an external command, the variable `$_' is set to
2588 the full pathname of the command and passed to that command in its
2592 File: bashref.info, Node: Exit Status, Next: Signals, Prev: Environment, Up: Executing Commands
2597 The exit status of an executed command is the value returned by the
2598 WAITPID system call or equivalent function. Exit statuses fall between
2599 0 and 255, though, as explained below, the shell may use values above
2600 125 specially. Exit statuses from shell builtins and compound commands
2601 are also limited to this range. Under certain circumstances, the shell
2602 will use special values to indicate specific failure modes.
2604 For the shell's purposes, a command which exits with a zero exit
2605 status has succeeded. A non-zero exit status indicates failure. This
2606 seemingly counter-intuitive scheme is used so there is one well-defined
2607 way to indicate success and a variety of ways to indicate various
2608 failure modes. When a command terminates on a fatal signal whose
2609 number is N, Bash uses the value 128+N as the exit status.
2611 If a command is not found, the child process created to execute it
2612 returns a status of 127. If a command is found but is not executable,
2613 the return status is 126.
2615 If a command fails because of an error during expansion or
2616 redirection, the exit status is greater than zero.
2618 The exit status is used by the Bash conditional commands (*note
2619 Conditional Constructs::) and some of the list constructs (*note
2622 All of the Bash builtins return an exit status of zero if they
2623 succeed and a non-zero status on failure, so they may be used by the
2624 conditional and list constructs. All builtins return an exit status of
2625 2 to indicate incorrect usage.
2628 File: bashref.info, Node: Signals, Prev: Exit Status, Up: Executing Commands
2633 When Bash is interactive, in the absence of any traps, it ignores
2634 `SIGTERM' (so that `kill 0' does not kill an interactive shell), and
2635 `SIGINT' is caught and handled (so that the `wait' builtin is
2636 interruptible). When Bash receives a `SIGINT', it breaks out of any
2637 executing loops. In all cases, Bash ignores `SIGQUIT'. If job control
2638 is in effect (*note Job Control::), Bash ignores `SIGTTIN', `SIGTTOU',
2641 Non-builtin commands started by Bash have signal handlers set to the
2642 values inherited by the shell from its parent. When job control is not
2643 in effect, asynchronous commands ignore `SIGINT' and `SIGQUIT' in
2644 addition to these inherited handlers. Commands run as a result of
2645 command substitution ignore the keyboard-generated job control signals
2646 `SIGTTIN', `SIGTTOU', and `SIGTSTP'.
2648 The shell exits by default upon receipt of a `SIGHUP'. Before
2649 exiting, an interactive shell resends the `SIGHUP' to all jobs, running
2650 or stopped. Stopped jobs are sent `SIGCONT' to ensure that they receive
2651 the `SIGHUP'. To prevent the shell from sending the `SIGHUP' signal to
2652 a particular job, it should be removed from the jobs table with the
2653 `disown' builtin (*note Job Control Builtins::) or marked to not
2654 receive `SIGHUP' using `disown -h'.
2656 If the `huponexit' shell option has been set with `shopt' (*note
2657 The Shopt Builtin::), Bash sends a `SIGHUP' to all jobs when an
2658 interactive login shell exits.
2660 If Bash is waiting for a command to complete and receives a signal
2661 for which a trap has been set, the trap will not be executed until the
2662 command completes. When Bash is waiting for an asynchronous command
2663 via the `wait' builtin, the reception of a signal for which a trap has
2664 been set will cause the `wait' builtin to return immediately with an
2665 exit status greater than 128, immediately after which the trap is
2669 File: bashref.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic Shell Features
2674 A shell script is a text file containing shell commands. When such a
2675 file is used as the first non-option argument when invoking Bash, and
2676 neither the `-c' nor `-s' option is supplied (*note Invoking Bash::),
2677 Bash reads and executes commands from the file, then exits. This mode
2678 of operation creates a non-interactive shell. The shell first searches
2679 for the file in the current directory, and looks in the directories in
2680 `$PATH' if not found there.
2682 When Bash runs a shell script, it sets the special parameter `0' to
2683 the name of the file, rather than the name of the shell, and the
2684 positional parameters are set to the remaining arguments, if any are
2685 given. If no additional arguments are supplied, the positional
2686 parameters are unset.
2688 A shell script may be made executable by using the `chmod' command
2689 to turn on the execute bit. When Bash finds such a file while
2690 searching the `$PATH' for a command, it spawns a subshell to execute
2691 it. In other words, executing
2693 is equivalent to executing
2694 bash filename ARGUMENTS
2696 if `filename' is an executable shell script. This subshell
2697 reinitializes itself, so that the effect is as if a new shell had been
2698 invoked to interpret the script, with the exception that the locations
2699 of commands remembered by the parent (see the description of `hash' in
2700 *note Bourne Shell Builtins::) are retained by the child.
2702 Most versions of Unix make this a part of the operating system's
2703 command execution mechanism. If the first line of a script begins with
2704 the two characters `#!', the remainder of the line specifies an
2705 interpreter for the program. Thus, you can specify Bash, `awk', Perl,
2706 or some other interpreter and write the rest of the script file in that
2709 The arguments to the interpreter consist of a single optional
2710 argument following the interpreter name on the first line of the script
2711 file, followed by the name of the script file, followed by the rest of
2712 the arguments. Bash will perform this action on operating systems that
2713 do not handle it themselves. Note that some older versions of Unix
2714 limit the interpreter name and argument to a maximum of 32 characters.
2716 Bash scripts often begin with `#! /bin/bash' (assuming that Bash has
2717 been installed in `/bin'), since this ensures that Bash will be used to
2718 interpret the script, even if it is executed under another shell.
2721 File: bashref.info, Node: Shell Builtin Commands, Next: Shell Variables, Prev: Basic Shell Features, Up: Top
2723 4 Shell Builtin Commands
2724 ************************
2728 * Bourne Shell Builtins:: Builtin commands inherited from the Bourne
2730 * Bash Builtins:: Table of builtins specific to Bash.
2731 * Modifying Shell Behavior:: Builtins to modify shell attributes and
2733 * Special Builtins:: Builtin commands classified specially by
2736 Builtin commands are contained within the shell itself. When the
2737 name of a builtin command is used as the first word of a simple command
2738 (*note Simple Commands::), the shell executes the command directly,
2739 without invoking another program. Builtin commands are necessary to
2740 implement functionality impossible or inconvenient to obtain with
2743 This section briefly describes the builtins which Bash inherits from
2744 the Bourne Shell, as well as the builtin commands which are unique to
2745 or have been extended in Bash.
2747 Several builtin commands are described in other chapters: builtin
2748 commands which provide the Bash interface to the job control facilities
2749 (*note Job Control Builtins::), the directory stack (*note Directory
2750 Stack Builtins::), the command history (*note Bash History Builtins::),
2751 and the programmable completion facilities (*note Programmable
2752 Completion Builtins::).
2754 Many of the builtins have been extended by POSIX or Bash.
2756 Unless otherwise noted, each builtin command documented as accepting
2757 options preceded by `-' accepts `--' to signify the end of the options.
2758 The `:', `true', `false', and `test' builtins do not accept options and
2759 do not treat `--' specially. The `exit', `logout', `break',
2760 `continue', `let', and `shift' builtins accept and process arguments
2761 beginning with `-' without requiring `--'. Other builtins that accept
2762 arguments but are not specified as accepting options interpret
2763 arguments beginning with `-' as invalid options and require `--' to
2764 prevent this interpretation.
2767 File: bashref.info, Node: Bourne Shell Builtins, Next: Bash Builtins, Up: Shell Builtin Commands
2769 4.1 Bourne Shell Builtins
2770 =========================
2772 The following shell builtin commands are inherited from the Bourne
2773 Shell. These commands are implemented as specified by the POSIX
2779 Do nothing beyond expanding ARGUMENTS and performing redirections.
2780 The return status is zero.
2783 . FILENAME [ARGUMENTS]
2785 Read and execute commands from the FILENAME argument in the
2786 current shell context. If FILENAME does not contain a slash, the
2787 `PATH' variable is used to find FILENAME. When Bash is not in
2788 POSIX mode, the current directory is searched if FILENAME is not
2789 found in `$PATH'. If any ARGUMENTS are supplied, they become the
2790 positional parameters when FILENAME is executed. Otherwise the
2791 positional parameters are unchanged. The return status is the
2792 exit status of the last command executed, or zero if no commands
2793 are executed. If FILENAME is not found, or cannot be read, the
2794 return status is non-zero. This builtin is equivalent to `source'.
2799 Exit from a `for', `while', `until', or `select' loop. If N is
2800 supplied, the Nth enclosing loop is exited. N must be greater
2801 than or equal to 1. The return status is zero unless N is not
2802 greater than or equal to 1.
2805 cd [-L|[-P [-e]] [-@] [DIRECTORY]
2807 Change the current working directory to DIRECTORY. If DIRECTORY
2808 is not supplied, the value of the `HOME' shell variable is used.
2809 Any additional arguments following DIRECTORY are ignored. If the
2810 shell variable `CDPATH' exists, it is used as a search path: each
2811 directory name in `CDPATH' is searched for DIRECTORY, with
2812 alternative directory names in `CDPATH' separated by a colon (`:').
2813 If DIRECTORY begins with a slash, `CDPATH' is not used.
2815 The `-P' option means to not follow symbolic links: symbolic links
2816 are resolved while `cd' is traversing DIRECTORY and before
2817 processing an instance of `..' in DIRECTORY.
2819 By default, or when the `-L' option is supplied, symbolic links in
2820 DIRECTORY are resolved after `cd' processes an instance of `..' in
2823 If `..' appears in DIRECTORY, it is processed by removing the
2824 immediately preceding pathname component, back to a slash or the
2825 beginning of DIRECTORY.
2827 If the `-e' option is supplied with `-P' and the current working
2828 directory cannot be successfully determined after a successful
2829 directory change, `cd' will return an unsuccessful status.
2831 On systems that support it, the `-@' option presents the extended
2832 attributes associated with a file as a directory.
2834 If DIRECTORY is `-', it is converted to `$OLDPWD' before the
2835 directory change is attempted.
2837 If a non-empty directory name from `CDPATH' is used, or if `-' is
2838 the first argument, and the directory change is successful, the
2839 absolute pathname of the new working directory is written to the
2842 The return status is zero if the directory is successfully changed,
2848 Resume the next iteration of an enclosing `for', `while', `until',
2849 or `select' loop. If N is supplied, the execution of the Nth
2850 enclosing loop is resumed. N must be greater than or equal to 1.
2851 The return status is zero unless N is not greater than or equal to
2857 The arguments are concatenated together into a single command,
2858 which is then read and executed, and its exit status returned as
2859 the exit status of `eval'. If there are no arguments or only
2860 empty arguments, the return status is zero.
2863 exec [-cl] [-a NAME] [COMMAND [ARGUMENTS]]
2865 If COMMAND is supplied, it replaces the shell without creating a
2866 new process. If the `-l' option is supplied, the shell places a
2867 dash at the beginning of the zeroth argument passed to COMMAND.
2868 This is what the `login' program does. The `-c' option causes
2869 COMMAND to be executed with an empty environment. If `-a' is
2870 supplied, the shell passes NAME as the zeroth argument to COMMAND.
2871 If COMMAND cannot be executed for some reason, a non-interactive
2872 shell exits, unless the `execfail' shell option is enabled. In
2873 that case, it returns failure. An interactive shell returns
2874 failure if the file cannot be executed. If no COMMAND is
2875 specified, redirections may be used to affect the current shell
2876 environment. If there are no redirection errors, the return
2877 status is zero; otherwise the return status is non-zero.
2882 Exit the shell, returning a status of N to the shell's parent. If
2883 N is omitted, the exit status is that of the last command executed.
2884 Any trap on `EXIT' is executed before the shell terminates.
2887 export [-fn] [-p] [NAME[=VALUE]]
2889 Mark each NAME to be passed to child processes in the environment.
2890 If the `-f' option is supplied, the NAMEs refer to shell
2891 functions; otherwise the names refer to shell variables. The `-n'
2892 option means to no longer mark each NAME for export. If no NAMES
2893 are supplied, or if the `-p' option is given, a list of names of
2894 all exported variables is displayed. The `-p' option displays
2895 output in a form that may be reused as input. If a variable name
2896 is followed by =VALUE, the value of the variable is set to VALUE.
2898 The return status is zero unless an invalid option is supplied,
2899 one of the names is not a valid shell variable name, or `-f' is
2900 supplied with a name that is not a shell function.
2903 getopts OPTSTRING NAME [ARGS]
2905 `getopts' is used by shell scripts to parse positional parameters.
2906 OPTSTRING contains the option characters to be recognized; if a
2907 character is followed by a colon, the option is expected to have an
2908 argument, which should be separated from it by whitespace. The
2909 colon (`:') and question mark (`?') may not be used as option
2910 characters. Each time it is invoked, `getopts' places the next
2911 option in the shell variable NAME, initializing NAME if it does
2912 not exist, and the index of the next argument to be processed into
2913 the variable `OPTIND'. `OPTIND' is initialized to 1 each time the
2914 shell or a shell script is invoked. When an option requires an
2915 argument, `getopts' places that argument into the variable
2916 `OPTARG'. The shell does not reset `OPTIND' automatically; it
2917 must be manually reset between multiple calls to `getopts' within
2918 the same shell invocation if a new set of parameters is to be used.
2920 When the end of options is encountered, `getopts' exits with a
2921 return value greater than zero. `OPTIND' is set to the index of
2922 the first non-option argument, and NAME is set to `?'.
2924 `getopts' normally parses the positional parameters, but if more
2925 arguments are given in ARGS, `getopts' parses those instead.
2927 `getopts' can report errors in two ways. If the first character of
2928 OPTSTRING is a colon, SILENT error reporting is used. In normal
2929 operation, diagnostic messages are printed when invalid options or
2930 missing option arguments are encountered. If the variable `OPTERR'
2931 is set to 0, no error messages will be displayed, even if the first
2932 character of `optstring' is not a colon.
2934 If an invalid option is seen, `getopts' places `?' into NAME and,
2935 if not silent, prints an error message and unsets `OPTARG'. If
2936 `getopts' is silent, the option character found is placed in
2937 `OPTARG' and no diagnostic message is printed.
2939 If a required argument is not found, and `getopts' is not silent,
2940 a question mark (`?') is placed in NAME, `OPTARG' is unset, and a
2941 diagnostic message is printed. If `getopts' is silent, then a
2942 colon (`:') is placed in NAME and `OPTARG' is set to the option
2946 hash [-r] [-p FILENAME] [-dt] [NAME]
2948 Each time `hash' is invoked, it remembers the full pathnames of the
2949 commands specified as NAME arguments, so they need not be searched
2950 for on subsequent invocations. The commands are found by
2951 searching through the directories listed in `$PATH'. Any
2952 previously-remembered pathname is discarded. The `-p' option
2953 inhibits the path search, and FILENAME is used as the location of
2954 NAME. The `-r' option causes the shell to forget all remembered
2955 locations. The `-d' option causes the shell to forget the
2956 remembered location of each NAME. If the `-t' option is supplied,
2957 the full pathname to which each NAME corresponds is printed. If
2958 multiple NAME arguments are supplied with `-t' the NAME is printed
2959 before the hashed full pathname. The `-l' option causes output to
2960 be displayed in a format that may be reused as input. If no
2961 arguments are given, or if only `-l' is supplied, information
2962 about remembered commands is printed. The return status is zero
2963 unless a NAME is not found or an invalid option is supplied.
2968 Print the absolute pathname of the current working directory. If
2969 the `-P' option is supplied, the pathname printed will not contain
2970 symbolic links. If the `-L' option is supplied, the pathname
2971 printed may contain symbolic links. The return status is zero
2972 unless an error is encountered while determining the name of the
2973 current directory or an invalid option is supplied.
2976 readonly [-aAf] [-p] [NAME[=VALUE]] ...
2978 Mark each NAME as readonly. The values of these names may not be
2979 changed by subsequent assignment. If the `-f' option is supplied,
2980 each NAME refers to a shell function. The `-a' option means each
2981 NAME refers to an indexed array variable; the `-A' option means
2982 each NAME refers to an associative array variable. If both
2983 options are supplied, `-A' takes precedence. If no NAME arguments
2984 are given, or if the `-p' option is supplied, a list of all
2985 readonly names is printed. The other options may be used to
2986 restrict the output to a subset of the set of readonly names. The
2987 `-p' option causes output to be displayed in a format that may be
2988 reused as input. If a variable name is followed by =VALUE, the
2989 value of the variable is set to VALUE. The return status is zero
2990 unless an invalid option is supplied, one of the NAME arguments is
2991 not a valid shell variable or function name, or the `-f' option is
2992 supplied with a name that is not a shell function.
2997 Cause a shell function to stop executing and return the value N to
2998 its caller. If N is not supplied, the return value is the exit
2999 status of the last command executed in the function. `return' may
3000 also be used to terminate execution of a script being executed
3001 with the `.' (`source') builtin, returning either N or the exit
3002 status of the last command executed within the script as the exit
3003 status of the script. If N is supplied, the return value is its
3004 least significant 8 bits. Any command associated with the
3005 `RETURN' trap is executed before execution resumes after the
3006 function or script. The return status is non-zero if `return' is
3007 supplied a non-numeric argument or is used outside a function and
3008 not during the execution of a script by `.' or `source'.
3013 Shift the positional parameters to the left by N. The positional
3014 parameters from N+1 ... `$#' are renamed to `$1' ... `$#'-N.
3015 Parameters represented by the numbers `$#' to `$#'-N+1 are unset.
3016 N must be a non-negative number less than or equal to `$#'. If N
3017 is zero or greater than `$#', the positional parameters are not
3018 changed. If N is not supplied, it is assumed to be 1. The return
3019 status is zero unless N is greater than `$#' or less than zero,
3026 Evaluate a conditional express ion EXPR and return a status of 0
3027 (true) or 1 (false). Each operator and operand must be a separate
3028 argument. Expressions are composed of the primaries described
3029 below in *note Bash Conditional Expressions::. `test' does not
3030 accept any options, nor does it accept and ignore an argument of
3031 `--' as signifying the end of options.
3033 When the `[' form is used, the last argument to the command must
3036 Expressions may be combined using the following operators, listed
3037 in decreasing order of precedence. The evaluation depends on the
3038 number of arguments; see below. Operator precedence is used when
3039 there are five or more arguments.
3042 True if EXPR is false.
3045 Returns the value of EXPR. This may be used to override the
3046 normal precedence of operators.
3049 True if both EXPR1 and EXPR2 are true.
3052 True if either EXPR1 or EXPR2 is true.
3054 The `test' and `[' builtins evaluate conditional expressions using
3055 a set of rules based on the number of arguments.
3058 The expression is false.
3061 The expression is true if and only if the argument is not
3065 If the first argument is `!', the expression is true if and
3066 only if the second argument is null. If the first argument
3067 is one of the unary conditional operators (*note Bash
3068 Conditional Expressions::), the expression is true if the
3069 unary test is true. If the first argument is not a valid
3070 unary operator, the expression is false.
3073 The following conditions are applied in the order listed. If
3074 the second argument is one of the binary conditional
3075 operators (*note Bash Conditional Expressions::), the result
3076 of the expression is the result of the binary test using the
3077 first and third arguments as operands. The `-a' and `-o'
3078 operators are considered binary operators when there are
3079 three arguments. If the first argument is `!', the value is
3080 the negation of the two-argument test using the second and
3081 third arguments. If the first argument is exactly `(' and
3082 the third argument is exactly `)', the result is the
3083 one-argument test of the second argument. Otherwise, the
3084 expression is false.
3087 If the first argument is `!', the result is the negation of
3088 the three-argument expression composed of the remaining
3089 arguments. Otherwise, the expression is parsed and evaluated
3090 according to precedence using the rules listed above.
3093 The expression is parsed and evaluated according to precedence
3094 using the rules listed above.
3096 When used with `test' or `[', the `<' and `>' operators sort
3097 lexicographically using ASCII ordering.
3102 Print out the user and system times used by the shell and its
3103 children. The return status is zero.
3106 trap [-lp] [ARG] [SIGSPEC ...]
3108 The commands in ARG are to be read and executed when the shell
3109 receives signal SIGSPEC. If ARG is absent (and there is a single
3110 SIGSPEC) or equal to `-', each specified signal's disposition is
3111 reset to the value it had when the shell was started. If ARG is
3112 the null string, then the signal specified by each SIGSPEC is
3113 ignored by the shell and commands it invokes. If ARG is not
3114 present and `-p' has been supplied, the shell displays the trap
3115 commands associated with each SIGSPEC. If no arguments are
3116 supplied, or only `-p' is given, `trap' prints the list of commands
3117 associated with each signal number in a form that may be reused as
3118 shell input. The `-l' option causes the shell to print a list of
3119 signal names and their corresponding numbers. Each SIGSPEC is
3120 either a signal name or a signal number. Signal names are case
3121 insensitive and the `SIG' prefix is optional.
3123 If a SIGSPEC is `0' or `EXIT', ARG is executed when the shell
3124 exits. If a SIGSPEC is `DEBUG', the command ARG is executed
3125 before every simple command, `for' command, `case' command,
3126 `select' command, every arithmetic `for' command, and before the
3127 first command executes in a shell function. Refer to the
3128 description of the `extdebug' option to the `shopt' builtin (*note
3129 The Shopt Builtin::) for details of its effect on the `DEBUG' trap.
3130 If a SIGSPEC is `RETURN', the command ARG is executed each time a
3131 shell function or a script executed with the `.' or `source'
3132 builtins finishes executing.
3134 If a SIGSPEC is `ERR', the command ARG is executed whenever a
3135 pipeline (which may consist of a single simple command), a list,
3136 or a compound command returns a non-zero exit status, subject to
3137 the following conditions. The `ERR' trap is not executed if the
3138 failed command is part of the command list immediately following
3139 an `until' or `while' keyword, part of the test following the `if'
3140 or `elif' reserved words, part of a command executed in a `&&' or
3141 `||' list except the command following the final `&&' or `||', any
3142 command in a pipeline but the last, or if the command's return
3143 status is being inverted using `!'. These are the same conditions
3144 obeyed by the `errexit' (`-e') option.
3146 Signals ignored upon entry to the shell cannot be trapped or reset.
3147 Trapped signals that are not being ignored are reset to their
3148 original values in a subshell or subshell environment when one is
3151 The return status is zero unless a SIGSPEC does not specify a
3155 umask [-p] [-S] [MODE]
3157 Set the shell process's file creation mask to MODE. If MODE
3158 begins with a digit, it is interpreted as an octal number; if not,
3159 it is interpreted as a symbolic mode mask similar to that accepted
3160 by the `chmod' command. If MODE is omitted, the current value of
3161 the mask is printed. If the `-S' option is supplied without a
3162 MODE argument, the mask is printed in a symbolic format. If the
3163 `-p' option is supplied, and MODE is omitted, the output is in a
3164 form that may be reused as input. The return status is zero if
3165 the mode is successfully changed or if no MODE argument is
3166 supplied, and non-zero otherwise.
3168 Note that when the mode is interpreted as an octal number, each
3169 number of the umask is subtracted from `7'. Thus, a umask of `022'
3170 results in permissions of `755'.
3175 Remove each variable or function NAME. If the `-v' option is
3176 given, each NAME refers to a shell variable and that variable is
3177 remvoved. If the `-f' option is given, the NAMEs refer to shell
3178 functions, and the function definition is removed. If the `-n'
3179 option is supplied, and NAME is a variable with the NAMEREF
3180 attribute, NAME will be unset rather than the variable it
3181 references. `-n' has no effect if the `-f' option is supplied.
3182 If no options are supplied, each NAME refers to a variable; if
3183 there is no variable by that name, any function with that name is
3184 unset. Readonly variables and functions may not be unset. The
3185 return status is zero unless a NAME is readonly.
3188 File: bashref.info, Node: Bash Builtins, Next: Modifying Shell Behavior, Prev: Bourne Shell Builtins, Up: Shell Builtin Commands
3190 4.2 Bash Builtin Commands
3191 =========================
3193 This section describes builtin commands which are unique to or have
3194 been extended in Bash. Some of these commands are specified in the
3198 alias [-p] [NAME[=VALUE] ...]
3200 Without arguments or with the `-p' option, `alias' prints the list
3201 of aliases on the standard output in a form that allows them to be
3202 reused as input. If arguments are supplied, an alias is defined
3203 for each NAME whose VALUE is given. If no VALUE is given, the name
3204 and value of the alias is printed. Aliases are described in *note
3208 bind [-m KEYMAP] [-lpsvPSVX]
3209 bind [-m KEYMAP] [-q FUNCTION] [-u FUNCTION] [-r KEYSEQ]
3210 bind [-m KEYMAP] -f FILENAME
3211 bind [-m KEYMAP] -x KEYSEQ:SHELL-COMMAND
3212 bind [-m KEYMAP] KEYSEQ:FUNCTION-NAME
3213 bind READLINE-COMMAND
3215 Display current Readline (*note Command Line Editing::) key and
3216 function bindings, bind a key sequence to a Readline function or
3217 macro, or set a Readline variable. Each non-option argument is a
3218 command as it would appear in a Readline initialization file
3219 (*note Readline Init File::), but each binding or command must be
3220 passed as a separate argument; e.g.,
3221 `"\C-x\C-r":re-read-init-file'.
3223 Options, if supplied, have the following meanings:
3226 Use KEYMAP as the keymap to be affected by the subsequent
3227 bindings. Acceptable KEYMAP names are `emacs',
3228 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
3229 `vi-command', and `vi-insert'. `vi' is equivalent to
3230 `vi-command'; `emacs' is equivalent to `emacs-standard'.
3233 List the names of all Readline functions.
3236 Display Readline function names and bindings in such a way
3237 that they can be used as input or in a Readline
3238 initialization file.
3241 List current Readline function names and bindings.
3244 Display Readline variable names and values in such a way that
3245 they can be used as input or in a Readline initialization
3249 List current Readline variable names and values.
3252 Display Readline key sequences bound to macros and the
3253 strings they output in such a way that they can be used as
3254 input or in a Readline initialization file.
3257 Display Readline key sequences bound to macros and the
3258 strings they output.
3261 Read key bindings from FILENAME.
3264 Query about which keys invoke the named FUNCTION.
3267 Unbind all keys bound to the named FUNCTION.
3270 Remove any current binding for KEYSEQ.
3272 `-x KEYSEQ:SHELL-COMMAND'
3273 Cause SHELL-COMMAND to be executed whenever KEYSEQ is entered.
3274 When SHELL-COMMAND is executed, the shell sets the
3275 `READLINE_LINE' variable to the contents of the Readline line
3276 buffer and the `READLINE_POINT' variable to the current
3277 location of the insertion point. If the executed command
3278 changes the value of `READLINE_LINE' or `READLINE_POINT',
3279 those new values will be reflected in the editing state.
3282 List all key sequences bound to shell commands and the
3283 associated commands in a format that can be reused as input.
3285 The return status is zero unless an invalid option is supplied or
3289 builtin [SHELL-BUILTIN [ARGS]]
3291 Run a shell builtin, passing it ARGS, and return its exit status.
3292 This is useful when defining a shell function with the same name
3293 as a shell builtin, retaining the functionality of the builtin
3294 within the function. The return status is non-zero if
3295 SHELL-BUILTIN is not a shell builtin command.
3300 Returns the context of any active subroutine call (a shell
3301 function or a script executed with the `.' or `source' builtins).
3303 Without EXPR, `caller' displays the line number and source
3304 filename of the current subroutine call. If a non-negative
3305 integer is supplied as EXPR, `caller' displays the line number,
3306 subroutine name, and source file corresponding to that position in
3307 the current execution call stack. This extra information may be
3308 used, for example, to print a stack trace. The current frame is
3311 The return value is 0 unless the shell is not executing a
3312 subroutine call or EXPR does not correspond to a valid position in
3316 command [-pVv] COMMAND [ARGUMENTS ...]
3318 Runs COMMAND with ARGUMENTS ignoring any shell function named
3319 COMMAND. Only shell builtin commands or commands found by
3320 searching the `PATH' are executed. If there is a shell function
3321 named `ls', running `command ls' within the function will execute
3322 the external command `ls' instead of calling the function
3323 recursively. The `-p' option means to use a default value for
3324 `PATH' that is guaranteed to find all of the standard utilities.
3325 The return status in this case is 127 if COMMAND cannot be found
3326 or an error occurred, and the exit status of COMMAND otherwise.
3328 If either the `-V' or `-v' option is supplied, a description of
3329 COMMAND is printed. The `-v' option causes a single word
3330 indicating the command or file name used to invoke COMMAND to be
3331 displayed; the `-V' option produces a more verbose description.
3332 In this case, the return status is zero if COMMAND is found, and
3336 declare [-aAfFgilnrtux] [-p] [NAME[=VALUE] ...]
3338 Declare variables and give them attributes. If no NAMEs are
3339 given, then display the values of variables instead.
3341 The `-p' option will display the attributes and values of each
3342 NAME. When `-p' is used with NAME arguments, additional options,
3343 other than `-f' and `-F', are ignored.
3345 When `-p' is supplied without NAME arguments, `declare' will
3346 display the attributes and values of all variables having the
3347 attributes specified by the additional options. If no other
3348 options are supplied with `-p', `declare' will display the
3349 attributes and values of all shell variables. The `-f' option
3350 will restrict the display to shell functions.
3352 The `-F' option inhibits the display of function definitions; only
3353 the function name and attributes are printed. If the `extdebug'
3354 shell option is enabled using `shopt' (*note The Shopt Builtin::),
3355 the source file name and line number where the function is defined
3356 are displayed as well. `-F' implies `-f'.
3358 The `-g' option forces variables to be created or modified at the
3359 global scope, even when `declare' is executed in a shell function.
3360 It is ignored in all other cases.
3362 The following options can be used to restrict output to variables
3363 with the specified attributes or to give variables attributes:
3366 Each NAME is an indexed array variable (*note Arrays::).
3369 Each NAME is an associative array variable (*note Arrays::).
3372 Use function names only.
3375 The variable is to be treated as an integer; arithmetic
3376 evaluation (*note Shell Arithmetic::) is performed when the
3377 variable is assigned a value.
3380 When the variable is assigned a value, all upper-case
3381 characters are converted to lower-case. The upper-case
3382 attribute is disabled.
3385 Give each NAME the NAMEREF attribute, making it a name
3386 reference to another variable. That other variable is
3387 defined by the value of NAME. All references and assignments
3388 to NAME, except for changing the `-n' attribute itself, are
3389 performed on the variable referenced by NAME's value. The
3390 `-n' attribute cannot be applied to array variables.
3393 Make NAMEs readonly. These names cannot then be assigned
3394 values by subsequent assignment statements or unset.
3397 Give each NAME the `trace' attribute. Traced functions
3398 inherit the `DEBUG' and `RETURN' traps from the calling shell.
3399 The trace attribute has no special meaning for variables.
3402 When the variable is assigned a value, all lower-case
3403 characters are converted to upper-case. The lower-case
3404 attribute is disabled.
3407 Mark each NAME for export to subsequent commands via the
3410 Using `+' instead of `-' turns off the attribute instead, with the
3411 exceptions that `+a' may not be used to destroy an array variable
3412 and `+r' will not remove the readonly attribute. When used in a
3413 function, `declare' makes each NAME local, as with the `local'
3414 command, unless the `-g' option is used. If a variable name is
3415 followed by =VALUE, the value of the variable is set to VALUE.
3417 When using `-a' or `-A' and the compound assignment syntax to
3418 create array variables, additional attributes do not take effect
3419 until subsequent assignments.
3421 The return status is zero unless an invalid option is encountered,
3422 an attempt is made to define a function using `-f foo=bar', an
3423 attempt is made to assign a value to a readonly variable, an
3424 attempt is made to assign a value to an array variable without
3425 using the compound assignment syntax (*note Arrays::), one of the
3426 NAMES is not a valid shell variable name, an attempt is made to
3427 turn off readonly status for a readonly variable, an attempt is
3428 made to turn off array status for an array variable, or an attempt
3429 is made to display a non-existent function with `-f'.
3432 echo [-neE] [ARG ...]
3434 Output the ARGs, separated by spaces, terminated with a newline.
3435 The return status is 0 unless a write error occurs. If `-n' is
3436 specified, the trailing newline is suppressed. If the `-e' option
3437 is given, interpretation of the following backslash-escaped
3438 characters is enabled. The `-E' option disables the
3439 interpretation of these escape characters, even on systems where
3440 they are interpreted by default. The `xpg_echo' shell option may
3441 be used to dynamically determine whether or not `echo' expands
3442 these escape characters by default. `echo' does not interpret
3443 `--' to mean the end of options.
3445 `echo' interprets the following escape sequences:
3453 suppress further output
3478 the eight-bit character whose value is the octal value NNN
3479 (zero to three octal digits)
3482 the eight-bit character whose value is the hexadecimal value
3483 HH (one or two hex digits)
3486 the Unicode (ISO/IEC 10646) character whose value is the
3487 hexadecimal value HHHH (one to four hex digits)
3490 the Unicode (ISO/IEC 10646) character whose value is the
3491 hexadecimal value HHHHHHHH (one to eight hex digits)
3494 enable [-a] [-dnps] [-f FILENAME] [NAME ...]
3496 Enable and disable builtin shell commands. Disabling a builtin
3497 allows a disk command which has the same name as a shell builtin
3498 to be executed without specifying a full pathname, even though the
3499 shell normally searches for builtins before disk commands. If
3500 `-n' is used, the NAMEs become disabled. Otherwise NAMEs are
3501 enabled. For example, to use the `test' binary found via `$PATH'
3502 instead of the shell builtin version, type `enable -n test'.
3504 If the `-p' option is supplied, or no NAME arguments appear, a
3505 list of shell builtins is printed. With no other arguments, the
3506 list consists of all enabled shell builtins. The `-a' option
3507 means to list each builtin with an indication of whether or not it
3510 The `-f' option means to load the new builtin command NAME from
3511 shared object FILENAME, on systems that support dynamic loading.
3512 The `-d' option will delete a builtin loaded with `-f'.
3514 If there are no options, a list of the shell builtins is displayed.
3515 The `-s' option restricts `enable' to the POSIX special builtins.
3516 If `-s' is used with `-f', the new builtin becomes a special
3517 builtin (*note Special Builtins::).
3519 The return status is zero unless a NAME is not a shell builtin or
3520 there is an error loading a new builtin from a shared object.
3523 help [-dms] [PATTERN]
3525 Display helpful information about builtin commands. If PATTERN is
3526 specified, `help' gives detailed help on all commands matching
3527 PATTERN, otherwise a list of the builtins is printed.
3529 Options, if supplied, have the following meanings:
3532 Display a short description of each PATTERN
3535 Display the description of each PATTERN in a manpage-like
3539 Display only a short usage synopsis for each PATTERN
3541 The return status is zero unless no command matches PATTERN.
3544 let EXPRESSION [EXPRESSION ...]
3546 The `let' builtin allows arithmetic to be performed on shell
3547 variables. Each EXPRESSION is evaluated according to the rules
3548 given below in *note Shell Arithmetic::. If the last EXPRESSION
3549 evaluates to 0, `let' returns 1; otherwise 0 is returned.
3552 local [OPTION] NAME[=VALUE] ...
3554 For each argument, a local variable named NAME is created, and
3555 assigned VALUE. The OPTION can be any of the options accepted by
3556 `declare'. `local' can only be used within a function; it makes
3557 the variable NAME have a visible scope restricted to that function
3558 and its children. The return status is zero unless `local' is
3559 used outside a function, an invalid NAME is supplied, or NAME is a
3565 Exit a login shell, returning a status of N to the shell's parent.
3568 mapfile [-n COUNT] [-O ORIGIN] [-s COUNT] [-t] [-u FD]
3569 [-C CALLBACK] [-c QUANTUM] [ARRAY]
3571 Read lines from the standard input into the indexed array variable
3572 ARRAY, or from file descriptor FD if the `-u' option is supplied.
3573 The variable `MAPFILE' is the default ARRAY. Options, if
3574 supplied, have the following meanings:
3577 Copy at most COUNT lines. If COUNT is 0, all lines are
3581 Begin assigning to ARRAY at index ORIGIN. The default index
3585 Discard the first COUNT lines read.
3588 Remove a trailing newline from each line read.
3591 Read lines from file descriptor FD instead of the standard
3595 Evaluate CALLBACK each time QUANTUMP lines are read. The
3596 `-c' option specifies QUANTUM.
3599 Specify the number of lines read between each call to
3602 If `-C' is specified without `-c', the default quantum is 5000.
3603 When CALLBACK is evaluated, it is supplied the index of the next
3604 array element to be assigned and the line to be assigned to that
3605 element as additional arguments. CALLBACK is evaluated after the
3606 line is read but before the array element is assigned.
3608 If not supplied with an explicit origin, `mapfile' will clear ARRAY
3609 before assigning to it.
3611 `mapfile' returns successfully unless an invalid option or option
3612 argument is supplied, ARRAY is invalid or unassignable, or ARRAY
3613 is not an indexed array.
3616 printf [-v VAR] FORMAT [ARGUMENTS]
3618 Write the formatted ARGUMENTS to the standard output under the
3619 control of the FORMAT. The `-v' option causes the output to be
3620 assigned to the variable VAR rather than being printed to the
3623 The FORMAT is a character string which contains three types of
3624 objects: plain characters, which are simply copied to standard
3625 output, character escape sequences, which are converted and copied
3626 to the standard output, and format specifications, each of which
3627 causes printing of the next successive ARGUMENT. In addition to
3628 the standard `printf(1)' formats, `printf' interprets the
3629 following extensions:
3632 Causes `printf' to expand backslash escape sequences in the
3633 corresponding ARGUMENT, except that `\c' terminates output,
3634 backslashes in `\'', `\"', and `\?' are not removed, and
3635 octal escapes beginning with `\0' may contain up to four
3639 Causes `printf' to output the corresponding ARGUMENT in a
3640 format that can be reused as shell input.
3643 Causes `printf' to output the date-time string resulting from
3644 using DATEFMT as a format string for `strftime'(3). The
3645 corresponding ARGUMENT is an integer representing the number
3646 of seconds since the epoch. Two special argument values may
3647 be used: -1 represents the current time, and -2 represents
3648 the time the shell was invoked. If no argument is specified,
3649 conversion behaves as if -1 had been given. This is an
3650 exception to the usual `printf' behavior.
3652 Arguments to non-string format specifiers are treated as C
3653 language constants, except that a leading plus or minus sign is
3654 allowed, and if the leading character is a single or double quote,
3655 the value is the ASCII value of the following character.
3657 The FORMAT is reused as necessary to consume all of the ARGUMENTS.
3658 If the FORMAT requires more ARGUMENTS than are supplied, the extra
3659 format specifications behave as if a zero value or null string, as
3660 appropriate, had been supplied. The return value is zero on
3661 success, non-zero on failure.
3664 read [-ers] [-a ANAME] [-d DELIM] [-i TEXT] [-n NCHARS]
3665 [-N NCHARS] [-p PROMPT] [-t TIMEOUT] [-u FD] [NAME ...]
3667 One line is read from the standard input, or from the file
3668 descriptor FD supplied as an argument to the `-u' option, and the
3669 first word is assigned to the first NAME, the second word to the
3670 second NAME, and so on, with leftover words and their intervening
3671 separators assigned to the last NAME. If there are fewer words
3672 read from the input stream than names, the remaining names are
3673 assigned empty values. The characters in the value of the `IFS'
3674 variable are used to split the line into words using the same
3675 rules the shell uses for expansion (described above in *note Word
3676 Splitting::). The backslash character `\' may be used to remove
3677 any special meaning for the next character read and for line
3678 continuation. If no names are supplied, the line read is assigned
3679 to the variable `REPLY'. The return code is zero, unless
3680 end-of-file is encountered, `read' times out (in which case the
3681 return code is greater than 128), a variable assignment error
3682 (such as assigning to a readonly variable) occurs, or an invalid
3683 file descriptor is supplied as the argument to `-u'.
3685 Options, if supplied, have the following meanings:
3688 The words are assigned to sequential indices of the array
3689 variable ANAME, starting at 0. All elements are removed from
3690 ANAME before the assignment. Other NAME arguments are
3694 The first character of DELIM is used to terminate the input
3695 line, rather than newline.
3698 Readline (*note Command Line Editing::) is used to obtain the
3699 line. Readline uses the current (or default, if line editing
3700 was not previously active) editing settings.
3703 If Readline is being used to read the line, TEXT is placed
3704 into the editing buffer before editing begins.
3707 `read' returns after reading NCHARS characters rather than
3708 waiting for a complete line of input, but honor a delimiter
3709 if fewer than NCHARS characters are read before the delimiter.
3712 `read' returns after reading exactly NCHARS characters rather
3713 than waiting for a complete line of input, unless EOF is
3714 encountered or `read' times out. Delimiter characters
3715 encountered in the input are not treated specially and do not
3716 cause `read' to return until NCHARS characters are read.
3719 Display PROMPT, without a trailing newline, before attempting
3720 to read any input. The prompt is displayed only if input is
3721 coming from a terminal.
3724 If this option is given, backslash does not act as an escape
3725 character. The backslash is considered to be part of the
3726 line. In particular, a backslash-newline pair may not be
3727 used as a line continuation.
3730 Silent mode. If input is coming from a terminal, characters
3734 Cause `read' to time out and return failure if a complete
3735 line of input (or a specified number of characters) is not
3736 read within TIMEOUT seconds. TIMEOUT may be a decimal
3737 number with a fractional portion following the decimal point.
3738 This option is only effective if `read' is reading input from
3739 a terminal, pipe, or other special file; it has no effect
3740 when reading from regular files. If `read' times out, `read'
3741 saves any partial input read into the specified variable NAME.
3742 If TIMEOUT is 0, `read' returns immediately, without trying to
3743 read and data. The exit status is 0 if input is available on
3744 the specified file descriptor, non-zero otherwise. The exit
3745 status is greater than 128 if the timeout is exceeded.
3748 Read input from file descriptor FD.
3751 readarray [-n COUNT] [-O ORIGIN] [-s COUNT] [-t] [-u FD]
3752 [-C CALLBACK] [-c QUANTUM] [ARRAY]
3754 Read lines from the standard input into the indexed array variable
3755 ARRAY, or from file descriptor FD if the `-u' option is supplied.
3757 A synonym for `mapfile'.
3762 A synonym for `.' (*note Bourne Shell Builtins::).
3765 type [-afptP] [NAME ...]
3767 For each NAME, indicate how it would be interpreted if used as a
3770 If the `-t' option is used, `type' prints a single word which is
3771 one of `alias', `function', `builtin', `file' or `keyword', if
3772 NAME is an alias, shell function, shell builtin, disk file, or
3773 shell reserved word, respectively. If the NAME is not found, then
3774 nothing is printed, and `type' returns a failure status.
3776 If the `-p' option is used, `type' either returns the name of the
3777 disk file that would be executed, or nothing if `-t' would not
3780 The `-P' option forces a path search for each NAME, even if `-t'
3781 would not return `file'.
3783 If a command is hashed, `-p' and `-P' print the hashed value,
3784 which is not necessarily the file that appears first in `$PATH'.
3786 If the `-a' option is used, `type' returns all of the places that
3787 contain an executable named FILE. This includes aliases and
3788 functions, if and only if the `-p' option is not also used.
3790 If the `-f' option is used, `type' does not attempt to find shell
3791 functions, as with the `command' builtin.
3793 The return status is zero if all of the NAMES are found, non-zero
3794 if any are not found.
3797 typeset [-afFgrxilnrtux] [-p] [NAME[=VALUE] ...]
3799 The `typeset' command is supplied for compatibility with the Korn
3800 shell. It is a synonym for the `declare' builtin command.
3803 ulimit [-abcdefilmnpqrstuvxHST] [LIMIT]
3805 `ulimit' provides control over the resources available to processes
3806 started by the shell, on systems that allow such control. If an
3807 option is given, it is interpreted as follows:
3810 Change and report the soft limit associated with a resource.
3813 Change and report the hard limit associated with a resource.
3816 All current limits are reported.
3819 The maximum socket buffer size.
3822 The maximum size of core files created.
3825 The maximum size of a process's data segment.
3828 The maximum scheduling priority ("nice").
3831 The maximum size of files written by the shell and its
3835 The maximum number of pending signals.
3838 The maximum size that may be locked into memory.
3841 The maximum resident set size (many systems do not honor this
3845 The maximum number of open file descriptors (most systems do
3846 not allow this value to be set).
3849 The pipe buffer size.
3852 The maximum number of bytes in POSIX message queues.
3855 The maximum real-time scheduling priority.
3858 The maximum stack size.
3861 The maximum amount of cpu time in seconds.
3864 The maximum number of processes available to a single user.
3867 The maximum amount of virtual memory available to the shell,
3868 and, on some systems, to its children.
3871 The maximum number of file locks.
3874 The maximum number of threads.
3876 If LIMIT is given, and the `-a' option is not used, LIMIT is the
3877 new value of the specified resource. The special LIMIT values
3878 `hard', `soft', and `unlimited' stand for the current hard limit,
3879 the current soft limit, and no limit, respectively. A hard limit
3880 cannot be increased by a non-root user once it is set; a soft
3881 limit may be increased up to the value of the hard limit.
3882 Otherwise, the current value of the soft limit for the specified
3883 resource is printed, unless the `-H' option is supplied. When
3884 setting new limits, if neither `-H' nor `-S' is supplied, both the
3885 hard and soft limits are set. If no option is given, then `-f' is
3886 assumed. Values are in 1024-byte increments, except for `-t',
3887 which is in seconds; `-p', which is in units of 512-byte blocks;
3888 and `-T', `-b', `-n' and `-u', which are unscaled values.
3890 The return status is zero unless an invalid option or argument is
3891 supplied, or an error occurs while setting a new limit.
3894 unalias [-a] [NAME ... ]
3896 Remove each NAME from the list of aliases. If `-a' is supplied,
3897 all aliases are removed. Aliases are described in *note Aliases::.
3900 File: bashref.info, Node: Modifying Shell Behavior, Next: Special Builtins, Prev: Bash Builtins, Up: Shell Builtin Commands
3902 4.3 Modifying Shell Behavior
3903 ============================
3907 * The Set Builtin:: Change the values of shell attributes and
3908 positional parameters.
3909 * The Shopt Builtin:: Modify shell optional behavior.
3912 File: bashref.info, Node: The Set Builtin, Next: The Shopt Builtin, Up: Modifying Shell Behavior
3914 4.3.1 The Set Builtin
3915 ---------------------
3917 This builtin is so complicated that it deserves its own section. `set'
3918 allows you to change the values of shell options and set the positional
3919 parameters, or to display the names and values of shell variables.
3922 set [--abefhkmnptuvxBCEHPT] [-o OPTION-NAME] [ARGUMENT ...]
3923 set [+abefhkmnptuvxBCEHPT] [+o OPTION-NAME] [ARGUMENT ...]
3925 If no options or arguments are supplied, `set' displays the names
3926 and values of all shell variables and functions, sorted according
3927 to the current locale, in a format that may be reused as input for
3928 setting or resetting the currently-set variables. Read-only
3929 variables cannot be reset. In POSIX mode, only shell variables
3932 When options are supplied, they set or unset shell attributes.
3933 Options, if specified, have the following meanings:
3936 Mark variables and function which are modified or created for
3937 export to the environment of subsequent commands.
3940 Cause the status of terminated background jobs to be reported
3941 immediately, rather than before printing the next primary
3945 Exit immediately if a pipeline (*note Pipelines::), which may
3946 consist of a single simple command (*note Simple Commands::),
3947 a list (*note Lists::), or a compound command (*note Compound
3948 Commands::) returns a non-zero status. The shell does not
3949 exit if the command that fails is part of the command list
3950 immediately following a `while' or `until' keyword, part of
3951 the test in an `if' statement, part of any command executed
3952 in a `&&' or `||' list except the command following the final
3953 `&&' or `||', any command in a pipeline but the last, or if
3954 the command's return status is being inverted with `!'. If a
3955 compound command other than a subshell returns a non-zero
3956 status because a command failed while `-e' was being ignored,
3957 the shell does not exit. A trap on `ERR', if set, is
3958 executed before the shell exits.
3960 This option applies to the shell environment and each
3961 subshell environment separately (*note Command Execution
3962 Environment::), and may cause subshells to exit before
3963 executing all the commands in the subshell.
3965 If a compound command or shell function executes in a context
3966 where `-e' is being ignored, none of the commands executed
3967 within the compound command or function body will be affected
3968 by the `-e' setting, even if `-e' is set and a command
3969 returns a failure status. If a compound command or shell
3970 function sets `-e' while executing in a context where `-e' is
3971 ignored, that setting will not have any effect until the
3972 compound command or the command containing the function call
3976 Disable filename expansion (globbing).
3979 Locate and remember (hash) commands as they are looked up for
3980 execution. This option is enabled by default.
3983 All arguments in the form of assignment statements are placed
3984 in the environment for a command, not just those that precede
3988 Job control is enabled (*note Job Control::). All processes
3989 run in a separate process group. When a background job
3990 completes, the shell prints a line containing its exit status.
3993 Read commands but do not execute them; this may be used to
3994 check a script for syntax errors. This option is ignored by
3998 Set the option corresponding to OPTION-NAME:
4007 Use an `emacs'-style line editing interface (*note
4008 Command Line Editing::). This also affects the editing
4009 interface used for `read -e'.
4027 Enable command history, as described in *note Bash
4028 History Facilities::. This option is on by default in
4032 An interactive shell will not exit upon reading EOF.
4065 If set, the return value of a pipeline is the value of
4066 the last (rightmost) command to exit with a non-zero
4067 status, or zero if all commands in the pipeline exit
4068 successfully. This option is disabled by default.
4071 Change the behavior of Bash where the default operation
4072 differs from the POSIX standard to match the standard
4073 (*note Bash POSIX Mode::). This is intended to make
4074 Bash behave as a strict superset of that standard.
4083 Use a `vi'-style line editing interface. This also
4084 affects the editing interface used for `read -e'.
4090 Turn on privileged mode. In this mode, the `$BASH_ENV' and
4091 `$ENV' files are not processed, shell functions are not
4092 inherited from the environment, and the `SHELLOPTS',
4093 `BASHOPTS', `CDPATH' and `GLOBIGNORE' variables, if they
4094 appear in the environment, are ignored. If the shell is
4095 started with the effective user (group) id not equal to the
4096 real user (group) id, and the `-p' option is not supplied,
4097 these actions are taken and the effective user id is set to
4098 the real user id. If the `-p' option is supplied at startup,
4099 the effective user id is not reset. Turning this option off
4100 causes the effective user and group ids to be set to the real
4104 Exit after reading and executing one command.
4107 Treat unset variables and parameters other than the special
4108 parameters `@' or `*' as an error when performing parameter
4109 expansion. An error message will be written to the standard
4110 error, and a non-interactive shell will exit.
4113 Print shell input lines as they are read.
4116 Print a trace of simple commands, `for' commands, `case'
4117 commands, `select' commands, and arithmetic `for' commands
4118 and their arguments or associated word lists after they are
4119 expanded and before they are executed. The value of the `PS4'
4120 variable is expanded and the resultant value is printed before
4121 the command and its expanded arguments.
4124 The shell will perform brace expansion (*note Brace
4125 Expansion::). This option is on by default.
4128 Prevent output redirection using `>', `>&', and `<>' from
4129 overwriting existing files.
4132 If set, any trap on `ERR' is inherited by shell functions,
4133 command substitutions, and commands executed in a subshell
4134 environment. The `ERR' trap is normally not inherited in
4138 Enable `!' style history substitution (*note History
4139 Interaction::). This option is on by default for interactive
4143 If set, do not resolve symbolic links when performing
4144 commands such as `cd' which change the current directory.
4145 The physical directory is used instead. By default, Bash
4146 follows the logical chain of directories when performing
4147 commands which change the current directory.
4149 For example, if `/usr/sys' is a symbolic link to
4150 `/usr/local/sys' then:
4151 $ cd /usr/sys; echo $PWD
4156 If `set -P' is on, then:
4157 $ cd /usr/sys; echo $PWD
4163 If set, any trap on `DEBUG' and `RETURN' are inherited by
4164 shell functions, command substitutions, and commands executed
4165 in a subshell environment. The `DEBUG' and `RETURN' traps
4166 are normally not inherited in such cases.
4169 If no arguments follow this option, then the positional
4170 parameters are unset. Otherwise, the positional parameters
4171 are set to the ARGUMENTS, even if some of them begin with a
4175 Signal the end of options, cause all remaining ARGUMENTS to
4176 be assigned to the positional parameters. The `-x' and `-v'
4177 options are turned off. If there are no arguments, the
4178 positional parameters remain unchanged.
4180 Using `+' rather than `-' causes these options to be turned off.
4181 The options can also be used upon invocation of the shell. The
4182 current set of options may be found in `$-'.
4184 The remaining N ARGUMENTS are positional parameters and are
4185 assigned, in order, to `$1', `$2', ... `$N'. The special
4186 parameter `#' is set to N.
4188 The return status is always zero unless an invalid option is
4192 File: bashref.info, Node: The Shopt Builtin, Prev: The Set Builtin, Up: Modifying Shell Behavior
4194 4.3.2 The Shopt Builtin
4195 -----------------------
4197 This builtin allows you to change additional shell optional behavior.
4200 shopt [-pqsu] [-o] [OPTNAME ...]
4202 Toggle the values of settings controlling optional shell behavior.
4203 The settings can be either those listed below, or, if the `-o'
4204 option is used, those available with the `-o' option to the `set'
4205 builtin command (*note The Set Builtin::). With no options, or
4206 with the `-p' option, a list of all settable options is displayed,
4207 with an indication of whether or not each is set. The `-p' option
4208 causes output to be displayed in a form that may be reused as
4209 input. Other options have the following meanings:
4212 Enable (set) each OPTNAME.
4215 Disable (unset) each OPTNAME.
4218 Suppresses normal output; the return status indicates whether
4219 the OPTNAME is set or unset. If multiple OPTNAME arguments
4220 are given with `-q', the return status is zero if all
4221 OPTNAMES are enabled; non-zero otherwise.
4224 Restricts the values of OPTNAME to be those defined for the
4225 `-o' option to the `set' builtin (*note The Set Builtin::).
4227 If either `-s' or `-u' is used with no OPTNAME arguments, `shopt'
4228 shows only those options which are set or unset, respectively.
4230 Unless otherwise noted, the `shopt' options are disabled (off) by
4233 The return status when listing options is zero if all OPTNAMES are
4234 enabled, non-zero otherwise. When setting or unsetting options,
4235 the return status is zero unless an OPTNAME is not a valid shell
4238 The list of `shopt' options is:
4240 If set, a command name that is the name of a directory is
4241 executed as if it were the argument to the `cd' command.
4242 This option is only used by interactive shells.
4245 If this is set, an argument to the `cd' builtin command that
4246 is not a directory is assumed to be the name of a variable
4247 whose value is the directory to change to.
4250 If set, minor errors in the spelling of a directory component
4251 in a `cd' command will be corrected. The errors checked for
4252 are transposed characters, a missing character, and a
4253 character too many. If a correction is found, the corrected
4254 path is printed, and the command proceeds. This option is
4255 only used by interactive shells.
4258 If this is set, Bash checks that a command found in the hash
4259 table exists before trying to execute it. If a hashed
4260 command no longer exists, a normal path search is performed.
4263 If set, Bash lists the status of any stopped and running jobs
4264 before exiting an interactive shell. If any jobs are
4265 running, this causes the exit to be deferred until a second
4266 exit is attempted without an intervening command (*note Job
4267 Control::). The shell always postpones exiting if any jobs
4271 If set, Bash checks the window size after each command and,
4272 if necessary, updates the values of `LINES' and `COLUMNS'.
4275 If set, Bash attempts to save all lines of a multiple-line
4276 command in the same history entry. This allows easy
4277 re-editing of multi-line commands.
4280 If set, Bash changes its behavior to that of version 3.1 with
4281 respect to quoted arguments to the conditional command's `=~'
4282 operator and with respect to locale-specific string
4283 comparison when using the `[[' conditional command's `<' and
4284 `>' operators. Bash versions prior to bash-4.1 use ASCII
4285 collation and strcmp(3); bash-4.1 and later use the current
4286 locale's collation sequence and strcoll(3).
4289 If set, Bash changes its behavior to that of version 3.2 with
4290 respect to locale-specific string comparison when using the
4291 `[[' conditional command's `<' and `>' operators (see
4295 If set, Bash changes its behavior to that of version 4.0 with
4296 respect to locale-specific string comparison when using the
4297 `[[' conditional command's `<' and `>' operators (see
4298 description of `compat31') and the effect of interrupting a
4299 command list. Bash versions 4.0 and later interrupt the list
4300 as if the shell received the interrupt; previous versions
4301 continue with the next command in the list.
4304 If set, Bash, when in POSIX mode, treats a single quote in a
4305 double-quoted parameter expansion as a special character.
4306 The single quotes must match (an even number) and the
4307 characters between the single quotes are considered quoted.
4308 This is the behavior of POSIX mode through version 4.1. The
4309 default Bash behavior remains as in previous versions.
4312 If set, Bash does not process the replacement string in the
4313 pattern substitution word expansion using quote removal.
4315 `complete_fullquote'
4316 If set, Bash quotes all shell metacharacters in filenames and
4317 directory names when performing completion. If not set, Bash
4318 removes metacharacters such as the dollar sign from the set of
4319 characters that will be quoted in completed filenames when
4320 these metacharacters appear in shell variable references in
4321 words to be completed. This means that dollar signs in
4322 variable names that expand to directories will not be quoted;
4323 however, any dollar signs appearing in filenames will not be
4324 quoted, either. This is active only when bash is using
4325 backslashes to quote completed filenames. This variable is
4326 set by default, which is the default Bash behavior in
4327 versions through 4.2.
4330 If set, Bash replaces directory names with the results of
4331 word expansion when performing filename completion. This
4332 changes the contents of the readline editing buffer. If not
4333 set, Bash attempts to preserve what the user typed.
4336 If set, Bash attempts spelling correction on directory names
4337 during word completion if the directory name initially
4338 supplied does not exist.
4341 If set, Bash includes filenames beginning with a `.' in the
4342 results of filename expansion.
4345 If this is set, a non-interactive shell will not exit if it
4346 cannot execute the file specified as an argument to the `exec'
4347 builtin command. An interactive shell does not exit if `exec'
4351 If set, aliases are expanded as described below under Aliases,
4352 *note Aliases::. This option is enabled by default for
4356 If set, behavior intended for use by debuggers is enabled:
4358 1. The `-F' option to the `declare' builtin (*note Bash
4359 Builtins::) displays the source file name and line
4360 number corresponding to each function name supplied as
4363 2. If the command run by the `DEBUG' trap returns a
4364 non-zero value, the next command is skipped and not
4367 3. If the command run by the `DEBUG' trap returns a value
4368 of 2, and the shell is executing in a subroutine (a
4369 shell function or a shell script executed by the `.' or
4370 `source' builtins), a call to `return' is simulated.
4372 4. `BASH_ARGC' and `BASH_ARGV' are updated as described in
4373 their descriptions (*note Bash Variables::).
4375 5. Function tracing is enabled: command substitution,
4376 shell functions, and subshells invoked with `( COMMAND
4377 )' inherit the `DEBUG' and `RETURN' traps.
4379 6. Error tracing is enabled: command substitution, shell
4380 functions, and subshells invoked with `( COMMAND )'
4381 inherit the `ERR' trap.
4384 If set, the extended pattern matching features described above
4385 (*note Pattern Matching::) are enabled.
4388 If set, `$'STRING'' and `$"STRING"' quoting is performed
4389 within `${PARAMETER}' expansions enclosed in double quotes.
4390 This option is enabled by default.
4393 If set, patterns which fail to match filenames during
4394 filename expansion result in an expansion error.
4397 If set, the suffixes specified by the `FIGNORE' shell variable
4398 cause words to be ignored when performing word completion
4399 even if the ignored words are the only possible completions.
4400 *Note Bash Variables::, for a description of `FIGNORE'. This
4401 option is enabled by default.
4404 If set, range expressions used in pattern matching bracket
4405 expressions (*note Pattern Matching::) behave as if in the
4406 traditional C locale when performing comparisons. That is,
4407 the current locale's collating sequence is not taken into
4408 account, so `b' will not collate between `A' and `B', and
4409 upper-case and lower-case ASCII characters will collate
4413 If set, the pattern `**' used in a filename expansion context
4414 will match all files and zero or more directories and
4415 subdirectories. If the pattern is followed by a `/', only
4416 directories and subdirectories match.
4419 If set, shell error messages are written in the standard GNU
4420 error message format.
4423 If set, the history list is appended to the file named by the
4424 value of the `HISTFILE' variable when the shell exits, rather
4425 than overwriting the file.
4428 If set, and Readline is being used, a user is given the
4429 opportunity to re-edit a failed history substitution.
4432 If set, and Readline is being used, the results of history
4433 substitution are not immediately passed to the shell parser.
4434 Instead, the resulting line is loaded into the Readline
4435 editing buffer, allowing further modification.
4438 If set, and Readline is being used, Bash will attempt to
4439 perform hostname completion when a word containing a `@' is
4440 being completed (*note Commands For Completion::). This
4441 option is enabled by default.
4444 If set, Bash will send `SIGHUP' to all jobs when an
4445 interactive login shell exits (*note Signals::).
4447 `interactive_comments'
4448 Allow a word beginning with `#' to cause that word and all
4449 remaining characters on that line to be ignored in an
4450 interactive shell. This option is enabled by default.
4453 If set, and job control is not active, the shell runs the
4454 last command of a pipeline not executed in the background in
4455 the current shell environment.
4458 If enabled, and the `cmdhist' option is enabled, multi-line
4459 commands are saved to the history with embedded newlines
4460 rather than using semicolon separators where possible.
4463 The shell sets this option if it is started as a login shell
4464 (*note Invoking Bash::). The value may not be changed.
4467 If set, and a file that Bash is checking for mail has been
4468 accessed since the last time it was checked, the message
4469 `"The mail in MAILFILE has been read"' is displayed.
4471 `no_empty_cmd_completion'
4472 If set, and Readline is being used, Bash will not attempt to
4473 search the `PATH' for possible completions when completion is
4474 attempted on an empty line.
4477 If set, Bash matches filenames in a case-insensitive fashion
4478 when performing filename expansion.
4481 If set, Bash matches patterns in a case-insensitive fashion
4482 when performing matching while executing `case' or `[['
4483 conditional commands.
4486 If set, Bash allows filename patterns which match no files to
4487 expand to a null string, rather than themselves.
4490 If set, the programmable completion facilities (*note
4491 Programmable Completion::) are enabled. This option is
4495 If set, prompt strings undergo parameter expansion, command
4496 substitution, arithmetic expansion, and quote removal after
4497 being expanded as described below (*note Controlling the
4498 Prompt::). This option is enabled by default.
4501 The shell sets this option if it is started in restricted mode
4502 (*note The Restricted Shell::). The value may not be changed.
4503 This is not reset when the startup files are executed,
4504 allowing the startup files to discover whether or not a shell
4508 If this is set, the `shift' builtin prints an error message
4509 when the shift count exceeds the number of positional
4513 If set, the `source' builtin uses the value of `PATH' to find
4514 the directory containing the file supplied as an argument.
4515 This option is enabled by default.
4518 If set, the `echo' builtin expands backslash-escape sequences
4522 The return status when listing options is zero if all OPTNAMES are
4523 enabled, non-zero otherwise. When setting or unsetting options,
4524 the return status is zero unless an OPTNAME is not a valid shell
4528 File: bashref.info, Node: Special Builtins, Prev: Modifying Shell Behavior, Up: Shell Builtin Commands
4530 4.4 Special Builtins
4531 ====================
4533 For historical reasons, the POSIX standard has classified several
4534 builtin commands as _special_. When Bash is executing in POSIX mode,
4535 the special builtins differ from other builtin commands in three
4538 1. Special builtins are found before shell functions during command
4541 2. If a special builtin returns an error status, a non-interactive
4544 3. Assignment statements preceding the command stay in effect in the
4545 shell environment after the command completes.
4547 When Bash is not executing in POSIX mode, these builtins behave no
4548 differently than the rest of the Bash builtin commands. The Bash POSIX
4549 mode is described in *note Bash POSIX Mode::.
4551 These are the POSIX special builtins:
4552 break : . continue eval exec exit export readonly return set
4556 File: bashref.info, Node: Shell Variables, Next: Bash Features, Prev: Shell Builtin Commands, Up: Top
4563 * Bourne Shell Variables:: Variables which Bash uses in the same way
4564 as the Bourne Shell.
4565 * Bash Variables:: List of variables that exist in Bash.
4567 This chapter describes the shell variables that Bash uses. Bash
4568 automatically assigns default values to a number of variables.
4571 File: bashref.info, Node: Bourne Shell Variables, Next: Bash Variables, Up: Shell Variables
4573 5.1 Bourne Shell Variables
4574 ==========================
4576 Bash uses certain shell variables in the same way as the Bourne shell.
4577 In some cases, Bash assigns a default value to the variable.
4580 A colon-separated list of directories used as a search path for
4581 the `cd' builtin command.
4584 The current user's home directory; the default for the `cd' builtin
4585 command. The value of this variable is also used by tilde
4586 expansion (*note Tilde Expansion::).
4589 A list of characters that separate fields; used when the shell
4590 splits words as part of expansion.
4593 If this parameter is set to a filename or directory name and the
4594 `MAILPATH' variable is not set, Bash informs the user of the
4595 arrival of mail in the specified file or Maildir-format directory.
4598 A colon-separated list of filenames which the shell periodically
4599 checks for new mail. Each list entry can specify the message that
4600 is printed when new mail arrives in the mail file by separating
4601 the filename from the message with a `?'. When used in the text
4602 of the message, `$_' expands to the name of the current mail file.
4605 The value of the last option argument processed by the `getopts'
4609 The index of the last option argument processed by the `getopts'
4613 A colon-separated list of directories in which the shell looks for
4614 commands. A zero-length (null) directory name in the value of
4615 `PATH' indicates the current directory. A null directory name may
4616 appear as two adjacent colons, or as an initial or trailing colon.
4619 The primary prompt string. The default value is `\s-\v\$ '.
4620 *Note Controlling the Prompt::, for the complete list of escape
4621 sequences that are expanded before `PS1' is displayed.
4624 The secondary prompt string. The default value is `> '.
4628 File: bashref.info, Node: Bash Variables, Prev: Bourne Shell Variables, Up: Shell Variables
4633 These variables are set or used by Bash, but other shells do not
4634 normally treat them specially.
4636 A few variables used by Bash are described in different chapters:
4637 variables for controlling the job control facilities (*note Job Control
4641 The full pathname used to execute the current instance of Bash.
4644 A colon-separated list of enabled shell options. Each word in the
4645 list is a valid argument for the `-s' option to the `shopt'
4646 builtin command (*note The Shopt Builtin::). The options
4647 appearing in `BASHOPTS' are those reported as `on' by `shopt'. If
4648 this variable is in the environment when Bash starts up, each
4649 shell option in the list will be enabled before reading any
4650 startup files. This variable is readonly.
4653 Expands to the process ID of the current Bash process. This
4654 differs from `$$' under certain circumstances, such as subshells
4655 that do not require Bash to be re-initialized.
4658 An associative array variable whose members correspond to the
4659 internal list of aliases as maintained by the `alias' builtin.
4660 (*note Bourne Shell Builtins::). Elements added to this array
4661 appear in the alias list; unsetting array elements cause aliases
4662 to be removed from the alias list.
4665 An array variable whose values are the number of parameters in each
4666 frame of the current bash execution call stack. The number of
4667 parameters to the current subroutine (shell function or script
4668 executed with `.' or `source') is at the top of the stack. When a
4669 subroutine is executed, the number of parameters passed is pushed
4670 onto `BASH_ARGC'. The shell sets `BASH_ARGC' only when in
4671 extended debugging mode (see *note The Shopt Builtin:: for a
4672 description of the `extdebug' option to the `shopt' builtin).
4675 An array variable containing all of the parameters in the current
4676 bash execution call stack. The final parameter of the last
4677 subroutine call is at the top of the stack; the first parameter of
4678 the initial call is at the bottom. When a subroutine is executed,
4679 the parameters supplied are pushed onto `BASH_ARGV'. The shell
4680 sets `BASH_ARGV' only when in extended debugging mode (see *note
4681 The Shopt Builtin:: for a description of the `extdebug' option to
4682 the `shopt' builtin).
4685 An associative array variable whose members correspond to the
4686 internal hash table of commands as maintained by the `hash' builtin
4687 (*note Bourne Shell Builtins::). Elements added to this array
4688 appear in the hash table; unsetting array elements cause commands
4689 to be removed from the hash table.
4692 The command currently being executed or about to be executed,
4693 unless the shell is executing a command as the result of a trap,
4694 in which case it is the command executing at the time of the trap.
4697 The value is used to set the shell's compatibility level. *Note
4698 The Shopt Builtin::, for a description of the various compatibility
4699 levels and their effects. The value may be a decimal number
4700 (e.g., 4.2) or an integer (e.g., 42) corresponding to the desired
4701 compatibility level. If `BASH_COMPAT' is unset or set to the
4702 empty string, the compatibility level is set to the default for
4703 the current version. If `BASH_COMPAT' is set to a value that is
4704 not one of the valid compatibility levels, the shell prints an
4705 error message and sets the compatibility level to the default for
4706 the current version. The valid compatibility levels correspond to
4707 the compatibility options accepted by the `shopt' builtin
4708 described above (for example, COMPAT42 means that 4.2 and 42 are
4709 valid values). The current version is also a valid value.
4712 If this variable is set when Bash is invoked to execute a shell
4713 script, its value is expanded and used as the name of a startup
4714 file to read before executing the script. *Note Bash Startup
4717 `BASH_EXECUTION_STRING'
4718 The command argument to the `-c' invocation option.
4721 An array variable whose members are the line numbers in source
4722 files where each corresponding member of FUNCNAME was invoked.
4723 `${BASH_LINENO[$i]}' is the line number in the source file
4724 (`${BASH_SOURCE[$i+1]}') where `${FUNCNAME[$i]}' was called (or
4725 `${BASH_LINENO[$i-1]}' if referenced within another shell
4726 function). Use `LINENO' to obtain the current line number.
4729 An array variable whose members are assigned by the `=~' binary
4730 operator to the `[[' conditional command (*note Conditional
4731 Constructs::). The element with index 0 is the portion of the
4732 string matching the entire regular expression. The element with
4733 index N is the portion of the string matching the Nth
4734 parenthesized subexpression. This variable is read-only.
4737 An array variable whose members are the source filenames where the
4738 corresponding shell function names in the `FUNCNAME' array
4739 variable are defined. The shell function `${FUNCNAME[$i]}' is
4740 defined in the file `${BASH_SOURCE[$i]}' and called from
4741 `${BASH_SOURCE[$i+1]}'
4744 Incremented by one within each subshell or subshell environment
4745 when the shell begins executing in that environment. The initial
4749 A readonly array variable (*note Arrays::) whose members hold
4750 version information for this instance of Bash. The values
4751 assigned to the array members are as follows:
4754 The major version number (the RELEASE).
4757 The minor version number (the VERSION).
4766 The release status (e.g., BETA1).
4769 The value of `MACHTYPE'.
4772 The version number of the current instance of Bash.
4775 If set to an integer corresponding to a valid file descriptor, Bash
4776 will write the trace output generated when `set -x' is enabled to
4777 that file descriptor. This allows tracing output to be separated
4778 from diagnostic and error messages. The file descriptor is closed
4779 when `BASH_XTRACEFD' is unset or assigned a new value. Unsetting
4780 `BASH_XTRACEFD' or assigning it the empty string causes the trace
4781 output to be sent to the standard error. Note that setting
4782 `BASH_XTRACEFD' to 2 (the standard error file descriptor) and then
4783 unsetting it will result in the standard error being closed.
4786 Set the number of exited child status values for the shell to
4787 remember. Bash will not allow this value to be decreased below a
4788 POSIX-mandated minimum, and there is a maximum value (currently
4789 8192) that this may not exceed. The minimum value is
4793 Used by the `select' command to determine the terminal width when
4794 printing selection lists. Automatically set if the `checkwinsize'
4795 option is enabled (*note The Shopt Builtin::), or in an
4796 interactive shell upon receipt of a `SIGWINCH'.
4799 An index into `${COMP_WORDS}' of the word containing the current
4800 cursor position. This variable is available only in shell
4801 functions invoked by the programmable completion facilities (*note
4802 Programmable Completion::).
4805 The current command line. This variable is available only in
4806 shell functions and external commands invoked by the programmable
4807 completion facilities (*note Programmable Completion::).
4810 The index of the current cursor position relative to the beginning
4811 of the current command. If the current cursor position is at the
4812 end of the current command, the value of this variable is equal to
4813 `${#COMP_LINE}'. This variable is available only in shell
4814 functions and external commands invoked by the programmable
4815 completion facilities (*note Programmable Completion::).
4818 Set to an integer value corresponding to the type of completion
4819 attempted that caused a completion function to be called: TAB, for
4820 normal completion, `?', for listing completions after successive
4821 tabs, `!', for listing alternatives on partial word completion,
4822 `@', to list completions if the word is not unmodified, or `%',
4823 for menu completion. This variable is available only in shell
4824 functions and external commands invoked by the programmable
4825 completion facilities (*note Programmable Completion::).
4828 The key (or final key of a key sequence) used to invoke the current
4829 completion function.
4832 The set of characters that the Readline library treats as word
4833 separators when performing word completion. If `COMP_WORDBREAKS'
4834 is unset, it loses its special properties, even if it is
4838 An array variable consisting of the individual words in the
4839 current command line. The line is split into words as Readline
4840 would split it, using `COMP_WORDBREAKS' as described above. This
4841 variable is available only in shell functions invoked by the
4842 programmable completion facilities (*note Programmable
4846 An array variable from which Bash reads the possible completions
4847 generated by a shell function invoked by the programmable
4848 completion facility (*note Programmable Completion::). Each array
4849 element contains one possible completion.
4852 An array variable created to hold the file descriptors for output
4853 from and input to an unnamed coprocess (*note Coprocesses::).
4856 An array variable containing the current contents of the directory
4857 stack. Directories appear in the stack in the order they are
4858 displayed by the `dirs' builtin. Assigning to members of this
4859 array variable may be used to modify directories already in the
4860 stack, but the `pushd' and `popd' builtins must be used to add and
4861 remove directories. Assignment to this variable will not change
4862 the current directory. If `DIRSTACK' is unset, it loses its
4863 special properties, even if it is subsequently reset.
4866 If Bash finds this variable in the environment when the shell
4867 starts with value `t', it assumes that the shell is running in an
4868 Emacs shell buffer and disables line editing.
4871 Similar to `BASH_ENV'; used when the shell is invoked in POSIX
4872 Mode (*note Bash POSIX Mode::).
4875 The numeric effective user id of the current user. This variable
4879 The editor used as a default by the `-e' option to the `fc'
4883 A colon-separated list of suffixes to ignore when performing
4884 filename completion. A filename whose suffix matches one of the
4885 entries in `FIGNORE' is excluded from the list of matched
4886 filenames. A sample value is `.o:~'
4889 An array variable containing the names of all shell functions
4890 currently in the execution call stack. The element with index 0
4891 is the name of any currently-executing shell function. The
4892 bottom-most element (the one with the highest index) is `"main"'.
4893 This variable exists only when a shell function is executing.
4894 Assignments to `FUNCNAME' have no effect and return an error
4895 status. If `FUNCNAME' is unset, it loses its special properties,
4896 even if it is subsequently reset.
4898 This variable can be used with `BASH_LINENO' and `BASH_SOURCE'.
4899 Each element of `FUNCNAME' has corresponding elements in
4900 `BASH_LINENO' and `BASH_SOURCE' to describe the call stack. For
4901 instance, `${FUNCNAME[$i]}' was called from the file
4902 `${BASH_SOURCE[$i+1]}' at line number `${BASH_LINENO[$i]}'. The
4903 `caller' builtin displays the current call stack using this
4907 If set to a numeric value greater than 0, defines a maximum
4908 function nesting level. Function invocations that exceed this
4909 nesting level will cause the current command to abort.
4912 A colon-separated list of patterns defining the set of filenames to
4913 be ignored by filename expansion. If a filename matched by a
4914 filename expansion pattern also matches one of the patterns in
4915 `GLOBIGNORE', it is removed from the list of matches.
4918 An array variable containing the list of groups of which the
4919 current user is a member. Assignments to `GROUPS' have no effect
4920 and return an error status. If `GROUPS' is unset, it loses its
4921 special properties, even if it is subsequently reset.
4924 Up to three characters which control history expansion, quick
4925 substitution, and tokenization (*note History Interaction::). The
4926 first character is the HISTORY EXPANSION character, that is, the
4927 character which signifies the start of a history expansion,
4928 normally `!'. The second character is the character which
4929 signifies `quick substitution' when seen as the first character on
4930 a line, normally `^'. The optional third character is the
4931 character which indicates that the remainder of the line is a
4932 comment when found as the first character of a word, usually `#'.
4933 The history comment character causes history substitution to be
4934 skipped for the remaining words on the line. It does not
4935 necessarily cause the shell parser to treat the rest of the line
4939 The history number, or index in the history list, of the current
4940 command. If `HISTCMD' is unset, it loses its special properties,
4941 even if it is subsequently reset.
4944 A colon-separated list of values controlling how commands are
4945 saved on the history list. If the list of values includes
4946 `ignorespace', lines which begin with a space character are not
4947 saved in the history list. A value of `ignoredups' causes lines
4948 which match the previous history entry to not be saved. A value
4949 of `ignoreboth' is shorthand for `ignorespace' and `ignoredups'.
4950 A value of `erasedups' causes all previous lines matching the
4951 current line to be removed from the history list before that line
4952 is saved. Any value not in the above list is ignored. If
4953 `HISTCONTROL' is unset, or does not include a valid value, all
4954 lines read by the shell parser are saved on the history list,
4955 subject to the value of `HISTIGNORE'. The second and subsequent
4956 lines of a multi-line compound command are not tested, and are
4957 added to the history regardless of the value of `HISTCONTROL'.
4960 The name of the file to which the command history is saved. The
4961 default value is `~/.bash_history'.
4964 The maximum number of lines contained in the history file. When
4965 this variable is assigned a value, the history file is truncated,
4966 if necessary, to contain no more than that number of lines by
4967 removing the oldest entries. The history file is also truncated
4968 to this size after writing it when a shell exits. If the value is
4969 0, the history file is truncated to zero size. Non-numeric values
4970 and numeric values less than zero inhibit truncation. The shell
4971 sets the default value to the value of `HISTSIZE' after reading
4975 A colon-separated list of patterns used to decide which command
4976 lines should be saved on the history list. Each pattern is
4977 anchored at the beginning of the line and must match the complete
4978 line (no implicit `*' is appended). Each pattern is tested
4979 against the line after the checks specified by `HISTCONTROL' are
4980 applied. In addition to the normal shell pattern matching
4981 characters, `&' matches the previous history line. `&' may be
4982 escaped using a backslash; the backslash is removed before
4983 attempting a match. The second and subsequent lines of a
4984 multi-line compound command are not tested, and are added to the
4985 history regardless of the value of `HISTIGNORE'.
4987 `HISTIGNORE' subsumes the function of `HISTCONTROL'. A pattern of
4988 `&' is identical to `ignoredups', and a pattern of `[ ]*' is
4989 identical to `ignorespace'. Combining these two patterns,
4990 separating them with a colon, provides the functionality of
4994 The maximum number of commands to remember on the history list.
4995 If the value is 0, commands are not saved in the history list.
4996 Numeric values less than zero result in every command being saved
4997 on the history list (there is no limit). The shell sets the
4998 default value to 500 after reading any startup files.
5001 If this variable is set and not null, its value is used as a
5002 format string for STRFTIME to print the time stamp associated with
5003 each history entry displayed by the `history' builtin. If this
5004 variable is set, time stamps are written to the history file so
5005 they may be preserved across shell sessions. This uses the
5006 history comment character to distinguish timestamps from other
5010 Contains the name of a file in the same format as `/etc/hosts' that
5011 should be read when the shell needs to complete a hostname. The
5012 list of possible hostname completions may be changed while the
5013 shell is running; the next time hostname completion is attempted
5014 after the value is changed, Bash adds the contents of the new file
5015 to the existing list. If `HOSTFILE' is set, but has no value, or
5016 does not name a readable file, Bash attempts to read `/etc/hosts'
5017 to obtain the list of possible hostname completions. When
5018 `HOSTFILE' is unset, the hostname list is cleared.
5021 The name of the current host.
5024 A string describing the machine Bash is running on.
5027 Controls the action of the shell on receipt of an `EOF' character
5028 as the sole input. If set, the value denotes the number of
5029 consecutive `EOF' characters that can be read as the first
5030 character on an input line before the shell will exit. If the
5031 variable exists but does not have a numeric value (or has no
5032 value) then the default is 10. If the variable does not exist,
5033 then `EOF' signifies the end of input to the shell. This is only
5034 in effect for interactive shells.
5037 The name of the Readline initialization file, overriding the
5038 default of `~/.inputrc'.
5041 Used to determine the locale category for any category not
5042 specifically selected with a variable starting with `LC_'.
5045 This variable overrides the value of `LANG' and any other `LC_'
5046 variable specifying a locale category.
5049 This variable determines the collation order used when sorting the
5050 results of filename expansion, and determines the behavior of
5051 range expressions, equivalence classes, and collating sequences
5052 within filename expansion and pattern matching (*note Filename
5056 This variable determines the interpretation of characters and the
5057 behavior of character classes within filename expansion and pattern
5058 matching (*note Filename Expansion::).
5061 This variable determines the locale used to translate double-quoted
5062 strings preceded by a `$' (*note Locale Translation::).
5065 This variable determines the locale category used for number
5069 The line number in the script or shell function currently
5073 Used by the `select' command to determine the column length for
5074 printing selection lists. Automatically set if the `checkwinsize'
5075 option is enabled (*note The Shopt Builtin::), or in an
5076 interactive shell upon receipt of a `SIGWINCH'.
5079 A string that fully describes the system type on which Bash is
5080 executing, in the standard GNU CPU-COMPANY-SYSTEM format.
5083 How often (in seconds) that the shell should check for mail in the
5084 files specified in the `MAILPATH' or `MAIL' variables. The
5085 default is 60 seconds. When it is time to check for mail, the
5086 shell does so before displaying the primary prompt. If this
5087 variable is unset, or set to a value that is not a number greater
5088 than or equal to zero, the shell disables mail checking.
5091 An array variable created to hold the text read by the `mapfile'
5092 builtin when no variable name is supplied.
5095 The previous working directory as set by the `cd' builtin.
5098 If set to the value 1, Bash displays error messages generated by
5099 the `getopts' builtin command.
5102 A string describing the operating system Bash is running on.
5105 An array variable (*note Arrays::) containing a list of exit
5106 status values from the processes in the most-recently-executed
5107 foreground pipeline (which may contain only a single command).
5110 If this variable is in the environment when Bash starts, the shell
5111 enters POSIX mode (*note Bash POSIX Mode::) before reading the
5112 startup files, as if the `--posix' invocation option had been
5113 supplied. If it is set while the shell is running, Bash enables
5114 POSIX mode, as if the command
5119 The process ID of the shell's parent process. This variable is
5123 If set, the value is interpreted as a command to execute before
5124 the printing of each primary prompt (`$PS1').
5127 If set to a number greater than zero, the value is used as the
5128 number of trailing directory components to retain when expanding
5129 the `\w' and `\W' prompt string escapes (*note Controlling the
5130 Prompt::). Characters removed are replaced with an ellipsis.
5133 The value of this variable is used as the prompt for the `select'
5134 command. If this variable is not set, the `select' command
5138 The value is the prompt printed before the command line is echoed
5139 when the `-x' option is set (*note The Set Builtin::). The first
5140 character of `PS4' is replicated multiple times, as necessary, to
5141 indicate multiple levels of indirection. The default is `+ '.
5144 The current working directory as set by the `cd' builtin.
5147 Each time this parameter is referenced, a random integer between 0
5148 and 32767 is generated. Assigning a value to this variable seeds
5149 the random number generator.
5152 The contents of the Readline line buffer, for use with `bind -x'
5153 (*note Bash Builtins::).
5156 The position of the insertion point in the Readline line buffer,
5157 for use with `bind -x' (*note Bash Builtins::).
5160 The default variable for the `read' builtin.
5163 This variable expands to the number of seconds since the shell was
5164 started. Assignment to this variable resets the count to the
5165 value assigned, and the expanded value becomes the value assigned
5166 plus the number of seconds since the assignment.
5169 The full pathname to the shell is kept in this environment
5170 variable. If it is not set when the shell starts, Bash assigns to
5171 it the full pathname of the current user's login shell.
5174 A colon-separated list of enabled shell options. Each word in the
5175 list is a valid argument for the `-o' option to the `set' builtin
5176 command (*note The Set Builtin::). The options appearing in
5177 `SHELLOPTS' are those reported as `on' by `set -o'. If this
5178 variable is in the environment when Bash starts up, each shell
5179 option in the list will be enabled before reading any startup
5180 files. This variable is readonly.
5183 Incremented by one each time a new instance of Bash is started.
5184 This is intended to be a count of how deeply your Bash shells are
5188 The value of this parameter is used as a format string specifying
5189 how the timing information for pipelines prefixed with the `time'
5190 reserved word should be displayed. The `%' character introduces an
5191 escape sequence that is expanded to a time value or other
5192 information. The escape sequences and their meanings are as
5193 follows; the braces denote optional portions.
5199 The elapsed time in seconds.
5202 The number of CPU seconds spent in user mode.
5205 The number of CPU seconds spent in system mode.
5208 The CPU percentage, computed as (%U + %S) / %R.
5210 The optional P is a digit specifying the precision, the number of
5211 fractional digits after a decimal point. A value of 0 causes no
5212 decimal point or fraction to be output. At most three places
5213 after the decimal point may be specified; values of P greater than
5214 3 are changed to 3. If P is not specified, the value 3 is used.
5216 The optional `l' specifies a longer format, including minutes, of
5217 the form MMmSS.FFs. The value of P determines whether or not the
5218 fraction is included.
5220 If this variable is not set, Bash acts as if it had the value
5221 `$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS''
5222 If the value is null, no timing information is displayed. A
5223 trailing newline is added when the format string is displayed.
5226 If set to a value greater than zero, `TMOUT' is treated as the
5227 default timeout for the `read' builtin (*note Bash Builtins::).
5228 The `select' command (*note Conditional Constructs::) terminates
5229 if input does not arrive after `TMOUT' seconds when input is coming
5232 In an interactive shell, the value is interpreted as the number of
5233 seconds to wait for a line of input after issuing the primary
5234 prompt. Bash terminates after waiting for that number of seconds
5235 if a complete line of input does not arrive.
5238 If set, Bash uses its value as the name of a directory in which
5239 Bash creates temporary files for the shell's use.
5242 The numeric real user id of the current user. This variable is
5247 File: bashref.info, Node: Bash Features, Next: Job Control, Prev: Shell Variables, Up: Top
5252 This chapter describes features unique to Bash.
5256 * Invoking Bash:: Command line options that you can give
5258 * Bash Startup Files:: When and how Bash executes scripts.
5259 * Interactive Shells:: What an interactive shell is.
5260 * Bash Conditional Expressions:: Primitives used in composing expressions for
5262 * Shell Arithmetic:: Arithmetic on shell variables.
5263 * Aliases:: Substituting one command for another.
5264 * Arrays:: Array Variables.
5265 * The Directory Stack:: History of visited directories.
5266 * Controlling the Prompt:: Customizing the various prompt strings.
5267 * The Restricted Shell:: A more controlled mode of shell execution.
5268 * Bash POSIX Mode:: Making Bash behave more closely to what
5269 the POSIX standard specifies.
5272 File: bashref.info, Node: Invoking Bash, Next: Bash Startup Files, Up: Bash Features
5277 bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] [ARGUMENT ...]
5278 bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] -c STRING [ARGUMENT ...]
5279 bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] [ARGUMENT ...]
5281 All of the single-character options used with the `set' builtin
5282 (*note The Set Builtin::) can be used as options when the shell is
5283 invoked. In addition, there are several multi-character options that
5284 you can use. These options must appear on the command line before the
5285 single-character options to be recognized.
5288 Arrange for the debugger profile to be executed before the shell
5289 starts. Turns on extended debugging mode (see *note The Shopt
5290 Builtin:: for a description of the `extdebug' option to the `shopt'
5294 A list of all double-quoted strings preceded by `$' is printed on
5295 the standard output in the GNU `gettext' PO (portable object) file
5296 format. Equivalent to `-D' except for the output format.
5302 Display a usage message on standard output and exit successfully.
5304 `--init-file FILENAME'
5306 Execute commands from FILENAME (instead of `~/.bashrc') in an
5313 Do not use the GNU Readline library (*note Command Line Editing::)
5314 to read command lines when the shell is interactive.
5317 Don't load the system-wide startup file `/etc/profile' or any of
5318 the personal initialization files `~/.bash_profile',
5319 `~/.bash_login', or `~/.profile' when Bash is invoked as a login
5323 Don't read the `~/.bashrc' initialization file in an interactive
5324 shell. This is on by default if the shell is invoked as `sh'.
5327 Change the behavior of Bash where the default operation differs
5328 from the POSIX standard to match the standard. This is intended
5329 to make Bash behave as a strict superset of that standard. *Note
5330 Bash POSIX Mode::, for a description of the Bash POSIX mode.
5333 Make the shell a restricted shell (*note The Restricted Shell::).
5336 Equivalent to `-v'. Print shell input lines as they're read.
5339 Show version information for this instance of Bash on the standard
5340 output and exit successfully.
5342 There are several single-character options that may be supplied at
5343 invocation which are not available with the `set' builtin.
5346 Read and execute commands from the first non-option ARGUMENT after
5347 processing the options, then exit. Any remaining arguments are
5348 assigned to the positional parameters, starting with `$0'.
5351 Force the shell to run interactively. Interactive shells are
5352 described in *note Interactive Shells::.
5355 Make this shell act as if it had been directly invoked by login.
5356 When the shell is interactive, this is equivalent to starting a
5357 login shell with `exec -l bash'. When the shell is not
5358 interactive, the login shell startup files will be executed.
5359 `exec bash -l' or `exec bash --login' will replace the current
5360 shell with a Bash login shell. *Note Bash Startup Files::, for a
5361 description of the special behavior of a login shell.
5364 Make the shell a restricted shell (*note The Restricted Shell::).
5367 If this option is present, or if no arguments remain after option
5368 processing, then commands are read from the standard input. This
5369 option allows the positional parameters to be set when invoking an
5373 A list of all double-quoted strings preceded by `$' is printed on
5374 the standard output. These are the strings that are subject to
5375 language translation when the current locale is not `C' or `POSIX'
5376 (*note Locale Translation::). This implies the `-n' option; no
5377 commands will be executed.
5379 `[-+]O [SHOPT_OPTION]'
5380 SHOPT_OPTION is one of the shell options accepted by the `shopt'
5381 builtin (*note The Shopt Builtin::). If SHOPT_OPTION is present,
5382 `-O' sets the value of that option; `+O' unsets it. If
5383 SHOPT_OPTION is not supplied, the names and values of the shell
5384 options accepted by `shopt' are printed on the standard output.
5385 If the invocation option is `+O', the output is displayed in a
5386 format that may be reused as input.
5389 A `--' signals the end of options and disables further option
5390 processing. Any arguments after the `--' are treated as filenames
5393 A _login_ shell is one whose first character of argument zero is
5394 `-', or one invoked with the `--login' option.
5396 An _interactive_ shell is one started without non-option arguments,
5397 unless `-s' is specified, without specifying the `-c' option, and whose
5398 input and output are both connected to terminals (as determined by
5399 `isatty(3)'), or one started with the `-i' option. *Note Interactive
5400 Shells::, for more information.
5402 If arguments remain after option processing, and neither the `-c'
5403 nor the `-s' option has been supplied, the first argument is assumed to
5404 be the name of a file containing shell commands (*note Shell Scripts::).
5405 When Bash is invoked in this fashion, `$0' is set to the name of the
5406 file, and the positional parameters are set to the remaining arguments.
5407 Bash reads and executes commands from this file, then exits. Bash's
5408 exit status is the exit status of the last command executed in the
5409 script. If no commands are executed, the exit status is 0.
5412 File: bashref.info, Node: Bash Startup Files, Next: Interactive Shells, Prev: Invoking Bash, Up: Bash Features
5414 6.2 Bash Startup Files
5415 ======================
5417 This section describes how Bash executes its startup files. If any of
5418 the files exist but cannot be read, Bash reports an error. Tildes are
5419 expanded in filenames as described above under Tilde Expansion (*note
5422 Interactive shells are described in *note Interactive Shells::.
5424 Invoked as an interactive login shell, or with `--login'
5425 ........................................................
5427 When Bash is invoked as an interactive login shell, or as a
5428 non-interactive shell with the `--login' option, it first reads and
5429 executes commands from the file `/etc/profile', if that file exists.
5430 After reading that file, it looks for `~/.bash_profile',
5431 `~/.bash_login', and `~/.profile', in that order, and reads and
5432 executes commands from the first one that exists and is readable. The
5433 `--noprofile' option may be used when the shell is started to inhibit
5436 When a login shell exits, Bash reads and executes commands from the
5437 file `~/.bash_logout', if it exists.
5439 Invoked as an interactive non-login shell
5440 .........................................
5442 When an interactive shell that is not a login shell is started, Bash
5443 reads and executes commands from `~/.bashrc', if that file exists.
5444 This may be inhibited by using the `--norc' option. The `--rcfile
5445 FILE' option will force Bash to read and execute commands from FILE
5446 instead of `~/.bashrc'.
5448 So, typically, your `~/.bash_profile' contains the line
5449 `if [ -f ~/.bashrc ]; then . ~/.bashrc; fi'
5450 after (or before) any login-specific initializations.
5452 Invoked non-interactively
5453 .........................
5455 When Bash is started non-interactively, to run a shell script, for
5456 example, it looks for the variable `BASH_ENV' in the environment,
5457 expands its value if it appears there, and uses the expanded value as
5458 the name of a file to read and execute. Bash behaves as if the
5459 following command were executed:
5460 `if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi'
5461 but the value of the `PATH' variable is not used to search for the
5464 As noted above, if a non-interactive shell is invoked with the
5465 `--login' option, Bash attempts to read and execute commands from the
5466 login shell startup files.
5468 Invoked with name `sh'
5469 ......................
5471 If Bash is invoked with the name `sh', it tries to mimic the startup
5472 behavior of historical versions of `sh' as closely as possible, while
5473 conforming to the POSIX standard as well.
5475 When invoked as an interactive login shell, or as a non-interactive
5476 shell with the `--login' option, it first attempts to read and execute
5477 commands from `/etc/profile' and `~/.profile', in that order. The
5478 `--noprofile' option may be used to inhibit this behavior. When
5479 invoked as an interactive shell with the name `sh', Bash looks for the
5480 variable `ENV', expands its value if it is defined, and uses the
5481 expanded value as the name of a file to read and execute. Since a
5482 shell invoked as `sh' does not attempt to read and execute commands
5483 from any other startup files, the `--rcfile' option has no effect. A
5484 non-interactive shell invoked with the name `sh' does not attempt to
5485 read any other startup files.
5487 When invoked as `sh', Bash enters POSIX mode after the startup files
5490 Invoked in POSIX mode
5491 .....................
5493 When Bash is started in POSIX mode, as with the `--posix' command line
5494 option, it follows the POSIX standard for startup files. In this mode,
5495 interactive shells expand the `ENV' variable and commands are read and
5496 executed from the file whose name is the expanded value. No other
5497 startup files are read.
5499 Invoked by remote shell daemon
5500 ..............................
5502 Bash attempts to determine when it is being run with its standard input
5503 connected to a network connection, as when executed by the remote shell
5504 daemon, usually `rshd', or the secure shell daemon `sshd'. If Bash
5505 determines it is being run in this fashion, it reads and executes
5506 commands from `~/.bashrc', if that file exists and is readable. It
5507 will not do this if invoked as `sh'. The `--norc' option may be used
5508 to inhibit this behavior, and the `--rcfile' option may be used to
5509 force another file to be read, but neither `rshd' nor `sshd' generally
5510 invoke the shell with those options or allow them to be specified.
5512 Invoked with unequal effective and real UID/GIDs
5513 ................................................
5515 If Bash is started with the effective user (group) id not equal to the
5516 real user (group) id, and the `-p' option is not supplied, no startup
5517 files are read, shell functions are not inherited from the environment,
5518 the `SHELLOPTS', `BASHOPTS', `CDPATH', and `GLOBIGNORE' variables, if
5519 they appear in the environment, are ignored, and the effective user id
5520 is set to the real user id. If the `-p' option is supplied at
5521 invocation, the startup behavior is the same, but the effective user id
5525 File: bashref.info, Node: Interactive Shells, Next: Bash Conditional Expressions, Prev: Bash Startup Files, Up: Bash Features
5527 6.3 Interactive Shells
5528 ======================
5532 * What is an Interactive Shell?:: What determines whether a shell is Interactive.
5533 * Is this Shell Interactive?:: How to tell if a shell is interactive.
5534 * Interactive Shell Behavior:: What changes in a interactive shell?
5537 File: bashref.info, Node: What is an Interactive Shell?, Next: Is this Shell Interactive?, Up: Interactive Shells
5539 6.3.1 What is an Interactive Shell?
5540 -----------------------------------
5542 An interactive shell is one started without non-option arguments,
5543 unless `-s' is specified, without specifying the `-c' option, and whose
5544 input and error output are both connected to terminals (as determined
5545 by `isatty(3)'), or one started with the `-i' option.
5547 An interactive shell generally reads from and writes to a user's
5550 The `-s' invocation option may be used to set the positional
5551 parameters when an interactive shell is started.
5554 File: bashref.info, Node: Is this Shell Interactive?, Next: Interactive Shell Behavior, Prev: What is an Interactive Shell?, Up: Interactive Shells
5556 6.3.2 Is this Shell Interactive?
5557 --------------------------------
5559 To determine within a startup script whether or not Bash is running
5560 interactively, test the value of the `-' special parameter. It
5561 contains `i' when the shell is interactive. For example:
5564 *i*) echo This shell is interactive ;;
5565 *) echo This shell is not interactive ;;
5568 Alternatively, startup scripts may examine the variable `PS1'; it is
5569 unset in non-interactive shells, and set in interactive shells. Thus:
5571 if [ -z "$PS1" ]; then
5572 echo This shell is not interactive
5574 echo This shell is interactive
5578 File: bashref.info, Node: Interactive Shell Behavior, Prev: Is this Shell Interactive?, Up: Interactive Shells
5580 6.3.3 Interactive Shell Behavior
5581 --------------------------------
5583 When the shell is running interactively, it changes its behavior in
5586 1. Startup files are read and executed as described in *note Bash
5589 2. Job Control (*note Job Control::) is enabled by default. When job
5590 control is in effect, Bash ignores the keyboard-generated job
5591 control signals `SIGTTIN', `SIGTTOU', and `SIGTSTP'.
5593 3. Bash expands and displays `PS1' before reading the first line of a
5594 command, and expands and displays `PS2' before reading the second
5595 and subsequent lines of a multi-line command.
5597 4. Bash executes the value of the `PROMPT_COMMAND' variable as a
5598 command before printing the primary prompt, `$PS1' (*note Bash
5601 5. Readline (*note Command Line Editing::) is used to read commands
5602 from the user's terminal.
5604 6. Bash inspects the value of the `ignoreeof' option to `set -o'
5605 instead of exiting immediately when it receives an `EOF' on its
5606 standard input when reading a command (*note The Set Builtin::).
5608 7. Command history (*note Bash History Facilities::) and history
5609 expansion (*note History Interaction::) are enabled by default.
5610 Bash will save the command history to the file named by `$HISTFILE'
5611 when a shell with history enabled exits.
5613 8. Alias expansion (*note Aliases::) is performed by default.
5615 9. In the absence of any traps, Bash ignores `SIGTERM' (*note
5618 10. In the absence of any traps, `SIGINT' is caught and handled
5619 ((*note Signals::). `SIGINT' will interrupt some shell builtins.
5621 11. An interactive login shell sends a `SIGHUP' to all jobs on exit if
5622 the `huponexit' shell option has been enabled (*note Signals::).
5624 12. The `-n' invocation option is ignored, and `set -n' has no effect
5625 (*note The Set Builtin::).
5627 13. Bash will check for mail periodically, depending on the values of
5628 the `MAIL', `MAILPATH', and `MAILCHECK' shell variables (*note
5631 14. Expansion errors due to references to unbound shell variables after
5632 `set -u' has been enabled will not cause the shell to exit (*note
5635 15. The shell will not exit on expansion errors caused by VAR being
5636 unset or null in `${VAR:?WORD}' expansions (*note Shell Parameter
5639 16. Redirection errors encountered by shell builtins will not cause the
5642 17. When running in POSIX mode, a special builtin returning an error
5643 status will not cause the shell to exit (*note Bash POSIX Mode::).
5645 18. A failed `exec' will not cause the shell to exit (*note Bourne
5648 19. Parser syntax errors will not cause the shell to exit.
5650 20. Simple spelling correction for directory arguments to the `cd'
5651 builtin is enabled by default (see the description of the `cdspell'
5652 option to the `shopt' builtin in *note The Shopt Builtin::).
5654 21. The shell will check the value of the `TMOUT' variable and exit if
5655 a command is not read within the specified number of seconds after
5656 printing `$PS1' (*note Bash Variables::).
5660 File: bashref.info, Node: Bash Conditional Expressions, Next: Shell Arithmetic, Prev: Interactive Shells, Up: Bash Features
5662 6.4 Bash Conditional Expressions
5663 ================================
5665 Conditional expressions are used by the `[[' compound command and the
5666 `test' and `[' builtin commands.
5668 Expressions may be unary or binary. Unary expressions are often
5669 used to examine the status of a file. There are string operators and
5670 numeric comparison operators as well. If the FILE argument to one of
5671 the primaries is of the form `/dev/fd/N', then file descriptor N is
5672 checked. If the FILE argument to one of the primaries is one of
5673 `/dev/stdin', `/dev/stdout', or `/dev/stderr', file descriptor 0, 1, or
5674 2, respectively, is checked.
5676 When used with `[[', the `<' and `>' operators sort
5677 lexicographically using the current locale. The `test' command uses
5680 Unless otherwise specified, primaries that operate on files follow
5681 symbolic links and operate on the target of the link, rather than the
5685 True if FILE exists.
5688 True if FILE exists and is a block special file.
5691 True if FILE exists and is a character special file.
5694 True if FILE exists and is a directory.
5697 True if FILE exists.
5700 True if FILE exists and is a regular file.
5703 True if FILE exists and its set-group-id bit is set.
5706 True if FILE exists and is a symbolic link.
5709 True if FILE exists and its "sticky" bit is set.
5712 True if FILE exists and is a named pipe (FIFO).
5715 True if FILE exists and is readable.
5718 True if FILE exists and has a size greater than zero.
5721 True if file descriptor FD is open and refers to a terminal.
5724 True if FILE exists and its set-user-id bit is set.
5727 True if FILE exists and is writable.
5730 True if FILE exists and is executable.
5733 True if FILE exists and is owned by the effective group id.
5736 True if FILE exists and is a symbolic link.
5739 True if FILE exists and has been modified since it was last read.
5742 True if FILE exists and is owned by the effective user id.
5745 True if FILE exists and is a socket.
5748 True if FILE1 and FILE2 refer to the same device and inode numbers.
5751 True if FILE1 is newer (according to modification date) than
5752 FILE2, or if FILE1 exists and FILE2 does not.
5755 True if FILE1 is older than FILE2, or if FILE2 exists and FILE1
5759 True if the shell option OPTNAME is enabled. The list of options
5760 appears in the description of the `-o' option to the `set' builtin
5761 (*note The Set Builtin::).
5764 True if the shell variable VARNAME is set (has been assigned a
5768 True if the shell variable VARNAME is set and is a name reference.
5771 True if the length of STRING is zero.
5775 True if the length of STRING is non-zero.
5777 `STRING1 == STRING2'
5779 True if the strings are equal. When used with the `[[' command,
5780 this performs pattern matching as described above (*note
5781 Conditional Constructs::).
5783 `=' should be used with the `test' command for POSIX conformance.
5785 `STRING1 != STRING2'
5786 True if the strings are not equal.
5789 True if STRING1 sorts before STRING2 lexicographically.
5792 True if STRING1 sorts after STRING2 lexicographically.
5795 `OP' is one of `-eq', `-ne', `-lt', `-le', `-gt', or `-ge'. These
5796 arithmetic binary operators return true if ARG1 is equal to, not
5797 equal to, less than, less than or equal to, greater than, or
5798 greater than or equal to ARG2, respectively. ARG1 and ARG2 may be
5799 positive or negative integers.
5802 File: bashref.info, Node: Shell Arithmetic, Next: Aliases, Prev: Bash Conditional Expressions, Up: Bash Features
5804 6.5 Shell Arithmetic
5805 ====================
5807 The shell allows arithmetic expressions to be evaluated, as one of the
5808 shell expansions or by the `let' and the `-i' option to the `declare'
5811 Evaluation is done in fixed-width integers with no check for
5812 overflow, though division by 0 is trapped and flagged as an error. The
5813 operators and their precedence, associativity, and values are the same
5814 as in the C language. The following list of operators is grouped into
5815 levels of equal-precedence operators. The levels are listed in order
5816 of decreasing precedence.
5819 variable post-increment and post-decrement
5822 variable pre-increment and pre-decrement
5825 unary minus and plus
5828 logical and bitwise negation
5834 multiplication, division, remainder
5837 addition, subtraction
5840 left and right bitwise shifts
5846 equality and inequality
5852 bitwise exclusive OR
5863 `expr ? expr : expr'
5864 conditional operator
5866 `= *= /= %= += -= <<= >>= &= ^= |='
5872 Shell variables are allowed as operands; parameter expansion is
5873 performed before the expression is evaluated. Within an expression,
5874 shell variables may also be referenced by name without using the
5875 parameter expansion syntax. A shell variable that is null or unset
5876 evaluates to 0 when referenced by name without using the parameter
5877 expansion syntax. The value of a variable is evaluated as an
5878 arithmetic expression when it is referenced, or when a variable which
5879 has been given the INTEGER attribute using `declare -i' is assigned a
5880 value. A null value evaluates to 0. A shell variable need not have
5881 its INTEGER attribute turned on to be used in an expression.
5883 Constants with a leading 0 are interpreted as octal numbers. A
5884 leading `0x' or `0X' denotes hexadecimal. Otherwise, numbers take the
5885 form [BASE`#']N, where the optional BASE is a decimal number between 2
5886 and 64 representing the arithmetic base, and N is a number in that base.
5887 If BASE`#' is omitted, then base 10 is used. When specifying N, he
5888 digits greater than 9 are represented by the lowercase letters, the
5889 uppercase letters, `@', and `_', in that order. If BASE is less than
5890 or equal to 36, lowercase and uppercase letters may be used
5891 interchangeably to represent numbers between 10 and 35.
5893 Operators are evaluated in order of precedence. Sub-expressions in
5894 parentheses are evaluated first and may override the precedence rules
5898 File: bashref.info, Node: Aliases, Next: Arrays, Prev: Shell Arithmetic, Up: Bash Features
5903 ALIASES allow a string to be substituted for a word when it is used as
5904 the first word of a simple command. The shell maintains a list of
5905 aliases that may be set and unset with the `alias' and `unalias'
5908 The first word of each simple command, if unquoted, is checked to see
5909 if it has an alias. If so, that word is replaced by the text of the
5910 alias. The characters `/', `$', ``', `=' and any of the shell
5911 metacharacters or quoting characters listed above may not appear in an
5912 alias name. The replacement text may contain any valid shell input,
5913 including shell metacharacters. The first word of the replacement text
5914 is tested for aliases, but a word that is identical to an alias being
5915 expanded is not expanded a second time. This means that one may alias
5916 `ls' to `"ls -F"', for instance, and Bash does not try to recursively
5917 expand the replacement text. If the last character of the alias value
5918 is a BLANK, then the next command word following the alias is also
5919 checked for alias expansion.
5921 Aliases are created and listed with the `alias' command, and removed
5922 with the `unalias' command.
5924 There is no mechanism for using arguments in the replacement text,
5925 as in `csh'. If arguments are needed, a shell function should be used
5926 (*note Shell Functions::).
5928 Aliases are not expanded when the shell is not interactive, unless
5929 the `expand_aliases' shell option is set using `shopt' (*note The Shopt
5932 The rules concerning the definition and use of aliases are somewhat
5933 confusing. Bash always reads at least one complete line of input
5934 before executing any of the commands on that line. Aliases are
5935 expanded when a command is read, not when it is executed. Therefore, an
5936 alias definition appearing on the same line as another command does not
5937 take effect until the next line of input is read. The commands
5938 following the alias definition on that line are not affected by the new
5939 alias. This behavior is also an issue when functions are executed.
5940 Aliases are expanded when a function definition is read, not when the
5941 function is executed, because a function definition is itself a
5942 compound command. As a consequence, aliases defined in a function are
5943 not available until after that function is executed. To be safe,
5944 always put alias definitions on a separate line, and do not use `alias'
5945 in compound commands.
5947 For almost every purpose, shell functions are preferred over aliases.
5950 File: bashref.info, Node: Arrays, Next: The Directory Stack, Prev: Aliases, Up: Bash Features
5955 Bash provides one-dimensional indexed and associative array variables.
5956 Any variable may be used as an indexed array; the `declare' builtin
5957 will explicitly declare an array. There is no maximum limit on the
5958 size of an array, nor any requirement that members be indexed or
5959 assigned contiguously. Indexed arrays are referenced using integers
5960 (including arithmetic expressions (*note Shell Arithmetic::)) and are
5961 zero-based; associative arrays use arbitrary strings. Unless otherwise
5962 noted, indexed array indices must be non-negative integers.
5964 An indexed array is created automatically if any variable is
5965 assigned to using the syntax
5966 NAME[SUBSCRIPT]=VALUE
5968 The SUBSCRIPT is treated as an arithmetic expression that must evaluate
5969 to a number. To explicitly declare an array, use
5972 declare -a NAME[SUBSCRIPT]
5973 is also accepted; the SUBSCRIPT is ignored.
5975 Associative arrays are created using
5978 Attributes may be specified for an array variable using the
5979 `declare' and `readonly' builtins. Each attribute applies to all
5980 members of an array.
5982 Arrays are assigned to using compound assignments of the form
5983 NAME=(VALUE1 VALUE2 ... )
5984 where each VALUE is of the form `[SUBSCRIPT]='STRING. Indexed array
5985 assignments do not require anything but STRING. When assigning to
5986 indexed arrays, if the optional subscript is supplied, that index is
5987 assigned to; otherwise the index of the element assigned is the last
5988 index assigned to by the statement plus one. Indexing starts at zero.
5990 When assigning to an associative array, the subscript is required.
5992 This syntax is also accepted by the `declare' builtin. Individual
5993 array elements may be assigned to using the `NAME[SUBSCRIPT]=VALUE'
5994 syntax introduced above.
5996 When assigning to an indexed array, if NAME is subscripted by a
5997 negative number, that number is interpreted as relative to one greater
5998 than the maximum index of NAME, so negative indices count back from the
5999 end of the array, and an index of -1 references the last element.
6001 Any element of an array may be referenced using `${NAME[SUBSCRIPT]}'.
6002 The braces are required to avoid conflicts with the shell's filename
6003 expansion operators. If the SUBSCRIPT is `@' or `*', the word expands
6004 to all members of the array NAME. These subscripts differ only when
6005 the word appears within double quotes. If the word is double-quoted,
6006 `${NAME[*]}' expands to a single word with the value of each array
6007 member separated by the first character of the `IFS' variable, and
6008 `${NAME[@]}' expands each element of NAME to a separate word. When
6009 there are no array members, `${NAME[@]}' expands to nothing. If the
6010 double-quoted expansion occurs within a word, the expansion of the
6011 first parameter is joined with the beginning part of the original word,
6012 and the expansion of the last parameter is joined with the last part of
6013 the original word. This is analogous to the expansion of the special
6014 parameters `@' and `*'. `${#NAME[SUBSCRIPT]}' expands to the length of
6015 `${NAME[SUBSCRIPT]}'. If SUBSCRIPT is `@' or `*', the expansion is the
6016 number of elements in the array. Referencing an array variable without
6017 a subscript is equivalent to referencing with a subscript of 0. If the
6018 SUBSCRIPT used to reference an element of an indexed array evaluates to
6019 a number less than zero, it is interpreted as relative to one greater
6020 than the maximum index of the array, so negative indices count back
6021 from the end of the array, and an index of -1 refers to the last
6024 An array variable is considered set if a subscript has been assigned
6025 a value. The null string is a valid value.
6027 It is possible to obtain the keys (indices) of an array as well as
6028 the values. ${!NAME[@]} and ${!NAME[*]} expand to the indices assigned
6029 in array variable NAME. The treatment when in double quotes is similar
6030 to the expansion of the special parameters `@' and `*' within double
6033 The `unset' builtin is used to destroy arrays. `unset
6034 NAME[SUBSCRIPT]' destroys the array element at index SUBSCRIPT.
6035 Negative subscripts to indexed arrays are interpreted as described
6036 above. Care must be taken to avoid unwanted side effects caused by
6037 filename expansion. `unset NAME', where NAME is an array, removes the
6038 entire array. A subscript of `*' or `@' also removes the entire array.
6040 The `declare', `local', and `readonly' builtins each accept a `-a'
6041 option to specify an indexed array and a `-A' option to specify an
6042 associative array. If both options are supplied, `-A' takes precedence.
6043 The `read' builtin accepts a `-a' option to assign a list of words read
6044 from the standard input to an array, and can read values from the
6045 standard input into individual array elements. The `set' and `declare'
6046 builtins display array values in a way that allows them to be reused as
6050 File: bashref.info, Node: The Directory Stack, Next: Controlling the Prompt, Prev: Arrays, Up: Bash Features
6052 6.8 The Directory Stack
6053 =======================
6057 * Directory Stack Builtins:: Bash builtin commands to manipulate
6058 the directory stack.
6060 The directory stack is a list of recently-visited directories. The
6061 `pushd' builtin adds directories to the stack as it changes the current
6062 directory, and the `popd' builtin removes specified directories from
6063 the stack and changes the current directory to the directory removed.
6064 The `dirs' builtin displays the contents of the directory stack.
6066 The contents of the directory stack are also visible as the value of
6067 the `DIRSTACK' shell variable.
6070 File: bashref.info, Node: Directory Stack Builtins, Up: The Directory Stack
6072 6.8.1 Directory Stack Builtins
6073 ------------------------------
6076 dirs [-clpv] [+N | -N]
6078 Display the list of currently remembered directories. Directories
6079 are added to the list with the `pushd' command; the `popd' command
6080 removes directories from the list.
6083 Clears the directory stack by deleting all of the elements.
6086 Produces a listing using full pathnames; the default listing
6087 format uses a tilde to denote the home directory.
6090 Causes `dirs' to print the directory stack with one entry per
6094 Causes `dirs' to print the directory stack with one entry per
6095 line, prefixing each entry with its index in the stack.
6098 Displays the Nth directory (counting from the left of the
6099 list printed by `dirs' when invoked without options), starting
6103 Displays the Nth directory (counting from the right of the
6104 list printed by `dirs' when invoked without options), starting
6110 Remove the top entry from the directory stack, and `cd' to the new
6111 top directory. When no arguments are given, `popd' removes the
6112 top directory from the stack and performs a `cd' to the new top
6113 directory. The elements are numbered from 0 starting at the first
6114 directory listed with `dirs'; that is, `popd' is equivalent to
6118 Suppresses the normal change of directory when removing
6119 directories from the stack, so that only the stack is
6123 Removes the Nth directory (counting from the left of the list
6124 printed by `dirs'), starting with zero.
6127 Removes the Nth directory (counting from the right of the
6128 list printed by `dirs'), starting with zero.
6131 pushd [-n] [+N | -N | DIR]
6133 Save the current directory on the top of the directory stack and
6134 then `cd' to DIR. With no arguments, `pushd' exchanges the top
6138 Suppresses the normal change of directory when adding
6139 directories to the stack, so that only the stack is
6143 Brings the Nth directory (counting from the left of the list
6144 printed by `dirs', starting with zero) to the top of the list
6145 by rotating the stack.
6148 Brings the Nth directory (counting from the right of the list
6149 printed by `dirs', starting with zero) to the top of the list
6150 by rotating the stack.
6153 Makes the current working directory be the top of the stack,
6154 making it the new current directory as if it had been
6155 supplied as an argument to the `cd' builtin.
6158 File: bashref.info, Node: Controlling the Prompt, Next: The Restricted Shell, Prev: The Directory Stack, Up: Bash Features
6160 6.9 Controlling the Prompt
6161 ==========================
6163 The value of the variable `PROMPT_COMMAND' is examined just before Bash
6164 prints each primary prompt. If `PROMPT_COMMAND' is set and has a
6165 non-null value, then the value is executed just as if it had been typed
6166 on the command line.
6168 In addition, the following table describes the special characters
6169 which can appear in the prompt variables `PS1' to `PS4':
6175 The date, in "Weekday Month Date" format (e.g., "Tue May 26").
6178 The FORMAT is passed to `strftime'(3) and the result is inserted
6179 into the prompt string; an empty FORMAT results in a
6180 locale-specific time representation. The braces are required.
6183 An escape character.
6186 The hostname, up to the first `.'.
6192 The number of jobs currently managed by the shell.
6195 The basename of the shell's terminal device name.
6204 The name of the shell, the basename of `$0' (the portion following
6208 The time, in 24-hour HH:MM:SS format.
6211 The time, in 12-hour HH:MM:SS format.
6214 The time, in 12-hour am/pm format.
6217 The time, in 24-hour HH:MM format.
6220 The username of the current user.
6223 The version of Bash (e.g., 2.00)
6226 The release of Bash, version + patchlevel (e.g., 2.00.0)
6229 The current working directory, with `$HOME' abbreviated with a
6230 tilde (uses the `$PROMPT_DIRTRIM' variable).
6233 The basename of `$PWD', with `$HOME' abbreviated with a tilde.
6236 The history number of this command.
6239 The command number of this command.
6242 If the effective uid is 0, `#', otherwise `$'.
6245 The character whose ASCII code is the octal value NNN.
6251 Begin a sequence of non-printing characters. This could be used to
6252 embed a terminal control sequence into the prompt.
6255 End a sequence of non-printing characters.
6257 The command number and the history number are usually different: the
6258 history number of a command is its position in the history list, which
6259 may include commands restored from the history file (*note Bash History
6260 Facilities::), while the command number is the position in the sequence
6261 of commands executed during the current shell session.
6263 After the string is decoded, it is expanded via parameter expansion,
6264 command substitution, arithmetic expansion, and quote removal, subject
6265 to the value of the `promptvars' shell option (*note Bash Builtins::).
6268 File: bashref.info, Node: The Restricted Shell, Next: Bash POSIX Mode, Prev: Controlling the Prompt, Up: Bash Features
6270 6.10 The Restricted Shell
6271 =========================
6273 If Bash is started with the name `rbash', or the `--restricted' or `-r'
6274 option is supplied at invocation, the shell becomes restricted. A
6275 restricted shell is used to set up an environment more controlled than
6276 the standard shell. A restricted shell behaves identically to `bash'
6277 with the exception that the following are disallowed or not performed:
6279 * Changing directories with the `cd' builtin.
6281 * Setting or unsetting the values of the `SHELL', `PATH', `ENV', or
6282 `BASH_ENV' variables.
6284 * Specifying command names containing slashes.
6286 * Specifying a filename containing a slash as an argument to the `.'
6289 * Specifying a filename containing a slash as an argument to the `-p'
6290 option to the `hash' builtin command.
6292 * Importing function definitions from the shell environment at
6295 * Parsing the value of `SHELLOPTS' from the shell environment at
6298 * Redirecting output using the `>', `>|', `<>', `>&', `&>', and `>>'
6299 redirection operators.
6301 * Using the `exec' builtin to replace the shell with another command.
6303 * Adding or deleting builtin commands with the `-f' and `-d' options
6304 to the `enable' builtin.
6306 * Using the `enable' builtin command to enable disabled shell
6309 * Specifying the `-p' option to the `command' builtin.
6311 * Turning off restricted mode with `set +r' or `set +o restricted'.
6313 These restrictions are enforced after any startup files are read.
6315 When a command that is found to be a shell script is executed (*note
6316 Shell Scripts::), `rbash' turns off any restrictions in the shell
6317 spawned to execute the script.
6320 File: bashref.info, Node: Bash POSIX Mode, Prev: The Restricted Shell, Up: Bash Features
6322 6.11 Bash POSIX Mode
6323 ====================
6325 Starting Bash with the `--posix' command-line option or executing `set
6326 -o posix' while Bash is running will cause Bash to conform more closely
6327 to the POSIX standard by changing the behavior to match that specified
6328 by POSIX in areas where the Bash default differs.
6330 When invoked as `sh', Bash enters POSIX mode after reading the
6333 The following list is what's changed when `POSIX mode' is in effect:
6335 1. When a command in the hash table no longer exists, Bash will
6336 re-search `$PATH' to find the new location. This is also
6337 available with `shopt -s checkhash'.
6339 2. The message printed by the job control code and builtins when a job
6340 exits with a non-zero status is `Done(status)'.
6342 3. The message printed by the job control code and builtins when a job
6343 is stopped is `Stopped(SIGNAME)', where SIGNAME is, for example,
6346 4. The `bg' builtin uses the required format to describe each job
6347 placed in the background, which does not include an indication of
6348 whether the job is the current or previous job.
6350 5. Reserved words appearing in a context where reserved words are
6351 recognized do not undergo alias expansion.
6353 6. The POSIX `PS1' and `PS2' expansions of `!' to the history number
6354 and `!!' to `!' are enabled, and parameter expansion is performed
6355 on the values of `PS1' and `PS2' regardless of the setting of the
6356 `promptvars' option.
6358 7. The POSIX startup files are executed (`$ENV') rather than the
6361 8. Tilde expansion is only performed on assignments preceding a
6362 command name, rather than on all assignment statements on the line.
6364 9. The `command' builtin does not prevent builtins that take
6365 assignment statements as arguments from expanding them as
6366 assignment statements; when not in POSIX mode, assignment builtins
6367 lose their assignment statement expansion properties when preceded
6370 10. The default history file is `~/.sh_history' (this is the default
6371 value of `$HISTFILE').
6373 11. The output of `kill -l' prints all the signal names on a single
6374 line, separated by spaces, without the `SIG' prefix.
6376 12. The `kill' builtin does not accept signal names with a `SIG'
6379 13. Non-interactive shells exit if FILENAME in `.' FILENAME is not
6382 14. Non-interactive shells exit if a syntax error in an arithmetic
6383 expansion results in an invalid expression.
6385 15. Non-interactive shells exit if there is a syntax error in a script
6386 read with the `.' or `source' builtins, or in a string processed by
6389 16. Redirection operators do not perform filename expansion on the word
6390 in the redirection unless the shell is interactive.
6392 17. Redirection operators do not perform word splitting on the word in
6395 18. Function names must be valid shell `name's. That is, they may not
6396 contain characters other than letters, digits, and underscores, and
6397 may not start with a digit. Declaring a function with an invalid
6398 name causes a fatal syntax error in non-interactive shells.
6400 19. Function names may not be the same as one of the POSIX special
6403 20. POSIX special builtins are found before shell functions during
6406 21. The `time' reserved word may be used by itself as a command. When
6407 used in this way, it displays timing statistics for the shell and
6408 its completed children. The `TIMEFORMAT' variable controls the
6409 format of the timing information.
6411 22. When parsing and expanding a ${...} expansion that appears within
6412 double quotes, single quotes are no longer special and cannot be
6413 used to quote a closing brace or other special character, unless
6414 the operator is one of those defined to perform pattern removal.
6415 In this case, they do not have to appear as matched pairs.
6417 23. The parser does not recognize `time' as a reserved word if the next
6418 token begins with a `-'.
6420 24. If a POSIX special builtin returns an error status, a
6421 non-interactive shell exits. The fatal errors are those listed in
6422 the POSIX standard, and include things like passing incorrect
6423 options, redirection errors, variable assignment errors for
6424 assignments preceding the command name, and so on.
6426 25. A non-interactive shell exits with an error status if a variable
6427 assignment error occurs when no command name follows the assignment
6428 statements. A variable assignment error occurs, for example, when
6429 trying to assign a value to a readonly variable.
6431 26. A non-interactive shell exits with an error status if a variable
6432 assignment error occurs in an assignment statement preceding a
6433 special builtin, but not with any other simple command.
6435 27. A non-interactive shell exits with an error status if the iteration
6436 variable in a `for' statement or the selection variable in a
6437 `select' statement is a readonly variable.
6439 28. Process substitution is not available.
6441 29. While variable indirection is available, it may not be applied to
6442 the `#' and `?' special parameters.
6444 30. Assignment statements preceding POSIX special builtins persist in
6445 the shell environment after the builtin completes.
6447 31. Assignment statements preceding shell function calls persist in the
6448 shell environment after the function returns, as if a POSIX
6449 special builtin command had been executed.
6451 32. The `export' and `readonly' builtin commands display their output
6452 in the format required by POSIX.
6454 33. The `trap' builtin displays signal names without the leading `SIG'.
6456 34. The `trap' builtin doesn't check the first argument for a possible
6457 signal specification and revert the signal handling to the original
6458 disposition if it is, unless that argument consists solely of
6459 digits and is a valid signal number. If users want to reset the
6460 handler for a given signal to the original disposition, they
6461 should use `-' as the first argument.
6463 35. The `.' and `source' builtins do not search the current directory
6464 for the filename argument if it is not found by searching `PATH'.
6466 36. Subshells spawned to execute command substitutions inherit the
6467 value of the `-e' option from the parent shell. When not in POSIX
6468 mode, Bash clears the `-e' option in such subshells.
6470 37. Alias expansion is always enabled, even in non-interactive shells.
6472 38. When the `alias' builtin displays alias definitions, it does not
6473 display them with a leading `alias ' unless the `-p' option is
6476 39. When the `set' builtin is invoked without options, it does not
6477 display shell function names and definitions.
6479 40. When the `set' builtin is invoked without options, it displays
6480 variable values without quotes, unless they contain shell
6481 metacharacters, even if the result contains nonprinting characters.
6483 41. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
6484 constructed from `$PWD' and the directory name supplied as an
6485 argument does not refer to an existing directory, `cd' will fail
6486 instead of falling back to PHYSICAL mode.
6488 42. The `pwd' builtin verifies that the value it prints is the same as
6489 the current directory, even if it is not asked to check the file
6490 system with the `-P' option.
6492 43. When listing the history, the `fc' builtin does not include an
6493 indication of whether or not a history entry has been modified.
6495 44. The default editor used by `fc' is `ed'.
6497 45. The `type' and `command' builtins will not report a non-executable
6498 file as having been found, though the shell will attempt to
6499 execute such a file if it is the only so-named file found in
6502 46. The `vi' editing mode will invoke the `vi' editor directly when
6503 the `v' command is run, instead of checking `$VISUAL' and
6506 47. When the `xpg_echo' option is enabled, Bash does not attempt to
6507 interpret any arguments to `echo' as options. Each argument is
6508 displayed, after escape characters are converted.
6510 48. The `ulimit' builtin uses a block size of 512 bytes for the `-c'
6513 49. The arrival of `SIGCHLD' when a trap is set on `SIGCHLD' does not
6514 interrupt the `wait' builtin and cause it to return immediately.
6515 The trap command is run once for each child that exits.
6517 50. The `read' builtin may be interrupted by a signal for which a trap
6518 has been set. If Bash receives a trapped signal while executing
6519 `read', the trap handler executes and `read' returns an exit
6520 status greater than 128.
6523 There is other POSIX behavior that Bash does not implement by
6524 default even when in POSIX mode. Specifically:
6526 1. The `fc' builtin checks `$EDITOR' as a program to edit history
6527 entries if `FCEDIT' is unset, rather than defaulting directly to
6528 `ed'. `fc' uses `ed' if `EDITOR' is unset.
6530 2. As noted above, Bash requires the `xpg_echo' option to be enabled
6531 for the `echo' builtin to be fully conformant.
6534 Bash can be configured to be POSIX-conformant by default, by
6535 specifying the `--enable-strict-posix-default' to `configure' when
6536 building (*note Optional Features::).
6539 File: bashref.info, Node: Job Control, Next: Command Line Editing, Prev: Bash Features, Up: Top
6544 This chapter discusses what job control is, how it works, and how Bash
6545 allows you to access its facilities.
6549 * Job Control Basics:: How job control works.
6550 * Job Control Builtins:: Bash builtin commands used to interact
6552 * Job Control Variables:: Variables Bash uses to customize job
6556 File: bashref.info, Node: Job Control Basics, Next: Job Control Builtins, Up: Job Control
6558 7.1 Job Control Basics
6559 ======================
6561 Job control refers to the ability to selectively stop (suspend) the
6562 execution of processes and continue (resume) their execution at a later
6563 point. A user typically employs this facility via an interactive
6564 interface supplied jointly by the operating system kernel's terminal
6567 The shell associates a JOB with each pipeline. It keeps a table of
6568 currently executing jobs, which may be listed with the `jobs' command.
6569 When Bash starts a job asynchronously, it prints a line that looks like:
6571 indicating that this job is job number 1 and that the process ID of
6572 the last process in the pipeline associated with this job is 25647.
6573 All of the processes in a single pipeline are members of the same job.
6574 Bash uses the JOB abstraction as the basis for job control.
6576 To facilitate the implementation of the user interface to job
6577 control, the operating system maintains the notion of a current terminal
6578 process group ID. Members of this process group (processes whose
6579 process group ID is equal to the current terminal process group ID)
6580 receive keyboard-generated signals such as `SIGINT'. These processes
6581 are said to be in the foreground. Background processes are those whose
6582 process group ID differs from the terminal's; such processes are immune
6583 to keyboard-generated signals. Only foreground processes are allowed
6584 to read from or, if the user so specifies with `stty tostop', write to
6585 the terminal. Background processes which attempt to read from (write
6586 to when `stty tostop' is in effect) the terminal are sent a `SIGTTIN'
6587 (`SIGTTOU') signal by the kernel's terminal driver, which, unless
6588 caught, suspends the process.
6590 If the operating system on which Bash is running supports job
6591 control, Bash contains facilities to use it. Typing the SUSPEND
6592 character (typically `^Z', Control-Z) while a process is running causes
6593 that process to be stopped and returns control to Bash. Typing the
6594 DELAYED SUSPEND character (typically `^Y', Control-Y) causes the
6595 process to be stopped when it attempts to read input from the terminal,
6596 and control to be returned to Bash. The user then manipulates the
6597 state of this job, using the `bg' command to continue it in the
6598 background, the `fg' command to continue it in the foreground, or the
6599 `kill' command to kill it. A `^Z' takes effect immediately, and has
6600 the additional side effect of causing pending output and typeahead to
6603 There are a number of ways to refer to a job in the shell. The
6604 character `%' introduces a job specification (JOBSPEC).
6606 Job number `n' may be referred to as `%n'. The symbols `%%' and
6607 `%+' refer to the shell's notion of the current job, which is the last
6608 job stopped while it was in the foreground or started in the background.
6609 A single `%' (with no accompanying job specification) also refers to
6610 the current job. The previous job may be referenced using `%-'. If
6611 there is only a single job, `%+' and `%-' can both be used to refer to
6612 that job. In output pertaining to jobs (e.g., the output of the `jobs'
6613 command), the current job is always flagged with a `+', and the
6614 previous job with a `-'.
6616 A job may also be referred to using a prefix of the name used to
6617 start it, or using a substring that appears in its command line. For
6618 example, `%ce' refers to a stopped `ce' job. Using `%?ce', on the
6619 other hand, refers to any job containing the string `ce' in its command
6620 line. If the prefix or substring matches more than one job, Bash
6623 Simply naming a job can be used to bring it into the foreground:
6624 `%1' is a synonym for `fg %1', bringing job 1 from the background into
6625 the foreground. Similarly, `%1 &' resumes job 1 in the background,
6626 equivalent to `bg %1'
6628 The shell learns immediately whenever a job changes state.
6629 Normally, Bash waits until it is about to print a prompt before
6630 reporting changes in a job's status so as to not interrupt any other
6631 output. If the `-b' option to the `set' builtin is enabled, Bash
6632 reports such changes immediately (*note The Set Builtin::). Any trap
6633 on `SIGCHLD' is executed for each child process that exits.
6635 If an attempt to exit Bash is made while jobs are stopped, (or
6636 running, if the `checkjobs' option is enabled - see *note The Shopt
6637 Builtin::), the shell prints a warning message, and if the `checkjobs'
6638 option is enabled, lists the jobs and their statuses. The `jobs'
6639 command may then be used to inspect their status. If a second attempt
6640 to exit is made without an intervening command, Bash does not print
6641 another warning, and any stopped jobs are terminated.
6644 File: bashref.info, Node: Job Control Builtins, Next: Job Control Variables, Prev: Job Control Basics, Up: Job Control
6646 7.2 Job Control Builtins
6647 ========================
6652 Resume each suspended job JOBSPEC in the background, as if it had
6653 been started with `&'. If JOBSPEC is not supplied, the current
6654 job is used. The return status is zero unless it is run when job
6655 control is not enabled, or, when run with job control enabled, any
6656 JOBSPEC was not found or specifies a job that was started without
6662 Resume the job JOBSPEC in the foreground and make it the current
6663 job. If JOBSPEC is not supplied, the current job is used. The
6664 return status is that of the command placed into the foreground,
6665 or non-zero if run when job control is disabled or, when run with
6666 job control enabled, JOBSPEC does not specify a valid job or
6667 JOBSPEC specifies a job that was started without job control.
6670 jobs [-lnprs] [JOBSPEC]
6671 jobs -x COMMAND [ARGUMENTS]
6673 The first form lists the active jobs. The options have the
6677 List process IDs in addition to the normal information.
6680 Display information only about jobs that have changed status
6681 since the user was last notified of their status.
6684 List only the process ID of the job's process group leader.
6687 Display only running jobs.
6690 Display only stopped jobs.
6692 If JOBSPEC is given, output is restricted to information about
6693 that job. If JOBSPEC is not supplied, the status of all jobs is
6696 If the `-x' option is supplied, `jobs' replaces any JOBSPEC found
6697 in COMMAND or ARGUMENTS with the corresponding process group ID,
6698 and executes COMMAND, passing it ARGUMENTs, returning its exit
6702 kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] JOBSPEC or PID
6703 kill -l [EXIT_STATUS]
6705 Send a signal specified by SIGSPEC or SIGNUM to the process named
6706 by job specification JOBSPEC or process ID PID. SIGSPEC is either
6707 a case-insensitive signal name such as `SIGINT' (with or without
6708 the `SIG' prefix) or a signal number; SIGNUM is a signal number.
6709 If SIGSPEC and SIGNUM are not present, `SIGTERM' is used. The
6710 `-l' option lists the signal names. If any arguments are supplied
6711 when `-l' is given, the names of the signals corresponding to the
6712 arguments are listed, and the return status is zero. EXIT_STATUS
6713 is a number specifying a signal number or the exit status of a
6714 process terminated by a signal. The return status is zero if at
6715 least one signal was successfully sent, or non-zero if an error
6716 occurs or an invalid option is encountered.
6719 wait [-n] [JOBSPEC or PID ...]
6721 Wait until the child process specified by each process ID PID or
6722 job specification JOBSPEC exits and return the exit status of the
6723 last command waited for. If a job spec is given, all processes in
6724 the job are waited for. If no arguments are given, all currently
6725 active child processes are waited for, and the return status is
6726 zero. If the `-n' option is supplied, `wait' waits for any job to
6727 terminate and returns its exit status. If neither JOBSPEC nor PID
6728 specifies an active child process of the shell, the return status
6732 disown [-ar] [-h] [JOBSPEC ...]
6734 Without options, remove each JOBSPEC from the table of active jobs.
6735 If the `-h' option is given, the job is not removed from the table,
6736 but is marked so that `SIGHUP' is not sent to the job if the shell
6737 receives a `SIGHUP'. If JOBSPEC is not present, and neither the
6738 `-a' nor the `-r' option is supplied, the current job is used. If
6739 no JOBSPEC is supplied, the `-a' option means to remove or mark
6740 all jobs; the `-r' option without a JOBSPEC argument restricts
6741 operation to running jobs.
6746 Suspend the execution of this shell until it receives a `SIGCONT'
6747 signal. A login shell cannot be suspended; the `-f' option can be
6748 used to override this and force the suspension.
6750 When job control is not active, the `kill' and `wait' builtins do
6751 not accept JOBSPEC arguments. They must be supplied process IDs.
6754 File: bashref.info, Node: Job Control Variables, Prev: Job Control Builtins, Up: Job Control
6756 7.3 Job Control Variables
6757 =========================
6760 This variable controls how the shell interacts with the user and
6761 job control. If this variable exists then single word simple
6762 commands without redirections are treated as candidates for
6763 resumption of an existing job. There is no ambiguity allowed; if
6764 there is more than one job beginning with the string typed, then
6765 the most recently accessed job will be selected. The name of a
6766 stopped job, in this context, is the command line used to start
6767 it. If this variable is set to the value `exact', the string
6768 supplied must match the name of a stopped job exactly; if set to
6769 `substring', the string supplied needs to match a substring of the
6770 name of a stopped job. The `substring' value provides
6771 functionality analogous to the `%?' job ID (*note Job Control
6772 Basics::). If set to any other value, the supplied string must be
6773 a prefix of a stopped job's name; this provides functionality
6774 analogous to the `%' job ID.
6778 File: bashref.info, Node: Command Line Editing, Next: Using History Interactively, Prev: Job Control, Up: Top
6780 8 Command Line Editing
6781 **********************
6783 This chapter describes the basic features of the GNU command line
6784 editing interface. Command line editing is provided by the Readline
6785 library, which is used by several different programs, including Bash.
6786 Command line editing is enabled by default when using an interactive
6787 shell, unless the `--noediting' option is supplied at shell invocation.
6788 Line editing is also used when using the `-e' option to the `read'
6789 builtin command (*note Bash Builtins::). By default, the line editing
6790 commands are similar to those of Emacs. A vi-style line editing
6791 interface is also available. Line editing can be enabled at any time
6792 using the `-o emacs' or `-o vi' options to the `set' builtin command
6793 (*note The Set Builtin::), or disabled using the `+o emacs' or `+o vi'
6798 * Introduction and Notation:: Notation used in this text.
6799 * Readline Interaction:: The minimum set of commands for editing a line.
6800 * Readline Init File:: Customizing Readline from a user's view.
6801 * Bindable Readline Commands:: A description of most of the Readline commands
6802 available for binding
6803 * Readline vi Mode:: A short description of how to make Readline
6804 behave like the vi editor.
6806 * Programmable Completion:: How to specify the possible completions for
6808 * Programmable Completion Builtins:: Builtin commands to specify how to
6809 complete arguments for a particular command.
6810 * A Programmable Completion Example:: An example shell function for
6811 generating possible completions.
6814 File: bashref.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing
6816 8.1 Introduction to Line Editing
6817 ================================
6819 The following paragraphs describe the notation used to represent
6822 The text `C-k' is read as `Control-K' and describes the character
6823 produced when the <k> key is pressed while the Control key is depressed.
6825 The text `M-k' is read as `Meta-K' and describes the character
6826 produced when the Meta key (if you have one) is depressed, and the <k>
6827 key is pressed. The Meta key is labeled <ALT> on many keyboards. On
6828 keyboards with two keys labeled <ALT> (usually to either side of the
6829 space bar), the <ALT> on the left side is generally set to work as a
6830 Meta key. The <ALT> key on the right may also be configured to work as
6831 a Meta key or may be configured as some other modifier, such as a
6832 Compose key for typing accented characters.
6834 If you do not have a Meta or <ALT> key, or another key working as a
6835 Meta key, the identical keystroke can be generated by typing <ESC>
6836 _first_, and then typing <k>. Either process is known as "metafying"
6839 The text `M-C-k' is read as `Meta-Control-k' and describes the
6840 character produced by "metafying" `C-k'.
6842 In addition, several keys have their own names. Specifically,
6843 <DEL>, <ESC>, <LFD>, <SPC>, <RET>, and <TAB> all stand for themselves
6844 when seen in this text, or in an init file (*note Readline Init File::).
6845 If your keyboard lacks a <LFD> key, typing <C-j> will produce the
6846 desired character. The <RET> key may be labeled <Return> or <Enter> on
6850 File: bashref.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing
6852 8.2 Readline Interaction
6853 ========================
6855 Often during an interactive session you type in a long line of text,
6856 only to notice that the first word on the line is misspelled. The
6857 Readline library gives you a set of commands for manipulating the text
6858 as you type it in, allowing you to just fix your typo, and not forcing
6859 you to retype the majority of the line. Using these editing commands,
6860 you move the cursor to the place that needs correction, and delete or
6861 insert the text of the corrections. Then, when you are satisfied with
6862 the line, you simply press <RET>. You do not have to be at the end of
6863 the line to press <RET>; the entire line is accepted regardless of the
6864 location of the cursor within the line.
6868 * Readline Bare Essentials:: The least you need to know about Readline.
6869 * Readline Movement Commands:: Moving about the input line.
6870 * Readline Killing Commands:: How to delete text, and how to get it back!
6871 * Readline Arguments:: Giving numeric arguments to commands.
6872 * Searching:: Searching through previous lines.
6875 File: bashref.info, Node: Readline Bare Essentials, Next: Readline Movement Commands, Up: Readline Interaction
6877 8.2.1 Readline Bare Essentials
6878 ------------------------------
6880 In order to enter characters into the line, simply type them. The typed
6881 character appears where the cursor was, and then the cursor moves one
6882 space to the right. If you mistype a character, you can use your erase
6883 character to back up and delete the mistyped character.
6885 Sometimes you may mistype a character, and not notice the error
6886 until you have typed several other characters. In that case, you can
6887 type `C-b' to move the cursor to the left, and then correct your
6888 mistake. Afterwards, you can move the cursor to the right with `C-f'.
6890 When you add text in the middle of a line, you will notice that
6891 characters to the right of the cursor are `pushed over' to make room
6892 for the text that you have inserted. Likewise, when you delete text
6893 behind the cursor, characters to the right of the cursor are `pulled
6894 back' to fill in the blank space created by the removal of the text. A
6895 list of the bare essentials for editing the text of an input line
6899 Move back one character.
6902 Move forward one character.
6904 <DEL> or <Backspace>
6905 Delete the character to the left of the cursor.
6908 Delete the character underneath the cursor.
6911 Insert the character into the line at the cursor.
6914 Undo the last editing command. You can undo all the way back to an
6917 (Depending on your configuration, the <Backspace> key be set to delete
6918 the character to the left of the cursor and the <DEL> key set to delete
6919 the character underneath the cursor, like `C-d', rather than the
6920 character to the left of the cursor.)
6923 File: bashref.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction
6925 8.2.2 Readline Movement Commands
6926 --------------------------------
6928 The above table describes the most basic keystrokes that you need in
6929 order to do editing of the input line. For your convenience, many
6930 other commands have been added in addition to `C-b', `C-f', `C-d', and
6931 <DEL>. Here are some commands for moving more rapidly about the line.
6934 Move to the start of the line.
6937 Move to the end of the line.
6940 Move forward a word, where a word is composed of letters and
6944 Move backward a word.
6947 Clear the screen, reprinting the current line at the top.
6949 Notice how `C-f' moves forward a character, while `M-f' moves
6950 forward a word. It is a loose convention that control keystrokes
6951 operate on characters while meta keystrokes operate on words.
6954 File: bashref.info, Node: Readline Killing Commands, Next: Readline Arguments, Prev: Readline Movement Commands, Up: Readline Interaction
6956 8.2.3 Readline Killing Commands
6957 -------------------------------
6959 "Killing" text means to delete the text from the line, but to save it
6960 away for later use, usually by "yanking" (re-inserting) it back into
6961 the line. (`Cut' and `paste' are more recent jargon for `kill' and
6964 If the description for a command says that it `kills' text, then you
6965 can be sure that you can get the text back in a different (or the same)
6968 When you use a kill command, the text is saved in a "kill-ring".
6969 Any number of consecutive kills save all of the killed text together, so
6970 that when you yank it back, you get it all. The kill ring is not line
6971 specific; the text that you killed on a previously typed line is
6972 available to be yanked back later, when you are typing another line.
6974 Here is the list of commands for killing text.
6977 Kill the text from the current cursor position to the end of the
6981 Kill from the cursor to the end of the current word, or, if between
6982 words, to the end of the next word. Word boundaries are the same
6983 as those used by `M-f'.
6986 Kill from the cursor the start of the current word, or, if between
6987 words, to the start of the previous word. Word boundaries are the
6988 same as those used by `M-b'.
6991 Kill from the cursor to the previous whitespace. This is
6992 different than `M-<DEL>' because the word boundaries differ.
6995 Here is how to "yank" the text back into the line. Yanking means to
6996 copy the most-recently-killed text from the kill buffer.
6999 Yank the most recently killed text back into the buffer at the
7003 Rotate the kill-ring, and yank the new top. You can only do this
7004 if the prior command is `C-y' or `M-y'.
7007 File: bashref.info, Node: Readline Arguments, Next: Searching, Prev: Readline Killing Commands, Up: Readline Interaction
7009 8.2.4 Readline Arguments
7010 ------------------------
7012 You can pass numeric arguments to Readline commands. Sometimes the
7013 argument acts as a repeat count, other times it is the sign of the
7014 argument that is significant. If you pass a negative argument to a
7015 command which normally acts in a forward direction, that command will
7016 act in a backward direction. For example, to kill text back to the
7017 start of the line, you might type `M-- C-k'.
7019 The general way to pass numeric arguments to a command is to type
7020 meta digits before the command. If the first `digit' typed is a minus
7021 sign (`-'), then the sign of the argument will be negative. Once you
7022 have typed one meta digit to get the argument started, you can type the
7023 remainder of the digits, and then the command. For example, to give
7024 the `C-d' command an argument of 10, you could type `M-1 0 C-d', which
7025 will delete the next ten characters on the input line.
7028 File: bashref.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction
7030 8.2.5 Searching for Commands in the History
7031 -------------------------------------------
7033 Readline provides commands for searching through the command history
7034 (*note Bash History Facilities::) for lines containing a specified
7035 string. There are two search modes: "incremental" and
7038 Incremental searches begin before the user has finished typing the
7039 search string. As each character of the search string is typed,
7040 Readline displays the next entry from the history matching the string
7041 typed so far. An incremental search requires only as many characters
7042 as needed to find the desired history entry. To search backward in the
7043 history for a particular string, type `C-r'. Typing `C-s' searches
7044 forward through the history. The characters present in the value of
7045 the `isearch-terminators' variable are used to terminate an incremental
7046 search. If that variable has not been assigned a value, the <ESC> and
7047 `C-J' characters will terminate an incremental search. `C-g' will
7048 abort an incremental search and restore the original line. When the
7049 search is terminated, the history entry containing the search string
7050 becomes the current line.
7052 To find other matching entries in the history list, type `C-r' or
7053 `C-s' as appropriate. This will search backward or forward in the
7054 history for the next entry matching the search string typed so far.
7055 Any other key sequence bound to a Readline command will terminate the
7056 search and execute that command. For instance, a <RET> will terminate
7057 the search and accept the line, thereby executing the command from the
7058 history list. A movement command will terminate the search, make the
7059 last line found the current line, and begin editing.
7061 Readline remembers the last incremental search string. If two
7062 `C-r's are typed without any intervening characters defining a new
7063 search string, any remembered search string is used.
7065 Non-incremental searches read the entire search string before
7066 starting to search for matching history lines. The search string may be
7067 typed by the user or be part of the contents of the current line.
7070 File: bashref.info, Node: Readline Init File, Next: Bindable Readline Commands, Prev: Readline Interaction, Up: Command Line Editing
7072 8.3 Readline Init File
7073 ======================
7075 Although the Readline library comes with a set of Emacs-like
7076 keybindings installed by default, it is possible to use a different set
7077 of keybindings. Any user can customize programs that use Readline by
7078 putting commands in an "inputrc" file, conventionally in his home
7079 directory. The name of this file is taken from the value of the shell
7080 variable `INPUTRC'. If that variable is unset, the default is
7081 `~/.inputrc'. If that file does not exist or cannot be read, the
7082 ultimate default is `/etc/inputrc'.
7084 When a program which uses the Readline library starts up, the init
7085 file is read, and the key bindings are set.
7087 In addition, the `C-x C-r' command re-reads this init file, thus
7088 incorporating any changes that you might have made to it.
7092 * Readline Init File Syntax:: Syntax for the commands in the inputrc file.
7094 * Conditional Init Constructs:: Conditional key bindings in the inputrc file.
7096 * Sample Init File:: An example inputrc file.
7099 File: bashref.info, Node: Readline Init File Syntax, Next: Conditional Init Constructs, Up: Readline Init File
7101 8.3.1 Readline Init File Syntax
7102 -------------------------------
7104 There are only a few basic constructs allowed in the Readline init
7105 file. Blank lines are ignored. Lines beginning with a `#' are
7106 comments. Lines beginning with a `$' indicate conditional constructs
7107 (*note Conditional Init Constructs::). Other lines denote variable
7108 settings and key bindings.
7111 You can modify the run-time behavior of Readline by altering the
7112 values of variables in Readline using the `set' command within the
7113 init file. The syntax is simple:
7117 Here, for example, is how to change from the default Emacs-like
7118 key binding to use `vi' line editing commands:
7122 Variable names and values, where appropriate, are recognized
7123 without regard to case. Unrecognized variable names are ignored.
7125 Boolean variables (those that can be set to on or off) are set to
7126 on if the value is null or empty, ON (case-insensitive), or 1.
7127 Any other value results in the variable being set to off.
7129 The `bind -V' command lists the current Readline variable names
7130 and values. *Note Bash Builtins::.
7132 A great deal of run-time behavior is changeable with the following
7136 Controls what happens when Readline wants to ring the
7137 terminal bell. If set to `none', Readline never rings the
7138 bell. If set to `visible', Readline uses a visible bell if
7139 one is available. If set to `audible' (the default),
7140 Readline attempts to ring the terminal's bell.
7142 `bind-tty-special-chars'
7143 If set to `on', Readline attempts to bind the control
7144 characters treated specially by the kernel's terminal driver
7145 to their Readline equivalents.
7148 If set to `on', Readline displays possible completions using
7149 different colors to indicate their file type. The color
7150 definitions are taken from the value of the `LS_COLORS'
7151 environment variable. The default is `off'.
7154 The string to insert at the beginning of the line when the
7155 `insert-comment' command is executed. The default value is
7158 `completion-display-width'
7159 The number of screen columns used to display possible matches
7160 when performing completion. The value is ignored if it is
7161 less than 0 or greater than the terminal screen width. A
7162 value of 0 will cause matches to be displayed one per line.
7163 The default value is -1.
7165 `completion-ignore-case'
7166 If set to `on', Readline performs filename matching and
7167 completion in a case-insensitive fashion. The default value
7170 `completion-map-case'
7171 If set to `on', and COMPLETION-IGNORE-CASE is enabled,
7172 Readline treats hyphens (`-') and underscores (`_') as
7173 equivalent when performing case-insensitive filename matching
7176 `completion-prefix-display-length'
7177 The length in characters of the common prefix of a list of
7178 possible completions that is displayed without modification.
7179 When set to a value greater than zero, common prefixes longer
7180 than this value are replaced with an ellipsis when displaying
7181 possible completions.
7183 `completion-query-items'
7184 The number of possible completions that determines when the
7185 user is asked whether the list of possibilities should be
7186 displayed. If the number of possible completions is greater
7187 than this value, Readline will ask the user whether or not he
7188 wishes to view them; otherwise, they are simply listed. This
7189 variable must be set to an integer value greater than or
7190 equal to 0. A negative value means Readline should never ask.
7191 The default limit is `100'.
7194 If set to `on', Readline will convert characters with the
7195 eighth bit set to an ASCII key sequence by stripping the
7196 eighth bit and prefixing an <ESC> character, converting them
7197 to a meta-prefixed key sequence. The default value is `on'.
7199 `disable-completion'
7200 If set to `On', Readline will inhibit word completion.
7201 Completion characters will be inserted into the line as if
7202 they had been mapped to `self-insert'. The default is `off'.
7205 The `editing-mode' variable controls which default set of key
7206 bindings is used. By default, Readline starts up in Emacs
7207 editing mode, where the keystrokes are most similar to Emacs.
7208 This variable can be set to either `emacs' or `vi'.
7210 `echo-control-characters'
7211 When set to `on', on operating systems that indicate they
7212 support it, readline echoes a character corresponding to a
7213 signal generated from the keyboard. The default is `on'.
7216 When set to `on', Readline will try to enable the application
7217 keypad when it is called. Some systems need this to enable
7218 the arrow keys. The default is `off'.
7221 When set to `on', Readline will try to enable any meta
7222 modifier key the terminal claims to support when it is
7223 called. On many terminals, the meta key is used to send
7224 eight-bit characters. The default is `on'.
7227 If set to `on', tilde expansion is performed when Readline
7228 attempts word completion. The default is `off'.
7230 `history-preserve-point'
7231 If set to `on', the history code attempts to place the point
7232 (the current cursor position) at the same location on each
7233 history line retrieved with `previous-history' or
7234 `next-history'. The default is `off'.
7237 Set the maximum number of history entries saved in the
7238 history list. If set to zero, any existing history entries
7239 are deleted and no new entries are saved. If set to a value
7240 less than zero, the number of history entries is not limited.
7241 By default, the number of history entries is not limited.
7243 `horizontal-scroll-mode'
7244 This variable can be set to either `on' or `off'. Setting it
7245 to `on' means that the text of the lines being edited will
7246 scroll horizontally on a single screen line when they are
7247 longer than the width of the screen, instead of wrapping onto
7248 a new screen line. By default, this variable is set to `off'.
7251 If set to `on', Readline will enable eight-bit input (it will
7252 not clear the eighth bit in the characters it reads),
7253 regardless of what the terminal claims it can support. The
7254 default value is `off'. The name `meta-flag' is a synonym
7257 `isearch-terminators'
7258 The string of characters that should terminate an incremental
7259 search without subsequently executing the character as a
7260 command (*note Searching::). If this variable has not been
7261 given a value, the characters <ESC> and `C-J' will terminate
7262 an incremental search.
7265 Sets Readline's idea of the current keymap for key binding
7266 commands. Acceptable `keymap' names are `emacs',
7267 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
7268 `vi-command', and `vi-insert'. `vi' is equivalent to
7269 `vi-command'; `emacs' is equivalent to `emacs-standard'. The
7270 default value is `emacs'. The value of the `editing-mode'
7271 variable also affects the default keymap.
7274 Specifies the duration Readline will wait for a character
7275 when reading an ambiguous key sequence (one that can form a
7276 complete key sequence using the input read so far, or can
7277 take additional input to complete a longer key sequence). If
7278 no input is received within the timeout, Readline will use
7279 the shorter but complete key sequence. Readline uses this
7280 value to determine whether or not input is available on the
7281 current input source (`rl_instream' by default). The value
7282 is specified in milliseconds, so a value of 1000 means that
7283 Readline will wait one second for additional input. If this
7284 variable is set to a value less than or equal to zero, or to a
7285 non-numeric value, Readline will wait until another key is
7286 pressed to decide which key sequence to complete. The
7287 default value is `500'.
7290 If set to `on', completed directory names have a slash
7291 appended. The default is `on'.
7293 `mark-modified-lines'
7294 This variable, when set to `on', causes Readline to display an
7295 asterisk (`*') at the start of history lines which have been
7296 modified. This variable is `off' by default.
7298 `mark-symlinked-directories'
7299 If set to `on', completed names which are symbolic links to
7300 directories have a slash appended (subject to the value of
7301 `mark-directories'). The default is `off'.
7303 `match-hidden-files'
7304 This variable, when set to `on', causes Readline to match
7305 files whose names begin with a `.' (hidden files) when
7306 performing filename completion. If set to `off', the leading
7307 `.' must be supplied by the user in the filename to be
7308 completed. This variable is `on' by default.
7310 `menu-complete-display-prefix'
7311 If set to `on', menu completion displays the common prefix of
7312 the list of possible completions (which may be empty) before
7313 cycling through the list. The default is `off'.
7316 If set to `on', Readline will display characters with the
7317 eighth bit set directly rather than as a meta-prefixed escape
7318 sequence. The default is `off'.
7321 If set to `on', Readline uses an internal `more'-like pager
7322 to display a screenful of possible completions at a time.
7323 This variable is `on' by default.
7325 `print-completions-horizontally'
7326 If set to `on', Readline will display completions with matches
7327 sorted horizontally in alphabetical order, rather than down
7328 the screen. The default is `off'.
7330 `revert-all-at-newline'
7331 If set to `on', Readline will undo all changes to history
7332 lines before returning when `accept-line' is executed. By
7333 default, history lines may be modified and retain individual
7334 undo lists across calls to `readline'. The default is `off'.
7336 `show-all-if-ambiguous'
7337 This alters the default behavior of the completion functions.
7338 If set to `on', words which have more than one possible
7339 completion cause the matches to be listed immediately instead
7340 of ringing the bell. The default value is `off'.
7342 `show-all-if-unmodified'
7343 This alters the default behavior of the completion functions
7344 in a fashion similar to SHOW-ALL-IF-AMBIGUOUS. If set to
7345 `on', words which have more than one possible completion
7346 without any possible partial completion (the possible
7347 completions don't share a common prefix) cause the matches to
7348 be listed immediately instead of ringing the bell. The
7349 default value is `off'.
7351 `show-mode-in-prompt'
7352 If set to `on', add a character to the beginning of the prompt
7353 indicating the editing mode: emacs (`@'), vi command (`:'),
7354 or vi insertion (`+'). The default value is `off'.
7356 `skip-completed-text'
7357 If set to `on', this alters the default completion behavior
7358 when inserting a single match into the line. It's only
7359 active when performing completion in the middle of a word.
7360 If enabled, readline does not insert characters from the
7361 completion that match characters after point in the word
7362 being completed, so portions of the word following the cursor
7363 are not duplicated. For instance, if this is enabled,
7364 attempting completion when the cursor is after the `e' in
7365 `Makefile' will result in `Makefile' rather than
7366 `Makefilefile', assuming there is a single possible
7367 completion. The default value is `off'.
7370 If set to `on', a character denoting a file's type is
7371 appended to the filename when listing possible completions.
7372 The default is `off'.
7376 The syntax for controlling key bindings in the init file is
7377 simple. First you need to find the name of the command that you
7378 want to change. The following sections contain tables of the
7379 command name, the default keybinding, if any, and a short
7380 description of what the command does.
7382 Once you know the name of the command, simply place on a line in
7383 the init file the name of the key you wish to bind the command to,
7384 a colon, and then the name of the command. There can be no space
7385 between the key name and the colon - that will be interpreted as
7386 part of the key name. The name of the key can be expressed in
7387 different ways, depending on what you find most comfortable.
7389 In addition to command names, readline allows keys to be bound to
7390 a string that is inserted when the key is pressed (a MACRO).
7392 The `bind -p' command displays Readline function names and
7393 bindings in a format that can put directly into an initialization
7394 file. *Note Bash Builtins::.
7396 KEYNAME: FUNCTION-NAME or MACRO
7397 KEYNAME is the name of a key spelled out in English. For
7399 Control-u: universal-argument
7400 Meta-Rubout: backward-kill-word
7401 Control-o: "> output"
7403 In the above example, `C-u' is bound to the function
7404 `universal-argument', `M-DEL' is bound to the function
7405 `backward-kill-word', and `C-o' is bound to run the macro
7406 expressed on the right hand side (that is, to insert the text
7407 `> output' into the line).
7409 A number of symbolic character names are recognized while
7410 processing this key binding syntax: DEL, ESC, ESCAPE, LFD,
7411 NEWLINE, RET, RETURN, RUBOUT, SPACE, SPC, and TAB.
7413 "KEYSEQ": FUNCTION-NAME or MACRO
7414 KEYSEQ differs from KEYNAME above in that strings denoting an
7415 entire key sequence can be specified, by placing the key
7416 sequence in double quotes. Some GNU Emacs style key escapes
7417 can be used, as in the following example, but the special
7418 character names are not recognized.
7420 "\C-u": universal-argument
7421 "\C-x\C-r": re-read-init-file
7422 "\e[11~": "Function Key 1"
7424 In the above example, `C-u' is again bound to the function
7425 `universal-argument' (just as it was in the first example),
7426 `C-x C-r' is bound to the function `re-read-init-file', and
7427 `<ESC> <[> <1> <1> <~>' is bound to insert the text `Function
7431 The following GNU Emacs style escape sequences are available when
7432 specifying key sequences:
7447 <">, a double quotation mark
7450 <'>, a single quote or apostrophe
7452 In addition to the GNU Emacs style escape sequences, a second set
7453 of backslash escapes is available:
7480 the eight-bit character whose value is the octal value NNN
7481 (one to three digits)
7484 the eight-bit character whose value is the hexadecimal value
7485 HH (one or two hex digits)
7487 When entering the text of a macro, single or double quotes must be
7488 used to indicate a macro definition. Unquoted text is assumed to
7489 be a function name. In the macro body, the backslash escapes
7490 described above are expanded. Backslash will quote any other
7491 character in the macro text, including `"' and `''. For example,
7492 the following binding will make `C-x \' insert a single `\' into
7498 File: bashref.info, Node: Conditional Init Constructs, Next: Sample Init File, Prev: Readline Init File Syntax, Up: Readline Init File
7500 8.3.2 Conditional Init Constructs
7501 ---------------------------------
7503 Readline implements a facility similar in spirit to the conditional
7504 compilation features of the C preprocessor which allows key bindings
7505 and variable settings to be performed as the result of tests. There
7506 are four parser directives used.
7509 The `$if' construct allows bindings to be made based on the
7510 editing mode, the terminal being used, or the application using
7511 Readline. The text of the test extends to the end of the line; no
7512 characters are required to isolate it.
7515 The `mode=' form of the `$if' directive is used to test
7516 whether Readline is in `emacs' or `vi' mode. This may be
7517 used in conjunction with the `set keymap' command, for
7518 instance, to set bindings in the `emacs-standard' and
7519 `emacs-ctlx' keymaps only if Readline is starting out in
7523 The `term=' form may be used to include terminal-specific key
7524 bindings, perhaps to bind the key sequences output by the
7525 terminal's function keys. The word on the right side of the
7526 `=' is tested against both the full name of the terminal and
7527 the portion of the terminal name before the first `-'. This
7528 allows `sun' to match both `sun' and `sun-cmd', for instance.
7531 The APPLICATION construct is used to include
7532 application-specific settings. Each program using the
7533 Readline library sets the APPLICATION NAME, and you can test
7534 for a particular value. This could be used to bind key
7535 sequences to functions useful for a specific program. For
7536 instance, the following command adds a key sequence that
7537 quotes the current or previous word in Bash:
7539 # Quote the current or previous word
7540 "\C-xq": "\eb\"\ef\""
7544 This command, as seen in the previous example, terminates an `$if'
7548 Commands in this branch of the `$if' directive are executed if the
7552 This directive takes a single filename as an argument and reads
7553 commands and bindings from that file. For example, the following
7554 directive reads from `/etc/inputrc':
7555 $include /etc/inputrc
7558 File: bashref.info, Node: Sample Init File, Prev: Conditional Init Constructs, Up: Readline Init File
7560 8.3.3 Sample Init File
7561 ----------------------
7563 Here is an example of an INPUTRC file. This illustrates key binding,
7564 variable assignment, and conditional syntax.
7567 # This file controls the behaviour of line input editing for
7568 # programs that use the GNU Readline library. Existing
7569 # programs include FTP, Bash, and GDB.
7571 # You can re-read the inputrc file with C-x C-r.
7572 # Lines beginning with '#' are comments.
7574 # First, include any system-wide bindings and variable
7575 # assignments from /etc/Inputrc
7576 $include /etc/Inputrc
7579 # Set various bindings for emacs mode.
7581 set editing-mode emacs
7585 Meta-Control-h: backward-kill-word Text after the function name is ignored
7588 # Arrow keys in keypad mode
7590 #"\M-OD": backward-char
7591 #"\M-OC": forward-char
7592 #"\M-OA": previous-history
7593 #"\M-OB": next-history
7595 # Arrow keys in ANSI mode
7597 "\M-[D": backward-char
7598 "\M-[C": forward-char
7599 "\M-[A": previous-history
7600 "\M-[B": next-history
7602 # Arrow keys in 8 bit keypad mode
7604 #"\M-\C-OD": backward-char
7605 #"\M-\C-OC": forward-char
7606 #"\M-\C-OA": previous-history
7607 #"\M-\C-OB": next-history
7609 # Arrow keys in 8 bit ANSI mode
7611 #"\M-\C-[D": backward-char
7612 #"\M-\C-[C": forward-char
7613 #"\M-\C-[A": previous-history
7614 #"\M-\C-[B": next-history
7620 # An old-style binding. This happens to be the default.
7623 # Macros that are convenient for shell interaction
7626 "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
7627 # prepare to type a quoted word --
7628 # insert open and close double quotes
7629 # and move to just after the open quote
7630 "\C-x\"": "\"\"\C-b"
7631 # insert a backslash (testing backslash escapes
7632 # in sequences and macros)
7634 # Quote the current or previous word
7635 "\C-xq": "\eb\"\ef\""
7636 # Add a binding to refresh the line, which is unbound
7637 "\C-xr": redraw-current-line
7638 # Edit variable on current line.
7639 "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
7642 # use a visible bell if one is available
7643 set bell-style visible
7645 # don't strip characters to 7 bits when reading
7648 # allow iso-latin1 characters to be inserted rather
7649 # than converted to prefix-meta sequences
7650 set convert-meta off
7652 # display characters with the eighth bit set directly
7653 # rather than as meta-prefixed characters
7656 # if there are more than 150 possible completions for
7657 # a word, ask the user if he wants to see all of them
7658 set completion-query-items 150
7664 "\M-.": yank-last-arg
7668 File: bashref.info, Node: Bindable Readline Commands, Next: Readline vi Mode, Prev: Readline Init File, Up: Command Line Editing
7670 8.4 Bindable Readline Commands
7671 ==============================
7675 * Commands For Moving:: Moving about the line.
7676 * Commands For History:: Getting at previous lines.
7677 * Commands For Text:: Commands for changing text.
7678 * Commands For Killing:: Commands for killing and yanking.
7679 * Numeric Arguments:: Specifying numeric arguments, repeat counts.
7680 * Commands For Completion:: Getting Readline to do the typing for you.
7681 * Keyboard Macros:: Saving and re-executing typed characters
7682 * Miscellaneous Commands:: Other miscellaneous commands.
7684 This section describes Readline commands that may be bound to key
7685 sequences. You can list your key bindings by executing `bind -P' or,
7686 for a more terse format, suitable for an INPUTRC file, `bind -p'.
7687 (*Note Bash Builtins::.) Command names without an accompanying key
7688 sequence are unbound by default.
7690 In the following descriptions, "point" refers to the current cursor
7691 position, and "mark" refers to a cursor position saved by the
7692 `set-mark' command. The text between the point and mark is referred to
7696 File: bashref.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands
7698 8.4.1 Commands For Moving
7699 -------------------------
7701 `beginning-of-line (C-a)'
7702 Move to the start of the current line.
7705 Move to the end of the line.
7707 `forward-char (C-f)'
7708 Move forward a character.
7710 `backward-char (C-b)'
7711 Move back a character.
7713 `forward-word (M-f)'
7714 Move forward to the end of the next word. Words are composed of
7717 `backward-word (M-b)'
7718 Move back to the start of the current or previous word. Words are
7719 composed of letters and digits.
7721 `shell-forward-word ()'
7722 Move forward to the end of the next word. Words are delimited by
7723 non-quoted shell metacharacters.
7725 `shell-backward-word ()'
7726 Move back to the start of the current or previous word. Words are
7727 delimited by non-quoted shell metacharacters.
7729 `clear-screen (C-l)'
7730 Clear the screen and redraw the current line, leaving the current
7731 line at the top of the screen.
7733 `redraw-current-line ()'
7734 Refresh the current line. By default, this is unbound.
7738 File: bashref.info, Node: Commands For History, Next: Commands For Text, Prev: Commands For Moving, Up: Bindable Readline Commands
7740 8.4.2 Commands For Manipulating The History
7741 -------------------------------------------
7743 `accept-line (Newline or Return)'
7744 Accept the line regardless of where the cursor is. If this line is
7745 non-empty, add it to the history list according to the setting of
7746 the `HISTCONTROL' and `HISTIGNORE' variables. If this line is a
7747 modified history line, then restore the history line to its
7750 `previous-history (C-p)'
7751 Move `back' through the history list, fetching the previous
7754 `next-history (C-n)'
7755 Move `forward' through the history list, fetching the next command.
7757 `beginning-of-history (M-<)'
7758 Move to the first line in the history.
7760 `end-of-history (M->)'
7761 Move to the end of the input history, i.e., the line currently
7764 `reverse-search-history (C-r)'
7765 Search backward starting at the current line and moving `up'
7766 through the history as necessary. This is an incremental search.
7768 `forward-search-history (C-s)'
7769 Search forward starting at the current line and moving `down'
7770 through the the history as necessary. This is an incremental
7773 `non-incremental-reverse-search-history (M-p)'
7774 Search backward starting at the current line and moving `up'
7775 through the history as necessary using a non-incremental search
7776 for a string supplied by the user.
7778 `non-incremental-forward-search-history (M-n)'
7779 Search forward starting at the current line and moving `down'
7780 through the the history as necessary using a non-incremental search
7781 for a string supplied by the user.
7783 `history-search-forward ()'
7784 Search forward through the history for the string of characters
7785 between the start of the current line and the point. The search
7786 string must match at the beginning of a history line. This is a
7787 non-incremental search. By default, this command is unbound.
7789 `history-search-backward ()'
7790 Search backward through the history for the string of characters
7791 between the start of the current line and the point. The search
7792 string must match at the beginning of a history line. This is a
7793 non-incremental search. By default, this command is unbound.
7795 `history-substr-search-forward ()'
7796 Search forward through the history for the string of characters
7797 between the start of the current line and the point. The search
7798 string may match anywhere in a history line. This is a
7799 non-incremental search. By default, this command is unbound.
7801 `history-substr-search-backward ()'
7802 Search backward through the history for the string of characters
7803 between the start of the current line and the point. The search
7804 string may match anywhere in a history line. This is a
7805 non-incremental search. By default, this command is unbound.
7807 `yank-nth-arg (M-C-y)'
7808 Insert the first argument to the previous command (usually the
7809 second word on the previous line) at point. With an argument N,
7810 insert the Nth word from the previous command (the words in the
7811 previous command begin with word 0). A negative argument inserts
7812 the Nth word from the end of the previous command. Once the
7813 argument N is computed, the argument is extracted as if the `!N'
7814 history expansion had been specified.
7816 `yank-last-arg (M-. or M-_)'
7817 Insert last argument to the previous command (the last word of the
7818 previous history entry). With a numeric argument, behave exactly
7819 like `yank-nth-arg'. Successive calls to `yank-last-arg' move
7820 back through the history list, inserting the last word (or the
7821 word specified by the argument to the first call) of each line in
7822 turn. Any numeric argument supplied to these successive calls
7823 determines the direction to move through the history. A negative
7824 argument switches the direction through the history (back or
7825 forward). The history expansion facilities are used to extract
7826 the last argument, as if the `!$' history expansion had been
7831 File: bashref.info, Node: Commands For Text, Next: Commands For Killing, Prev: Commands For History, Up: Bindable Readline Commands
7833 8.4.3 Commands For Changing Text
7834 --------------------------------
7836 `end-of-file (usually C-d)'
7837 The character indicating end-of-file as set, for example, by
7838 `stty'. If this character is read when there are no characters on
7839 the line, and point is at the beginning of the line, Readline
7840 interprets it as the end of input and returns EOF.
7843 Delete the character at point. If this function is bound to the
7844 same character as the tty EOF character, as `C-d' commonly is, see
7845 above for the effects.
7847 `backward-delete-char (Rubout)'
7848 Delete the character behind the cursor. A numeric argument means
7849 to kill the characters instead of deleting them.
7851 `forward-backward-delete-char ()'
7852 Delete the character under the cursor, unless the cursor is at the
7853 end of the line, in which case the character behind the cursor is
7854 deleted. By default, this is not bound to a key.
7856 `quoted-insert (C-q or C-v)'
7857 Add the next character typed to the line verbatim. This is how to
7858 insert key sequences like `C-q', for example.
7860 `self-insert (a, b, A, 1, !, ...)'
7863 `transpose-chars (C-t)'
7864 Drag the character before the cursor forward over the character at
7865 the cursor, moving the cursor forward as well. If the insertion
7866 point is at the end of the line, then this transposes the last two
7867 characters of the line. Negative arguments have no effect.
7869 `transpose-words (M-t)'
7870 Drag the word before point past the word after point, moving point
7871 past that word as well. If the insertion point is at the end of
7872 the line, this transposes the last two words on the line.
7875 Uppercase the current (or following) word. With a negative
7876 argument, uppercase the previous word, but do not move the cursor.
7878 `downcase-word (M-l)'
7879 Lowercase the current (or following) word. With a negative
7880 argument, lowercase the previous word, but do not move the cursor.
7882 `capitalize-word (M-c)'
7883 Capitalize the current (or following) word. With a negative
7884 argument, capitalize the previous word, but do not move the cursor.
7887 Toggle overwrite mode. With an explicit positive numeric argument,
7888 switches to overwrite mode. With an explicit non-positive numeric
7889 argument, switches to insert mode. This command affects only
7890 `emacs' mode; `vi' mode does overwrite differently. Each call to
7891 `readline()' starts in insert mode.
7893 In overwrite mode, characters bound to `self-insert' replace the
7894 text at point rather than pushing the text to the right.
7895 Characters bound to `backward-delete-char' replace the character
7896 before point with a space.
7898 By default, this command is unbound.
7902 File: bashref.info, Node: Commands For Killing, Next: Numeric Arguments, Prev: Commands For Text, Up: Bindable Readline Commands
7904 8.4.4 Killing And Yanking
7905 -------------------------
7908 Kill the text from point to the end of the line.
7910 `backward-kill-line (C-x Rubout)'
7911 Kill backward to the beginning of the line.
7913 `unix-line-discard (C-u)'
7914 Kill backward from the cursor to the beginning of the current line.
7916 `kill-whole-line ()'
7917 Kill all characters on the current line, no matter where point is.
7918 By default, this is unbound.
7921 Kill from point to the end of the current word, or if between
7922 words, to the end of the next word. Word boundaries are the same
7925 `backward-kill-word (M-<DEL>)'
7926 Kill the word behind point. Word boundaries are the same as
7929 `shell-kill-word ()'
7930 Kill from point to the end of the current word, or if between
7931 words, to the end of the next word. Word boundaries are the same
7932 as `shell-forward-word'.
7934 `shell-backward-kill-word ()'
7935 Kill the word behind point. Word boundaries are the same as
7936 `shell-backward-word'.
7938 `unix-word-rubout (C-w)'
7939 Kill the word behind point, using white space as a word boundary.
7940 The killed text is saved on the kill-ring.
7942 `unix-filename-rubout ()'
7943 Kill the word behind point, using white space and the slash
7944 character as the word boundaries. The killed text is saved on the
7947 `delete-horizontal-space ()'
7948 Delete all spaces and tabs around point. By default, this is
7952 Kill the text in the current region. By default, this command is
7955 `copy-region-as-kill ()'
7956 Copy the text in the region to the kill buffer, so it can be yanked
7957 right away. By default, this command is unbound.
7959 `copy-backward-word ()'
7960 Copy the word before point to the kill buffer. The word
7961 boundaries are the same as `backward-word'. By default, this
7964 `copy-forward-word ()'
7965 Copy the word following point to the kill buffer. The word
7966 boundaries are the same as `forward-word'. By default, this
7970 Yank the top of the kill ring into the buffer at point.
7973 Rotate the kill-ring, and yank the new top. You can only do this
7974 if the prior command is `yank' or `yank-pop'.
7977 File: bashref.info, Node: Numeric Arguments, Next: Commands For Completion, Prev: Commands For Killing, Up: Bindable Readline Commands
7979 8.4.5 Specifying Numeric Arguments
7980 ----------------------------------
7982 `digit-argument (M-0, M-1, ... M--)'
7983 Add this digit to the argument already accumulating, or start a new
7984 argument. `M--' starts a negative argument.
7986 `universal-argument ()'
7987 This is another way to specify an argument. If this command is
7988 followed by one or more digits, optionally with a leading minus
7989 sign, those digits define the argument. If the command is
7990 followed by digits, executing `universal-argument' again ends the
7991 numeric argument, but is otherwise ignored. As a special case, if
7992 this command is immediately followed by a character that is
7993 neither a digit or minus sign, the argument count for the next
7994 command is multiplied by four. The argument count is initially
7995 one, so executing this function the first time makes the argument
7996 count four, a second time makes the argument count sixteen, and so
7997 on. By default, this is not bound to a key.
8000 File: bashref.info, Node: Commands For Completion, Next: Keyboard Macros, Prev: Numeric Arguments, Up: Bindable Readline Commands
8002 8.4.6 Letting Readline Type For You
8003 -----------------------------------
8006 Attempt to perform completion on the text before point. The
8007 actual completion performed is application-specific. Bash
8008 attempts completion treating the text as a variable (if the text
8009 begins with `$'), username (if the text begins with `~'), hostname
8010 (if the text begins with `@'), or command (including aliases and
8011 functions) in turn. If none of these produces a match, filename
8012 completion is attempted.
8014 `possible-completions (M-?)'
8015 List the possible completions of the text before point. When
8016 displaying completions, Readline sets the number of columns used
8017 for display to the value of `completion-display-width', the value
8018 of the environment variable `COLUMNS', or the screen width, in
8021 `insert-completions (M-*)'
8022 Insert all completions of the text before point that would have
8023 been generated by `possible-completions'.
8026 Similar to `complete', but replaces the word to be completed with
8027 a single match from the list of possible completions. Repeated
8028 execution of `menu-complete' steps through the list of possible
8029 completions, inserting each match in turn. At the end of the list
8030 of completions, the bell is rung (subject to the setting of
8031 `bell-style') and the original text is restored. An argument of N
8032 moves N positions forward in the list of matches; a negative
8033 argument may be used to move backward through the list. This
8034 command is intended to be bound to <TAB>, but is unbound by
8037 `menu-complete-backward ()'
8038 Identical to `menu-complete', but moves backward through the list
8039 of possible completions, as if `menu-complete' had been given a
8042 `delete-char-or-list ()'
8043 Deletes the character under the cursor if not at the beginning or
8044 end of the line (like `delete-char'). If at the end of the line,
8045 behaves identically to `possible-completions'. This command is
8048 `complete-filename (M-/)'
8049 Attempt filename completion on the text before point.
8051 `possible-filename-completions (C-x /)'
8052 List the possible completions of the text before point, treating
8055 `complete-username (M-~)'
8056 Attempt completion on the text before point, treating it as a
8059 `possible-username-completions (C-x ~)'
8060 List the possible completions of the text before point, treating
8063 `complete-variable (M-$)'
8064 Attempt completion on the text before point, treating it as a
8067 `possible-variable-completions (C-x $)'
8068 List the possible completions of the text before point, treating
8069 it as a shell variable.
8071 `complete-hostname (M-@)'
8072 Attempt completion on the text before point, treating it as a
8075 `possible-hostname-completions (C-x @)'
8076 List the possible completions of the text before point, treating
8079 `complete-command (M-!)'
8080 Attempt completion on the text before point, treating it as a
8081 command name. Command completion attempts to match the text
8082 against aliases, reserved words, shell functions, shell builtins,
8083 and finally executable filenames, in that order.
8085 `possible-command-completions (C-x !)'
8086 List the possible completions of the text before point, treating
8087 it as a command name.
8089 `dynamic-complete-history (M-<TAB>)'
8090 Attempt completion on the text before point, comparing the text
8091 against lines from the history list for possible completion
8095 Attempt menu completion on the text before point, comparing the
8096 text against lines from the history list for possible completion
8099 `complete-into-braces (M-{)'
8100 Perform filename completion and insert the list of possible
8101 completions enclosed within braces so the list is available to the
8102 shell (*note Brace Expansion::).
8106 File: bashref.info, Node: Keyboard Macros, Next: Miscellaneous Commands, Prev: Commands For Completion, Up: Bindable Readline Commands
8108 8.4.7 Keyboard Macros
8109 ---------------------
8111 `start-kbd-macro (C-x ()'
8112 Begin saving the characters typed into the current keyboard macro.
8114 `end-kbd-macro (C-x ))'
8115 Stop saving the characters typed into the current keyboard macro
8116 and save the definition.
8118 `call-last-kbd-macro (C-x e)'
8119 Re-execute the last keyboard macro defined, by making the
8120 characters in the macro appear as if typed at the keyboard.
8122 `print-last-kbd-macro ()'
8123 Print the last keboard macro defined in a format suitable for the
8128 File: bashref.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up: Bindable Readline Commands
8130 8.4.8 Some Miscellaneous Commands
8131 ---------------------------------
8133 `re-read-init-file (C-x C-r)'
8134 Read in the contents of the INPUTRC file, and incorporate any
8135 bindings or variable assignments found there.
8138 Abort the current editing command and ring the terminal's bell
8139 (subject to the setting of `bell-style').
8141 `do-uppercase-version (M-a, M-b, M-X, ...)'
8142 If the metafied character X is lowercase, run the command that is
8143 bound to the corresponding uppercase character.
8145 `prefix-meta (<ESC>)'
8146 Metafy the next character typed. This is for keyboards without a
8147 meta key. Typing `<ESC> f' is equivalent to typing `M-f'.
8149 `undo (C-_ or C-x C-u)'
8150 Incremental undo, separately remembered for each line.
8153 Undo all changes made to this line. This is like executing the
8154 `undo' command enough times to get back to the beginning.
8156 `tilde-expand (M-&)'
8157 Perform tilde expansion on the current word.
8160 Set the mark to the point. If a numeric argument is supplied, the
8161 mark is set to that position.
8163 `exchange-point-and-mark (C-x C-x)'
8164 Swap the point with the mark. The current cursor position is set
8165 to the saved position, and the old cursor position is saved as the
8168 `character-search (C-])'
8169 A character is read and point is moved to the next occurrence of
8170 that character. A negative count searches for previous
8173 `character-search-backward (M-C-])'
8174 A character is read and point is moved to the previous occurrence
8175 of that character. A negative count searches for subsequent
8178 `skip-csi-sequence ()'
8179 Read enough characters to consume a multi-key sequence such as
8180 those defined for keys like Home and End. Such sequences begin
8181 with a Control Sequence Indicator (CSI), usually ESC-[. If this
8182 sequence is bound to "\e[", keys producing such sequences will
8183 have no effect unless explicitly bound to a readline command,
8184 instead of inserting stray characters into the editing buffer.
8185 This is unbound by default, but usually bound to ESC-[.
8187 `insert-comment (M-#)'
8188 Without a numeric argument, the value of the `comment-begin'
8189 variable is inserted at the beginning of the current line. If a
8190 numeric argument is supplied, this command acts as a toggle: if
8191 the characters at the beginning of the line do not match the value
8192 of `comment-begin', the value is inserted, otherwise the
8193 characters in `comment-begin' are deleted from the beginning of
8194 the line. In either case, the line is accepted as if a newline
8195 had been typed. The default value of `comment-begin' causes this
8196 command to make the current line a shell comment. If a numeric
8197 argument causes the comment character to be removed, the line will
8198 be executed by the shell.
8201 Print all of the functions and their key bindings to the Readline
8202 output stream. If a numeric argument is supplied, the output is
8203 formatted in such a way that it can be made part of an INPUTRC
8204 file. This command is unbound by default.
8207 Print all of the settable variables and their values to the
8208 Readline output stream. If a numeric argument is supplied, the
8209 output is formatted in such a way that it can be made part of an
8210 INPUTRC file. This command is unbound by default.
8213 Print all of the Readline key sequences bound to macros and the
8214 strings they output. If a numeric argument is supplied, the
8215 output is formatted in such a way that it can be made part of an
8216 INPUTRC file. This command is unbound by default.
8218 `glob-complete-word (M-g)'
8219 The word before point is treated as a pattern for pathname
8220 expansion, with an asterisk implicitly appended. This pattern is
8221 used to generate a list of matching file names for possible
8224 `glob-expand-word (C-x *)'
8225 The word before point is treated as a pattern for pathname
8226 expansion, and the list of matching file names is inserted,
8227 replacing the word. If a numeric argument is supplied, a `*' is
8228 appended before pathname expansion.
8230 `glob-list-expansions (C-x g)'
8231 The list of expansions that would have been generated by
8232 `glob-expand-word' is displayed, and the line is redrawn. If a
8233 numeric argument is supplied, a `*' is appended before pathname
8236 `display-shell-version (C-x C-v)'
8237 Display version information about the current instance of Bash.
8239 `shell-expand-line (M-C-e)'
8240 Expand the line as the shell does. This performs alias and
8241 history expansion as well as all of the shell word expansions
8242 (*note Shell Expansions::).
8244 `history-expand-line (M-^)'
8245 Perform history expansion on the current line.
8248 Perform history expansion on the current line and insert a space
8249 (*note History Interaction::).
8251 `alias-expand-line ()'
8252 Perform alias expansion on the current line (*note Aliases::).
8254 `history-and-alias-expand-line ()'
8255 Perform history and alias expansion on the current line.
8257 `insert-last-argument (M-. or M-_)'
8258 A synonym for `yank-last-arg'.
8260 `operate-and-get-next (C-o)'
8261 Accept the current line for execution and fetch the next line
8262 relative to the current line from the history for editing. Any
8263 argument is ignored.
8265 `edit-and-execute-command (C-xC-e)'
8266 Invoke an editor on the current command line, and execute the
8267 result as shell commands. Bash attempts to invoke `$VISUAL',
8268 `$EDITOR', and `emacs' as the editor, in that order.
8272 File: bashref.info, Node: Readline vi Mode, Next: Programmable Completion, Prev: Bindable Readline Commands, Up: Command Line Editing
8274 8.5 Readline vi Mode
8275 ====================
8277 While the Readline library does not have a full set of `vi' editing
8278 functions, it does contain enough to allow simple editing of the line.
8279 The Readline `vi' mode behaves as specified in the POSIX standard.
8281 In order to switch interactively between `emacs' and `vi' editing
8282 modes, use the `set -o emacs' and `set -o vi' commands (*note The Set
8283 Builtin::). The Readline default is `emacs' mode.
8285 When you enter a line in `vi' mode, you are already placed in
8286 `insertion' mode, as if you had typed an `i'. Pressing <ESC> switches
8287 you into `command' mode, where you can edit the text of the line with
8288 the standard `vi' movement keys, move to previous history lines with
8289 `k' and subsequent lines with `j', and so forth.
8292 File: bashref.info, Node: Programmable Completion, Next: Programmable Completion Builtins, Prev: Readline vi Mode, Up: Command Line Editing
8294 8.6 Programmable Completion
8295 ===========================
8297 When word completion is attempted for an argument to a command for
8298 which a completion specification (a COMPSPEC) has been defined using
8299 the `complete' builtin (*note Programmable Completion Builtins::), the
8300 programmable completion facilities are invoked.
8302 First, the command name is identified. If a compspec has been
8303 defined for that command, the compspec is used to generate the list of
8304 possible completions for the word. If the command word is the empty
8305 string (completion attempted at the beginning of an empty line), any
8306 compspec defined with the `-E' option to `complete' is used. If the
8307 command word is a full pathname, a compspec for the full pathname is
8308 searched for first. If no compspec is found for the full pathname, an
8309 attempt is made to find a compspec for the portion following the final
8310 slash. If those searches do not result in a compspec, any compspec
8311 defined with the `-D' option to `complete' is used as the default.
8313 Once a compspec has been found, it is used to generate the list of
8314 matching words. If a compspec is not found, the default Bash completion
8315 described above (*note Commands For Completion::) is performed.
8317 First, the actions specified by the compspec are used. Only matches
8318 which are prefixed by the word being completed are returned. When the
8319 `-f' or `-d' option is used for filename or directory name completion,
8320 the shell variable `FIGNORE' is used to filter the matches. *Note Bash
8321 Variables::, for a description of `FIGNORE'.
8323 Any completions specified by a filename expansion pattern to the
8324 `-G' option are generated next. The words generated by the pattern
8325 need not match the word being completed. The `GLOBIGNORE' shell
8326 variable is not used to filter the matches, but the `FIGNORE' shell
8329 Next, the string specified as the argument to the `-W' option is
8330 considered. The string is first split using the characters in the `IFS'
8331 special variable as delimiters. Shell quoting is honored. Each word
8332 is then expanded using brace expansion, tilde expansion, parameter and
8333 variable expansion, command substitution, and arithmetic expansion, as
8334 described above (*note Shell Expansions::). The results are split
8335 using the rules described above (*note Word Splitting::). The results
8336 of the expansion are prefix-matched against the word being completed,
8337 and the matching words become the possible completions.
8339 After these matches have been generated, any shell function or
8340 command specified with the `-F' and `-C' options is invoked. When the
8341 command or function is invoked, the `COMP_LINE', `COMP_POINT',
8342 `COMP_KEY', and `COMP_TYPE' variables are assigned values as described
8343 above (*note Bash Variables::). If a shell function is being invoked,
8344 the `COMP_WORDS' and `COMP_CWORD' variables are also set. When the
8345 function or command is invoked, the first argument ($1) is the name of
8346 the command whose arguments are being completed, the second argument
8347 ($2) is the word being completed, and the third argument ($3) is the
8348 word preceding the word being completed on the current command line.
8349 No filtering of the generated completions against the word being
8350 completed is performed; the function or command has complete freedom in
8351 generating the matches.
8353 Any function specified with `-F' is invoked first. The function may
8354 use any of the shell facilities, including the `compgen' and `compopt'
8355 builtins described below (*note Programmable Completion Builtins::), to
8356 generate the matches. It must put the possible completions in the
8357 `COMPREPLY' array variable, one per array element.
8359 Next, any command specified with the `-C' option is invoked in an
8360 environment equivalent to command substitution. It should print a list
8361 of completions, one per line, to the standard output. Backslash may be
8362 used to escape a newline, if necessary.
8364 After all of the possible completions are generated, any filter
8365 specified with the `-X' option is applied to the list. The filter is a
8366 pattern as used for pathname expansion; a `&' in the pattern is
8367 replaced with the text of the word being completed. A literal `&' may
8368 be escaped with a backslash; the backslash is removed before attempting
8369 a match. Any completion that matches the pattern will be removed from
8370 the list. A leading `!' negates the pattern; in this case any
8371 completion not matching the pattern will be removed.
8373 Finally, any prefix and suffix specified with the `-P' and `-S'
8374 options are added to each member of the completion list, and the result
8375 is returned to the Readline completion code as the list of possible
8378 If the previously-applied actions do not generate any matches, and
8379 the `-o dirnames' option was supplied to `complete' when the compspec
8380 was defined, directory name completion is attempted.
8382 If the `-o plusdirs' option was supplied to `complete' when the
8383 compspec was defined, directory name completion is attempted and any
8384 matches are added to the results of the other actions.
8386 By default, if a compspec is found, whatever it generates is
8387 returned to the completion code as the full set of possible completions.
8388 The default Bash completions are not attempted, and the Readline default
8389 of filename completion is disabled. If the `-o bashdefault' option was
8390 supplied to `complete' when the compspec was defined, the default Bash
8391 completions are attempted if the compspec generates no matches. If the
8392 `-o default' option was supplied to `complete' when the compspec was
8393 defined, Readline's default completion will be performed if the
8394 compspec (and, if attempted, the default Bash completions) generate no
8397 When a compspec indicates that directory name completion is desired,
8398 the programmable completion functions force Readline to append a slash
8399 to completed names which are symbolic links to directories, subject to
8400 the value of the MARK-DIRECTORIES Readline variable, regardless of the
8401 setting of the MARK-SYMLINKED-DIRECTORIES Readline variable.
8403 There is some support for dynamically modifying completions. This is
8404 most useful when used in combination with a default completion specified
8405 with `-D'. It's possible for shell functions executed as completion
8406 handlers to indicate that completion should be retried by returning an
8407 exit status of 124. If a shell function returns 124, and changes the
8408 compspec associated with the command on which completion is being
8409 attempted (supplied as the first argument when the function is
8410 executed), programmable completion restarts from the beginning, with an
8411 attempt to find a new compspec for that command. This allows a set of
8412 completions to be built dynamically as completion is attempted, rather
8413 than being loaded all at once.
8415 For instance, assuming that there is a library of compspecs, each
8416 kept in a file corresponding to the name of the command, the following
8417 default completion function would load completions dynamically:
8419 _completion_loader()
8421 . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
8423 complete -D -F _completion_loader -o bashdefault -o default
8426 File: bashref.info, Node: Programmable Completion Builtins, Next: A Programmable Completion Example, Prev: Programmable Completion, Up: Command Line Editing
8428 8.7 Programmable Completion Builtins
8429 ====================================
8431 Three builtin commands are available to manipulate the programmable
8432 completion facilities: one to specify how the arguments to a particular
8433 command are to be completed, and two to modify the completion as it is
8437 `compgen [OPTION] [WORD]'
8439 Generate possible completion matches for WORD according to the
8440 OPTIONs, which may be any option accepted by the `complete'
8441 builtin with the exception of `-p' and `-r', and write the matches
8442 to the standard output. When using the `-F' or `-C' options, the
8443 various shell variables set by the programmable completion
8444 facilities, while available, will not have useful values.
8446 The matches will be generated in the same way as if the
8447 programmable completion code had generated them directly from a
8448 completion specification with the same flags. If WORD is
8449 specified, only those completions matching WORD will be displayed.
8451 The return value is true unless an invalid option is supplied, or
8452 no matches were generated.
8455 `complete [-abcdefgjksuv] [-o COMP-OPTION] [-DE] [-A ACTION] [-G GLOBPAT] [-W WORDLIST]
8456 [-F FUNCTION] [-C COMMAND] [-X FILTERPAT]
8457 [-P PREFIX] [-S SUFFIX] NAME [NAME ...]'
8458 `complete -pr [-DE] [NAME ...]'
8460 Specify how arguments to each NAME should be completed. If the
8461 `-p' option is supplied, or if no options are supplied, existing
8462 completion specifications are printed in a way that allows them to
8463 be reused as input. The `-r' option removes a completion
8464 specification for each NAME, or, if no NAMEs are supplied, all
8465 completion specifications. The `-D' option indicates that the
8466 remaining options and actions should apply to the "default"
8467 command completion; that is, completion attempted on a command for
8468 which no completion has previously been defined. The `-E' option
8469 indicates that the remaining options and actions should apply to
8470 "empty" command completion; that is, completion attempted on a
8473 The process of applying these completion specifications when word
8474 completion is attempted is described above (*note Programmable
8475 Completion::). The `-D' option takes precedence over `-E'.
8477 Other options, if specified, have the following meanings. The
8478 arguments to the `-G', `-W', and `-X' options (and, if necessary,
8479 the `-P' and `-S' options) should be quoted to protect them from
8480 expansion before the `complete' builtin is invoked.
8483 The COMP-OPTION controls several aspects of the compspec's
8484 behavior beyond the simple generation of completions.
8485 COMP-OPTION may be one of:
8488 Perform the rest of the default Bash completions if the
8489 compspec generates no matches.
8492 Use Readline's default filename completion if the
8493 compspec generates no matches.
8496 Perform directory name completion if the compspec
8497 generates no matches.
8500 Tell Readline that the compspec generates filenames, so
8501 it can perform any filename-specific processing (like
8502 adding a slash to directory names quoting special
8503 characters, or suppressing trailing spaces). This
8504 option is intended to be used with shell functions
8505 specified with `-F'.
8508 Tell Readline not to quote the completed words if they
8509 are filenames (quoting filenames is the default).
8512 Tell Readline not to append a space (the default) to
8513 words completed at the end of the line.
8516 After any matches defined by the compspec are generated,
8517 directory name completion is attempted and any matches
8518 are added to the results of the other actions.
8522 The ACTION may be one of the following to generate a list of
8523 possible completions:
8526 Alias names. May also be specified as `-a'.
8529 Array variable names.
8532 Readline key binding names (*note Bindable Readline
8536 Names of shell builtin commands. May also be specified
8540 Command names. May also be specified as `-c'.
8543 Directory names. May also be specified as `-d'.
8546 Names of disabled shell builtins.
8549 Names of enabled shell builtins.
8552 Names of exported shell variables. May also be
8556 File names. May also be specified as `-f'.
8559 Names of shell functions.
8562 Group names. May also be specified as `-g'.
8565 Help topics as accepted by the `help' builtin (*note
8569 Hostnames, as taken from the file specified by the
8570 `HOSTFILE' shell variable (*note Bash Variables::).
8573 Job names, if job control is active. May also be
8577 Shell reserved words. May also be specified as `-k'.
8580 Names of running jobs, if job control is active.
8583 Service names. May also be specified as `-s'.
8586 Valid arguments for the `-o' option to the `set' builtin
8587 (*note The Set Builtin::).
8590 Shell option names as accepted by the `shopt' builtin
8591 (*note Bash Builtins::).
8597 Names of stopped jobs, if job control is active.
8600 User names. May also be specified as `-u'.
8603 Names of all shell variables. May also be specified as
8607 COMMAND is executed in a subshell environment, and its output
8608 is used as the possible completions.
8611 The shell function FUNCTION is executed in the current shell
8612 environment. When it is executed, $1 is the name of the
8613 command whose arguments are being completed, $2 is the word
8614 being completed, and $3 is the word preceding the word being
8615 completed, as described above (*note Programmable
8616 Completion::). When it finishes, the possible completions
8617 are retrieved from the value of the `COMPREPLY' array
8621 The filename expansion pattern GLOBPAT is expanded to generate
8622 the possible completions.
8625 PREFIX is added at the beginning of each possible completion
8626 after all other options have been applied.
8629 SUFFIX is appended to each possible completion after all
8630 other options have been applied.
8633 The WORDLIST is split using the characters in the `IFS'
8634 special variable as delimiters, and each resultant word is
8635 expanded. The possible completions are the members of the
8636 resultant list which match the word being completed.
8639 FILTERPAT is a pattern as used for filename expansion. It is
8640 applied to the list of possible completions generated by the
8641 preceding options and arguments, and each completion matching
8642 FILTERPAT is removed from the list. A leading `!' in
8643 FILTERPAT negates the pattern; in this case, any completion
8644 not matching FILTERPAT is removed.
8646 The return value is true unless an invalid option is supplied, an
8647 option other than `-p' or `-r' is supplied without a NAME
8648 argument, an attempt is made to remove a completion specification
8649 for a NAME for which no specification exists, or an error occurs
8650 adding a completion specification.
8653 `compopt' [-o OPTION] [-DE] [+o OPTION] [NAME]
8654 Modify completion options for each NAME according to the OPTIONs,
8655 or for the currently-executing completion if no NAMEs are supplied.
8656 If no OPTIONs are given, display the completion options for each
8657 NAME or the current completion. The possible values of OPTION are
8658 those valid for the `complete' builtin described above. The `-D'
8659 option indicates that the remaining options should apply to the
8660 "default" command completion; that is, completion attempted on a
8661 command for which no completion has previously been defined. The
8662 `-E' option indicates that the remaining options should apply to
8663 "empty" command completion; that is, completion attempted on a
8666 The `-D' option takes precedence over `-E'.
8668 The return value is true unless an invalid option is supplied, an
8669 attempt is made to modify the options for a NAME for which no
8670 completion specification exists, or an output error occurs.
8674 File: bashref.info, Node: A Programmable Completion Example, Prev: Programmable Completion Builtins, Up: Command Line Editing
8676 8.8 A Programmable Completion Example
8677 =====================================
8679 The most common way to obtain additional completion functionality beyond
8680 the default actions `complete' and `compgen' provide is to use a shell
8681 function and bind it to a particular command using `complete -F'.
8683 The following function provides completions for the `cd' builtin.
8684 It is a reasonably good example of what shell functions must do when
8685 used for completion. This function uses the word passsed as `$2' to
8686 determine the directory name to complete. You can also use the
8687 `COMP_WORDS' array variable; the current word is indexed by the
8688 `COMP_CWORD' variable.
8690 The function relies on the `complete' and `compgen' builtins to do
8691 much of the work, adding only the things that the Bash `cd' does beyond
8692 accepting basic directory names: tilde expansion (*note Tilde
8693 Expansion::), searching directories in $CDPATH, which is described above
8694 (*note Bourne Shell Builtins::), and basic support for the
8695 `cdable_vars' shell option (*note The Shopt Builtin::). `_comp_cd'
8696 modifies the value of IFS so that it contains only a newline to
8697 accommodate file names containing spaces and tabs - `compgen' prints
8698 the possible completions it generates one per line.
8700 Possible completions go into the COMPREPLY array variable, one
8701 completion per array element. The programmable completion system
8702 retrieves the completions from there when the function returns.
8704 # A completion function for the cd builtin
8705 # based on the cd completion function from the bash_completion package
8708 local IFS=$' \t\n' # normalize IFS
8709 local cur _skipdot _cdpath
8712 # Tilde expansion, with side effect of expanding tilde to full pathname
8714 \~*) eval cur="$2" ;;
8718 # no cdpath or absolute pathname -- straight directory completion
8719 if [[ -z "${CDPATH:-}" ]] || [[ "$cur" == @(./*|../*|/*) ]]; then
8720 # compgen prints paths one per line; could also use while loop
8722 COMPREPLY=( $(compgen -d -- "$cur") )
8724 # CDPATH+directories in the current directory if not in CDPATH
8728 # preprocess CDPATH to convert null directory names to .
8729 _cdpath=${CDPATH/#:/.:}
8730 _cdpath=${_cdpath//::/:.:}
8731 _cdpath=${_cdpath/%:/:.}
8732 for i in ${_cdpath//:/$'\n'}; do
8733 if [[ $i -ef . ]]; then _skipdot=true; fi
8734 k="${#COMPREPLY[@]}"
8735 for j in $( compgen -d -- "$i/$cur" ); do
8736 COMPREPLY[k++]=${j#$i/} # cut off directory
8739 $_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") )
8743 # variable names if appropriate shell option set and no completions
8744 if shopt -q cdable_vars && [[ ${#COMPREPLY[@]} -eq 0 ]]; then
8745 COMPREPLY=( $(compgen -v -- "$cur") )
8751 We install the completion function using the `-F' option to
8754 # Tell readline to quote appropriate and append slashes to directories;
8755 # use the bash default completion for other arguments
8756 complete -o filenames -o nospace -o bashdefault -F _comp_cd cd
8758 Since we'd like Bash and Readline to take care of some of the other
8759 details for us, we use several other options to tell Bash and Readline
8760 what to do. The `-o filenames' option tells Readline that the possible
8761 completions should be treated as filenames, and quoted appropriately.
8762 That option will also cause Readline to append a slash to filenames it
8763 can determine are directories (which is why we might want to extend
8764 `_comp_cd' to append a slash if we're using directories found via
8765 CDPATH: Readline can't tell those completions are directories). The
8766 `-o nospace' option tells Readline to not append a space character to
8767 the directory name, in case we want to append to it. The `-o
8768 bashdefault' option brings in the rest of the "Bash default"
8769 completions - possible completion that Bash adds to the default Readline
8770 set. These include things like command name completion, variable
8771 completion for words beginning with `{', completions containing pathname
8772 expansion patterns (*note Filename Expansion::), and so on.
8774 Once installed using `complete', `_comp_cd' will be called every
8775 time we attempt word completion for a `cd' command.
8777 Many more examples - an extensive collection of completions for most
8778 of the common GNU, Unix, and Linux commands - are available as part of
8779 the bash_completion project. This is installed by default on many
8780 GNU/Linux distributions. Originally written by Ian Macdonald, the
8781 project now lives at `http://bash-completion.alioth.debian.org/'.
8782 There are ports for other systems such as Solaris and Mac OS X.
8784 An older version of the bash_completion package is distributed with
8785 bash in the `examples/complete' subdirectory.
8788 File: bashref.info, Node: Using History Interactively, Next: Installing Bash, Prev: Command Line Editing, Up: Top
8790 9 Using History Interactively
8791 *****************************
8793 This chapter describes how to use the GNU History Library
8794 interactively, from a user's standpoint. It should be considered a
8795 user's guide. For information on using the GNU History Library in
8796 other programs, see the GNU Readline Library Manual.
8800 * Bash History Facilities:: How Bash lets you manipulate your command
8802 * Bash History Builtins:: The Bash builtin commands that manipulate
8803 the command history.
8804 * History Interaction:: What it feels like using History as a user.
8807 File: bashref.info, Node: Bash History Facilities, Next: Bash History Builtins, Up: Using History Interactively
8809 9.1 Bash History Facilities
8810 ===========================
8812 When the `-o history' option to the `set' builtin is enabled (*note The
8813 Set Builtin::), the shell provides access to the "command history", the
8814 list of commands previously typed. The value of the `HISTSIZE' shell
8815 variable is used as the number of commands to save in a history list.
8816 The text of the last `$HISTSIZE' commands (default 500) is saved. The
8817 shell stores each command in the history list prior to parameter and
8818 variable expansion but after history expansion is performed, subject to
8819 the values of the shell variables `HISTIGNORE' and `HISTCONTROL'.
8821 When the shell starts up, the history is initialized from the file
8822 named by the `HISTFILE' variable (default `~/.bash_history'). The file
8823 named by the value of `HISTFILE' is truncated, if necessary, to contain
8824 no more than the number of lines specified by the value of the
8825 `HISTFILESIZE' variable. When a shell with history enabled exits, the
8826 last `$HISTSIZE' lines are copied from the history list to the file
8827 named by `$HISTFILE'. If the `histappend' shell option is set (*note
8828 Bash Builtins::), the lines are appended to the history file, otherwise
8829 the history file is overwritten. If `HISTFILE' is unset, or if the
8830 history file is unwritable, the history is not saved. After saving the
8831 history, the history file is truncated to contain no more than
8832 `$HISTFILESIZE' lines. If `HISTFILESIZE' is unset, or set to null, a
8833 non-numeric value, or a numeric value less than zero, the history file
8836 If the `HISTTIMEFORMAT' is set, the time stamp information
8837 associated with each history entry is written to the history file,
8838 marked with the history comment character. When the history file is
8839 read, lines beginning with the history comment character followed
8840 immediately by a digit are interpreted as timestamps for the previous
8843 The builtin command `fc' may be used to list or edit and re-execute
8844 a portion of the history list. The `history' builtin may be used to
8845 display or modify the history list and manipulate the history file.
8846 When using command-line editing, search commands are available in each
8847 editing mode that provide access to the history list (*note Commands
8850 The shell allows control over which commands are saved on the history
8851 list. The `HISTCONTROL' and `HISTIGNORE' variables may be set to cause
8852 the shell to save only a subset of the commands entered. The `cmdhist'
8853 shell option, if enabled, causes the shell to attempt to save each line
8854 of a multi-line command in the same history entry, adding semicolons
8855 where necessary to preserve syntactic correctness. The `lithist' shell
8856 option causes the shell to save the command with embedded newlines
8857 instead of semicolons. The `shopt' builtin is used to set these
8858 options. *Note Bash Builtins::, for a description of `shopt'.
8861 File: bashref.info, Node: Bash History Builtins, Next: History Interaction, Prev: Bash History Facilities, Up: Using History Interactively
8863 9.2 Bash History Builtins
8864 =========================
8866 Bash provides two builtin commands which manipulate the history list
8870 `fc [-e ENAME] [-lnr] [FIRST] [LAST]'
8871 `fc -s [PAT=REP] [COMMAND]'
8873 The first form selects a range of commands from FIRST to LAST from
8874 the history list and displays or edits and re-executes them. Both
8875 FIRST and LAST may be specified as a string (to locate the most
8876 recent command beginning with that string) or as a number (an
8877 index into the history list, where a negative number is used as an
8878 offset from the current command number). If LAST is not specified
8879 it is set to FIRST. If FIRST is not specified it is set to the
8880 previous command for editing and -16 for listing. If the `-l'
8881 flag is given, the commands are listed on standard output. The
8882 `-n' flag suppresses the command numbers when listing. The `-r'
8883 flag reverses the order of the listing. Otherwise, the editor
8884 given by ENAME is invoked on a file containing those commands. If
8885 ENAME is not given, the value of the following variable expansion
8886 is used: `${FCEDIT:-${EDITOR:-vi}}'. This says to use the value
8887 of the `FCEDIT' variable if set, or the value of the `EDITOR'
8888 variable if that is set, or `vi' if neither is set. When editing
8889 is complete, the edited commands are echoed and executed.
8891 In the second form, COMMAND is re-executed after each instance of
8892 PAT in the selected command is replaced by REP. COMMAND is
8893 intepreted the same as FIRST above.
8895 A useful alias to use with the `fc' command is `r='fc -s'', so
8896 that typing `r cc' runs the last command beginning with `cc' and
8897 typing `r' re-executes the last command (*note Aliases::).
8903 history [-anrw] [FILENAME]
8906 With no options, display the history list with line numbers.
8907 Lines prefixed with a `*' have been modified. An argument of N
8908 lists only the last N lines. If the shell variable
8909 `HISTTIMEFORMAT' is set and not null, it is used as a format
8910 string for STRFTIME to display the time stamp associated with each
8911 displayed history entry. No intervening blank is printed between
8912 the formatted time stamp and the history line.
8914 Options, if supplied, have the following meanings:
8917 Clear the history list. This may be combined with the other
8918 options to replace the history list completely.
8921 Delete the history entry at position OFFSET. OFFSET should
8922 be specified as it appears when the history is displayed.
8925 Append the new history lines (history lines entered since the
8926 beginning of the current Bash session) to the history file.
8929 Append the history lines not already read from the history
8930 file to the current history list. These are lines appended
8931 to the history file since the beginning of the current Bash
8935 Read the history file and append its contents to the history
8939 Write out the current history list to the history file.
8942 Perform history substitution on the ARGs and display the
8943 result on the standard output, without storing the results in
8947 The ARGs are added to the end of the history list as a single
8951 When any of the `-w', `-r', `-a', or `-n' options is used, if
8952 FILENAME is given, then it is used as the history file. If not,
8953 then the value of the `HISTFILE' variable is used.
8957 File: bashref.info, Node: History Interaction, Prev: Bash History Builtins, Up: Using History Interactively
8959 9.3 History Expansion
8960 =====================
8962 The History library provides a history expansion feature that is similar
8963 to the history expansion provided by `csh'. This section describes the
8964 syntax used to manipulate the history information.
8966 History expansions introduce words from the history list into the
8967 input stream, making it easy to repeat commands, insert the arguments
8968 to a previous command into the current input line, or fix errors in
8969 previous commands quickly.
8971 History expansion takes place in two parts. The first is to
8972 determine which line from the history list should be used during
8973 substitution. The second is to select portions of that line for
8974 inclusion into the current one. The line selected from the history is
8975 called the "event", and the portions of that line that are acted upon
8976 are called "words". Various "modifiers" are available to manipulate
8977 the selected words. The line is broken into words in the same fashion
8978 that Bash does, so that several words surrounded by quotes are
8979 considered one word. History expansions are introduced by the
8980 appearance of the history expansion character, which is `!' by default.
8981 Only `\' and `'' may be used to escape the history expansion character.
8983 Several shell options settable with the `shopt' builtin (*note Bash
8984 Builtins::) may be used to tailor the behavior of history expansion.
8985 If the `histverify' shell option is enabled, and Readline is being
8986 used, history substitutions are not immediately passed to the shell
8987 parser. Instead, the expanded line is reloaded into the Readline
8988 editing buffer for further modification. If Readline is being used,
8989 and the `histreedit' shell option is enabled, a failed history
8990 expansion will be reloaded into the Readline editing buffer for
8991 correction. The `-p' option to the `history' builtin command may be
8992 used to see what a history expansion will do before using it. The `-s'
8993 option to the `history' builtin may be used to add commands to the end
8994 of the history list without actually executing them, so that they are
8995 available for subsequent recall. This is most useful in conjunction
8998 The shell allows control of the various characters used by the
8999 history expansion mechanism with the `histchars' variable, as explained
9000 above (*note Bash Variables::). The shell uses the history comment
9001 character to mark history timestamps when writing the history file.
9005 * Event Designators:: How to specify which history line to use.
9006 * Word Designators:: Specifying which words are of interest.
9007 * Modifiers:: Modifying the results of substitution.
9010 File: bashref.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
9012 9.3.1 Event Designators
9013 -----------------------
9015 An event designator is a reference to a command line entry in the
9016 history list. Unless the reference is absolute, events are relative to
9017 the current position in the history list.
9020 Start a history substitution, except when followed by a space, tab,
9021 the end of the line, `=' or `(' (when the `extglob' shell option
9022 is enabled using the `shopt' builtin).
9025 Refer to command line N.
9028 Refer to the command N lines back.
9031 Refer to the previous command. This is a synonym for `!-1'.
9034 Refer to the most recent command preceding the current position in
9035 the history list starting with STRING.
9038 Refer to the most recent command preceding the current position in
9039 the history list containing STRING. The trailing `?' may be
9040 omitted if the STRING is followed immediately by a newline.
9043 Quick Substitution. Repeat the last command, replacing STRING1
9044 with STRING2. Equivalent to `!!:s/STRING1/STRING2/'.
9047 The entire command line typed so far.
9051 File: bashref.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
9053 9.3.2 Word Designators
9054 ----------------------
9056 Word designators are used to select desired words from the event. A
9057 `:' separates the event specification from the word designator. It may
9058 be omitted if the word designator begins with a `^', `$', `*', `-', or
9059 `%'. Words are numbered from the beginning of the line, with the first
9060 word being denoted by 0 (zero). Words are inserted into the current
9061 line separated by single spaces.
9066 designates the preceding command. When you type this, the
9067 preceding command is repeated in toto.
9070 designates the last argument of the preceding command. This may be
9074 designates the second argument of the most recent command starting
9075 with the letters `fi'.
9077 Here are the word designators:
9080 The `0'th word. For many applications, this is the command word.
9086 The first argument; that is, word 1.
9092 The word matched by the most recent `?STRING?' search.
9095 A range of words; `-Y' abbreviates `0-Y'.
9098 All of the words, except the `0'th. This is a synonym for `1-$'.
9099 It is not an error to use `*' if there is just one word in the
9100 event; the empty string is returned in that case.
9106 Abbreviates `X-$' like `X*', but omits the last word.
9109 If a word designator is supplied without an event specification, the
9110 previous command is used as the event.
9113 File: bashref.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
9118 After the optional word designator, you can add a sequence of one or
9119 more of the following modifiers, each preceded by a `:'.
9122 Remove a trailing pathname component, leaving only the head.
9125 Remove all leading pathname components, leaving the tail.
9128 Remove a trailing suffix of the form `.SUFFIX', leaving the
9132 Remove all but the trailing suffix.
9135 Print the new command but do not execute it.
9138 Quote the substituted words, escaping further substitutions.
9141 Quote the substituted words as with `q', but break into words at
9142 spaces, tabs, and newlines.
9145 Substitute NEW for the first occurrence of OLD in the event line.
9146 Any delimiter may be used in place of `/'. The delimiter may be
9147 quoted in OLD and NEW with a single backslash. If `&' appears in
9148 NEW, it is replaced by OLD. A single backslash will quote the
9149 `&'. The final delimiter is optional if it is the last character
9153 Repeat the previous substitution.
9157 Cause changes to be applied over the entire event line. Used in
9158 conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
9161 Apply the following `s' modifier once to each word in the event.
9165 File: bashref.info, Node: Installing Bash, Next: Reporting Bugs, Prev: Using History Interactively, Up: Top
9170 This chapter provides basic instructions for installing Bash on the
9171 various supported platforms. The distribution supports the GNU
9172 operating systems, nearly every version of Unix, and several non-Unix
9173 systems such as BeOS and Interix. Other independent ports exist for
9174 MS-DOS, OS/2, and Windows platforms.
9178 * Basic Installation:: Installation instructions.
9179 * Compilers and Options:: How to set special options for various
9181 * Compiling For Multiple Architectures:: How to compile Bash for more
9182 than one kind of system from
9183 the same source tree.
9184 * Installation Names:: How to set the various paths used by the installation.
9185 * Specifying the System Type:: How to configure Bash for a particular system.
9186 * Sharing Defaults:: How to share default configuration values among GNU
9188 * Operation Controls:: Options recognized by the configuration program.
9189 * Optional Features:: How to enable and disable optional features when
9193 File: bashref.info, Node: Basic Installation, Next: Compilers and Options, Up: Installing Bash
9195 10.1 Basic Installation
9196 =======================
9198 These are installation instructions for Bash.
9200 The simplest way to compile Bash is:
9202 1. `cd' to the directory containing the source code and type
9203 `./configure' to configure Bash for your system. If you're using
9204 `csh' on an old version of System V, you might need to type `sh
9205 ./configure' instead to prevent `csh' from trying to execute
9208 Running `configure' takes some time. While running, it prints
9209 messages telling which features it is checking for.
9211 2. Type `make' to compile Bash and build the `bashbug' bug reporting
9214 3. Optionally, type `make tests' to run the Bash test suite.
9216 4. Type `make install' to install `bash' and `bashbug'. This will
9217 also install the manual pages and Info file.
9220 The `configure' shell script attempts to guess correct values for
9221 various system-dependent variables used during compilation. It uses
9222 those values to create a `Makefile' in each directory of the package
9223 (the top directory, the `builtins', `doc', and `support' directories,
9224 each directory under `lib', and several others). It also creates a
9225 `config.h' file containing system-dependent definitions. Finally, it
9226 creates a shell script named `config.status' that you can run in the
9227 future to recreate the current configuration, a file `config.cache'
9228 that saves the results of its tests to speed up reconfiguring, and a
9229 file `config.log' containing compiler output (useful mainly for
9230 debugging `configure'). If at some point `config.cache' contains
9231 results you don't want to keep, you may remove or edit it.
9233 To find out more about the options and arguments that the
9234 `configure' script understands, type
9236 bash-2.04$ ./configure --help
9238 at the Bash prompt in your Bash source directory.
9240 If you need to do unusual things to compile Bash, please try to
9241 figure out how `configure' could check whether or not to do them, and
9242 mail diffs or instructions to <bash-maintainers@gnu.org> so they can be
9243 considered for the next release.
9245 The file `configure.ac' is used to create `configure' by a program
9246 called Autoconf. You only need `configure.ac' if you want to change it
9247 or regenerate `configure' using a newer version of Autoconf. If you do
9248 this, make sure you are using Autoconf version 2.50 or newer.
9250 You can remove the program binaries and object files from the source
9251 code directory by typing `make clean'. To also remove the files that
9252 `configure' created (so you can compile Bash for a different kind of
9253 computer), type `make distclean'.
9256 File: bashref.info, Node: Compilers and Options, Next: Compiling For Multiple Architectures, Prev: Basic Installation, Up: Installing Bash
9258 10.2 Compilers and Options
9259 ==========================
9261 Some systems require unusual options for compilation or linking that
9262 the `configure' script does not know about. You can give `configure'
9263 initial values for variables by setting them in the environment. Using
9264 a Bourne-compatible shell, you can do that on the command line like
9267 CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
9269 On systems that have the `env' program, you can do it like this:
9271 env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
9273 The configuration process uses GCC to build Bash if it is available.
9276 File: bashref.info, Node: Compiling For Multiple Architectures, Next: Installation Names, Prev: Compilers and Options, Up: Installing Bash
9278 10.3 Compiling For Multiple Architectures
9279 =========================================
9281 You can compile Bash for more than one kind of computer at the same
9282 time, by placing the object files for each architecture in their own
9283 directory. To do this, you must use a version of `make' that supports
9284 the `VPATH' variable, such as GNU `make'. `cd' to the directory where
9285 you want the object files and executables to go and run the `configure'
9286 script from the source directory. You may need to supply the
9287 `--srcdir=PATH' argument to tell `configure' where the source files
9288 are. `configure' automatically checks for the source code in the
9289 directory that `configure' is in and in `..'.
9291 If you have to use a `make' that does not supports the `VPATH'
9292 variable, you can compile Bash for one architecture at a time in the
9293 source code directory. After you have installed Bash for one
9294 architecture, use `make distclean' before reconfiguring for another
9297 Alternatively, if your system supports symbolic links, you can use
9298 the `support/mkclone' script to create a build tree which has symbolic
9299 links back to each file in the source directory. Here's an example
9300 that creates a build directory in the current directory from a source
9301 directory `/usr/gnu/src/bash-2.0':
9303 bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
9305 The `mkclone' script requires Bash, so you must have already built Bash
9306 for at least one architecture before you can create build directories
9307 for other architectures.
9310 File: bashref.info, Node: Installation Names, Next: Specifying the System Type, Prev: Compiling For Multiple Architectures, Up: Installing Bash
9312 10.4 Installation Names
9313 =======================
9315 By default, `make install' will install into `/usr/local/bin',
9316 `/usr/local/man', etc. You can specify an installation prefix other
9317 than `/usr/local' by giving `configure' the option `--prefix=PATH', or
9318 by specifying a value for the `DESTDIR' `make' variable when running
9321 You can specify separate installation prefixes for
9322 architecture-specific files and architecture-independent files. If you
9323 give `configure' the option `--exec-prefix=PATH', `make install' will
9324 use PATH as the prefix for installing programs and libraries.
9325 Documentation and other data files will still use the regular prefix.
9328 File: bashref.info, Node: Specifying the System Type, Next: Sharing Defaults, Prev: Installation Names, Up: Installing Bash
9330 10.5 Specifying the System Type
9331 ===============================
9333 There may be some features `configure' can not figure out
9334 automatically, but need to determine by the type of host Bash will run
9335 on. Usually `configure' can figure that out, but if it prints a
9336 message saying it can not guess the host type, give it the
9337 `--host=TYPE' option. `TYPE' can either be a short name for the system
9338 type, such as `sun4', or a canonical name with three fields:
9339 `CPU-COMPANY-SYSTEM' (e.g., `i386-unknown-freebsd4.2').
9341 See the file `support/config.sub' for the possible values of each
9345 File: bashref.info, Node: Sharing Defaults, Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash
9347 10.6 Sharing Defaults
9348 =====================
9350 If you want to set default values for `configure' scripts to share, you
9351 can create a site shell script called `config.site' that gives default
9352 values for variables like `CC', `cache_file', and `prefix'. `configure'
9353 looks for `PREFIX/share/config.site' if it exists, then
9354 `PREFIX/etc/config.site' if it exists. Or, you can set the
9355 `CONFIG_SITE' environment variable to the location of the site script.
9356 A warning: the Bash `configure' looks for a site script, but not all
9357 `configure' scripts do.
9360 File: bashref.info, Node: Operation Controls, Next: Optional Features, Prev: Sharing Defaults, Up: Installing Bash
9362 10.7 Operation Controls
9363 =======================
9365 `configure' recognizes the following options to control how it operates.
9368 Use and save the results of the tests in FILE instead of
9369 `./config.cache'. Set FILE to `/dev/null' to disable caching, for
9370 debugging `configure'.
9373 Print a summary of the options to `configure', and exit.
9378 Do not print messages saying which checks are being made.
9381 Look for the Bash source code in directory DIR. Usually
9382 `configure' can determine that directory automatically.
9385 Print the version of Autoconf used to generate the `configure'
9388 `configure' also accepts some other, not widely used, boilerplate
9389 options. `configure --help' prints the complete list.
9392 File: bashref.info, Node: Optional Features, Prev: Operation Controls, Up: Installing Bash
9394 10.8 Optional Features
9395 ======================
9397 The Bash `configure' has a number of `--enable-FEATURE' options, where
9398 FEATURE indicates an optional part of Bash. There are also several
9399 `--with-PACKAGE' options, where PACKAGE is something like `bash-malloc'
9400 or `purify'. To turn off the default use of a package, use
9401 `--without-PACKAGE'. To configure Bash without a feature that is
9402 enabled by default, use `--disable-FEATURE'.
9404 Here is a complete list of the `--enable-' and `--with-' options
9405 that the Bash `configure' recognizes.
9408 Define if you are using the Andrew File System from Transarc.
9410 `--with-bash-malloc'
9411 Use the Bash version of `malloc' in the directory `lib/malloc'.
9412 This is not the same `malloc' that appears in GNU libc, but an
9413 older version originally derived from the 4.2 BSD `malloc'. This
9414 `malloc' is very fast, but wastes some space on each allocation.
9415 This option is enabled by default. The `NOTES' file contains a
9416 list of systems for which this should be turned off, and
9417 `configure' disables this option automatically for a number of
9421 Use the curses library instead of the termcap library. This should
9422 be supplied if your system has an inadequate or incomplete termcap
9426 A synonym for `--with-bash-malloc'.
9428 `--with-installed-readline[=PREFIX]'
9429 Define this to make Bash link with a locally-installed version of
9430 Readline rather than the version in `lib/readline'. This works
9431 only with Readline 5.0 and later versions. If PREFIX is `yes' or
9432 not supplied, `configure' uses the values of the make variables
9433 `includedir' and `libdir', which are subdirectories of `prefix' by
9434 default, to find the installed version of Readline if it is not in
9435 the standard system include and library directories. If PREFIX is
9436 `no', Bash links with the version in `lib/readline'. If PREFIX is
9437 set to any other value, `configure' treats it as a directory
9438 pathname and looks for the installed version of Readline in
9439 subdirectories of that directory (include files in
9440 PREFIX/`include' and the library in PREFIX/`lib').
9443 Define this to use the Purify memory allocation checker from
9446 `--enable-minimal-config'
9447 This produces a shell with minimal features, close to the
9448 historical Bourne shell.
9450 There are several `--enable-' options that alter how Bash is
9451 compiled and linked, rather than changing run-time features.
9453 `--enable-largefile'
9454 Enable support for large files
9455 (http://www.sas.com/standards/large_file/x_open.20Mar96.html) if
9456 the operating system requires special compiler options to build
9457 programs which can access large files. This is enabled by
9458 default, if the operating system provides large file support.
9460 `--enable-profiling'
9461 This builds a Bash binary that produces profiling information to be
9462 processed by `gprof' each time it is executed.
9464 `--enable-static-link'
9465 This causes Bash to be linked statically, if `gcc' is being used.
9466 This could be used to build a version to use as root's shell.
9468 The `minimal-config' option can be used to disable all of the
9469 following options, but it is processed first, so individual options may
9470 be enabled using `enable-FEATURE'.
9472 All of the following options except for `disabled-builtins',
9473 `directpand-default', and `xpg-echo-default' are enabled by default,
9474 unless the operating system does not provide the necessary support.
9477 Allow alias expansion and include the `alias' and `unalias'
9478 builtins (*note Aliases::).
9480 `--enable-arith-for-command'
9481 Include support for the alternate form of the `for' command that
9482 behaves like the C language `for' statement (*note Looping
9485 `--enable-array-variables'
9486 Include support for one-dimensional array shell variables (*note
9489 `--enable-bang-history'
9490 Include support for `csh'-like history substitution (*note History
9493 `--enable-brace-expansion'
9494 Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
9495 See *note Brace Expansion::, for a complete description.
9497 `--enable-casemod-attributes'
9498 Include support for case-modifying attributes in the `declare'
9499 builtin and assignment statements. Variables with the UPPERCASE
9500 attribute, for example, will have their values converted to
9501 uppercase upon assignment.
9503 `--enable-casemod-expansion'
9504 Include support for case-modifying word expansions.
9506 `--enable-command-timing'
9507 Include support for recognizing `time' as a reserved word and for
9508 displaying timing statistics for the pipeline following `time'
9509 (*note Pipelines::). This allows pipelines as well as shell
9510 builtins and functions to be timed.
9512 `--enable-cond-command'
9513 Include support for the `[[' conditional command. (*note
9514 Conditional Constructs::).
9516 `--enable-cond-regexp'
9517 Include support for matching POSIX regular expressions using the
9518 `=~' binary operator in the `[[' conditional command. (*note
9519 Conditional Constructs::).
9521 `--enable-coprocesses'
9522 Include support for coprocesses and the `coproc' reserved word
9523 (*note Pipelines::).
9526 Include support for the bash debugger (distributed separately).
9528 `--enable-direxpand-default'
9529 Cause the `direxpand' shell option (*note The Shopt Builtin::) to
9530 be enabled by default when the shell starts. It is normally
9531 disabled by default.
9533 `--enable-directory-stack'
9534 Include support for a `csh'-like directory stack and the `pushd',
9535 `popd', and `dirs' builtins (*note The Directory Stack::).
9537 `--enable-disabled-builtins'
9538 Allow builtin commands to be invoked via `builtin xxx' even after
9539 `xxx' has been disabled using `enable -n xxx'. See *note Bash
9540 Builtins::, for details of the `builtin' and `enable' builtin
9543 `--enable-dparen-arithmetic'
9544 Include support for the `((...))' command (*note Conditional
9547 `--enable-extended-glob'
9548 Include support for the extended pattern matching features
9549 described above under *note Pattern Matching::.
9551 `--enable-extended-glob-default'
9552 Set the default value of the EXTGLOB shell option described above
9553 under *note The Shopt Builtin:: to be enabled.
9555 `--enable-glob-asciirange-default'
9556 Set the default value of the GLOBASCIIRANGES shell option described
9557 above under *note The Shopt Builtin:: to be enabled. This
9558 controls the behavior of character ranges when used in pattern
9559 matching bracket expressions.
9561 `--enable-help-builtin'
9562 Include the `help' builtin, which displays help on shell builtins
9563 and variables (*note Bash Builtins::).
9566 Include command history and the `fc' and `history' builtin
9567 commands (*note Bash History Facilities::).
9569 `--enable-job-control'
9570 This enables the job control features (*note Job Control::), if
9571 the operating system supports them.
9573 `--enable-multibyte'
9574 This enables support for multibyte characters if the operating
9575 system provides the necessary support.
9577 `--enable-net-redirections'
9578 This enables the special handling of filenames of the form
9579 `/dev/tcp/HOST/PORT' and `/dev/udp/HOST/PORT' when used in
9580 redirections (*note Redirections::).
9582 `--enable-process-substitution'
9583 This enables process substitution (*note Process Substitution::) if
9584 the operating system provides the necessary support.
9587 Enable the programmable completion facilities (*note Programmable
9588 Completion::). If Readline is not enabled, this option has no
9591 `--enable-prompt-string-decoding'
9592 Turn on the interpretation of a number of backslash-escaped
9593 characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
9594 strings. See *note Controlling the Prompt::, for a complete list
9595 of prompt string escape sequences.
9598 Include support for command-line editing and history with the Bash
9599 version of the Readline library (*note Command Line Editing::).
9601 `--enable-restricted'
9602 Include support for a "restricted shell". If this is enabled,
9603 Bash, when called as `rbash', enters a restricted mode. See *note
9604 The Restricted Shell::, for a description of restricted mode.
9607 Include the `select' compound command, which allows the generation
9608 of simple menus (*note Conditional Constructs::).
9610 `--enable-separate-helpfiles'
9611 Use external files for the documentation displayed by the `help'
9612 builtin instead of storing the text internally.
9614 `--enable-single-help-strings'
9615 Store the text displayed by the `help' builtin as a single string
9616 for each help topic. This aids in translating the text to
9617 different languages. You may need to disable this if your
9618 compiler cannot handle very long string literals.
9620 `--enable-strict-posix-default'
9621 Make Bash POSIX-conformant by default (*note Bash POSIX Mode::).
9623 `--enable-usg-echo-default'
9624 A synonym for `--enable-xpg-echo-default'.
9626 `--enable-xpg-echo-default'
9627 Make the `echo' builtin expand backslash-escaped characters by
9628 default, without requiring the `-e' option. This sets the default
9629 value of the `xpg_echo' shell option to `on', which makes the Bash
9630 `echo' behave more like the version specified in the Single Unix
9631 Specification, version 3. *Note Bash Builtins::, for a
9632 description of the escape sequences that `echo' recognizes.
9634 The file `config-top.h' contains C Preprocessor `#define' statements
9635 for options which are not settable from `configure'. Some of these are
9636 not meant to be changed; beware of the consequences if you do. Read
9637 the comments associated with each definition for more information about
9641 File: bashref.info, Node: Reporting Bugs, Next: Major Differences From The Bourne Shell, Prev: Installing Bash, Up: Top
9643 Appendix A Reporting Bugs
9644 *************************
9646 Please report all bugs you find in Bash. But first, you should make
9647 sure that it really is a bug, and that it appears in the latest version
9648 of Bash. The latest version of Bash is always available for FTP from
9649 `ftp://ftp.gnu.org/pub/gnu/bash/'.
9651 Once you have determined that a bug actually exists, use the
9652 `bashbug' command to submit a bug report. If you have a fix, you are
9653 encouraged to mail that as well! Suggestions and `philosophical' bug
9654 reports may be mailed to <bug-bash@gnu.org> or posted to the Usenet
9655 newsgroup `gnu.bash.bug'.
9657 All bug reports should include:
9658 * The version number of Bash.
9660 * The hardware and operating system.
9662 * The compiler used to compile Bash.
9664 * A description of the bug behaviour.
9666 * A short script or `recipe' which exercises the bug and may be used
9669 `bashbug' inserts the first three items automatically into the template
9670 it provides for filing a bug report.
9672 Please send all reports concerning this manual to <bug-bash@gnu.org>.
9675 File: bashref.info, Node: Major Differences From The Bourne Shell, Next: GNU Free Documentation License, Prev: Reporting Bugs, Up: Top
9677 Appendix B Major Differences From The Bourne Shell
9678 **************************************************
9680 Bash implements essentially the same grammar, parameter and variable
9681 expansion, redirection, and quoting as the Bourne Shell. Bash uses the
9682 POSIX standard as the specification of how these features are to be
9683 implemented. There are some differences between the traditional Bourne
9684 shell and Bash; this section quickly details the differences of
9685 significance. A number of these differences are explained in greater
9686 depth in previous sections. This section uses the version of `sh'
9687 included in SVR4.2 (the last version of the historical Bourne shell) as
9688 the baseline reference.
9690 * Bash is POSIX-conformant, even where the POSIX specification
9691 differs from traditional `sh' behavior (*note Bash POSIX Mode::).
9693 * Bash has multi-character invocation options (*note Invoking
9696 * Bash has command-line editing (*note Command Line Editing::) and
9699 * Bash provides a programmable word completion mechanism (*note
9700 Programmable Completion::), and builtin commands `complete',
9701 `compgen', and `compopt', to manipulate it.
9703 * Bash has command history (*note Bash History Facilities::) and the
9704 `history' and `fc' builtins to manipulate it. The Bash history
9705 list maintains timestamp information and uses the value of the
9706 `HISTTIMEFORMAT' variable to display it.
9708 * Bash implements `csh'-like history expansion (*note History
9711 * Bash has one-dimensional array variables (*note Arrays::), and the
9712 appropriate variable expansions and assignment syntax to use them.
9713 Several of the Bash builtins take options to act on arrays. Bash
9714 provides a number of built-in array variables.
9716 * The `$'...'' quoting syntax, which expands ANSI-C
9717 backslash-escaped characters in the text between the single quotes,
9718 is supported (*note ANSI-C Quoting::).
9720 * Bash supports the `$"..."' quoting syntax to do locale-specific
9721 translation of the characters between the double quotes. The
9722 `-D', `--dump-strings', and `--dump-po-strings' invocation options
9723 list the translatable strings found in a script (*note Locale
9726 * Bash implements the `!' keyword to negate the return value of a
9727 pipeline (*note Pipelines::). Very useful when an `if' statement
9728 needs to act only if a test fails. The Bash `-o pipefail' option
9729 to `set' will cause a pipeline to return a failure status if any
9732 * Bash has the `time' reserved word and command timing (*note
9733 Pipelines::). The display of the timing statistics may be
9734 controlled with the `TIMEFORMAT' variable.
9736 * Bash implements the `for (( EXPR1 ; EXPR2 ; EXPR3 ))' arithmetic
9737 for command, similar to the C language (*note Looping
9740 * Bash includes the `select' compound command, which allows the
9741 generation of simple menus (*note Conditional Constructs::).
9743 * Bash includes the `[[' compound command, which makes conditional
9744 testing part of the shell grammar (*note Conditional
9745 Constructs::), including optional regular expression matching.
9747 * Bash provides optional case-insensitive matching for the `case' and
9750 * Bash includes brace expansion (*note Brace Expansion::) and tilde
9751 expansion (*note Tilde Expansion::).
9753 * Bash implements command aliases and the `alias' and `unalias'
9754 builtins (*note Aliases::).
9756 * Bash provides shell arithmetic, the `((' compound command (*note
9757 Conditional Constructs::), and arithmetic expansion (*note Shell
9760 * Variables present in the shell's initial environment are
9761 automatically exported to child processes. The Bourne shell does
9762 not normally do this unless the variables are explicitly marked
9763 using the `export' command.
9765 * Bash supports the `+=' assignment operator, which appends to the
9766 value of the variable named on the left hand side.
9768 * Bash includes the POSIX pattern removal `%', `#', `%%' and `##'
9769 expansions to remove leading or trailing substrings from variable
9770 values (*note Shell Parameter Expansion::).
9772 * The expansion `${#xx}', which returns the length of `${xx}', is
9773 supported (*note Shell Parameter Expansion::).
9775 * The expansion `${var:'OFFSET`[:'LENGTH`]}', which expands to the
9776 substring of `var''s value of length LENGTH, beginning at OFFSET,
9777 is present (*note Shell Parameter Expansion::).
9779 * The expansion `${var/[/]'PATTERN`[/'REPLACEMENT`]}', which matches
9780 PATTERN and replaces it with REPLACEMENT in the value of `var', is
9781 available (*note Shell Parameter Expansion::).
9783 * The expansion `${!PREFIX*}' expansion, which expands to the names
9784 of all shell variables whose names begin with PREFIX, is available
9785 (*note Shell Parameter Expansion::).
9787 * Bash has INDIRECT variable expansion using `${!word}' (*note Shell
9788 Parameter Expansion::).
9790 * Bash can expand positional parameters beyond `$9' using `${NUM}'.
9792 * The POSIX `$()' form of command substitution is implemented (*note
9793 Command Substitution::), and preferred to the Bourne shell's ```'
9794 (which is also implemented for backwards compatibility).
9796 * Bash has process substitution (*note Process Substitution::).
9798 * Bash automatically assigns variables that provide information
9799 about the current user (`UID', `EUID', and `GROUPS'), the current
9800 host (`HOSTTYPE', `OSTYPE', `MACHTYPE', and `HOSTNAME'), and the
9801 instance of Bash that is running (`BASH', `BASH_VERSION', and
9802 `BASH_VERSINFO'). *Note Bash Variables::, for details.
9804 * The `IFS' variable is used to split only the results of expansion,
9805 not all words (*note Word Splitting::). This closes a
9806 longstanding shell security hole.
9808 * The filename expansion bracket expression code uses `!' and `^' to
9809 negate the set of characters between the brackets. The Bourne
9810 shell uses only `!'.
9812 * Bash implements the full set of POSIX filename expansion operators,
9813 including CHARACTER CLASSES, EQUIVALENCE CLASSES, and COLLATING
9814 SYMBOLS (*note Filename Expansion::).
9816 * Bash implements extended pattern matching features when the
9817 `extglob' shell option is enabled (*note Pattern Matching::).
9819 * It is possible to have a variable and a function with the same
9820 name; `sh' does not separate the two name spaces.
9822 * Bash functions are permitted to have local variables using the
9823 `local' builtin, and thus useful recursive functions may be written
9824 (*note Bash Builtins::).
9826 * Variable assignments preceding commands affect only that command,
9827 even builtins and functions (*note Environment::). In `sh', all
9828 variable assignments preceding commands are global unless the
9829 command is executed from the file system.
9831 * Bash performs filename expansion on filenames specified as operands
9832 to input and output redirection operators (*note Redirections::).
9834 * Bash contains the `<>' redirection operator, allowing a file to be
9835 opened for both reading and writing, and the `&>' redirection
9836 operator, for directing standard output and standard error to the
9837 same file (*note Redirections::).
9839 * Bash includes the `<<<' redirection operator, allowing a string to
9840 be used as the standard input to a command.
9842 * Bash implements the `[n]<&WORD' and `[n]>&WORD' redirection
9843 operators, which move one file descriptor to another.
9845 * Bash treats a number of filenames specially when they are used in
9846 redirection operators (*note Redirections::).
9848 * Bash can open network connections to arbitrary machines and
9849 services with the redirection operators (*note Redirections::).
9851 * The `noclobber' option is available to avoid overwriting existing
9852 files with output redirection (*note The Set Builtin::). The `>|'
9853 redirection operator may be used to override `noclobber'.
9855 * The Bash `cd' and `pwd' builtins (*note Bourne Shell Builtins::)
9856 each take `-L' and `-P' options to switch between logical and
9859 * Bash allows a function to override a builtin with the same name,
9860 and provides access to that builtin's functionality within the
9861 function via the `builtin' and `command' builtins (*note Bash
9864 * The `command' builtin allows selective disabling of functions when
9865 command lookup is performed (*note Bash Builtins::).
9867 * Individual builtins may be enabled or disabled using the `enable'
9868 builtin (*note Bash Builtins::).
9870 * The Bash `exec' builtin takes additional options that allow users
9871 to control the contents of the environment passed to the executed
9872 command, and what the zeroth argument to the command is to be
9873 (*note Bourne Shell Builtins::).
9875 * Shell functions may be exported to children via the environment
9876 using `export -f' (*note Shell Functions::).
9878 * The Bash `export', `readonly', and `declare' builtins can take a
9879 `-f' option to act on shell functions, a `-p' option to display
9880 variables with various attributes set in a format that can be used
9881 as shell input, a `-n' option to remove various variable
9882 attributes, and `name=value' arguments to set variable attributes
9883 and values simultaneously.
9885 * The Bash `hash' builtin allows a name to be associated with an
9886 arbitrary filename, even when that filename cannot be found by
9887 searching the `$PATH', using `hash -p' (*note Bourne Shell
9890 * Bash includes a `help' builtin for quick reference to shell
9891 facilities (*note Bash Builtins::).
9893 * The `printf' builtin is available to display formatted output
9894 (*note Bash Builtins::).
9896 * The Bash `read' builtin (*note Bash Builtins::) will read a line
9897 ending in `\' with the `-r' option, and will use the `REPLY'
9898 variable as a default if no non-option arguments are supplied.
9899 The Bash `read' builtin also accepts a prompt string with the `-p'
9900 option and will use Readline to obtain the line when given the
9901 `-e' option. The `read' builtin also has additional options to
9902 control input: the `-s' option will turn off echoing of input
9903 characters as they are read, the `-t' option will allow `read' to
9904 time out if input does not arrive within a specified number of
9905 seconds, the `-n' option will allow reading only a specified
9906 number of characters rather than a full line, and the `-d' option
9907 will read until a particular character rather than newline.
9909 * The `return' builtin may be used to abort execution of scripts
9910 executed with the `.' or `source' builtins (*note Bourne Shell
9913 * Bash includes the `shopt' builtin, for finer control of shell
9914 optional capabilities (*note The Shopt Builtin::), and allows
9915 these options to be set and unset at shell invocation (*note
9918 * Bash has much more optional behavior controllable with the `set'
9919 builtin (*note The Set Builtin::).
9921 * The `-x' (`xtrace') option displays commands other than simple
9922 commands when performing an execution trace (*note The Set
9925 * The `test' builtin (*note Bourne Shell Builtins::) is slightly
9926 different, as it implements the POSIX algorithm, which specifies
9927 the behavior based on the number of arguments.
9929 * Bash includes the `caller' builtin, which displays the context of
9930 any active subroutine call (a shell function or a script executed
9931 with the `.' or `source' builtins). This supports the bash
9934 * The `trap' builtin (*note Bourne Shell Builtins::) allows a
9935 `DEBUG' pseudo-signal specification, similar to `EXIT'. Commands
9936 specified with a `DEBUG' trap are executed before every simple
9937 command, `for' command, `case' command, `select' command, every
9938 arithmetic `for' command, and before the first command executes in
9939 a shell function. The `DEBUG' trap is not inherited by shell
9940 functions unless the function has been given the `trace' attribute
9941 or the `functrace' option has been enabled using the `shopt'
9942 builtin. The `extdebug' shell option has additional effects on the
9945 The `trap' builtin (*note Bourne Shell Builtins::) allows an `ERR'
9946 pseudo-signal specification, similar to `EXIT' and `DEBUG'.
9947 Commands specified with an `ERR' trap are executed after a simple
9948 command fails, with a few exceptions. The `ERR' trap is not
9949 inherited by shell functions unless the `-o errtrace' option to
9950 the `set' builtin is enabled.
9952 The `trap' builtin (*note Bourne Shell Builtins::) allows a
9953 `RETURN' pseudo-signal specification, similar to `EXIT' and
9954 `DEBUG'. Commands specified with an `RETURN' trap are executed
9955 before execution resumes after a shell function or a shell script
9956 executed with `.' or `source' returns. The `RETURN' trap is not
9957 inherited by shell functions unless the function has been given
9958 the `trace' attribute or the `functrace' option has been enabled
9959 using the `shopt' builtin.
9961 * The Bash `type' builtin is more extensive and gives more
9962 information about the names it finds (*note Bash Builtins::).
9964 * The Bash `umask' builtin permits a `-p' option to cause the output
9965 to be displayed in the form of a `umask' command that may be
9966 reused as input (*note Bourne Shell Builtins::).
9968 * Bash implements a `csh'-like directory stack, and provides the
9969 `pushd', `popd', and `dirs' builtins to manipulate it (*note The
9970 Directory Stack::). Bash also makes the directory stack visible
9971 as the value of the `DIRSTACK' shell variable.
9973 * Bash interprets special backslash-escaped characters in the prompt
9974 strings when interactive (*note Controlling the Prompt::).
9976 * The Bash restricted mode is more useful (*note The Restricted
9977 Shell::); the SVR4.2 shell restricted mode is too limited.
9979 * The `disown' builtin can remove a job from the internal shell job
9980 table (*note Job Control Builtins::) or suppress the sending of
9981 `SIGHUP' to a job when the shell exits as the result of a `SIGHUP'.
9983 * Bash includes a number of features to support a separate debugger
9986 * The SVR4.2 shell has two privilege-related builtins (`mldmode' and
9987 `priv') not present in Bash.
9989 * Bash does not have the `stop' or `newgrp' builtins.
9991 * Bash does not use the `SHACCT' variable or perform shell
9994 * The SVR4.2 `sh' uses a `TIMEOUT' variable like Bash uses `TMOUT'.
9997 More features unique to Bash may be found in *note Bash Features::.
9999 B.1 Implementation Differences From The SVR4.2 Shell
10000 ====================================================
10002 Since Bash is a completely new implementation, it does not suffer from
10003 many of the limitations of the SVR4.2 shell. For instance:
10005 * Bash does not fork a subshell when redirecting into or out of a
10006 shell control structure such as an `if' or `while' statement.
10008 * Bash does not allow unbalanced quotes. The SVR4.2 shell will
10009 silently insert a needed closing quote at `EOF' under certain
10010 circumstances. This can be the cause of some hard-to-find errors.
10012 * The SVR4.2 shell uses a baroque memory management scheme based on
10013 trapping `SIGSEGV'. If the shell is started from a process with
10014 `SIGSEGV' blocked (e.g., by using the `system()' C library
10015 function call), it misbehaves badly.
10017 * In a questionable attempt at security, the SVR4.2 shell, when
10018 invoked without the `-p' option, will alter its real and effective
10019 UID and GID if they are less than some magic threshold value,
10020 commonly 100. This can lead to unexpected results.
10022 * The SVR4.2 shell does not allow users to trap `SIGSEGV',
10023 `SIGALRM', or `SIGCHLD'.
10025 * The SVR4.2 shell does not allow the `IFS', `MAILCHECK', `PATH',
10026 `PS1', or `PS2' variables to be unset.
10028 * The SVR4.2 shell treats `^' as the undocumented equivalent of `|'.
10030 * Bash allows multiple option arguments when it is invoked (`-x -v');
10031 the SVR4.2 shell allows only one option argument (`-xv'). In
10032 fact, some versions of the shell dump core if the second argument
10035 * The SVR4.2 shell exits a script if any builtin fails; Bash exits a
10036 script only if one of the POSIX special builtins fails, and only
10037 for certain failures, as enumerated in the POSIX standard.
10039 * The SVR4.2 shell behaves differently when invoked as `jsh' (it
10040 turns on job control).
10043 File: bashref.info, Node: GNU Free Documentation License, Next: Indexes, Prev: Major Differences From The Bourne Shell, Up: Top
10045 Appendix C GNU Free Documentation License
10046 *****************************************
10048 Version 1.3, 3 November 2008
10050 Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
10053 Everyone is permitted to copy and distribute verbatim copies
10054 of this license document, but changing it is not allowed.
10058 The purpose of this License is to make a manual, textbook, or other
10059 functional and useful document "free" in the sense of freedom: to
10060 assure everyone the effective freedom to copy and redistribute it,
10061 with or without modifying it, either commercially or
10062 noncommercially. Secondarily, this License preserves for the
10063 author and publisher a way to get credit for their work, while not
10064 being considered responsible for modifications made by others.
10066 This License is a kind of "copyleft", which means that derivative
10067 works of the document must themselves be free in the same sense.
10068 It complements the GNU General Public License, which is a copyleft
10069 license designed for free software.
10071 We have designed this License in order to use it for manuals for
10072 free software, because free software needs free documentation: a
10073 free program should come with manuals providing the same freedoms
10074 that the software does. But this License is not limited to
10075 software manuals; it can be used for any textual work, regardless
10076 of subject matter or whether it is published as a printed book.
10077 We recommend this License principally for works whose purpose is
10078 instruction or reference.
10080 1. APPLICABILITY AND DEFINITIONS
10082 This License applies to any manual or other work, in any medium,
10083 that contains a notice placed by the copyright holder saying it
10084 can be distributed under the terms of this License. Such a notice
10085 grants a world-wide, royalty-free license, unlimited in duration,
10086 to use that work under the conditions stated herein. The
10087 "Document", below, refers to any such manual or work. Any member
10088 of the public is a licensee, and is addressed as "you". You
10089 accept the license if you copy, modify or distribute the work in a
10090 way requiring permission under copyright law.
10092 A "Modified Version" of the Document means any work containing the
10093 Document or a portion of it, either copied verbatim, or with
10094 modifications and/or translated into another language.
10096 A "Secondary Section" is a named appendix or a front-matter section
10097 of the Document that deals exclusively with the relationship of the
10098 publishers or authors of the Document to the Document's overall
10099 subject (or to related matters) and contains nothing that could
10100 fall directly within that overall subject. (Thus, if the Document
10101 is in part a textbook of mathematics, a Secondary Section may not
10102 explain any mathematics.) The relationship could be a matter of
10103 historical connection with the subject or with related matters, or
10104 of legal, commercial, philosophical, ethical or political position
10107 The "Invariant Sections" are certain Secondary Sections whose
10108 titles are designated, as being those of Invariant Sections, in
10109 the notice that says that the Document is released under this
10110 License. If a section does not fit the above definition of
10111 Secondary then it is not allowed to be designated as Invariant.
10112 The Document may contain zero Invariant Sections. If the Document
10113 does not identify any Invariant Sections then there are none.
10115 The "Cover Texts" are certain short passages of text that are
10116 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
10117 that says that the Document is released under this License. A
10118 Front-Cover Text may be at most 5 words, and a Back-Cover Text may
10119 be at most 25 words.
10121 A "Transparent" copy of the Document means a machine-readable copy,
10122 represented in a format whose specification is available to the
10123 general public, that is suitable for revising the document
10124 straightforwardly with generic text editors or (for images
10125 composed of pixels) generic paint programs or (for drawings) some
10126 widely available drawing editor, and that is suitable for input to
10127 text formatters or for automatic translation to a variety of
10128 formats suitable for input to text formatters. A copy made in an
10129 otherwise Transparent file format whose markup, or absence of
10130 markup, has been arranged to thwart or discourage subsequent
10131 modification by readers is not Transparent. An image format is
10132 not Transparent if used for any substantial amount of text. A
10133 copy that is not "Transparent" is called "Opaque".
10135 Examples of suitable formats for Transparent copies include plain
10136 ASCII without markup, Texinfo input format, LaTeX input format,
10137 SGML or XML using a publicly available DTD, and
10138 standard-conforming simple HTML, PostScript or PDF designed for
10139 human modification. Examples of transparent image formats include
10140 PNG, XCF and JPG. Opaque formats include proprietary formats that
10141 can be read and edited only by proprietary word processors, SGML or
10142 XML for which the DTD and/or processing tools are not generally
10143 available, and the machine-generated HTML, PostScript or PDF
10144 produced by some word processors for output purposes only.
10146 The "Title Page" means, for a printed book, the title page itself,
10147 plus such following pages as are needed to hold, legibly, the
10148 material this License requires to appear in the title page. For
10149 works in formats which do not have any title page as such, "Title
10150 Page" means the text near the most prominent appearance of the
10151 work's title, preceding the beginning of the body of the text.
10153 The "publisher" means any person or entity that distributes copies
10154 of the Document to the public.
10156 A section "Entitled XYZ" means a named subunit of the Document
10157 whose title either is precisely XYZ or contains XYZ in parentheses
10158 following text that translates XYZ in another language. (Here XYZ
10159 stands for a specific section name mentioned below, such as
10160 "Acknowledgements", "Dedications", "Endorsements", or "History".)
10161 To "Preserve the Title" of such a section when you modify the
10162 Document means that it remains a section "Entitled XYZ" according
10163 to this definition.
10165 The Document may include Warranty Disclaimers next to the notice
10166 which states that this License applies to the Document. These
10167 Warranty Disclaimers are considered to be included by reference in
10168 this License, but only as regards disclaiming warranties: any other
10169 implication that these Warranty Disclaimers may have is void and
10170 has no effect on the meaning of this License.
10172 2. VERBATIM COPYING
10174 You may copy and distribute the Document in any medium, either
10175 commercially or noncommercially, provided that this License, the
10176 copyright notices, and the license notice saying this License
10177 applies to the Document are reproduced in all copies, and that you
10178 add no other conditions whatsoever to those of this License. You
10179 may not use technical measures to obstruct or control the reading
10180 or further copying of the copies you make or distribute. However,
10181 you may accept compensation in exchange for copies. If you
10182 distribute a large enough number of copies you must also follow
10183 the conditions in section 3.
10185 You may also lend copies, under the same conditions stated above,
10186 and you may publicly display copies.
10188 3. COPYING IN QUANTITY
10190 If you publish printed copies (or copies in media that commonly
10191 have printed covers) of the Document, numbering more than 100, and
10192 the Document's license notice requires Cover Texts, you must
10193 enclose the copies in covers that carry, clearly and legibly, all
10194 these Cover Texts: Front-Cover Texts on the front cover, and
10195 Back-Cover Texts on the back cover. Both covers must also clearly
10196 and legibly identify you as the publisher of these copies. The
10197 front cover must present the full title with all words of the
10198 title equally prominent and visible. You may add other material
10199 on the covers in addition. Copying with changes limited to the
10200 covers, as long as they preserve the title of the Document and
10201 satisfy these conditions, can be treated as verbatim copying in
10204 If the required texts for either cover are too voluminous to fit
10205 legibly, you should put the first ones listed (as many as fit
10206 reasonably) on the actual cover, and continue the rest onto
10209 If you publish or distribute Opaque copies of the Document
10210 numbering more than 100, you must either include a
10211 machine-readable Transparent copy along with each Opaque copy, or
10212 state in or with each Opaque copy a computer-network location from
10213 which the general network-using public has access to download
10214 using public-standard network protocols a complete Transparent
10215 copy of the Document, free of added material. If you use the
10216 latter option, you must take reasonably prudent steps, when you
10217 begin distribution of Opaque copies in quantity, to ensure that
10218 this Transparent copy will remain thus accessible at the stated
10219 location until at least one year after the last time you
10220 distribute an Opaque copy (directly or through your agents or
10221 retailers) of that edition to the public.
10223 It is requested, but not required, that you contact the authors of
10224 the Document well before redistributing any large number of
10225 copies, to give them a chance to provide you with an updated
10226 version of the Document.
10230 You may copy and distribute a Modified Version of the Document
10231 under the conditions of sections 2 and 3 above, provided that you
10232 release the Modified Version under precisely this License, with
10233 the Modified Version filling the role of the Document, thus
10234 licensing distribution and modification of the Modified Version to
10235 whoever possesses a copy of it. In addition, you must do these
10236 things in the Modified Version:
10238 A. Use in the Title Page (and on the covers, if any) a title
10239 distinct from that of the Document, and from those of
10240 previous versions (which should, if there were any, be listed
10241 in the History section of the Document). You may use the
10242 same title as a previous version if the original publisher of
10243 that version gives permission.
10245 B. List on the Title Page, as authors, one or more persons or
10246 entities responsible for authorship of the modifications in
10247 the Modified Version, together with at least five of the
10248 principal authors of the Document (all of its principal
10249 authors, if it has fewer than five), unless they release you
10250 from this requirement.
10252 C. State on the Title page the name of the publisher of the
10253 Modified Version, as the publisher.
10255 D. Preserve all the copyright notices of the Document.
10257 E. Add an appropriate copyright notice for your modifications
10258 adjacent to the other copyright notices.
10260 F. Include, immediately after the copyright notices, a license
10261 notice giving the public permission to use the Modified
10262 Version under the terms of this License, in the form shown in
10263 the Addendum below.
10265 G. Preserve in that license notice the full lists of Invariant
10266 Sections and required Cover Texts given in the Document's
10269 H. Include an unaltered copy of this License.
10271 I. Preserve the section Entitled "History", Preserve its Title,
10272 and add to it an item stating at least the title, year, new
10273 authors, and publisher of the Modified Version as given on
10274 the Title Page. If there is no section Entitled "History" in
10275 the Document, create one stating the title, year, authors,
10276 and publisher of the Document as given on its Title Page,
10277 then add an item describing the Modified Version as stated in
10278 the previous sentence.
10280 J. Preserve the network location, if any, given in the Document
10281 for public access to a Transparent copy of the Document, and
10282 likewise the network locations given in the Document for
10283 previous versions it was based on. These may be placed in
10284 the "History" section. You may omit a network location for a
10285 work that was published at least four years before the
10286 Document itself, or if the original publisher of the version
10287 it refers to gives permission.
10289 K. For any section Entitled "Acknowledgements" or "Dedications",
10290 Preserve the Title of the section, and preserve in the
10291 section all the substance and tone of each of the contributor
10292 acknowledgements and/or dedications given therein.
10294 L. Preserve all the Invariant Sections of the Document,
10295 unaltered in their text and in their titles. Section numbers
10296 or the equivalent are not considered part of the section
10299 M. Delete any section Entitled "Endorsements". Such a section
10300 may not be included in the Modified Version.
10302 N. Do not retitle any existing section to be Entitled
10303 "Endorsements" or to conflict in title with any Invariant
10306 O. Preserve any Warranty Disclaimers.
10308 If the Modified Version includes new front-matter sections or
10309 appendices that qualify as Secondary Sections and contain no
10310 material copied from the Document, you may at your option
10311 designate some or all of these sections as invariant. To do this,
10312 add their titles to the list of Invariant Sections in the Modified
10313 Version's license notice. These titles must be distinct from any
10314 other section titles.
10316 You may add a section Entitled "Endorsements", provided it contains
10317 nothing but endorsements of your Modified Version by various
10318 parties--for example, statements of peer review or that the text
10319 has been approved by an organization as the authoritative
10320 definition of a standard.
10322 You may add a passage of up to five words as a Front-Cover Text,
10323 and a passage of up to 25 words as a Back-Cover Text, to the end
10324 of the list of Cover Texts in the Modified Version. Only one
10325 passage of Front-Cover Text and one of Back-Cover Text may be
10326 added by (or through arrangements made by) any one entity. If the
10327 Document already includes a cover text for the same cover,
10328 previously added by you or by arrangement made by the same entity
10329 you are acting on behalf of, you may not add another; but you may
10330 replace the old one, on explicit permission from the previous
10331 publisher that added the old one.
10333 The author(s) and publisher(s) of the Document do not by this
10334 License give permission to use their names for publicity for or to
10335 assert or imply endorsement of any Modified Version.
10337 5. COMBINING DOCUMENTS
10339 You may combine the Document with other documents released under
10340 this License, under the terms defined in section 4 above for
10341 modified versions, provided that you include in the combination
10342 all of the Invariant Sections of all of the original documents,
10343 unmodified, and list them all as Invariant Sections of your
10344 combined work in its license notice, and that you preserve all
10345 their Warranty Disclaimers.
10347 The combined work need only contain one copy of this License, and
10348 multiple identical Invariant Sections may be replaced with a single
10349 copy. If there are multiple Invariant Sections with the same name
10350 but different contents, make the title of each such section unique
10351 by adding at the end of it, in parentheses, the name of the
10352 original author or publisher of that section if known, or else a
10353 unique number. Make the same adjustment to the section titles in
10354 the list of Invariant Sections in the license notice of the
10357 In the combination, you must combine any sections Entitled
10358 "History" in the various original documents, forming one section
10359 Entitled "History"; likewise combine any sections Entitled
10360 "Acknowledgements", and any sections Entitled "Dedications". You
10361 must delete all sections Entitled "Endorsements."
10363 6. COLLECTIONS OF DOCUMENTS
10365 You may make a collection consisting of the Document and other
10366 documents released under this License, and replace the individual
10367 copies of this License in the various documents with a single copy
10368 that is included in the collection, provided that you follow the
10369 rules of this License for verbatim copying of each of the
10370 documents in all other respects.
10372 You may extract a single document from such a collection, and
10373 distribute it individually under this License, provided you insert
10374 a copy of this License into the extracted document, and follow
10375 this License in all other respects regarding verbatim copying of
10378 7. AGGREGATION WITH INDEPENDENT WORKS
10380 A compilation of the Document or its derivatives with other
10381 separate and independent documents or works, in or on a volume of
10382 a storage or distribution medium, is called an "aggregate" if the
10383 copyright resulting from the compilation is not used to limit the
10384 legal rights of the compilation's users beyond what the individual
10385 works permit. When the Document is included in an aggregate, this
10386 License does not apply to the other works in the aggregate which
10387 are not themselves derivative works of the Document.
10389 If the Cover Text requirement of section 3 is applicable to these
10390 copies of the Document, then if the Document is less than one half
10391 of the entire aggregate, the Document's Cover Texts may be placed
10392 on covers that bracket the Document within the aggregate, or the
10393 electronic equivalent of covers if the Document is in electronic
10394 form. Otherwise they must appear on printed covers that bracket
10395 the whole aggregate.
10399 Translation is considered a kind of modification, so you may
10400 distribute translations of the Document under the terms of section
10401 4. Replacing Invariant Sections with translations requires special
10402 permission from their copyright holders, but you may include
10403 translations of some or all Invariant Sections in addition to the
10404 original versions of these Invariant Sections. You may include a
10405 translation of this License, and all the license notices in the
10406 Document, and any Warranty Disclaimers, provided that you also
10407 include the original English version of this License and the
10408 original versions of those notices and disclaimers. In case of a
10409 disagreement between the translation and the original version of
10410 this License or a notice or disclaimer, the original version will
10413 If a section in the Document is Entitled "Acknowledgements",
10414 "Dedications", or "History", the requirement (section 4) to
10415 Preserve its Title (section 1) will typically require changing the
10420 You may not copy, modify, sublicense, or distribute the Document
10421 except as expressly provided under this License. Any attempt
10422 otherwise to copy, modify, sublicense, or distribute it is void,
10423 and will automatically terminate your rights under this License.
10425 However, if you cease all violation of this License, then your
10426 license from a particular copyright holder is reinstated (a)
10427 provisionally, unless and until the copyright holder explicitly
10428 and finally terminates your license, and (b) permanently, if the
10429 copyright holder fails to notify you of the violation by some
10430 reasonable means prior to 60 days after the cessation.
10432 Moreover, your license from a particular copyright holder is
10433 reinstated permanently if the copyright holder notifies you of the
10434 violation by some reasonable means, this is the first time you have
10435 received notice of violation of this License (for any work) from
10436 that copyright holder, and you cure the violation prior to 30 days
10437 after your receipt of the notice.
10439 Termination of your rights under this section does not terminate
10440 the licenses of parties who have received copies or rights from
10441 you under this License. If your rights have been terminated and
10442 not permanently reinstated, receipt of a copy of some or all of
10443 the same material does not give you any rights to use it.
10445 10. FUTURE REVISIONS OF THIS LICENSE
10447 The Free Software Foundation may publish new, revised versions of
10448 the GNU Free Documentation License from time to time. Such new
10449 versions will be similar in spirit to the present version, but may
10450 differ in detail to address new problems or concerns. See
10451 `http://www.gnu.org/copyleft/'.
10453 Each version of the License is given a distinguishing version
10454 number. If the Document specifies that a particular numbered
10455 version of this License "or any later version" applies to it, you
10456 have the option of following the terms and conditions either of
10457 that specified version or of any later version that has been
10458 published (not as a draft) by the Free Software Foundation. If
10459 the Document does not specify a version number of this License,
10460 you may choose any version ever published (not as a draft) by the
10461 Free Software Foundation. If the Document specifies that a proxy
10462 can decide which future versions of this License can be used, that
10463 proxy's public statement of acceptance of a version permanently
10464 authorizes you to choose that version for the Document.
10468 "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
10469 World Wide Web server that publishes copyrightable works and also
10470 provides prominent facilities for anybody to edit those works. A
10471 public wiki that anybody can edit is an example of such a server.
10472 A "Massive Multiauthor Collaboration" (or "MMC") contained in the
10473 site means any set of copyrightable works thus published on the MMC
10476 "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
10477 license published by Creative Commons Corporation, a not-for-profit
10478 corporation with a principal place of business in San Francisco,
10479 California, as well as future copyleft versions of that license
10480 published by that same organization.
10482 "Incorporate" means to publish or republish a Document, in whole or
10483 in part, as part of another Document.
10485 An MMC is "eligible for relicensing" if it is licensed under this
10486 License, and if all works that were first published under this
10487 License somewhere other than this MMC, and subsequently
10488 incorporated in whole or in part into the MMC, (1) had no cover
10489 texts or invariant sections, and (2) were thus incorporated prior
10490 to November 1, 2008.
10492 The operator of an MMC Site may republish an MMC contained in the
10493 site under CC-BY-SA on the same site at any time before August 1,
10494 2009, provided the MMC is eligible for relicensing.
10497 ADDENDUM: How to use this License for your documents
10498 ====================================================
10500 To use this License in a document you have written, include a copy of
10501 the License in the document and put the following copyright and license
10502 notices just after the title page:
10504 Copyright (C) YEAR YOUR NAME.
10505 Permission is granted to copy, distribute and/or modify this document
10506 under the terms of the GNU Free Documentation License, Version 1.3
10507 or any later version published by the Free Software Foundation;
10508 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
10509 Texts. A copy of the license is included in the section entitled ``GNU
10510 Free Documentation License''.
10512 If you have Invariant Sections, Front-Cover Texts and Back-Cover
10513 Texts, replace the "with...Texts." line with this:
10515 with the Invariant Sections being LIST THEIR TITLES, with
10516 the Front-Cover Texts being LIST, and with the Back-Cover Texts
10519 If you have Invariant Sections without Cover Texts, or some other
10520 combination of the three, merge those two alternatives to suit the
10523 If your document contains nontrivial examples of program code, we
10524 recommend releasing these examples in parallel under your choice of
10525 free software license, such as the GNU General Public License, to
10526 permit their use in free software.
10529 File: bashref.info, Node: Indexes, Prev: GNU Free Documentation License, Up: Top
10536 * Builtin Index:: Index of Bash builtin commands.
10537 * Reserved Word Index:: Index of Bash reserved words.
10538 * Variable Index:: Quick reference helps you find the
10540 * Function Index:: Index of bindable Readline functions.
10541 * Concept Index:: General index for concepts described in
10545 File: bashref.info, Node: Builtin Index, Next: Reserved Word Index, Up: Indexes
10547 D.1 Index of Shell Builtin Commands
10548 ===================================
10553 * .: Bourne Shell Builtins.
10555 * :: Bourne Shell Builtins.
10557 * [: Bourne Shell Builtins.
10559 * alias: Bash Builtins. (line 11)
10560 * bg: Job Control Builtins.
10562 * bind: Bash Builtins. (line 21)
10563 * break: Bourne Shell Builtins.
10565 * builtin: Bash Builtins. (line 102)
10566 * caller: Bash Builtins. (line 111)
10567 * cd: Bourne Shell Builtins.
10569 * command: Bash Builtins. (line 129)
10570 * compgen: Programmable Completion Builtins.
10572 * complete: Programmable Completion Builtins.
10574 * compopt: Programmable Completion Builtins.
10576 * continue: Bourne Shell Builtins.
10578 * declare: Bash Builtins. (line 149)
10579 * dirs: Directory Stack Builtins.
10581 * disown: Job Control Builtins.
10583 * echo: Bash Builtins. (line 245)
10584 * enable: Bash Builtins. (line 307)
10585 * eval: Bourne Shell Builtins.
10587 * exec: Bourne Shell Builtins.
10589 * exit: Bourne Shell Builtins.
10591 * export: Bourne Shell Builtins.
10593 * fc: Bash History Builtins.
10595 * fg: Job Control Builtins.
10597 * getopts: Bourne Shell Builtins.
10599 * hash: Bourne Shell Builtins.
10601 * help: Bash Builtins. (line 336)
10602 * history: Bash History Builtins.
10604 * jobs: Job Control Builtins.
10606 * kill: Job Control Builtins.
10608 * let: Bash Builtins. (line 357)
10609 * local: Bash Builtins. (line 365)
10610 * logout: Bash Builtins. (line 376)
10611 * mapfile: Bash Builtins. (line 381)
10612 * popd: Directory Stack Builtins.
10614 * printf: Bash Builtins. (line 429)
10615 * pushd: Directory Stack Builtins.
10617 * pwd: Bourne Shell Builtins.
10619 * read: Bash Builtins. (line 477)
10620 * readarray: Bash Builtins. (line 564)
10621 * readonly: Bourne Shell Builtins.
10623 * return: Bourne Shell Builtins.
10625 * set: The Set Builtin. (line 11)
10626 * shift: Bourne Shell Builtins.
10628 * shopt: The Shopt Builtin. (line 9)
10629 * source: Bash Builtins. (line 573)
10630 * suspend: Job Control Builtins.
10632 * test: Bourne Shell Builtins.
10634 * times: Bourne Shell Builtins.
10636 * trap: Bourne Shell Builtins.
10638 * type: Bash Builtins. (line 578)
10639 * typeset: Bash Builtins. (line 610)
10640 * ulimit: Bash Builtins. (line 616)
10641 * umask: Bourne Shell Builtins.
10643 * unalias: Bash Builtins. (line 707)
10644 * unset: Bourne Shell Builtins.
10646 * wait: Job Control Builtins.
10650 File: bashref.info, Node: Reserved Word Index, Next: Variable Index, Prev: Builtin Index, Up: Indexes
10652 D.2 Index of Shell Reserved Words
10653 =================================
10658 * !: Pipelines. (line 9)
10659 * [[: Conditional Constructs.
10661 * ]]: Conditional Constructs.
10663 * case: Conditional Constructs.
10665 * do: Looping Constructs. (line 12)
10666 * done: Looping Constructs. (line 12)
10667 * elif: Conditional Constructs.
10669 * else: Conditional Constructs.
10671 * esac: Conditional Constructs.
10673 * fi: Conditional Constructs.
10675 * for: Looping Constructs. (line 32)
10676 * function: Shell Functions. (line 13)
10677 * if: Conditional Constructs.
10679 * in: Conditional Constructs.
10681 * select: Conditional Constructs.
10683 * then: Conditional Constructs.
10685 * time: Pipelines. (line 9)
10686 * until: Looping Constructs. (line 12)
10687 * while: Looping Constructs. (line 22)
10688 * {: Command Grouping. (line 21)
10689 * }: Command Grouping. (line 21)
10692 File: bashref.info, Node: Variable Index, Next: Function Index, Prev: Reserved Word Index, Up: Indexes
10694 D.3 Parameter and Variable Index
10695 ================================
10700 * !: Special Parameters. (line 50)
10701 * #: Special Parameters. (line 33)
10702 * $: Special Parameters. (line 45)
10703 * $!: Special Parameters. (line 51)
10704 * $#: Special Parameters. (line 34)
10705 * $$: Special Parameters. (line 46)
10706 * $*: Special Parameters. (line 10)
10707 * $-: Special Parameters. (line 41)
10708 * $0: Special Parameters. (line 56)
10709 * $?: Special Parameters. (line 37)
10710 * $@: Special Parameters. (line 23)
10711 * $_: Special Parameters. (line 65)
10712 * *: Special Parameters. (line 9)
10713 * -: Special Parameters. (line 40)
10714 * 0: Special Parameters. (line 55)
10715 * ?: Special Parameters. (line 36)
10716 * @: Special Parameters. (line 22)
10717 * _: Special Parameters. (line 64)
10718 * auto_resume: Job Control Variables.
10720 * BASH: Bash Variables. (line 13)
10721 * BASH_ALIASES: Bash Variables. (line 30)
10722 * BASH_ARGC: Bash Variables. (line 37)
10723 * BASH_ARGV: Bash Variables. (line 47)
10724 * BASH_CMDS: Bash Variables. (line 57)
10725 * BASH_COMMAND: Bash Variables. (line 64)
10726 * BASH_COMPAT: Bash Variables. (line 69)
10727 * BASH_ENV: Bash Variables. (line 84)
10728 * BASH_EXECUTION_STRING: Bash Variables. (line 90)
10729 * BASH_LINENO: Bash Variables. (line 93)
10730 * BASH_REMATCH: Bash Variables. (line 101)
10731 * BASH_SOURCE: Bash Variables. (line 109)
10732 * BASH_SUBSHELL: Bash Variables. (line 116)
10733 * BASH_VERSINFO: Bash Variables. (line 121)
10734 * BASH_VERSION: Bash Variables. (line 144)
10735 * BASH_XTRACEFD: Bash Variables. (line 147)
10736 * BASHOPTS: Bash Variables. (line 16)
10737 * BASHPID: Bash Variables. (line 25)
10738 * bell-style: Readline Init File Syntax.
10740 * bind-tty-special-chars: Readline Init File Syntax.
10742 * CDPATH: Bourne Shell Variables.
10744 * CHILD_MAX: Bash Variables. (line 158)
10745 * colored-stats: Readline Init File Syntax.
10747 * COLUMNS: Bash Variables. (line 165)
10748 * comment-begin: Readline Init File Syntax.
10750 * COMP_CWORD: Bash Variables. (line 171)
10751 * COMP_KEY: Bash Variables. (line 200)
10752 * COMP_LINE: Bash Variables. (line 177)
10753 * COMP_POINT: Bash Variables. (line 182)
10754 * COMP_TYPE: Bash Variables. (line 190)
10755 * COMP_WORDBREAKS: Bash Variables. (line 204)
10756 * COMP_WORDS: Bash Variables. (line 210)
10757 * completion-display-width: Readline Init File Syntax.
10759 * completion-ignore-case: Readline Init File Syntax.
10761 * completion-map-case: Readline Init File Syntax.
10763 * completion-prefix-display-length: Readline Init File Syntax.
10765 * completion-query-items: Readline Init File Syntax.
10767 * COMPREPLY: Bash Variables. (line 218)
10768 * convert-meta: Readline Init File Syntax.
10770 * COPROC: Bash Variables. (line 224)
10771 * DIRSTACK: Bash Variables. (line 228)
10772 * disable-completion: Readline Init File Syntax.
10774 * editing-mode: Readline Init File Syntax.
10776 * EMACS: Bash Variables. (line 238)
10777 * enable-keypad: Readline Init File Syntax.
10779 * ENV: Bash Variables. (line 243)
10780 * EUID: Bash Variables. (line 247)
10781 * expand-tilde: Readline Init File Syntax.
10783 * FCEDIT: Bash Variables. (line 251)
10784 * FIGNORE: Bash Variables. (line 255)
10785 * FUNCNAME: Bash Variables. (line 261)
10786 * FUNCNEST: Bash Variables. (line 279)
10787 * GLOBIGNORE: Bash Variables. (line 284)
10788 * GROUPS: Bash Variables. (line 290)
10789 * histchars: Bash Variables. (line 296)
10790 * HISTCMD: Bash Variables. (line 311)
10791 * HISTCONTROL: Bash Variables. (line 316)
10792 * HISTFILE: Bash Variables. (line 332)
10793 * HISTFILESIZE: Bash Variables. (line 336)
10794 * HISTIGNORE: Bash Variables. (line 347)
10795 * history-preserve-point: Readline Init File Syntax.
10797 * history-size: Readline Init File Syntax.
10799 * HISTSIZE: Bash Variables. (line 366)
10800 * HISTTIMEFORMAT: Bash Variables. (line 373)
10801 * HOME: Bourne Shell Variables.
10803 * horizontal-scroll-mode: Readline Init File Syntax.
10805 * HOSTFILE: Bash Variables. (line 382)
10806 * HOSTNAME: Bash Variables. (line 393)
10807 * HOSTTYPE: Bash Variables. (line 396)
10808 * IFS: Bourne Shell Variables.
10810 * IGNOREEOF: Bash Variables. (line 399)
10811 * input-meta: Readline Init File Syntax.
10813 * INPUTRC: Bash Variables. (line 409)
10814 * isearch-terminators: Readline Init File Syntax.
10816 * keymap: Readline Init File Syntax.
10818 * LANG: Bash Variables. (line 413)
10819 * LC_ALL: Bash Variables. (line 417)
10820 * LC_COLLATE: Bash Variables. (line 421)
10821 * LC_CTYPE: Bash Variables. (line 428)
10822 * LC_MESSAGES <1>: Locale Translation. (line 11)
10823 * LC_MESSAGES: Bash Variables. (line 433)
10824 * LC_NUMERIC: Bash Variables. (line 437)
10825 * LINENO: Bash Variables. (line 441)
10826 * LINES: Bash Variables. (line 445)
10827 * MACHTYPE: Bash Variables. (line 451)
10828 * MAIL: Bourne Shell Variables.
10830 * MAILCHECK: Bash Variables. (line 455)
10831 * MAILPATH: Bourne Shell Variables.
10833 * MAPFILE: Bash Variables. (line 463)
10834 * mark-modified-lines: Readline Init File Syntax.
10836 * mark-symlinked-directories: Readline Init File Syntax.
10838 * match-hidden-files: Readline Init File Syntax.
10840 * menu-complete-display-prefix: Readline Init File Syntax.
10842 * meta-flag: Readline Init File Syntax.
10844 * OLDPWD: Bash Variables. (line 467)
10845 * OPTARG: Bourne Shell Variables.
10847 * OPTERR: Bash Variables. (line 470)
10848 * OPTIND: Bourne Shell Variables.
10850 * OSTYPE: Bash Variables. (line 474)
10851 * output-meta: Readline Init File Syntax.
10853 * page-completions: Readline Init File Syntax.
10855 * PATH: Bourne Shell Variables.
10857 * PIPESTATUS: Bash Variables. (line 477)
10858 * POSIXLY_CORRECT: Bash Variables. (line 482)
10859 * PPID: Bash Variables. (line 491)
10860 * PROMPT_COMMAND: Bash Variables. (line 495)
10861 * PROMPT_DIRTRIM: Bash Variables. (line 499)
10862 * PS1: Bourne Shell Variables.
10864 * PS2: Bourne Shell Variables.
10866 * PS3: Bash Variables. (line 505)
10867 * PS4: Bash Variables. (line 510)
10868 * PWD: Bash Variables. (line 516)
10869 * RANDOM: Bash Variables. (line 519)
10870 * READLINE_LINE: Bash Variables. (line 524)
10871 * READLINE_POINT: Bash Variables. (line 528)
10872 * REPLY: Bash Variables. (line 532)
10873 * revert-all-at-newline: Readline Init File Syntax.
10875 * SECONDS: Bash Variables. (line 535)
10876 * SHELL: Bash Variables. (line 541)
10877 * SHELLOPTS: Bash Variables. (line 546)
10878 * SHLVL: Bash Variables. (line 555)
10879 * show-all-if-ambiguous: Readline Init File Syntax.
10881 * show-all-if-unmodified: Readline Init File Syntax.
10883 * show-mode-in-prompt: Readline Init File Syntax.
10885 * skip-completed-text: Readline Init File Syntax.
10887 * TEXTDOMAIN: Locale Translation. (line 11)
10888 * TEXTDOMAINDIR: Locale Translation. (line 11)
10889 * TIMEFORMAT: Bash Variables. (line 560)
10890 * TMOUT: Bash Variables. (line 598)
10891 * TMPDIR: Bash Variables. (line 610)
10892 * UID: Bash Variables. (line 614)
10893 * visible-stats: Readline Init File Syntax.
10897 File: bashref.info, Node: Function Index, Next: Concept Index, Prev: Variable Index, Up: Indexes
10905 * abort (C-g): Miscellaneous Commands.
10907 * accept-line (Newline or Return): Commands For History. (line 6)
10908 * backward-char (C-b): Commands For Moving. (line 15)
10909 * backward-delete-char (Rubout): Commands For Text. (line 17)
10910 * backward-kill-line (C-x Rubout): Commands For Killing. (line 9)
10911 * backward-kill-word (M-<DEL>): Commands For Killing. (line 24)
10912 * backward-word (M-b): Commands For Moving. (line 22)
10913 * beginning-of-history (M-<): Commands For History. (line 20)
10914 * beginning-of-line (C-a): Commands For Moving. (line 6)
10915 * call-last-kbd-macro (C-x e): Keyboard Macros. (line 13)
10916 * capitalize-word (M-c): Commands For Text. (line 52)
10917 * character-search (C-]): Miscellaneous Commands.
10919 * character-search-backward (M-C-]): Miscellaneous Commands.
10921 * clear-screen (C-l): Commands For Moving. (line 34)
10922 * complete (<TAB>): Commands For Completion.
10924 * copy-backward-word (): Commands For Killing. (line 58)
10925 * copy-forward-word (): Commands For Killing. (line 63)
10926 * copy-region-as-kill (): Commands For Killing. (line 54)
10927 * delete-char (C-d): Commands For Text. (line 12)
10928 * delete-char-or-list (): Commands For Completion.
10930 * delete-horizontal-space (): Commands For Killing. (line 46)
10931 * digit-argument (M-0, M-1, ... M--): Numeric Arguments. (line 6)
10932 * do-uppercase-version (M-a, M-b, M-X, ...): Miscellaneous Commands.
10934 * downcase-word (M-l): Commands For Text. (line 48)
10935 * dump-functions (): Miscellaneous Commands.
10937 * dump-macros (): Miscellaneous Commands.
10939 * dump-variables (): Miscellaneous Commands.
10941 * end-kbd-macro (C-x )): Keyboard Macros. (line 9)
10942 * end-of-file (usually C-d): Commands For Text. (line 6)
10943 * end-of-history (M->): Commands For History. (line 23)
10944 * end-of-line (C-e): Commands For Moving. (line 9)
10945 * exchange-point-and-mark (C-x C-x): Miscellaneous Commands.
10947 * forward-backward-delete-char (): Commands For Text. (line 21)
10948 * forward-char (C-f): Commands For Moving. (line 12)
10949 * forward-search-history (C-s): Commands For History. (line 31)
10950 * forward-word (M-f): Commands For Moving. (line 18)
10951 * history-search-backward (): Commands For History. (line 52)
10952 * history-search-forward (): Commands For History. (line 46)
10953 * history-substr-search-backward (): Commands For History. (line 64)
10954 * history-substr-search-forward (): Commands For History. (line 58)
10955 * insert-comment (M-#): Miscellaneous Commands.
10957 * insert-completions (M-*): Commands For Completion.
10959 * kill-line (C-k): Commands For Killing. (line 6)
10960 * kill-region (): Commands For Killing. (line 50)
10961 * kill-whole-line (): Commands For Killing. (line 15)
10962 * kill-word (M-d): Commands For Killing. (line 19)
10963 * menu-complete (): Commands For Completion.
10965 * menu-complete-backward (): Commands For Completion.
10967 * next-history (C-n): Commands For History. (line 17)
10968 * non-incremental-forward-search-history (M-n): Commands For History.
10970 * non-incremental-reverse-search-history (M-p): Commands For History.
10972 * overwrite-mode (): Commands For Text. (line 56)
10973 * possible-completions (M-?): Commands For Completion.
10975 * prefix-meta (<ESC>): Miscellaneous Commands.
10977 * previous-history (C-p): Commands For History. (line 13)
10978 * print-last-kbd-macro (): Keyboard Macros. (line 17)
10979 * quoted-insert (C-q or C-v): Commands For Text. (line 26)
10980 * re-read-init-file (C-x C-r): Miscellaneous Commands.
10982 * redraw-current-line (): Commands For Moving. (line 38)
10983 * reverse-search-history (C-r): Commands For History. (line 27)
10984 * revert-line (M-r): Miscellaneous Commands.
10986 * self-insert (a, b, A, 1, !, ...): Commands For Text. (line 30)
10987 * set-mark (C-@): Miscellaneous Commands.
10989 * skip-csi-sequence (): Miscellaneous Commands.
10991 * start-kbd-macro (C-x (): Keyboard Macros. (line 6)
10992 * transpose-chars (C-t): Commands For Text. (line 33)
10993 * transpose-words (M-t): Commands For Text. (line 39)
10994 * undo (C-_ or C-x C-u): Miscellaneous Commands.
10996 * universal-argument (): Numeric Arguments. (line 10)
10997 * unix-filename-rubout (): Commands For Killing. (line 41)
10998 * unix-line-discard (C-u): Commands For Killing. (line 12)
10999 * unix-word-rubout (C-w): Commands For Killing. (line 37)
11000 * upcase-word (M-u): Commands For Text. (line 44)
11001 * yank (C-y): Commands For Killing. (line 68)
11002 * yank-last-arg (M-. or M-_): Commands For History. (line 79)
11003 * yank-nth-arg (M-C-y): Commands For History. (line 70)
11004 * yank-pop (M-y): Commands For Killing. (line 71)
11007 File: bashref.info, Node: Concept Index, Prev: Function Index, Up: Indexes
11015 * alias expansion: Aliases. (line 6)
11016 * arithmetic evaluation: Shell Arithmetic. (line 6)
11017 * arithmetic expansion: Arithmetic Expansion.
11019 * arithmetic, shell: Shell Arithmetic. (line 6)
11020 * arrays: Arrays. (line 6)
11021 * background: Job Control Basics. (line 6)
11022 * Bash configuration: Basic Installation. (line 6)
11023 * Bash installation: Basic Installation. (line 6)
11024 * Bourne shell: Basic Shell Features.
11026 * brace expansion: Brace Expansion. (line 6)
11027 * builtin: Definitions. (line 17)
11028 * command editing: Readline Bare Essentials.
11030 * command execution: Command Search and Execution.
11032 * command expansion: Simple Command Expansion.
11034 * command history: Bash History Facilities.
11036 * command search: Command Search and Execution.
11038 * command substitution: Command Substitution.
11040 * command timing: Pipelines. (line 9)
11041 * commands, compound: Compound Commands. (line 6)
11042 * commands, conditional: Conditional Constructs.
11044 * commands, grouping: Command Grouping. (line 6)
11045 * commands, lists: Lists. (line 6)
11046 * commands, looping: Looping Constructs. (line 6)
11047 * commands, pipelines: Pipelines. (line 6)
11048 * commands, shell: Shell Commands. (line 6)
11049 * commands, simple: Simple Commands. (line 6)
11050 * comments, shell: Comments. (line 6)
11051 * completion builtins: Programmable Completion Builtins.
11053 * configuration: Basic Installation. (line 6)
11054 * control operator: Definitions. (line 21)
11055 * coprocess: Coprocesses. (line 6)
11056 * directory stack: The Directory Stack. (line 6)
11057 * editing command lines: Readline Bare Essentials.
11059 * environment: Environment. (line 6)
11060 * evaluation, arithmetic: Shell Arithmetic. (line 6)
11061 * event designators: Event Designators. (line 6)
11062 * execution environment: Command Execution Environment.
11064 * exit status <1>: Exit Status. (line 6)
11065 * exit status: Definitions. (line 26)
11066 * expansion: Shell Expansions. (line 6)
11067 * expansion, arithmetic: Arithmetic Expansion.
11069 * expansion, brace: Brace Expansion. (line 6)
11070 * expansion, filename: Filename Expansion. (line 9)
11071 * expansion, parameter: Shell Parameter Expansion.
11073 * expansion, pathname: Filename Expansion. (line 9)
11074 * expansion, tilde: Tilde Expansion. (line 6)
11075 * expressions, arithmetic: Shell Arithmetic. (line 6)
11076 * expressions, conditional: Bash Conditional Expressions.
11078 * field: Definitions. (line 30)
11079 * filename: Definitions. (line 35)
11080 * filename expansion: Filename Expansion. (line 9)
11081 * foreground: Job Control Basics. (line 6)
11082 * functions, shell: Shell Functions. (line 6)
11083 * history builtins: Bash History Builtins.
11085 * history events: Event Designators. (line 8)
11086 * history expansion: History Interaction. (line 6)
11087 * history list: Bash History Facilities.
11089 * History, how to use: A Programmable Completion Example.
11091 * identifier: Definitions. (line 51)
11092 * initialization file, readline: Readline Init File. (line 6)
11093 * installation: Basic Installation. (line 6)
11094 * interaction, readline: Readline Interaction.
11096 * interactive shell <1>: Interactive Shells. (line 6)
11097 * interactive shell: Invoking Bash. (line 125)
11098 * internationalization: Locale Translation. (line 6)
11099 * job: Definitions. (line 38)
11100 * job control <1>: Job Control Basics. (line 6)
11101 * job control: Definitions. (line 42)
11102 * kill ring: Readline Killing Commands.
11104 * killing text: Readline Killing Commands.
11106 * localization: Locale Translation. (line 6)
11107 * login shell: Invoking Bash. (line 122)
11108 * matching, pattern: Pattern Matching. (line 6)
11109 * metacharacter: Definitions. (line 46)
11110 * name: Definitions. (line 51)
11111 * native languages: Locale Translation. (line 6)
11112 * notation, readline: Readline Bare Essentials.
11114 * operator, shell: Definitions. (line 57)
11115 * parameter expansion: Shell Parameter Expansion.
11117 * parameters: Shell Parameters. (line 6)
11118 * parameters, positional: Positional Parameters.
11120 * parameters, special: Special Parameters. (line 6)
11121 * pathname expansion: Filename Expansion. (line 9)
11122 * pattern matching: Pattern Matching. (line 6)
11123 * pipeline: Pipelines. (line 6)
11124 * POSIX: Definitions. (line 9)
11125 * POSIX Mode: Bash POSIX Mode. (line 6)
11126 * process group: Definitions. (line 62)
11127 * process group ID: Definitions. (line 66)
11128 * process substitution: Process Substitution.
11130 * programmable completion: Programmable Completion.
11132 * prompting: Controlling the Prompt.
11134 * quoting: Quoting. (line 6)
11135 * quoting, ANSI: ANSI-C Quoting. (line 6)
11136 * Readline, how to use: Job Control Variables.
11138 * redirection: Redirections. (line 6)
11139 * reserved word: Definitions. (line 70)
11140 * restricted shell: The Restricted Shell.
11142 * return status: Definitions. (line 75)
11143 * shell arithmetic: Shell Arithmetic. (line 6)
11144 * shell function: Shell Functions. (line 6)
11145 * shell script: Shell Scripts. (line 6)
11146 * shell variable: Shell Parameters. (line 6)
11147 * shell, interactive: Interactive Shells. (line 6)
11148 * signal: Definitions. (line 78)
11149 * signal handling: Signals. (line 6)
11150 * special builtin <1>: Special Builtins. (line 6)
11151 * special builtin: Definitions. (line 82)
11152 * startup files: Bash Startup Files. (line 6)
11153 * suspending jobs: Job Control Basics. (line 6)
11154 * tilde expansion: Tilde Expansion. (line 6)
11155 * token: Definitions. (line 86)
11156 * translation, native languages: Locale Translation. (line 6)
11157 * variable, shell: Shell Parameters. (line 6)
11158 * variables, readline: Readline Init File Syntax.
11160 * word: Definitions. (line 90)
11161 * word splitting: Word Splitting. (line 6)
11162 * yanking text: Readline Killing Commands.
11169 Node: Introduction
\7f2848
11170 Node: What is Bash?
\7f3076
11171 Node: What is a shell?
\7f4189
11172 Node: Definitions
\7f6728
11173 Node: Basic Shell Features
\7f9646
11174 Node: Shell Syntax
\7f10865
11175 Node: Shell Operation
\7f11895
11176 Node: Quoting
\7f13189
11177 Node: Escape Character
\7f14492
11178 Node: Single Quotes
\7f14977
11179 Node: Double Quotes
\7f15325
11180 Node: ANSI-C Quoting
\7f16450
11181 Node: Locale Translation
\7f17694
11182 Node: Comments
\7f18590
11183 Node: Shell Commands
\7f19208
11184 Node: Simple Commands
\7f20080
11185 Node: Pipelines
\7f20711
11186 Node: Lists
\7f23449
11187 Node: Compound Commands
\7f25178
11188 Node: Looping Constructs
\7f26184
11189 Node: Conditional Constructs
\7f28647
11190 Node: Command Grouping
\7f39577
11191 Node: Coprocesses
\7f41056
11192 Node: GNU Parallel
\7f42889
11193 Node: Shell Functions
\7f46875
11194 Node: Shell Parameters
\7f51959
11195 Node: Positional Parameters
\7f56088
11196 Node: Special Parameters
\7f56988
11197 Node: Shell Expansions
\7f60327
11198 Node: Brace Expansion
\7f62270
11199 Node: Tilde Expansion
\7f65051
11200 Node: Shell Parameter Expansion
\7f67400
11201 Node: Command Substitution
\7f79694
11202 Node: Arithmetic Expansion
\7f81027
11203 Node: Process Substitution
\7f81959
11204 Node: Word Splitting
\7f83009
11205 Node: Filename Expansion
\7f84657
11206 Node: Pattern Matching
\7f86822
11207 Node: Quote Removal
\7f90522
11208 Node: Redirections
\7f90817
11209 Node: Executing Commands
\7f99981
11210 Node: Simple Command Expansion
\7f100651
11211 Node: Command Search and Execution
\7f102581
11212 Node: Command Execution Environment
\7f104918
11213 Node: Environment
\7f107904
11214 Node: Exit Status
\7f109563
11215 Node: Signals
\7f111185
11216 Node: Shell Scripts
\7f113153
11217 Node: Shell Builtin Commands
\7f115671
11218 Node: Bourne Shell Builtins
\7f117699
11219 Node: Bash Builtins
\7f137606
11220 Node: Modifying Shell Behavior
\7f165232
11221 Node: The Set Builtin
\7f165577
11222 Node: The Shopt Builtin
\7f175903
11223 Node: Special Builtins
\7f190324
11224 Node: Shell Variables
\7f191303
11225 Node: Bourne Shell Variables
\7f191743
11226 Node: Bash Variables
\7f193774
11227 Node: Bash Features
\7f220649
11228 Node: Invoking Bash
\7f221548
11229 Node: Bash Startup Files
\7f227326
11230 Node: Interactive Shells
\7f232355
11231 Node: What is an Interactive Shell?
\7f232765
11232 Node: Is this Shell Interactive?
\7f233414
11233 Node: Interactive Shell Behavior
\7f234229
11234 Node: Bash Conditional Expressions
\7f237517
11235 Node: Shell Arithmetic
\7f241519
11236 Node: Aliases
\7f244295
11237 Node: Arrays
\7f246851
11238 Node: The Directory Stack
\7f251832
11239 Node: Directory Stack Builtins
\7f252551
11240 Node: Controlling the Prompt
\7f255507
11241 Node: The Restricted Shell
\7f258279
11242 Node: Bash POSIX Mode
\7f260116
11243 Node: Job Control
\7f269502
11244 Node: Job Control Basics
\7f269962
11245 Node: Job Control Builtins
\7f274681
11246 Node: Job Control Variables
\7f279152
11247 Node: Command Line Editing
\7f280310
11248 Node: Introduction and Notation
\7f281982
11249 Node: Readline Interaction
\7f283604
11250 Node: Readline Bare Essentials
\7f284795
11251 Node: Readline Movement Commands
\7f286584
11252 Node: Readline Killing Commands
\7f287549
11253 Node: Readline Arguments
\7f289469
11254 Node: Searching
\7f290513
11255 Node: Readline Init File
\7f292699
11256 Node: Readline Init File Syntax
\7f293846
11257 Node: Conditional Init Constructs
\7f310832
11258 Node: Sample Init File
\7f313365
11259 Node: Bindable Readline Commands
\7f316483
11260 Node: Commands For Moving
\7f317690
11261 Node: Commands For History
\7f318834
11262 Node: Commands For Text
\7f323019
11263 Node: Commands For Killing
\7f325948
11264 Node: Numeric Arguments
\7f328405
11265 Node: Commands For Completion
\7f329544
11266 Node: Keyboard Macros
\7f333736
11267 Node: Miscellaneous Commands
\7f334424
11268 Node: Readline vi Mode
\7f340230
11269 Node: Programmable Completion
\7f341137
11270 Node: Programmable Completion Builtins
\7f348413
11271 Node: A Programmable Completion Example
\7f358159
11272 Node: Using History Interactively
\7f363409
11273 Node: Bash History Facilities
\7f364093
11274 Node: Bash History Builtins
\7f367092
11275 Node: History Interaction
\7f371020
11276 Node: Event Designators
\7f373725
11277 Node: Word Designators
\7f374947
11278 Node: Modifiers
\7f376586
11279 Node: Installing Bash
\7f377990
11280 Node: Basic Installation
\7f379127
11281 Node: Compilers and Options
\7f381819
11282 Node: Compiling For Multiple Architectures
\7f382560
11283 Node: Installation Names
\7f384224
11284 Node: Specifying the System Type
\7f385042
11285 Node: Sharing Defaults
\7f385758
11286 Node: Operation Controls
\7f386431
11287 Node: Optional Features
\7f387389
11288 Node: Reporting Bugs
\7f397453
11289 Node: Major Differences From The Bourne Shell
\7f398651
11290 Node: GNU Free Documentation License
\7f415510
11291 Node: Indexes
\7f440706
11292 Node: Builtin Index
\7f441160
11293 Node: Reserved Word Index
\7f447987
11294 Node: Variable Index
\7f450435
11295 Node: Function Index
\7f464615
11296 Node: Concept Index
\7f471916