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