1<HTML><HEAD> 2<TITLE>BASH(1) Manual Page</TITLE> 3</HEAD> 4<BODY><TABLE WIDTH=100%> 5<TR> 6<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2005 Aug 27<TH ALIGN=RIGHT width=33%>BASH(1) 7</TR> 8</TABLE> 9<BR><A HREF="#index">Index</A> 10<HR> 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30<A NAME="lbAB"> </A> 31<H3>NAME</H3> 32 33bash - GNU Bourne-Again SHell 34<A NAME="lbAC"> </A> 35<H3>SYNOPSIS</H3> 36 37<B>bash</B> 38 39[options] 40[file] 41<A NAME="lbAD"> </A> 42<H3>COPYRIGHT</H3> 43 44 45Bash is Copyright © 1989-2005 by the Free Software Foundation, Inc. 46<A NAME="lbAE"> </A> 47<H3>DESCRIPTION</H3> 48 49<B>Bash</B> 50 51is an <B>sh</B>-compatible command language interpreter that 52executes commands read from the standard input or from a file. 53<B>Bash</B> 54 55also incorporates useful features from the <I>Korn</I> and <I>C</I> 56shells (<B>ksh</B> and <B>csh</B>). 57<P> 58 59<B>Bash</B> 60 61is intended to be a conformant implementation of the IEEE 62POSIX Shell and Tools specification (IEEE Working Group 1003.2). 63<B>Bash</B> 64 65can be configured to be POSIX-conformant by default. 66<A NAME="lbAF"> </A> 67<H3>OPTIONS</H3> 68 69In addition to the single-character shell options documented in the 70description of the <B>set</B> builtin command, <B>bash</B> 71interprets the following options when it is invoked: 72<P> 73 74 75<DL COMPACT> 76<DT><B>-c</B><I> string</I> 77 78<DD> 79If the 80<B>-c</B> 81 82option is present, then commands are read from 83<I>string</I>. 84 85If there are arguments after the 86<I>string</I>, 87 88they are assigned to the positional parameters, starting with 89<B>$0</B>. 90 91<DT><B>-i</B> 92 93<DD> 94If the 95<B>-i</B> 96 97option is present, the shell is 98<I>interactive</I>. 99 100<DT><B>-l</B> 101 102<DD> 103Make 104<B>bash</B> 105 106act as if it had been invoked as a login shell (see 107<FONT SIZE=-1><B>INVOCATION</B> 108 109</FONT> 110below). 111<DT><B>-r</B> 112 113<DD> 114If the 115<B>-r</B> 116 117option is present, the shell becomes 118<I>restricted</I> 119 120(see 121<FONT SIZE=-1><B>RESTRICTED SHELL</B> 122 123</FONT> 124below). 125<DT><B>-s</B> 126 127<DD> 128If the 129<B>-s</B> 130 131option is present, or if no arguments remain after option 132processing, then commands are read from the standard input. 133This option allows the positional parameters to be set 134when invoking an interactive shell. 135<DT><B>-D</B> 136 137<DD> 138A list of all double-quoted strings preceded by <B>$</B> 139is printed on the standard output. 140These are the strings that 141are subject to language translation when the current locale 142is not <B>C</B> or <B>POSIX</B>. 143This implies the <B>-n</B> option; no commands will be executed. 144<DT><B>[-+]O [</B><I>shopt_option</I>] 145 146<DD> 147<I>shopt_option</I> is one of the shell options accepted by the 148<B>shopt</B> builtin (see 149<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 150 151</FONT> 152below). 153If <I>shopt_option</I> is present, <B>-O</B> sets the value of that option; 154<B>+O</B> unsets it. 155If <I>shopt_option</I> is not supplied, the names and values of the shell 156options accepted by <B>shopt</B> are printed on the standard output. 157If the invocation option is <B>+O</B>, the output is displayed in a format 158that may be reused as input. 159<DT><B>--</B> 160 161<DD> 162A 163<B>--</B> 164 165signals the end of options and disables further option processing. 166Any arguments after the 167<B>--</B> 168 169are treated as filenames and arguments. An argument of 170<B>-</B> 171 172is equivalent to <B>--</B>. 173 174</DL> 175<P> 176 177<B>Bash</B> 178 179also interprets a number of multi-character options. 180These options must appear on the command line before the 181single-character options to be recognized. 182<P> 183 184 185<DL COMPACT> 186<DT><B>--debugger</B> 187 188<DD> 189Arrange for the debugger profile to be executed before the shell 190starts. 191Turns on extended debugging mode (see the description of the 192<B>extdebug</B> 193 194option to the 195<B>shopt</B> 196 197builtin below) 198and shell function tracing (see the description of the 199<B>-o functrace</B> option to the 200<B>set</B> 201 202builtin below). 203<DT><B>--dump-po-strings</B> 204 205<DD> 206Equivalent to <B>-D</B>, but the output is in the GNU <I>gettext</I> 207<B>po</B> (portable object) file format. 208<DT><B>--dump-strings</B> 209 210<DD> 211Equivalent to <B>-D</B>. 212<DT><B>--help</B> 213 214<DD> 215Display a usage message on standard output and exit successfully. 216<DT><B>--init-file</B> <I>file</I><DD> 217 218<DT><B>--rcfile</B> <I>file</I><DD> 219 220Execute commands from 221<I>file</I> 222 223instead of the standard personal initialization file 224<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A> 225 226if the shell is interactive (see 227<FONT SIZE=-1><B>INVOCATION</B> 228 229</FONT> 230below). 231<DT><B>--login</B> 232 233<DD> 234Equivalent to <B>-l</B>. 235<DT><B>--noediting</B> 236 237<DD> 238Do not use the GNU 239<B>readline</B> 240 241library to read command lines when the shell is interactive. 242<DT><B>--noprofile</B> 243 244<DD> 245Do not read either the system-wide startup file 246 247<A HREF="file:/etc/profile"><I>/etc/profile</I></A> 248 249or any of the personal initialization files 250<A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>, 251 252<A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>, 253 254or 255<A HREF="file:~/.profile"><I>~/.profile</I></A>. 256 257By default, 258<B>bash</B> 259 260reads these files when it is invoked as a login shell (see 261<FONT SIZE=-1><B>INVOCATION</B> 262 263</FONT> 264below). 265<DT><B>--norc</B> 266 267<DD> 268Do not read and execute the personal initialization file 269<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A> 270 271if the shell is interactive. 272This option is on by default if the shell is invoked as 273<B>sh</B>. 274 275<DT><B>--posix</B> 276 277<DD> 278Change the behavior of <B>bash</B> where the default operation differs 279from the POSIX 1003.2 standard to match the standard (<I>posix mode</I>). 280<DT><B>--restricted</B> 281 282<DD> 283The shell becomes restricted (see 284<FONT SIZE=-1><B>RESTRICTED SHELL</B> 285 286</FONT> 287below). 288<DT><B>--verbose</B> 289 290<DD> 291Equivalent to <B>-v</B>. 292<DT><B>--version</B> 293 294<DD> 295Show version information for this instance of 296<B>bash</B> 297 298on the standard output and exit successfully. 299 300</DL> 301<A NAME="lbAG"> </A> 302<H3>ARGUMENTS</H3> 303 304If arguments remain after option processing, and neither the 305<B>-c</B> 306 307nor the 308<B>-s</B> 309 310option has been supplied, the first argument is assumed to 311be the name of a file containing shell commands. 312If 313<B>bash</B> 314 315is invoked in this fashion, 316<B>$0</B> 317 318is set to the name of the file, and the positional parameters 319are set to the remaining arguments. 320<B>Bash</B> 321 322reads and executes commands from this file, then exits. 323<B>Bash</B>'s exit status is the exit status of the last command 324executed in the script. 325If no commands are executed, the exit status is 0. 326An attempt is first made to open the file in the current directory, and, 327if no file is found, then the shell searches the directories in 328<FONT SIZE=-1><B>PATH</B> 329 330</FONT> 331for the script. 332<A NAME="lbAH"> </A> 333<H3>INVOCATION</H3> 334 335A <I>login shell</I> is one whose first character of argument zero is a 336<B>-</B>, 337 338or one started with the 339<B>--login</B> 340 341option. 342<P> 343 344An <I>interactive</I> shell is one started without non-option arguments 345and without the 346<B>-c</B> 347 348option 349whose standard input and error are 350both connected to terminals (as determined by 351<I>isatty</I>(3)), 352 353or one started with the 354<B>-i</B> 355 356option. 357<FONT SIZE=-1><B>PS1</B> 358 359</FONT> 360is set and 361<B>$-</B> 362 363includes 364<B>i</B> 365 366if 367<B>bash</B> 368 369is interactive, 370allowing a shell script or a startup file to test this state. 371<P> 372 373The following paragraphs describe how 374<B>bash</B> 375 376executes its startup files. 377If any of the files exist but cannot be read, 378<B>bash</B> 379 380reports an error. 381Tildes are expanded in file names as described below under 382<B>Tilde Expansion</B> 383 384in the 385<FONT SIZE=-1><B>EXPANSION</B> 386 387</FONT> 388section. 389<P> 390 391When 392<B>bash</B> 393 394is invoked as an interactive login shell, or as a non-interactive shell 395with the <B>--login</B> option, it first reads and 396executes commands from the file <A HREF="file:/etc/profile"><I>/etc/profile</I></A>, if that 397file exists. 398After reading that file, it looks for <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>, 399<A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>, and <A HREF="file:~/.profile"><I>~/.profile</I></A>, in that order, and reads 400and executes commands from the first one that exists and is readable. 401The 402<B>--noprofile</B> 403 404option may be used when the shell is started to inhibit this behavior. 405<P> 406 407When a login shell exits, 408<B>bash</B> 409 410reads and executes commands from the file <A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>, if it 411exists. 412<P> 413 414When an interactive shell that is not a login shell is started, 415<B>bash</B> 416 417reads and executes commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists. 418This may be inhibited by using the 419<B>--norc</B> 420 421option. 422The <B>--rcfile</B> <I>file</I> option will force 423<B>bash</B> 424 425to read and execute commands from <I>file</I> instead of <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>. 426<P> 427 428When 429<B>bash</B> 430 431is started non-interactively, to run a shell script, for example, it 432looks for the variable 433<FONT SIZE=-1><B>BASH_ENV</B> 434 435</FONT> 436in the environment, expands its value if it appears there, and uses the 437expanded value as the name of a file to read and execute. 438<B>Bash</B> 439 440behaves as if the following command were executed: 441<P> 442<DL COMPACT><DT><DD> 443<TT>if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi</TT> 444 445</DL> 446 447<P> 448but the value of the 449<FONT SIZE=-1><B>PATH</B> 450 451</FONT> 452variable is not used to search for the file name. 453<P> 454 455If 456<B>bash</B> 457 458is invoked with the name 459<B>sh</B>, 460 461it tries to mimic the startup behavior of historical versions of 462<B>sh</B> 463 464as closely as possible, 465while conforming to the POSIX standard as well. 466When invoked as an interactive login shell, or a non-interactive 467shell with the <B>--login</B> option, it first attempts to 468read and execute commands from 469<A HREF="file:/etc/profile"><I>/etc/profile</I></A> 470 471and 472<A HREF="file:~/.profile"><I>~/.profile</I></A>, 473 474in that order. 475The 476<B>--noprofile</B> 477 478option may be used to inhibit this behavior. 479When invoked as an interactive shell with the name 480<B>sh</B>, 481 482<B>bash</B> 483 484looks for the variable 485<FONT SIZE=-1><B>ENV</B>, 486 487</FONT> 488expands its value if it is defined, and uses the 489expanded value as the name of a file to read and execute. 490Since a shell invoked as 491<B>sh</B> 492 493does not attempt to read and execute commands from any other startup 494files, the 495<B>--rcfile</B> 496 497option has no effect. 498A non-interactive shell invoked with the name 499<B>sh</B> 500 501does not attempt to read any other startup files. 502When invoked as 503<B>sh</B>, 504 505<B>bash</B> 506 507enters 508<I>posix</I> 509 510mode after the startup files are read. 511<P> 512 513When 514<B>bash</B> 515 516is started in 517<I>posix</I> 518 519mode, as with the 520<B>--posix</B> 521 522command line option, it follows the POSIX standard for startup files. 523In this mode, interactive shells expand the 524<FONT SIZE=-1><B>ENV</B> 525 526</FONT> 527variable and commands are read and executed from the file 528whose name is the expanded value. 529No other startup files are read. 530<P> 531 532<B>Bash</B> 533 534attempts to determine when it is being run by the remote shell 535daemon, usually <I>rshd</I>. 536If 537<B>bash</B> 538 539determines it is being run by <I>rshd</I>, it reads and executes 540commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists and is readable. 541It will not do this if invoked as <B>sh</B>. 542The 543<B>--norc</B> 544 545option may be used to inhibit this behavior, and the 546<B>--rcfile</B> 547 548option may be used to force another file to be read, but 549<I>rshd</I> does not generally invoke the shell with those options 550or allow them to be specified. 551<P> 552 553If the shell is started with the effective user (group) id not equal to the 554real user (group) id, and the <B>-p</B> option is not supplied, no startup 555files are read, shell functions are not inherited from the environment, the 556<FONT SIZE=-1><B>SHELLOPTS</B> 557 558</FONT> 559variable, if it appears in the environment, is ignored, 560and the effective user id is set to the real user id. 561If the <B>-p</B> option is supplied at invocation, the startup behavior is 562the same, but the effective user id is not reset. 563<A NAME="lbAI"> </A> 564<H3>DEFINITIONS</H3> 565 566<P> 567 568The following definitions are used throughout the rest of this 569document. 570 571<DL COMPACT> 572<DT><B>blank </B> 573 574<DD> 575A space or tab. 576<DT><B>word</B> 577 578<DD> 579A sequence of characters considered as a single unit by the shell. 580Also known as a 581<B>token</B>. 582 583<DT><B>name</B> 584 585<DD> 586A 587<I>word</I> 588 589consisting only of alphanumeric characters and underscores, and 590beginning with an alphabetic character or an underscore. Also 591referred to as an 592<B>identifier</B>. 593 594<DT><B>metacharacter</B> 595 596<DD> 597A character that, when unquoted, separates words. One of the following: 598<BR> 599 600<DL COMPACT><DT><DD> 601<P> 602 603<B>| & ; ( ) < > space tab</B> 604 605</DL> 606 607</DL> 608<P> 609 610<DL COMPACT> 611<DT><B>control operator</B> 612 613<DD> 614A <I>token</I> that performs a control function. It is one of the following 615symbols: 616<DL COMPACT><DT><DD> 617<P> 618 619<B>|| & && ; ;; ( ) | <newline></B> 620 621</DL> 622 623 624</DL> 625<A NAME="lbAJ"> </A> 626<H3>RESERVED WORDS</H3> 627 628<I>Reserved words</I> are words that have a special meaning to the shell. 629The following words are recognized as reserved when unquoted and either 630the first word of a simple command (see 631<FONT SIZE=-1><B>SHELL GRAMMAR</B> 632 633</FONT> 634below) or the third word of a 635<B>case </B> 636 637or 638<B>for</B> 639 640command: 641<DL COMPACT><DT><DD> 642 643<P> 644 645<B> 646</B> 647 648! case do done elif else esac fi for function if in select then until while { } time [[ ]] 649</DL> 650 651 652<A NAME="lbAK"> </A> 653<H3>SHELL GRAMMAR</H3> 654 655<A NAME="lbAL"> </A> 656<H4>Simple Commands</H4> 657 658<P> 659 660A <I>simple command</I> is a sequence of optional variable assignments 661followed by <B>blank</B>-separated words and redirections, and 662terminated by a <I>control operator</I>. The first word 663specifies the command to be executed, and is passed as argument zero. 664The remaining words are passed as arguments to the invoked command. 665<P> 666 667The return value of a <I>simple command</I> is its exit status, or 668128+<I>n</I> if the command is terminated by signal 669<I>n</I>. 670 671<A NAME="lbAM"> </A> 672<H4>Pipelines</H4> 673 674<P> 675 676A <I>pipeline</I> is a sequence of one or more commands separated by 677the character 678<B>|</B>. 679 680The format for a pipeline is: 681<DL COMPACT><DT><DD> 682<P> 683 684[<B>time</B> [<B>-p</B>]] [ ! ] <I>command</I> [ <B>|</B> <I>command2</I> ... ] 685</DL> 686 687<P> 688 689The standard output of 690<I>command</I> 691 692is connected via a pipe to the standard input of 693<I>command2</I>. 694 695This connection is performed before any redirections specified by the 696command (see 697<FONT SIZE=-1><B>REDIRECTION</B> 698 699</FONT> 700below). 701<P> 702 703The return status of a pipeline is the exit status of the last 704command, unless the <B>pipefail</B> option is enabled. 705If <B>pipefail</B> is enabled, the pipeline's return status is the 706value of the last (rightmost) command to exit with a non-zero status, 707or zero if all commands exit successfully. 708If the reserved word 709<B>!</B> 710 711precedes a pipeline, the exit status of that pipeline is the logical 712negation of the exit status as described above. 713The shell waits for all commands in the pipeline to 714terminate before returning a value. 715<P> 716 717If the 718<B>time</B> 719 720reserved word precedes a pipeline, the elapsed as well as user and 721system time consumed by its execution are reported when the pipeline 722terminates. 723The <B>-p</B> option changes the output format to that specified by POSIX. 724The 725<FONT SIZE=-1><B>TIMEFORMAT</B> 726 727</FONT> 728variable may be set to a format string that specifies how the timing 729information should be displayed; see the description of 730<FONT SIZE=-1><B>TIMEFORMAT</B> 731 732</FONT> 733under 734<B>Shell Variables</B> 735 736below. 737<P> 738 739Each command in a pipeline is executed as a separate process (i.e., in a 740subshell). 741<A NAME="lbAN"> </A> 742<H4>Lists</H4> 743 744<P> 745 746A <I>list</I> is a sequence of one or more pipelines separated by one 747of the operators 748<B>;</B>, 749 750<B>&</B>, 751 752<B>&&</B>, 753 754or 755<B>||</B>, 756 757and optionally terminated by one of 758<B>;</B>, 759 760<B>&</B>, 761 762or 763<B><newline></B>. 764 765<P> 766 767Of these list operators, 768<B>&&</B> 769 770and 771<B>||</B> 772 773have equal precedence, followed by 774<B>;</B> 775 776and 777<B>&,</B> 778 779which have equal precedence. 780<P> 781 782A sequence of one or more newlines may appear in a <I>list</I> instead 783of a semicolon to delimit commands. 784<P> 785 786If a command is terminated by the control operator 787<B>&</B>, 788 789the shell executes the command in the <I>background</I> 790in a subshell. The shell does not wait for the command to 791finish, and the return status is 0. Commands separated by a 792<B>;</B> 793 794are executed sequentially; the shell waits for each 795command to terminate in turn. The return status is the 796exit status of the last command executed. 797<P> 798 799The control operators 800<B>&&</B> 801 802and 803<B>||</B> 804 805denote AND lists and OR lists, respectively. 806An AND list has the form 807<DL COMPACT><DT><DD> 808<P> 809 810<I>command1</I> <B>&&</B> <I>command2</I> 811</DL> 812 813<P> 814 815<I>command2</I> 816 817is executed if, and only if, 818<I>command1</I> 819 820returns an exit status of zero. 821<P> 822 823An OR list has the form 824<DL COMPACT><DT><DD> 825<P> 826 827<I>command1</I> <B>||</B> <I>command2</I> 828<P> 829 830</DL> 831 832<P> 833 834<I>command2</I> 835 836is executed if and only if 837<I>command1</I> 838 839returns a non-zero exit status. The return status of 840AND and OR lists is the exit status of the last command 841executed in the list. 842<A NAME="lbAO"> </A> 843<H4>Compound Commands</H4> 844 845<P> 846 847A <I>compound command</I> is one of the following: 848<DL COMPACT> 849<DT>(<I>list</I>)<DD> 850<I>list</I> is executed in a subshell environment (see 851<FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B></FONT> 852below). 853Variable assignments and builtin 854commands that affect the shell's environment do not remain in effect 855after the command completes. The return status is the exit status of 856<I>list</I>. 857<DT>{ <I>list</I>; }<DD> 858<I>list</I> is simply executed in the current shell environment. 859<I>list</I> must be terminated with a newline or semicolon. 860This is known as a <I>group command</I>. 861The return status is the exit status of 862<I>list</I>. 863Note that unlike the metacharacters <B>(</B> and <B>)</B>, <B>{</B> and 864<B>}</B> are <I>reserved words</I> and must occur where a reserved 865word is permitted to be recognized. Since they do not cause a word 866break, they must be separated from <I>list</I> by whitespace. 867<DT>((<I>expression</I>))<DD> 868The <I>expression</I> is evaluated according to the rules described 869below under 870<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>. 871 872</FONT> 873If the value of the expression is non-zero, the return status is 0; 874otherwise the return status is 1. This is exactly equivalent to 875<B>let "</B><I>expression</I>". 876<DT><B>[[</B> <I>expression</I> <B>]]</B><DD> 877Return a status of 0 or 1 depending on the evaluation of 878the conditional expression <I>expression</I>. 879Expressions are composed of the primaries described below under 880<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>. 881 882</FONT> 883Word splitting and pathname expansion are not performed on the words 884between the <B>[[</B> and <B>]]</B>; tilde expansion, parameter and 885variable expansion, arithmetic expansion, command substitution, process 886substitution, and quote removal are performed. 887Conditional operators such as <B>-f</B> must be unquoted to be recognized 888as primaries. 889<P> 890 891 892When the <B>==</B> and <B>!=</B> operators are used, the string to the 893right of the operator is considered a pattern and matched according 894to the rules described below under <B>Pattern Matching</B>. 895If the shell option 896<B>nocasematch</B> 897 898is enabled, the match is performed without regard to the case 899of alphabetic characters. 900The return value is 0 if the string matches or does not match 901the pattern, respectively, and 1 otherwise. 902Any part of the pattern may be quoted to force it to be matched as a 903string. 904<P> 905 906 907An additional binary operator, <B>=~</B>, is available, with the same 908precedence as <B>==</B> and <B>!=</B>. 909When it is used, the string to the right of the operator is considered 910an extended regular expression and matched accordingly (as in <I>regex</I>(3)). 911The return value is 0 if the string matches 912the pattern, and 1 otherwise. 913If the regular expression is syntactically incorrect, the conditional 914expression's return value is 2. 915If the shell option 916<B>nocasematch</B> 917 918is enabled, the match is performed without regard to the case 919of alphabetic characters. 920Substrings matched by parenthesized subexpressions within the regular 921expression are saved in the array variable <B>BASH_REMATCH</B>. 922The element of <B>BASH_REMATCH</B> with index 0 is the portion of the string 923matching the entire regular expression. 924The element of <B>BASH_REMATCH</B> with index <I>n</I> is the portion of the 925string matching the <I>n</I>th parenthesized subexpression. 926<P> 927 928 929Expressions may be combined using the following operators, listed 930in decreasing order of precedence: 931<P> 932 933 934<DL COMPACT><DT><DD> 935 936<DL COMPACT> 937<DT><B>( </B><I>expression</I> ) 938 939<DD> 940Returns the value of <I>expression</I>. 941This may be used to override the normal precedence of operators. 942<DT><B>! </B><I>expression</I> 943 944<DD> 945True if 946<I>expression</I> 947 948is false. 949<DT><I>expression1</I> <B>&&</B> <I>expression2</I><DD> 950True if both 951<I>expression1</I> 952 953and 954<I>expression2</I> 955 956are true. 957<DT><I>expression1</I> <B>||</B> <I>expression2</I> 958<DD> 959 960True if either 961<I>expression1</I> 962 963or 964<I>expression2</I> 965 966is true. 967 968</DL> 969<P> 970 971The <B>&&</B> and 972<B>||</B> 973 974operators do not evaluate <I>expression2</I> if the value of 975<I>expression1</I> is sufficient to determine the return value of 976the entire conditional expression. 977</DL> 978 979<DT><B>for</B> <I>name</I> [ <B>in</B> <I>word</I> ] ; <B>do</B> <I>list</I> ; <B>done</B><DD> 980The list of words following <B>in</B> is expanded, generating a list 981of items. 982The variable <I>name</I> is set to each element of this list 983in turn, and <I>list</I> is executed each time. 984If the <B>in</B> <I>word</I> is omitted, the <B>for</B> command executes 985<I>list</I> once for each positional parameter that is set (see 986<FONT SIZE=-1><B>PARAMETERS</B> 987 988</FONT> 989below). 990The return status is the exit status of the last command that executes. 991If the expansion of the items following <B>in</B> results in an empty 992list, no commands are executed, and the return status is 0. 993<DT><B>for</B> (( <I>expr1</I> ; <I>expr2</I> ; <I>expr3</I> )) ; <B>do</B> <I>list</I> ; <B>done</B><DD> 994First, the arithmetic expression <I>expr1</I> is evaluated according 995to the rules described below under 996<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>. 997 998</FONT> 999The arithmetic expression <I>expr2</I> is then evaluated repeatedly 1000until it evaluates to zero. 1001Each time <I>expr2</I> evaluates to a non-zero value, <I>list</I> is 1002executed and the arithmetic expression <I>expr3</I> is evaluated. 1003If any expression is omitted, it behaves as if it evaluates to 1. 1004The return value is the exit status of the last command in <I>list</I> 1005that is executed, or false if any of the expressions is invalid. 1006<DT><B>select</B> <I>name</I> [ <B>in</B> <I>word</I> ] ; <B>do</B> <I>list</I> ; <B>done</B><DD> 1007The list of words following <B>in</B> is expanded, generating a list 1008of items. The set of expanded words is printed on the standard 1009error, each preceded by a number. If the <B>in</B> 1010<I>word</I> is omitted, the positional parameters are printed (see 1011<FONT SIZE=-1><B>PARAMETERS</B> 1012 1013</FONT> 1014below). The 1015<B>PS3</B> 1016 1017prompt is then displayed and a line read from the standard input. 1018If the line consists of a number corresponding to one of 1019the displayed words, then the value of 1020<I>name</I> 1021 1022is set to that word. If the line is empty, the words and prompt 1023are displayed again. If EOF is read, the command completes. Any 1024other value read causes 1025<I>name</I> 1026 1027to be set to null. The line read is saved in the variable 1028<B>REPLY</B>. 1029 1030The 1031<I>list</I> 1032 1033is executed after each selection until a 1034<B>break</B> 1035 1036command is executed. 1037The exit status of 1038<B>select</B> 1039 1040is the exit status of the last command executed in 1041<I>list</I>, 1042 1043or zero if no commands were executed. 1044<DT><B>case</B> <I>word</I> <B>in</B> [ [(] <I>pattern</I> [ <B>|</B> <I>pattern</I> ] 1045<DD> 1046A <B>case</B> command first expands <I>word</I>, and tries to match 1047it against each <I>pattern</I> in turn, using the same matching rules 1048as for pathname expansion (see 1049<B>Pathname Expansion</B> 1050 1051below). 1052If the shell option 1053<B>nocasematch</B> 1054 1055is enabled, the match is performed without regard to the case 1056of alphabetic characters. 1057When a match is found, the 1058corresponding <I>list</I> is executed. After the first match, no 1059subsequent matches are attempted. The exit status is zero if no 1060pattern matches. Otherwise, it is the exit status of the 1061last command executed in <I>list</I>. 1062<DT><B>if</B> <I>list</I>; <B>then</B> <I>list;</I> [ <B>elif</B> <I>list</I>; <B>then</B> <I>list</I>; ] ... [ <B>else</B> <I>list</I>; ] <B>fi</B><DD> 1063The 1064<B>if </B> 1065 1066<I>list</I> 1067 1068is executed. If its exit status is zero, the 1069<B>then</B> <I>list</I> is executed. Otherwise, each <B>elif</B> 1070<I>list</I> is executed in turn, and if its exit status is zero, 1071the corresponding <B>then</B> <I>list</I> is executed and the 1072command completes. Otherwise, the <B>else</B> <I>list</I> is 1073executed, if present. The exit status is the exit status of the 1074last command executed, or zero if no condition tested true. 1075<DT><B>while</B> <I>list</I>; <B>do</B> <I>list</I>; <B>done</B><DD> 1076 1077<DT><B>until</B> <I>list</I>; <B>do</B> <I>list</I>; <B>done</B><DD> 1078 1079The <B>while</B> command continuously executes the <B>do</B> 1080<I>list</I> as long as the last command in <I>list</I> returns 1081an exit status of zero. The <B>until</B> command is identical 1082to the <B>while</B> command, except that the test is negated; 1083the 1084<B>do</B> 1085 1086<I>list</I> 1087 1088is executed as long as the last command in 1089<I>list</I> 1090 1091returns a non-zero exit status. 1092The exit status of the <B>while</B> and <B>until</B> commands 1093is the exit status 1094of the last <B>do</B> <I>list</I> command executed, or zero if 1095none was executed. 1096</DL> 1097<A NAME="lbAP"> </A> 1098<H4>Shell Function Definitions</H4> 1099 1100<P> 1101 1102A shell function is an object that is called like a simple command and 1103executes a compound command with a new set of positional parameters. 1104Shell functions are declared as follows: 1105<DL COMPACT> 1106<DT>[ <B>function</B> ] <I>name</I> () <I>compound-command</I> [<I>redirection</I>]<DD> 1107This defines a function named <I>name</I>. 1108The reserved word <B>function</B> is optional. 1109If the <B>function</B> reserved word is supplied, the parentheses are optional. 1110The <I>body</I> of the function is the compound command 1111<I>compound-command </I> 1112 1113(see <B>Compound Commands</B> above). 1114That command is usually a <I>list</I> of commands between { and }, but 1115may be any command listed under <B>Compound Commands</B> above. 1116<I>compound-command</I> is executed whenever <I>name</I> is specified as the 1117name of a simple command. 1118Any redirections (see 1119<FONT SIZE=-1><B>REDIRECTION</B> 1120 1121</FONT> 1122below) specified when a function is defined are performed 1123when the function is executed. 1124The exit status of a function definition is zero unless a syntax error 1125occurs or a readonly function with the same name already exists. 1126When executed, the exit status of a function is the exit status of the 1127last command executed in the body. (See 1128<FONT SIZE=-1><B>FUNCTIONS</B> 1129 1130</FONT> 1131below.) 1132</DL> 1133<A NAME="lbAQ"> </A> 1134<H3>COMMENTS</H3> 1135 1136In a non-interactive shell, or an interactive shell in which the 1137<B>interactive_comments</B> 1138 1139option to the 1140<B>shopt</B> 1141 1142builtin is enabled (see 1143<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 1144 1145</FONT> 1146below), a word beginning with 1147<B>#</B> 1148 1149causes that word and all remaining characters on that line to 1150be ignored. An interactive shell without the 1151<B>interactive_comments</B> 1152 1153option enabled does not allow comments. The 1154<B>interactive_comments</B> 1155 1156option is on by default in interactive shells. 1157<A NAME="lbAR"> </A> 1158<H3>QUOTING</H3> 1159 1160<I>Quoting</I> is used to remove the special meaning of certain 1161characters or words to the shell. Quoting can be used to 1162disable special treatment for special characters, to prevent 1163reserved words from being recognized as such, and to prevent 1164parameter expansion. 1165<P> 1166 1167Each of the <I>metacharacters</I> listed above under 1168<FONT SIZE=-1><B>DEFINITIONS</B> 1169 1170</FONT> 1171has special meaning to the shell and must be quoted if it is to 1172represent itself. 1173<P> 1174 1175When the command history expansion facilities are being used 1176(see 1177<FONT SIZE=-1><B>HISTORY EXPANSION</B> 1178 1179</FONT> 1180below), the 1181<I>history expansion</I> character, usually <B>!</B>, must be quoted 1182to prevent history expansion. 1183<P> 1184 1185There are three quoting mechanisms: the 1186<I>escape character</I>, 1187 1188single quotes, and double quotes. 1189<P> 1190 1191A non-quoted backslash (<B>\</B>) is the 1192<I>escape character</I>. 1193 1194It preserves the literal value of the next character that follows, 1195with the exception of <newline>. If a <B>\</B><newline> pair 1196appears, and the backslash is not itself quoted, the <B>\</B><newline> 1197is treated as a line continuation (that is, it is removed from the 1198input stream and effectively ignored). 1199<P> 1200 1201Enclosing characters in single quotes preserves the literal value 1202of each character within the quotes. A single quote may not occur 1203between single quotes, even when preceded by a backslash. 1204<P> 1205 1206Enclosing characters in double quotes preserves the literal value 1207of all characters within the quotes, with the exception of 1208<B>$</B>, 1209 1210<B>`</B>, 1211 1212<B>\</B>, 1213 1214and, when history expansion is enabled, 1215<B>!</B>. 1216 1217The characters 1218<B>$</B> 1219 1220and 1221<B>`</B> 1222 1223retain their special meaning within double quotes. The backslash 1224retains its special meaning only when followed by one of the following 1225characters: 1226<B>$</B>, 1227 1228<B>`</B>, 1229 1230<B>"</B>, 1231<B>\</B>, 1232 1233or 1234<B><newline></B>. 1235 1236A double quote may be quoted within double quotes by preceding it with 1237a backslash. 1238If enabled, history expansion will be performed unless an 1239<B>!</B> 1240 1241appearing in double quotes is escaped using a backslash. 1242The backslash preceding the 1243<B>!</B> 1244 1245is not removed. 1246<P> 1247 1248The special parameters 1249<B>*</B> 1250 1251and 1252<B>@</B> 1253 1254have special meaning when in double 1255quotes (see 1256<FONT SIZE=-1><B>PARAMETERS</B> 1257 1258</FONT> 1259below). 1260<P> 1261 1262Words of the form <B>$</B>'<I>string</I>' are treated specially. The 1263word expands to <I>string</I>, with backslash-escaped characters replaced 1264as specified by the ANSI C standard. Backslash escape sequences, if 1265present, are decoded as follows: 1266<DL COMPACT><DT><DD> 1267 1268<DL COMPACT> 1269<DT><B>\a</B> 1270 1271<DD> 1272alert (bell) 1273<DT><B>\b</B> 1274 1275<DD> 1276backspace 1277<DT><B>\e</B> 1278 1279<DD> 1280an escape character 1281<DT><B>\f</B> 1282 1283<DD> 1284form feed 1285<DT><B>\n</B> 1286 1287<DD> 1288new line 1289<DT><B>\r</B> 1290 1291<DD> 1292carriage return 1293<DT><B>\t</B> 1294 1295<DD> 1296horizontal tab 1297<DT><B>\v</B> 1298 1299<DD> 1300vertical tab 1301<DT><B>\\</B> 1302 1303<DD> 1304backslash 1305<DT><B>\'</B> 1306 1307<DD> 1308single quote 1309<DT><B>\</B><I>nnn</I> 1310 1311<DD> 1312the eight-bit character whose value is the octal value <I>nnn</I> 1313(one to three digits) 1314<DT><B>\x</B><I>HH</I> 1315 1316<DD> 1317the eight-bit character whose value is the hexadecimal value <I>HH</I> 1318(one or two hex digits) 1319<DT><B>\c</B><I>x</I> 1320 1321<DD> 1322a control-<I>x</I> character 1323 1324</DL></DL> 1325 1326<P> 1327 1328The expanded result is single-quoted, as if the dollar sign had 1329not been present. 1330<P> 1331 1332A double-quoted string preceded by a dollar sign (<B>$</B>) will cause 1333the string to be translated according to the current locale. 1334If the current locale is <B>C</B> or <B>POSIX</B>, the dollar sign 1335is ignored. 1336If the string is translated and replaced, the replacement is 1337double-quoted. 1338<A NAME="lbAS"> </A> 1339<H3>PARAMETERS</H3> 1340 1341A 1342<I>parameter</I> 1343 1344is an entity that stores values. 1345It can be a 1346<I>name</I>, 1347 1348a number, or one of the special characters listed below under 1349<B>Special Parameters</B>. 1350 1351A 1352<I>variable</I> 1353 1354is a parameter denoted by a 1355<I>name</I>. 1356 1357A variable has a <I>value</I> and zero or more <I>attributes</I>. 1358Attributes are assigned using the 1359<B>declare</B> 1360 1361builtin command (see 1362<B>declare</B> 1363 1364below in 1365<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>). 1366 1367</FONT> 1368<P> 1369 1370A parameter is set if it has been assigned a value. The null string is 1371a valid value. Once a variable is set, it may be unset only by using 1372the 1373<B>unset</B> 1374 1375builtin command (see 1376<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 1377 1378</FONT> 1379below). 1380<P> 1381 1382A 1383<I>variable</I> 1384 1385may be assigned to by a statement of the form 1386<DL COMPACT><DT><DD> 1387<P> 1388 1389<I>name</I>=[<I>value</I>] 1390</DL> 1391 1392<P> 1393 1394If 1395<I>value</I> 1396 1397is not given, the variable is assigned the null string. All 1398<I>values</I> 1399 1400undergo tilde expansion, parameter and variable expansion, 1401command substitution, arithmetic expansion, and quote 1402removal (see 1403<FONT SIZE=-1><B>EXPANSION</B> 1404 1405</FONT> 1406below). If the variable has its 1407<B>integer</B> 1408 1409attribute set, then 1410<I>value</I> 1411 1412is evaluated as an arithmetic expression even if the $((...)) expansion is 1413not used (see 1414<B>Arithmetic Expansion</B> 1415 1416below). 1417Word splitting is not performed, with the exception 1418of <B>"$@"</B> as explained below under 1419<B>Special Parameters</B>. 1420 1421Pathname expansion is not performed. 1422Assignment statements may also appear as arguments to the 1423<B>alias</B>, 1424 1425<B>declare</B>, 1426 1427<B>typeset</B>, 1428 1429<B>export</B>, 1430 1431<B>readonly</B>, 1432 1433and 1434<B>local</B> 1435 1436builtin commands. 1437<P> 1438 1439In the context where an assignment statement is assigning a value 1440to a shell variable or array index, the += operator can be used to 1441append to or add to the variable's previous value. 1442When += is applied to a variable for which the integer attribute has been 1443set, <I>value</I> is evaluated as an arithmetic expression and added to the 1444variable's current value, which is also evaluated. 1445When += is applied to an array variable using compound assignment (see 1446<B>Arrays</B> 1447 1448below), the 1449variable's value is not unset (as it is when using =), and new values are 1450appended to the array beginning at one greater than the array's maximum index. 1451When applied to a string-valued variable, <I>value</I> is expanded and 1452appended to the variable's value. 1453<A NAME="lbAT"> </A> 1454<H4>Positional Parameters</H4> 1455 1456<P> 1457 1458A 1459<I>positional parameter</I> 1460 1461is a parameter denoted by one or more 1462digits, other than the single digit 0. Positional parameters are 1463assigned from the shell's arguments when it is invoked, 1464and may be reassigned using the 1465<B>set</B> 1466 1467builtin command. Positional parameters may not be assigned to 1468with assignment statements. The positional parameters are 1469temporarily replaced when a shell function is executed (see 1470<FONT SIZE=-1><B>FUNCTIONS</B> 1471 1472</FONT> 1473below). 1474<P> 1475 1476When a positional parameter consisting of more than a single 1477digit is expanded, it must be enclosed in braces (see 1478<FONT SIZE=-1><B>EXPANSION</B> 1479 1480</FONT> 1481below). 1482<A NAME="lbAU"> </A> 1483<H4>Special Parameters</H4> 1484 1485<P> 1486 1487The shell treats several parameters specially. These parameters may 1488only be referenced; assignment to them is not allowed. 1489 1490<DL COMPACT> 1491<DT><B>*</B> 1492 1493<DD> 1494Expands to the positional parameters, starting from one. When the 1495expansion occurs within double quotes, it expands to a single word 1496with the value of each parameter separated by the first character 1497of the 1498<FONT SIZE=-1><B>IFS</B> 1499 1500</FONT> 1501special variable. That is, "<B>$*</B>" is equivalent 1502to "<B>$1</B><I>c</I><B>$2</B><I>c</I><B>...</B>", where 1503<I>c</I> 1504 1505is the first character of the value of the 1506<FONT SIZE=-1><B>IFS</B> 1507 1508</FONT> 1509variable. If 1510<FONT SIZE=-1><B>IFS</B> 1511 1512</FONT> 1513is unset, the parameters are separated by spaces. 1514If 1515<FONT SIZE=-1><B>IFS</B> 1516 1517</FONT> 1518is null, the parameters are joined without intervening separators. 1519<DT><B>@</B> 1520 1521<DD> 1522Expands to the positional parameters, starting from one. When the 1523expansion occurs within double quotes, each parameter expands to a 1524separate word. That is, "<B>$@</B>" is equivalent to 1525"<B>$1</B>" "<B>$2</B>" ... 1526If the double-quoted expansion occurs within a word, the expansion of 1527the first parameter is joined with the beginning part of the original 1528word, and the expansion of the last parameter is joined with the last 1529part of the original word. 1530When there are no positional parameters, "<B>$@</B>" and 1531<B>$@</B> 1532 1533expand to nothing (i.e., they are removed). 1534<DT><B>#</B> 1535 1536<DD> 1537Expands to the number of positional parameters in decimal. 1538<DT><B>?</B> 1539 1540<DD> 1541Expands to the status of the most recently executed foreground 1542pipeline. 1543<DT><B>-</B> 1544 1545<DD> 1546Expands to the current option flags as specified upon invocation, 1547by the 1548<B>set</B> 1549 1550builtin command, or those set by the shell itself 1551(such as the 1552<B>-i</B> 1553 1554option). 1555<DT><B>$</B> 1556 1557<DD> 1558Expands to the process ID of the shell. In a () subshell, it 1559expands to the process ID of the current shell, not the 1560subshell. 1561<DT><B>!</B> 1562 1563<DD> 1564Expands to the process ID of the most recently executed background 1565(asynchronous) command. 1566<DT><B>0</B> 1567 1568<DD> 1569Expands to the name of the shell or shell script. This is set at 1570shell initialization. If 1571<B>bash</B> 1572 1573is invoked with a file of commands, 1574<B>$0</B> 1575 1576is set to the name of that file. If 1577<B>bash</B> 1578 1579is started with the 1580<B>-c</B> 1581 1582option, then 1583<B>$0</B> 1584 1585is set to the first argument after the string to be 1586executed, if one is present. Otherwise, it is set 1587to the file name used to invoke 1588<B>bash</B>, 1589 1590as given by argument zero. 1591<DT><B>_</B> 1592 1593<DD> 1594At shell startup, set to the absolute pathname used to invoke the 1595shell or shell script being executed as passed in the environment 1596or argument list. 1597Subsequently, expands to the last argument to the previous command, 1598after expansion. 1599Also set to the full pathname used to invoke each command executed 1600and placed in the environment exported to that command. 1601When checking mail, this parameter holds the name of the mail file 1602currently being checked. 1603 1604</DL> 1605<A NAME="lbAV"> </A> 1606<H4>Shell Variables</H4> 1607 1608<P> 1609 1610The following variables are set by the shell: 1611<P> 1612 1613 1614<DL COMPACT> 1615<DT><B>BASH</B> 1616 1617<DD> 1618Expands to the full file name used to invoke this instance of 1619<B>bash</B>. 1620 1621<DT><B>BASH_ARGC</B> 1622 1623<DD> 1624An array variable whose values are the number of parameters in each 1625frame of the current bash execution call stack. 1626The number of 1627parameters to the current subroutine (shell function or script executed 1628with <B>.</B> or <B>source</B>) is at the top of the stack. 1629When a subroutine is executed, the number of parameters passed is pushed onto 1630<B>BASH_ARGC</B>. 1631The shell sets <B>BASH_ARGC</B> only when in extended debugging mode 1632(see the description of the 1633<B>extdebug</B> 1634 1635option to the 1636<B>shopt</B> 1637 1638builtin below) 1639<DT><B>BASH_ARGV</B> 1640 1641<DD> 1642An array variable containing all of the parameters in the current bash 1643execution call stack. The final parameter of the last subroutine call 1644is at the top of the stack; the first parameter of the initial call is 1645at the bottom. When a subroutine is executed, the parameters supplied 1646are pushed onto <B>BASH_ARGV</B>. 1647The shell sets <B>BASH_ARGV</B> only when in extended debugging mode 1648(see the description of the 1649<B>extdebug</B> 1650 1651option to the 1652<B>shopt</B> 1653 1654builtin below) 1655<DT><B>BASH_COMMAND</B> 1656 1657<DD> 1658The command currently being executed or about to be executed, unless the 1659shell is executing a command as the result of a trap, 1660in which case it is the command executing at the time of the trap. 1661<DT><B>BASH_EXECUTION_STRING</B> 1662 1663<DD> 1664The command argument to the <B>-c</B> invocation option. 1665<DT><B>BASH_LINENO</B> 1666 1667<DD> 1668An array variable whose members are the line numbers in source files 1669corresponding to each member of <B>FUNCNAME</B>. 1670<B>${BASH_LINENO[</B><I>$i</I><B>]}</B> is the line number in the source 1671file where <B>${FUNCNAME[</B><I>$ifP</I><B>]}</B> was called. 1672The corresponding source file name is <B>${BASH_SOURCE[</B><I>$i</I><B>]}. 1673Use LINENO</B> to obtain the current line number. 1674<DT><B>BASH_REMATCH</B> 1675 1676<DD> 1677An array variable whose members are assigned by the <B>=~</B> binary 1678operator to the <B>[[</B> conditional command. 1679The element with index 0 is the portion of the string 1680matching the entire regular expression. 1681The element with index <I>n</I> is the portion of the 1682string matching the <I>n</I>th parenthesized subexpression. 1683This variable is read-only. 1684<DT><B>BASH_SOURCE</B> 1685 1686<DD> 1687An array variable whose members are the source filenames corresponding 1688to the elements in the <B>FUNCNAME</B> array variable. 1689<DT><B>BASH_SUBSHELL</B> 1690 1691<DD> 1692Incremented by one each time a subshell or subshell environment is spawned. 1693The initial value is 0. 1694<DT><B>BASH_VERSINFO</B> 1695 1696<DD> 1697A readonly array variable whose members hold version information for 1698this instance of 1699<B>bash</B>. 1700 1701The values assigned to the array members are as follows: 1702<P> 1703<DL COMPACT><DT><DD> 1704 1705<DL COMPACT> 1706<DT><B>BASH_VERSINFO[</B>0] 1707 1708<DD> 1709The major version number (the <I>release</I>). 1710<DT><B>BASH_VERSINFO[</B>1] 1711 1712<DD> 1713The minor version number (the <I>version</I>). 1714<DT><B>BASH_VERSINFO[</B>2] 1715 1716<DD> 1717The patch level. 1718<DT><B>BASH_VERSINFO[</B>3] 1719 1720<DD> 1721The build version. 1722<DT><B>BASH_VERSINFO[</B>4] 1723 1724<DD> 1725The release status (e.g., <I>beta1</I>). 1726<DT><B>BASH_VERSINFO[</B>5] 1727 1728<DD> 1729The value of <B>MACHTYPE</B>. 1730 1731</DL></DL> 1732 1733<DT><B>BASH_VERSION</B> 1734 1735<DD> 1736Expands to a string describing the version of this instance of 1737<B>bash</B>. 1738 1739<DT><B>COMP_CWORD</B> 1740 1741<DD> 1742An index into <B>${COMP_WORDS}</B> of the word containing the current 1743cursor position. 1744This variable is available only in shell functions invoked by the 1745programmable completion facilities (see <B>Programmable Completion</B> 1746below). 1747<DT><B>COMP_LINE</B> 1748 1749<DD> 1750The current command line. 1751This variable is available only in shell functions and external 1752commands invoked by the 1753programmable completion facilities (see <B>Programmable Completion</B> 1754below). 1755<DT><B>COMP_POINT</B> 1756 1757<DD> 1758The index of the current cursor position relative to the beginning of 1759the current command. 1760If the current cursor position is at the end of the current command, 1761the value of this variable is equal to <B>${#COMP_LINE}</B>. 1762This variable is available only in shell functions and external 1763commands invoked by the 1764programmable completion facilities (see <B>Programmable Completion</B> 1765below). 1766<DT><B>COMP_WORDBREAKS</B> 1767 1768<DD> 1769The set of characters that the Readline library treats as word 1770separators when performing word completion. 1771If 1772<FONT SIZE=-1><B>COMP_WORDBREAKS</B> 1773 1774</FONT> 1775is unset, it loses its special properties, even if it is 1776subsequently reset. 1777<DT><B>COMP_WORDS</B> 1778 1779<DD> 1780An array variable (see <B>Arrays</B> below) consisting of the individual 1781words in the current command line. 1782This variable is available only in shell functions invoked by the 1783programmable completion facilities (see <B>Programmable Completion</B> 1784below). 1785<DT><B>DIRSTACK</B> 1786 1787<DD> 1788An array variable (see 1789<B>Arrays</B> 1790 1791below) containing the current contents of the directory stack. 1792Directories appear in the stack in the order they are displayed by the 1793<B>dirs</B> 1794 1795builtin. 1796Assigning to members of this array variable may be used to modify 1797directories already in the stack, but the 1798<B>pushd</B> 1799 1800and 1801<B>popd</B> 1802 1803builtins must be used to add and remove directories. 1804Assignment to this variable will not change the current directory. 1805If 1806<FONT SIZE=-1><B>DIRSTACK</B> 1807 1808</FONT> 1809is unset, it loses its special properties, even if it is 1810subsequently reset. 1811<DT><B>EUID</B> 1812 1813<DD> 1814Expands to the effective user ID of the current user, initialized at 1815shell startup. This variable is readonly. 1816<DT><B>FUNCNAME</B> 1817 1818<DD> 1819An array variable containing the names of all shell functions 1820currently in the execution call stack. 1821The element with index 0 is the name of any currently-executing 1822shell function. 1823The bottom-most element is "main". 1824This variable exists only when a shell function is executing. 1825Assignments to 1826<FONT SIZE=-1><B>FUNCNAME</B> 1827 1828</FONT> 1829have no effect and return an error status. 1830If 1831<FONT SIZE=-1><B>FUNCNAME</B> 1832 1833</FONT> 1834is unset, it loses its special properties, even if it is 1835subsequently reset. 1836<DT><B>GROUPS</B> 1837 1838<DD> 1839An array variable containing the list of groups of which the current 1840user is a member. 1841Assignments to 1842<FONT SIZE=-1><B>GROUPS</B> 1843 1844</FONT> 1845have no effect and return an error status. 1846If 1847<FONT SIZE=-1><B>GROUPS</B> 1848 1849</FONT> 1850is unset, it loses its special properties, even if it is 1851subsequently reset. 1852<DT><B>HISTCMD</B> 1853 1854<DD> 1855The history number, or index in the history list, of the current 1856command. 1857If 1858<FONT SIZE=-1><B>HISTCMD</B> 1859 1860</FONT> 1861is unset, it loses its special properties, even if it is 1862subsequently reset. 1863<DT><B>HOSTNAME</B> 1864 1865<DD> 1866Automatically set to the name of the current host. 1867<DT><B>HOSTTYPE</B> 1868 1869<DD> 1870Automatically set to a string that uniquely 1871describes the type of machine on which 1872<B>bash</B> 1873 1874is executing. 1875The default is system-dependent. 1876<DT><B>LINENO</B> 1877 1878<DD> 1879Each time this parameter is referenced, the shell substitutes 1880a decimal number representing the current sequential line number 1881(starting with 1) within a script or function. When not in a 1882script or function, the value substituted is not guaranteed to 1883be meaningful. 1884If 1885<FONT SIZE=-1><B>LINENO</B> 1886 1887</FONT> 1888is unset, it loses its special properties, even if it is 1889subsequently reset. 1890<DT><B>MACHTYPE</B> 1891 1892<DD> 1893Automatically set to a string that fully describes the system 1894type on which 1895<B>bash</B> 1896 1897is executing, in the standard GNU <I>cpu-company-system</I> format. 1898The default is system-dependent. 1899<DT><B>OLDPWD</B> 1900 1901<DD> 1902The previous working directory as set by the 1903<B>cd</B> 1904 1905command. 1906<DT><B>OPTARG</B> 1907 1908<DD> 1909The value of the last option argument processed by the 1910<B>getopts</B> 1911 1912builtin command (see 1913<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 1914 1915</FONT> 1916below). 1917<DT><B>OPTIND</B> 1918 1919<DD> 1920The index of the next argument to be processed by the 1921<B>getopts</B> 1922 1923builtin command (see 1924<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 1925 1926</FONT> 1927below). 1928<DT><B>OSTYPE</B> 1929 1930<DD> 1931Automatically set to a string that 1932describes the operating system on which 1933<B>bash</B> 1934 1935is executing. 1936The default is system-dependent. 1937<DT><B>PIPESTATUS</B> 1938 1939<DD> 1940An array variable (see 1941<B>Arrays</B> 1942 1943below) containing a list of exit status values from the processes 1944in the most-recently-executed foreground pipeline (which may 1945contain only a single command). 1946<DT><B>PPID</B> 1947 1948<DD> 1949The process ID of the shell's parent. This variable is readonly. 1950<DT><B>PWD</B> 1951 1952<DD> 1953The current working directory as set by the 1954<B>cd</B> 1955 1956command. 1957<DT><B>RANDOM</B> 1958 1959<DD> 1960Each time this parameter is referenced, a random integer between 19610 and 32767 is 1962generated. The sequence of random numbers may be initialized by assigning 1963a value to 1964<FONT SIZE=-1><B>RANDOM</B>. 1965 1966</FONT> 1967If 1968<FONT SIZE=-1><B>RANDOM</B> 1969 1970</FONT> 1971is unset, it loses its special properties, even if it is 1972subsequently reset. 1973<DT><B>REPLY</B> 1974 1975<DD> 1976Set to the line of input read by the 1977<B>read</B> 1978 1979builtin command when no arguments are supplied. 1980<DT><B>SECONDS</B> 1981 1982<DD> 1983Each time this parameter is 1984referenced, the number of seconds since shell invocation is returned. If a 1985value is assigned to 1986<FONT SIZE=-1><B>SECONDS</B>, 1987 1988</FONT> 1989the value returned upon subsequent 1990references is 1991the number of seconds since the assignment plus the value assigned. 1992If 1993<FONT SIZE=-1><B>SECONDS</B> 1994 1995</FONT> 1996is unset, it loses its special properties, even if it is 1997subsequently reset. 1998<DT><B>SHELLOPTS</B> 1999 2000<DD> 2001A colon-separated list of enabled shell options. Each word in 2002the list is a valid argument for the 2003<B>-o</B> 2004 2005option to the 2006<B>set</B> 2007 2008builtin command (see 2009<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 2010 2011</FONT> 2012below). The options appearing in 2013<FONT SIZE=-1><B>SHELLOPTS</B> 2014 2015</FONT> 2016are those reported as 2017<I>on</I> 2018 2019by <B>set -o</B>. 2020If this variable is in the environment when 2021<B>bash</B> 2022 2023starts up, each shell option in the list will be enabled before 2024reading any startup files. 2025This variable is read-only. 2026<DT><B>SHLVL</B> 2027 2028<DD> 2029Incremented by one each time an instance of 2030<B>bash</B> 2031 2032is started. 2033<DT><B>UID</B> 2034 2035<DD> 2036Expands to the user ID of the current user, initialized at shell startup. 2037This variable is readonly. 2038 2039</DL> 2040<P> 2041 2042The following variables are used by the shell. In some cases, 2043<B>bash</B> 2044 2045assigns a default value to a variable; these cases are noted 2046below. 2047<P> 2048 2049 2050<DL COMPACT> 2051<DT><B>BASH_ENV</B> 2052 2053<DD> 2054If this parameter is set when <B>bash</B> is executing a shell script, 2055its value is interpreted as a filename containing commands to 2056initialize the shell, as in 2057<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>. 2058 2059The value of 2060<FONT SIZE=-1><B>BASH_ENV</B> 2061 2062</FONT> 2063is subjected to parameter expansion, command substitution, and arithmetic 2064expansion before being interpreted as a file name. 2065<FONT SIZE=-1><B>PATH</B> 2066 2067</FONT> 2068is not used to search for the resultant file name. 2069<DT><B>CDPATH</B> 2070 2071<DD> 2072The search path for the 2073<B>cd</B> 2074 2075command. 2076This is a colon-separated list of directories in which the shell looks 2077for destination directories specified by the 2078<B>cd</B> 2079 2080command. 2081A sample value is 2082<TT>".:~:/usr"</TT>. 2083 2084<DT><B>COLUMNS</B> 2085 2086<DD> 2087Used by the <B>select</B> builtin command to determine the terminal width 2088when printing selection lists. Automatically set upon receipt of a SIGWINCH. 2089<DT><B>COMPREPLY</B> 2090 2091<DD> 2092An array variable from which <B>bash</B> reads the possible completions 2093generated by a shell function invoked by the programmable completion 2094facility (see <B>Programmable Completion</B> below). 2095<DT><B>EMACS</B> 2096 2097<DD> 2098If <B>bash</B> finds this variable in the environment when the shell starts 2099with value 2100<TT>t</TT>, 2101 2102it assumes that the shell is running in an emacs shell buffer and disables 2103line editing. 2104<DT><B>FCEDIT</B> 2105 2106<DD> 2107The default editor for the 2108<B>fc</B> 2109 2110builtin command. 2111<DT><B>FIGNORE</B> 2112 2113<DD> 2114A colon-separated list of suffixes to ignore when performing 2115filename completion (see 2116<FONT SIZE=-1><B>READLINE</B> 2117 2118</FONT> 2119below). 2120A filename whose suffix matches one of the entries in 2121<FONT SIZE=-1><B>FIGNORE</B> 2122 2123</FONT> 2124is excluded from the list of matched filenames. 2125A sample value is 2126<TT>".o:~"</TT>. 2127 2128<DT><B>GLOBIGNORE</B> 2129 2130<DD> 2131A colon-separated list of patterns defining the set of filenames to 2132be ignored by pathname expansion. 2133If a filename matched by a pathname expansion pattern also matches one 2134of the patterns in 2135<FONT SIZE=-1><B>GLOBIGNORE</B>, 2136 2137</FONT> 2138it is removed from the list of matches. 2139<DT><B>HISTCONTROL</B> 2140 2141<DD> 2142A colon-separated list of values controlling how commands are saved on 2143the history list. 2144If the list of values includes 2145<I>ignorespace</I>, 2146 2147lines which begin with a 2148<B>space</B> 2149 2150character are not saved in the history list. 2151A value of 2152<I>ignoredups</I> 2153 2154causes lines matching the previous history entry to not be saved. 2155A value of 2156<I>ignoreboth</I> 2157 2158is shorthand for <I>ignorespace</I> and <I>ignoredups</I>. 2159A value of 2160<I>erasedups</I> 2161 2162causes all previous lines matching the current line to be removed from 2163the history list before that line is saved. 2164Any value not in the above list is ignored. 2165If <B>HISTCONTROL</B> is unset, or does not include a valid value, 2166all lines read by the shell parser are saved on the history list, 2167subject to the value of 2168<B>HISTIGNORE</B>. 2169 2170The second and subsequent lines of a multi-line compound command are 2171not tested, and are added to the history regardless of the value of 2172<B>HISTCONTROL</B>. 2173 2174<DT><B>HISTFILE</B> 2175 2176<DD> 2177The name of the file in which command history is saved (see 2178<FONT SIZE=-1><B>HISTORY</B> 2179 2180</FONT> 2181below). The default value is <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>. If unset, the 2182command history is not saved when an interactive shell exits. 2183<DT><B>HISTFILESIZE</B> 2184 2185<DD> 2186The maximum number of lines contained in the history file. When this 2187variable is assigned a value, the history file is truncated, if 2188necessary, to contain no more than that number of lines. The default 2189value is 500. The history file is also truncated to this size after 2190writing it when an interactive shell exits. 2191<DT><B>HISTIGNORE</B> 2192 2193<DD> 2194A colon-separated list of patterns used to decide which command lines 2195should be saved on the history list. Each pattern is anchored at the 2196beginning of the line and must match the complete line (no implicit 2197`<B>*</B>' is appended). Each pattern is tested against the line 2198after the checks specified by 2199<B>HISTCONTROL</B> 2200 2201are applied. 2202In addition to the normal shell pattern matching characters, `<B>&</B>' 2203matches the previous history line. `<B>&</B>' may be escaped using a 2204backslash; the backslash is removed before attempting a match. 2205The second and subsequent lines of a multi-line compound command are 2206not tested, and are added to the history regardless of the value of 2207<B>HISTIGNORE</B>. 2208 2209<DT><B>HISTSIZE</B> 2210 2211<DD> 2212The number of commands to remember in the command history (see 2213<FONT SIZE=-1><B>HISTORY</B> 2214 2215</FONT> 2216below). The default value is 500. 2217<DT><B>HISTTIMEFORMAT</B> 2218 2219<DD> 2220If this variable is set and not null, its value is used as a format string 2221for <I>strftime</I>(3) to print the time stamp associated with each history 2222entry displayed by the <B>history</B> builtin. 2223If this variable is set, time stamps are written to the history file so 2224they may be preserved across shell sessions. 2225<DT><B>HOME</B> 2226 2227<DD> 2228The home directory of the current user; the default argument for the 2229<B>cd</B> builtin command. 2230The value of this variable is also used when performing tilde expansion. 2231<DT><B>HOSTFILE</B> 2232 2233<DD> 2234Contains the name of a file in the same format as 2235 2236<I>/etc/hosts</I> 2237 2238that should be read when the shell needs to complete a 2239hostname. 2240The list of possible hostname completions may be changed while the 2241shell is running; 2242the next time hostname completion is attempted after the 2243value is changed, 2244<B>bash</B> 2245 2246adds the contents of the new file to the existing list. 2247If 2248<FONT SIZE=-1><B>HOSTFILE</B> 2249 2250</FONT> 2251is set, but has no value, <B>bash</B> attempts to read 2252 2253<I>/etc/hosts</I> 2254 2255to obtain the list of possible hostname completions. 2256When 2257<FONT SIZE=-1><B>HOSTFILE</B> 2258 2259</FONT> 2260is unset, the hostname list is cleared. 2261<DT><B>IFS</B> 2262 2263<DD> 2264The 2265<I>Internal Field Separator</I> 2266 2267that is used 2268for word splitting after expansion and to 2269split lines into words with the 2270<B>read</B> 2271 2272builtin command. The default value is 2273``<space><tab><newline>''. 2274<DT><B>IGNOREEOF</B> 2275 2276<DD> 2277Controls the 2278action of an interactive shell on receipt of an 2279<FONT SIZE=-1><B>EOF</B> 2280 2281</FONT> 2282character as the sole input. If set, the value is the number of 2283consecutive 2284<FONT SIZE=-1><B>EOF</B> 2285 2286</FONT> 2287characters which must be 2288typed as the first characters on an input line before 2289<B>bash</B> 2290 2291exits. If the variable exists but does not have a numeric value, or 2292has no value, the default value is 10. If it does not exist, 2293<FONT SIZE=-1><B>EOF</B> 2294 2295</FONT> 2296signifies the end of input to the shell. 2297<DT><B>INPUTRC</B> 2298 2299<DD> 2300The filename for the 2301<B>readline</B> 2302 2303startup file, overriding the default of 2304 2305<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A> 2306 2307(see 2308<FONT SIZE=-1><B>READLINE</B> 2309 2310</FONT> 2311below). 2312<DT><B>LANG</B> 2313 2314<DD> 2315Used to determine the locale category for any category not specifically 2316selected with a variable starting with <B>LC_</B>. 2317<DT><B>LC_ALL</B> 2318 2319<DD> 2320This variable overrides the value of <B>LANG</B> and any other 2321<B>LC_</B> variable specifying a locale category. 2322<DT><B>LC_COLLATE</B> 2323 2324<DD> 2325This variable determines the collation order used when sorting the 2326results of pathname expansion, and determines the behavior of range 2327expressions, equivalence classes, and collating sequences within 2328pathname expansion and pattern matching. 2329<DT><B>LC_CTYPE</B> 2330 2331<DD> 2332This variable determines the interpretation of characters and the 2333behavior of character classes within pathname expansion and pattern 2334matching. 2335<DT><B>LC_MESSAGES</B> 2336 2337<DD> 2338This variable determines the locale used to translate double-quoted 2339strings preceded by a <B>$</B>. 2340<DT><B>LC_NUMERIC</B> 2341 2342<DD> 2343This variable determines the locale category used for number formatting. 2344<DT><B>LINES</B> 2345 2346<DD> 2347Used by the <B>select</B> builtin command to determine the column length 2348for printing selection lists. Automatically set upon receipt of a SIGWINCH. 2349<DT><B>MAIL</B> 2350 2351<DD> 2352If this parameter is set to a file name and the 2353<FONT SIZE=-1><B>MAILPATH</B> 2354 2355</FONT> 2356variable is not set, 2357<B>bash</B> 2358 2359informs the user of the arrival of mail in the specified file. 2360<DT><B>MAILCHECK</B> 2361 2362<DD> 2363Specifies how 2364often (in seconds) 2365<B>bash</B> 2366 2367checks for mail. The default is 60 seconds. When it is time to check 2368for mail, the shell does so before displaying the primary prompt. 2369If this variable is unset, or set to a value that is not a number 2370greater than or equal to zero, the shell disables mail checking. 2371<DT><B>MAILPATH</B> 2372 2373<DD> 2374A colon-separated list of file names to be checked for mail. 2375The message to be printed when mail arrives in a particular file 2376may be specified by separating the file name from the message with a `?'. 2377When used in the text of the message, <B>$_</B> expands to the name of 2378the current mailfile. 2379Example: 2380<DL COMPACT><DT><DD> 2381<P> 2382 2383<B>MAILPATH</B>='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"' 2384<P> 2385 2386<B>Bash</B> 2387 2388supplies a default value for this variable, but the location of the user 2389mail files that it uses is system dependent (e.g., /var/mail/<B>$USER</B>). 2390</DL> 2391 2392<DT><B>OPTERR</B> 2393 2394<DD> 2395If set to the value 1, 2396<B>bash</B> 2397 2398displays error messages generated by the 2399<B>getopts</B> 2400 2401builtin command (see 2402<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 2403 2404</FONT> 2405below). 2406<FONT SIZE=-1><B>OPTERR</B> 2407 2408</FONT> 2409is initialized to 1 each time the shell is invoked or a shell 2410script is executed. 2411<DT><B>PATH</B> 2412 2413<DD> 2414The search path for commands. It 2415is a colon-separated list of directories in which 2416the shell looks for commands (see 2417<FONT SIZE=-1><B>COMMAND EXECUTION</B> 2418 2419</FONT> 2420below). 2421A zero-length (null) directory name in the value of <B>PATH</B> indicates the 2422current directory. 2423A null directory name may appear as two adjacent colons, or as an initial 2424or trailing colon. 2425The default path is system-dependent, 2426and is set by the administrator who installs 2427<B>bash</B>. 2428 2429A common value is 2430<TT>/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin</TT>. 2431 2432<DT><B>POSIXLY_CORRECT</B> 2433 2434<DD> 2435If this variable is in the environment when <B>bash</B> starts, the shell 2436enters <I>posix mode</I> before reading the startup files, as if the 2437<B>--posix</B> 2438 2439invocation option had been supplied. If it is set while the shell is 2440running, <B>bash</B> enables <I>posix mode</I>, as if the command 2441<TT>set -o posix</TT> 2442 2443had been executed. 2444<DT><B>PROMPT_COMMAND</B> 2445 2446<DD> 2447If set, the value is executed as a command prior to issuing each primary 2448prompt. 2449<DT><B>PS1</B> 2450 2451<DD> 2452The value of this parameter is expanded (see 2453<FONT SIZE=-1><B>PROMPTING</B> 2454 2455</FONT> 2456below) and used as the primary prompt string. The default value is 2457``<B>\s-\v\$ </B>''. 2458<DT><B>PS2</B> 2459 2460<DD> 2461The value of this parameter is expanded as with 2462<B>PS1</B> 2463 2464and used as the secondary prompt string. The default is 2465``<B>> </B>''. 2466<DT><B>PS3</B> 2467 2468<DD> 2469The value of this parameter is used as the prompt for the 2470<B>select</B> 2471 2472command (see 2473<FONT SIZE=-1><B>SHELL GRAMMAR</B> 2474 2475</FONT> 2476above). 2477<DT><B>PS4</B> 2478 2479<DD> 2480The value of this parameter is expanded as with 2481<B>PS1</B> 2482 2483and the value is printed before each command 2484<B>bash</B> 2485 2486displays during an execution trace. The first character of 2487<FONT SIZE=-1><B>PS4</B> 2488 2489</FONT> 2490is replicated multiple times, as necessary, to indicate multiple 2491levels of indirection. The default is ``<B>+ </B>''. 2492<DT><B>SHELL</B> 2493 2494<DD> 2495The full pathname to the shell is kept in this environment variable. 2496If it is not set when the shell starts, 2497<B>bash</B> 2498 2499assigns to it the full pathname of the current user's login shell. 2500<DT><B>TIMEFORMAT</B> 2501 2502<DD> 2503The value of this parameter is used as a format string specifying 2504how the timing information for pipelines prefixed with the 2505<B>time</B> 2506 2507reserved word should be displayed. 2508The <B>%</B> character introduces an escape sequence that is 2509expanded to a time value or other information. 2510The escape sequences and their meanings are as follows; the 2511braces denote optional portions. 2512<P> 2513<DL COMPACT><DT><DD> 2514 2515<DL COMPACT> 2516<DT><B>%%</B> 2517 2518<DD> 2519A literal <B>%</B>. 2520<DT><B>%[</B><I>p</I>][l]R 2521 2522<DD> 2523The elapsed time in seconds. 2524<DT><B>%[</B><I>p</I>][l]U 2525 2526<DD> 2527The number of CPU seconds spent in user mode. 2528<DT><B>%[</B><I>p</I>][l]S 2529 2530<DD> 2531The number of CPU seconds spent in system mode. 2532<DT><B>%P</B> 2533 2534<DD> 2535The CPU percentage, computed as (%U + %S) / %R. 2536 2537</DL></DL> 2538 2539<DT><DD> 2540The optional <I>p</I> is a digit specifying the <I>precision</I>, 2541the number of fractional digits after a decimal point. 2542A value of 0 causes no decimal point or fraction to be output. 2543At most three places after the decimal point may be specified; 2544values of <I>p</I> greater than 3 are changed to 3. 2545If <I>p</I> is not specified, the value 3 is used. 2546<DT><DD> 2547The optional <B>l</B> specifies a longer format, including 2548minutes, of the form <I>MM</I>m<I>SS</I>.<I>FF</I>s. 2549The value of <I>p</I> determines whether or not the fraction is 2550included. 2551<DT><DD> 2552If this variable is not set, <B>bash</B> acts as if it had the 2553value <B>$'\nreal\t%3lR\nuser\t%3lU\nsys %3lS'</B>. 2554If the value is null, no timing information is displayed. 2555A trailing newline is added when the format string is displayed. 2556<DT><B>TMOUT</B> 2557 2558<DD> 2559If set to a value greater than zero, <B>TMOUT</B> is treated as the 2560default timeout for the <B>read</B> builtin. 2561The <B>select</B> command terminates if input does not arrive 2562after <B>TMOUT</B> seconds when input is coming from a terminal. 2563In an interactive shell, the value is interpreted as the 2564number of seconds to wait for input after issuing the primary prompt. 2565<B>Bash</B> 2566 2567terminates after waiting for that number of seconds if input does 2568not arrive. 2569<DT><B>TMPDIR</B> 2570 2571<DD> 2572If set, <B>Bash</B> uses its value as the name of a directory in which 2573<B>Bash</B> creates temporary files for the shell's use. 2574<DT><B>auto_resume</B> 2575 2576<DD> 2577This variable controls how the shell interacts with the user and 2578job control. If this variable is set, single word simple 2579commands without redirections are treated as candidates for resumption 2580of an existing stopped job. There is no ambiguity allowed; if there is 2581more than one job beginning with the string typed, the job most recently 2582accessed is selected. The 2583<I>name</I> 2584 2585of a stopped job, in this context, is the command line used to 2586start it. 2587If set to the value 2588<I>exact</I>, 2589 2590the string supplied must match the name of a stopped job exactly; 2591if set to 2592<I>substring</I>, 2593 2594the string supplied needs to match a substring of the name of a 2595stopped job. The 2596<I>substring</I> 2597 2598value provides functionality analogous to the 2599<B>%?</B> 2600 2601job identifier (see 2602<FONT SIZE=-1><B>JOB CONTROL</B> 2603 2604</FONT> 2605below). If set to any other value, the supplied string must 2606be a prefix of a stopped job's name; this provides functionality 2607analogous to the <B>%</B><I>string</I> job identifier. 2608<DT><B>histchars</B> 2609 2610<DD> 2611The two or three characters which control history expansion 2612and tokenization (see 2613<FONT SIZE=-1><B>HISTORY EXPANSION</B> 2614 2615</FONT> 2616below). The first character is the <I>history expansion</I> character, 2617the character which signals the start of a history 2618expansion, normally `<B>!</B>'. 2619The second character is the <I>quick substitution</I> 2620character, which is used as shorthand for re-running the previous 2621command entered, substituting one string for another in the command. 2622The default is `<B>^</B>'. 2623The optional third character is the character 2624which indicates that the remainder of the line is a comment when found 2625as the first character of a word, normally `<B>#</B>'. The history 2626comment character causes history substitution to be skipped for the 2627remaining words on the line. It does not necessarily cause the shell 2628parser to treat the rest of the line as a comment. 2629 2630</DL> 2631<A NAME="lbAW"> </A> 2632<H4>Arrays</H4> 2633 2634<B>Bash</B> 2635 2636provides one-dimensional array variables. Any variable may be used as 2637an array; the 2638<B>declare</B> 2639 2640builtin will explicitly declare an array. There is no maximum 2641limit on the size of an array, nor any requirement that members 2642be indexed or assigned contiguously. Arrays are indexed using 2643integers and are zero-based. 2644<P> 2645 2646An array is created automatically if any variable is assigned to using 2647the syntax <I>name</I>[<I>subscript</I>]=<I>value</I>. The 2648<I>subscript</I> 2649 2650is treated as an arithmetic expression that must evaluate to a number 2651greater than or equal to zero. To explicitly declare an array, use 2652<B>declare -a </B><I>name</I> 2653 2654(see 2655<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 2656 2657</FONT> 2658below). 2659<B>declare -a </B><I>name</I>[<I>subscript</I>] 2660 2661is also accepted; the <I>subscript</I> is ignored. Attributes may be 2662specified for an array variable using the 2663<B>declare</B> 2664 2665and 2666<B>readonly</B> 2667 2668builtins. Each attribute applies to all members of an array. 2669<P> 2670 2671Arrays are assigned to using compound assignments of the form 2672<I>name</I>=<B>(</B>value<I>1</I> ... value<I>n</I><B>)</B>, where each 2673<I>value</I> is of the form [<I>subscript</I>]=<I>string</I>. Only 2674<I>string</I> is required. If 2675the optional brackets and subscript are supplied, that index is assigned to; 2676otherwise the index of the element assigned is the last index assigned 2677to by the statement plus one. Indexing starts at zero. 2678This syntax is also accepted by the 2679<B>declare</B> 2680 2681builtin. Individual array elements may be assigned to using the 2682<I>name</I>[<I>subscript</I>]=<I>value</I> syntax introduced above. 2683<P> 2684 2685Any element of an array may be referenced using 2686${<I>name</I>[<I>subscript</I>]}. The braces are required to avoid 2687conflicts with pathname expansion. If 2688<I>subscript</I> is <B>@</B> or <B>*</B>, the word expands to 2689all members of <I>name</I>. These subscripts differ only when the 2690word appears within double quotes. If the word is double-quoted, 2691${<I>name</I>[*]} expands to a single 2692word with the value of each array member separated by the first 2693character of the 2694<FONT SIZE=-1><B>IFS</B> 2695 2696</FONT> 2697special variable, and ${<I>name</I>[@]} expands each element of 2698<I>name</I> to a separate word. When there are no array members, 2699${<I>name</I>[@]} expands to nothing. 2700If the double-quoted expansion occurs within a word, the expansion of 2701the first parameter is joined with the beginning part of the original 2702word, and the expansion of the last parameter is joined with the last 2703part of the original word. 2704This is analogous to the expansion 2705of the special parameters <B>*</B> and <B>@</B> (see 2706<B>Special Parameters</B> 2707 2708above). ${#<I>name</I>[<I>subscript</I>]} expands to the length of 2709${<I>name</I>[<I>subscript</I>]}. If <I>subscript</I> is <B>*</B> or 2710<B>@</B>, the expansion is the number of elements in the array. 2711Referencing an array variable without a subscript is equivalent to 2712referencing element zero. 2713<P> 2714 2715The 2716<B>unset</B> 2717 2718builtin is used to destroy arrays. <B>unset</B> <I>name</I>[<I>subscript</I>] 2719destroys the array element at index <I>subscript</I>. 2720Care must be taken to avoid unwanted side effects caused by filename 2721generation. 2722<B>unset</B> <I>name</I>, where <I>name</I> is an array, or 2723<B>unset</B> <I>name</I>[<I>subscript</I>], where 2724<I>subscript</I> is <B>*</B> or <B>@</B>, removes the entire array. 2725<P> 2726 2727The 2728<B>declare</B>, 2729 2730<B>local</B>, 2731 2732and 2733<B>readonly</B> 2734 2735builtins each accept a 2736<B>-a</B> 2737 2738option to specify an array. The 2739<B>read</B> 2740 2741builtin accepts a 2742<B>-a</B> 2743 2744option to assign a list of words read from the standard input 2745to an array. The 2746<B>set</B> 2747 2748and 2749<B>declare</B> 2750 2751builtins display array values in a way that allows them to be 2752reused as assignments. 2753<A NAME="lbAX"> </A> 2754<H3>EXPANSION</H3> 2755 2756Expansion is performed on the command line after it has been split into 2757words. There are seven kinds of expansion performed: 2758<I>brace expansion</I>, 2759 2760<I>tilde expansion</I>, 2761 2762<I>parameter and variable expansion</I>, 2763 2764<I>command substitution</I>, 2765 2766<I>arithmetic expansion</I>, 2767 2768<I>word splitting</I>, 2769 2770and 2771<I>pathname expansion</I>. 2772 2773<P> 2774 2775The order of expansions is: brace expansion, tilde expansion, 2776parameter, variable and arithmetic expansion and 2777command substitution 2778(done in a left-to-right fashion), word splitting, and pathname 2779expansion. 2780<P> 2781 2782On systems that can support it, there is an additional expansion 2783available: <I>process substitution</I>. 2784<P> 2785 2786Only brace expansion, word splitting, and pathname expansion 2787can change the number of words of the expansion; other expansions 2788expand a single word to a single word. 2789The only exceptions to this are the expansions of 2790"<B>$@</B>" and "<B>${</B><I>name</I><B>[@]}</B>" 2791as explained above (see 2792<FONT SIZE=-1><B>PARAMETERS</B>). 2793 2794</FONT> 2795<A NAME="lbAY"> </A> 2796<H4>Brace Expansion</H4> 2797 2798<P> 2799 2800<I>Brace expansion</I> 2801 2802is a mechanism by which arbitrary strings 2803may be generated. This mechanism is similar to 2804<I>pathname expansion</I>, but the filenames generated 2805need not exist. Patterns to be brace expanded take 2806the form of an optional 2807<I>preamble</I>, 2808 2809followed by either a series of comma-separated strings or 2810a sequence expression between a pair of braces, followed by 2811an optional 2812<I>postscript</I>. 2813 2814The preamble is prefixed to each string contained 2815within the braces, and the postscript is then appended 2816to each resulting string, expanding left to right. 2817<P> 2818 2819Brace expansions may be nested. The results of each expanded 2820string are not sorted; left to right order is preserved. 2821For example, a<B>{</B>d,c,b<B>}</B>e expands into `ade ace abe'. 2822<P> 2823 2824A sequence expression takes the form <B>{</B><I>x</I><B>..</B><I>y</I><B>}</B>, 2825where <I>x</I> and <I>y</I> are either integers or single characters. 2826When integers are supplied, the expression expands to each number between 2827<I>x</I> and <I>y</I>, inclusive. 2828When characters are supplied, the expression expands to each character 2829lexicographically between <I>x</I> and <I>y</I>, inclusive. Note that 2830both <I>x</I> and <I>y</I> must be of the same type. 2831<P> 2832 2833Brace expansion is performed before any other expansions, 2834and any characters special to other expansions are preserved 2835in the result. It is strictly textual. 2836<B>Bash</B> 2837 2838does not apply any syntactic interpretation to the context of the 2839expansion or the text between the braces. 2840<P> 2841 2842A correctly-formed brace expansion must contain unquoted opening 2843and closing braces, and at least one unquoted comma or a valid 2844sequence expression. 2845Any incorrectly formed brace expansion is left unchanged. 2846A <B>{</B> or <B>,</B> may be quoted with a backslash to prevent its 2847being considered part of a brace expression. 2848To avoid conflicts with parameter expansion, the string <B>${</B> 2849is not considered eligible for brace expansion. 2850<P> 2851 2852This construct is typically used as shorthand when the common 2853prefix of the strings to be generated is longer than in the 2854above example: 2855<DL COMPACT><DT><DD> 2856<P> 2857 2858mkdir /usr/local/src/bash/{old,new,dist,bugs} 2859</DL> 2860 2861or 2862<DL COMPACT><DT><DD> 2863chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} 2864</DL> 2865 2866<P> 2867 2868Brace expansion introduces a slight incompatibility with 2869historical versions of 2870<B>sh</B>. 2871 2872<B>sh</B> 2873 2874does not treat opening or closing braces specially when they 2875appear as part of a word, and preserves them in the output. 2876<B>Bash</B> 2877 2878removes braces from words as a consequence of brace 2879expansion. For example, a word entered to 2880<B>sh</B> 2881 2882as <I>file{1,2}</I> 2883appears identically in the output. The same word is 2884output as 2885<I>file1 file2</I> 2886 2887after expansion by 2888<B>bash</B>. 2889 2890If strict compatibility with 2891<B>sh</B> 2892 2893is desired, start 2894<B>bash</B> 2895 2896with the 2897<B>+B </B> 2898 2899option or disable brace expansion with the 2900<B>+B</B> 2901 2902option to the 2903<B>set</B> 2904 2905command (see 2906<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 2907 2908</FONT> 2909below). 2910<A NAME="lbAZ"> </A> 2911<H4>Tilde Expansion</H4> 2912 2913<P> 2914 2915If a word begins with an unquoted tilde character (`<B>~</B>'), all of 2916the characters preceding the first unquoted slash (or all characters, 2917if there is no unquoted slash) are considered a <I>tilde-prefix</I>. 2918If none of the characters in the tilde-prefix are quoted, the 2919characters in the tilde-prefix following the tilde are treated as a 2920possible <I>login name</I>. 2921If this login name is the null string, the tilde is replaced with the 2922value of the shell parameter 2923<FONT SIZE=-1><B>HOME</B>. 2924 2925</FONT> 2926If 2927<FONT SIZE=-1><B>HOME</B> 2928 2929</FONT> 2930is unset, the home directory of the user executing the shell is 2931substituted instead. 2932Otherwise, the tilde-prefix is replaced with the home directory 2933associated with the specified login name. 2934<P> 2935 2936If the tilde-prefix is a `~+', the value of the shell variable 2937<FONT SIZE=-1><B>PWD</B> 2938 2939</FONT> 2940replaces the tilde-prefix. 2941If the tilde-prefix is a `~-', the value of the shell variable 2942<FONT SIZE=-1><B>OLDPWD</B>, 2943 2944</FONT> 2945if it is set, is substituted. 2946If the characters following the tilde in the tilde-prefix consist 2947of a number <I>N</I>, optionally prefixed 2948by a `+' or a `-', the tilde-prefix is replaced with the corresponding 2949element from the directory stack, as it would be displayed by the 2950<B>dirs</B> 2951 2952builtin invoked with the tilde-prefix as an argument. 2953If the characters following the tilde in the tilde-prefix consist of a 2954number without a leading `+' or `-', `+' is assumed. 2955<P> 2956 2957If the login name is invalid, or the tilde expansion fails, the word 2958is unchanged. 2959<P> 2960 2961Each variable assignment is checked for unquoted tilde-prefixes immediately 2962following a 2963<B>:</B> 2964 2965or the first 2966<B>=</B>. 2967 2968In these cases, tilde expansion is also performed. 2969Consequently, one may use file names with tildes in assignments to 2970<FONT SIZE=-1><B>PATH</B>, 2971 2972</FONT> 2973<FONT SIZE=-1><B>MAILPATH</B>, 2974 2975</FONT> 2976and 2977<FONT SIZE=-1><B>CDPATH</B>, 2978 2979</FONT> 2980and the shell assigns the expanded value. 2981<A NAME="lbBA"> </A> 2982<H4>Parameter Expansion</H4> 2983 2984<P> 2985 2986The `<B>$</B>' character introduces parameter expansion, 2987command substitution, or arithmetic expansion. The parameter name 2988or symbol to be expanded may be enclosed in braces, which 2989are optional but serve to protect the variable to be expanded from 2990characters immediately following it which could be 2991interpreted as part of the name. 2992<P> 2993 2994When braces are used, the matching ending brace is the first `<B>}</B>' 2995not escaped by a backslash or within a quoted string, and not within an 2996embedded arithmetic expansion, command substitution, or parameter 2997expansion. 2998<P> 2999 3000 3001<DL COMPACT> 3002<DT>${<I>parameter</I>}<DD> 3003The value of <I>parameter</I> is substituted. The braces are required 3004when 3005<I>parameter</I> 3006 3007is a positional parameter with more than one digit, 3008or when 3009<I>parameter</I> 3010 3011is followed by a character which is not to be 3012interpreted as part of its name. 3013 3014</DL> 3015<P> 3016 3017If the first character of <I>parameter</I> is an exclamation point, 3018a level of variable indirection is introduced. 3019<B>Bash</B> uses the value of the variable formed from the rest of 3020<I>parameter</I> as the name of the variable; this variable is then 3021expanded and that value is used in the rest of the substitution, rather 3022than the value of <I>parameter</I> itself. 3023This is known as <I>indirect expansion</I>. 3024The exceptions to this are the expansions of ${!<I>prefix</I>*} and 3025${<B>!</B><I>name</I>[<I>@</I>]} described below. 3026The exclamation point must immediately follow the left brace in order to 3027introduce indirection. 3028<P> 3029 3030In each of the cases below, <I>word</I> is subject to tilde expansion, 3031parameter expansion, command substitution, and arithmetic expansion. 3032When not performing substring expansion, <B>bash</B> tests for a parameter 3033that is unset or null; omitting the colon results in a test only for a 3034parameter that is unset. 3035<P> 3036 3037 3038<DL COMPACT> 3039<DT>${<I>parameter</I><B>:-</B><I>word</I>}<DD> 3040<B>Use Default Values</B>. If 3041<I>parameter</I> 3042 3043is unset or null, the expansion of 3044<I>word</I> 3045 3046is substituted. Otherwise, the value of 3047<I>parameter</I> 3048 3049is substituted. 3050<DT>${<I>parameter</I><B>:=</B><I>word</I>}<DD> 3051<B>Assign Default Values</B>. 3052If 3053<I>parameter</I> 3054 3055is unset or null, the expansion of 3056<I>word</I> 3057 3058is assigned to 3059<I>parameter</I>. 3060 3061The value of 3062<I>parameter</I> 3063 3064is then substituted. Positional parameters and special parameters may 3065not be assigned to in this way. 3066<DT>${<I>parameter</I><B>:?</B><I>word</I>}<DD> 3067<B>Display Error if Null or Unset</B>. 3068If 3069<I>parameter</I> 3070 3071is null or unset, the expansion of <I>word</I> (or a message to that effect 3072if 3073<I>word</I> 3074 3075is not present) is written to the standard error and the shell, if it 3076is not interactive, exits. Otherwise, the value of <I>parameter</I> is 3077substituted. 3078<DT>${<I>parameter</I><B>:+</B><I>word</I>}<DD> 3079<B>Use Alternate Value</B>. 3080If 3081<I>parameter</I> 3082 3083is null or unset, nothing is substituted, otherwise the expansion of 3084<I>word</I> 3085 3086is substituted. 3087<DT>${<I>parameter</I><B>:</B><I>offset</I>}<DD> 3088 3089<DT>${<I>parameter</I><B>:</B><I>offset</I><B>:</B><I>length</I>}<DD> 3090 3091<B>Substring Expansion.</B> 3092Expands to up to <I>length</I> characters of <I>parameter</I> 3093starting at the character specified by <I>offset</I>. 3094If <I>length</I> is omitted, expands to the substring of 3095<I>parameter</I> starting at the character specified by <I>offset</I>. 3096<I>length</I> and <I>offset</I> are arithmetic expressions (see 3097<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B> 3098 3099</FONT> 3100below). 3101<I>length</I> must evaluate to a number greater than or equal to zero. 3102If <I>offset</I> evaluates to a number less than zero, the value 3103is used as an offset from the end of the value of <I>parameter</I>. 3104If <I>parameter</I> is <B>@</B>, the result is <I>length</I> positional 3105parameters beginning at <I>offset</I>. 3106If <I>parameter</I> is an array name indexed by @ or *, 3107the result is the <I>length</I> 3108members of the array beginning with ${<I>parameter</I>[<I>offset</I>]}. 3109A negative <I>offset</I> is taken relative to one greater than the maximum 3110index of the specified array. 3111Note that a negative offset must be separated from the colon by at least 3112one space to avoid being confused with the :- expansion. 3113Substring indexing is zero-based unless the positional parameters 3114are used, in which case the indexing starts at 1. 3115<DT>${<B>!</B><I>prefix</I><B>*</B>}<DD> 3116 3117<DT>${<B>!</B><I>prefix</I><B>@</B>}<DD> 3118 3119Expands to the names of variables whose names begin with <I>prefix</I>, 3120separated by the first character of the 3121<FONT SIZE=-1><B>IFS</B> 3122 3123</FONT> 3124special variable. 3125<DT>${<B>!</B><I>name</I>[<I>@</I>]}<DD> 3126 3127<DT>${<B>!</B><I>name</I>[<I>*</I>]}<DD> 3128 3129If <I>name</I> is an array variable, expands to the list of array indices 3130(keys) assigned in <I>name</I>. 3131If <I>name</I> is not an array, expands to 0 if <I>name</I> is set and null 3132otherwise. 3133When <I>@</I> is used and the expansion appears within double quotes, each 3134key expands to a separate word. 3135<DT>${<B>#</B><I>parameter</I>}<DD> 3136The length in characters of the value of <I>parameter</I> is substituted. 3137If 3138<I>parameter</I> 3139 3140is 3141<B>*</B> 3142 3143or 3144<B>@</B>, 3145 3146the value substituted is the number of positional parameters. 3147If 3148<I>parameter</I> 3149 3150is an array name subscripted by 3151<B>*</B> 3152 3153or 3154<B>@</B>, 3155 3156the value substituted is the number of elements in the array. 3157<DT>${<I>parameter</I><B>#</B><I>word</I>}<DD> 3158 3159<DT>${<I>parameter</I><B>##</B><I>word</I>}<DD> 3160 3161The 3162<I>word</I> 3163 3164is expanded to produce a pattern just as in pathname 3165expansion. If the pattern matches the beginning of 3166the value of 3167<I>parameter</I>, 3168 3169then the result of the expansion is the expanded value of 3170<I>parameter</I> 3171 3172with the shortest matching pattern (the ``<B>#</B>'' case) or the 3173longest matching pattern (the ``<B>##</B>'' case) deleted. 3174If 3175<I>parameter</I> 3176 3177is 3178<B>@</B> 3179 3180or 3181<B>*</B>, 3182 3183the pattern removal operation is applied to each positional 3184parameter in turn, and the expansion is the resultant list. 3185If 3186<I>parameter</I> 3187 3188is an array variable subscripted with 3189<B>@</B> 3190 3191or 3192<B>*</B>, 3193 3194the pattern removal operation is applied to each member of the 3195array in turn, and the expansion is the resultant list. 3196<DT>${<I>parameter</I><B>%</B><I>word</I>}<DD> 3197 3198<DT>${<I>parameter</I><B>%%</B><I>word</I>}<DD> 3199 3200The <I>word</I> is expanded to produce a pattern just as in 3201pathname expansion. 3202If the pattern matches a trailing portion of the expanded value of 3203<I>parameter</I>, 3204 3205then the result of the expansion is the expanded value of 3206<I>parameter</I> 3207 3208with the shortest matching pattern (the ``<B>%</B>'' case) or the 3209longest matching pattern (the ``<B>%%</B>'' case) deleted. 3210If 3211<I>parameter</I> 3212 3213is 3214<B>@</B> 3215 3216or 3217<B>*</B>, 3218 3219the pattern removal operation is applied to each positional 3220parameter in turn, and the expansion is the resultant list. 3221If 3222<I>parameter</I> 3223 3224is an array variable subscripted with 3225<B>@</B> 3226 3227or 3228<B>*</B>, 3229 3230the pattern removal operation is applied to each member of the 3231array in turn, and the expansion is the resultant list. 3232<DT>${<I>parameter</I><B>/</B><I>pattern</I><B>/</B><I>string</I>}<DD> 3233 3234<DT>${<I>parameter</I><B>//</B><I>pattern</I><B>/</B><I>string</I>}<DD> 3235 3236The <I>pattern</I> is expanded to produce a pattern just as in 3237pathname expansion. 3238<I>Parameter</I> is expanded and the longest match of <I>pattern</I> 3239against its value is replaced with <I>string</I>. 3240In the first form, only the first match is replaced. 3241The second form causes all matches of <I>pattern</I> to be 3242replaced with <I>string</I>. 3243If <I>pattern</I> begins with <B>#</B>, it must match at the beginning 3244of the expanded value of <I>parameter</I>. 3245If <I>pattern</I> begins with <B>%</B>, it must match at the end 3246of the expanded value of <I>parameter</I>. 3247If <I>string</I> is null, matches of <I>pattern</I> are deleted 3248and the <B>/</B> following <I>pattern</I> may be omitted. 3249If 3250<I>parameter</I> 3251 3252is 3253<B>@</B> 3254 3255or 3256<B>*</B>, 3257 3258the substitution operation is applied to each positional 3259parameter in turn, and the expansion is the resultant list. 3260If 3261<I>parameter</I> 3262 3263is an array variable subscripted with 3264<B>@</B> 3265 3266or 3267<B>*</B>, 3268 3269the substitution operation is applied to each member of the 3270array in turn, and the expansion is the resultant list. 3271</DL> 3272<A NAME="lbBB"> </A> 3273<H4>Command Substitution</H4> 3274 3275<P> 3276 3277<I>Command substitution</I> allows the output of a command to replace 3278the command name. There are two forms: 3279<P> 3280 3281<DL COMPACT><DT><DD> 3282<P> 3283 3284<B>$(</B><I>command</I><B>)</B> 3285</DL> 3286 3287or 3288<DL COMPACT><DT><DD> 3289<B>`</B><I>command</I><B>`</B> 3290</DL> 3291 3292<P> 3293 3294<B>Bash</B> 3295 3296performs the expansion by executing <I>command</I> and 3297replacing the command substitution with the standard output of the 3298command, with any trailing newlines deleted. 3299Embedded newlines are not deleted, but they may be removed during 3300word splitting. 3301The command substitution <B>$(cat </B><I>file</I>) can be replaced by 3302the equivalent but faster <B>$(< </B><I>file</I>). 3303<P> 3304 3305When the old-style backquote form of substitution is used, 3306backslash retains its literal meaning except when followed by 3307<B>$</B>, 3308 3309<B>`</B>, 3310 3311or 3312<B>\</B>. 3313 3314The first backquote not preceded by a backslash terminates the 3315command substitution. 3316When using the $(<I>command</I>) form, all characters between the 3317parentheses make up the command; none are treated specially. 3318<P> 3319 3320Command substitutions may be nested. To nest when using the backquoted form, 3321escape the inner backquotes with backslashes. 3322<P> 3323 3324If the substitution appears within double quotes, word splitting and 3325pathname expansion are not performed on the results. 3326<A NAME="lbBC"> </A> 3327<H4>Arithmetic Expansion</H4> 3328 3329<P> 3330 3331Arithmetic expansion allows the evaluation of an arithmetic expression 3332and the substitution of the result. The format for arithmetic expansion is: 3333<DL COMPACT><DT><DD> 3334<P> 3335 3336<B>$((</B><I>expression</I><B>))</B> 3337</DL> 3338 3339<P> 3340 3341The 3342<I>expression</I> 3343 3344is treated as if it were within double quotes, but a double quote 3345inside the parentheses is not treated specially. 3346All tokens in the expression undergo parameter expansion, string 3347expansion, command substitution, and quote removal. 3348Arithmetic expansions may be nested. 3349<P> 3350 3351The evaluation is performed according to the rules listed below under 3352<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>. 3353 3354</FONT> 3355If 3356<I>expression</I> 3357 3358is invalid, 3359<B>bash</B> 3360 3361prints a message indicating failure and no substitution occurs. 3362<A NAME="lbBD"> </A> 3363<H4>Process Substitution</H4> 3364 3365<P> 3366 3367<I>Process substitution</I> is supported on systems that support named 3368pipes (<I>FIFOs</I>) or the <B>/dev/fd</B> method of naming open files. 3369It takes the form of 3370<B><(</B><I>list</I><B>)</B> 3371or 3372<B>>(</B><I>list</I><B>)</B>. 3373The process <I>list</I> is run with its input or output connected to a 3374<I>FIFO</I> or some file in <B>/dev/fd</B>. The name of this file is 3375passed as an argument to the current command as the result of the 3376expansion. If the <B>>(</B><I>list</I><B>)</B> form is used, writing to 3377the file will provide input for <I>list</I>. If the 3378<B><(</B><I>list</I><B>)</B> form is used, the file passed as an 3379argument should be read to obtain the output of <I>list</I>. 3380<P> 3381 3382When available, process substitution is performed 3383simultaneously with parameter and variable expansion, 3384command substitution, 3385and arithmetic expansion. 3386<A NAME="lbBE"> </A> 3387<H4>Word Splitting</H4> 3388 3389<P> 3390 3391The shell scans the results of 3392parameter expansion, 3393command substitution, 3394and 3395arithmetic expansion 3396that did not occur within double quotes for 3397<I>word splitting</I>. 3398 3399<P> 3400 3401The shell treats each character of 3402<FONT SIZE=-1><B>IFS</B> 3403 3404</FONT> 3405as a delimiter, and splits the results of the other 3406expansions into words on these characters. If 3407<FONT SIZE=-1><B>IFS</B> 3408 3409</FONT> 3410is unset, or its 3411value is exactly 3412<B><space><tab><newline></B>, 3413 3414the default, then 3415any sequence of 3416<FONT SIZE=-1><B>IFS</B> 3417 3418</FONT> 3419characters serves to delimit words. If 3420<FONT SIZE=-1><B>IFS</B> 3421 3422</FONT> 3423has a value other than the default, then sequences of 3424the whitespace characters 3425<B>space</B> 3426 3427and 3428<B>tab</B> 3429 3430are ignored at the beginning and end of the 3431word, as long as the whitespace character is in the 3432value of 3433<FONT SIZE=-1><B>IFS</B> 3434 3435</FONT> 3436(an 3437<FONT SIZE=-1><B>IFS</B> 3438 3439</FONT> 3440whitespace character). 3441Any character in 3442<FONT SIZE=-1><B>IFS</B> 3443 3444</FONT> 3445that is not 3446<FONT SIZE=-1><B>IFS</B> 3447 3448</FONT> 3449whitespace, along with any adjacent 3450<FONT SIZE=-1><B>IFS</B> 3451 3452</FONT> 3453whitespace characters, delimits a field. 3454A sequence of 3455<FONT SIZE=-1><B>IFS</B> 3456 3457</FONT> 3458whitespace characters is also treated as a delimiter. 3459If the value of 3460<FONT SIZE=-1><B>IFS</B> 3461 3462</FONT> 3463is null, no word splitting occurs. 3464<P> 3465 3466Explicit null arguments (<B>""</B> or <B>''</B>) are retained. 3467Unquoted implicit null arguments, resulting from the expansion of 3468parameters that have no values, are removed. 3469If a parameter with no value is expanded within double quotes, a 3470null argument results and is retained. 3471<P> 3472 3473Note that if no expansion occurs, no splitting 3474is performed. 3475<A NAME="lbBF"> </A> 3476<H4>Pathname Expansion</H4> 3477 3478<P> 3479 3480After word splitting, 3481unless the 3482<B>-f</B> 3483 3484option has been set, 3485<B>bash</B> 3486 3487scans each word for the characters 3488<B>*</B>, 3489 3490<B>?</B>, 3491 3492and 3493<B>[</B>. 3494 3495If one of these characters appears, then the word is 3496regarded as a 3497<I>pattern</I>, 3498 3499and replaced with an alphabetically sorted list of 3500file names matching the pattern. 3501If no matching file names are found, 3502and the shell option 3503<B>nullglob</B> 3504 3505is disabled, the word is left unchanged. 3506If the 3507<B>nullglob</B> 3508 3509option is set, and no matches are found, 3510the word is removed. 3511If the 3512<B>failglob</B> 3513 3514shell option is set, and no matches are found, an error message 3515is printed and the command is not executed. 3516If the shell option 3517<B>nocaseglob</B> 3518 3519is enabled, the match is performed without regard to the case 3520of alphabetic characters. 3521When a pattern is used for pathname expansion, 3522the character 3523<B>``.''</B> 3524 3525at the start of a name or immediately following a slash 3526must be matched explicitly, unless the shell option 3527<B>dotglob</B> 3528 3529is set. 3530When matching a pathname, the slash character must always be 3531matched explicitly. 3532In other cases, the 3533<B>``.''</B> 3534 3535character is not treated specially. 3536See the description of 3537<B>shopt</B> 3538 3539below under 3540<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 3541 3542</FONT> 3543for a description of the 3544<B>nocaseglob</B>, 3545 3546<B>nullglob</B>, 3547 3548<B>failglob</B>, 3549 3550and 3551<B>dotglob</B> 3552 3553shell options. 3554<P> 3555 3556The 3557<FONT SIZE=-1><B>GLOBIGNORE</B> 3558 3559</FONT> 3560shell variable may be used to restrict the set of file names matching a 3561<I>pattern</I>. 3562 3563If 3564<FONT SIZE=-1><B>GLOBIGNORE</B> 3565 3566</FONT> 3567is set, each matching file name that also matches one of the patterns in 3568<FONT SIZE=-1><B>GLOBIGNORE</B> 3569 3570</FONT> 3571is removed from the list of matches. 3572The file names 3573<B>``.''</B> 3574 3575and 3576<B>``..''</B> 3577 3578are always ignored when 3579<FONT SIZE=-1><B>GLOBIGNORE</B> 3580 3581</FONT> 3582is set and not null. However, setting 3583<FONT SIZE=-1><B>GLOBIGNORE</B> 3584 3585</FONT> 3586to a non-null value has the effect of enabling the 3587<B>dotglob</B> 3588 3589shell option, so all other file names beginning with a 3590<B>``.''</B> 3591 3592will match. 3593To get the old behavior of ignoring file names beginning with a 3594<B>``.''</B>, 3595 3596make 3597<B>``.*''</B> 3598 3599one of the patterns in 3600<FONT SIZE=-1><B>GLOBIGNORE</B>. 3601 3602</FONT> 3603The 3604<B>dotglob</B> 3605 3606option is disabled when 3607<FONT SIZE=-1><B>GLOBIGNORE</B> 3608 3609</FONT> 3610is unset. 3611<P> 3612 3613<B>Pattern Matching</B> 3614<P> 3615 3616Any character that appears in a pattern, other than the special pattern 3617characters described below, matches itself. The NUL character may not 3618occur in a pattern. A backslash escapes the following character; the 3619escaping backslash is discarded when matching. 3620The special pattern characters must be quoted if 3621they are to be matched literally. 3622<P> 3623 3624The special pattern characters have the following meanings: 3625<P> 3626 3627 3628<DL COMPACT> 3629<DT><B>*</B> 3630 3631<DD> 3632Matches any string, including the null string. 3633<DT><B>?</B> 3634 3635<DD> 3636Matches any single character. 3637<DT><B>[...]</B> 3638 3639<DD> 3640Matches any one of the enclosed characters. A pair of characters 3641separated by a hyphen denotes a 3642<I>range expression</I>; 3643any character that sorts between those two characters, inclusive, 3644using the current locale's collating sequence and character set, 3645is matched. If the first character following the 3646<B>[</B> 3647 3648is a 3649<B>!</B> 3650 3651or a 3652<B>^</B> 3653 3654then any character not enclosed is matched. 3655The sorting order of characters in range expressions is determined by 3656the current locale and the value of the <B>LC_COLLATE</B> shell variable, 3657if set. 3658A 3659<B>-</B> 3660 3661may be matched by including it as the first or last character 3662in the set. 3663A 3664<B>]</B> 3665 3666may be matched by including it as the first character 3667in the set. 3668<BR> 3669 3670<P> 3671 3672 3673Within 3674<B>[</B> 3675 3676and 3677<B>]</B>, 3678 3679<I>character classes</I> can be specified using the syntax 3680<B>[:</B><I>class</I><B>:]</B>, where <I>class</I> is one of the 3681following classes defined in the POSIX.2 standard: 3682</DL> 3683<P> 3684 3685<DL COMPACT><DT><DD> 3686<B> 3687</B> 3688 3689alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit 3690<BR> 3691 3692A character class matches any character belonging to that class. 3693The <B>word</B> character class matches letters, digits, and the character _. 3694<BR> 3695 3696<P> 3697 3698 3699Within 3700<B>[</B> 3701 3702and 3703<B>]</B>, 3704 3705an <I>equivalence class</I> can be specified using the syntax 3706<B>[=</B><I>c</I><B>=]</B>, which matches all characters with the 3707same collation weight (as defined by the current locale) as 3708the character <I>c</I>. 3709<BR> 3710 3711<P> 3712 3713 3714Within 3715<B>[</B> 3716 3717and 3718<B>]</B>, 3719 3720the syntax <B>[.</B><I>symbol</I><B>.]</B> matches the collating symbol 3721<I>symbol</I>. 3722</DL> 3723 3724 3725<P> 3726 3727If the <B>extglob</B> shell option is enabled using the <B>shopt</B> 3728builtin, several extended pattern matching operators are recognized. 3729In the following description, a <I>pattern-list</I> is a list of one 3730or more patterns separated by a <B>|</B>. 3731Composite patterns may be formed using one or more of the following 3732sub-patterns: 3733<P> 3734 3735<DL COMPACT><DT><DD> 3736<DL COMPACT> 3737<DT><B>?(</B><I>pattern-list</I><B>)</B><DD> 3738Matches zero or one occurrence of the given patterns 3739<DT><B>*(</B><I>pattern-list</I><B>)</B><DD> 3740Matches zero or more occurrences of the given patterns 3741<DT><B>+(</B><I>pattern-list</I><B>)</B><DD> 3742Matches one or more occurrences of the given patterns 3743<DT><B>@(</B><I>pattern-list</I><B>)</B><DD> 3744Matches one of the given patterns 3745<DT><B>!(</B><I>pattern-list</I><B>)</B><DD> 3746Matches anything except one of the given patterns 3747</DL></DL> 3748 3749 3750<A NAME="lbBG"> </A> 3751<H4>Quote Removal</H4> 3752 3753<P> 3754 3755After the preceding expansions, all unquoted occurrences of the 3756characters 3757<B>\</B>, 3758 3759<B>'</B>, 3760 3761and <B>"</B> that did not result from one of the above 3762expansions are removed. 3763<A NAME="lbBH"> </A> 3764<H3>REDIRECTION</H3> 3765 3766Before a command is executed, its input and output 3767may be 3768<I>redirected</I> 3769 3770using a special notation interpreted by the shell. 3771Redirection may also be used to open and close files for the 3772current shell execution environment. The following redirection 3773operators may precede or appear anywhere within a 3774<I>simple command</I> 3775 3776or may follow a 3777<I>command</I>. 3778 3779Redirections are processed in the order they appear, from 3780left to right. 3781<P> 3782 3783In the following descriptions, if the file descriptor number is 3784omitted, and the first character of the redirection operator is 3785<B><</B>, 3786 3787the redirection refers to the standard input (file descriptor 37880). If the first character of the redirection operator is 3789<B>></B>, 3790 3791the redirection refers to the standard output (file descriptor 37921). 3793<P> 3794 3795The word following the redirection operator in the following 3796descriptions, unless otherwise noted, is subjected to brace expansion, 3797tilde expansion, parameter expansion, command substitution, arithmetic 3798expansion, quote removal, pathname expansion, and word splitting. 3799If it expands to more than one word, 3800<B>bash</B> 3801 3802reports an error. 3803<P> 3804 3805Note that the order of redirections is significant. For example, 3806the command 3807<DL COMPACT><DT><DD> 3808<P> 3809 3810ls <B>></B> dirlist 2<B>>&</B>1 3811</DL> 3812 3813<P> 3814 3815directs both standard output and standard error to the file 3816<I>dirlist</I>, 3817 3818while the command 3819<DL COMPACT><DT><DD> 3820<P> 3821 3822ls 2<B>>&</B>1 <B>></B> dirlist 3823</DL> 3824 3825<P> 3826 3827directs only the standard output to file 3828<I>dirlist</I>, 3829 3830because the standard error was duplicated as standard output 3831before the standard output was redirected to 3832<I>dirlist</I>. 3833 3834<P> 3835 3836<B>Bash</B> handles several filenames specially when they are used in 3837redirections, as described in the following table: 3838<DL COMPACT><DT><DD> 3839<P> 3840 3841 3842<DL COMPACT> 3843<DT><B>/dev/fd/</B><I>fd</I> 3844 3845<DD> 3846If <I>fd</I> is a valid integer, file descriptor <I>fd</I> is duplicated. 3847<DT><B>/dev/stdin</B> 3848 3849<DD> 3850File descriptor 0 is duplicated. 3851<DT><B>/dev/stdout</B> 3852 3853<DD> 3854File descriptor 1 is duplicated. 3855<DT><B>/dev/stderr</B> 3856 3857<DD> 3858File descriptor 2 is duplicated. 3859<DT><B>/dev/tcp/</B><I>host</I>/<I>port</I> 3860 3861<DD> 3862If <I>host</I> is a valid hostname or Internet address, and <I>port</I> 3863is an integer port number or service name, <B>bash</B> attempts to open 3864a TCP connection to the corresponding socket. 3865<DT><B>/dev/udp/</B><I>host</I>/<I>port</I> 3866 3867<DD> 3868If <I>host</I> is a valid hostname or Internet address, and <I>port</I> 3869is an integer port number or service name, <B>bash</B> attempts to open 3870a UDP connection to the corresponding socket. 3871 3872</DL></DL> 3873 3874<P> 3875 3876A failure to open or create a file causes the redirection to fail. 3877<P> 3878 3879Redirections using file descriptors greater than 9 should be used with 3880care, as they may conflict with file descriptors the shell uses 3881internally. 3882<A NAME="lbBI"> </A> 3883<H4>Redirecting Input</H4> 3884 3885<P> 3886 3887Redirection of input causes the file whose name results from 3888the expansion of 3889<I>word</I> 3890 3891to be opened for reading on file descriptor 3892<I>n</I>, 3893 3894or the standard input (file descriptor 0) if 3895<I>n</I> 3896 3897is not specified. 3898<P> 3899 3900The general format for redirecting input is: 3901<DL COMPACT><DT><DD> 3902<P> 3903 3904[<I>n</I>]<B><</B><I>word</I> 3905</DL> 3906 3907<A NAME="lbBJ"> </A> 3908<H4>Redirecting Output</H4> 3909 3910<P> 3911 3912Redirection of output causes the file whose name results from 3913the expansion of 3914<I>word</I> 3915 3916to be opened for writing on file descriptor 3917<I>n</I>, 3918 3919or the standard output (file descriptor 1) if 3920<I>n</I> 3921 3922is not specified. If the file does not exist it is created; 3923if it does exist it is truncated to zero size. 3924<P> 3925 3926The general format for redirecting output is: 3927<DL COMPACT><DT><DD> 3928<P> 3929 3930[<I>n</I>]<B>></B><I>word</I> 3931</DL> 3932 3933<P> 3934 3935If the redirection operator is 3936<B>></B>, 3937 3938and the 3939<B>noclobber</B> 3940 3941option to the 3942<B>set</B> 3943 3944builtin has been enabled, the redirection will fail if the file 3945whose name results from the expansion of <I>word</I> exists and is 3946a regular file. 3947If the redirection operator is 3948<B>>|</B>, 3949 3950or the redirection operator is 3951<B>></B> 3952 3953and the 3954<B>noclobber</B> 3955 3956option to the 3957<B>set</B> 3958 3959builtin command is not enabled, the redirection is attempted even 3960if the file named by <I>word</I> exists. 3961<A NAME="lbBK"> </A> 3962<H4>Appending Redirected Output</H4> 3963 3964<P> 3965 3966Redirection of output in this fashion 3967causes the file whose name results from 3968the expansion of 3969<I>word</I> 3970 3971to be opened for appending on file descriptor 3972<I>n</I>, 3973 3974or the standard output (file descriptor 1) if 3975<I>n</I> 3976 3977is not specified. If the file does not exist it is created. 3978<P> 3979 3980The general format for appending output is: 3981<DL COMPACT><DT><DD> 3982<P> 3983 3984[<I>n</I>]<B>>></B><I>word</I> 3985</DL> 3986 3987<P> 3988 3989<A NAME="lbBL"> </A> 3990<H4>Redirecting Standard Output and Standard Error</H4> 3991 3992<P> 3993 3994<B>Bash</B> 3995 3996allows both the 3997standard output (file descriptor 1) and 3998the standard error output (file descriptor 2) 3999to be redirected to the file whose name is the 4000expansion of 4001<I>word</I> 4002 4003with this construct. 4004<P> 4005 4006There are two formats for redirecting standard output and 4007standard error: 4008<DL COMPACT><DT><DD> 4009<P> 4010 4011<B>&></B><I>word</I> 4012</DL> 4013 4014and 4015<DL COMPACT><DT><DD> 4016<B>>&</B><I>word</I> 4017</DL> 4018 4019<P> 4020 4021Of the two forms, the first is preferred. 4022This is semantically equivalent to 4023<DL COMPACT><DT><DD> 4024<P> 4025 4026<B>></B><I>word</I> 2<B>>&</B>1 4027</DL> 4028 4029<A NAME="lbBM"> </A> 4030<H4>Here Documents</H4> 4031 4032<P> 4033 4034This type of redirection instructs the shell to read input from the 4035current source until a line containing only 4036<I>word</I> 4037 4038(with no trailing blanks) 4039is seen. All of 4040the lines read up to that point are then used as the standard 4041input for a command. 4042<P> 4043 4044The format of here-documents is: 4045<DL COMPACT><DT><DD> 4046<P> 4047 4048<PRE> 4049<B><<</B>[<B>-</B>]<I>word</I> 4050 <I>here-document</I> 4051<I>delimiter</I> 4052</PRE> 4053 4054</DL> 4055 4056<P> 4057 4058No parameter expansion, command substitution, arithmetic expansion, 4059or pathname expansion is performed on 4060<I>word</I>. 4061 4062If any characters in 4063<I>word</I> 4064 4065are quoted, the 4066<I>delimiter</I> 4067 4068is the result of quote removal on 4069<I>word</I>, 4070 4071and the lines in the here-document are not expanded. 4072If <I>word</I> is unquoted, 4073all lines of the here-document are subjected to parameter expansion, 4074command substitution, and arithmetic expansion. In the latter 4075case, the character sequence 4076<B>\<newline></B> 4077 4078is ignored, and 4079<B>\</B> 4080 4081must be used to quote the characters 4082<B>\</B>, 4083 4084<B>$</B>, 4085 4086and 4087<B>`</B>. 4088 4089<P> 4090 4091If the redirection operator is 4092<B><<-</B>, 4093 4094then all leading tab characters are stripped from input lines and the 4095line containing 4096<I>delimiter</I>. 4097 4098This allows 4099here-documents within shell scripts to be indented in a 4100natural fashion. 4101<A NAME="lbBN"> </A> 4102<H4>Here Strings</H4> 4103 4104A variant of here documents, the format is: 4105<DL COMPACT><DT><DD> 4106<P> 4107 4108<PRE> 4109<B><<<</B><I>word</I> 4110</PRE> 4111 4112</DL> 4113 4114<P> 4115 4116The <I>word</I> is expanded and supplied to the command on its standard 4117input. 4118<A NAME="lbBO"> </A> 4119<H4>Duplicating File Descriptors</H4> 4120 4121<P> 4122 4123The redirection operator 4124<DL COMPACT><DT><DD> 4125<P> 4126 4127[<I>n</I>]<B><&</B><I>word</I> 4128</DL> 4129 4130<P> 4131 4132is used to duplicate input file descriptors. 4133If 4134<I>word</I> 4135 4136expands to one or more digits, the file descriptor denoted by 4137<I>n</I> 4138 4139is made to be a copy of that file descriptor. 4140If the digits in 4141<I>word</I> 4142 4143do not specify a file descriptor open for input, a redirection error occurs. 4144If 4145<I>word</I> 4146 4147evaluates to 4148<B>-</B>, 4149 4150file descriptor 4151<I>n</I> 4152 4153is closed. If 4154<I>n</I> 4155 4156is not specified, the standard input (file descriptor 0) is used. 4157<P> 4158 4159The operator 4160<DL COMPACT><DT><DD> 4161<P> 4162 4163[<I>n</I>]<B>>&</B><I>word</I> 4164</DL> 4165 4166<P> 4167 4168is used similarly to duplicate output file descriptors. If 4169<I>n</I> 4170 4171is not specified, the standard output (file descriptor 1) is used. 4172If the digits in 4173<I>word</I> 4174 4175do not specify a file descriptor open for output, a redirection error occurs. 4176As a special case, if <I>n</I> is omitted, and <I>word</I> does not 4177expand to one or more digits, the standard output and standard 4178error are redirected as described previously. 4179<A NAME="lbBP"> </A> 4180<H4>Moving File Descriptors</H4> 4181 4182<P> 4183 4184The redirection operator 4185<DL COMPACT><DT><DD> 4186<P> 4187 4188[<I>n</I>]<B><&</B><I>digit</I><B>-</B> 4189</DL> 4190 4191<P> 4192 4193moves the file descriptor <I>digit</I> to file descriptor 4194<I>n</I>, 4195 4196or the standard input (file descriptor 0) if <I>n</I> is not specified. 4197<I>digit</I> is closed after being duplicated to <I>n</I>. 4198<P> 4199 4200Similarly, the redirection operator 4201<DL COMPACT><DT><DD> 4202<P> 4203 4204[<I>n</I>]<B>>&</B><I>digit</I><B>-</B> 4205</DL> 4206 4207<P> 4208 4209moves the file descriptor <I>digit</I> to file descriptor 4210<I>n</I>, 4211 4212or the standard output (file descriptor 1) if <I>n</I> is not specified. 4213<A NAME="lbBQ"> </A> 4214<H4>Opening File Descriptors for Reading and Writing</H4> 4215 4216<P> 4217 4218The redirection operator 4219<DL COMPACT><DT><DD> 4220<P> 4221 4222[<I>n</I>]<B><></B><I>word</I> 4223</DL> 4224 4225<P> 4226 4227causes the file whose name is the expansion of 4228<I>word</I> 4229 4230to be opened for both reading and writing on file descriptor 4231<I>n</I>, 4232 4233or on file descriptor 0 if 4234<I>n</I> 4235 4236is not specified. If the file does not exist, it is created. 4237<A NAME="lbBR"> </A> 4238<H3>ALIASES</H3> 4239 4240<I>Aliases</I> allow a string to be substituted for a word when it is used 4241as the first word of a simple command. 4242The shell maintains a list of aliases that may be set and unset with the 4243<B>alias</B> 4244 4245and 4246<B>unalias</B> 4247 4248builtin commands (see 4249<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 4250 4251</FONT> 4252below). 4253The first word of each simple command, if unquoted, 4254is checked to see if it has an 4255alias. If so, that word is replaced by the text of the alias. 4256The characters <B>/</B>, <B>$</B>, <B>`</B>, and <B>=</B> and 4257any of the shell <I>metacharacters</I> or quoting characters 4258listed above may not appear in an alias name. 4259The replacement text may contain any valid shell input, 4260including shell metacharacters. 4261The first word of the replacement text is tested 4262for aliases, but a word that is identical to an alias being expanded 4263is not expanded a second time. 4264This means that one may alias 4265<B>ls</B> 4266 4267to 4268<B>ls -F</B>, 4269 4270for instance, and 4271<B>bash</B> 4272 4273does not try to recursively expand the replacement text. 4274If the last character of the alias value is a 4275<I>blank</I>, 4276 4277then the next command 4278word following the alias is also checked for alias expansion. 4279<P> 4280 4281Aliases are created and listed with the 4282<B>alias</B> 4283 4284command, and removed with the 4285<B>unalias</B> 4286 4287command. 4288<P> 4289 4290There is no mechanism for using arguments in the replacement text. 4291If arguments are needed, a shell function should be used (see 4292<FONT SIZE=-1><B>FUNCTIONS</B> 4293 4294</FONT> 4295below). 4296<P> 4297 4298Aliases are not expanded when the shell is not interactive, unless 4299the 4300<B>expand_aliases</B> 4301 4302shell option is set using 4303<B>shopt</B> 4304 4305(see the description of 4306<B>shopt</B> 4307 4308under 4309<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B></FONT> 4310below). 4311<P> 4312 4313The rules concerning the definition and use of aliases are 4314somewhat confusing. 4315<B>Bash</B> 4316 4317always reads at least one complete line 4318of input before executing any 4319of the commands on that line. Aliases are expanded when a 4320command is read, not when it is executed. Therefore, an 4321alias definition appearing on the same line as another 4322command does not take effect until the next line of input is read. 4323The commands following the alias definition 4324on that line are not affected by the new alias. 4325This behavior is also an issue when functions are executed. 4326Aliases are expanded when a function definition is read, 4327not when the function is executed, because a function definition 4328is itself a compound command. As a consequence, aliases 4329defined in a function are not available until after that 4330function is executed. To be safe, always put 4331alias definitions on a separate line, and do not use 4332<B>alias</B> 4333 4334in compound commands. 4335<P> 4336 4337For almost every purpose, aliases are superseded by 4338shell functions. 4339<A NAME="lbBS"> </A> 4340<H3>FUNCTIONS</H3> 4341 4342A shell function, defined as described above under 4343<FONT SIZE=-1><B>SHELL GRAMMAR</B>, 4344 4345</FONT> 4346stores a series of commands for later execution. 4347When the name of a shell function is used as a simple command name, 4348the list of commands associated with that function name is executed. 4349Functions are executed in the context of the 4350current shell; no new process is created to interpret 4351them (contrast this with the execution of a shell script). 4352When a function is executed, the arguments to the 4353function become the positional parameters 4354during its execution. 4355The special parameter 4356<B>#</B> 4357 4358is updated to reflect the change. Special parameter 0 4359is unchanged. 4360The first element of the 4361<FONT SIZE=-1><B>FUNCNAME</B> 4362 4363</FONT> 4364variable is set to the name of the function while the function 4365is executing. 4366All other aspects of the shell execution 4367environment are identical between a function and its caller 4368with the exception that the 4369<FONT SIZE=-1><B>DEBUG</B> 4370 4371</FONT> 4372and 4373<B>RETURN</B> 4374 4375traps (see the description of the 4376<B>trap</B> 4377 4378builtin under 4379<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 4380 4381</FONT> 4382below) are not inherited unless the function has been given the 4383<B>trace</B> attribute (see the description of the 4384<FONT SIZE=-1><B>declare</B> 4385 4386</FONT> 4387builtin below) or the 4388<B>-o functrace</B> shell option has been enabled with 4389the <B>set</B> builtin 4390(in which case all functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps). 4391<P> 4392 4393Variables local to the function may be declared with the 4394<B>local</B> 4395 4396builtin command. Ordinarily, variables and their values 4397are shared between the function and its caller. 4398<P> 4399 4400If the builtin command 4401<B>return</B> 4402 4403is executed in a function, the function completes and 4404execution resumes with the next command after the function 4405call. 4406Any command associated with the <B>RETURN</B> trap is executed 4407before execution resumes. 4408When a function completes, the values of the 4409positional parameters and the special parameter 4410<B>#</B> 4411 4412are restored to the values they had prior to the function's 4413execution. 4414<P> 4415 4416Function names and definitions may be listed with the 4417<B>-f</B> 4418 4419option to the 4420<B>declare</B> 4421 4422or 4423<B>typeset</B> 4424 4425builtin commands. The 4426<B>-F</B> 4427 4428option to 4429<B>declare</B> 4430 4431or 4432<B>typeset</B> 4433 4434will list the function names only 4435(and optionally the source file and line number, if the <B>extdebug</B> 4436shell option is enabled). 4437Functions may be exported so that subshells 4438automatically have them defined with the 4439<B>-f</B> 4440 4441option to the 4442<B>export</B> 4443 4444builtin. 4445Note that shell functions and variables with the same name may result 4446in multiple identically-named entries in the environment passed to the 4447shell's children. 4448Care should be taken in cases where this may cause a problem. 4449<P> 4450 4451Functions may be recursive. No limit is imposed on the number 4452of recursive calls. 4453<A NAME="lbBT"> </A> 4454<H3>ARITHMETIC EVALUATION</H3> 4455 4456The shell allows arithmetic expressions to be evaluated, under 4457certain circumstances (see the <B>let</B> and <B>declare</B> builtin 4458commands and <B>Arithmetic Expansion</B>). 4459Evaluation is done in fixed-width integers with no check for overflow, 4460though division by 0 is trapped and flagged as an error. 4461The operators and their precedence, associativity, and values 4462are the same as in the C language. 4463The following list of operators is grouped into levels of 4464equal-precedence operators. 4465The levels are listed in order of decreasing precedence. 4466<P> 4467 4468 4469<DL COMPACT> 4470<DT><B></B><I>id</I>++ <I>id</I>-- 4471 4472<DD> 4473variable post-increment and post-decrement 4474<DT><B>++</B><I>id</I> --<I>id</I> 4475 4476<DD> 4477variable pre-increment and pre-decrement 4478<DT><B>- +</B> 4479 4480<DD> 4481unary minus and plus 4482<DT><B>! ~</B> 4483 4484<DD> 4485logical and bitwise negation 4486<DT><B>**</B> 4487 4488<DD> 4489exponentiation 4490<DT><B>* / %</B> 4491 4492<DD> 4493multiplication, division, remainder 4494<DT><B>+ -</B> 4495 4496<DD> 4497addition, subtraction 4498<DT><B><< >></B> 4499 4500<DD> 4501left and right bitwise shifts 4502<DT><B><= >= < ></B> 4503 4504<DD> 4505comparison 4506<DT><B>== !=</B> 4507 4508<DD> 4509equality and inequality 4510<DT><B>&</B> 4511 4512<DD> 4513bitwise AND 4514<DT><B>^</B> 4515 4516<DD> 4517bitwise exclusive OR 4518<DT><B>|</B> 4519 4520<DD> 4521bitwise OR 4522<DT><B>&&</B> 4523 4524<DD> 4525logical AND 4526<DT><B>||</B> 4527 4528<DD> 4529logical OR 4530<DT><B></B><I>expr</I>?<I>expr</I>:<I>expr</I> 4531 4532<DD> 4533conditional operator 4534<DT><B>= *= /= %= += -= <<= >>= &= ^= |=</B> 4535 4536<DD> 4537assignment 4538<DT><B></B><I>expr1</I> , <I>expr2</I> 4539 4540<DD> 4541comma 4542 4543</DL> 4544<P> 4545 4546Shell variables are allowed as operands; parameter expansion is 4547performed before the expression is evaluated. 4548Within an expression, shell variables may also be referenced by name 4549without using the parameter expansion syntax. 4550A shell variable that is null or unset evaluates to 0 when referenced 4551by name without using the parameter expansion syntax. 4552The value of a variable is evaluated as an arithmetic expression 4553when it is referenced, or when a variable which has been given the 4554<I>integer</I> attribute using <B>declare -i</B> is assigned a value. 4555A null value evaluates to 0. 4556A shell variable need not have its integer attribute 4557turned on to be used in an expression. 4558<P> 4559 4560Constants with a leading 0 are interpreted as octal numbers. 4561A leading 0x or 0X denotes hexadecimal. 4562Otherwise, numbers take the form [<I>base#</I>]n, where <I>base</I> 4563is a decimal number between 2 and 64 representing the arithmetic 4564base, and <I>n</I> is a number in that base. 4565If <I>base#</I> is omitted, then base 10 is used. 4566The digits greater than 9 are represented by the lowercase letters, 4567the uppercase letters, @, and _, in that order. 4568If <I>base</I> is less than or equal to 36, lowercase and uppercase 4569letters may be used interchangeably to represent numbers between 10 4570and 35. 4571<P> 4572 4573Operators are evaluated in order of precedence. Sub-expressions in 4574parentheses are evaluated first and may override the precedence 4575rules above. 4576<A NAME="lbBU"> </A> 4577<H3>CONDITIONAL EXPRESSIONS</H3> 4578 4579Conditional expressions are used by the <B>[[</B> compound command and 4580the <B>test</B> and <B>[</B> builtin commands to test file attributes 4581and perform string and arithmetic comparisons. 4582Expressions are formed from the following unary or binary primaries. 4583If any <I>file</I> argument to one of the primaries is of the form 4584<I>/dev/fd/n</I>, then file descriptor <I>n</I> is checked. 4585If the <I>file</I> argument to one of the primaries is one of 4586<I>/dev/stdin</I>, <I>/dev/stdout</I>, or <I>/dev/stderr</I>, file 4587descriptor 0, 1, or 2, respectively, is checked. 4588<P> 4589 4590Unless otherwise specified, primaries that operate on files follow symbolic 4591links and operate on the target of the link, rather than the link itself. 4592<P> 4593 4594<DL COMPACT> 4595<DT><B>-a </B><I>file</I> 4596 4597<DD> 4598True if <I>file</I> exists. 4599<DT><B>-b </B><I>file</I> 4600 4601<DD> 4602True if <I>file</I> exists and is a block special file. 4603<DT><B>-c </B><I>file</I> 4604 4605<DD> 4606True if <I>file</I> exists and is a character special file. 4607<DT><B>-d </B><I>file</I> 4608 4609<DD> 4610True if <I>file</I> exists and is a directory. 4611<DT><B>-e </B><I>file</I> 4612 4613<DD> 4614True if <I>file</I> exists. 4615<DT><B>-f </B><I>file</I> 4616 4617<DD> 4618True if <I>file</I> exists and is a regular file. 4619<DT><B>-g </B><I>file</I> 4620 4621<DD> 4622True if <I>file</I> exists and is set-group-id. 4623<DT><B>-h </B><I>file</I> 4624 4625<DD> 4626True if <I>file</I> exists and is a symbolic link. 4627<DT><B>-k </B><I>file</I> 4628 4629<DD> 4630True if <I>file</I> exists and its ``sticky'' bit is set. 4631<DT><B>-p </B><I>file</I> 4632 4633<DD> 4634True if <I>file</I> exists and is a named pipe (FIFO). 4635<DT><B>-r </B><I>file</I> 4636 4637<DD> 4638True if <I>file</I> exists and is readable. 4639<DT><B>-s </B><I>file</I> 4640 4641<DD> 4642True if <I>file</I> exists and has a size greater than zero. 4643<DT><B>-t </B><I>fd</I> 4644 4645<DD> 4646True if file descriptor 4647<I>fd</I> 4648 4649is open and refers to a terminal. 4650<DT><B>-u </B><I>file</I> 4651 4652<DD> 4653True if <I>file</I> exists and its set-user-id bit is set. 4654<DT><B>-w </B><I>file</I> 4655 4656<DD> 4657True if <I>file</I> exists and is writable. 4658<DT><B>-x </B><I>file</I> 4659 4660<DD> 4661True if <I>file</I> exists and is executable. 4662<DT><B>-O </B><I>file</I> 4663 4664<DD> 4665True if <I>file</I> exists and is owned by the effective user id. 4666<DT><B>-G </B><I>file</I> 4667 4668<DD> 4669True if <I>file</I> exists and is owned by the effective group id. 4670<DT><B>-L </B><I>file</I> 4671 4672<DD> 4673True if <I>file</I> exists and is a symbolic link. 4674<DT><B>-S </B><I>file</I> 4675 4676<DD> 4677True if <I>file</I> exists and is a socket. 4678<DT><B>-N </B><I>file</I> 4679 4680<DD> 4681True if <I>file</I> exists and has been modified since it was last read. 4682<DT><I>file1</I> -<B>nt</B> <I>file2</I><DD> 4683True if <I>file1</I> is newer (according to modification date) than <I>file2</I>, 4684or if <I>file1</I> exists and file2 does not. 4685<DT><I>file1</I> -<B>ot</B> <I>file2</I><DD> 4686True if <I>file1</I> is older than <I>file2</I>, or if <I>file2</I> exists 4687and <I>file1</I> does not. 4688<DT><I>file1</I> <B>-ef</B> <I>file2</I><DD> 4689True if <I>file1</I> and <I>file2</I> refer to the same device and 4690inode numbers. 4691<DT><B>-o </B><I>optname</I> 4692 4693<DD> 4694True if shell option 4695<I>optname</I> 4696 4697is enabled. 4698See the list of options under the description of the 4699<B>-o</B> 4700 4701option to the 4702<B>set</B> 4703 4704builtin below. 4705<DT><B>-z </B><I>string</I> 4706 4707<DD> 4708True if the length of <I>string</I> is zero. 4709<DT><I>string</I><DD> 4710 4711<DT><B>-n </B><I>string</I> 4712 4713<DD> 4714 4715True if the length of 4716<I>string</I> 4717 4718is non-zero. 4719<DT><I>string1</I> <B>==</B> <I>string2</I><DD> 4720True if the strings are equal. <B>=</B> may be used in place of 4721<B>==</B> for strict POSIX compliance. 4722<DT><I>string1</I> <B>!=</B> <I>string2</I><DD> 4723True if the strings are not equal. 4724<DT><I>string1</I> <B><</B> <I>string2</I><DD> 4725True if <I>string1</I> sorts before <I>string2</I> lexicographically 4726in the current locale. 4727<DT><I>string1</I> <B>></B> <I>string2</I><DD> 4728True if <I>string1</I> sorts after <I>string2</I> lexicographically 4729in the current locale. 4730<DT><I>arg1</I> <B>OP</B> <I>arg2</I> 4731 4732<DD> 4733<FONT SIZE=-1><B>OP</B> 4734 4735</FONT> 4736is one of 4737<B>-eq</B>, 4738 4739<B>-ne</B>, 4740 4741<B>-lt</B>, 4742 4743<B>-le</B>, 4744 4745<B>-gt</B>, 4746 4747or 4748<B>-ge</B>. 4749 4750These arithmetic binary operators return true if <I>arg1</I> 4751is equal to, not equal to, less than, less than or equal to, 4752greater than, or greater than or equal to <I>arg2</I>, respectively. 4753<I>Arg1</I> 4754 4755and 4756<I>arg2</I> 4757 4758may be positive or negative integers. 4759 4760</DL> 4761<A NAME="lbBV"> </A> 4762<H3>SIMPLE COMMAND EXPANSION</H3> 4763 4764When a simple command is executed, the shell performs the following 4765expansions, assignments, and redirections, from left to right. 4766<DL COMPACT> 4767<DT>1.<DD> 4768The words that the parser has marked as variable assignments (those 4769preceding the command name) and redirections are saved for later 4770processing. 4771<DT>2.<DD> 4772The words that are not variable assignments or redirections are 4773expanded. If any words remain after expansion, the first word 4774is taken to be the name of the command and the remaining words are 4775the arguments. 4776<DT>3.<DD> 4777Redirections are performed as described above under 4778<FONT SIZE=-1><B>REDIRECTION</B>. 4779 4780</FONT> 4781<DT>4.<DD> 4782The text after the <B>=</B> in each variable assignment undergoes tilde 4783expansion, parameter expansion, command substitution, arithmetic expansion, 4784and quote removal before being assigned to the variable. 4785</DL> 4786<P> 4787 4788If no command name results, the variable assignments affect the current 4789shell environment. Otherwise, the variables are added to the environment 4790of the executed command and do not affect the current shell environment. 4791If any of the assignments attempts to assign a value to a readonly variable, 4792an error occurs, and the command exits with a non-zero status. 4793<P> 4794 4795If no command name results, redirections are performed, but do not 4796affect the current shell environment. A redirection error causes the 4797command to exit with a non-zero status. 4798<P> 4799 4800If there is a command name left after expansion, execution proceeds as 4801described below. Otherwise, the command exits. If one of the expansions 4802contained a command substitution, the exit status of the command is 4803the exit status of the last command substitution performed. If there 4804were no command substitutions, the command exits with a status of zero. 4805<A NAME="lbBW"> </A> 4806<H3>COMMAND EXECUTION</H3> 4807 4808After a command has been split into words, if it results in a 4809simple command and an optional list of arguments, the following 4810actions are taken. 4811<P> 4812 4813If the command name contains no slashes, the shell attempts to 4814locate it. If there exists a shell function by that name, that 4815function is invoked as described above in 4816<FONT SIZE=-1><B>FUNCTIONS</B>. 4817 4818</FONT> 4819If the name does not match a function, the shell searches for 4820it in the list of shell builtins. If a match is found, that 4821builtin is invoked. 4822<P> 4823 4824If the name is neither a shell function nor a builtin, 4825and contains no slashes, 4826<B>bash</B> 4827 4828searches each element of the 4829<FONT SIZE=-1><B>PATH</B> 4830 4831</FONT> 4832for a directory containing an executable file by that name. 4833<B>Bash</B> 4834 4835uses a hash table to remember the full pathnames of executable 4836files (see 4837<B>hash</B> 4838 4839under 4840<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 4841 4842</FONT> 4843below). 4844A full search of the directories in 4845<FONT SIZE=-1><B>PATH</B> 4846 4847</FONT> 4848is performed only if the command is not found in the hash table. 4849If the search is unsuccessful, the shell prints an error 4850message and returns an exit status of 127. 4851<P> 4852 4853If the search is successful, or if the command name contains 4854one or more slashes, the shell executes the named program in a 4855separate execution environment. 4856Argument 0 is set to the name given, and the remaining arguments 4857to the command are set to the arguments given, if any. 4858<P> 4859 4860If this execution fails because the file is not in executable 4861format, and the file is not a directory, it is assumed to be 4862a <I>shell script</I>, a file 4863containing shell commands. A subshell is spawned to execute 4864it. This subshell reinitializes itself, so 4865that the effect is as if a new shell had been invoked 4866to handle the script, with the exception that the locations of 4867commands remembered by the parent (see 4868<B>hash</B> 4869 4870below under 4871<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>)</FONT> 4872are retained by the child. 4873<P> 4874 4875If the program is a file beginning with 4876<B>#!</B>, 4877 4878the remainder of the first line specifies an interpreter 4879for the program. The shell executes the 4880specified interpreter on operating systems that do not 4881handle this executable format themselves. The arguments to the 4882interpreter consist of a single optional argument following the 4883interpreter name on the first line of the program, followed 4884by the name of the program, followed by the command 4885arguments, if any. 4886<A NAME="lbBX"> </A> 4887<H3>COMMAND EXECUTION ENVIRONMENT</H3> 4888 4889The shell has an <I>execution environment</I>, which consists of the 4890following: 4891<P> 4892<DL COMPACT> 4893<DT>*<DD> 4894open files inherited by the shell at invocation, as modified by 4895redirections supplied to the <B>exec</B> builtin 4896<DT>*<DD> 4897the current working directory as set by <B>cd</B>, <B>pushd</B>, or 4898<B>popd</B>, or inherited by the shell at invocation 4899<DT>*<DD> 4900the file creation mode mask as set by <B>umask</B> or inherited from 4901the shell's parent 4902<DT>*<DD> 4903current traps set by <B>trap</B> 4904<DT>*<DD> 4905shell parameters that are set by variable assignment or with <B>set</B> 4906or inherited from the shell's parent in the environment 4907<DT>*<DD> 4908shell functions defined during execution or inherited from the shell's 4909parent in the environment 4910<DT>*<DD> 4911options enabled at invocation (either by default or with command-line 4912arguments) or by <B>set</B> 4913<DT>*<DD> 4914options enabled by <B>shopt</B> 4915<DT>*<DD> 4916shell aliases defined with <B>alias</B> 4917<DT>*<DD> 4918various process IDs, including those of background jobs, the value 4919of <B>$$</B>, and the value of <B>$PPID</B> 4920</DL> 4921<P> 4922 4923When a simple command other than a builtin or shell function 4924is to be executed, it 4925is invoked in a separate execution environment that consists of 4926the following. Unless otherwise noted, the values are inherited 4927from the shell. 4928<P> 4929<DL COMPACT> 4930<DT>*<DD> 4931the shell's open files, plus any modifications and additions specified 4932by redirections to the command 4933<DT>*<DD> 4934the current working directory 4935<DT>*<DD> 4936the file creation mode mask 4937<DT>*<DD> 4938shell variables and functions marked for export, along with variables 4939exported for the command, passed in the environment 4940<DT>*<DD> 4941traps caught by the shell are reset to the values inherited from the 4942shell's parent, and traps ignored by the shell are ignored 4943</DL> 4944<P> 4945 4946A command invoked in this separate environment cannot affect the 4947shell's execution environment. 4948<P> 4949 4950Command substitution, commands grouped with parentheses, 4951and asynchronous commands are invoked in a 4952subshell environment that is a duplicate of the shell environment, 4953except that traps caught by the shell are reset to the values 4954that the shell inherited from its parent at invocation. Builtin 4955commands that are invoked as part of a pipeline are also executed in a 4956subshell environment. Changes made to the subshell environment 4957cannot affect the shell's execution environment. 4958<P> 4959 4960If a command is followed by a <B>&</B> and job control is not active, the 4961default standard input for the command is the empty file <I>/dev/null</I>. 4962Otherwise, the invoked command inherits the file descriptors of the calling 4963shell as modified by redirections. 4964<A NAME="lbBY"> </A> 4965<H3>ENVIRONMENT</H3> 4966 4967When a program is invoked it is given an array of strings 4968called the 4969<I>environment</I>. 4970 4971This is a list of 4972<I>name</I>-<I>value</I> pairs, of the form 4973<I>name</I>=value. 4974 4975<P> 4976 4977The shell provides several ways to manipulate the environment. 4978On invocation, the shell scans its own environment and 4979creates a parameter for each name found, automatically marking 4980it for 4981<I>export</I> 4982 4983to child processes. Executed commands inherit the environment. 4984The 4985<B>export</B> 4986 4987and 4988<B>declare -x</B> 4989 4990commands allow parameters and functions to be added to and 4991deleted from the environment. If the value of a parameter 4992in the environment is modified, the new value becomes part 4993of the environment, replacing the old. The environment 4994inherited by any executed command consists of the shell's 4995initial environment, whose values may be modified in the shell, 4996less any pairs removed by the 4997<B>unset</B> 4998 4999command, plus any additions via the 5000<B>export</B> 5001 5002and 5003<B>declare -x</B> 5004 5005commands. 5006<P> 5007 5008The environment for any 5009<I>simple command</I> 5010 5011or function may be augmented temporarily by prefixing it with 5012parameter assignments, as described above in 5013<FONT SIZE=-1><B>PARAMETERS</B>. 5014 5015</FONT> 5016These assignment statements affect only the environment seen 5017by that command. 5018<P> 5019 5020If the 5021<B>-k</B> 5022 5023option is set (see the 5024<B>set</B> 5025 5026builtin command below), then 5027<I>all</I> 5028 5029parameter assignments are placed in the environment for a command, 5030not just those that precede the command name. 5031<P> 5032 5033When 5034<B>bash</B> 5035 5036invokes an external command, the variable 5037<B>_</B> 5038 5039is set to the full file name of the command and passed to that 5040command in its environment. 5041<A NAME="lbBZ"> </A> 5042<H3>EXIT STATUS</H3> 5043 5044For the shell's purposes, a command which exits with a 5045zero exit status has succeeded. An exit status of zero 5046indicates success. A non-zero exit status indicates failure. 5047When a command terminates on a fatal signal <I>N</I>, <B>bash</B> uses 5048the value of 128+<I>N</I> as the exit status. 5049<P> 5050 5051If a command is not found, the child process created to 5052execute it returns a status of 127. If a command is found 5053but is not executable, the return status is 126. 5054<P> 5055 5056If a command fails because of an error during expansion or redirection, 5057the exit status is greater than zero. 5058<P> 5059 5060Shell builtin commands return a status of 0 (<I>true</I>) if 5061successful, and non-zero (<I>false</I>) if an error occurs 5062while they execute. 5063All builtins return an exit status of 2 to indicate incorrect usage. 5064<P> 5065 5066<B>Bash</B> itself returns the exit status of the last command 5067executed, unless a syntax error occurs, in which case it exits 5068with a non-zero value. See also the <B>exit</B> builtin 5069command below. 5070<A NAME="lbCA"> </A> 5071<H3>SIGNALS</H3> 5072 5073When <B>bash</B> is interactive, in the absence of any traps, it ignores 5074<FONT SIZE=-1><B>SIGTERM</B> 5075 5076</FONT> 5077(so that <B>kill 0</B> does not kill an interactive shell), 5078and 5079<FONT SIZE=-1><B>SIGINT</B> 5080 5081</FONT> 5082is caught and handled (so that the <B>wait</B> builtin is interruptible). 5083In all cases, <B>bash</B> ignores 5084<FONT SIZE=-1><B>SIGQUIT</B>. 5085 5086</FONT> 5087If job control is in effect, 5088<B>bash</B> 5089 5090ignores 5091<FONT SIZE=-1><B>SIGTTIN</B>, 5092 5093</FONT> 5094<FONT SIZE=-1><B>SIGTTOU</B>, 5095 5096</FONT> 5097and 5098<FONT SIZE=-1><B>SIGTSTP</B>. 5099 5100</FONT> 5101<P> 5102 5103Non-builtin commands run by <B>bash</B> have signal handlers 5104set to the values inherited by the shell from its parent. 5105When job control is not in effect, asynchronous commands 5106ignore 5107<FONT SIZE=-1><B>SIGINT</B> 5108 5109</FONT> 5110and 5111<FONT SIZE=-1><B>SIGQUIT</B> 5112 5113</FONT> 5114in addition to these inherited handlers. 5115Commands run as a result of command substitution ignore the 5116keyboard-generated job control signals 5117<FONT SIZE=-1><B>SIGTTIN</B>, 5118 5119</FONT> 5120<FONT SIZE=-1><B>SIGTTOU</B>, 5121 5122</FONT> 5123and 5124<FONT SIZE=-1><B>SIGTSTP</B>. 5125 5126</FONT> 5127<P> 5128 5129The shell exits by default upon receipt of a 5130<FONT SIZE=-1><B>SIGHUP</B>. 5131 5132</FONT> 5133Before exiting, an interactive shell resends the 5134<FONT SIZE=-1><B>SIGHUP</B> 5135 5136</FONT> 5137to all jobs, running or stopped. 5138Stopped jobs are sent 5139<FONT SIZE=-1><B>SIGCONT</B> 5140 5141</FONT> 5142to ensure that they receive the 5143<FONT SIZE=-1><B>SIGHUP</B>. 5144 5145</FONT> 5146To prevent the shell from 5147sending the signal to a particular job, it should be removed from the 5148jobs table with the 5149<B>disown</B> 5150 5151builtin (see 5152<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 5153 5154</FONT> 5155below) or marked 5156to not receive 5157<FONT SIZE=-1><B>SIGHUP</B> 5158 5159</FONT> 5160using 5161<B>disown -h</B>. 5162 5163<P> 5164 5165If the 5166<B>huponexit</B> 5167 5168shell option has been set with 5169<B>shopt</B>, 5170 5171<B>bash</B> 5172 5173sends a 5174<FONT SIZE=-1><B>SIGHUP</B> 5175 5176</FONT> 5177to all jobs when an interactive login shell exits. 5178<P> 5179 5180If <B>bash</B> is waiting for a command to complete and receives a signal 5181for which a trap has been set, the trap will not be executed until 5182the command completes. 5183When <B>bash</B> is waiting for an asynchronous command via the <B>wait</B> 5184builtin, the reception of a signal for which a trap has been set will 5185cause the <B>wait</B> builtin to return immediately with an exit status 5186greater than 128, immediately after which the trap is executed. 5187<A NAME="lbCB"> </A> 5188<H3>JOB CONTROL</H3> 5189 5190<I>Job control</I> 5191 5192refers to the ability to selectively stop (<I>suspend</I>) 5193the execution of processes and continue (<I>resume</I>) 5194their execution at a later point. A user typically employs 5195this facility via an interactive interface supplied jointly 5196by the system's terminal driver and 5197<B>bash</B>. 5198 5199<P> 5200 5201The shell associates a 5202<I>job</I> 5203 5204with each pipeline. It keeps a table of currently executing 5205jobs, which may be listed with the 5206<B>jobs</B> 5207 5208command. When 5209<B>bash</B> 5210 5211starts a job asynchronously (in the 5212<I>background</I>), 5213 5214it prints a line that looks like: 5215<DL COMPACT><DT><DD> 5216<P> 5217 5218[1] 25647 5219</DL> 5220 5221<P> 5222 5223indicating that this job is job number 1 and that the process ID 5224of the last process in the pipeline associated with this job is 25647. 5225All of the processes in a single pipeline are members of the same job. 5226<B>Bash</B> 5227 5228uses the 5229<I>job</I> 5230 5231abstraction as the basis for job control. 5232<P> 5233 5234To facilitate the implementation of the user interface to job 5235control, the operating system maintains the notion of a <I>current terminal 5236process group ID</I>. Members of this process group (processes whose 5237process group ID is equal to the current terminal process group ID) 5238receive keyboard-generated signals such as 5239<FONT SIZE=-1><B>SIGINT</B>. 5240 5241</FONT> 5242These processes are said to be in the 5243<I>foreground</I>. 5244 5245<I>Background</I> 5246 5247processes are those whose process group ID differs from the terminal's; 5248such processes are immune to keyboard-generated signals. 5249Only foreground processes are allowed to read from or write to the 5250terminal. Background processes which attempt to read from (write to) the 5251terminal are sent a 5252<FONT SIZE=-1><B>SIGTTIN (SIGTTOU)</B> 5253 5254</FONT> 5255signal by the terminal driver, 5256which, unless caught, suspends the process. 5257<P> 5258 5259If the operating system on which 5260<B>bash</B> 5261 5262is running supports 5263job control, 5264<B>bash</B> 5265 5266contains facilities to use it. 5267Typing the 5268<I>suspend</I> 5269 5270character (typically 5271<B>^Z</B>, 5272 5273Control-Z) while a process is running 5274causes that process to be stopped and returns control to 5275<B>bash</B>. 5276 5277Typing the 5278<I>delayed suspend</I> 5279 5280character (typically 5281<B>^Y</B>, 5282 5283Control-Y) causes the process to be stopped when it 5284attempts to read input from the terminal, and control to 5285be returned to 5286<B>bash</B>. 5287 5288The user may then manipulate the state of this job, using the 5289<B>bg</B> 5290 5291command to continue it in the background, the 5292<B>fg</B> 5293 5294command to continue it in the foreground, or 5295the 5296<B>kill</B> 5297 5298command to kill it. A <B>^Z</B> takes effect immediately, 5299and has the additional side effect of causing pending output 5300and typeahead to be discarded. 5301<P> 5302 5303There are a number of ways to refer to a job in the shell. 5304The character 5305<B>%</B> 5306 5307introduces a job name. Job number 5308<I>n</I> 5309 5310may be referred to as 5311<B>%n</B>. 5312 5313A job may also be referred to using a prefix of the name used to 5314start it, or using a substring that appears in its command line. 5315For example, 5316<B>%ce</B> 5317 5318refers to a stopped 5319<B>ce</B> 5320 5321job. If a prefix matches more than one job, 5322<B>bash</B> 5323 5324reports an error. Using 5325<B>%?ce</B>, 5326 5327on the other hand, refers to any job containing the string 5328<B>ce</B> 5329 5330in its command line. If the substring matches more than one job, 5331<B>bash</B> 5332 5333reports an error. The symbols 5334<B>%%</B> 5335 5336and 5337<B>%+</B> 5338 5339refer to the shell's notion of the 5340<I>current job</I>, 5341 5342which is the last job stopped while it was in 5343the foreground or started in the background. 5344The 5345<I>previous job</I> 5346 5347may be referenced using 5348<B>%-</B>. 5349 5350In output pertaining to jobs (e.g., the output of the 5351<B>jobs</B> 5352 5353command), the current job is always flagged with a 5354<B>+</B>, 5355 5356and the previous job with a 5357<B>-</B>. 5358 5359A single % (with no accompanying job specification) also refers to the 5360current job. 5361<P> 5362 5363Simply naming a job can be used to bring it into the 5364foreground: 5365<B>%1</B> 5366 5367is a synonym for 5368<B>``fg %1''</B>, 5369bringing job 1 from the background into the foreground. 5370Similarly, 5371<B>``%1 &''</B> 5372 5373resumes job 1 in the background, equivalent to 5374<B>``bg %1''</B>. 5375<P> 5376 5377The shell learns immediately whenever a job changes state. 5378Normally, 5379<B>bash</B> 5380 5381waits until it is about to print a prompt before reporting 5382changes in a job's status so as to not interrupt 5383any other output. If the 5384<B>-b</B> 5385 5386option to the 5387<B>set</B> 5388 5389builtin command 5390is enabled, 5391<B>bash</B> 5392 5393reports such changes immediately. 5394Any trap on 5395<FONT SIZE=-1><B>SIGCHLD</B> 5396 5397</FONT> 5398is executed for each child that exits. 5399<P> 5400 5401If an attempt to exit 5402<B>bash</B> 5403 5404is made while jobs are stopped, the shell prints a warning message. The 5405<B>jobs</B> 5406 5407command may then be used to inspect their status. 5408If a second attempt to exit is made without an intervening command, 5409the shell does not print another warning, and the stopped 5410jobs are terminated. 5411<A NAME="lbCC"> </A> 5412<H3>PROMPTING</H3> 5413 5414When executing interactively, 5415<B>bash</B> 5416 5417displays the primary prompt 5418<FONT SIZE=-1><B>PS1</B> 5419 5420</FONT> 5421when it is ready to read a command, and the secondary prompt 5422<FONT SIZE=-1><B>PS2</B> 5423 5424</FONT> 5425when it needs more input to complete a command. 5426<B>Bash</B> 5427 5428allows these prompt strings to be customized by inserting a number of 5429backslash-escaped special characters that are decoded as follows: 5430<DL COMPACT><DT><DD> 5431 5432<DL COMPACT> 5433<DT><B>\a</B> 5434 5435<DD> 5436an ASCII bell character (07) 5437<DT><B>\d</B> 5438 5439<DD> 5440the date in "Weekday Month Date" format (e.g., "Tue May 26") 5441<DT><B>\D{</B><I>format</I>} 5442 5443<DD> 5444the <I>format</I> is passed to <I>strftime</I>(3) and the result is inserted 5445into the prompt string; an empty <I>format</I> results in a locale-specific 5446time representation. The braces are required 5447<DT><B>\e</B> 5448 5449<DD> 5450an ASCII escape character (033) 5451<DT><B>\h</B> 5452 5453<DD> 5454the hostname up to the first `.' 5455<DT><B>\H</B> 5456 5457<DD> 5458the hostname 5459<DT><B>\j</B> 5460 5461<DD> 5462the number of jobs currently managed by the shell 5463<DT><B>\l</B> 5464 5465<DD> 5466the basename of the shell's terminal device name 5467<DT><B>\n</B> 5468 5469<DD> 5470newline 5471<DT><B>\r</B> 5472 5473<DD> 5474carriage return 5475<DT><B>\s</B> 5476 5477<DD> 5478the name of the shell, the basename of 5479<B>$0</B> 5480 5481(the portion following the final slash) 5482<DT><B>\t</B> 5483 5484<DD> 5485the current time in 24-hour HH:MM:SS format 5486<DT><B>\T</B> 5487 5488<DD> 5489the current time in 12-hour HH:MM:SS format 5490<DT><B>\@</B> 5491 5492<DD> 5493the current time in 12-hour am/pm format 5494<DT><B>\A</B> 5495 5496<DD> 5497the current time in 24-hour HH:MM format 5498<DT><B>\u</B> 5499 5500<DD> 5501the username of the current user 5502<DT><B>\v</B> 5503 5504<DD> 5505the version of <B>bash</B> (e.g., 2.00) 5506<DT><B>\V</B> 5507 5508<DD> 5509the release of <B>bash</B>, version + patch level (e.g., 2.00.0) 5510<DT><B>\w</B> 5511 5512<DD> 5513the current working directory, with <B>$HOME</B> abbreviated with a tilde 5514<DT><B>\W</B> 5515 5516<DD> 5517the basename of the current working directory, with <B>$HOME</B> 5518abbreviated with a tilde 5519<DT><B>\!</B> 5520 5521<DD> 5522the history number of this command 5523<DT><B>\#</B> 5524 5525<DD> 5526the command number of this command 5527<DT><B>\$</B> 5528 5529<DD> 5530if the effective UID is 0, a 5531<B>#</B>, 5532 5533otherwise a 5534<B>$</B> 5535 5536<DT><B>\</B><I>nnn</I> 5537 5538<DD> 5539the character corresponding to the octal number <I>nnn</I> 5540<DT><B>\\</B> 5541 5542<DD> 5543a backslash 5544<DT><B>\[</B> 5545 5546<DD> 5547begin a sequence of non-printing characters, which could be used to 5548embed a terminal control sequence into the prompt 5549<DT><B>\]</B> 5550 5551<DD> 5552end a sequence of non-printing characters 5553 5554</DL></DL> 5555 5556<P> 5557 5558The command number and the history number are usually different: 5559the history number of a command is its position in the history 5560list, which may include commands restored from the history file 5561(see 5562<FONT SIZE=-1><B>HISTORY</B> 5563 5564</FONT> 5565below), while the command number is the position in the sequence 5566of commands executed during the current shell session. 5567After the string is decoded, it is expanded via 5568parameter expansion, command substitution, arithmetic 5569expansion, and quote removal, subject to the value of the 5570<B>promptvars</B> 5571 5572shell option (see the description of the 5573<B>shopt</B> 5574 5575command under 5576<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 5577 5578</FONT> 5579below). 5580<A NAME="lbCD"> </A> 5581<H3>READLINE</H3> 5582 5583This is the library that handles reading input when using an interactive 5584shell, unless the 5585<B>--noediting</B> 5586 5587option is given at shell invocation. 5588By default, the line editing commands are similar to those of emacs. 5589A vi-style line editing interface is also available. 5590To turn off line editing after the shell is running, use the 5591<B>+o emacs</B> 5592 5593or 5594<B>+o vi</B> 5595 5596options to the 5597<B>set</B> 5598 5599builtin (see 5600<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 5601 5602</FONT> 5603below). 5604<A NAME="lbCE"> </A> 5605<H4>Readline Notation</H4> 5606 5607<P> 5608 5609In this section, the emacs-style notation is used to denote 5610keystrokes. Control keys are denoted by C-<I>key</I>, e.g., C-n 5611means Control-N. Similarly, 5612<I>meta</I> 5613 5614keys are denoted by M-<I>key</I>, so M-x means Meta-X. (On keyboards 5615without a 5616<I>meta</I> 5617 5618key, M-<I>x</I> means ESC <I>x</I>, i.e., press the Escape key 5619then the 5620<I>x</I> 5621 5622key. This makes ESC the <I>meta prefix</I>. 5623The combination M-C-<I>x</I> means ESC-Control-<I>x</I>, 5624or press the Escape key 5625then hold the Control key while pressing the 5626<I>x</I> 5627 5628key.) 5629<P> 5630 5631Readline commands may be given numeric 5632<I>arguments</I>, 5633 5634which normally act as a repeat count. 5635Sometimes, however, it is the sign of the argument that is significant. 5636Passing a negative argument to a command that acts in the forward 5637direction (e.g., <B>kill-line</B>) causes that command to act in a 5638backward direction. 5639Commands whose behavior with arguments deviates from this are noted 5640below. 5641<P> 5642 5643When a command is described as <I>killing</I> text, the text 5644deleted is saved for possible future retrieval 5645(<I>yanking</I>). The killed text is saved in a 5646<I>kill ring</I>. Consecutive kills cause the text to be 5647accumulated into one unit, which can be yanked all at once. 5648Commands which do not kill text separate the chunks of text 5649on the kill ring. 5650<A NAME="lbCF"> </A> 5651<H4>Readline Initialization</H4> 5652 5653<P> 5654 5655Readline is customized by putting commands in an initialization 5656file (the <I>inputrc</I> file). 5657The name of this file is taken from the value of the 5658<FONT SIZE=-1><B>INPUTRC</B> 5659 5660</FONT> 5661variable. If that variable is unset, the default is 5662<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>. 5663 5664When a program which uses the readline library starts up, the 5665initialization file is read, and the key bindings and variables 5666are set. 5667There are only a few basic constructs allowed in the 5668readline initialization file. 5669Blank lines are ignored. 5670Lines beginning with a <B>#</B> are comments. 5671Lines beginning with a <B>$</B> indicate conditional constructs. 5672Other lines denote key bindings and variable settings. 5673<P> 5674 5675The default key-bindings may be changed with an 5676<I>inputrc </I> 5677 5678file. 5679Other programs that use this library may add their own commands 5680and bindings. 5681<P> 5682 5683For example, placing 5684<DL COMPACT><DT><DD> 5685<P> 5686 5687M-Control-u: universal-argument 5688</DL> 5689 5690or 5691<DL COMPACT><DT><DD> 5692C-Meta-u: universal-argument 5693</DL> 5694 5695into the 5696<I>inputrc</I> 5697 5698would make M-C-u execute the readline command 5699<I>universal-argument</I>. 5700 5701<P> 5702 5703The following symbolic character names are recognized: 5704<I>RUBOUT</I>, 5705 5706<I>DEL</I>, 5707 5708<I>ESC</I>, 5709 5710<I>LFD</I>, 5711 5712<I>NEWLINE</I>, 5713 5714<I>RET</I>, 5715 5716<I>RETURN</I>, 5717 5718<I>SPC</I>, 5719 5720<I>SPACE</I>, 5721 5722and 5723<I>TAB</I>. 5724 5725<P> 5726 5727In addition to command names, readline allows keys to be bound 5728to a string that is inserted when the key is pressed (a <I>macro</I>). 5729<A NAME="lbCG"> </A> 5730<H4>Readline Key Bindings</H4> 5731 5732<P> 5733 5734The syntax for controlling key bindings in the 5735<I>inputrc</I> 5736 5737file is simple. All that is required is the name of the 5738command or the text of a macro and a key sequence to which 5739it should be bound. The name may be specified in one of two ways: 5740as a symbolic key name, possibly with <I>Meta-</I> or <I>Control-</I> 5741prefixes, or as a key sequence. 5742<P> 5743 5744When using the form <B>keyname</B>:<I>function-name</I> or <I>macro</I>, 5745<I>keyname</I> 5746 5747is the name of a key spelled out in English. For example: 5748<P> 5749<DL COMPACT><DT><DD> 5750Control-u: universal-argument 5751<BR> 5752 5753Meta-Rubout: backward-kill-word 5754<BR> 5755 5756Control-o: "> output" 5757</DL> 5758 5759<P> 5760 5761In the above example, 5762<I>C-u</I> 5763 5764is bound to the function 5765<B>universal-argument</B>, 5766 5767<I>M-DEL</I> 5768 5769is bound to the function 5770<B>backward-kill-word</B>, 5771 5772and 5773<I>C-o</I> 5774 5775is bound to run the macro 5776expressed on the right hand side (that is, to insert the text 5777<TT>> output</TT> 5778 5779into the line). 5780<P> 5781 5782In the second form, <B>"keyseq"</B>:<I>function-name</I> or <I>macro</I>, 5783<B>keyseq</B> 5784 5785differs from 5786<B>keyname</B> 5787 5788above in that strings denoting 5789an entire key sequence may be specified by placing the sequence 5790within double quotes. Some GNU Emacs style key escapes can be 5791used, as in the following example, but the symbolic character names 5792are not recognized. 5793<P> 5794<DL COMPACT><DT><DD> 5795"\C-u": universal-argument 5796<BR> 5797 5798"\C-x\C-r": re-read-init-file 5799<BR> 5800 5801"\e[11~": "Function Key 1" 5802</DL> 5803 5804<P> 5805 5806In this example, 5807<I>C-u</I> 5808 5809is again bound to the function 5810<B>universal-argument</B>. 5811 5812<I>C-x C-r</I> 5813 5814is bound to the function 5815<B>re-read-init-file</B>, 5816 5817and 5818<I>ESC [ 1 1 ~</I> 5819 5820is bound to insert the text 5821<TT>Function Key 1</TT>. 5822 5823<P> 5824 5825The full set of GNU Emacs style escape sequences is 5826<DL COMPACT><DT><DD> 5827 5828<DL COMPACT> 5829<DT><B>\C-</B> 5830 5831<DD> 5832control prefix 5833<DT><B>\M-</B> 5834 5835<DD> 5836meta prefix 5837<DT><B>\e</B> 5838 5839<DD> 5840an escape character 5841<DT><B>\\</B> 5842 5843<DD> 5844backslash 5845<DT><B>\</B> 5846 5847<DD> 5848literal " 5849<DT><B>\'</B> 5850 5851<DD> 5852literal ' 5853</DL></DL> 5854 5855 5856<P> 5857 5858In addition to the GNU Emacs style escape sequences, a second 5859set of backslash escapes is available: 5860<DL COMPACT><DT><DD> 5861 5862<DL COMPACT> 5863<DT><B>\a</B> 5864 5865<DD> 5866alert (bell) 5867<DT><B>\b</B> 5868 5869<DD> 5870backspace 5871<DT><B>\d</B> 5872 5873<DD> 5874delete 5875<DT><B>\f</B> 5876 5877<DD> 5878form feed 5879<DT><B>\n</B> 5880 5881<DD> 5882newline 5883<DT><B>\r</B> 5884 5885<DD> 5886carriage return 5887<DT><B>\t</B> 5888 5889<DD> 5890horizontal tab 5891<DT><B>\v</B> 5892 5893<DD> 5894vertical tab 5895<DT><B>\</B><I>nnn</I> 5896 5897<DD> 5898the eight-bit character whose value is the octal value <I>nnn</I> 5899(one to three digits) 5900<DT><B>\x</B><I>HH</I> 5901 5902<DD> 5903the eight-bit character whose value is the hexadecimal value <I>HH</I> 5904(one or two hex digits) 5905</DL></DL> 5906 5907 5908<P> 5909 5910When entering the text of a macro, single or double quotes must 5911be used to indicate a macro definition. 5912Unquoted text is assumed to be a function name. 5913In the macro body, the backslash escapes described above are expanded. 5914Backslash will quote any other character in the macro text, 5915including " and '. 5916<P> 5917 5918<B>Bash</B> 5919 5920allows the current readline key bindings to be displayed or modified 5921with the 5922<B>bind</B> 5923 5924builtin command. The editing mode may be switched during interactive 5925use by using the 5926<B>-o</B> 5927 5928option to the 5929<B>set</B> 5930 5931builtin command (see 5932<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 5933 5934</FONT> 5935below). 5936<A NAME="lbCH"> </A> 5937<H4>Readline Variables</H4> 5938 5939<P> 5940 5941Readline has variables that can be used to further customize its 5942behavior. A variable may be set in the 5943<I>inputrc</I> 5944 5945file with a statement of the form 5946<DL COMPACT><DT><DD> 5947<P> 5948 5949<B>set</B> <I>variable-name</I> <I>value</I> 5950</DL> 5951 5952<P> 5953 5954Except where noted, readline variables can take the values 5955<B>On</B> 5956 5957or 5958<B>Off</B> 5959 5960(without regard to case). 5961Unrecognized variable names are ignored. 5962When a variable value is read, empty or null values, "on" (case-insensitive), 5963and "1" are equivalent to <B>On</B>. All other values are equivalent to 5964<B>Off</B>. 5965The variables and their default values are: 5966<P> 5967 5968 5969<DL COMPACT> 5970<DT><B>bell-style (audible)</B> 5971 5972<DD> 5973Controls what happens when readline wants to ring the terminal bell. 5974If set to <B>none</B>, readline never rings the bell. If set to 5975<B>visible</B>, readline uses a visible bell if one is available. 5976If set to <B>audible</B>, readline attempts to ring the terminal's bell. 5977<DT><B>bind-tty-special-chars (On)</B> 5978 5979<DD> 5980If set to <B>On</B>, readline attempts to bind the control characters 5981treated specially by the kernel's terminal driver to their readline 5982equivalents. 5983<DT><B>comment-begin (``#'')</B> 5984 5985<DD> 5986The string that is inserted when the readline 5987<B>insert-comment</B> 5988 5989command is executed. 5990This command is bound to 5991<B>M-#</B> 5992 5993in emacs mode and to 5994<B>#</B> 5995 5996in vi command mode. 5997<DT><B>completion-ignore-case (Off)</B> 5998 5999<DD> 6000If set to <B>On</B>, readline performs filename matching and completion 6001in a case-insensitive fashion. 6002<DT><B>completion-query-items (100)</B> 6003 6004<DD> 6005This determines when the user is queried about viewing 6006the number of possible completions 6007generated by the <B>possible-completions</B> command. 6008It may be set to any integer value greater than or equal to 6009zero. If the number of possible completions is greater than 6010or equal to the value of this variable, the user is asked whether 6011or not he wishes to view them; otherwise they are simply listed 6012on the terminal. 6013<DT><B>convert-meta (On)</B> 6014 6015<DD> 6016If set to <B>On</B>, readline will convert characters with the 6017eighth bit set to an ASCII key sequence 6018by stripping the eighth bit and prefixing an 6019escape character (in effect, using escape as the <I>meta prefix</I>). 6020<DT><B>disable-completion (Off)</B> 6021 6022<DD> 6023If set to <B>On</B>, readline will inhibit word completion. Completion 6024characters will be inserted into the line as if they had been 6025mapped to <B>self-insert</B>. 6026<DT><B>editing-mode (emacs)</B> 6027 6028<DD> 6029Controls whether readline begins with a set of key bindings similar 6030to <I>emacs</I> or <I>vi</I>. 6031<B>editing-mode</B> 6032 6033can be set to either 6034<B>emacs</B> 6035 6036or 6037<B>vi</B>. 6038 6039<DT><B>enable-keypad (Off)</B> 6040 6041<DD> 6042When set to <B>On</B>, readline will try to enable the application 6043keypad when it is called. Some systems need this to enable the 6044arrow keys. 6045<DT><B>expand-tilde (Off)</B> 6046 6047<DD> 6048If set to <B>on</B>, tilde expansion is performed when readline 6049attempts word completion. 6050<DT><B>history-preserve-point (Off)</B> 6051 6052<DD> 6053If set to <B>on</B>, the history code attempts to place point at the 6054same location on each history line retrieved with <B>previous-history</B> 6055or <B>next-history</B>. 6056<DT><B>horizontal-scroll-mode (Off)</B> 6057 6058<DD> 6059When set to <B>On</B>, makes readline use a single line for display, 6060scrolling the input horizontally on a single screen line when it 6061becomes longer than the screen width rather than wrapping to a new line. 6062<DT><B>input-meta (Off)</B> 6063 6064<DD> 6065If set to <B>On</B>, readline will enable eight-bit input (that is, 6066it will not strip the high bit from the characters it reads), 6067regardless of what the terminal claims it can support. The name 6068<B>meta-flag</B> 6069 6070is a synonym for this variable. 6071<DT><B>isearch-terminators (``C-[C-J'')</B> 6072 6073<DD> 6074The string of characters that should terminate an incremental 6075search without subsequently executing the character as a command. 6076If this variable has not been given a value, the characters 6077<I>ESC</I> and <I>C-J</I> will terminate an incremental search. 6078<DT><B>keymap (emacs)</B> 6079 6080<DD> 6081Set the current readline keymap. The set of valid keymap names is 6082<I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, 6083vi-command</I>, and 6084<I>vi-insert</I>. 6085 6086<I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is 6087equivalent to <I>emacs-standard</I>. The default value is 6088<I>emacs</I>; 6089 6090the value of 6091<B>editing-mode</B> 6092 6093also affects the default keymap. 6094<DT><B>mark-directories (On)</B> 6095 6096<DD> 6097If set to <B>On</B>, completed directory names have a slash 6098appended. 6099<DT><B>mark-modified-lines (Off)</B> 6100 6101<DD> 6102If set to <B>On</B>, history lines that have been modified are displayed 6103with a preceding asterisk (<B>*</B>). 6104<DT><B>mark-symlinked-directories (Off)</B> 6105 6106<DD> 6107If set to <B>On</B>, completed names which are symbolic links to directories 6108have a slash appended (subject to the value of 6109<B>mark-directories</B>). 6110<DT><B>match-hidden-files (On)</B> 6111 6112<DD> 6113This variable, when set to <B>On</B>, causes readline to match files whose 6114names begin with a `.' (hidden files) when performing filename 6115completion, unless the leading `.' is 6116supplied by the user in the filename to be completed. 6117<DT><B>output-meta (Off)</B> 6118 6119<DD> 6120If set to <B>On</B>, readline will display characters with the 6121eighth bit set directly rather than as a meta-prefixed escape 6122sequence. 6123<DT><B>page-completions (On)</B> 6124 6125<DD> 6126If set to <B>On</B>, readline uses an internal <I>more</I>-like pager 6127to display a screenful of possible completions at a time. 6128<DT><B>print-completions-horizontally (Off)</B> 6129 6130<DD> 6131If set to <B>On</B>, readline will display completions with matches 6132sorted horizontally in alphabetical order, rather than down the screen. 6133<DT><B>show-all-if-ambiguous (Off)</B> 6134 6135<DD> 6136This alters the default behavior of the completion functions. If 6137set to 6138<B>on</B>, 6139 6140words which have more than one possible completion cause the 6141matches to be listed immediately instead of ringing the bell. 6142<DT><B>show-all-if-unmodified (Off)</B> 6143 6144<DD> 6145This alters the default behavior of the completion functions in 6146a fashion similar to <B>show-all-if-ambiguous</B>. 6147If set to 6148<B>on</B>, 6149 6150words which have more than one possible completion without any 6151possible partial completion (the possible completions don't share 6152a common prefix) cause the matches to be listed immediately instead 6153of ringing the bell. 6154<DT><B>visible-stats (Off)</B> 6155 6156<DD> 6157If set to <B>On</B>, a character denoting a file's type as reported 6158by <I>stat</I>(2) is appended to the filename when listing possible 6159completions. 6160 6161</DL> 6162<A NAME="lbCI"> </A> 6163<H4>Readline Conditional Constructs</H4> 6164 6165<P> 6166 6167Readline implements a facility similar in spirit to the conditional 6168compilation features of the C preprocessor which allows key 6169bindings and variable settings to be performed as the result 6170of tests. There are four parser directives used. 6171<DL COMPACT> 6172<DT><B>$if</B><DD> 6173The 6174<B>$if</B> 6175 6176construct allows bindings to be made based on the 6177editing mode, the terminal being used, or the application using 6178readline. The text of the test extends to the end of the line; 6179no characters are required to isolate it. 6180<DL COMPACT><DT><DD> 6181<DL COMPACT> 6182<DT><B>mode</B><DD> 6183The <B>mode=</B> form of the <B>$if</B> directive is used to test 6184whether readline is in emacs or vi mode. 6185This may be used in conjunction 6186with the <B>set keymap</B> command, for instance, to set bindings in 6187the <I>emacs-standard</I> and <I>emacs-ctlx</I> keymaps only if 6188readline is starting out in emacs mode. 6189<DT><B>term</B><DD> 6190The <B>term=</B> form may be used to include terminal-specific 6191key bindings, perhaps to bind the key sequences output by the 6192terminal's function keys. The word on the right side of the 6193<B>=</B> 6194 6195is tested against the both full name of the terminal and the portion 6196of the terminal name before the first <B>-</B>. This allows 6197<I>sun</I> 6198 6199to match both 6200<I>sun</I> 6201 6202and 6203<I>sun-cmd</I>, 6204 6205for instance. 6206<DT><B>application</B><DD> 6207The <B>application</B> construct is used to include 6208application-specific settings. Each program using the readline 6209library sets the <I>application name</I>, and an initialization 6210file can test for a particular value. 6211This could be used to bind key sequences to functions useful for 6212a specific program. For instance, the following command adds a 6213key sequence that quotes the current or previous word in Bash: 6214<P> 6215<DL COMPACT><DT><DD> 6216<PRE> 6217<B>$if</B> Bash 6218# Quote the current or previous word 6219"\C-xq": "\eb\"\ef\"" 6220<B>$endif</B> 6221</PRE> 6222 6223</DL> 6224 6225</DL></DL> 6226 6227<DT><B>$endif</B><DD> 6228This command, as seen in the previous example, terminates an 6229<B>$if</B> command. 6230<DT><B>$else</B><DD> 6231Commands in this branch of the <B>$if</B> directive are executed if 6232the test fails. 6233<DT><B>$include</B><DD> 6234This directive takes a single filename as an argument and reads commands 6235and bindings from that file. For example, the following directive 6236would read <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>: 6237<P> 6238<DL COMPACT><DT><DD> 6239<PRE> 6240<B>$include</B> <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A> 6241</PRE> 6242 6243</DL> 6244 6245</DL> 6246<A NAME="lbCJ"> </A> 6247<H4>Searching</H4> 6248 6249<P> 6250 6251Readline provides commands for searching through the command history 6252(see 6253<FONT SIZE=-1><B>HISTORY</B> 6254 6255</FONT> 6256below) for lines containing a specified string. 6257There are two search modes: 6258<I>incremental</I> 6259 6260and 6261<I>non-incremental</I>. 6262 6263<P> 6264 6265Incremental searches begin before the user has finished typing the 6266search string. 6267As each character of the search string is typed, readline displays 6268the next entry from the history matching the string typed so far. 6269An incremental search requires only as many characters as needed to 6270find the desired history entry. 6271The characters present in the value of the <B>isearch-terminators</B> 6272variable are used to terminate an incremental search. 6273If that variable has not been assigned a value the Escape and 6274Control-J characters will terminate an incremental search. 6275Control-G will abort an incremental search and restore the original 6276line. 6277When the search is terminated, the history entry containing the 6278search string becomes the current line. 6279<P> 6280 6281To find other matching entries in the history list, type Control-S or 6282Control-R as appropriate. 6283This will search backward or forward in the history for the next 6284entry matching the search string typed so far. 6285Any other key sequence bound to a readline command will terminate 6286the search and execute that command. 6287For instance, a <I>newline</I> will terminate the search and accept 6288the line, thereby executing the command from the history list. 6289<P> 6290 6291Readline remembers the last incremental search string. If two 6292Control-Rs are typed without any intervening characters defining a 6293new search string, any remembered search string is used. 6294<P> 6295 6296Non-incremental searches read the entire search string before starting 6297to search for matching history lines. The search string may be 6298typed by the user or be part of the contents of the current line. 6299<A NAME="lbCK"> </A> 6300<H4>Readline Command Names</H4> 6301 6302<P> 6303 6304The following is a list of the names of the commands and the default 6305key sequences to which they are bound. 6306Command names without an accompanying key sequence are unbound by default. 6307In the following descriptions, <I>point</I> refers to the current cursor 6308position, and <I>mark</I> refers to a cursor position saved by the 6309<B>set-mark</B> command. 6310The text between the point and mark is referred to as the <I>region</I>. 6311<A NAME="lbCL"> </A> 6312<H4>Commands for Moving</H4> 6313 6314<P> 6315 6316 6317<DL COMPACT> 6318<DT><B>beginning-of-line (C-a)</B> 6319 6320<DD> 6321Move to the start of the current line. 6322<DT><B>end-of-line (C-e)</B> 6323 6324<DD> 6325Move to the end of the line. 6326<DT><B>forward-char (C-f)</B> 6327 6328<DD> 6329Move forward a character. 6330<DT><B>backward-char (C-b)</B> 6331 6332<DD> 6333Move back a character. 6334<DT><B>forward-word (M-f)</B> 6335 6336<DD> 6337Move forward to the end of the next word. Words are composed of 6338alphanumeric characters (letters and digits). 6339<DT><B>backward-word (M-b)</B> 6340 6341<DD> 6342Move back to the start of the current or previous word. Words are 6343composed of alphanumeric characters (letters and digits). 6344<DT><B>clear-screen (C-l)</B> 6345 6346<DD> 6347Clear the screen leaving the current line at the top of the screen. 6348With an argument, refresh the current line without clearing the 6349screen. 6350<DT><B>redraw-current-line</B> 6351 6352<DD> 6353Refresh the current line. 6354 6355</DL> 6356<A NAME="lbCM"> </A> 6357<H4>Commands for Manipulating the History</H4> 6358 6359<P> 6360 6361 6362<DL COMPACT> 6363<DT><B>accept-line (Newline, Return)</B> 6364 6365<DD> 6366Accept the line regardless of where the cursor is. If this line is 6367non-empty, add it to the history list according to the state of the 6368<FONT SIZE=-1><B>HISTCONTROL</B> 6369 6370</FONT> 6371variable. If the line is a modified history 6372line, then restore the history line to its original state. 6373<DT><B>previous-history (C-p)</B> 6374 6375<DD> 6376Fetch the previous command from the history list, moving back in 6377the list. 6378<DT><B>next-history (C-n)</B> 6379 6380<DD> 6381Fetch the next command from the history list, moving forward in the 6382list. 6383<DT><B>beginning-of-history (M-<)</B> 6384 6385<DD> 6386Move to the first line in the history. 6387<DT><B>end-of-history (M->)</B> 6388 6389<DD> 6390Move to the end of the input history, i.e., the line currently being 6391entered. 6392<DT><B>reverse-search-history (C-r)</B> 6393 6394<DD> 6395Search backward starting at the current line and moving `up' through 6396the history as necessary. This is an incremental search. 6397<DT><B>forward-search-history (C-s)</B> 6398 6399<DD> 6400Search forward starting at the current line and moving `down' through 6401the history as necessary. This is an incremental search. 6402<DT><B>non-incremental-reverse-search-history (M-p)</B> 6403 6404<DD> 6405Search backward through the history starting at the current line 6406using a non-incremental search for a string supplied by the user. 6407<DT><B>non-incremental-forward-search-history (M-n)</B> 6408 6409<DD> 6410Search forward through the history using a non-incremental search for 6411a string supplied by the user. 6412<DT><B>history-search-forward</B> 6413 6414<DD> 6415Search forward through the history for the string of characters 6416between the start of the current line and the point. 6417This is a non-incremental search. 6418<DT><B>history-search-backward</B> 6419 6420<DD> 6421Search backward through the history for the string of characters 6422between the start of the current line and the point. 6423This is a non-incremental search. 6424<DT><B>yank-nth-arg (M-C-y)</B> 6425 6426<DD> 6427Insert the first argument to the previous command (usually 6428the second word on the previous line) at point. 6429With an argument 6430<I>n</I>, 6431 6432insert the <I>n</I>th word from the previous command (the words 6433in the previous command begin with word 0). A negative argument 6434inserts the <I>n</I>th word from the end of the previous command. 6435Once the argument <I>n</I> is computed, the argument is extracted 6436as if the "!<I>n</I>" history expansion had been specified. 6437<DT><B>yank-last-arg (M-., M-_)</B> 6438 6439<DD> 6440Insert the last argument to the previous command (the last word of 6441the previous history entry). With an argument, 6442behave exactly like <B>yank-nth-arg</B>. 6443Successive calls to <B>yank-last-arg</B> move back through the history 6444list, inserting the last argument of each line in turn. 6445The history expansion facilities are used to extract the last argument, 6446as if the "!$" history expansion had been specified. 6447<DT><B>shell-expand-line (M-C-e)</B> 6448 6449<DD> 6450Expand the line as the shell does. This 6451performs alias and history expansion as well as all of the shell 6452word expansions. See 6453<FONT SIZE=-1><B>HISTORY EXPANSION</B> 6454 6455</FONT> 6456below for a description of history expansion. 6457<DT><B>history-expand-line (M-^)</B> 6458 6459<DD> 6460Perform history expansion on the current line. 6461See 6462<FONT SIZE=-1><B>HISTORY EXPANSION</B> 6463 6464</FONT> 6465below for a description of history expansion. 6466<DT><B>magic-space</B> 6467 6468<DD> 6469Perform history expansion on the current line and insert a space. 6470See 6471<FONT SIZE=-1><B>HISTORY EXPANSION</B> 6472 6473</FONT> 6474below for a description of history expansion. 6475<DT><B>alias-expand-line</B> 6476 6477<DD> 6478Perform alias expansion on the current line. 6479See 6480<FONT SIZE=-1><B>ALIASES</B> 6481 6482</FONT> 6483above for a description of alias expansion. 6484<DT><B>history-and-alias-expand-line</B> 6485 6486<DD> 6487Perform history and alias expansion on the current line. 6488<DT><B>insert-last-argument (M-., M-_)</B> 6489 6490<DD> 6491A synonym for <B>yank-last-arg</B>. 6492<DT><B>operate-and-get-next (C-o)</B> 6493 6494<DD> 6495Accept the current line for execution and fetch the next line 6496relative to the current line from the history for editing. Any 6497argument is ignored. 6498<DT><B>edit-and-execute-command (C-xC-e)</B> 6499 6500<DD> 6501Invoke an editor on the current command line, and execute the result as shell 6502commands. 6503<B>Bash</B> attempts to invoke 6504<FONT SIZE=-1><B>$FCEDIT</B>, 6505 6506</FONT> 6507<FONT SIZE=-1><B>$EDITOR</B>, 6508 6509</FONT> 6510and <I>emacs</I> as the editor, in that order. 6511 6512</DL> 6513<A NAME="lbCN"> </A> 6514<H4>Commands for Changing Text</H4> 6515 6516<P> 6517 6518 6519<DL COMPACT> 6520<DT><B>delete-char (C-d)</B> 6521 6522<DD> 6523Delete the character at point. If point is at the 6524beginning of the line, there are no characters in the line, and 6525the last character typed was not bound to <B>delete-char</B>, 6526then return 6527<FONT SIZE=-1><B>EOF</B>. 6528 6529</FONT> 6530<DT><B>backward-delete-char (Rubout)</B> 6531 6532<DD> 6533Delete the character behind the cursor. When given a numeric argument, 6534save the deleted text on the kill ring. 6535<DT><B>forward-backward-delete-char</B> 6536 6537<DD> 6538Delete the character under the cursor, unless the cursor is at the 6539end of the line, in which case the character behind the cursor is 6540deleted. 6541<DT><B>quoted-insert (C-q, C-v)</B> 6542 6543<DD> 6544Add the next character typed to the line verbatim. This is 6545how to insert characters like <B>C-q</B>, for example. 6546<DT><B>tab-insert (C-v TAB)</B> 6547 6548<DD> 6549Insert a tab character. 6550<DT><B>self-insert (a, b, A, 1, !, ...)</B> 6551 6552<DD> 6553Insert the character typed. 6554<DT><B>transpose-chars (C-t)</B> 6555 6556<DD> 6557Drag the character before point forward over the character at point, 6558moving point forward as well. 6559If point is at the end of the line, then this transposes 6560the two characters before point. 6561Negative arguments have no effect. 6562<DT><B>transpose-words (M-t)</B> 6563 6564<DD> 6565Drag the word before point past the word after point, 6566moving point over that word as well. 6567If point is at the end of the line, this transposes 6568the last two words on the line. 6569<DT><B>upcase-word (M-u)</B> 6570 6571<DD> 6572Uppercase the current (or following) word. With a negative argument, 6573uppercase the previous word, but do not move point. 6574<DT><B>downcase-word (M-l)</B> 6575 6576<DD> 6577Lowercase the current (or following) word. With a negative argument, 6578lowercase the previous word, but do not move point. 6579<DT><B>capitalize-word (M-c)</B> 6580 6581<DD> 6582Capitalize the current (or following) word. With a negative argument, 6583capitalize the previous word, but do not move point. 6584<DT><B>overwrite-mode</B> 6585 6586<DD> 6587Toggle overwrite mode. With an explicit positive numeric argument, 6588switches to overwrite mode. With an explicit non-positive numeric 6589argument, switches to insert mode. This command affects only 6590<B>emacs</B> mode; <B>vi</B> mode does overwrite differently. 6591Each call to <I>readline()</I> starts in insert mode. 6592In overwrite mode, characters bound to <B>self-insert</B> replace 6593the text at point rather than pushing the text to the right. 6594Characters bound to <B>backward-delete-char</B> replace the character 6595before point with a space. By default, this command is unbound. 6596 6597</DL> 6598<A NAME="lbCO"> </A> 6599<H4>Killing and Yanking</H4> 6600 6601<P> 6602 6603 6604<DL COMPACT> 6605<DT><B>kill-line (C-k)</B> 6606 6607<DD> 6608Kill the text from point to the end of the line. 6609<DT><B>backward-kill-line (C-x Rubout)</B> 6610 6611<DD> 6612Kill backward to the beginning of the line. 6613<DT><B>unix-line-discard (C-u)</B> 6614 6615<DD> 6616Kill backward from point to the beginning of the line. 6617The killed text is saved on the kill-ring. 6618 6619<DT><B>kill-whole-line</B> 6620 6621<DD> 6622Kill all characters on the current line, no matter where point is. 6623<DT><B>kill-word (M-d)</B> 6624 6625<DD> 6626Kill from point to the end of the current word, or if between 6627words, to the end of the next word. 6628Word boundaries are the same as those used by <B>forward-word</B>. 6629<DT><B>backward-kill-word (M-Rubout)</B> 6630 6631<DD> 6632Kill the word behind point. 6633Word boundaries are the same as those used by <B>backward-word</B>. 6634<DT><B>unix-word-rubout (C-w)</B> 6635 6636<DD> 6637Kill the word behind point, using white space as a word boundary. 6638The killed text is saved on the kill-ring. 6639<DT><B>unix-filename-rubout</B> 6640 6641<DD> 6642Kill the word behind point, using white space and the slash character 6643as the word boundaries. 6644The killed text is saved on the kill-ring. 6645<DT><B>delete-horizontal-space (M-\)</B> 6646 6647<DD> 6648Delete all spaces and tabs around point. 6649<DT><B>kill-region</B> 6650 6651<DD> 6652Kill the text in the current region. 6653<DT><B>copy-region-as-kill</B> 6654 6655<DD> 6656Copy the text in the region to the kill buffer. 6657<DT><B>copy-backward-word</B> 6658 6659<DD> 6660Copy the word before point to the kill buffer. 6661The word boundaries are the same as <B>backward-word</B>. 6662<DT><B>copy-forward-word</B> 6663 6664<DD> 6665Copy the word following point to the kill buffer. 6666The word boundaries are the same as <B>forward-word</B>. 6667<DT><B>yank (C-y)</B> 6668 6669<DD> 6670Yank the top of the kill ring into the buffer at point. 6671<DT><B>yank-pop (M-y)</B> 6672 6673<DD> 6674Rotate the kill ring, and yank the new top. Only works following 6675<B>yank</B> 6676 6677or 6678<B>yank-pop</B>. 6679 6680 6681</DL> 6682<A NAME="lbCP"> </A> 6683<H4>Numeric Arguments</H4> 6684 6685<P> 6686 6687 6688<DL COMPACT> 6689<DT><B>digit-argument (M-0, M-1, ..., M--)</B> 6690 6691<DD> 6692Add this digit to the argument already accumulating, or start a new 6693argument. M-- starts a negative argument. 6694<DT><B>universal-argument</B> 6695 6696<DD> 6697This is another way to specify an argument. 6698If this command is followed by one or more digits, optionally with a 6699leading minus sign, those digits define the argument. 6700If the command is followed by digits, executing 6701<B>universal-argument</B> 6702 6703again ends the numeric argument, but is otherwise ignored. 6704As a special case, if this command is immediately followed by a 6705character that is neither a digit or minus sign, the argument count 6706for the next command is multiplied by four. 6707The argument count is initially one, so executing this function the 6708first time makes the argument count four, a second time makes the 6709argument count sixteen, and so on. 6710 6711</DL> 6712<A NAME="lbCQ"> </A> 6713<H4>Completing</H4> 6714 6715<P> 6716 6717 6718<DL COMPACT> 6719<DT><B>complete (TAB)</B> 6720 6721<DD> 6722Attempt to perform completion on the text before point. 6723<B>Bash</B> 6724 6725attempts completion treating the text as a variable (if the 6726text begins with <B>$</B>), username (if the text begins with 6727<B>~</B>), hostname (if the text begins with <B>@</B>), or 6728command (including aliases and functions) in turn. If none 6729of these produces a match, filename completion is attempted. 6730<DT><B>possible-completions (M-?)</B> 6731 6732<DD> 6733List the possible completions of the text before point. 6734<DT><B>insert-completions (M-*)</B> 6735 6736<DD> 6737Insert all completions of the text before point 6738that would have been generated by 6739<B>possible-completions</B>. 6740<DT><B>menu-complete</B> 6741 6742<DD> 6743Similar to <B>complete</B>, but replaces the word to be completed 6744with a single match from the list of possible completions. 6745Repeated execution of <B>menu-complete</B> steps through the list 6746of possible completions, inserting each match in turn. 6747At the end of the list of completions, the bell is rung 6748(subject to the setting of <B>bell-style</B>) 6749and the original text is restored. 6750An argument of <I>n</I> moves <I>n</I> positions forward in the list 6751of matches; a negative argument may be used to move backward 6752through the list. 6753This command is intended to be bound to <B>TAB</B>, but is unbound 6754by default. 6755<DT><B>delete-char-or-list</B> 6756 6757<DD> 6758Deletes the character under the cursor if not at the beginning or 6759end of the line (like <B>delete-char</B>). 6760If at the end of the line, behaves identically to 6761<B>possible-completions</B>. 6762This command is unbound by default. 6763<DT><B>complete-filename (M-/)</B> 6764 6765<DD> 6766Attempt filename completion on the text before point. 6767<DT><B>possible-filename-completions (C-x /)</B> 6768 6769<DD> 6770List the possible completions of the text before point, 6771treating it as a filename. 6772<DT><B>complete-username (M-~)</B> 6773 6774<DD> 6775Attempt completion on the text before point, treating 6776it as a username. 6777<DT><B>possible-username-completions (C-x ~)</B> 6778 6779<DD> 6780List the possible completions of the text before point, 6781treating it as a username. 6782<DT><B>complete-variable (M-$)</B> 6783 6784<DD> 6785Attempt completion on the text before point, treating 6786it as a shell variable. 6787<DT><B>possible-variable-completions (C-x $)</B> 6788 6789<DD> 6790List the possible completions of the text before point, 6791treating it as a shell variable. 6792<DT><B>complete-hostname (M-@)</B> 6793 6794<DD> 6795Attempt completion on the text before point, treating 6796it as a hostname. 6797<DT><B>possible-hostname-completions (C-x @)</B> 6798 6799<DD> 6800List the possible completions of the text before point, 6801treating it as a hostname. 6802<DT><B>complete-command (M-!)</B> 6803 6804<DD> 6805Attempt completion on the text before point, treating 6806it as a command name. Command completion attempts to 6807match the text against aliases, reserved words, shell 6808functions, shell builtins, and finally executable filenames, 6809in that order. 6810<DT><B>possible-command-completions (C-x !)</B> 6811 6812<DD> 6813List the possible completions of the text before point, 6814treating it as a command name. 6815<DT><B>dynamic-complete-history (M-TAB)</B> 6816 6817<DD> 6818Attempt completion on the text before point, comparing 6819the text against lines from the history list for possible 6820completion matches. 6821<DT><B>complete-into-braces (M-{)</B> 6822 6823<DD> 6824Perform filename completion and insert the list of possible completions 6825enclosed within braces so the list is available to the shell (see 6826<B>Brace Expansion</B> 6827 6828above). 6829 6830</DL> 6831<A NAME="lbCR"> </A> 6832<H4>Keyboard Macros</H4> 6833 6834<P> 6835 6836 6837<DL COMPACT> 6838<DT><B>start-kbd-macro (C-x ()</B> 6839 6840<DD> 6841Begin saving the characters typed into the current keyboard macro. 6842<DT><B>end-kbd-macro (C-x ))</B> 6843 6844<DD> 6845Stop saving the characters typed into the current keyboard macro 6846and store the definition. 6847<DT><B>call-last-kbd-macro (C-x e)</B> 6848 6849<DD> 6850Re-execute the last keyboard macro defined, by making the characters 6851in the macro appear as if typed at the keyboard. 6852 6853</DL> 6854<A NAME="lbCS"> </A> 6855<H4>Miscellaneous</H4> 6856 6857<P> 6858 6859 6860<DL COMPACT> 6861<DT><B>re-read-init-file (C-x C-r)</B> 6862 6863<DD> 6864Read in the contents of the <I>inputrc</I> file, and incorporate 6865any bindings or variable assignments found there. 6866<DT><B>abort (C-g)</B> 6867 6868<DD> 6869Abort the current editing command and 6870ring the terminal's bell (subject to the setting of 6871<B>bell-style</B>). 6872 6873<DT><B>do-uppercase-version (M-a, M-b, M-</B><I>x</I>, ...) 6874 6875<DD> 6876If the metafied character <I>x</I> is lowercase, run the command 6877that is bound to the corresponding uppercase character. 6878<DT><B>prefix-meta (ESC)</B> 6879 6880<DD> 6881Metafy the next character typed. 6882<FONT SIZE=-1><B>ESC</B> 6883 6884</FONT> 6885<B>f</B> 6886 6887is equivalent to 6888<B>Meta-f</B>. 6889 6890<DT><B>undo (C-_, C-x C-u)</B> 6891 6892<DD> 6893Incremental undo, separately remembered for each line. 6894<DT><B>revert-line (M-r)</B> 6895 6896<DD> 6897Undo all changes made to this line. This is like executing the 6898<B>undo</B> 6899 6900command enough times to return the line to its initial state. 6901<DT><B>tilde-expand (M-&)</B> 6902 6903<DD> 6904Perform tilde expansion on the current word. 6905<DT><B>set-mark (C-@, M-<space>)</B> 6906 6907<DD> 6908Set the mark to the point. If a 6909numeric argument is supplied, the mark is set to that position. 6910<DT><B>exchange-point-and-mark (C-x C-x)</B> 6911 6912<DD> 6913Swap the point with the mark. The current cursor position is set to 6914the saved position, and the old cursor position is saved as the mark. 6915<DT><B>character-search (C-])</B> 6916 6917<DD> 6918A character is read and point is moved to the next occurrence of that 6919character. A negative count searches for previous occurrences. 6920<DT><B>character-search-backward (M-C-])</B> 6921 6922<DD> 6923A character is read and point is moved to the previous occurrence of that 6924character. A negative count searches for subsequent occurrences. 6925<DT><B>insert-comment (M-#)</B> 6926 6927<DD> 6928Without a numeric argument, the value of the readline 6929<B>comment-begin</B> 6930 6931variable is inserted at the beginning of the current line. 6932If a numeric argument is supplied, this command acts as a toggle: if 6933the characters at the beginning of the line do not match the value 6934of <B>comment-begin</B>, the value is inserted, otherwise 6935the characters in <B>comment-begin</B> are deleted from the beginning of 6936the line. 6937In either case, the line is accepted as if a newline had been typed. 6938The default value of 6939<B>comment-begin</B> causes this command to make the current line 6940a shell comment. 6941If a numeric argument causes the comment character to be removed, the line 6942will be executed by the shell. 6943<DT><B>glob-complete-word (M-g)</B> 6944 6945<DD> 6946The word before point is treated as a pattern for pathname expansion, 6947with an asterisk implicitly appended. This pattern is used to 6948generate a list of matching file names for possible completions. 6949<DT><B>glob-expand-word (C-x *)</B> 6950 6951<DD> 6952The word before point is treated as a pattern for pathname expansion, 6953and the list of matching file names is inserted, replacing the word. 6954If a numeric argument is supplied, an asterisk is appended before 6955pathname expansion. 6956<DT><B>glob-list-expansions (C-x g)</B> 6957 6958<DD> 6959The list of expansions that would have been generated by 6960<B>glob-expand-word</B> 6961 6962is displayed, and the line is redrawn. 6963If a numeric argument is supplied, an asterisk is appended before 6964pathname expansion. 6965<DT><B>dump-functions</B> 6966 6967<DD> 6968Print all of the functions and their key bindings to the 6969readline output stream. If a numeric argument is supplied, 6970the output is formatted in such a way that it can be made part 6971of an <I>inputrc</I> file. 6972<DT><B>dump-variables</B> 6973 6974<DD> 6975Print all of the settable readline variables and their values to the 6976readline output stream. If a numeric argument is supplied, 6977the output is formatted in such a way that it can be made part 6978of an <I>inputrc</I> file. 6979<DT><B>dump-macros</B> 6980 6981<DD> 6982Print all of the readline key sequences bound to macros and the 6983strings they output. If a numeric argument is supplied, 6984the output is formatted in such a way that it can be made part 6985of an <I>inputrc</I> file. 6986<DT><B>display-shell-version (C-x C-v)</B> 6987 6988<DD> 6989Display version information about the current instance of 6990<B>bash</B>. 6991 6992 6993</DL> 6994<A NAME="lbCT"> </A> 6995<H4>Programmable Completion</H4> 6996 6997<P> 6998 6999When word completion is attempted for an argument to a command for 7000which a completion specification (a <I>compspec</I>) has been defined 7001using the <B>complete</B> builtin (see 7002<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 7003 7004</FONT> 7005below), the programmable completion facilities are invoked. 7006<P> 7007 7008First, the command name is identified. 7009If a compspec has been defined for that command, the 7010compspec is used to generate the list of possible completions for the word. 7011If the command word is a full pathname, a compspec for the full 7012pathname is searched for first. 7013If no compspec is found for the full pathname, an attempt is made to 7014find a compspec for the portion following the final slash. 7015<P> 7016 7017Once a compspec has been found, it is used to generate the list of 7018matching words. 7019If a compspec is not found, the default <B>bash</B> completion as 7020described above under <B>Completing</B> is performed. 7021<P> 7022 7023First, the actions specified by the compspec are used. 7024Only matches which are prefixed by the word being completed are 7025returned. 7026When the 7027<B>-f</B> 7028 7029or 7030<B>-d</B> 7031 7032option is used for filename or directory name completion, the shell 7033variable 7034<FONT SIZE=-1><B>FIGNORE</B> 7035 7036</FONT> 7037is used to filter the matches. 7038<P> 7039 7040Any completions specified by a filename expansion pattern to the 7041<B>-G</B> option are generated next. 7042The words generated by the pattern need not match the word 7043being completed. 7044The 7045<FONT SIZE=-1><B>GLOBIGNORE</B> 7046 7047</FONT> 7048shell variable is not used to filter the matches, but the 7049<FONT SIZE=-1><B>FIGNORE</B> 7050 7051</FONT> 7052variable is used. 7053<P> 7054 7055Next, the string specified as the argument to the <B>-W</B> option 7056is considered. 7057The string is first split using the characters in the 7058<FONT SIZE=-1><B>IFS</B> 7059 7060</FONT> 7061special variable as delimiters. 7062Shell quoting is honored. 7063Each word is then expanded using 7064brace expansion, tilde expansion, parameter and variable expansion, 7065command substitution, and arithmetic expansion, 7066as described above under 7067<FONT SIZE=-1><B>EXPANSION</B>. 7068 7069</FONT> 7070The results are split using the rules described above under 7071<B>Word Splitting</B>. 7072The results of the expansion are prefix-matched against the word being 7073completed, and the matching words become the possible completions. 7074<P> 7075 7076After these matches have been generated, any shell function or command 7077specified with the <B>-F</B> and <B>-C</B> options is invoked. 7078When the command or function is invoked, the 7079<FONT SIZE=-1><B>COMP_LINE</B> 7080 7081</FONT> 7082and 7083<FONT SIZE=-1><B>COMP_POINT</B> 7084 7085</FONT> 7086variables are assigned values as described above under 7087<B>Shell Variables</B>. 7088If a shell function is being invoked, the 7089<FONT SIZE=-1><B>COMP_WORDS</B> 7090 7091</FONT> 7092and 7093<FONT SIZE=-1><B>COMP_CWORD</B> 7094 7095</FONT> 7096variables are also set. 7097When the function or command is invoked, the first argument is the 7098name of the command whose arguments are being completed, the 7099second argument is the word being completed, and the third argument 7100is the word preceding the word being completed on the current command line. 7101No filtering of the generated completions against the word being completed 7102is performed; the function or command has complete freedom in generating 7103the matches. 7104<P> 7105 7106Any function specified with <B>-F</B> is invoked first. 7107The function may use any of the shell facilities, including the 7108<B>compgen</B> builtin described below, to generate the matches. 7109It must put the possible completions in the 7110<FONT SIZE=-1><B>COMPREPLY</B> 7111 7112</FONT> 7113array variable. 7114<P> 7115 7116Next, any command specified with the <B>-C</B> option is invoked 7117in an environment equivalent to command substitution. 7118It should print a list of completions, one per line, to the 7119standard output. 7120Backslash may be used to escape a newline, if necessary. 7121<P> 7122 7123After all of the possible completions are generated, any filter 7124specified with the <B>-X</B> option is applied to the list. 7125The filter is a pattern as used for pathname expansion; a <B>&</B> 7126in the pattern is replaced with the text of the word being completed. 7127A literal <B>&</B> may be escaped with a backslash; the backslash 7128is removed before attempting a match. 7129Any completion that matches the pattern will be removed from the list. 7130A leading <B>!</B> negates the pattern; in this case any completion 7131not matching the pattern will be removed. 7132<P> 7133 7134Finally, any prefix and suffix specified with the <B>-P</B> and <B>-S</B> 7135options are added to each member of the completion list, and the result is 7136returned to the readline completion code as the list of possible 7137completions. 7138<P> 7139 7140If the previously-applied actions do not generate any matches, and the 7141<B>-o dirnames</B> option was supplied to <B>complete</B> when the 7142compspec was defined, directory name completion is attempted. 7143<P> 7144 7145If the <B>-o plusdirs</B> option was supplied to <B>complete</B> when the 7146compspec was defined, directory name completion is attempted and any 7147matches are added to the results of the other actions. 7148<P> 7149 7150By default, if a compspec is found, whatever it generates is returned 7151to the completion code as the full set of possible completions. 7152The default <B>bash</B> completions are not attempted, and the readline 7153default of filename completion is disabled. 7154If the <B>-o bashdefault</B> option was supplied to <B>complete</B> when 7155the compspec was defined, the <B>bash</B> default completions are attempted 7156if the compspec generates no matches. 7157If the <B>-o default</B> option was supplied to <B>complete</B> when the 7158compspec was defined, readline's default completion will be performed 7159if the compspec (and, if attempted, the default <B>bash</B> completions) 7160generate no matches. 7161<P> 7162 7163When a compspec indicates that directory name completion is desired, 7164the programmable completion functions force readline to append a slash 7165to completed names which are symbolic links to directories, subject to 7166the value of the <B>mark-directories</B> readline variable, regardless 7167of the setting of the <B>mark-symlinked-directories</B> readline variable. 7168<A NAME="lbCU"> </A> 7169<H3>HISTORY</H3> 7170 7171When the 7172<B>-o history</B> 7173 7174option to the 7175<B>set</B> 7176 7177builtin is enabled, the shell provides access to the 7178<I>command history</I>, 7179the list of commands previously typed. 7180The value of the <B>HISTSIZE</B> variable is used as the 7181number of commands to save in a history list. 7182The text of the last 7183<FONT SIZE=-1><B>HISTSIZE</B> 7184 7185</FONT> 7186commands (default 500) is saved. The shell 7187stores each command in the history list prior to parameter and 7188variable expansion (see 7189<FONT SIZE=-1><B>EXPANSION</B> 7190 7191</FONT> 7192above) but after history expansion is performed, subject to the 7193values of the shell variables 7194<FONT SIZE=-1><B>HISTIGNORE</B> 7195 7196</FONT> 7197and 7198<FONT SIZE=-1><B>HISTCONTROL</B>. 7199 7200</FONT> 7201<P> 7202 7203On startup, the history is initialized from the file named by 7204the variable 7205<FONT SIZE=-1><B>HISTFILE</B> 7206 7207</FONT> 7208(default <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>). 7209The file named by the value of 7210<FONT SIZE=-1><B>HISTFILE</B> 7211 7212</FONT> 7213is truncated, if necessary, to contain no more than 7214the number of lines specified by the value of 7215<FONT SIZE=-1><B>HISTFILESIZE</B>. 7216 7217</FONT> 7218When an interactive shell exits, the last 7219<FONT SIZE=-1><B>$HISTSIZE</B> 7220 7221</FONT> 7222lines are copied from the history list to 7223<FONT SIZE=-1><B>$HISTFILE</B>. 7224 7225</FONT> 7226If the 7227<B>histappend</B> 7228 7229shell option is enabled 7230(see the description of 7231<B>shopt</B> 7232 7233under 7234<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 7235 7236</FONT> 7237below), the lines are appended to the history file, 7238otherwise the history file is overwritten. 7239If 7240<FONT SIZE=-1><B>HISTFILE</B> 7241 7242</FONT> 7243is unset, or if the history file is unwritable, the history is 7244not saved. After saving the history, the history file is truncated 7245to contain no more than 7246<FONT SIZE=-1><B>HISTFILESIZE</B> 7247 7248</FONT> 7249lines. If 7250<FONT SIZE=-1><B>HISTFILESIZE</B> 7251 7252</FONT> 7253is not set, no truncation is performed. 7254<P> 7255 7256The builtin command 7257<B>fc</B> 7258 7259(see 7260<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 7261 7262</FONT> 7263below) may be used to list or edit and re-execute a portion of 7264the history list. 7265The 7266<B>history</B> 7267 7268builtin may be used to display or modify the history list and 7269manipulate the history file. 7270When using command-line editing, search commands 7271are available in each editing mode that provide access to the 7272history list. 7273<P> 7274 7275The shell allows control over which commands are saved on the history 7276list. The 7277<FONT SIZE=-1><B>HISTCONTROL</B> 7278 7279</FONT> 7280and 7281<FONT SIZE=-1><B>HISTIGNORE</B> 7282 7283</FONT> 7284variables may be set to cause the shell to save only a subset of the 7285commands entered. 7286The 7287<B>cmdhist</B> 7288 7289shell option, if enabled, causes the shell to attempt to save each 7290line of a multi-line command in the same history entry, adding 7291semicolons where necessary to preserve syntactic correctness. 7292The 7293<B>lithist</B> 7294 7295shell option causes the shell to save the command with embedded newlines 7296instead of semicolons. See the description of the 7297<B>shopt</B> 7298 7299builtin below under 7300<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 7301 7302</FONT> 7303for information on setting and unsetting shell options. 7304<A NAME="lbCV"> </A> 7305<H3>HISTORY EXPANSION</H3> 7306 7307<P> 7308 7309The shell supports a history expansion feature that 7310is similar to the history expansion in 7311<B>csh.</B> 7312 7313This section describes what syntax features are available. This 7314feature is enabled by default for interactive shells, and can be 7315disabled using the 7316<B>+H</B> 7317 7318option to the 7319<B>set</B> 7320 7321builtin command (see 7322<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B> 7323 7324</FONT> 7325below). Non-interactive shells do not perform history expansion 7326by default. 7327<P> 7328 7329History expansions introduce words from the history list into 7330the input stream, making it easy to repeat commands, insert the 7331arguments to a previous command into the current input line, or 7332fix errors in previous commands quickly. 7333<P> 7334 7335History expansion is performed immediately after a complete line 7336is read, before the shell breaks it into words. 7337It takes place in two parts. 7338The first is to determine which line from the history list 7339to use during substitution. 7340The second is to select portions of that line for inclusion into 7341the current one. 7342The line selected from the history is the <I>event</I>, 7343and the portions of that line that are acted upon are <I>words</I>. 7344Various <I>modifiers</I> are available to manipulate the selected words. 7345The line is broken into words in the same fashion as when reading input, 7346so that several <I>metacharacter</I>-separated words surrounded by 7347quotes are considered one word. 7348History expansions are introduced by the appearance of the 7349history expansion character, which is <B>!</B> by default. 7350Only backslash (<B>\</B>) and single quotes can quote 7351the history expansion character. 7352<P> 7353 7354Several characters inhibit history expansion if found immediately 7355following the history expansion character, even if it is unquoted: 7356space, tab, newline, carriage return, and <B>=</B>. 7357If the <B>extglob</B> shell option is enabled, <B>(</B> will also 7358inhibit expansion. 7359<P> 7360 7361Several shell options settable with the 7362<B>shopt</B> 7363 7364builtin may be used to tailor the behavior of history expansion. 7365If the 7366<B>histverify</B> 7367 7368shell option is enabled (see the description of the 7369<B>shopt</B> 7370 7371builtin), and 7372<B>readline</B> 7373 7374is being used, history substitutions are not immediately passed to 7375the shell parser. 7376Instead, the expanded line is reloaded into the 7377<B>readline</B> 7378 7379editing buffer for further modification. 7380If 7381<B>readline</B> 7382 7383is being used, and the 7384<B>histreedit</B> 7385 7386shell option is enabled, a failed history substitution will be reloaded 7387into the 7388<B>readline</B> 7389 7390editing buffer for correction. 7391The 7392<B>-p</B> 7393 7394option to the 7395<B>history</B> 7396 7397builtin command may be used to see what a history expansion will 7398do before using it. 7399The 7400<B>-s</B> 7401 7402option to the 7403<B>history</B> 7404 7405builtin may be used to add commands to the end of the history list 7406without actually executing them, so that they are available for 7407subsequent recall. 7408<P> 7409 7410The shell allows control of the various characters used by the 7411history expansion mechanism (see the description of 7412<B>histchars</B> 7413 7414above under 7415<B>Shell Variables</B>). 7416 7417<A NAME="lbCW"> </A> 7418<H4>Event Designators</H4> 7419 7420<P> 7421 7422An event designator is a reference to a command line entry in the 7423history list. 7424<P> 7425 7426 7427<DL COMPACT> 7428<DT><B>!</B> 7429 7430<DD> 7431Start a history substitution, except when followed by a 7432<B>blank</B>, 7433 7434newline, carriage return, = 7435or ( (when the <B>extglob</B> shell option is enabled using 7436the <B>shopt</B> builtin). 7437<DT><B>!</B><I>n</I> 7438 7439<DD> 7440Refer to command line 7441<I>n</I>. 7442 7443<DT><B>!-</B><I>n</I> 7444 7445<DD> 7446Refer to the current command line minus 7447<I>n</I>. 7448 7449<DT><B>!!</B> 7450 7451<DD> 7452Refer to the previous command. This is a synonym for `!-1'. 7453<DT><B>!</B><I>string</I> 7454 7455<DD> 7456Refer to the most recent command starting with 7457<I>string</I>. 7458 7459<DT><B>!?</B><I>string</I><B>[?]</B> 7460 7461<DD> 7462Refer to the most recent command containing 7463<I>string</I>. 7464 7465The trailing <B>?</B> may be omitted if 7466<I>string</I> 7467 7468is followed immediately by a newline. 7469<DT><B></B><FONT SIZE=+2><B>^</B></FONT><B></B><I>string1</I><FONT SIZE=+2>^</FONT><I>string2</I><FONT SIZE=+2>^</FONT> 7470 7471<DD> 7472Quick substitution. Repeat the last command, replacing 7473<I>string1</I> 7474 7475with 7476<I>string2</I>. 7477 7478Equivalent to 7479``!!:s/<I>string1</I>/<I>string2</I>/'' 7480(see <B>Modifiers</B> below). 7481<DT><B>!#</B> 7482 7483<DD> 7484The entire command line typed so far. 7485 7486</DL> 7487<A NAME="lbCX"> </A> 7488<H4>Word Designators</H4> 7489 7490<P> 7491 7492Word designators are used to select desired words from the event. 7493A 7494<B>:</B> 7495 7496separates the event specification from the word designator. 7497It may be omitted if the word designator begins with a 7498<B>^</B>, 7499 7500<B>$</B>, 7501 7502<B>*</B>, 7503 7504<B>-</B>, 7505 7506or 7507<B>%</B>. 7508 7509Words are numbered from the beginning of the line, 7510with the first word being denoted by 0 (zero). 7511Words are inserted into the current line separated by single spaces. 7512<P> 7513 7514 7515<DL COMPACT> 7516<DT><B>0 (zero)</B> 7517 7518<DD> 7519The zeroth word. For the shell, this is the command 7520word. 7521<DT><I>n</I> 7522 7523<DD> 7524The <I>n</I>th word. 7525<DT><B>^</B> 7526 7527<DD> 7528The first argument. That is, word 1. 7529<DT><B>$</B> 7530 7531<DD> 7532The last argument. 7533<DT><B>%</B> 7534 7535<DD> 7536The word matched by the most recent `?<I>string</I>?' search. 7537<DT><I>x</I><B>-</B>y 7538 7539<DD> 7540A range of words; `-<I>y</I>' abbreviates `0-<I>y</I>'. 7541<DT><B>*</B> 7542 7543<DD> 7544All of the words but the zeroth. This is a synonym 7545for `<I>1-$</I>'. It is not an error to use 7546<B>*</B> 7547 7548if there is just one 7549word in the event; the empty string is returned in that case. 7550<DT><B>x*</B> 7551 7552<DD> 7553Abbreviates <I>x-$</I>. 7554<DT><B>x-</B> 7555 7556<DD> 7557Abbreviates <I>x-$</I> like <B>x*</B>, but omits the last word. 7558 7559</DL> 7560<P> 7561 7562If a word designator is supplied without an event specification, the 7563previous command is used as the event. 7564<A NAME="lbCY"> </A> 7565<H4>Modifiers</H4> 7566 7567<P> 7568 7569After the optional word designator, there may appear a sequence of 7570one or more of the following modifiers, each preceded by a `:'. 7571<P> 7572 7573 7574<P> 7575 7576<DL COMPACT> 7577<DT><B>h</B> 7578 7579<DD> 7580Remove a trailing file name component, leaving only the head. 7581<DT><B>t</B> 7582 7583<DD> 7584Remove all leading file name components, leaving the tail. 7585<DT><B>r</B> 7586 7587<DD> 7588Remove a trailing suffix of the form <I>.xxx</I>, leaving the 7589basename. 7590<DT><B>e</B> 7591 7592<DD> 7593Remove all but the trailing suffix. 7594<DT><B>p</B> 7595 7596<DD> 7597Print the new command but do not execute it. 7598<DT><B>q</B> 7599 7600<DD> 7601Quote the substituted words, escaping further substitutions. 7602<DT><B>x</B> 7603 7604<DD> 7605Quote the substituted words as with 7606<B>q</B>, 7607 7608but break into words at 7609<B>blanks</B> 7610 7611and newlines. 7612<DT><B>s/</B><I>old</I>/<I>new</I>/ 7613 7614<DD> 7615Substitute 7616<I>new</I> 7617 7618for the first occurrence of 7619<I>old</I> 7620 7621in the event line. Any delimiter can be used in place of /. The 7622final delimiter is optional if it is the last character of the 7623event line. The delimiter may be quoted in 7624<I>old</I> 7625 7626and 7627<I>new</I> 7628 7629with a single backslash. If & appears in 7630<I>new</I>, 7631 7632it is replaced by 7633<I>old</I>. 7634 7635A single backslash will quote the &. If 7636<I>old</I> 7637 7638is null, it is set to the last 7639<I>old</I> 7640 7641substituted, or, if no previous history substitutions took place, 7642the last 7643<I>string</I> 7644 7645in a 7646<B>!?</B><I>string</I><B>[?]</B> 7647 7648search. 7649<DT><B>&</B> 7650 7651<DD> 7652Repeat the previous substitution. 7653<DT><B>g</B> 7654 7655<DD> 7656Cause changes to be applied over the entire event line. This is 7657used in conjunction with `<B>:s</B>' (e.g., `<B>:gs/</B><I>old</I>/<I>new</I>/') 7658or `<B>:&</B>'. If used with 7659`<B>:s</B>', any delimiter can be used 7660in place of /, and the final delimiter is optional 7661if it is the last character of the event line. 7662An <B>a</B> may be used as a synonym for <B>g</B>. 7663<DT><B>G</B> 7664 7665<DD> 7666Apply the following `<B>s</B>' modifier once to each word in the event line. 7667 7668</DL> 7669<A NAME="lbCZ"> </A> 7670<H3>SHELL BUILTIN COMMANDS</H3> 7671 7672 7673 7674<P> 7675 7676Unless otherwise noted, each builtin command documented in this 7677section as accepting options preceded by 7678<B>-</B> 7679 7680accepts 7681<B>--</B> 7682 7683to signify the end of the options. 7684For example, the <B>:</B>, <B>true</B>, <B>false</B>, and <B>test</B> builtins 7685do not accept options. 7686<P> 7687 7688<DL COMPACT> 7689<DT><B>:</B> [<I>arguments</I>]<DD> 7690 7691No effect; the command does nothing beyond expanding 7692<I>arguments</I> 7693 7694and performing any specified 7695redirections. A zero exit code is returned. 7696<DT><B> . </B> <I>filename</I> [<I>arguments</I>]<DD> 7697 7698<DT><B>source</B> <I>filename</I> [<I>arguments</I>]<DD> 7699 7700Read and execute commands from 7701<I>filename</I> 7702 7703in the current 7704shell environment and return the exit status of the last command 7705executed from 7706<I>filename</I>. 7707 7708If 7709<I>filename</I> 7710 7711does not contain a slash, file names in 7712<FONT SIZE=-1><B>PATH</B> 7713 7714</FONT> 7715are used to find the directory containing 7716<I>filename</I>. 7717 7718The file searched for in 7719<FONT SIZE=-1><B>PATH</B> 7720 7721</FONT> 7722need not be executable. 7723When <B>bash</B> is not in <I>posix mode</I>, the current directory is 7724searched if no file is found in 7725<FONT SIZE=-1><B>PATH</B>. 7726 7727</FONT> 7728If the 7729<B>sourcepath</B> 7730 7731option to the 7732<B>shopt</B> 7733 7734builtin command is turned off, the 7735<FONT SIZE=-1><B>PATH</B> 7736 7737</FONT> 7738is not searched. 7739If any <I>arguments</I> are supplied, they become the positional 7740parameters when <I>filename</I> is executed. Otherwise the positional 7741parameters are unchanged. 7742The return status is the status of the last command exited within 7743the script (0 if no commands are executed), and false if 7744<I>filename</I> 7745 7746is not found or cannot be read. 7747<DT><B>alias</B> [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD> 7748<B>Alias</B> with no arguments or with the 7749<B>-p</B> 7750 7751option prints the list of aliases in the form 7752<B>alias</B> <I>name</I>=<I>value</I> on standard output. 7753When arguments are supplied, an alias is defined for 7754each <I>name</I> whose <I>value</I> is given. 7755A trailing space in <I>value</I> causes the next word to be 7756checked for alias substitution when the alias is expanded. 7757For each <I>name</I> in the argument list for which no <I>value</I> 7758is supplied, the name and value of the alias is printed. 7759<B>Alias</B> returns true unless a <I>name</I> is given for which 7760no alias has been defined. 7761<DT><B>bg</B> [<I>jobspec</I> ...]<DD> 7762Resume each suspended job <I>jobspec</I> in the background, as if it 7763had been started with 7764<B>&</B>. 7765 7766If <I>jobspec</I> is not present, the shell's notion of the 7767<I>current job</I> is used. 7768<B>bg</B> 7769 7770<I>jobspec</I> 7771 7772returns 0 unless run when job control is disabled or, when run with 7773job control enabled, any specified <I>jobspec</I> was not found 7774or was started without job control. 7775<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] [<B>-lpsvPSV</B>]<DD> 7776 7777<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] [<B>-q</B> <I>function</I>] [<B>-u</B> <I>function</I>] [<B>-r</B> <I>keyseq</I>]<DD> 7778<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-f</B> <I>filename</I><DD> 7779<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-x</B> <I>keyseq</I>:<I>shell-command</I><DD> 7780<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <I>keyseq</I>:<I>function-name</I><DD> 7781<DT><B>bind</B> <I>readline-command</I><DD> 7782 7783Display current 7784<B>readline</B> 7785 7786key and function bindings, bind a key sequence to a 7787<B>readline</B> 7788 7789function or macro, or set a 7790<B>readline</B> 7791 7792variable. 7793Each non-option argument is a command as it would appear in 7794<I>.inputrc</I>, 7795 7796but each binding or command must be passed as a separate argument; 7797e.g., '"\C-x\C-r": re-read-init-file'. 7798Options, if supplied, have the following meanings: 7799<DL COMPACT><DT><DD> 7800 7801<DL COMPACT> 7802<DT><B>-m </B><I>keymap</I> 7803 7804<DD> 7805Use 7806<I>keymap</I> 7807 7808as the keymap to be affected by the subsequent bindings. 7809Acceptable 7810<I>keymap</I> 7811 7812names are 7813<I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, 7814vi-move, vi-command</I>, and 7815<I>vi-insert</I>. 7816 7817<I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is 7818equivalent to <I>emacs-standard</I>. 7819<DT><B>-l</B> 7820 7821<DD> 7822List the names of all <B>readline</B> functions. 7823<DT><B>-p</B> 7824 7825<DD> 7826Display <B>readline</B> function names and bindings in such a way 7827that they can be re-read. 7828<DT><B>-P</B> 7829 7830<DD> 7831List current <B>readline</B> function names and bindings. 7832<DT><B>-v</B> 7833 7834<DD> 7835Display <B>readline</B> variable names and values in such a way that they 7836can be re-read. 7837<DT><B>-V</B> 7838 7839<DD> 7840List current <B>readline</B> variable names and values. 7841<DT><B>-s</B> 7842 7843<DD> 7844Display <B>readline</B> key sequences bound to macros and the strings 7845they output in such a way that they can be re-read. 7846<DT><B>-S</B> 7847 7848<DD> 7849Display <B>readline</B> key sequences bound to macros and the strings 7850they output. 7851<DT><B>-f </B><I>filename</I> 7852 7853<DD> 7854Read key bindings from <I>filename</I>. 7855<DT><B>-q </B><I>function</I> 7856 7857<DD> 7858Query about which keys invoke the named <I>function</I>. 7859<DT><B>-u </B><I>function</I> 7860 7861<DD> 7862Unbind all keys bound to the named <I>function</I>. 7863<DT><B>-r </B><I>keyseq</I> 7864 7865<DD> 7866Remove any current binding for <I>keyseq</I>. 7867<DT><B>-x </B><I>keyseq</I>:<I>shell-command</I> 7868 7869<DD> 7870Cause <I>shell-command</I> to be executed whenever <I>keyseq</I> is 7871entered. 7872 7873</DL> 7874<P> 7875 7876The return value is 0 unless an unrecognized option is given or an 7877error occurred. 7878</DL> 7879 7880<DT><B>break</B> [<I>n</I>]<DD> 7881Exit from within a 7882<B>for</B>, 7883 7884<B>while</B>, 7885 7886<B>until</B>, 7887 7888or 7889<B>select</B> 7890 7891loop. If <I>n</I> is specified, break <I>n</I> levels. 7892<I>n</I> 7893 7894must be >= 1. If 7895<I>n</I> 7896 7897is greater than the number of enclosing loops, all enclosing loops 7898are exited. The return value is 0 unless the shell is not executing 7899a loop when 7900<B>break</B> 7901 7902is executed. 7903<DT><B>builtin</B> <I>shell-builtin</I> [<I>arguments</I>]<DD> 7904Execute the specified shell builtin, passing it 7905<I>arguments</I>, 7906 7907and return its exit status. 7908This is useful when defining a 7909function whose name is the same as a shell builtin, 7910retaining the functionality of the builtin within the function. 7911The <B>cd</B> builtin is commonly redefined this way. 7912The return status is false if 7913<I>shell-builtin</I> 7914 7915is not a shell builtin command. 7916<DT><B>cd</B> [<B>-L|-P</B>] [<I>dir</I>]<DD> 7917Change the current directory to <I>dir</I>. The variable 7918<FONT SIZE=-1><B>HOME</B> 7919 7920</FONT> 7921is the 7922default 7923<I>dir</I>. 7924 7925The variable 7926<FONT SIZE=-1><B>CDPATH</B> 7927 7928</FONT> 7929defines the search path for the directory containing 7930<I>dir</I>. 7931 7932Alternative directory names in 7933<FONT SIZE=-1><B>CDPATH</B> 7934 7935</FONT> 7936are separated by a colon (:). A null directory name in 7937<FONT SIZE=-1><B>CDPATH</B> 7938 7939</FONT> 7940is the same as the current directory, i.e., ``<B>.</B>''. If 7941<I>dir</I> 7942 7943begins with a slash (/), 7944then 7945<FONT SIZE=-1><B>CDPATH</B> 7946 7947</FONT> 7948is not used. The 7949<B>-P</B> 7950 7951option says to use the physical directory structure instead of 7952following symbolic links (see also the 7953<B>-P</B> 7954 7955option to the 7956<B>set</B> 7957 7958builtin command); the 7959<B>-L</B> 7960 7961option forces symbolic links to be followed. An argument of 7962<B>-</B> 7963 7964is equivalent to 7965<FONT SIZE=-1><B>$OLDPWD</B>. 7966 7967</FONT> 7968If a non-empty directory name from <B>CDPATH</B> is used, or if 7969<B>-</B> is the first argument, and the directory change is 7970successful, the absolute pathname of the new working directory is 7971written to the standard output. 7972The return value is true if the directory was successfully changed; 7973false otherwise. 7974<DT><B>caller</B> [<I>expr</I>]<DD> 7975Returns the context of any active subroutine call (a shell function or 7976a script executed with the <B>.</B> or <B>source</B> builtins. 7977Without <I>expr</I>, <B>caller</B> displays the line number and source 7978filename of the current subroutine call. 7979If a non-negative integer is supplied as <I>expr</I>, <B>caller</B> 7980displays the line number, subroutine name, and source file corresponding 7981to that position in the current execution call stack. This extra 7982information may be used, for example, to print a stack trace. The 7983current frame is frame 0. 7984The return value is 0 unless the shell is not executing a subroutine 7985call or <I>expr</I> does not correspond to a valid position in the 7986call stack. 7987<DT><B>command</B> [<B>-pVv</B>] <I>command</I> [<I>arg</I> ...]<DD> 7988Run 7989<I>command</I> 7990 7991with 7992<I>args</I> 7993 7994suppressing the normal shell function lookup. Only builtin 7995commands or commands found in the 7996<FONT SIZE=-1><B>PATH</B> 7997 7998</FONT> 7999are executed. If the 8000<B>-p</B> 8001 8002option is given, the search for 8003<I>command</I> 8004 8005is performed using a default value for 8006<B>PATH</B> 8007 8008that is guaranteed to find all of the standard utilities. 8009If either the 8010<B>-V</B> 8011 8012or 8013<B>-v</B> 8014 8015option is supplied, a description of 8016<I>command</I> 8017 8018is printed. The 8019<B>-v</B> 8020 8021option causes a single word indicating the command or file name 8022used to invoke 8023<I>command</I> 8024 8025to be displayed; the 8026<B>-V</B> 8027 8028option produces a more verbose description. 8029If the 8030<B>-V</B> 8031 8032or 8033<B>-v</B> 8034 8035option is supplied, the exit status is 0 if 8036<I>command</I> 8037 8038was found, and 1 if not. If neither option is supplied and 8039an error occurred or 8040<I>command</I> 8041 8042cannot be found, the exit status is 127. Otherwise, the exit status of the 8043<B>command</B> 8044 8045builtin is the exit status of 8046<I>command</I>. 8047 8048<DT><B>compgen</B> [<I>option</I>] [<I>word</I>]<DD> 8049Generate possible completion matches for <I>word</I> according to 8050the <I>option</I>s, which may be any option accepted by the 8051<B>complete</B> 8052 8053builtin with the exception of <B>-p</B> and <B>-r</B>, and write 8054the matches to the standard output. 8055When using the <B>-F</B> or <B>-C</B> options, the various shell variables 8056set by the programmable completion facilities, while available, will not 8057have useful values. 8058<P> 8059The matches will be generated in the same way as if the programmable 8060completion code had generated them directly from a completion specification 8061with the same flags. 8062If <I>word</I> is specified, only those completions matching <I>word</I> 8063will be displayed. 8064<P> 8065The return value is true unless an invalid option is supplied, or no 8066matches were generated. 8067<DT><B>complete</B> [<B>-abcdefgjksuv</B>] [<B>-o</B> <I>comp-option</I>] [<B>-A</B> <I>action</I>] [<B>-G</B> <I>globpat</I>] [<B>-W</B> <I>wordlist</I>] [<B>-P</B> <I>prefix</I>] [<B>-S</B> <I>suffix</I>]<DD> 8068<BR> 8069 8070[<B>-X</B> <I>filterpat</I>] [<B>-F</B> <I>function</I>] [<B>-C</B> <I>command</I>] <I>name</I> [<I>name ...</I>] 8071 8072<DT><B>complete</B> <B>-pr</B> [<I>name</I> ...]<DD> 8073 8074Specify how arguments to each <I>name</I> should be completed. 8075If the <B>-p</B> option is supplied, or if no options are supplied, 8076existing completion specifications are printed in a way that allows 8077them to be reused as input. 8078The <B>-r</B> option removes a completion specification for 8079each <I>name</I>, or, if no <I>name</I>s are supplied, all 8080completion specifications. 8081<P> 8082The process of applying these completion specifications when word completion 8083is attempted is described above under <B>Programmable Completion</B>. 8084<P> 8085Other options, if specified, have the following meanings. 8086The arguments to the <B>-G</B>, <B>-W</B>, and <B>-X</B> options 8087(and, if necessary, the <B>-P</B> and <B>-S</B> options) 8088should be quoted to protect them from expansion before the 8089<B>complete</B> 8090 8091builtin is invoked. 8092<DL COMPACT><DT><DD> 8093 8094<DL COMPACT> 8095<DT><B>-o</B> <I>comp-option</I><DD> 8096The <I>comp-option</I> controls several aspects of the compspec's behavior 8097beyond the simple generation of completions. 8098<I>comp-option</I> may be one of: 8099<DL COMPACT><DT><DD> 8100<DL COMPACT> 8101<DT><B>bashdefault</B> 8102 8103<DD> 8104Perform the rest of the default <B>bash</B> completions if the compspec 8105generates no matches. 8106<DT><B>default</B> 8107 8108<DD> 8109Use readline's default filename completion if the compspec generates 8110no matches. 8111<DT><B>dirnames</B> 8112 8113<DD> 8114Perform directory name completion if the compspec generates no matches. 8115<DT><B>filenames</B> 8116 8117<DD> 8118Tell readline that the compspec generates filenames, so it can perform any 8119filename-specific processing (like adding a slash to directory names or 8120suppressing trailing spaces). Intended to be used with shell functions. 8121<DT><B>nospace</B> 8122 8123<DD> 8124Tell readline not to append a space (the default) to words completed at 8125the end of the line. 8126<DT><B>plusdirs</B> 8127 8128<DD> 8129After any matches defined by the compspec are generated, 8130directory name completion is attempted and any 8131matches are added to the results of the other actions. 8132</DL></DL> 8133 8134<DT><B>-A</B> <I>action</I><DD> 8135The <I>action</I> may be one of the following to generate a list of possible 8136completions: 8137<DL COMPACT><DT><DD> 8138<DL COMPACT> 8139<DT><B>alias</B> 8140 8141<DD> 8142Alias names. May also be specified as <B>-a</B>. 8143<DT><B>arrayvar</B> 8144 8145<DD> 8146Array variable names. 8147<DT><B>binding</B> 8148 8149<DD> 8150<B>Readline</B> key binding names. 8151<DT><B>builtin</B> 8152 8153<DD> 8154Names of shell builtin commands. May also be specified as <B>-b</B>. 8155<DT><B>command</B> 8156 8157<DD> 8158Command names. May also be specified as <B>-c</B>. 8159<DT><B>directory</B> 8160 8161<DD> 8162Directory names. May also be specified as <B>-d</B>. 8163<DT><B>disabled</B> 8164 8165<DD> 8166Names of disabled shell builtins. 8167<DT><B>enabled</B> 8168 8169<DD> 8170Names of enabled shell builtins. 8171<DT><B>export</B> 8172 8173<DD> 8174Names of exported shell variables. May also be specified as <B>-e</B>. 8175<DT><B>file</B> 8176 8177<DD> 8178File names. May also be specified as <B>-f</B>. 8179<DT><B>function</B> 8180 8181<DD> 8182Names of shell functions. 8183<DT><B>group</B> 8184 8185<DD> 8186Group names. May also be specified as <B>-g</B>. 8187<DT><B>helptopic</B> 8188 8189<DD> 8190Help topics as accepted by the <B>help</B> builtin. 8191<DT><B>hostname</B> 8192 8193<DD> 8194Hostnames, as taken from the file specified by the 8195<FONT SIZE=-1><B>HOSTFILE</B> 8196 8197</FONT> 8198shell variable. 8199<DT><B>job</B> 8200 8201<DD> 8202Job names, if job control is active. May also be specified as <B>-j</B>. 8203<DT><B>keyword</B> 8204 8205<DD> 8206Shell reserved words. May also be specified as <B>-k</B>. 8207<DT><B>running</B> 8208 8209<DD> 8210Names of running jobs, if job control is active. 8211<DT><B>service</B> 8212 8213<DD> 8214Service names. May also be specified as <B>-s</B>. 8215<DT><B>setopt</B> 8216 8217<DD> 8218Valid arguments for the <B>-o</B> option to the <B>set</B> builtin. 8219<DT><B>shopt</B> 8220 8221<DD> 8222Shell option names as accepted by the <B>shopt</B> builtin. 8223<DT><B>signal</B> 8224 8225<DD> 8226Signal names. 8227<DT><B>stopped</B> 8228 8229<DD> 8230Names of stopped jobs, if job control is active. 8231<DT><B>user</B> 8232 8233<DD> 8234User names. May also be specified as <B>-u</B>. 8235<DT><B>variable</B> 8236 8237<DD> 8238Names of all shell variables. May also be specified as <B>-v</B>. 8239</DL></DL> 8240 8241<DT><B>-G</B> <I>globpat</I><DD> 8242The filename expansion pattern <I>globpat</I> is expanded to generate 8243the possible completions. 8244<DT><B>-W</B> <I>wordlist</I><DD> 8245The <I>wordlist</I> is split using the characters in the 8246<FONT SIZE=-1><B>IFS</B> 8247 8248</FONT> 8249special variable as delimiters, and each resultant word is expanded. 8250The possible completions are the members of the resultant list which 8251match the word being completed. 8252<DT><B>-C</B> <I>command</I><DD> 8253<I>command</I> is executed in a subshell environment, and its output is 8254used as the possible completions. 8255<DT><B>-F</B> <I>function</I><DD> 8256The shell function <I>function</I> is executed in the current shell 8257environment. 8258When it finishes, the possible completions are retrieved from the value 8259of the 8260<FONT SIZE=-1><B>COMPREPLY</B> 8261 8262</FONT> 8263array variable. 8264<DT><B>-X</B> <I>filterpat</I><DD> 8265<I>filterpat</I> is a pattern as used for filename expansion. 8266It is applied to the list of possible completions generated by the 8267preceding options and arguments, and each completion matching 8268<I>filterpat</I> is removed from the list. 8269A leading <B>!</B> in <I>filterpat</I> negates the pattern; in this 8270case, any completion not matching <I>filterpat</I> is removed. 8271<DT><B>-P</B> <I>prefix</I><DD> 8272<I>prefix</I> is added at the beginning of each possible completion 8273after all other options have been applied. 8274<DT><B>-S</B> <I>suffix</I><DD> 8275<I>suffix</I> is appended to each possible completion 8276after all other options have been applied. 8277 8278</DL> 8279<P> 8280 8281The return value is true unless an invalid option is supplied, an option 8282other than <B>-p</B> or <B>-r</B> is supplied without a <I>name</I> 8283argument, an attempt is made to remove a completion specification for 8284a <I>name</I> for which no specification exists, or 8285an error occurs adding a completion specification. 8286</DL> 8287 8288<DT><B>continue</B> [<I>n</I>]<DD> 8289Resume the next iteration of the enclosing 8290<B>for</B>, 8291 8292<B>while</B>, 8293 8294<B>until</B>, 8295 8296or 8297<B>select</B> 8298 8299loop. 8300If 8301<I>n</I> 8302 8303is specified, resume at the <I>n</I>th enclosing loop. 8304<I>n</I> 8305 8306must be >= 1. If 8307<I>n</I> 8308 8309is greater than the number of enclosing loops, the last enclosing loop 8310(the ``top-level'' loop) is resumed. The return value is 0 unless the 8311shell is not executing a loop when 8312<B>continue</B> 8313 8314is executed. 8315<DT><B>declare</B> [<B>-afFirtx</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD> 8316 8317<DT><B>typeset</B> [<B>-afFirtx</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD> 8318 8319Declare variables and/or give them attributes. 8320If no <I>name</I>s are given then display the values of variables. 8321The 8322<B>-p</B> 8323 8324option will display the attributes and values of each 8325<I>name</I>. 8326 8327When 8328<B>-p</B> 8329 8330is used, additional options are ignored. 8331The 8332<B>-F</B> 8333 8334option inhibits the display of function definitions; only the 8335function name and attributes are printed. 8336If the <B>extdebug</B> shell option is enabled using <B>shopt</B>, 8337the source file name and line number where the function is defined 8338are displayed as well. The 8339<B>-F</B> 8340 8341option implies 8342<B>-f</B>. 8343 8344The following options can 8345be used to restrict output to variables with the specified attribute or 8346to give variables attributes: 8347<DL COMPACT><DT><DD> 8348 8349<DL COMPACT> 8350<DT><B>-a</B> 8351 8352<DD> 8353Each <I>name</I> is an array variable (see 8354<B>Arrays</B> 8355 8356above). 8357<DT><B>-f</B> 8358 8359<DD> 8360Use function names only. 8361<DT><B>-i</B> 8362 8363<DD> 8364The variable is treated as an integer; arithmetic evaluation (see 8365<FONT SIZE=-1><B>ARITHMETIC EVALUATION ) </B> 8366 8367</FONT> 8368is performed when the variable is assigned a value. 8369<DT><B>-r</B> 8370 8371<DD> 8372Make <I>name</I>s readonly. These names cannot then be assigned values 8373by subsequent assignment statements or unset. 8374<DT><B>-t</B> 8375 8376<DD> 8377Give each <I>name</I> the <I>trace</I> attribute. 8378Traced functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps from 8379the calling shell. 8380The trace attribute has no special meaning for variables. 8381<DT><B>-x</B> 8382 8383<DD> 8384Mark <I>name</I>s for export to subsequent commands via the environment. 8385 8386</DL> 8387<P> 8388 8389Using `+' instead of `-' 8390turns off the attribute instead, with the exception that <B>+a</B> 8391may not be used to destroy an array variable. When used in a function, 8392makes each 8393<I>name</I> local, as with the 8394<B>local</B> 8395 8396command. 8397If a variable name is followed by =<I>value</I>, the value of 8398the variable is set to <I>value</I>. 8399The return value is 0 unless an invalid option is encountered, 8400an attempt is made to define a function using 8401 8402<TT>-f foo=bar</TT>, 8403an attempt is made to assign a value to a readonly variable, 8404an attempt is made to assign a value to an array variable without 8405using the compound assignment syntax (see 8406<B>Arrays</B> 8407 8408above), one of the <I>names</I> is not a valid shell variable name, 8409an attempt is made to turn off readonly status for a readonly variable, 8410an attempt is made to turn off array status for an array variable, 8411or an attempt is made to display a non-existent function with <B>-f</B>. 8412</DL> 8413 8414<DT><B>dirs [-clpv</B>] [+<I>n</I>] [-<I>n</I>] 8415 8416<DD> 8417Without options, displays the list of currently remembered directories. 8418The default display is on a single line with directory names separated 8419by spaces. 8420Directories are added to the list with the 8421<B>pushd</B> 8422 8423command; the 8424<B>popd</B> 8425 8426command removes entries from the list. 8427<DL COMPACT><DT><DD> 8428 8429<DL COMPACT> 8430<DT><B>+</B><I>n</I><DD> 8431Displays the <I>n</I>th entry counting from the left of the list 8432shown by 8433<B>dirs</B> 8434 8435when invoked without options, starting with zero. 8436<DT><B>-</B><I>n</I><DD> 8437Displays the <I>n</I>th entry counting from the right of the list 8438shown by 8439<B>dirs</B> 8440 8441when invoked without options, starting with zero. 8442<DT><B>-c</B> 8443 8444<DD> 8445Clears the directory stack by deleting all of the entries. 8446<DT><B>-l</B> 8447 8448<DD> 8449Produces a longer listing; the default listing format uses a 8450tilde to denote the home directory. 8451<DT><B>-p</B> 8452 8453<DD> 8454Print the directory stack with one entry per line. 8455<DT><B>-v</B> 8456 8457<DD> 8458Print the directory stack with one entry per line, 8459prefixing each entry with its index in the stack. 8460 8461</DL> 8462<P> 8463 8464The return value is 0 unless an 8465invalid option is supplied or <I>n</I> indexes beyond the end 8466of the directory stack. 8467</DL> 8468 8469<DT><B>disown</B> [<B>-ar</B>] [<B>-h</B>] [<I>jobspec</I> ...]<DD> 8470Without options, each 8471<I>jobspec</I> 8472 8473is removed from the table of active jobs. 8474If the <B>-h</B> option is given, each 8475<I>jobspec</I> 8476 8477is not removed from the table, but is marked so that 8478<FONT SIZE=-1><B>SIGHUP</B> 8479 8480</FONT> 8481is not sent to the job if the shell receives a 8482<FONT SIZE=-1><B>SIGHUP</B>. 8483 8484</FONT> 8485If no 8486<I>jobspec</I> 8487 8488is present, and neither the 8489<B>-a</B> 8490 8491nor the 8492<B>-r</B> 8493 8494option is supplied, the <I>current job</I> is used. 8495If no 8496<I>jobspec</I> 8497 8498is supplied, the 8499<B>-a</B> 8500 8501option means to remove or mark all jobs; the 8502<B>-r</B> 8503 8504option without a 8505<I>jobspec</I> 8506 8507argument restricts operation to running jobs. 8508The return value is 0 unless a 8509<I>jobspec</I> 8510 8511does not specify a valid job. 8512<DT><B>echo</B> [<B>-neE</B>] [<I>arg</I> ...]<DD> 8513Output the <I>arg</I>s, separated by spaces, followed by a newline. 8514The return status is always 0. 8515If <B>-n</B> is specified, the trailing newline is 8516suppressed. If the <B>-e</B> option is given, interpretation of 8517the following backslash-escaped characters is enabled. The 8518<B>-E</B> 8519 8520option disables the interpretation of these escape characters, 8521even on systems where they are interpreted by default. 8522The <B>xpg_echo</B> shell option may be used to 8523dynamically determine whether or not <B>echo</B> expands these 8524escape characters by default. 8525<B>echo</B> 8526 8527does not interpret <B>--</B> to mean the end of options. 8528<B>echo</B> 8529 8530interprets the following escape sequences: 8531<DL COMPACT><DT><DD> 8532 8533<DL COMPACT> 8534<DT><B>\a</B> 8535 8536<DD> 8537alert (bell) 8538<DT><B>\b</B> 8539 8540<DD> 8541backspace 8542<DT><B>\c</B> 8543 8544<DD> 8545suppress trailing newline 8546<DT><B>\e</B> 8547 8548<DD> 8549an escape character 8550<DT><B>\f</B> 8551 8552<DD> 8553form feed 8554<DT><B>\n</B> 8555 8556<DD> 8557new line 8558<DT><B>\r</B> 8559 8560<DD> 8561carriage return 8562<DT><B>\t</B> 8563 8564<DD> 8565horizontal tab 8566<DT><B>\v</B> 8567 8568<DD> 8569vertical tab 8570<DT><B>\\</B> 8571 8572<DD> 8573backslash 8574<DT><B>\0</B><I>nnn</I> 8575 8576<DD> 8577the eight-bit character whose value is the octal value <I>nnn</I> 8578(zero to three octal digits) 8579<DT><B>\</B><I>nnn</I> 8580 8581<DD> 8582the eight-bit character whose value is the octal value <I>nnn</I> 8583(one to three octal digits) 8584<DT><B>\x</B><I>HH</I> 8585 8586<DD> 8587the eight-bit character whose value is the hexadecimal value <I>HH</I> 8588(one or two hex digits) 8589 8590</DL></DL> 8591 8592<DT><B>enable</B> [<B>-adnps</B>] [<B>-f</B> <I>filename</I>] [<I>name</I> ...]<DD> 8593Enable and disable builtin shell commands. 8594Disabling a builtin allows a disk command which has the same name 8595as a shell builtin to be executed without specifying a full pathname, 8596even though the shell normally searches for builtins before disk commands. 8597If <B>-n</B> is used, each <I>name</I> 8598is disabled; otherwise, 8599<I>names</I> are enabled. For example, to use the 8600<B>test</B> 8601 8602binary found via the 8603<FONT SIZE=-1><B>PATH</B> 8604 8605</FONT> 8606instead of the shell builtin version, run 8607<TT>enable -n test</TT>. 8608 8609The 8610<B>-f</B> 8611 8612option means to load the new builtin command 8613<I>name</I> 8614 8615from shared object 8616<I>filename</I>, 8617 8618on systems that support dynamic loading. The 8619<B>-d</B> 8620 8621option will delete a builtin previously loaded with 8622<B>-f</B>. 8623 8624If no <I>name</I> arguments are given, or if the 8625<B>-p</B> 8626 8627option is supplied, a list of shell builtins is printed. 8628With no other option arguments, the list consists of all enabled 8629shell builtins. 8630If <B>-n</B> is supplied, only disabled builtins are printed. 8631If <B>-a</B> is supplied, the list printed includes all builtins, with an 8632indication of whether or not each is enabled. 8633If <B>-s</B> is supplied, the output is restricted to the POSIX 8634<I>special</I> builtins. 8635The return value is 0 unless a 8636<I>name</I> 8637 8638is not a shell builtin or there is an error loading a new builtin 8639from a shared object. 8640<DT><B>eval</B> [<I>arg</I> ...]<DD> 8641The <I>arg</I>s are read and concatenated together into a single 8642command. This command is then read and executed by the shell, and 8643its exit status is returned as the value of 8644<B>eval</B>. 8645 8646If there are no 8647<I>args</I>, 8648 8649or only null arguments, 8650<B>eval</B> 8651 8652returns 0. 8653<DT><B>exec</B> [<B>-cl</B>] [<B>-a</B> <I>name</I>] [<I>command</I> [<I>arguments</I>]]<DD> 8654If 8655<I>command</I> 8656 8657is specified, it replaces the shell. 8658No new process is created. The 8659<I>arguments</I> 8660 8661become the arguments to <I>command</I>. 8662If the 8663<B>-l</B> 8664 8665option is supplied, 8666the shell places a dash at the beginning of the zeroth arg passed to 8667<I>command</I>. 8668 8669This is what 8670<I>login</I>(1) 8671 8672does. The 8673<B>-c</B> 8674 8675option causes 8676<I>command</I> 8677 8678to be executed with an empty environment. If 8679<B>-a</B> 8680 8681is supplied, the shell passes 8682<I>name</I> 8683 8684as the zeroth argument to the executed command. If 8685<I>command</I> 8686 8687cannot be executed for some reason, a non-interactive shell exits, 8688unless the shell option 8689<B>execfail</B> 8690 8691is enabled, in which case it returns failure. 8692An interactive shell returns failure if the file cannot be executed. 8693If 8694<I>command</I> 8695 8696is not specified, any redirections take effect in the current shell, 8697and the return status is 0. If there is a redirection error, the 8698return status is 1. 8699<DT><B>exit</B> [<I>n</I>]<DD> 8700Cause the shell to exit 8701with a status of <I>n</I>. If 8702<I>n</I> 8703 8704is omitted, the exit status 8705is that of the last command executed. 8706A trap on 8707<FONT SIZE=-1><B>EXIT</B> 8708 8709</FONT> 8710is executed before the shell terminates. 8711<DT><B>export</B> [<B>-fn</B>] [<I>name</I>[=<I>word</I>]] ...<DD> 8712 8713<DT><B>export -p</B> 8714 8715<DD> 8716 8717The supplied 8718<I>names</I> 8719 8720are marked for automatic export to the environment of 8721subsequently executed commands. If the 8722<B>-f</B> 8723 8724option is given, 8725the 8726<I>names</I> 8727 8728refer to functions. 8729If no 8730<I>names</I> 8731 8732are given, or if the 8733<B>-p</B> 8734 8735option is supplied, a list 8736of all names that are exported in this shell is printed. 8737The 8738<B>-n</B> 8739 8740option causes the export property to be removed from each 8741<I>name</I>. 8742If a variable name is followed by =<I>word</I>, the value of 8743the variable is set to <I>word</I>. 8744<B>export</B> 8745 8746returns an exit status of 0 unless an invalid option is 8747encountered, 8748one of the <I>names</I> is not a valid shell variable name, or 8749<B>-f</B> 8750 8751is supplied with a 8752<I>name</I> 8753 8754that is not a function. 8755<DT><B>fc</B> [<B>-e</B> <I>ename</I>] [<B>-nlr</B>] [<I>first</I>] [<I>last</I>]<DD> 8756 8757<DT><B>fc</B> <B>-s</B> [<I>pat</I>=<I>rep</I>] [<I>cmd</I>]<DD> 8758 8759Fix Command. In the first form, a range of commands from 8760<I>first</I> 8761 8762to 8763<I>last</I> 8764 8765is selected from the history list. 8766<I>First</I> 8767 8768and 8769<I>last</I> 8770 8771may be specified as a string (to locate the last command beginning 8772with that string) or as a number (an index into the history list, 8773where a negative number is used as an offset from the current 8774command number). If 8775<I>last</I> 8776 8777is not specified it is set to 8778the current command for listing (so that 8779 8780<TT>fc -l -10</TT> 8781prints the last 10 commands) and to 8782<I>first</I> 8783 8784otherwise. 8785If 8786<I>first</I> 8787 8788is not specified it is set to the previous 8789command for editing and -16 for listing. 8790<P> 8791The 8792<B>-n</B> 8793 8794option suppresses 8795the command numbers when listing. The 8796<B>-r</B> 8797 8798option reverses the order of 8799the commands. If the 8800<B>-l</B> 8801 8802option is given, 8803the commands are listed on 8804standard output. Otherwise, the editor given by 8805<I>ename</I> 8806 8807is invoked 8808on a file containing those commands. If 8809<I>ename</I> 8810 8811is not given, the 8812value of the 8813<FONT SIZE=-1><B>FCEDIT</B> 8814 8815</FONT> 8816variable is used, and 8817the value of 8818<FONT SIZE=-1><B>EDITOR</B> 8819 8820</FONT> 8821if 8822<FONT SIZE=-1><B>FCEDIT</B> 8823 8824</FONT> 8825is not set. If neither variable is set, 8826 8827<I>vi</I> 8828 8829is used. When editing is complete, the edited commands are 8830echoed and executed. 8831<P> 8832In the second form, <I>command</I> is re-executed after each instance 8833of <I>pat</I> is replaced by <I>rep</I>. 8834A useful alias to use with this is 8835 8836<TT>r='fc -s'</TT>, 8837so that typing 8838 8839<TT>r cc</TT> 8840runs the last command beginning with 8841 8842<TT>cc</TT> 8843and typing 8844 8845<TT>r</TT> 8846re-executes the last command. 8847<P> 8848If the first form is used, the return value is 0 unless an invalid 8849option is encountered or 8850<I>first</I> 8851 8852or 8853<I>last</I> 8854 8855specify history lines out of range. 8856If the 8857<B>-e</B> 8858 8859option is supplied, the return value is the value of the last 8860command executed or failure if an error occurs with the temporary 8861file of commands. If the second form is used, the return status 8862is that of the command re-executed, unless 8863<I>cmd</I> 8864 8865does not specify a valid history line, in which case 8866<B>fc</B> 8867 8868returns failure. 8869<DT><B>fg</B> [<I>jobspec</I>]<DD> 8870Resume 8871<I>jobspec</I> 8872 8873in the foreground, and make it the current job. 8874If 8875<I>jobspec</I> 8876 8877is not present, the shell's notion of the <I>current job</I> is used. 8878The return value is that of the command placed into the foreground, 8879or failure if run when job control is disabled or, when run with 8880job control enabled, if 8881<I>jobspec</I> 8882 8883does not specify a valid job or 8884<I>jobspec</I> 8885 8886specifies a job that was started without job control. 8887<DT><B>getopts</B> <I>optstring</I> <I>name</I> [<I>args</I>]<DD> 8888<B>getopts</B> 8889 8890is used by shell procedures to parse positional parameters. 8891<I>optstring</I> 8892 8893contains the option characters to be recognized; if a character 8894is followed by a colon, the option is expected to have an 8895argument, which should be separated from it by white space. 8896The colon and question mark characters may not be used as 8897option characters. 8898Each time it is invoked, 8899<B>getopts</B> 8900 8901places the next option in the shell variable 8902<I>name</I>, 8903 8904initializing 8905<I>name</I> 8906 8907if it does not exist, 8908and the index of the next argument to be processed into the 8909variable 8910<FONT SIZE=-1><B>OPTIND</B>. 8911 8912</FONT> 8913<FONT SIZE=-1><B>OPTIND</B> 8914 8915</FONT> 8916is initialized to 1 each time the shell or a shell script 8917is invoked. When an option requires an argument, 8918<B>getopts</B> 8919 8920places that argument into the variable 8921<FONT SIZE=-1><B>OPTARG</B>. 8922 8923</FONT> 8924The shell does not reset 8925<FONT SIZE=-1><B>OPTIND</B> 8926 8927</FONT> 8928automatically; it must be manually reset between multiple 8929calls to 8930<B>getopts</B> 8931 8932within the same shell invocation if a new set of parameters 8933is to be used. 8934<P> 8935When the end of options is encountered, <B>getopts</B> exits with a 8936return value greater than zero. 8937<B>OPTIND</B> is set to the index of the first non-option argument, 8938and <B>name</B> is set to ?. 8939<P> 8940<B>getopts</B> 8941 8942normally parses the positional parameters, but if more arguments are 8943given in 8944<I>args</I>, 8945 8946<B>getopts</B> 8947 8948parses those instead. 8949<P> 8950<B>getopts</B> 8951 8952can report errors in two ways. If the first character of 8953<I>optstring</I> 8954 8955is a colon, 8956<I>silent</I> 8957 8958error reporting is used. In normal operation diagnostic messages 8959are printed when invalid options or missing option arguments are 8960encountered. 8961If the variable 8962<FONT SIZE=-1><B>OPTERR</B> 8963 8964</FONT> 8965is set to 0, no error messages will be displayed, even if the first 8966character of 8967<I>optstring</I> 8968 8969is not a colon. 8970<P> 8971If an invalid option is seen, 8972<B>getopts</B> 8973 8974places ? into 8975<I>name</I> 8976 8977and, if not silent, 8978prints an error message and unsets 8979<FONT SIZE=-1><B>OPTARG</B>. 8980 8981</FONT> 8982If 8983<B>getopts</B> 8984 8985is silent, 8986the option character found is placed in 8987<FONT SIZE=-1><B>OPTARG</B> 8988 8989</FONT> 8990and no diagnostic message is printed. 8991<P> 8992If a required argument is not found, and 8993<B>getopts</B> 8994 8995is not silent, 8996a question mark (<B>?</B>) is placed in 8997<I>name</I>, 8998 8999<FONT SIZE=-1><B>OPTARG</B> 9000 9001</FONT> 9002is unset, and a diagnostic message is printed. 9003If 9004<B>getopts</B> 9005 9006is silent, then a colon (<B>:</B>) is placed in 9007<I>name</I> 9008 9009and 9010<FONT SIZE=-1><B>OPTARG</B> 9011 9012</FONT> 9013is set to the option character found. 9014<P> 9015<B>getopts</B> 9016 9017returns true if an option, specified or unspecified, is found. 9018It returns false if the end of options is encountered or an 9019error occurs. 9020<DT><B>hash</B> [<B>-lr</B>] [<B>-p</B> <I>filename</I>] [<B>-dt</B>] [<I>name</I>]<DD> 9021For each 9022<I>name</I>, 9023 9024the full file name of the command is determined by searching 9025the directories in 9026<B>$PATH</B> 9027 9028and remembered. 9029If the 9030<B>-p</B> 9031 9032option is supplied, no path search is performed, and 9033<I>filename</I> 9034 9035is used as the full file name of the command. 9036The 9037<B>-r</B> 9038 9039option causes the shell to forget all 9040remembered locations. 9041The 9042<B>-d</B> 9043 9044option causes the shell to forget the remembered location of each <I>name</I>. 9045If the 9046<B>-t</B> 9047 9048option is supplied, the full pathname to which each <I>name</I> corresponds 9049is printed. If multiple <I>name</I> arguments are supplied with <B>-t</B>, 9050the <I>name</I> is printed before the hashed full pathname. 9051The 9052<B>-l</B> 9053 9054option causes output to be displayed in a format that may be reused as input. 9055If no arguments are given, or if only <B>-l</B> is supplied, 9056information about remembered commands is printed. 9057The return status is true unless a 9058<I>name</I> 9059 9060is not found or an invalid option is supplied. 9061<DT><B>help</B> [<B>-s</B>] [<I>pattern</I>]<DD> 9062Display helpful information about builtin commands. If 9063<I>pattern</I> 9064 9065is specified, 9066<B>help</B> 9067 9068gives detailed help on all commands matching 9069<I>pattern</I>; 9070 9071otherwise help for all the builtins and shell control structures 9072is printed. 9073The <B>-s</B> option restricts the information displayed to a short 9074usage synopsis. 9075The return status is 0 unless no command matches 9076<I>pattern</I>. 9077 9078<DT><B>history [</B><I>n</I>]<DD> 9079 9080<DT><B>history</B> <B>-c</B><DD> 9081<DT><B>history -d</B> <I>offset</I><DD> 9082<DT><B>history</B> <B>-anrw</B> [<I>filename</I>]<DD> 9083<DT><B>history</B> <B>-p</B> <I>arg</I> [<I>arg ...</I>]<DD> 9084<DT><B>history</B> <B>-s</B> <I>arg</I> [<I>arg ...</I>]<DD> 9085 9086With no options, display the command 9087history list with line numbers. Lines listed 9088with a 9089<B>*</B> 9090 9091have been modified. An argument of 9092<I>n</I> 9093 9094lists only the last 9095<I>n</I> 9096 9097lines. 9098If the shell variable <B>HISTTIMEFORMAT</B> is set and not null, 9099it is used as a format string for <I>strftime</I>(3) to display 9100the time stamp associated with each displayed history entry. 9101No intervening blank is printed between the formatted time stamp 9102and the history line. 9103If <I>filename</I> is supplied, it is used as the 9104name of the history file; if not, the value of 9105<FONT SIZE=-1><B>HISTFILE</B> 9106 9107</FONT> 9108is used. Options, if supplied, have the following meanings: 9109<DL COMPACT><DT><DD> 9110 9111<DL COMPACT> 9112<DT><B>-c</B> 9113 9114<DD> 9115Clear the history list by deleting all the entries. 9116<DT><B>-d</B> <I>offset</I><DD> 9117Delete the history entry at position <I>offset</I>. 9118<DT><B>-a</B> 9119 9120<DD> 9121Append the ``new'' history lines (history lines entered since the 9122beginning of the current <B>bash</B> session) to the history file. 9123<DT><B>-n</B> 9124 9125<DD> 9126Read the history lines not already read from the history 9127file into the current history list. These are lines 9128appended to the history file since the beginning of the 9129current <B>bash</B> session. 9130<DT><B>-r</B> 9131 9132<DD> 9133Read the contents of the history file 9134and use them as the current history. 9135<DT><B>-w</B> 9136 9137<DD> 9138Write the current history to the history file, overwriting the 9139history file's contents. 9140<DT><B>-p</B> 9141 9142<DD> 9143Perform history substitution on the following <I>args</I> and display 9144the result on the standard output. 9145Does not store the results in the history list. 9146Each <I>arg</I> must be quoted to disable normal history expansion. 9147<DT><B>-s</B> 9148 9149<DD> 9150Store the 9151<I>args</I> 9152 9153in the history list as a single entry. The last command in the 9154history list is removed before the 9155<I>args</I> 9156 9157are added. 9158 9159</DL> 9160<P> 9161 9162If the <B>HISTTIMEFORMAT</B> is set, the time stamp information 9163associated with each history entry is written to the history file. 9164The return value is 0 unless an invalid option is encountered, an 9165error occurs while reading or writing the history file, an invalid 9166<I>offset</I> is supplied as an argument to <B>-d</B>, or the 9167history expansion supplied as an argument to <B>-p</B> fails. 9168</DL> 9169 9170<DT><B>jobs</B> [<B>-lnprs</B>] [ <I>jobspec</I> ... ]<DD> 9171 9172<DT><B>jobs</B> <B>-x</B> <I>command</I> [ <I>args</I> ... ]<DD> 9173 9174The first form lists the active jobs. The options have the following 9175meanings: 9176<DL COMPACT><DT><DD> 9177 9178<DL COMPACT> 9179<DT><B>-l</B> 9180 9181<DD> 9182List process IDs 9183in addition to the normal information. 9184<DT><B>-p</B> 9185 9186<DD> 9187List only the process ID of the job's process group 9188leader. 9189<DT><B>-n</B> 9190 9191<DD> 9192Display information only about jobs that have changed status since 9193the user was last notified of their status. 9194<DT><B>-r</B> 9195 9196<DD> 9197Restrict output to running jobs. 9198<DT><B>-s</B> 9199 9200<DD> 9201Restrict output to stopped jobs. 9202 9203</DL> 9204<P> 9205 9206If 9207<I>jobspec</I> 9208 9209is given, output is restricted to information about that job. 9210The return status is 0 unless an invalid option is encountered 9211or an invalid 9212<I>jobspec</I> 9213 9214is supplied. 9215<P> 9216 9217If the 9218<B>-x</B> 9219 9220option is supplied, 9221<B>jobs</B> 9222 9223replaces any 9224<I>jobspec</I> 9225 9226found in 9227<I>command</I> 9228 9229or 9230<I>args</I> 9231 9232with the corresponding process group ID, and executes 9233<I>command</I> 9234 9235passing it 9236<I>args</I>, 9237 9238returning its exit status. 9239</DL> 9240 9241<DT><B>kill</B> [<B>-s</B> <I>sigspec</I> | <B>-n</B> <I>signum</I> | <B>-</B><I>sigspec</I>] [<I>pid</I> | <I>jobspec</I>] ...<DD> 9242 9243<DT><B>kill</B> <B>-l</B> [<I>sigspec</I> | <I>exit_status</I>]<DD> 9244 9245Send the signal named by 9246<I>sigspec</I> 9247 9248or 9249<I>signum</I> 9250 9251to the processes named by 9252<I>pid</I> 9253 9254or 9255<I>jobspec</I>. 9256 9257<I>sigspec</I> 9258 9259is either a case-insensitive signal name such as 9260<FONT SIZE=-1><B>SIGKILL</B> 9261 9262</FONT> 9263(with or without the 9264<FONT SIZE=-1><B>SIG</B> 9265 9266</FONT> 9267prefix) or a signal number; 9268<I>signum</I> 9269 9270is a signal number. 9271If 9272<I>sigspec</I> 9273 9274is not present, then 9275<FONT SIZE=-1><B>SIGTERM</B> 9276 9277</FONT> 9278is assumed. 9279An argument of 9280<B>-l</B> 9281 9282lists the signal names. 9283If any arguments are supplied when 9284<B>-l</B> 9285 9286is given, the names of the signals corresponding to the arguments are 9287listed, and the return status is 0. 9288The <I>exit_status</I> argument to 9289<B>-l</B> 9290 9291is a number specifying either a signal number or the exit status of 9292a process terminated by a signal. 9293<B>kill</B> 9294 9295returns true if at least one signal was successfully sent, or false 9296if an error occurs or an invalid option is encountered. 9297<DT><B>let</B> <I>arg</I> [<I>arg</I> ...]<DD> 9298Each 9299<I>arg</I> 9300 9301is an arithmetic expression to be evaluated (see 9302<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>). 9303 9304</FONT> 9305If the last 9306<I>arg</I> 9307 9308evaluates to 0, 9309<B>let</B> 9310 9311returns 1; 0 is returned otherwise. 9312<DT><B>local</B> [<I>option</I>] [<I>name</I>[=<I>value</I>] ...]<DD> 9313For each argument, a local variable named 9314<I>name </I> 9315 9316is created, and assigned 9317<I>value</I>. 9318 9319The <I>option</I> can be any of the options accepted by <B>declare</B>. 9320When 9321<B>local</B> 9322 9323is used within a function, it causes the variable 9324<I>name</I> 9325 9326to have a visible scope restricted to that function and its children. 9327With no operands, 9328<B>local</B> 9329 9330writes a list of local variables to the standard output. It is 9331an error to use 9332<B>local</B> 9333 9334when not within a function. The return status is 0 unless 9335<B>local</B> 9336 9337is used outside a function, an invalid 9338<I>name</I> 9339 9340is supplied, or 9341<I>name</I> is a readonly variable. 9342<DT><B>logout</B> 9343 9344<DD> 9345Exit a login shell. 9346<DT><B>popd</B> [-<B>n</B>] [+<I>n</I>] [-<I>n</I>]<DD> 9347Removes entries from the directory stack. With no arguments, 9348removes the top directory from the stack, and performs a 9349<B>cd</B> 9350 9351to the new top directory. 9352Arguments, if supplied, have the following meanings: 9353<DL COMPACT><DT><DD> 9354 9355<DL COMPACT> 9356<DT><B>+</B><I>n</I><DD> 9357Removes the <I>n</I>th entry counting from the left of the list 9358shown by 9359<B>dirs</B>, 9360 9361starting with zero. For example: 9362 9363<TT>popd +0</TT> 9364removes the first directory, 9365 9366<TT>popd +1</TT> 9367the second. 9368<DT><B>-</B><I>n</I><DD> 9369Removes the <I>n</I>th entry counting from the right of the list 9370shown by 9371<B>dirs</B>, 9372 9373starting with zero. For example: 9374 9375<TT>popd -0</TT> 9376removes the last directory, 9377 9378<TT>popd -1</TT> 9379the next to last. 9380<DT><B>-n</B> 9381 9382<DD> 9383Suppresses the normal change of directory when removing directories 9384from the stack, so that only the stack is manipulated. 9385 9386</DL> 9387<P> 9388 9389If the 9390<B>popd</B> 9391 9392command is successful, a 9393<B>dirs</B> 9394 9395is performed as well, and the return status is 0. 9396<B>popd</B> 9397 9398returns false if an invalid option is encountered, the directory stack 9399is empty, a non-existent directory stack entry is specified, or the 9400directory change fails. 9401</DL> 9402 9403<DT><B>printf</B> [<B>-v</B> <I>var</I>] <I>format</I> [<I>arguments</I>]<DD> 9404Write the formatted <I>arguments</I> to the standard output under the 9405control of the <I>format</I>. 9406The <I>format</I> is a character string which contains three types of objects: 9407plain characters, which are simply copied to standard output, character 9408escape sequences, which are converted and copied to the standard output, and 9409format specifications, each of which causes printing of the next successive 9410<I>argument</I>. 9411In addition to the standard <I>printf</I>(1) formats, <B>%b</B> causes 9412<B>printf</B> to expand backslash escape sequences in the corresponding 9413<I>argument</I> (except that <B>\c</B> terminates output, backslashes in 9414<B>\'</B>, <B>\"</B>, and <B>\?</B> are not removed, and octal escapes 9415beginning with <B>\0</B> may contain up to four digits), 9416and <B>%q</B> causes <B>printf</B> to output the corresponding 9417<I>argument</I> in a format that can be reused as shell input. 9418<P> 9419The <B>-v</B> option causes the output to be assigned to the variable 9420<I>var</I> rather than being printed to the standard output. 9421<P> 9422The <I>format</I> is reused as necessary to consume all of the <I>arguments</I>. 9423If the <I>format</I> requires more <I>arguments</I> than are supplied, the 9424extra format specifications behave as if a zero value or null string, as 9425appropriate, had been supplied. The return value is zero on success, 9426non-zero on failure. 9427<DT><B>pushd</B> [<B>-n</B>] [<I>dir</I>]<DD> 9428 9429<DT><B>pushd</B> [<B>-n</B>] [+<I>n</I>] [-<I>n</I>]<DD> 9430 9431Adds a directory to the top of the directory stack, or rotates 9432the stack, making the new top of the stack the current working 9433directory. With no arguments, exchanges the top two directories 9434and returns 0, unless the directory stack is empty. 9435Arguments, if supplied, have the following meanings: 9436<DL COMPACT><DT><DD> 9437 9438<DL COMPACT> 9439<DT><B>+</B><I>n</I><DD> 9440Rotates the stack so that the <I>n</I>th directory 9441(counting from the left of the list shown by 9442<B>dirs</B>, 9443 9444starting with zero) 9445is at the top. 9446<DT><B>-</B><I>n</I><DD> 9447Rotates the stack so that the <I>n</I>th directory 9448(counting from the right of the list shown by 9449<B>dirs</B>, 9450 9451starting with zero) is at the top. 9452<DT><B>-n</B> 9453 9454<DD> 9455Suppresses the normal change of directory when adding directories 9456to the stack, so that only the stack is manipulated. 9457<DT><I>dir</I> 9458 9459<DD> 9460Adds 9461<I>dir</I> 9462 9463to the directory stack at the top, making it the 9464new current working directory. 9465 9466</DL> 9467<P> 9468 9469If the 9470<B>pushd</B> 9471 9472command is successful, a 9473<B>dirs</B> 9474 9475is performed as well. 9476If the first form is used, 9477<B>pushd</B> 9478 9479returns 0 unless the cd to 9480<I>dir</I> 9481 9482fails. With the second form, 9483<B>pushd</B> 9484 9485returns 0 unless the directory stack is empty, 9486a non-existent directory stack element is specified, 9487or the directory change to the specified new current directory 9488fails. 9489</DL> 9490 9491<DT><B>pwd</B> [<B>-LP</B>]<DD> 9492Print the absolute pathname of the current working directory. 9493The pathname printed contains no symbolic links if the 9494<B>-P</B> 9495 9496option is supplied or the 9497<B>-o physical</B> 9498 9499option to the 9500<B>set</B> 9501 9502builtin command is enabled. 9503If the 9504<B>-L</B> 9505 9506option is used, the pathname printed may contain symbolic links. 9507The return status is 0 unless an error occurs while 9508reading the name of the current directory or an 9509invalid option is supplied. 9510<DT><B>read</B> [<B>-ers</B>] [<B>-u</B> <I>fd</I>] [<B>-t</B> <I>timeout</I>] [<B>-a</B> <I>aname</I>] [<B>-p</B> <I>prompt</I>] [<B>-n</B> <I>nchars</I>] [<B>-d</B> <I>delim</I>] [<I>name</I> ...]<DD> 9511One line is read from the standard input, or from the file descriptor 9512<I>fd</I> supplied as an argument to the <B>-u</B> option, and the first word 9513is assigned to the first 9514<I>name</I>, 9515 9516the second word to the second 9517<I>name</I>, 9518 9519and so on, with leftover words and their intervening separators assigned 9520to the last 9521<I>name</I>. 9522 9523If there are fewer words read from the input stream than names, 9524the remaining names are assigned empty values. 9525The characters in 9526<FONT SIZE=-1><B>IFS</B> 9527 9528</FONT> 9529are used to split the line into words. 9530The backslash character (<B>\</B>) may be used to remove any special 9531meaning for the next character read and for line continuation. 9532Options, if supplied, have the following meanings: 9533<DL COMPACT><DT><DD> 9534 9535<DL COMPACT> 9536<DT><B>-a </B><I>aname</I> 9537 9538<DD> 9539The words are assigned to sequential indices 9540of the array variable 9541<I>aname</I>, 9542 9543starting at 0. 9544<I>aname</I> 9545 9546is unset before any new values are assigned. 9547Other <I>name</I> arguments are ignored. 9548<DT><B>-d </B><I>delim</I> 9549 9550<DD> 9551The first character of <I>delim</I> is used to terminate the input line, 9552rather than newline. 9553<DT><B>-e</B> 9554 9555<DD> 9556If the standard input 9557is coming from a terminal, 9558<B>readline</B> 9559 9560(see 9561<FONT SIZE=-1><B>READLINE</B> 9562 9563</FONT> 9564above) is used to obtain the line. 9565<DT><B>-n </B><I>nchars</I> 9566 9567<DD> 9568<B>read</B> returns after reading <I>nchars</I> characters rather than 9569waiting for a complete line of input. 9570<DT><B>-p </B><I>prompt</I> 9571 9572<DD> 9573Display <I>prompt</I> on standard error, without a 9574trailing newline, before attempting to read any input. The prompt 9575is displayed only if input is coming from a terminal. 9576<DT><B>-r</B> 9577 9578<DD> 9579Backslash does not act as an escape character. 9580The backslash is considered to be part of the line. 9581In particular, a backslash-newline pair may not be used as a line 9582continuation. 9583<DT><B>-s</B> 9584 9585<DD> 9586Silent mode. If input is coming from a terminal, characters are 9587not echoed. 9588<DT><B>-t </B><I>timeout</I> 9589 9590<DD> 9591Cause <B>read</B> to time out and return failure if a complete line of 9592input is not read within <I>timeout</I> seconds. 9593This option has no effect if <B>read</B> is not reading input from the 9594terminal or a pipe. 9595<DT><B>-u </B><I>fd</I> 9596 9597<DD> 9598Read input from file descriptor <I>fd</I>. 9599 9600</DL> 9601<P> 9602 9603If no 9604<I>names</I> 9605 9606are supplied, the line read is assigned to the variable 9607<FONT SIZE=-1><B>REPLY</B>. 9608 9609</FONT> 9610The return code is zero, unless end-of-file is encountered, <B>read</B> 9611times out, or an invalid file descriptor is supplied as the argument to 9612<B>-u</B>. 9613</DL> 9614 9615<DT><B>readonly</B> [<B>-apf</B>] [<I>name</I>[=<I>word</I>] ...]<DD> 9616 9617The given 9618<I>names</I> are marked readonly; the values of these 9619<I>names</I> 9620 9621may not be changed by subsequent assignment. 9622If the 9623<B>-f</B> 9624 9625option is supplied, the functions corresponding to the 9626<I>names</I> are so 9627marked. 9628The 9629<B>-a</B> 9630 9631option restricts the variables to arrays. 9632If no 9633<I>name</I> 9634 9635arguments are given, or if the 9636<B>-p</B> 9637 9638option is supplied, a list of all readonly names is printed. 9639The 9640<B>-p</B> 9641 9642option causes output to be displayed in a format that 9643may be reused as input. 9644If a variable name is followed by =<I>word</I>, the value of 9645the variable is set to <I>word</I>. 9646The return status is 0 unless an invalid option is encountered, 9647one of the 9648<I>names</I> 9649 9650is not a valid shell variable name, or 9651<B>-f</B> 9652 9653is supplied with a 9654<I>name</I> 9655 9656that is not a function. 9657<DT><B>return</B> [<I>n</I>]<DD> 9658Causes a function to exit with the return value specified by 9659<I>n</I>. 9660 9661If 9662<I>n</I> 9663 9664is omitted, the return status is that of the last command 9665executed in the function body. If used outside a function, 9666but during execution of a script by the 9667<B>.</B> 9668 9669(<B>source</B>) command, it causes the shell to stop executing 9670that script and return either 9671<I>n</I> 9672 9673or the exit status of the last command executed within the 9674script as the exit status of the script. If used outside a 9675function and not during execution of a script by <B>.</B>, 9676the return status is false. 9677Any command associated with the <B>RETURN</B> trap is executed 9678before execution resumes after the function or script. 9679<DT><B>set</B> [<B>--abefhkmnptuvxBCHP</B>] [<B>-o</B> <I>option</I>] [<I>arg</I> ...]<DD> 9680Without options, the name and value of each shell variable are displayed 9681in a format that can be reused as input 9682for setting or resetting the currently-set variables. 9683Read-only variables cannot be reset. 9684In <I>posix mode</I>, only shell variables are listed. 9685The output is sorted according to the current locale. 9686When options are specified, they set or unset shell attributes. 9687Any arguments remaining after the options are processed are treated 9688as values for the positional parameters and are assigned, in order, to 9689<B>$1</B>, 9690 9691<B>$2</B>, 9692 9693<B>...</B> 9694 9695<B>$</B><I>n</I>. 9696 9697Options, if specified, have the following meanings: 9698<DL COMPACT><DT><DD> 9699 9700<DL COMPACT> 9701<DT><B>-a</B> 9702 9703<DD> 9704Automatically mark variables and functions which are modified or 9705created for export to the environment of subsequent commands. 9706<DT><B>-b</B> 9707 9708<DD> 9709Report the status of terminated background jobs 9710immediately, rather than before the next primary prompt. This is 9711effective only when job control is enabled. 9712<DT><B>-e</B> 9713 9714<DD> 9715Exit immediately if a <I>simple command</I> (see 9716<FONT SIZE=-1><B>SHELL GRAMMAR</B> 9717 9718</FONT> 9719above) exits with a non-zero status. 9720The shell does not exit if the 9721command that fails is part of the command list immediately following a 9722<B>while</B> 9723 9724or 9725<B>until</B> 9726 9727keyword, 9728part of the test in an 9729<I>if</I> 9730 9731statement, part of a 9732<B>&&</B> 9733 9734or 9735<B>||</B> 9736 9737list, or if the command's return value is 9738being inverted via 9739<B>!</B>. 9740 9741A trap on <B>ERR</B>, if set, is executed before the shell exits. 9742<DT><B>-f</B> 9743 9744<DD> 9745Disable pathname expansion. 9746<DT><B>-h</B> 9747 9748<DD> 9749Remember the location of commands as they are looked up for execution. 9750This is enabled by default. 9751<DT><B>-k</B> 9752 9753<DD> 9754All arguments in the form of assignment statements 9755are placed in the environment for a command, not just 9756those that precede the command name. 9757<DT><B>-m</B> 9758 9759<DD> 9760Monitor mode. Job control is enabled. This option is on 9761by default for interactive shells on systems that support 9762it (see 9763<FONT SIZE=-1><B>JOB CONTROL</B> 9764 9765</FONT> 9766above). Background processes run in a separate process 9767group and a line containing their exit status is printed 9768upon their completion. 9769<DT><B>-n</B> 9770 9771<DD> 9772Read commands but do not execute them. This may be used to 9773check a shell script for syntax errors. This is ignored by 9774interactive shells. 9775<DT><B>-o </B><I>option-name</I> 9776 9777<DD> 9778The <I>option-name</I> can be one of the following: 9779<DL COMPACT><DT><DD> 9780<DL COMPACT> 9781<DT><B>allexport</B> 9782 9783<DD> 9784Same as 9785<B>-a</B>. 9786 9787<DT><B>braceexpand</B> 9788 9789<DD> 9790Same as 9791<B>-B</B>. 9792 9793<DT><B>emacs</B> 9794 9795<DD> 9796Use an emacs-style command line editing interface. This is enabled 9797by default when the shell is interactive, unless the shell is started 9798with the 9799<B>--noediting</B> 9800 9801option. 9802<DT><B>errtrace</B> 9803 9804<DD> 9805Same as 9806<B>-E</B>. 9807 9808<DT><B>functrace</B> 9809 9810<DD> 9811Same as 9812<B>-T</B>. 9813 9814<DT><B>errexit</B> 9815 9816<DD> 9817Same as 9818<B>-e</B>. 9819 9820<DT><B>hashall</B> 9821 9822<DD> 9823Same as 9824<B>-h</B>. 9825 9826<DT><B>histexpand</B> 9827 9828<DD> 9829Same as 9830<B>-H</B>. 9831 9832<DT><B>history</B> 9833 9834<DD> 9835Enable command history, as described above under 9836<FONT SIZE=-1><B>HISTORY</B>. 9837 9838</FONT> 9839This option is on by default in interactive shells. 9840<DT><B>ignoreeof</B> 9841 9842<DD> 9843The effect is as if the shell command 9844<TT>IGNOREEOF=10</TT> 9845 9846had been executed 9847(see 9848<B>Shell Variables</B> 9849 9850above). 9851<DT><B>keyword</B> 9852 9853<DD> 9854Same as 9855<B>-k</B>. 9856 9857<DT><B>monitor</B> 9858 9859<DD> 9860Same as 9861<B>-m</B>. 9862 9863<DT><B>noclobber</B> 9864 9865<DD> 9866Same as 9867<B>-C</B>. 9868 9869<DT><B>noexec</B> 9870 9871<DD> 9872Same as 9873<B>-n</B>. 9874 9875<DT><B>noglob</B> 9876 9877<DD> 9878Same as 9879<B>-f</B>. 9880 9881<B>nolog</B> 9882 9883Currently ignored. 9884<DT><B>notify</B> 9885 9886<DD> 9887Same as 9888<B>-b</B>. 9889 9890<DT><B>nounset</B> 9891 9892<DD> 9893Same as 9894<B>-u</B>. 9895 9896<DT><B>onecmd</B> 9897 9898<DD> 9899Same as 9900<B>-t</B>. 9901 9902<DT><B>physical</B> 9903 9904<DD> 9905Same as 9906<B>-P</B>. 9907 9908<DT><B>pipefail</B> 9909 9910<DD> 9911If set, the return value of a pipeline is the value of the last 9912(rightmost) command to exit with a non-zero status, or zero if all 9913commands in the pipeline exit successfully. 9914This option is disabled by default. 9915<DT><B>posix</B> 9916 9917<DD> 9918Change the behavior of 9919<B>bash</B> 9920 9921where the default operation differs 9922from the POSIX 1003.2 standard to match the standard (<I>posix mode</I>). 9923<DT><B>privileged</B> 9924 9925<DD> 9926Same as 9927<B>-p</B>. 9928 9929<DT><B>verbose</B> 9930 9931<DD> 9932Same as 9933<B>-v</B>. 9934 9935<DT><B>vi</B> 9936 9937<DD> 9938Use a vi-style command line editing interface. 9939<DT><B>xtrace</B> 9940 9941<DD> 9942Same as 9943<B>-x</B>. 9944 9945<P> 9946</DL> 9947<P> 9948 9949If 9950<B>-o</B> 9951 9952is supplied with no <I>option-name</I>, the values of the current options are 9953printed. 9954If 9955<B>+o</B> 9956 9957is supplied with no <I>option-name</I>, a series of 9958<B>set</B> 9959 9960commands to recreate the current option settings is displayed on 9961the standard output. 9962</DL> 9963 9964<DT><B>-p</B> 9965 9966<DD> 9967Turn on 9968<I>privileged</I> 9969 9970mode. In this mode, the 9971<FONT SIZE=-1><B>$ENV</B> 9972 9973</FONT> 9974and 9975<FONT SIZE=-1><B>$BASH_ENV</B> 9976 9977</FONT> 9978files are not processed, shell functions are not inherited from the 9979environment, and the 9980<FONT SIZE=-1><B>SHELLOPTS</B> 9981 9982</FONT> 9983variable, if it appears in the environment, is ignored. 9984If the shell is started with the effective user (group) id not equal to the 9985real user (group) id, and the <B>-p</B> option is not supplied, these actions 9986are taken and the effective user id is set to the real user id. 9987If the <B>-p</B> option is supplied at startup, the effective user id is 9988not reset. 9989Turning this option off causes the effective user 9990and group ids to be set to the real user and group ids. 9991<DT><B>-t</B> 9992 9993<DD> 9994Exit after reading and executing one command. 9995<DT><B>-u</B> 9996 9997<DD> 9998Treat unset variables as an error when performing 9999parameter expansion. If expansion is attempted on an 10000unset variable, the shell prints an error message, and, 10001if not interactive, exits with a non-zero status. 10002<DT><B>-v</B> 10003 10004<DD> 10005Print shell input lines as they are read. 10006<DT><B>-x</B> 10007 10008<DD> 10009After expanding each <I>simple command</I>, 10010<B>for</B> command, <B>case</B> command, <B>select</B> command, or 10011arithmetic <B>for</B> command, display the expanded value of 10012<FONT SIZE=-1><B>PS4</B>, 10013 10014</FONT> 10015followed by the command and its expanded arguments 10016or associated word list. 10017<DT><B>-B</B> 10018 10019<DD> 10020The shell performs brace expansion (see 10021<B>Brace Expansion</B> 10022 10023above). This is on by default. 10024<DT><B>-C</B> 10025 10026<DD> 10027If set, 10028<B>bash</B> 10029 10030does not overwrite an existing file with the 10031<B>></B>, 10032 10033<B>>&</B>, 10034 10035and 10036<B><></B> 10037 10038redirection operators. This may be overridden when 10039creating output files by using the redirection operator 10040<B>>|</B> 10041 10042instead of 10043<B>></B>. 10044 10045<DT><B>-E</B> 10046 10047<DD> 10048If set, any trap on <B>ERR</B> is inherited by shell functions, command 10049substitutions, and commands executed in a subshell environment. 10050The <B>ERR</B> trap is normally not inherited in such cases. 10051<DT><B>-H</B> 10052 10053<DD> 10054Enable 10055<B>!</B> 10056 10057style history substitution. This option is on by 10058default when the shell is interactive. 10059<DT><B>-P</B> 10060 10061<DD> 10062If set, the shell does not follow symbolic links when executing 10063commands such as 10064<B>cd</B> 10065 10066that change the current working directory. It uses the 10067physical directory structure instead. By default, 10068<B>bash</B> 10069 10070follows the logical chain of directories when performing commands 10071which change the current directory. 10072<DT><B>-T</B> 10073 10074<DD> 10075If set, any traps on <B>DEBUG</B> and <B>RETURN</B> are inherited by shell 10076functions, command substitutions, and commands executed in a 10077subshell environment. 10078The <B>DEBUG</B> and <B>RETURN</B> traps are normally not inherited 10079in such cases. 10080<DT><B>--</B> 10081 10082<DD> 10083If no arguments follow this option, then the positional parameters are 10084unset. Otherwise, the positional parameters are set to the 10085<I>arg</I>s, even if some of them begin with a 10086<B>-</B>. 10087 10088<DT><B>-</B> 10089 10090<DD> 10091Signal the end of options, cause all remaining <I>arg</I>s to be 10092assigned to the positional parameters. The 10093<B>-x</B> 10094 10095and 10096<B>-v</B> 10097 10098options are turned off. 10099If there are no <I>arg</I>s, 10100the positional parameters remain unchanged. 10101 10102</DL> 10103<P> 10104 10105The options are off by default unless otherwise noted. 10106Using + rather than - causes these options to be turned off. 10107The options can also be specified as arguments to an invocation of 10108the shell. 10109The current set of options may be found in 10110<B>$-</B>. 10111 10112The return status is always true unless an invalid option is encountered. 10113</DL> 10114 10115<DT><B>shift</B> [<I>n</I>]<DD> 10116The positional parameters from <I>n</I>+1 ... are renamed to 10117<B>$1</B> 10118 10119<B>....</B> 10120 10121Parameters represented by the numbers <B>$#</B> 10122down to <B>$#</B>-<I>n</I>+1 are unset. 10123<I>n</I> 10124 10125must be a non-negative number less than or equal to <B>$#</B>. 10126If 10127<I>n</I> 10128 10129is 0, no parameters are changed. 10130If 10131<I>n </I> 10132 10133is not given, it is assumed to be 1. 10134If 10135<I>n</I> 10136 10137is greater than <B>$#</B>, the positional parameters are not changed. 10138The return status is greater than zero if 10139<I>n</I> 10140 10141is greater than 10142<B>$#</B> 10143 10144or less than zero; otherwise 0. 10145<DT><B>shopt</B> [<B>-pqsu</B>] [<B>-o</B>] [<I>optname</I> ...]<DD> 10146Toggle the values of variables controlling optional shell behavior. 10147With no options, or with the 10148<B>-p</B> 10149 10150option, a list of all settable options is displayed, with 10151an indication of whether or not each is set. 10152The <B>-p</B> option causes output to be displayed in a form that 10153may be reused as input. 10154Other options have the following meanings: 10155<DL COMPACT><DT><DD> 10156 10157<DL COMPACT> 10158<DT><B>-s</B> 10159 10160<DD> 10161Enable (set) each <I>optname</I>. 10162<DT><B>-u</B> 10163 10164<DD> 10165Disable (unset) each <I>optname</I>. 10166<DT><B>-q</B> 10167 10168<DD> 10169Suppresses normal output (quiet mode); the return status indicates 10170whether the <I>optname</I> is set or unset. 10171If multiple <I>optname</I> arguments are given with 10172<B>-q</B>, 10173 10174the return status is zero if all <I>optnames</I> are enabled; non-zero 10175otherwise. 10176<DT><B>-o</B> 10177 10178<DD> 10179Restricts the values of <I>optname</I> to be those defined for the 10180<B>-o</B> 10181 10182option to the 10183<B>set</B> 10184 10185builtin. 10186 10187</DL> 10188<P> 10189 10190If either 10191<B>-s</B> 10192 10193or 10194<B>-u</B> 10195 10196is used with no <I>optname</I> arguments, the display is limited to 10197those options which are set or unset, respectively. 10198Unless otherwise noted, the <B>shopt</B> options are disabled (unset) 10199by default. 10200<P> 10201 10202The return status when listing options is zero if all <I>optnames</I> 10203are enabled, non-zero otherwise. When setting or unsetting options, 10204the return status is zero unless an <I>optname</I> is not a valid shell 10205option. 10206<P> 10207 10208The list of <B>shopt</B> options is: 10209<P> 10210 10211 10212 10213<DL COMPACT> 10214<DT><B>cdable_vars</B> 10215 10216<DD> 10217If set, an argument to the 10218<B>cd</B> 10219 10220builtin command that 10221is not a directory is assumed to be the name of a variable whose 10222value is the directory to change to. 10223<DT><B>cdspell</B> 10224 10225<DD> 10226If set, minor errors in the spelling of a directory component in a 10227<B>cd</B> 10228 10229command will be corrected. 10230The errors checked for are transposed characters, 10231a missing character, and one character too many. 10232If a correction is found, the corrected file name is printed, 10233and the command proceeds. 10234This option is only used by interactive shells. 10235<DT><B>checkhash</B> 10236 10237<DD> 10238If set, <B>bash</B> checks that a command found in the hash 10239table exists before trying to execute it. If a hashed command no 10240longer exists, a normal path search is performed. 10241<DT><B>checkwinsize</B> 10242 10243<DD> 10244If set, <B>bash</B> checks the window size after each command 10245and, if necessary, updates the values of 10246<FONT SIZE=-1><B>LINES</B> 10247 10248</FONT> 10249and 10250<FONT SIZE=-1><B>COLUMNS</B>. 10251 10252</FONT> 10253<DT><B>cmdhist</B> 10254 10255<DD> 10256If set, 10257<B>bash</B> 10258 10259attempts to save all lines of a multiple-line 10260command in the same history entry. This allows 10261easy re-editing of multi-line commands. 10262<DT><B>dotglob</B> 10263 10264<DD> 10265If set, 10266<B>bash</B> 10267 10268includes filenames beginning with a `.' in the results of pathname 10269expansion. 10270<DT><B>execfail</B> 10271 10272<DD> 10273If set, a non-interactive shell will not exit if 10274it cannot execute the file specified as an argument to the 10275<B>exec</B> 10276 10277builtin command. An interactive shell does not exit if 10278<B>exec</B> 10279 10280fails. 10281<DT><B>expand_aliases</B> 10282 10283<DD> 10284If set, aliases are expanded as described above under 10285<FONT SIZE=-1><B>ALIASES</B>. 10286 10287</FONT> 10288This option is enabled by default for interactive shells. 10289<DT><B>extdebug</B> 10290 10291<DD> 10292If set, behavior intended for use by debuggers is enabled: 10293<DL COMPACT><DT><DD> 10294<DL COMPACT> 10295<DT><B>1.</B> 10296 10297<DD> 10298The <B>-F</B> option to the <B>declare</B> builtin displays the source 10299file name and line number corresponding to each function name supplied 10300as an argument. 10301<DT><B>2.</B> 10302 10303<DD> 10304If the command run by the <B>DEBUG</B> trap returns a non-zero value, the 10305next command is skipped and not executed. 10306<DT><B>3.</B> 10307 10308<DD> 10309If the command run by the <B>DEBUG</B> trap returns a value of 2, and the 10310shell is executing in a subroutine (a shell function or a shell script 10311executed by the <B>.</B> or <B>source</B> builtins), a call to 10312<B>return</B> is simulated. 10313<DT><B>4.</B> 10314 10315<DD> 10316<B>BASH_ARGC</B> and <B>BASH_ARGV</B> are updated as described in their 10317descriptions above. 10318<DT><B>5.</B> 10319 10320<DD> 10321Function tracing is enabled: command substitution, shell functions, and 10322subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the 10323<B>DEBUG</B> and <B>RETURN</B> traps. 10324<DT><B>6.</B> 10325 10326<DD> 10327Error tracing is enabled: command substitution, shell functions, and 10328subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the 10329<B>ERROR</B> trap. 10330</DL></DL> 10331 10332<DT><B>extglob</B> 10333 10334<DD> 10335If set, the extended pattern matching features described above under 10336<B>Pathname Expansion</B> are enabled. 10337<DT><B>extquote</B> 10338 10339<DD> 10340If set, <B>$</B>'<I>string</I>' and <B>$</B>"<I>string</I>" quoting is 10341performed within <B>${</B><I>parameter</I><B>}</B> expansions 10342enclosed in double quotes. This option is enabled by default. 10343<DT><B>failglob</B> 10344 10345<DD> 10346If set, patterns which fail to match filenames during pathname expansion 10347result in an expansion error. 10348<DT><B>force_fignore</B> 10349 10350<DD> 10351If set, the suffixes specified by the <B>FIGNORE</B> shell variable 10352cause words to be ignored when performing word completion even if 10353the ignored words are the only possible completions. 10354See 10355<FONT SIZE=-1><B>SHELL VARIABLES</B></FONT> 10356above for a description of <B>FIGNORE</B>. 10357This option is enabled by default. 10358<DT><B>gnu_errfmt</B> 10359 10360<DD> 10361If set, shell error messages are written in the standard GNU error 10362message format. 10363<DT><B>histappend</B> 10364 10365<DD> 10366If set, the history list is appended to the file named by the value 10367of the 10368<B>HISTFILE</B> 10369 10370variable when the shell exits, rather than overwriting the file. 10371<DT><B>histreedit</B> 10372 10373<DD> 10374If set, and 10375<B>readline</B> 10376 10377is being used, a user is given the opportunity to re-edit a 10378failed history substitution. 10379<DT><B>histverify</B> 10380 10381<DD> 10382If set, and 10383<B>readline</B> 10384 10385is being used, the results of history substitution are not immediately 10386passed to the shell parser. Instead, the resulting line is loaded into 10387the <B>readline</B> editing buffer, allowing further modification. 10388<DT><B>hostcomplete</B> 10389 10390<DD> 10391If set, and 10392<B>readline</B> 10393 10394is being used, <B>bash</B> will attempt to perform hostname completion when a 10395word containing a <B>@</B> is being completed (see 10396<B>Completing</B> 10397 10398under 10399<FONT SIZE=-1><B>READLINE</B> 10400 10401</FONT> 10402above). 10403This is enabled by default. 10404<DT><B>huponexit</B> 10405 10406<DD> 10407If set, <B>bash</B> will send 10408<FONT SIZE=-1><B>SIGHUP</B> 10409 10410</FONT> 10411to all jobs when an interactive login shell exits. 10412<DT><B>interactive_comments</B> 10413 10414<DD> 10415If set, allow a word beginning with 10416<B>#</B> 10417 10418to cause that word and all remaining characters on that 10419line to be ignored in an interactive shell (see 10420<FONT SIZE=-1><B>COMMENTS</B> 10421 10422</FONT> 10423above). This option is enabled by default. 10424<DT><B>lithist</B> 10425 10426<DD> 10427If set, and the 10428<B>cmdhist</B> 10429 10430option is enabled, multi-line commands are saved to the history with 10431embedded newlines rather than using semicolon separators where possible. 10432<DT><B>login_shell</B> 10433 10434<DD> 10435The shell sets this option if it is started as a login shell (see 10436<FONT SIZE=-1><B>INVOCATION</B> 10437 10438</FONT> 10439above). 10440The value may not be changed. 10441<DT><B>mailwarn</B> 10442 10443<DD> 10444If set, and a file that <B>bash</B> is checking for mail has been 10445accessed since the last time it was checked, the message ``The mail in 10446<I>mailfile</I> has been read'' is displayed. 10447<DT><B>no_empty_cmd_completion</B> 10448 10449<DD> 10450If set, and 10451<B>readline</B> 10452 10453is being used, 10454<B>bash</B> 10455 10456will not attempt to search the <B>PATH</B> for possible completions when 10457completion is attempted on an empty line. 10458<DT><B>nocaseglob</B> 10459 10460<DD> 10461If set, 10462<B>bash</B> 10463 10464matches filenames in a case-insensitive fashion when performing pathname 10465expansion (see 10466<B>Pathname Expansion</B> 10467 10468above). 10469<DT><B>nocasematch</B> 10470 10471<DD> 10472If set, 10473<B>bash</B> 10474 10475matches patterns in a case-insensitive fashion when performing matching 10476while executing <B>case</B> or <B>[[</B> conditional commands. 10477<DT><B>nullglob</B> 10478 10479<DD> 10480If set, 10481<B>bash</B> 10482 10483allows patterns which match no 10484files (see 10485<B>Pathname Expansion</B> 10486 10487above) 10488to expand to a null string, rather than themselves. 10489<DT><B>progcomp</B> 10490 10491<DD> 10492If set, the programmable completion facilities (see 10493<B>Programmable Completion</B> above) are enabled. 10494This option is enabled by default. 10495<DT><B>promptvars</B> 10496 10497<DD> 10498If set, prompt strings undergo 10499parameter expansion, command substitution, arithmetic 10500expansion, and quote removal after being expanded as described in 10501<FONT SIZE=-1><B>PROMPTING</B> 10502 10503</FONT> 10504above. This option is enabled by default. 10505<DT><B>restricted_shell</B> 10506 10507<DD> 10508The shell sets this option if it is started in restricted mode (see 10509<FONT SIZE=-1><B>RESTRICTED SHELL</B> 10510 10511</FONT> 10512below). 10513The value may not be changed. 10514This is not reset when the startup files are executed, allowing 10515the startup files to discover whether or not a shell is restricted. 10516<DT><B>shift_verbose</B> 10517 10518<DD> 10519If set, the 10520<B>shift</B> 10521 10522builtin prints an error message when the shift count exceeds the 10523number of positional parameters. 10524<DT><B>sourcepath</B> 10525 10526<DD> 10527If set, the 10528<B>source</B> (<B>.</B>) builtin uses the value of 10529<FONT SIZE=-1><B>PATH</B> 10530 10531</FONT> 10532to find the directory containing the file supplied as an argument. 10533This option is enabled by default. 10534<DT><B>xpg_echo</B> 10535 10536<DD> 10537If set, the <B>echo</B> builtin expands backslash-escape sequences 10538by default. 10539</DL></DL> 10540 10541<DT><B>suspend</B> [<B>-f</B>]<DD> 10542Suspend the execution of this shell until it receives a 10543<FONT SIZE=-1><B>SIGCONT</B> 10544 10545</FONT> 10546signal. The 10547<B>-f</B> 10548 10549option says not to complain if this is 10550a login shell; just suspend anyway. The return status is 0 unless 10551the shell is a login shell and 10552<B>-f</B> 10553 10554is not supplied, or if job control is not enabled. 10555<DT><B>test</B> <I>expr</I><DD> 10556 10557<DT><B>[</B> <I>expr</I> <B>]</B><DD> 10558Return a status of 0 or 1 depending on 10559the evaluation of the conditional expression 10560<I>expr</I>. 10561 10562Each operator and operand must be a separate argument. 10563Expressions are composed of the primaries described above under 10564<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>. 10565 10566</FONT> 10567<B>test</B> does not accept any options, nor does it accept and ignore 10568an argument of <B>--</B> as signifying the end of options. 10569<P> 10570 10571 10572Expressions may be combined using the following operators, listed 10573in decreasing order of precedence. 10574<DL COMPACT><DT><DD> 10575 10576<DL COMPACT> 10577<DT><B>! </B><I>expr</I> 10578 10579<DD> 10580True if 10581<I>expr</I> 10582 10583is false. 10584<DT><B>( </B><I>expr</I> ) 10585 10586<DD> 10587Returns the value of <I>expr</I>. 10588This may be used to override the normal precedence of operators. 10589<DT><I>expr1</I> -<B>a</B> <I>expr2</I><DD> 10590True if both 10591<I>expr1</I> 10592 10593and 10594<I>expr2</I> 10595 10596are true. 10597<DT><I>expr1</I> -<B>o</B> <I>expr2</I><DD> 10598True if either 10599<I>expr1</I> 10600 10601or 10602<I>expr2</I> 10603 10604is true. 10605 10606</DL> 10607<P> 10608 10609<B>test</B> and <B>[</B> evaluate conditional 10610expressions using a set of rules based on the number of arguments. 10611<P> 10612 10613 10614 10615<DL COMPACT> 10616<DT>0 arguments<DD> 10617The expression is false. 10618<DT>1 argument<DD> 10619The expression is true if and only if the argument is not null. 10620<DT>2 arguments<DD> 10621If the first argument is <B>!</B>, the expression is true if and 10622only if the second argument is null. 10623If the first argument is one of the unary conditional operators listed above 10624under 10625<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>, 10626 10627</FONT> 10628the expression is true if the unary test is true. 10629If the first argument is not a valid unary conditional operator, the expression 10630is false. 10631<DT>3 arguments<DD> 10632If the second argument is one of the binary conditional operators listed above 10633under 10634<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>, 10635 10636</FONT> 10637the result of the expression is the result of the binary test using 10638the first and third arguments as operands. 10639If the first argument is <B>!</B>, the value is the negation of 10640the two-argument test using the second and third arguments. 10641If the first argument is exactly <B>(</B> and the third argument is 10642exactly <B>)</B>, the result is the one-argument test of the second 10643argument. 10644Otherwise, the expression is false. 10645The <B>-a</B> and <B>-o</B> operators are considered binary operators 10646in this case. 10647<DT>4 arguments<DD> 10648If the first argument is <B>!</B>, the result is the negation of 10649the three-argument expression composed of the remaining arguments. 10650Otherwise, the expression is parsed and evaluated according to 10651precedence using the rules listed above. 10652<DT>5 or more arguments<DD> 10653The expression is parsed and evaluated according to precedence 10654using the rules listed above. 10655</DL></DL> 10656 10657 10658<DT><B>times</B> 10659 10660<DD> 10661Print the accumulated user and system times for the shell and 10662for processes run from the shell. The return status is 0. 10663<DT><B>trap</B> [<B>-lp</B>] [[<I>arg</I>] <I>sigspec</I> ...]<DD> 10664The command 10665<I>arg</I> 10666 10667is to be read and executed when the shell receives 10668signal(s) 10669<I>sigspec</I>. 10670 10671If 10672<I>arg</I> 10673 10674is absent (and there is a single <I>sigspec</I>) or 10675<B>-</B>, 10676 10677each specified signal is 10678reset to its original disposition (the value it had 10679upon entrance to the shell). 10680If 10681<I>arg</I> 10682 10683is the null string the signal specified by each 10684<I>sigspec</I> 10685 10686is ignored by the shell and by the commands it invokes. 10687If 10688<I>arg</I> 10689 10690is not present and 10691<B>-p</B> 10692 10693has been supplied, then the trap commands associated with each 10694<I>sigspec</I> 10695 10696are displayed. 10697If no arguments are supplied or if only 10698<B>-p</B> 10699 10700is given, 10701<B>trap</B> 10702 10703prints the list of commands associated with each signal. 10704The 10705<B>-l</B> 10706 10707option causes the shell to print a list of signal names and 10708their corresponding numbers. 10709Each 10710<I>sigspec</I> 10711 10712is either 10713a signal name defined in <<I>signal.h</I>>, or a signal number. 10714Signal names are case insensitive and the SIG prefix is optional. 10715If a 10716<I>sigspec</I> 10717 10718is 10719<FONT SIZE=-1><B>EXIT</B> 10720 10721</FONT> 10722(0) the command 10723<I>arg</I> 10724 10725is executed on exit from the shell. 10726If a 10727<I>sigspec</I> 10728 10729is 10730<FONT SIZE=-1><B>DEBUG</B>, 10731 10732</FONT> 10733the command 10734<I>arg</I> 10735 10736is executed before every <I>simple command</I>, <I>for</I> command, 10737<I>case</I> command, <I>select</I> command, every arithmetic <I>for</I> 10738command, and before the first command executes in a shell function (see 10739<FONT SIZE=-1><B>SHELL GRAMMAR</B> 10740 10741</FONT> 10742above). 10743Refer to the description of the <B>extdebug</B> option to the 10744<B>shopt</B> builtin for details of its effect on the <B>DEBUG</B> trap. 10745If a 10746<I>sigspec</I> 10747 10748is 10749<FONT SIZE=-1><B>ERR</B>, 10750 10751</FONT> 10752the command 10753<I>arg</I> 10754 10755is executed whenever a simple command has a non-zero exit status, 10756subject to the following conditions. 10757The 10758<FONT SIZE=-1><B>ERR</B> 10759 10760</FONT> 10761trap is not executed if the failed 10762command is part of the command list immediately following a 10763<B>while</B> 10764 10765or 10766<B>until</B> 10767 10768keyword, 10769part of the test in an 10770<I>if</I> 10771 10772statement, part of a 10773<B>&&</B> 10774 10775or 10776<B>||</B> 10777 10778list, or if the command's return value is 10779being inverted via 10780<B>!</B>. 10781 10782These are the same conditions obeyed by the <B>errexit</B> option. 10783If a 10784<I>sigspec</I> 10785 10786is 10787<FONT SIZE=-1><B>RETURN</B>, 10788 10789</FONT> 10790the command 10791<I>arg</I> 10792 10793is executed each time a shell function or a script executed with the 10794<B>.</B> or <B>source</B> builtins finishes executing. 10795Signals ignored upon entry to the shell cannot be trapped or reset. 10796Trapped signals are reset to their original values in a child 10797process when it is created. 10798The return status is false if any 10799<I>sigspec</I> 10800 10801is invalid; otherwise 10802<B>trap</B> 10803 10804returns true. 10805<DT><B>type</B> [<B>-aftpP</B>] <I>name</I> [<I>name</I> ...]<DD> 10806With no options, 10807indicate how each 10808<I>name</I> 10809 10810would be interpreted if used as a command name. 10811If the 10812<B>-t</B> 10813 10814option is used, 10815<B>type</B> 10816 10817prints a string which is one of 10818<I>alias</I>, 10819 10820<I>keyword</I>, 10821 10822<I>function</I>, 10823 10824<I>builtin</I>, 10825 10826or 10827<I>file </I> 10828 10829if 10830<I>name</I> 10831 10832is an alias, shell reserved word, function, builtin, or disk file, 10833respectively. 10834If the 10835<I>name</I> 10836 10837is not found, then nothing is printed, and an exit status of false 10838is returned. 10839If the 10840<B>-p</B> 10841 10842option is used, 10843<B>type</B> 10844 10845either returns the name of the disk file 10846that would be executed if 10847<I>name</I> 10848 10849were specified as a command name, 10850or nothing if 10851<TT>type -t name</TT> 10852 10853would not return 10854<I>file</I>. 10855 10856The 10857<B>-P</B> 10858 10859option forces a 10860<FONT SIZE=-1><B>PATH</B> 10861 10862</FONT> 10863search for each <I>name</I>, even if 10864<TT>type -t name</TT> 10865 10866would not return 10867<I>file</I>. 10868 10869If a command is hashed, 10870<B>-p</B> 10871 10872and 10873<B>-P</B> 10874 10875print the hashed value, not necessarily the file that appears 10876first in 10877<FONT SIZE=-1><B>PATH</B>. 10878 10879</FONT> 10880If the 10881<B>-a</B> 10882 10883option is used, 10884<B>type</B> 10885 10886prints all of the places that contain 10887an executable named 10888<I>name</I>. 10889 10890This includes aliases and functions, 10891if and only if the 10892<B>-p</B> 10893 10894option is not also used. 10895The table of hashed commands is not consulted 10896when using 10897<B>-a</B>. 10898 10899The 10900<B>-f</B> 10901 10902option suppresses shell function lookup, as with the <B>command</B> builtin. 10903<B>type</B> 10904 10905returns true if any of the arguments are found, false if 10906none are found. 10907<DT><B>ulimit</B> [<B>-SHacdflmnpstuv</B> [<I>limit</I>]]<DD> 10908Provides control over the resources available to the shell and to 10909processes started by it, on systems that allow such control. 10910The <B>-H</B> and <B>-S</B> options specify that the hard or soft limit is 10911set for the given resource. A hard limit cannot be increased once it 10912is set; a soft limit may be increased up to the value of the hard limit. 10913If neither <B>-H</B> nor <B>-S</B> is specified, both the soft and hard 10914limits are set. 10915The value of 10916<I>limit</I> 10917 10918can be a number in the unit specified for the resource 10919or one of the special values 10920<B>hard</B>, 10921 10922<B>soft</B>, 10923 10924or 10925<B>unlimited</B>, 10926 10927which stand for the current hard limit, the current soft limit, and 10928no limit, respectively. 10929If 10930<I>limit</I> 10931 10932is omitted, the current value of the soft limit of the resource is 10933printed, unless the <B>-H</B> option is given. When more than one 10934resource is specified, the limit name and unit are printed before the value. 10935Other options are interpreted as follows: 10936<DL COMPACT><DT><DD> 10937 10938<DL COMPACT> 10939<DT><B>-a</B> 10940 10941<DD> 10942All current limits are reported 10943<DT><B>-c</B> 10944 10945<DD> 10946The maximum size of core files created 10947<DT><B>-d</B> 10948 10949<DD> 10950The maximum size of a process's data segment 10951<DT><B>-f</B> 10952 10953<DD> 10954The maximum size of files created by the shell 10955<DT><B>-l</B> 10956 10957<DD> 10958The maximum size that may be locked into memory 10959<DT><B>-m</B> 10960 10961<DD> 10962The maximum resident set size 10963<DT><B>-n</B> 10964 10965<DD> 10966The maximum number of open file descriptors (most systems do not 10967allow this value to be set) 10968<DT><B>-p</B> 10969 10970<DD> 10971The pipe size in 512-byte blocks (this may not be set) 10972<DT><B>-s</B> 10973 10974<DD> 10975The maximum stack size 10976<DT><B>-t</B> 10977 10978<DD> 10979The maximum amount of cpu time in seconds 10980<DT><B>-u</B> 10981 10982<DD> 10983The maximum number of processes available to a single user 10984<DT><B>-v</B> 10985 10986<DD> 10987The maximum amount of virtual memory available to the shell 10988 10989</DL> 10990<P> 10991 10992If 10993<I>limit</I> 10994 10995is given, it is the new value of the specified resource (the 10996<B>-a</B> 10997 10998option is display only). 10999If no option is given, then 11000<B>-f</B> 11001 11002is assumed. Values are in 1024-byte increments, except for 11003<B>-t</B>, 11004 11005which is in seconds, 11006<B>-p</B>, 11007 11008which is in units of 512-byte blocks, 11009and 11010<B>-n</B> 11011 11012and 11013<B>-u</B>, 11014 11015which are unscaled values. 11016The return status is 0 unless an invalid option or argument is supplied, 11017or an error occurs while setting a new limit. 11018</DL> 11019 11020<DT><B>umask</B> [<B>-p</B>] [<B>-S</B>] [<I>mode</I>]<DD> 11021The user file-creation mask is set to 11022<I>mode</I>. 11023 11024If 11025<I>mode</I> 11026 11027begins with a digit, it 11028is interpreted as an octal number; otherwise 11029it is interpreted as a symbolic mode mask similar 11030to that accepted by 11031<I>chmod</I>(1). 11032 11033If 11034<I>mode</I> 11035 11036is omitted, the current value of the mask is printed. 11037The 11038<B>-S</B> 11039 11040option causes the mask to be printed in symbolic form; the 11041default output is an octal number. 11042If the 11043<B>-p</B> 11044 11045option is supplied, and 11046<I>mode</I> 11047 11048is omitted, the output is in a form that may be reused as input. 11049The return status is 0 if the mode was successfully changed or if 11050no <I>mode</I> argument was supplied, and false otherwise. 11051<DT><B>unalias</B> [-<B>a</B>] [<I>name</I> ...]<DD> 11052Remove each <I>name</I> from the list of defined aliases. If 11053<B>-a</B> 11054 11055is supplied, all alias definitions are removed. The return 11056value is true unless a supplied 11057<I>name</I> 11058 11059is not a defined alias. 11060<DT><B>unset</B> [-<B>fv</B>] [<I>name</I> ...]<DD> 11061For each 11062<I>name</I>, 11063 11064remove the corresponding variable or function. 11065If no options are supplied, or the 11066<B>-v</B> 11067 11068option is given, each 11069<I>name</I> 11070 11071refers to a shell variable. 11072Read-only variables may not be unset. 11073If 11074<B>-f</B> 11075 11076is specified, each 11077<I>name</I> 11078 11079refers to a shell function, and the function definition 11080is removed. 11081Each unset variable or function is removed from the environment 11082passed to subsequent commands. 11083If any of 11084<FONT SIZE=-1><B>RANDOM</B>, 11085 11086</FONT> 11087<FONT SIZE=-1><B>SECONDS</B>, 11088 11089</FONT> 11090<FONT SIZE=-1><B>LINENO</B>, 11091 11092</FONT> 11093<FONT SIZE=-1><B>HISTCMD</B>, 11094 11095</FONT> 11096<FONT SIZE=-1><B>FUNCNAME</B>, 11097 11098</FONT> 11099<FONT SIZE=-1><B>GROUPS</B>, 11100 11101</FONT> 11102or 11103<FONT SIZE=-1><B>DIRSTACK</B> 11104 11105</FONT> 11106are unset, they lose their special properties, even if they are 11107subsequently reset. The exit status is true unless a 11108<I>name</I> 11109 11110is readonly. 11111<DT><B>wait</B> [<I>n ...</I>]<DD> 11112Wait for each specified process and return its termination status. 11113Each 11114<I>n</I> 11115 11116may be a process 11117ID or a job specification; if a job spec is given, all processes 11118in that job's pipeline are waited for. If 11119<I>n</I> 11120 11121is not given, all currently active child processes 11122are waited for, and the return status is zero. If 11123<I>n</I> 11124 11125specifies a non-existent process or job, the return status is 11126127. Otherwise, the return status is the exit status of the last 11127process or job waited for. 11128 11129 11130</DL> 11131<A NAME="lbDA"> </A> 11132<H3>RESTRICTED SHELL</H3> 11133 11134 11135 11136<P> 11137 11138If 11139<B>bash</B> 11140 11141is started with the name 11142<B>rbash</B>, 11143 11144or the 11145<B>-r</B> 11146 11147option is supplied at invocation, 11148the shell becomes restricted. 11149A restricted shell is used to 11150set up an environment more controlled than the standard shell. 11151It behaves identically to 11152<B>bash</B> 11153 11154with the exception that the following are disallowed or not performed: 11155<DL COMPACT> 11156<DT>*<DD> 11157changing directories with <B>cd</B> 11158<DT>*<DD> 11159setting or unsetting the values of 11160<B>SHELL</B>, 11161 11162<B>PATH</B>, 11163 11164<B>ENV</B>, 11165 11166or 11167<B>BASH_ENV</B> 11168 11169<DT>*<DD> 11170specifying command names containing 11171<B>/</B> 11172 11173<DT>*<DD> 11174specifying a file name containing a 11175<B>/</B> 11176 11177as an argument to the 11178<B>.</B> 11179 11180builtin command 11181<DT>*<DD> 11182Specifying a filename containing a slash as an argument to the 11183<B>-p</B> 11184 11185option to the 11186<B>hash</B> 11187 11188builtin command 11189<DT>*<DD> 11190importing function definitions from the shell environment at startup 11191<DT>*<DD> 11192parsing the value of <B>SHELLOPTS</B> from the shell environment at startup 11193<DT>*<DD> 11194redirecting output using the >, >|, <>, >&, &>, and >> redirection operators 11195<DT>*<DD> 11196using the 11197<B>exec</B> 11198 11199builtin command to replace the shell with another command 11200<DT>*<DD> 11201adding or deleting builtin commands with the 11202<B>-f</B> 11203 11204and 11205<B>-d</B> 11206 11207options to the 11208<B>enable</B> 11209 11210builtin command 11211<DT>*<DD> 11212Using the <B>enable</B> builtin command to enable disabled shell builtins 11213<DT>*<DD> 11214specifying the 11215<B>-p</B> 11216 11217option to the 11218<B>command</B> 11219 11220builtin command 11221<DT>*<DD> 11222turning off restricted mode with 11223<B>set +r</B> or <B>set +o restricted</B>. 11224</DL> 11225<P> 11226 11227These restrictions are enforced after any startup files are read. 11228<P> 11229 11230 11231 When a command that is found to be a shell script is executed 11232(see 11233<FONT SIZE=-1><B>COMMAND EXECUTION</B> 11234 11235</FONT> 11236 11237above), 11238 11239<B>rbash</B> 11240 11241turns off any restrictions in the shell spawned to execute the 11242script. 11243 11244 11245<A NAME="lbDB"> </A> 11246<H3>SEE ALSO</H3> 11247 11248 11249<DL COMPACT> 11250<DT><I>Bash Reference Manual</I>, Brian Fox and Chet Ramey<DD> 11251<DT><I>The Gnu Readline Library</I>, Brian Fox and Chet Ramey<DD> 11252<DT><I>The Gnu History Library</I>, Brian Fox and Chet Ramey<DD> 11253<DT><I>Portable Operating System Interface (POSIX) Part 2: Shell and Utilities</I>, IEEE<DD> 11254<DT><I>sh</I>(1), <I>ksh</I>(1), <I>csh</I>(1)<DD> 11255<DT><I>emacs</I>(1), <I>vi</I>(1)<DD> 11256<DT><I>readline</I>(3)<DD> 11257 11258</DL> 11259<A NAME="lbDC"> </A> 11260<H3>FILES</H3> 11261 11262 11263<DL COMPACT> 11264<DT> 11265<A HREF="file:/bin/bash"><I>/bin/bash</I></A> 11266 11267<DD> 11268The <B>bash</B> executable 11269<DT> 11270<A HREF="file:/etc/profile"><I>/etc/profile</I></A> 11271 11272<DD> 11273The systemwide initialization file, executed for login shells 11274<DT> 11275<A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A> 11276 11277<DD> 11278The personal initialization file, executed for login shells 11279<DT> 11280<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A> 11281 11282<DD> 11283The individual per-interactive-shell startup file 11284<DT> 11285<A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A> 11286 11287<DD> 11288The individual login shell cleanup file, executed when a login shell exits 11289<DT> 11290<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A> 11291 11292<DD> 11293Individual <I>readline</I> initialization file 11294 11295</DL> 11296<A NAME="lbDD"> </A> 11297<H3>AUTHORS</H3> 11298 11299Brian Fox, Free Software Foundation 11300<BR> 11301 11302<A HREF="mailto:bfox@gnu.org">bfox@gnu.org</A> 11303<P> 11304 11305Chet Ramey, Case Western Reserve University 11306<BR> 11307 11308<A HREF="mailto:chet@po.cwru.edu">chet@po.cwru.edu</A> 11309<A NAME="lbDE"> </A> 11310<H3>BUG REPORTS</H3> 11311 11312If you find a bug in 11313<B>bash,</B> 11314 11315you should report it. But first, you should 11316make sure that it really is a bug, and that it appears in the latest 11317version of 11318<B>bash</B>. 11319 11320The latest version is always available from 11321<I><A HREF="ftp://ftp.gnu.org/pub/bash/">ftp://ftp.gnu.org/pub/bash/</A></I>. 11322<P> 11323 11324Once you have determined that a bug actually exists, use the 11325<I>bashbug</I> 11326 11327command to submit a bug report. 11328If you have a fix, you are encouraged to mail that as well! 11329Suggestions and `philosophical' bug reports may be mailed 11330to <I><A HREF="mailto:bug-bash@gnu.org">bug-bash@gnu.org</A></I> or posted to the Usenet 11331newsgroup 11332<A HREF="news:gnu.bash.bug">gnu.bash.bug</A>. 11333 11334<P> 11335 11336ALL bug reports should include: 11337<P> 11338 11339 11340<DL COMPACT> 11341<DT>The version number of <B>bash</B><DD> 11342<DT>The hardware and operating system<DD> 11343<DT>The compiler used to compile<DD> 11344<DT>A description of the bug behaviour<DD> 11345<DT>A short script or `recipe' which exercises the bug<DD> 11346 11347</DL> 11348<P> 11349 11350<I>bashbug</I> 11351 11352inserts the first three items automatically into the template 11353it provides for filing a bug report. 11354<P> 11355 11356Comments and bug reports concerning 11357this manual page should be directed to 11358<I><A HREF="mailto:chet@po.cwru.edu">chet@po.cwru.edu</A></I>. 11359 11360<A NAME="lbDF"> </A> 11361<H3>BUGS</H3> 11362 11363<P> 11364 11365It's too big and too slow. 11366<P> 11367 11368There are some subtle differences between 11369<B>bash</B> 11370 11371and traditional versions of 11372<B>sh</B>, 11373 11374mostly because of the 11375<FONT SIZE=-1><B>POSIX</B> 11376 11377</FONT> 11378specification. 11379<P> 11380 11381Aliases are confusing in some uses. 11382<P> 11383 11384Shell builtin commands and functions are not stoppable/restartable. 11385<P> 11386 11387Compound commands and command sequences of the form `a ; b ; c' 11388are not handled gracefully when process suspension is attempted. 11389When a process is stopped, the shell immediately executes the next 11390command in the sequence. 11391It suffices to place the sequence of commands between 11392parentheses to force it into a subshell, which may be stopped as 11393a unit. 11394<P> 11395 11396Commands inside of <B>$(</B>...<B>)</B> command substitution are not 11397parsed until substitution is attempted. This will delay error 11398reporting until some time after the command is entered. For example, 11399unmatched parentheses, even inside shell comments, will result in 11400error messages while the construct is being read. 11401<P> 11402 11403Array variables may not (yet) be exported. 11404 11405 11406 11407<HR> 11408<TABLE WIDTH=100%> 11409<TR> 11410<TH ALIGN=LEFT width=33%>GNU Bash-3.1-beta1<TH ALIGN=CENTER width=33%>2005 Aug 27<TH ALIGN=RIGHT width=33%>BASH(1) 11411</TR> 11412</TABLE> 11413<HR> 11414<A NAME="index"> </A><H2>Index</H2> 11415<DL> 11416<DT><A HREF="#lbAB">NAME</A><DD> 11417<DT><A HREF="#lbAC">SYNOPSIS</A><DD> 11418<DT><A HREF="#lbAD">COPYRIGHT</A><DD> 11419<DT><A HREF="#lbAE">DESCRIPTION</A><DD> 11420<DT><A HREF="#lbAF">OPTIONS</A><DD> 11421<DT><A HREF="#lbAG">ARGUMENTS</A><DD> 11422<DT><A HREF="#lbAH">INVOCATION</A><DD> 11423<DT><A HREF="#lbAI">DEFINITIONS</A><DD> 11424<DT><A HREF="#lbAJ">RESERVED WORDS</A><DD> 11425<DT><A HREF="#lbAK">SHELL GRAMMAR</A><DD> 11426<DL> 11427<DT><A HREF="#lbAL">Simple Commands</A><DD> 11428<DT><A HREF="#lbAM">Pipelines</A><DD> 11429<DT><A HREF="#lbAN">Lists</A><DD> 11430<DT><A HREF="#lbAO">Compound Commands</A><DD> 11431<DT><A HREF="#lbAP">Shell Function Definitions</A><DD> 11432</DL> 11433<DT><A HREF="#lbAQ">COMMENTS</A><DD> 11434<DT><A HREF="#lbAR">QUOTING</A><DD> 11435<DT><A HREF="#lbAS">PARAMETERS</A><DD> 11436<DL> 11437<DT><A HREF="#lbAT">Positional Parameters</A><DD> 11438<DT><A HREF="#lbAU">Special Parameters</A><DD> 11439<DT><A HREF="#lbAV">Shell Variables</A><DD> 11440<DT><A HREF="#lbAW">Arrays</A><DD> 11441</DL> 11442<DT><A HREF="#lbAX">EXPANSION</A><DD> 11443<DL> 11444<DT><A HREF="#lbAY">Brace Expansion</A><DD> 11445<DT><A HREF="#lbAZ">Tilde Expansion</A><DD> 11446<DT><A HREF="#lbBA">Parameter Expansion</A><DD> 11447<DT><A HREF="#lbBB">Command Substitution</A><DD> 11448<DT><A HREF="#lbBC">Arithmetic Expansion</A><DD> 11449<DT><A HREF="#lbBD">Process Substitution</A><DD> 11450<DT><A HREF="#lbBE">Word Splitting</A><DD> 11451<DT><A HREF="#lbBF">Pathname Expansion</A><DD> 11452<DT><A HREF="#lbBG">Quote Removal</A><DD> 11453</DL> 11454<DT><A HREF="#lbBH">REDIRECTION</A><DD> 11455<DL> 11456<DT><A HREF="#lbBI">Redirecting Input</A><DD> 11457<DT><A HREF="#lbBJ">Redirecting Output</A><DD> 11458<DT><A HREF="#lbBK">Appending Redirected Output</A><DD> 11459<DT><A HREF="#lbBL">Redirecting Standard Output and Standard Error</A><DD> 11460<DT><A HREF="#lbBM">Here Documents</A><DD> 11461<DT><A HREF="#lbBN">Here Strings</A><DD> 11462<DT><A HREF="#lbBO">Duplicating File Descriptors</A><DD> 11463<DT><A HREF="#lbBP">Moving File Descriptors</A><DD> 11464<DT><A HREF="#lbBQ">Opening File Descriptors for Reading and Writing</A><DD> 11465</DL> 11466<DT><A HREF="#lbBR">ALIASES</A><DD> 11467<DT><A HREF="#lbBS">FUNCTIONS</A><DD> 11468<DT><A HREF="#lbBT">ARITHMETIC EVALUATION</A><DD> 11469<DT><A HREF="#lbBU">CONDITIONAL EXPRESSIONS</A><DD> 11470<DT><A HREF="#lbBV">SIMPLE COMMAND EXPANSION</A><DD> 11471<DT><A HREF="#lbBW">COMMAND EXECUTION</A><DD> 11472<DT><A HREF="#lbBX">COMMAND EXECUTION ENVIRONMENT</A><DD> 11473<DT><A HREF="#lbBY">ENVIRONMENT</A><DD> 11474<DT><A HREF="#lbBZ">EXIT STATUS</A><DD> 11475<DT><A HREF="#lbCA">SIGNALS</A><DD> 11476<DT><A HREF="#lbCB">JOB CONTROL</A><DD> 11477<DT><A HREF="#lbCC">PROMPTING</A><DD> 11478<DT><A HREF="#lbCD">READLINE</A><DD> 11479<DL> 11480<DT><A HREF="#lbCE">Readline Notation</A><DD> 11481<DT><A HREF="#lbCF">Readline Initialization</A><DD> 11482<DT><A HREF="#lbCG">Readline Key Bindings</A><DD> 11483<DT><A HREF="#lbCH">Readline Variables</A><DD> 11484<DT><A HREF="#lbCI">Readline Conditional Constructs</A><DD> 11485<DT><A HREF="#lbCJ">Searching</A><DD> 11486<DT><A HREF="#lbCK">Readline Command Names</A><DD> 11487<DT><A HREF="#lbCL">Commands for Moving</A><DD> 11488<DT><A HREF="#lbCM">Commands for Manipulating the History</A><DD> 11489<DT><A HREF="#lbCN">Commands for Changing Text</A><DD> 11490<DT><A HREF="#lbCO">Killing and Yanking</A><DD> 11491<DT><A HREF="#lbCP">Numeric Arguments</A><DD> 11492<DT><A HREF="#lbCQ">Completing</A><DD> 11493<DT><A HREF="#lbCR">Keyboard Macros</A><DD> 11494<DT><A HREF="#lbCS">Miscellaneous</A><DD> 11495<DT><A HREF="#lbCT">Programmable Completion</A><DD> 11496</DL> 11497<DT><A HREF="#lbCU">HISTORY</A><DD> 11498<DT><A HREF="#lbCV">HISTORY EXPANSION</A><DD> 11499<DL> 11500<DT><A HREF="#lbCW">Event Designators</A><DD> 11501<DT><A HREF="#lbCX">Word Designators</A><DD> 11502<DT><A HREF="#lbCY">Modifiers</A><DD> 11503</DL> 11504<DT><A HREF="#lbCZ">SHELL BUILTIN COMMANDS</A><DD> 11505<DT><A HREF="#lbDA">RESTRICTED SHELL</A><DD> 11506<DT><A HREF="#lbDB">SEE ALSO</A><DD> 11507<DT><A HREF="#lbDC">FILES</A><DD> 11508<DT><A HREF="#lbDD">AUTHORS</A><DD> 11509<DT><A HREF="#lbDE">BUG REPORTS</A><DD> 11510<DT><A HREF="#lbDF">BUGS</A><DD> 11511</DL> 11512<HR> 11513This document was created by man2html from bash.1.<BR> 11514Time: 12 October 2005 16:46:47 EDT 11515</BODY> 11516</HTML> 11517