]> git.ipfire.org Git - thirdparty/bash.git/blame - doc/bash.html
Imported from ../bash-4.0.tar.gz.
[thirdparty/bash.git] / doc / bash.html
CommitLineData
17345e5a
JA
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%>2008 December 29<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">&nbsp;</A>
31<H3>NAME</H3>
32
33bash - GNU Bourne-Again SHell
34<A NAME="lbAC">&nbsp;</A>
35<H3>SYNOPSIS</H3>
36
37<B>bash</B>
38
39[options]
40[file]
41<A NAME="lbAD">&nbsp;</A>
42<H3>COPYRIGHT</H3>
43
44
45Bash is Copyright &#169; 1989-2009 by the Free Software Foundation, Inc.
46<A NAME="lbAE">&nbsp;</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
62Shell and Utilities portion of the IEEE POSIX specification
63(IEEE Standard 1003.1).
64<B>Bash</B>
65
66can be configured to be POSIX-conformant by default.
67<A NAME="lbAF">&nbsp;</A>
68<H3>OPTIONS</H3>
69
70In addition to the single-character shell options documented in the
71description of the <B>set</B> builtin command, <B>bash</B>
72interprets the following options when it is invoked:
73<P>
74
75
76<DL COMPACT>
77<DT><B>-c</B><I> string</I>
78
79<DD>
80If the
81<B>-c</B>
82
83option is present, then commands are read from
84<I>string</I>.
85
86If there are arguments after the
87<I>string</I>,
88
89they are assigned to the positional parameters, starting with
90<B>$0</B>.
91
92<DT><B>-i</B>
93
94<DD>
95If the
96<B>-i</B>
97
98option is present, the shell is
99<I>interactive</I>.
100
101<DT><B>-l</B>
102
103<DD>
104Make
105<B>bash</B>
106
107act as if it had been invoked as a login shell (see
108<FONT SIZE=-1><B>INVOCATION</B>
109
110</FONT>
111below).
112<DT><B>-r</B>
113
114<DD>
115If the
116<B>-r</B>
117
118option is present, the shell becomes
119<I>restricted</I>
120
121(see
122<FONT SIZE=-1><B>RESTRICTED SHELL</B>
123
124</FONT>
125below).
126<DT><B>-s</B>
127
128<DD>
129If the
130<B>-s</B>
131
132option is present, or if no arguments remain after option
133processing, then commands are read from the standard input.
134This option allows the positional parameters to be set
135when invoking an interactive shell.
136<DT><B>-D</B>
137
138<DD>
139A list of all double-quoted strings preceded by <B>$</B>
140is printed on the standard output.
141These are the strings that
142are subject to language translation when the current locale
143is not <B>C</B> or <B>POSIX</B>.
144This implies the <B>-n</B> option; no commands will be executed.
145<DT><B>[-+]O [</B><I>shopt_option</I>]
146
147<DD>
148<I>shopt_option</I> is one of the shell options accepted by the
149<B>shopt</B> builtin (see
150<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
151
152</FONT>
153below).
154If <I>shopt_option</I> is present, <B>-O</B> sets the value of that option;
155<B>+O</B> unsets it.
156If <I>shopt_option</I> is not supplied, the names and values of the shell
157options accepted by <B>shopt</B> are printed on the standard output.
158If the invocation option is <B>+O</B>, the output is displayed in a format
159that may be reused as input.
160<DT><B>--</B>
161
162<DD>
163A
164<B>--</B>
165
166signals the end of options and disables further option processing.
167Any arguments after the
168<B>--</B>
169
170are treated as filenames and arguments. An argument of
171<B>-</B>
172
173is equivalent to <B>--</B>.
174
175</DL>
176<P>
177
178<B>Bash</B>
179
180also interprets a number of multi-character options.
181These options must appear on the command line before the
182single-character options to be recognized.
183<P>
184
185
186<DL COMPACT>
187<DT><B>--debugger</B>
188
189<DD>
190Arrange for the debugger profile to be executed before the shell
191starts.
192Turns on extended debugging mode (see the description of the
193<B>extdebug</B>
194
195option to the
196<B>shopt</B>
197
198builtin below)
199and shell function tracing (see the description of the
200<B>-o functrace</B> option to the
201<B>set</B>
202
203builtin below).
204<DT><B>--dump-po-strings</B>
205
206<DD>
207Equivalent to <B>-D</B>, but the output is in the GNU <I>gettext</I>
208<B>po</B> (portable object) file format.
209<DT><B>--dump-strings</B>
210
211<DD>
212Equivalent to <B>-D</B>.
213<DT><B>--help</B>
214
215<DD>
216Display a usage message on standard output and exit successfully.
217<DT><B>--init-file</B> <I>file</I><DD>
218
219<DT><B>--rcfile</B> <I>file</I><DD>
220
221Execute commands from
222<I>file</I>
223
224instead of the standard personal initialization file
225<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
226
227if the shell is interactive (see
228<FONT SIZE=-1><B>INVOCATION</B>
229
230</FONT>
231below).
232<DT><B>--login</B>
233
234<DD>
235Equivalent to <B>-l</B>.
236<DT><B>--noediting</B>
237
238<DD>
239Do not use the GNU
240<B>readline</B>
241
242library to read command lines when the shell is interactive.
243<DT><B>--noprofile</B>
244
245<DD>
246Do not read either the system-wide startup file
247
248<A HREF="file:/etc/profile"><I>/etc/profile</I></A>
249
250or any of the personal initialization files
251<A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>,
252
253<A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>,
254
255or
256<A HREF="file:~/.profile"><I>~/.profile</I></A>.
257
258By default,
259<B>bash</B>
260
261reads these files when it is invoked as a login shell (see
262<FONT SIZE=-1><B>INVOCATION</B>
263
264</FONT>
265below).
266<DT><B>--norc</B>
267
268<DD>
269Do not read and execute the personal initialization file
270<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
271
272if the shell is interactive.
273This option is on by default if the shell is invoked as
274<B>sh</B>.
275
276<DT><B>--posix</B>
277
278<DD>
279Change the behavior of <B>bash</B> where the default operation differs
280from the POSIX standard to match the standard (<I>posix mode</I>).
281<DT><B>--restricted</B>
282
283<DD>
284The shell becomes restricted (see
285<FONT SIZE=-1><B>RESTRICTED SHELL</B>
286
287</FONT>
288below).
289<DT><B>--verbose</B>
290
291<DD>
292Equivalent to <B>-v</B>.
293<DT><B>--version</B>
294
295<DD>
296Show version information for this instance of
297<B>bash</B>
298
299on the standard output and exit successfully.
300
301</DL>
302<A NAME="lbAG">&nbsp;</A>
303<H3>ARGUMENTS</H3>
304
305If arguments remain after option processing, and neither the
306<B>-c</B>
307
308nor the
309<B>-s</B>
310
311option has been supplied, the first argument is assumed to
312be the name of a file containing shell commands.
313If
314<B>bash</B>
315
316is invoked in this fashion,
317<B>$0</B>
318
319is set to the name of the file, and the positional parameters
320are set to the remaining arguments.
321<B>Bash</B>
322
323reads and executes commands from this file, then exits.
324<B>Bash</B>'s exit status is the exit status of the last command
325executed in the script.
326If no commands are executed, the exit status is 0.
327An attempt is first made to open the file in the current directory, and,
328if no file is found, then the shell searches the directories in
329<FONT SIZE=-1><B>PATH</B>
330
331</FONT>
332for the script.
333<A NAME="lbAH">&nbsp;</A>
334<H3>INVOCATION</H3>
335
336A <I>login shell</I> is one whose first character of argument zero is a
337<B>-</B>,
338
339or one started with the
340<B>--login</B>
341
342option.
343<P>
344
345An <I>interactive</I> shell is one started without non-option arguments
346and without the
347<B>-c</B>
348
349option
350whose standard input and error are
351both connected to terminals (as determined by
352<I>isatty</I>(3)),
353
354or one started with the
355<B>-i</B>
356
357option.
358<FONT SIZE=-1><B>PS1</B>
359
360</FONT>
361is set and
362<B>$-</B>
363
364includes
365<B>i</B>
366
367if
368<B>bash</B>
369
370is interactive,
371allowing a shell script or a startup file to test this state.
372<P>
373
374The following paragraphs describe how
375<B>bash</B>
376
377executes its startup files.
378If any of the files exist but cannot be read,
379<B>bash</B>
380
381reports an error.
382Tildes are expanded in file names as described below under
383<B>Tilde Expansion</B>
384
385in the
386<FONT SIZE=-1><B>EXPANSION</B>
387
388</FONT>
389section.
390<P>
391
392When
393<B>bash</B>
394
395is invoked as an interactive login shell, or as a non-interactive shell
396with the <B>--login</B> option, it first reads and
397executes commands from the file <A HREF="file:/etc/profile"><I>/etc/profile</I></A>, if that
398file exists.
399After reading that file, it looks for <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>,
400<A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>, and <A HREF="file:~/.profile"><I>~/.profile</I></A>, in that order, and reads
401and executes commands from the first one that exists and is readable.
402The
403<B>--noprofile</B>
404
405option may be used when the shell is started to inhibit this behavior.
406<P>
407
408When a login shell exits,
409<B>bash</B>
410
411reads and executes commands from the file <A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>, if it
412exists.
413<P>
414
415When an interactive shell that is not a login shell is started,
416<B>bash</B>
417
418reads and executes commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists.
419This may be inhibited by using the
420<B>--norc</B>
421
422option.
423The <B>--rcfile</B> <I>file</I> option will force
424<B>bash</B>
425
426to read and execute commands from <I>file</I> instead of <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
427<P>
428
429When
430<B>bash</B>
431
432is started non-interactively, to run a shell script, for example, it
433looks for the variable
434<FONT SIZE=-1><B>BASH_ENV</B>
435
436</FONT>
437in the environment, expands its value if it appears there, and uses the
438expanded value as the name of a file to read and execute.
439<B>Bash</B>
440
441behaves as if the following command were executed:
442<P>
443<DL COMPACT><DT><DD>
444<TT>if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi</TT>
445
446</DL>
447
448<P>
449but the value of the
450<FONT SIZE=-1><B>PATH</B>
451
452</FONT>
453variable is not used to search for the file name.
454<P>
455
456If
457<B>bash</B>
458
459is invoked with the name
460<B>sh</B>,
461
462it tries to mimic the startup behavior of historical versions of
463<B>sh</B>
464
465as closely as possible,
466while conforming to the POSIX standard as well.
467When invoked as an interactive login shell, or a non-interactive
468shell with the <B>--login</B> option, it first attempts to
469read and execute commands from
470<A HREF="file:/etc/profile"><I>/etc/profile</I></A>
471
472and
473<A HREF="file:~/.profile"><I>~/.profile</I></A>,
474
475in that order.
476The
477<B>--noprofile</B>
478
479option may be used to inhibit this behavior.
480When invoked as an interactive shell with the name
481<B>sh</B>,
482
483<B>bash</B>
484
485looks for the variable
486<FONT SIZE=-1><B>ENV</B>,
487
488</FONT>
489expands its value if it is defined, and uses the
490expanded value as the name of a file to read and execute.
491Since a shell invoked as
492<B>sh</B>
493
494does not attempt to read and execute commands from any other startup
495files, the
496<B>--rcfile</B>
497
498option has no effect.
499A non-interactive shell invoked with the name
500<B>sh</B>
501
502does not attempt to read any other startup files.
503When invoked as
504<B>sh</B>,
505
506<B>bash</B>
507
508enters
509<I>posix</I>
510
511mode after the startup files are read.
512<P>
513
514When
515<B>bash</B>
516
517is started in
518<I>posix</I>
519
520mode, as with the
521<B>--posix</B>
522
523command line option, it follows the POSIX standard for startup files.
524In this mode, interactive shells expand the
525<FONT SIZE=-1><B>ENV</B>
526
527</FONT>
528variable and commands are read and executed from the file
529whose name is the expanded value.
530No other startup files are read.
531<P>
532
533<B>Bash</B>
534
535attempts to determine when it is being run with its standard input
536connected to a a network connection, as if by the remote shell
537daemon, usually <I>rshd</I>, or the secure shell daemon <I>sshd</I>.
538If
539<B>bash</B>
540
541determines it is being run in this fashion, it reads and executes
542commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists and is readable.
543It will not do this if invoked as <B>sh</B>.
544The
545<B>--norc</B>
546
547option may be used to inhibit this behavior, and the
548<B>--rcfile</B>
549
550option may be used to force another file to be read, but
551<I>rshd</I> does not generally invoke the shell with those options
552or allow them to be specified.
553<P>
554
555If the shell is started with the effective user (group) id not equal to the
556real user (group) id, and the <B>-p</B> option is not supplied, no startup
557files are read, shell functions are not inherited from the environment, the
558<FONT SIZE=-1><B>SHELLOPTS</B>
559
560</FONT>
561variable, if it appears in the environment, is ignored,
562and the effective user id is set to the real user id.
563If the <B>-p</B> option is supplied at invocation, the startup behavior is
564the same, but the effective user id is not reset.
565<A NAME="lbAI">&nbsp;</A>
566<H3>DEFINITIONS</H3>
567
568<P>
569
570The following definitions are used throughout the rest of this
571document.
572
573<DL COMPACT>
574<DT><B>blank </B>
575
576<DD>
577A space or tab.
578<DT><B>word</B>
579
580<DD>
581A sequence of characters considered as a single unit by the shell.
582Also known as a
583<B>token</B>.
584
585<DT><B>name</B>
586
587<DD>
588A
589<I>word</I>
590
591consisting only of alphanumeric characters and underscores, and
592beginning with an alphabetic character or an underscore. Also
593referred to as an
594<B>identifier</B>.
595
596<DT><B>metacharacter</B>
597
598<DD>
599A character that, when unquoted, separates words. One of the following:
600<BR>
601
602<DL COMPACT><DT><DD>
603<P>
604
605<B>| &amp; ; ( ) &lt; &gt; space tab</B>
606
607</DL>
608
609</DL>
610<P>
611
612<DL COMPACT>
613<DT><B>control operator</B>
614
615<DD>
616A <I>token</I> that performs a control function. It is one of the following
617symbols:
618<DL COMPACT><DT><DD>
619<P>
620
621<B>|| &amp; &amp;&amp; ; ;; ( ) | |&amp; &lt;newline&gt;</B>
622
623</DL>
624
625
626</DL>
627<A NAME="lbAJ">&nbsp;</A>
628<H3>RESERVED WORDS</H3>
629
630<I>Reserved words</I> are words that have a special meaning to the shell.
631The following words are recognized as reserved when unquoted and either
632the first word of a simple command (see
633<FONT SIZE=-1><B>SHELL GRAMMAR</B>
634
635</FONT>
636below) or the third word of a
637<B>case </B>
638
639or
640<B>for</B>
641
642command:
643<DL COMPACT><DT><DD>
644
645<P>
646
647<B>
648</B>
649
650! case do done elif else esac fi for function if in select then until while { } time [[ ]]
651</DL>
652
653
654<A NAME="lbAK">&nbsp;</A>
655<H3>SHELL GRAMMAR</H3>
656
657<A NAME="lbAL">&nbsp;</A>
658<H4>Simple Commands</H4>
659
660<P>
661
662A <I>simple command</I> is a sequence of optional variable assignments
663followed by <B>blank</B>-separated words and redirections, and
664terminated by a <I>control operator</I>. The first word
665specifies the command to be executed, and is passed as argument zero.
666The remaining words are passed as arguments to the invoked command.
667<P>
668
669The return value of a <I>simple command</I> is its exit status, or
670128+<I>n</I> if the command is terminated by signal
671<I>n</I>.
672
673<A NAME="lbAM">&nbsp;</A>
674<H4>Pipelines</H4>
675
676<P>
677
678A <I>pipeline</I> is a sequence of one or more commands separated by
679one of the control operators
680<B>|</B>
681
682or <B>|&amp;</B>.
683The format for a pipeline is:
684<DL COMPACT><DT><DD>
685<P>
686
687[<B>time</B> [<B>-p</B>]] [ ! ] <I>command</I> [ [<B>|</B>|<B>|&amp;</B>] <I>command2</I> ... ]
688</DL>
689
690<P>
691
692The standard output of
693<I>command</I>
694
695is connected via a pipe to the standard input of
696<I>command2</I>.
697
698This connection is performed before any redirections specified by the
699command (see
700<FONT SIZE=-1><B>REDIRECTION</B>
701
702</FONT>
703below).
704If <B>|&amp;</B> is used, the standard error of <I>command</I> is connected to
705<I>command2</I>'s standard input through the pipe; it is shorthand for
706<B>2&gt;&amp;1 |</B>.
707This implicit redirection of the standard error is performed after any
708redirections specified by the command.
709<P>
710
711The return status of a pipeline is the exit status of the last
712command, unless the <B>pipefail</B> option is enabled.
713If <B>pipefail</B> is enabled, the pipeline's return status is the
714value of the last (rightmost) command to exit with a non-zero status,
715or zero if all commands exit successfully.
716If the reserved word
717<B>!</B>
718
719precedes a pipeline, the exit status of that pipeline is the logical
720negation of the exit status as described above.
721The shell waits for all commands in the pipeline to
722terminate before returning a value.
723<P>
724
725If the
726<B>time</B>
727
728reserved word precedes a pipeline, the elapsed as well as user and
729system time consumed by its execution are reported when the pipeline
730terminates.
731The <B>-p</B> option changes the output format to that specified by POSIX.
732The
733<FONT SIZE=-1><B>TIMEFORMAT</B>
734
735</FONT>
736variable may be set to a format string that specifies how the timing
737information should be displayed; see the description of
738<FONT SIZE=-1><B>TIMEFORMAT</B>
739
740</FONT>
741under
742<B>Shell Variables</B>
743
744below.
745<P>
746
747Each command in a pipeline is executed as a separate process (i.e., in a
748subshell).
749<A NAME="lbAN">&nbsp;</A>
750<H4>Lists</H4>
751
752<P>
753
754A <I>list</I> is a sequence of one or more pipelines separated by one
755of the operators
756<B>;</B>,
757
758<B>&amp;</B>,
759
760<B>&amp;&amp;</B>,
761
762or
763<B>||</B>,
764
765and optionally terminated by one of
766<B>;</B>,
767
768<B>&amp;</B>,
769
770or
771<B>&lt;newline&gt;</B>.
772
773<P>
774
775Of these list operators,
776<B>&amp;&amp;</B>
777
778and
779<B>||</B>
780
781have equal precedence, followed by
782<B>;</B>
783
784and
785<B>&amp;</B>,
786
787which have equal precedence.
788<P>
789
790A sequence of one or more newlines may appear in a <I>list</I> instead
791of a semicolon to delimit commands.
792<P>
793
794If a command is terminated by the control operator
795<B>&amp;</B>,
796
797the shell executes the command in the <I>background</I>
798in a subshell. The shell does not wait for the command to
799finish, and the return status is 0. Commands separated by a
800<B>;</B>
801
802are executed sequentially; the shell waits for each
803command to terminate in turn. The return status is the
804exit status of the last command executed.
805<P>
806
807AND and OR lists are sequences of one of more pipelines separated by the
808<B>&amp;&amp;</B> and <B>||</B> control operators, respectively.
809AND and OR lists are executed with left associativity.
810An AND list has the form
811<DL COMPACT><DT><DD>
812<P>
813
814<I>command1</I> <B>&amp;&amp;</B> <I>command2</I>
815</DL>
816
817<P>
818
819<I>command2</I>
820
821is executed if, and only if,
822<I>command1</I>
823
824returns an exit status of zero.
825<P>
826
827An OR list has the form
828<DL COMPACT><DT><DD>
829<P>
830
831<I>command1</I> <B>||</B> <I>command2</I>
832<P>
833
834</DL>
835
836<P>
837
838<I>command2</I>
839
840is executed if and only if
841<I>command1</I>
842
843returns a non-zero exit status.
844The return status of
845AND and OR lists is the exit status of the last command
846executed in the list.
847<A NAME="lbAO">&nbsp;</A>
848<H4>Compound Commands</H4>
849
850<P>
851
852A <I>compound command</I> is one of the following:
853<DL COMPACT>
854<DT>(<I>list</I>)<DD>
855<I>list</I> is executed in a subshell environment (see
856<FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B></FONT>
857below).
858Variable assignments and builtin
859commands that affect the shell's environment do not remain in effect
860after the command completes. The return status is the exit status of
861<I>list</I>.
862<DT>{ <I>list</I>; }<DD>
863<I>list</I> is simply executed in the current shell environment.
864<I>list</I> must be terminated with a newline or semicolon.
865This is known as a <I>group command</I>.
866The return status is the exit status of
867<I>list</I>.
868Note that unlike the metacharacters <B>(</B> and <B>)</B>, <B>{</B> and
869<B>}</B> are <I>reserved words</I> and must occur where a reserved
870word is permitted to be recognized. Since they do not cause a word
871break, they must be separated from <I>list</I> by whitespace or another
872shell metacharacter.
873<DT>((<I>expression</I>))<DD>
874The <I>expression</I> is evaluated according to the rules described
875below under
876<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
877
878</FONT>
879If the value of the expression is non-zero, the return status is 0;
880otherwise the return status is 1. This is exactly equivalent to
881<B>let &quot;</B><I>expression</I>&quot;.
882<DT><B>[[</B> <I>expression</I> <B>]]</B><DD>
883Return a status of 0 or 1 depending on the evaluation of
884the conditional expression <I>expression</I>.
885Expressions are composed of the primaries described below under
886<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
887
888</FONT>
889Word splitting and pathname expansion are not performed on the words
890between the <B>[[</B> and <B>]]</B>; tilde expansion, parameter and
891variable expansion, arithmetic expansion, command substitution, process
892substitution, and quote removal are performed.
893Conditional operators such as <B>-f</B> must be unquoted to be recognized
894as primaries.
895<P>
896
897
898When the <B>==</B> and <B>!=</B> operators are used, the string to the
899right of the operator is considered a pattern and matched according
900to the rules described below under <B>Pattern Matching</B>.
901If the shell option
902<B>nocasematch</B>
903
904is enabled, the match is performed without regard to the case
905of alphabetic characters.
906The return value is 0 if the string matches (<B>==</B>) or does not match
907(<B>!=</B>) the pattern, and 1 otherwise.
908Any part of the pattern may be quoted to force it to be matched as a
909string.
910<P>
911
912
913An additional binary operator, <B>=~</B>, is available, with the same
914precedence as <B>==</B> and <B>!=</B>.
915When it is used, the string to the right of the operator is considered
916an extended regular expression and matched accordingly (as in <I>regex</I>(3)).
917The return value is 0 if the string matches
918the pattern, and 1 otherwise.
919If the regular expression is syntactically incorrect, the conditional
920expression's return value is 2.
921If the shell option
922<B>nocasematch</B>
923
924is enabled, the match is performed without regard to the case
925of alphabetic characters.
926Any part of the pattern may be quoted to force it to be matched as a
927string.
928Substrings matched by parenthesized subexpressions within the regular
929expression are saved in the array variable <B>BASH_REMATCH</B>.
930The element of <B>BASH_REMATCH</B> with index 0 is the portion of the string
931matching the entire regular expression.
932The element of <B>BASH_REMATCH</B> with index <I>n</I> is the portion of the
933string matching the <I>n</I>th parenthesized subexpression.
934<P>
935
936
937Expressions may be combined using the following operators, listed
938in decreasing order of precedence:
939<P>
940
941
942<DL COMPACT><DT><DD>
943
944<DL COMPACT>
945<DT><B>( </B><I>expression</I> )
946
947<DD>
948Returns the value of <I>expression</I>.
949This may be used to override the normal precedence of operators.
950<DT><B>! </B><I>expression</I>
951
952<DD>
953True if
954<I>expression</I>
955
956is false.
957<DT><I>expression1</I> <B>&amp;&amp;</B> <I>expression2</I><DD>
958True if both
959<I>expression1</I>
960
961and
962<I>expression2</I>
963
964are true.
965<DT><I>expression1</I> <B>||</B> <I>expression2</I>
966<DD>
967
968True if either
969<I>expression1</I>
970
971or
972<I>expression2</I>
973
974is true.
975
976</DL>
977<P>
978
979The <B>&amp;&amp;</B> and
980<B>||</B>
981
982operators do not evaluate <I>expression2</I> if the value of
983<I>expression1</I> is sufficient to determine the return value of
984the entire conditional expression.
985</DL>
986
987<DT><B>for</B> <I>name</I> [ <B>in</B> <I>word</I> ] ; <B>do</B> <I>list</I> ; <B>done</B><DD>
988The list of words following <B>in</B> is expanded, generating a list
989of items.
990The variable <I>name</I> is set to each element of this list
991in turn, and <I>list</I> is executed each time.
992If the <B>in</B> <I>word</I> is omitted, the <B>for</B> command executes
993<I>list</I> once for each positional parameter that is set (see
994<FONT SIZE=-1><B>PARAMETERS</B>
995
996</FONT>
997below).
998The return status is the exit status of the last command that executes.
999If the expansion of the items following <B>in</B> results in an empty
1000list, no commands are executed, and the return status is 0.
1001<DT><B>for</B> (( <I>expr1</I> ; <I>expr2</I> ; <I>expr3</I> )) ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1002First, the arithmetic expression <I>expr1</I> is evaluated according
1003to the rules described below under
1004<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
1005
1006</FONT>
1007The arithmetic expression <I>expr2</I> is then evaluated repeatedly
1008until it evaluates to zero.
1009Each time <I>expr2</I> evaluates to a non-zero value, <I>list</I> is
1010executed and the arithmetic expression <I>expr3</I> is evaluated.
1011If any expression is omitted, it behaves as if it evaluates to 1.
1012The return value is the exit status of the last command in <I>list</I>
1013that is executed, or false if any of the expressions is invalid.
1014<DT><B>select</B> <I>name</I> [ <B>in</B> <I>word</I> ] ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1015The list of words following <B>in</B> is expanded, generating a list
1016of items. The set of expanded words is printed on the standard
1017error, each preceded by a number. If the <B>in</B>
1018<I>word</I> is omitted, the positional parameters are printed (see
1019<FONT SIZE=-1><B>PARAMETERS</B>
1020
1021</FONT>
1022below). The
1023<B>PS3</B>
1024
1025prompt is then displayed and a line read from the standard input.
1026If the line consists of a number corresponding to one of
1027the displayed words, then the value of
1028<I>name</I>
1029
1030is set to that word. If the line is empty, the words and prompt
1031are displayed again. If EOF is read, the command completes. Any
1032other value read causes
1033<I>name</I>
1034
1035to be set to null. The line read is saved in the variable
1036<B>REPLY</B>.
1037
1038The
1039<I>list</I>
1040
1041is executed after each selection until a
1042<B>break</B>
1043
1044command is executed.
1045The exit status of
1046<B>select</B>
1047
1048is the exit status of the last command executed in
1049<I>list</I>,
1050
1051or zero if no commands were executed.
1052<DT><B>case</B> <I>word</I> <B>in</B> [ [(] <I>pattern</I> [ <B>|</B> <I>pattern</I> ]
1053<DD>
1054A <B>case</B> command first expands <I>word</I>, and tries to match
1055it against each <I>pattern</I> in turn, using the same matching rules
1056as for pathname expansion (see
1057<B>Pathname Expansion</B>
1058
1059below).
1060The <I>word</I> is expanded using tilde
1061expansion, parameter and variable expansion, arithmetic substitution,
1062command substitution, process substitution and quote removal.
1063Each <I>pattern</I> examined is expanded using tilde
1064expansion, parameter and variable expansion, arithmetic substitution,
1065command substitution, and process substitution.
1066If the shell option
1067<B>nocasematch</B>
1068
1069is enabled, the match is performed without regard to the case
1070of alphabetic characters.
1071When a match is found, the corresponding <I>list</I> is executed.
1072If the <B>;;</B> operator is used, no subsequent matches are attempted after
1073the first pattern match.
1074Using <B>;&amp;</B> in place of <B>;;</B> causes execution to continue with
1075the <I>list</I> associated with the next set of patterns.
1076Using <B>;;&amp;</B> in place of <B>;;</B> causes the shell to test the next
1077pattern list in the statement, if any, and execute any associated <I>list</I>
1078on a successful match.
1079The exit status is zero if no
1080pattern matches. Otherwise, it is the exit status of the
1081last command executed in <I>list</I>.
1082<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>
1083The
1084<B>if </B>
1085
1086<I>list</I>
1087
1088is executed. If its exit status is zero, the
1089<B>then</B> <I>list</I> is executed. Otherwise, each <B>elif</B>
1090<I>list</I> is executed in turn, and if its exit status is zero,
1091the corresponding <B>then</B> <I>list</I> is executed and the
1092command completes. Otherwise, the <B>else</B> <I>list</I> is
1093executed, if present. The exit status is the exit status of the
1094last command executed, or zero if no condition tested true.
1095<DT><B>while</B> <I>list</I>; <B>do</B> <I>list</I>; <B>done</B><DD>
1096
1097<DT><B>until</B> <I>list</I>; <B>do</B> <I>list</I>; <B>done</B><DD>
1098
1099The <B>while</B> command continuously executes the <B>do</B>
1100<I>list</I> as long as the last command in <I>list</I> returns
1101an exit status of zero. The <B>until</B> command is identical
1102to the <B>while</B> command, except that the test is negated;
1103the
1104<B>do</B>
1105
1106<I>list</I>
1107
1108is executed as long as the last command in
1109<I>list</I>
1110
1111returns a non-zero exit status.
1112The exit status of the <B>while</B> and <B>until</B> commands
1113is the exit status
1114of the last <B>do</B> <I>list</I> command executed, or zero if
1115none was executed.
1116</DL>
1117<A NAME="lbAP">&nbsp;</A>
1118<H4>Coprocesses</H4>
1119
1120<P>
1121
1122A <I>coprocess</I> is a shell command preceded by the <B>coproc</B> reserved
1123word.
1124A coprocess is executed asynchronously in a subshell, as if the command
1125had been terminated with the <B>&amp;</B> control operator, with a two-way pipe
1126established between the executing shell and the coprocess.
1127<P>
1128
1129The format for a coprocess is:
1130<DL COMPACT><DT><DD>
1131<P>
1132
1133<B>coproc</B> [<I>NAME</I>] <I>command</I> [<I>redirections</I>]
1134</DL>
1135
1136<P>
1137
1138This creates a coprocess named <I>NAME</I>.
1139If <I>NAME</I> is not supplied, the default name is <I>COPROC</I>.
1140<I>NAME</I> must not be supplied if <I>command</I> is a <I>simple
1141command</I> (see above); otherwise, it is interpreted as the first word
1142of the simple command.
1143When the coproc is executed, the shell creates an array variable (see
1144<B>Arrays</B>
1145
1146below) named <I>NAME</I> in the context of the executing shell.
1147The standard output of
1148<I>command</I>
1149
1150is connected via a pipe to a file descriptor in the executing shell,
1151and that file descriptor is assigned to <I>NAME</I>[0].
1152The standard input of
1153<I>command</I>
1154
1155is connected via a pipe to a file descriptor in the executing shell,
1156and that file descriptor is assigned to <I>NAME</I>[1].
1157This pipe is established before any redirections specified by the
1158command (see
1159<FONT SIZE=-1><B>REDIRECTION</B>
1160
1161</FONT>
1162below).
1163The file descriptors can be utilized as arguments to shell commands
1164and redirections using standard word expansions.
1165The process id of the shell spawned to execute the coprocess is
1166available as the value of the variable <I>NAME</I>_PID.
1167The <B>wait</B>
1168builtin command may be used to wait for the coprocess to terminate.
1169<P>
1170
1171The return status of a coprocess is the exit status of <I>command</I>.
1172<A NAME="lbAQ">&nbsp;</A>
1173<H4>Shell Function Definitions</H4>
1174
1175<P>
1176
1177A shell function is an object that is called like a simple command and
1178executes a compound command with a new set of positional parameters.
1179Shell functions are declared as follows:
1180<DL COMPACT>
1181<DT>[ <B>function</B> ] <I>name</I> () <I>compound-command</I> [<I>redirection</I>]<DD>
1182This defines a function named <I>name</I>.
1183The reserved word <B>function</B> is optional.
1184If the <B>function</B> reserved word is supplied, the parentheses are optional.
1185The <I>body</I> of the function is the compound command
1186<I>compound-command </I>
1187
1188(see <B>Compound Commands</B> above).
1189That command is usually a <I>list</I> of commands between { and }, but
1190may be any command listed under <B>Compound Commands</B> above.
1191<I>compound-command</I> is executed whenever <I>name</I> is specified as the
1192name of a simple command.
1193Any redirections (see
1194<FONT SIZE=-1><B>REDIRECTION</B>
1195
1196</FONT>
1197below) specified when a function is defined are performed
1198when the function is executed.
1199The exit status of a function definition is zero unless a syntax error
1200occurs or a readonly function with the same name already exists.
1201When executed, the exit status of a function is the exit status of the
1202last command executed in the body. (See
1203<FONT SIZE=-1><B>FUNCTIONS</B>
1204
1205</FONT>
1206below.)
1207</DL>
1208<A NAME="lbAR">&nbsp;</A>
1209<H3>COMMENTS</H3>
1210
1211In a non-interactive shell, or an interactive shell in which the
1212<B>interactive_comments</B>
1213
1214option to the
1215<B>shopt</B>
1216
1217builtin is enabled (see
1218<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1219
1220</FONT>
1221below), a word beginning with
1222<B>#</B>
1223
1224causes that word and all remaining characters on that line to
1225be ignored. An interactive shell without the
1226<B>interactive_comments</B>
1227
1228option enabled does not allow comments. The
1229<B>interactive_comments</B>
1230
1231option is on by default in interactive shells.
1232<A NAME="lbAS">&nbsp;</A>
1233<H3>QUOTING</H3>
1234
1235<I>Quoting</I> is used to remove the special meaning of certain
1236characters or words to the shell. Quoting can be used to
1237disable special treatment for special characters, to prevent
1238reserved words from being recognized as such, and to prevent
1239parameter expansion.
1240<P>
1241
1242Each of the <I>metacharacters</I> listed above under
1243<FONT SIZE=-1><B>DEFINITIONS</B>
1244
1245</FONT>
1246has special meaning to the shell and must be quoted if it is to
1247represent itself.
1248<P>
1249
1250When the command history expansion facilities are being used
1251(see
1252<FONT SIZE=-1><B>HISTORY EXPANSION</B>
1253
1254</FONT>
1255below), the
1256<I>history expansion</I> character, usually <B>!</B>, must be quoted
1257to prevent history expansion.
1258<P>
1259
1260There are three quoting mechanisms: the
1261<I>escape character</I>,
1262
1263single quotes, and double quotes.
1264<P>
1265
1266A non-quoted backslash (<B>\</B>) is the
1267<I>escape character</I>.
1268
1269It preserves the literal value of the next character that follows,
1270with the exception of &lt;newline&gt;. If a <B>\</B>&lt;newline&gt; pair
1271appears, and the backslash is not itself quoted, the <B>\</B>&lt;newline&gt;
1272is treated as a line continuation (that is, it is removed from the
1273input stream and effectively ignored).
1274<P>
1275
1276Enclosing characters in single quotes preserves the literal value
1277of each character within the quotes. A single quote may not occur
1278between single quotes, even when preceded by a backslash.
1279<P>
1280
1281Enclosing characters in double quotes preserves the literal value
1282of all characters within the quotes, with the exception of
1283<B>$</B>,
1284
1285<B>`</B>,
1286
1287<B>\</B>,
1288
1289and, when history expansion is enabled,
1290<B>!</B>.
1291
1292The characters
1293<B>$</B>
1294
1295and
1296<B>`</B>
1297
1298retain their special meaning within double quotes. The backslash
1299retains its special meaning only when followed by one of the following
1300characters:
1301<B>$</B>,
1302
1303<B>`</B>,
1304
1305<B>&quot;</B>,
1306<B>\</B>,
1307
1308or
1309<B>&lt;newline&gt;</B>.
1310
1311A double quote may be quoted within double quotes by preceding it with
1312a backslash.
1313If enabled, history expansion will be performed unless an
1314<B>!</B>
1315
1316appearing in double quotes is escaped using a backslash.
1317The backslash preceding the
1318<B>!</B>
1319
1320is not removed.
1321<P>
1322
1323The special parameters
1324<B>*</B>
1325
1326and
1327<B>@</B>
1328
1329have special meaning when in double
1330quotes (see
1331<FONT SIZE=-1><B>PARAMETERS</B>
1332
1333</FONT>
1334below).
1335<P>
1336
1337Words of the form <B>$</B>aq<I>string</I>aq are treated specially. The
1338word expands to <I>string</I>, with backslash-escaped characters replaced
1339as specified by the ANSI C standard. Backslash escape sequences, if
1340present, are decoded as follows:
1341<DL COMPACT><DT><DD>
1342
1343<DL COMPACT>
1344<DT><B>\a</B>
1345
1346<DD>
1347alert (bell)
1348<DT><B>\b</B>
1349
1350<DD>
1351backspace
1352<DT><B>\e</B>
1353
1354<DD>
1355an escape character
1356<DT><B>\f</B>
1357
1358<DD>
1359form feed
1360<DT><B>\n</B>
1361
1362<DD>
1363new line
1364<DT><B>\r</B>
1365
1366<DD>
1367carriage return
1368<DT><B>\t</B>
1369
1370<DD>
1371horizontal tab
1372<DT><B>\v</B>
1373
1374<DD>
1375vertical tab
1376<DT><B>\\</B>
1377
1378<DD>
1379backslash
1380<DT><B>\aq</B>
1381
1382<DD>
1383single quote
1384<DT><B>\</B><I>nnn</I>
1385
1386<DD>
1387the eight-bit character whose value is the octal value <I>nnn</I>
1388(one to three digits)
1389<DT><B>\x</B><I>HH</I>
1390
1391<DD>
1392the eight-bit character whose value is the hexadecimal value <I>HH</I>
1393(one or two hex digits)
1394<DT><B>\c</B><I>x</I>
1395
1396<DD>
1397a control-<I>x</I> character
1398
1399</DL></DL>
1400
1401<P>
1402
1403The expanded result is single-quoted, as if the dollar sign had
1404not been present.
1405<P>
1406
1407A double-quoted string preceded by a dollar sign (<B>$</B>) will cause
1408the string to be translated according to the current locale.
1409If the current locale is <B>C</B> or <B>POSIX</B>, the dollar sign
1410is ignored.
1411If the string is translated and replaced, the replacement is
1412double-quoted.
1413<A NAME="lbAT">&nbsp;</A>
1414<H3>PARAMETERS</H3>
1415
1416A
1417<I>parameter</I>
1418
1419is an entity that stores values.
1420It can be a
1421<I>name</I>,
1422
1423a number, or one of the special characters listed below under
1424<B>Special Parameters</B>.
1425
1426A
1427<I>variable</I>
1428
1429is a parameter denoted by a
1430<I>name</I>.
1431
1432A variable has a <I>value</I> and zero or more <I>attributes</I>.
1433Attributes are assigned using the
1434<B>declare</B>
1435
1436builtin command (see
1437<B>declare</B>
1438
1439below in
1440<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>).
1441
1442</FONT>
1443<P>
1444
1445A parameter is set if it has been assigned a value. The null string is
1446a valid value. Once a variable is set, it may be unset only by using
1447the
1448<B>unset</B>
1449
1450builtin command (see
1451<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1452
1453</FONT>
1454below).
1455<P>
1456
1457A
1458<I>variable</I>
1459
1460may be assigned to by a statement of the form
1461<DL COMPACT><DT><DD>
1462<P>
1463
1464<I>name</I>=[<I>value</I>]
1465</DL>
1466
1467<P>
1468
1469If
1470<I>value</I>
1471
1472is not given, the variable is assigned the null string. All
1473<I>values</I>
1474
1475undergo tilde expansion, parameter and variable expansion,
1476command substitution, arithmetic expansion, and quote
1477removal (see
1478<FONT SIZE=-1><B>EXPANSION</B>
1479
1480</FONT>
1481below). If the variable has its
1482<B>integer</B>
1483
1484attribute set, then
1485<I>value</I>
1486
1487is evaluated as an arithmetic expression even if the $((...)) expansion is
1488not used (see
1489<B>Arithmetic Expansion</B>
1490
1491below).
1492Word splitting is not performed, with the exception
1493of <B>&quot;$@&quot;</B> as explained below under
1494<B>Special Parameters</B>.
1495
1496Pathname expansion is not performed.
1497Assignment statements may also appear as arguments to the
1498<B>alias</B>,
1499
1500<B>declare</B>,
1501
1502<B>typeset</B>,
1503
1504<B>export</B>,
1505
1506<B>readonly</B>,
1507
1508and
1509<B>local</B>
1510
1511builtin commands.
1512<P>
1513
1514In the context where an assignment statement is assigning a value
1515to a shell variable or array index, the += operator can be used to
1516append to or add to the variable's previous value.
1517When += is applied to a variable for which the integer attribute has been
1518set, <I>value</I> is evaluated as an arithmetic expression and added to the
1519variable's current value, which is also evaluated.
1520When += is applied to an array variable using compound assignment (see
1521<B>Arrays</B>
1522
1523below), the
1524variable's value is not unset (as it is when using =), and new values are
1525appended to the array beginning at one greater than the array's maximum index
1526(for indexed arrays) or added as additional key-value pairs in an
1527associative array.
1528When applied to a string-valued variable, <I>value</I> is expanded and
1529appended to the variable's value.
1530<A NAME="lbAU">&nbsp;</A>
1531<H4>Positional Parameters</H4>
1532
1533<P>
1534
1535A
1536<I>positional parameter</I>
1537
1538is a parameter denoted by one or more
1539digits, other than the single digit 0. Positional parameters are
1540assigned from the shell's arguments when it is invoked,
1541and may be reassigned using the
1542<B>set</B>
1543
1544builtin command. Positional parameters may not be assigned to
1545with assignment statements. The positional parameters are
1546temporarily replaced when a shell function is executed (see
1547<FONT SIZE=-1><B>FUNCTIONS</B>
1548
1549</FONT>
1550below).
1551<P>
1552
1553When a positional parameter consisting of more than a single
1554digit is expanded, it must be enclosed in braces (see
1555<FONT SIZE=-1><B>EXPANSION</B>
1556
1557</FONT>
1558below).
1559<A NAME="lbAV">&nbsp;</A>
1560<H4>Special Parameters</H4>
1561
1562<P>
1563
1564The shell treats several parameters specially. These parameters may
1565only be referenced; assignment to them is not allowed.
1566
1567<DL COMPACT>
1568<DT><B>*</B>
1569
1570<DD>
1571Expands to the positional parameters, starting from one. When the
1572expansion occurs within double quotes, it expands to a single word
1573with the value of each parameter separated by the first character
1574of the
1575<FONT SIZE=-1><B>IFS</B>
1576
1577</FONT>
1578special variable. That is, &quot;<B>$*</B>&quot; is equivalent
1579to &quot;<B>$1</B><I>c</I><B>$2</B><I>c</I><B>...</B>&quot;, where
1580<I>c</I>
1581
1582is the first character of the value of the
1583<FONT SIZE=-1><B>IFS</B>
1584
1585</FONT>
1586variable. If
1587<FONT SIZE=-1><B>IFS</B>
1588
1589</FONT>
1590is unset, the parameters are separated by spaces.
1591If
1592<FONT SIZE=-1><B>IFS</B>
1593
1594</FONT>
1595is null, the parameters are joined without intervening separators.
1596<DT><B>@</B>
1597
1598<DD>
1599Expands to the positional parameters, starting from one. When the
1600expansion occurs within double quotes, each parameter expands to a
1601separate word. That is, &quot;<B>$@</B>&quot; is equivalent to
1602&quot;<B>$1</B>&quot; &quot;<B>$2</B>&quot; ...
1603If the double-quoted expansion occurs within a word, the expansion of
1604the first parameter is joined with the beginning part of the original
1605word, and the expansion of the last parameter is joined with the last
1606part of the original word.
1607When there are no positional parameters, &quot;<B>$@</B>&quot; and
1608<B>$@</B>
1609
1610expand to nothing (i.e., they are removed).
1611<DT><B>#</B>
1612
1613<DD>
1614Expands to the number of positional parameters in decimal.
1615<DT><B>?</B>
1616
1617<DD>
1618Expands to the exit status of the most recently executed foreground
1619pipeline.
1620<DT><B>-</B>
1621
1622<DD>
1623Expands to the current option flags as specified upon invocation,
1624by the
1625<B>set</B>
1626
1627builtin command, or those set by the shell itself
1628(such as the
1629<B>-i</B>
1630
1631option).
1632<DT><B>$</B>
1633
1634<DD>
1635Expands to the process ID of the shell. In a () subshell, it
1636expands to the process ID of the current shell, not the
1637subshell.
1638<DT><B>!</B>
1639
1640<DD>
1641Expands to the process ID of the most recently executed background
1642(asynchronous) command.
1643<DT><B>0</B>
1644
1645<DD>
1646Expands to the name of the shell or shell script. This is set at
1647shell initialization. If
1648<B>bash</B>
1649
1650is invoked with a file of commands,
1651<B>$0</B>
1652
1653is set to the name of that file. If
1654<B>bash</B>
1655
1656is started with the
1657<B>-c</B>
1658
1659option, then
1660<B>$0</B>
1661
1662is set to the first argument after the string to be
1663executed, if one is present. Otherwise, it is set
1664to the file name used to invoke
1665<B>bash</B>,
1666
1667as given by argument zero.
1668<DT><B>_</B>
1669
1670<DD>
1671At shell startup, set to the absolute pathname used to invoke the
1672shell or shell script being executed as passed in the environment
1673or argument list.
1674Subsequently, expands to the last argument to the previous command,
1675after expansion.
1676Also set to the full pathname used to invoke each command executed
1677and placed in the environment exported to that command.
1678When checking mail, this parameter holds the name of the mail file
1679currently being checked.
1680
1681</DL>
1682<A NAME="lbAW">&nbsp;</A>
1683<H4>Shell Variables</H4>
1684
1685<P>
1686
1687The following variables are set by the shell:
1688<P>
1689
1690
1691<DL COMPACT>
1692<DT><B>BASH</B>
1693
1694<DD>
1695Expands to the full file name used to invoke this instance of
1696<B>bash</B>.
1697
1698<DT><B>BASHPID</B>
1699
1700<DD>
1701Expands to the process id of the current <B>bash</B> process.
1702This differs from <B>$$</B> under certain circumstances, such as subshells
1703that do not require <B>bash</B> to be re-initialized.
1704<DT><B>BASH_ALIASES</B>
1705
1706<DD>
1707An associative array variable whose members correspond to the internal
1708list of aliases as maintained by the <B>alias</B> builtin
1709Elements added to this array appear in the alias list; unsetting array
1710elements cause aliases to be removed from the alias list.
1711<DT><B>BASH_ARGC</B>
1712
1713<DD>
1714An array variable whose values are the number of parameters in each
1715frame of the current <B>bash</B> execution call stack.
1716The number of
1717parameters to the current subroutine (shell function or script executed
1718with <B>.</B> or <B>source</B>) is at the top of the stack.
1719When a subroutine is executed, the number of parameters passed is pushed onto
1720<B>BASH_ARGC</B>.
1721The shell sets <B>BASH_ARGC</B> only when in extended debugging mode
1722(see the description of the
1723<B>extdebug</B>
1724
1725option to the
1726<B>shopt</B>
1727
1728builtin below)
1729<DT><B>BASH_ARGV</B>
1730
1731<DD>
1732An array variable containing all of the parameters in the current <B>bash</B>
1733execution call stack. The final parameter of the last subroutine call
1734is at the top of the stack; the first parameter of the initial call is
1735at the bottom. When a subroutine is executed, the parameters supplied
1736are pushed onto <B>BASH_ARGV</B>.
1737The shell sets <B>BASH_ARGV</B> only when in extended debugging mode
1738(see the description of the
1739<B>extdebug</B>
1740
1741option to the
1742<B>shopt</B>
1743
1744builtin below)
1745<DT><B>BASH_CMDS</B>
1746
1747<DD>
1748An associative array variable whose members correspond to the internal
1749hash table of commands as maintained by the <B>hash</B> builtin.
1750Elements added to this array appear in the hash table; unsetting array
1751elements cause commands to be removed from the hash table.
1752<DT><B>BASH_COMMAND</B>
1753
1754<DD>
1755The command currently being executed or about to be executed, unless the
1756shell is executing a command as the result of a trap,
1757in which case it is the command executing at the time of the trap.
1758<DT><B>BASH_EXECUTION_STRING</B>
1759
1760<DD>
1761The command argument to the <B>-c</B> invocation option.
1762<DT><B>BASH_LINENO</B>
1763
1764<DD>
1765An array variable whose members are the line numbers in source files
1766corresponding to each member of <B>FUNCNAME</B>.
1767<B>${BASH_LINENO[</B><I>$i</I><B>]}</B> is the line number in the source
1768file where <B>${FUNCNAME[</B><I>$i</I><B>]}</B> was called
1769(or <B>${BASH_LINENO[</B><I>$i-1</I><B>]}</B> if referenced within another
1770shell function).
1771The corresponding source file name is <B>${BASH_SOURCE[</B><I>$i</I><B>]}.
1772Use LINENO</B> to obtain the current line number.
1773<DT><B>BASH_REMATCH</B>
1774
1775<DD>
1776An array variable whose members are assigned by the <B>=~</B> binary
1777operator to the <B>[[</B> conditional command.
1778The element with index 0 is the portion of the string
1779matching the entire regular expression.
1780The element with index <I>n</I> is the portion of the
1781string matching the <I>n</I>th parenthesized subexpression.
1782This variable is read-only.
1783<DT><B>BASH_SOURCE</B>
1784
1785<DD>
1786An array variable whose members are the source filenames corresponding
1787to the elements in the <B>FUNCNAME</B> array variable.
1788<DT><B>BASH_SUBSHELL</B>
1789
1790<DD>
1791Incremented by one each time a subshell or subshell environment is spawned.
1792The initial value is 0.
1793<DT><B>BASH_VERSINFO</B>
1794
1795<DD>
1796A readonly array variable whose members hold version information for
1797this instance of
1798<B>bash</B>.
1799
1800The values assigned to the array members are as follows:
1801<P>
1802<DL COMPACT><DT><DD>
1803
1804<DL COMPACT>
1805<DT><B>BASH_VERSINFO[</B>0]
1806
1807<DD>
1808The major version number (the <I>release</I>).
1809<DT><B>BASH_VERSINFO[</B>1]
1810
1811<DD>
1812The minor version number (the <I>version</I>).
1813<DT><B>BASH_VERSINFO[</B>2]
1814
1815<DD>
1816The patch level.
1817<DT><B>BASH_VERSINFO[</B>3]
1818
1819<DD>
1820The build version.
1821<DT><B>BASH_VERSINFO[</B>4]
1822
1823<DD>
1824The release status (e.g., <I>beta1</I>).
1825<DT><B>BASH_VERSINFO[</B>5]
1826
1827<DD>
1828The value of <B>MACHTYPE</B>.
1829
1830</DL></DL>
1831
1832<DT><B>BASH_VERSION</B>
1833
1834<DD>
1835Expands to a string describing the version of this instance of
1836<B>bash</B>.
1837
1838<DT><B>COMP_CWORD</B>
1839
1840<DD>
1841An index into <B>${COMP_WORDS}</B> of the word containing the current
1842cursor position.
1843This variable is available only in shell functions invoked by the
1844programmable completion facilities (see <B>Programmable Completion</B>
1845below).
1846<DT><B>COMP_KEY</B>
1847
1848<DD>
1849The key (or final key of a key sequence) used to invoke the current
1850completion function.
1851<DT><B>COMP_LINE</B>
1852
1853<DD>
1854The current command line.
1855This variable is available only in shell functions and external
1856commands invoked by the
1857programmable completion facilities (see <B>Programmable Completion</B>
1858below).
1859<DT><B>COMP_POINT</B>
1860
1861<DD>
1862The index of the current cursor position relative to the beginning of
1863the current command.
1864If the current cursor position is at the end of the current command,
1865the value of this variable is equal to <B>${#COMP_LINE}</B>.
1866This variable is available only in shell functions and external
1867commands invoked by the
1868programmable completion facilities (see <B>Programmable Completion</B>
1869below).
1870<DT><B>COMP_TYPE</B>
1871
1872<DD>
1873Set to an integer value corresponding to the type of completion attempted
1874that caused a completion function to be called:
1875<I>TAB</I>, for normal completion,
1876<I>?</I>, for listing completions after successive tabs,
1877<I>!</I>, for listing alternatives on partial word completion,
1878<I>@</I>, to list completions if the word is not unmodified,
1879or
1880<I>%</I>, for menu completion.
1881This variable is available only in shell functions and external
1882commands invoked by the
1883programmable completion facilities (see <B>Programmable Completion</B>
1884below).
1885<DT><B>COMP_WORDBREAKS</B>
1886
1887<DD>
1888The set of characters that the Readline library treats as word
1889separators when performing word completion.
1890If
1891<FONT SIZE=-1><B>COMP_WORDBREAKS</B>
1892
1893</FONT>
1894is unset, it loses its special properties, even if it is
1895subsequently reset.
1896<DT><B>COMP_WORDS</B>
1897
1898<DD>
1899An array variable (see <B>Arrays</B> below) consisting of the individual
1900words in the current command line.
1901The words are split on shell metacharacters as the shell parser would
1902separate them.
1903This variable is available only in shell functions invoked by the
1904programmable completion facilities (see <B>Programmable Completion</B>
1905below).
1906<DT><B>DIRSTACK</B>
1907
1908<DD>
1909An array variable (see
1910<B>Arrays</B>
1911
1912below) containing the current contents of the directory stack.
1913Directories appear in the stack in the order they are displayed by the
1914<B>dirs</B>
1915
1916builtin.
1917Assigning to members of this array variable may be used to modify
1918directories already in the stack, but the
1919<B>pushd</B>
1920
1921and
1922<B>popd</B>
1923
1924builtins must be used to add and remove directories.
1925Assignment to this variable will not change the current directory.
1926If
1927<FONT SIZE=-1><B>DIRSTACK</B>
1928
1929</FONT>
1930is unset, it loses its special properties, even if it is
1931subsequently reset.
1932<DT><B>EUID</B>
1933
1934<DD>
1935Expands to the effective user ID of the current user, initialized at
1936shell startup. This variable is readonly.
1937<DT><B>FUNCNAME</B>
1938
1939<DD>
1940An array variable containing the names of all shell functions
1941currently in the execution call stack.
1942The element with index 0 is the name of any currently-executing
1943shell function.
1944The bottom-most element is
1945<TT>&quot;main&quot;</TT>.
1946
1947This variable exists only when a shell function is executing.
1948Assignments to
1949<FONT SIZE=-1><B>FUNCNAME</B>
1950
1951</FONT>
1952have no effect and return an error status.
1953If
1954<FONT SIZE=-1><B>FUNCNAME</B>
1955
1956</FONT>
1957is unset, it loses its special properties, even if it is
1958subsequently reset.
1959<DT><B>GROUPS</B>
1960
1961<DD>
1962An array variable containing the list of groups of which the current
1963user is a member.
1964Assignments to
1965<FONT SIZE=-1><B>GROUPS</B>
1966
1967</FONT>
1968have no effect and return an error status.
1969If
1970<FONT SIZE=-1><B>GROUPS</B>
1971
1972</FONT>
1973is unset, it loses its special properties, even if it is
1974subsequently reset.
1975<DT><B>HISTCMD</B>
1976
1977<DD>
1978The history number, or index in the history list, of the current
1979command.
1980If
1981<FONT SIZE=-1><B>HISTCMD</B>
1982
1983</FONT>
1984is unset, it loses its special properties, even if it is
1985subsequently reset.
1986<DT><B>HOSTNAME</B>
1987
1988<DD>
1989Automatically set to the name of the current host.
1990<DT><B>HOSTTYPE</B>
1991
1992<DD>
1993Automatically set to a string that uniquely
1994describes the type of machine on which
1995<B>bash</B>
1996
1997is executing.
1998The default is system-dependent.
1999<DT><B>LINENO</B>
2000
2001<DD>
2002Each time this parameter is referenced, the shell substitutes
2003a decimal number representing the current sequential line number
2004(starting with 1) within a script or function. When not in a
2005script or function, the value substituted is not guaranteed to
2006be meaningful.
2007If
2008<FONT SIZE=-1><B>LINENO</B>
2009
2010</FONT>
2011is unset, it loses its special properties, even if it is
2012subsequently reset.
2013<DT><B>MACHTYPE</B>
2014
2015<DD>
2016Automatically set to a string that fully describes the system
2017type on which
2018<B>bash</B>
2019
2020is executing, in the standard GNU <I>cpu-company-system</I> format.
2021The default is system-dependent.
2022<DT><B>OLDPWD</B>
2023
2024<DD>
2025The previous working directory as set by the
2026<B>cd</B>
2027
2028command.
2029<DT><B>OPTARG</B>
2030
2031<DD>
2032The value of the last option argument processed by the
2033<B>getopts</B>
2034
2035builtin command (see
2036<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2037
2038</FONT>
2039below).
2040<DT><B>OPTIND</B>
2041
2042<DD>
2043The index of the next argument to be processed by the
2044<B>getopts</B>
2045
2046builtin command (see
2047<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2048
2049</FONT>
2050below).
2051<DT><B>OSTYPE</B>
2052
2053<DD>
2054Automatically set to a string that
2055describes the operating system on which
2056<B>bash</B>
2057
2058is executing.
2059The default is system-dependent.
2060<DT><B>PIPESTATUS</B>
2061
2062<DD>
2063An array variable (see
2064<B>Arrays</B>
2065
2066below) containing a list of exit status values from the processes
2067in the most-recently-executed foreground pipeline (which may
2068contain only a single command).
2069<DT><B>PPID</B>
2070
2071<DD>
2072The process ID of the shell's parent. This variable is readonly.
2073<DT><B>PWD</B>
2074
2075<DD>
2076The current working directory as set by the
2077<B>cd</B>
2078
2079command.
2080<DT><B>RANDOM</B>
2081
2082<DD>
2083Each time this parameter is referenced, a random integer between
20840 and 32767 is
2085generated. The sequence of random numbers may be initialized by assigning
2086a value to
2087<FONT SIZE=-1><B>RANDOM</B>.
2088
2089</FONT>
2090If
2091<FONT SIZE=-1><B>RANDOM</B>
2092
2093</FONT>
2094is unset, it loses its special properties, even if it is
2095subsequently reset.
2096<DT><B>REPLY</B>
2097
2098<DD>
2099Set to the line of input read by the
2100<B>read</B>
2101
2102builtin command when no arguments are supplied.
2103<DT><B>SECONDS</B>
2104
2105<DD>
2106Each time this parameter is
2107referenced, the number of seconds since shell invocation is returned. If a
2108value is assigned to
2109<FONT SIZE=-1><B>SECONDS</B>,
2110
2111</FONT>
2112the value returned upon subsequent
2113references is
2114the number of seconds since the assignment plus the value assigned.
2115If
2116<FONT SIZE=-1><B>SECONDS</B>
2117
2118</FONT>
2119is unset, it loses its special properties, even if it is
2120subsequently reset.
2121<DT><B>SHELLOPTS</B>
2122
2123<DD>
2124A colon-separated list of enabled shell options. Each word in
2125the list is a valid argument for the
2126<B>-o</B>
2127
2128option to the
2129<B>set</B>
2130
2131builtin command (see
2132<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2133
2134</FONT>
2135below). The options appearing in
2136<FONT SIZE=-1><B>SHELLOPTS</B>
2137
2138</FONT>
2139are those reported as
2140<I>on</I>
2141
2142by <B>set -o</B>.
2143If this variable is in the environment when
2144<B>bash</B>
2145
2146starts up, each shell option in the list will be enabled before
2147reading any startup files.
2148This variable is read-only.
2149<DT><B>SHLVL</B>
2150
2151<DD>
2152Incremented by one each time an instance of
2153<B>bash</B>
2154
2155is started.
2156<DT><B>UID</B>
2157
2158<DD>
2159Expands to the user ID of the current user, initialized at shell startup.
2160This variable is readonly.
2161
2162</DL>
2163<P>
2164
2165The following variables are used by the shell. In some cases,
2166<B>bash</B>
2167
2168assigns a default value to a variable; these cases are noted
2169below.
2170<P>
2171
2172
2173<DL COMPACT>
2174<DT><B>BASH_ENV</B>
2175
2176<DD>
2177If this parameter is set when <B>bash</B> is executing a shell script,
2178its value is interpreted as a filename containing commands to
2179initialize the shell, as in
2180<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
2181
2182The value of
2183<FONT SIZE=-1><B>BASH_ENV</B>
2184
2185</FONT>
2186is subjected to parameter expansion, command substitution, and arithmetic
2187expansion before being interpreted as a file name.
2188<FONT SIZE=-1><B>PATH</B>
2189
2190</FONT>
2191is not used to search for the resultant file name.
2192<DT><B>CDPATH</B>
2193
2194<DD>
2195The search path for the
2196<B>cd</B>
2197
2198command.
2199This is a colon-separated list of directories in which the shell looks
2200for destination directories specified by the
2201<B>cd</B>
2202
2203command.
2204A sample value is
2205<TT>&quot;.:~:/usr&quot;</TT>.
2206
2207<DT><B>COLUMNS</B>
2208
2209<DD>
2210Used by the <B>select</B> builtin command to determine the terminal width
2211when printing selection lists. Automatically set upon receipt of a SIGWINCH.
2212<DT><B>COMPREPLY</B>
2213
2214<DD>
2215An array variable from which <B>bash</B> reads the possible completions
2216generated by a shell function invoked by the programmable completion
2217facility (see <B>Programmable Completion</B> below).
2218<DT><B>EMACS</B>
2219
2220<DD>
2221If <B>bash</B> finds this variable in the environment when the shell starts
2222with value
2223<TT>t</TT>,
2224
2225it assumes that the shell is running in an emacs shell buffer and disables
2226line editing.
2227<DT><B>FCEDIT</B>
2228
2229<DD>
2230The default editor for the
2231<B>fc</B>
2232
2233builtin command.
2234<DT><B>FIGNORE</B>
2235
2236<DD>
2237A colon-separated list of suffixes to ignore when performing
2238filename completion (see
2239<FONT SIZE=-1><B>READLINE</B>
2240
2241</FONT>
2242below).
2243A filename whose suffix matches one of the entries in
2244<FONT SIZE=-1><B>FIGNORE</B>
2245
2246</FONT>
2247is excluded from the list of matched filenames.
2248A sample value is
2249<TT>&quot;.o:~&quot;</TT>.
2250
2251<DT><B>GLOBIGNORE</B>
2252
2253<DD>
2254A colon-separated list of patterns defining the set of filenames to
2255be ignored by pathname expansion.
2256If a filename matched by a pathname expansion pattern also matches one
2257of the patterns in
2258<FONT SIZE=-1><B>GLOBIGNORE</B>,
2259
2260</FONT>
2261it is removed from the list of matches.
2262<DT><B>HISTCONTROL</B>
2263
2264<DD>
2265A colon-separated list of values controlling how commands are saved on
2266the history list.
2267If the list of values includes
2268<I>ignorespace</I>,
2269
2270lines which begin with a
2271<B>space</B>
2272
2273character are not saved in the history list.
2274A value of
2275<I>ignoredups</I>
2276
2277causes lines matching the previous history entry to not be saved.
2278A value of
2279<I>ignoreboth</I>
2280
2281is shorthand for <I>ignorespace</I> and <I>ignoredups</I>.
2282A value of
2283<I>erasedups</I>
2284
2285causes all previous lines matching the current line to be removed from
2286the history list before that line is saved.
2287Any value not in the above list is ignored.
2288If <B>HISTCONTROL</B> is unset, or does not include a valid value,
2289all lines read by the shell parser are saved on the history list,
2290subject to the value of
2291<B>HISTIGNORE</B>.
2292
2293The second and subsequent lines of a multi-line compound command are
2294not tested, and are added to the history regardless of the value of
2295<B>HISTCONTROL</B>.
2296
2297<DT><B>HISTFILE</B>
2298
2299<DD>
2300The name of the file in which command history is saved (see
2301<FONT SIZE=-1><B>HISTORY</B>
2302
2303</FONT>
2304below). The default value is <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>. If unset, the
2305command history is not saved when an interactive shell exits.
2306<DT><B>HISTFILESIZE</B>
2307
2308<DD>
2309The maximum number of lines contained in the history file. When this
2310variable is assigned a value, the history file is truncated, if
2311necessary, by removing the oldest entries,
2312to contain no more than that number of lines. The default
2313value is 500. The history file is also truncated to this size after
2314writing it when an interactive shell exits.
2315<DT><B>HISTIGNORE</B>
2316
2317<DD>
2318A colon-separated list of patterns used to decide which command lines
2319should be saved on the history list. Each pattern is anchored at the
2320beginning of the line and must match the complete line (no implicit
2321`<B>*</B>' is appended). Each pattern is tested against the line
2322after the checks specified by
2323<B>HISTCONTROL</B>
2324
2325are applied.
2326In addition to the normal shell pattern matching characters, `<B>&amp;</B>'
2327matches the previous history line. `<B>&amp;</B>' may be escaped using a
2328backslash; the backslash is removed before attempting a match.
2329The second and subsequent lines of a multi-line compound command are
2330not tested, and are added to the history regardless of the value of
2331<B>HISTIGNORE</B>.
2332
2333<DT><B>HISTSIZE</B>
2334
2335<DD>
2336The number of commands to remember in the command history (see
2337<FONT SIZE=-1><B>HISTORY</B>
2338
2339</FONT>
2340below). The default value is 500.
2341<DT><B>HISTTIMEFORMAT</B>
2342
2343<DD>
2344If this variable is set and not null, its value is used as a format string
2345for <I>strftime</I>(3) to print the time stamp associated with each history
2346entry displayed by the <B>history</B> builtin.
2347If this variable is set, time stamps are written to the history file so
2348they may be preserved across shell sessions.
2349This uses the history comment character to distinguish timestamps from
2350other history lines.
2351<DT><B>HOME</B>
2352
2353<DD>
2354The home directory of the current user; the default argument for the
2355<B>cd</B> builtin command.
2356The value of this variable is also used when performing tilde expansion.
2357<DT><B>HOSTFILE</B>
2358
2359<DD>
2360Contains the name of a file in the same format as
2361
2362<I>/etc/hosts</I>
2363
2364that should be read when the shell needs to complete a
2365hostname.
2366The list of possible hostname completions may be changed while the
2367shell is running;
2368the next time hostname completion is attempted after the
2369value is changed,
2370<B>bash</B>
2371
2372adds the contents of the new file to the existing list.
2373If
2374<FONT SIZE=-1><B>HOSTFILE</B>
2375
2376</FONT>
2377is set, but has no value, <B>bash</B> attempts to read
2378
2379<I>/etc/hosts</I>
2380
2381to obtain the list of possible hostname completions.
2382When
2383<FONT SIZE=-1><B>HOSTFILE</B>
2384
2385</FONT>
2386is unset, the hostname list is cleared.
2387<DT><B>IFS</B>
2388
2389<DD>
2390The
2391<I>Internal Field Separator</I>
2392
2393that is used
2394for word splitting after expansion and to
2395split lines into words with the
2396<B>read</B>
2397
2398builtin command. The default value is
2399``&lt;space&gt;&lt;tab&gt;&lt;newline&gt;''.
2400<DT><B>IGNOREEOF</B>
2401
2402<DD>
2403Controls the
2404action of an interactive shell on receipt of an
2405<FONT SIZE=-1><B>EOF</B>
2406
2407</FONT>
2408character as the sole input. If set, the value is the number of
2409consecutive
2410<FONT SIZE=-1><B>EOF</B>
2411
2412</FONT>
2413characters which must be
2414typed as the first characters on an input line before
2415<B>bash</B>
2416
2417exits. If the variable exists but does not have a numeric value, or
2418has no value, the default value is 10. If it does not exist,
2419<FONT SIZE=-1><B>EOF</B>
2420
2421</FONT>
2422signifies the end of input to the shell.
2423<DT><B>INPUTRC</B>
2424
2425<DD>
2426The filename for the
2427<B>readline</B>
2428
2429startup file, overriding the default of
2430
2431<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
2432
2433(see
2434<FONT SIZE=-1><B>READLINE</B>
2435
2436</FONT>
2437below).
2438<DT><B>LANG</B>
2439
2440<DD>
2441Used to determine the locale category for any category not specifically
2442selected with a variable starting with <B>LC_</B>.
2443<DT><B>LC_ALL</B>
2444
2445<DD>
2446This variable overrides the value of <B>LANG</B> and any other
2447<B>LC_</B> variable specifying a locale category.
2448<DT><B>LC_COLLATE</B>
2449
2450<DD>
2451This variable determines the collation order used when sorting the
2452results of pathname expansion, and determines the behavior of range
2453expressions, equivalence classes, and collating sequences within
2454pathname expansion and pattern matching.
2455<DT><B>LC_CTYPE</B>
2456
2457<DD>
2458This variable determines the interpretation of characters and the
2459behavior of character classes within pathname expansion and pattern
2460matching.
2461<DT><B>LC_MESSAGES</B>
2462
2463<DD>
2464This variable determines the locale used to translate double-quoted
2465strings preceded by a <B>$</B>.
2466<DT><B>LC_NUMERIC</B>
2467
2468<DD>
2469This variable determines the locale category used for number formatting.
2470<DT><B>LINES</B>
2471
2472<DD>
2473Used by the <B>select</B> builtin command to determine the column length
2474for printing selection lists. Automatically set upon receipt of a SIGWINCH.
2475<DT><B>MAIL</B>
2476
2477<DD>
2478If this parameter is set to a file name and the
2479<FONT SIZE=-1><B>MAILPATH</B>
2480
2481</FONT>
2482variable is not set,
2483<B>bash</B>
2484
2485informs the user of the arrival of mail in the specified file.
2486<DT><B>MAILCHECK</B>
2487
2488<DD>
2489Specifies how
2490often (in seconds)
2491<B>bash</B>
2492
2493checks for mail. The default is 60 seconds. When it is time to check
2494for mail, the shell does so before displaying the primary prompt.
2495If this variable is unset, or set to a value that is not a number
2496greater than or equal to zero, the shell disables mail checking.
2497<DT><B>MAILPATH</B>
2498
2499<DD>
2500A colon-separated list of file names to be checked for mail.
2501The message to be printed when mail arrives in a particular file
2502may be specified by separating the file name from the message with a `?'.
2503When used in the text of the message, <B>$_</B> expands to the name of
2504the current mailfile.
2505Example:
2506<DL COMPACT><DT><DD>
2507<P>
2508
2509<B>MAILPATH</B>=aq/var/mail/bfox?&quot;You have mail&quot;:~/shell-mail?&quot;$_ has mail!&quot;aq
2510<P>
2511
2512<B>Bash</B>
2513
2514supplies a default value for this variable, but the location of the user
2515mail files that it uses is system dependent (e.g., /var/mail/<B>$USER</B>).
2516</DL>
2517
2518<DT><B>OPTERR</B>
2519
2520<DD>
2521If set to the value 1,
2522<B>bash</B>
2523
2524displays error messages generated by the
2525<B>getopts</B>
2526
2527builtin command (see
2528<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2529
2530</FONT>
2531below).
2532<FONT SIZE=-1><B>OPTERR</B>
2533
2534</FONT>
2535is initialized to 1 each time the shell is invoked or a shell
2536script is executed.
2537<DT><B>PATH</B>
2538
2539<DD>
2540The search path for commands. It
2541is a colon-separated list of directories in which
2542the shell looks for commands (see
2543<FONT SIZE=-1><B>COMMAND EXECUTION</B>
2544
2545</FONT>
2546below).
2547A zero-length (null) directory name in the value of <B>PATH</B> indicates the
2548current directory.
2549A null directory name may appear as two adjacent colons, or as an initial
2550or trailing colon.
2551The default path is system-dependent,
2552and is set by the administrator who installs
2553<B>bash</B>.
2554
2555A common value is
2556<TT>/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin</TT>.
2557
2558<DT><B>POSIXLY_CORRECT</B>
2559
2560<DD>
2561If this variable is in the environment when <B>bash</B> starts, the shell
2562enters <I>posix mode</I> before reading the startup files, as if the
2563<B>--posix</B>
2564
2565invocation option had been supplied. If it is set while the shell is
2566running, <B>bash</B> enables <I>posix mode</I>, as if the command
2567<TT>set -o posix</TT>
2568
2569had been executed.
2570<DT><B>PROMPT_COMMAND</B>
2571
2572<DD>
2573If set, the value is executed as a command prior to issuing each primary
2574prompt.
2575<DT><B>PROMPT_DIRTRIM</B>
2576
2577<DD>
2578If set to a number greater than zero, the value is used as the number of
2579trailing directory components to retain when expanding the <B>\w and
2580\W</B> prompt string escapes (see
2581<FONT SIZE=-1><B>PROMPTING</B>
2582
2583</FONT>
2584below). Characters removed are replaced with an ellipsis.
2585<DT><B>PS1</B>
2586
2587<DD>
2588The value of this parameter is expanded (see
2589<FONT SIZE=-1><B>PROMPTING</B>
2590
2591</FONT>
2592below) and used as the primary prompt string. The default value is
2593``<B>\s-\v\$ </B>''.
2594<DT><B>PS2</B>
2595
2596<DD>
2597The value of this parameter is expanded as with
2598<B>PS1</B>
2599
2600and used as the secondary prompt string. The default is
2601``<B>&gt; </B>''.
2602<DT><B>PS3</B>
2603
2604<DD>
2605The value of this parameter is used as the prompt for the
2606<B>select</B>
2607
2608command (see
2609<FONT SIZE=-1><B>SHELL GRAMMAR</B>
2610
2611</FONT>
2612above).
2613<DT><B>PS4</B>
2614
2615<DD>
2616The value of this parameter is expanded as with
2617<B>PS1</B>
2618
2619and the value is printed before each command
2620<B>bash</B>
2621
2622displays during an execution trace. The first character of
2623<FONT SIZE=-1><B>PS4</B>
2624
2625</FONT>
2626is replicated multiple times, as necessary, to indicate multiple
2627levels of indirection. The default is ``<B>+ </B>''.
2628<DT><B>SHELL</B>
2629
2630<DD>
2631The full pathname to the shell is kept in this environment variable.
2632If it is not set when the shell starts,
2633<B>bash</B>
2634
2635assigns to it the full pathname of the current user's login shell.
2636<DT><B>TIMEFORMAT</B>
2637
2638<DD>
2639The value of this parameter is used as a format string specifying
2640how the timing information for pipelines prefixed with the
2641<B>time</B>
2642
2643reserved word should be displayed.
2644The <B>%</B> character introduces an escape sequence that is
2645expanded to a time value or other information.
2646The escape sequences and their meanings are as follows; the
2647braces denote optional portions.
2648<P>
2649<DL COMPACT><DT><DD>
2650
2651<DL COMPACT>
2652<DT><B>%%</B>
2653
2654<DD>
2655A literal <B>%</B>.
2656<DT><B>%[</B><I>p</I>][l]R
2657
2658<DD>
2659The elapsed time in seconds.
2660<DT><B>%[</B><I>p</I>][l]U
2661
2662<DD>
2663The number of CPU seconds spent in user mode.
2664<DT><B>%[</B><I>p</I>][l]S
2665
2666<DD>
2667The number of CPU seconds spent in system mode.
2668<DT><B>%P</B>
2669
2670<DD>
2671The CPU percentage, computed as (%U + %S) / %R.
2672
2673</DL></DL>
2674
2675<DT><DD>
2676The optional <I>p</I> is a digit specifying the <I>precision</I>,
2677the number of fractional digits after a decimal point.
2678A value of 0 causes no decimal point or fraction to be output.
2679At most three places after the decimal point may be specified;
2680values of <I>p</I> greater than 3 are changed to 3.
2681If <I>p</I> is not specified, the value 3 is used.
2682<DT><DD>
2683The optional <B>l</B> specifies a longer format, including
2684minutes, of the form <I>MM</I>m<I>SS</I>.<I>FF</I>s.
2685The value of <I>p</I> determines whether or not the fraction is
2686included.
2687<DT><DD>
2688If this variable is not set, <B>bash</B> acts as if it had the
2689value <B>$aq\nreal\t%3lR\nuser\t%3lU\nsys %3lSaq</B>.
2690If the value is null, no timing information is displayed.
2691A trailing newline is added when the format string is displayed.
2692<DT><B>TMOUT</B>
2693
2694<DD>
2695If set to a value greater than zero, <B>TMOUT</B> is treated as the
2696default timeout for the <B>read</B> builtin.
2697The <B>select</B> command terminates if input does not arrive
2698after <B>TMOUT</B> seconds when input is coming from a terminal.
2699In an interactive shell, the value is interpreted as the
2700number of seconds to wait for input after issuing the primary prompt.
2701<B>Bash</B>
2702
2703terminates after waiting for that number of seconds if input does
2704not arrive.
2705<DT><B>TMPDIR</B>
2706
2707<DD>
2708If set, <B>Bash</B> uses its value as the name of a directory in which
2709<B>Bash</B> creates temporary files for the shell's use.
2710<DT><B>auto_resume</B>
2711
2712<DD>
2713This variable controls how the shell interacts with the user and
2714job control. If this variable is set, single word simple
2715commands without redirections are treated as candidates for resumption
2716of an existing stopped job. There is no ambiguity allowed; if there is
2717more than one job beginning with the string typed, the job most recently
2718accessed is selected. The
2719<I>name</I>
2720
2721of a stopped job, in this context, is the command line used to
2722start it.
2723If set to the value
2724<I>exact</I>,
2725
2726the string supplied must match the name of a stopped job exactly;
2727if set to
2728<I>substring</I>,
2729
2730the string supplied needs to match a substring of the name of a
2731stopped job. The
2732<I>substring</I>
2733
2734value provides functionality analogous to the
2735<B>%?</B>
2736
2737job identifier (see
2738<FONT SIZE=-1><B>JOB CONTROL</B>
2739
2740</FONT>
2741below). If set to any other value, the supplied string must
2742be a prefix of a stopped job's name; this provides functionality
2743analogous to the <B>%</B><I>string</I> job identifier.
2744<DT><B>histchars</B>
2745
2746<DD>
2747The two or three characters which control history expansion
2748and tokenization (see
2749<FONT SIZE=-1><B>HISTORY EXPANSION</B>
2750
2751</FONT>
2752below). The first character is the <I>history expansion</I> character,
2753the character which signals the start of a history
2754expansion, normally `<B>!</B>'.
2755The second character is the <I>quick substitution</I>
2756character, which is used as shorthand for re-running the previous
2757command entered, substituting one string for another in the command.
2758The default is `<B>^</B>'.
2759The optional third character is the character
2760which indicates that the remainder of the line is a comment when found
2761as the first character of a word, normally `<B>#</B>'. The history
2762comment character causes history substitution to be skipped for the
2763remaining words on the line. It does not necessarily cause the shell
2764parser to treat the rest of the line as a comment.
2765
2766</DL>
2767<A NAME="lbAX">&nbsp;</A>
2768<H4>Arrays</H4>
2769
2770<B>Bash</B>
2771
2772provides one-dimensional indexed and associative array variables.
2773Any variable may be used as an indexed array; the
2774<B>declare</B>
2775
2776builtin will explicitly declare an array.
2777There is no maximum
2778limit on the size of an array, nor any requirement that members
2779be indexed or assigned contiguously.
2780Indexed arrays are referenced using integers (including arithmetic
2781expressions) and are zero-based; associative arrays are referenced
2782using arbitrary strings.
2783<P>
2784
2785An indexed array is created automatically if any variable is assigned to
2786using the syntax <I>name</I>[<I>subscript</I>]=<I>value</I>. The
2787<I>subscript</I>
2788
2789is treated as an arithmetic expression that must evaluate to a number
2790greater than or equal to zero. To explicitly declare an indexed array,
2791use
2792<B>declare -a </B><I>name</I>
2793
2794(see
2795<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2796
2797</FONT>
2798below).
2799<B>declare -a </B><I>name</I>[<I>subscript</I>]
2800
2801is also accepted; the <I>subscript</I> is ignored.
2802<P>
2803
2804Associative arrays are created using
2805<B>declare -A </B><I>name</I>.
2806
2807<P>
2808
2809Attributes may be
2810specified for an array variable using the
2811<B>declare</B>
2812
2813and
2814<B>readonly</B>
2815
2816builtins. Each attribute applies to all members of an array.
2817<P>
2818
2819Arrays are assigned to using compound assignments of the form
2820<I>name</I>=<B>(</B>value<I>1</I> ... value<I>n</I><B>)</B>, where each
2821<I>value</I> is of the form [<I>subscript</I>]=<I>string</I>.
2822Indexed array assignments do not require the bracket and subscript.
2823When assigning to indexed arrays, if the optional brackets and subscript
2824are supplied, that index is assigned to;
2825otherwise the index of the element assigned is the last index assigned
2826to by the statement plus one. Indexing starts at zero.
2827<P>
2828
2829When assigning to an associative array, the subscript is required.
2830<P>
2831
2832This syntax is also accepted by the
2833<B>declare</B>
2834
2835builtin. Individual array elements may be assigned to using the
2836<I>name</I>[<I>subscript</I>]=<I>value</I> syntax introduced above.
2837<P>
2838
2839Any element of an array may be referenced using
2840${<I>name</I>[<I>subscript</I>]}. The braces are required to avoid
2841conflicts with pathname expansion. If
2842<I>subscript</I> is <B>@</B> or <B>*</B>, the word expands to
2843all members of <I>name</I>. These subscripts differ only when the
2844word appears within double quotes. If the word is double-quoted,
2845${<I>name</I>[*]} expands to a single
2846word with the value of each array member separated by the first
2847character of the
2848<FONT SIZE=-1><B>IFS</B>
2849
2850</FONT>
2851special variable, and ${<I>name</I>[@]} expands each element of
2852<I>name</I> to a separate word. When there are no array members,
2853${<I>name</I>[@]} expands to nothing.
2854If the double-quoted expansion occurs within a word, the expansion of
2855the first parameter is joined with the beginning part of the original
2856word, and the expansion of the last parameter is joined with the last
2857part of the original word.
2858This is analogous to the expansion
2859of the special parameters <B>*</B> and <B>@</B> (see
2860<B>Special Parameters</B>
2861
2862above). ${#<I>name</I>[<I>subscript</I>]} expands to the length of
2863${<I>name</I>[<I>subscript</I>]}. If <I>subscript</I> is <B>*</B> or
2864<B>@</B>, the expansion is the number of elements in the array.
2865Referencing an array variable without a subscript is equivalent to
2866referencing the array with a subscript of 0.
2867<P>
2868
2869The
2870<B>unset</B>
2871
2872builtin is used to destroy arrays. <B>unset</B> <I>name</I>[<I>subscript</I>]
2873destroys the array element at index <I>subscript</I>.
2874Care must be taken to avoid unwanted side effects caused by filename
2875generation.
2876<B>unset</B> <I>name</I>, where <I>name</I> is an array, or
2877<B>unset</B> <I>name</I>[<I>subscript</I>], where
2878<I>subscript</I> is <B>*</B> or <B>@</B>, removes the entire array.
2879<P>
2880
2881The
2882<B>declare</B>,
2883
2884<B>local</B>,
2885
2886and
2887<B>readonly</B>
2888
2889builtins each accept a
2890<B>-a</B>
2891
2892option to specify an indexed array and a
2893<B>-A</B>
2894
2895option to specify an associative array.
2896The
2897<B>read</B>
2898
2899builtin accepts a
2900<B>-a</B>
2901
2902option to assign a list of words read from the standard input
2903to an array. The
2904<B>set</B>
2905
2906and
2907<B>declare</B>
2908
2909builtins display array values in a way that allows them to be
2910reused as assignments.
2911<A NAME="lbAY">&nbsp;</A>
2912<H3>EXPANSION</H3>
2913
2914Expansion is performed on the command line after it has been split into
2915words. There are seven kinds of expansion performed:
2916<I>brace expansion</I>,
2917
2918<I>tilde expansion</I>,
2919
2920<I>parameter and variable expansion</I>,
2921
2922<I>command substitution</I>,
2923
2924<I>arithmetic expansion</I>,
2925
2926<I>word splitting</I>,
2927
2928and
2929<I>pathname expansion</I>.
2930
2931<P>
2932
2933The order of expansions is: brace expansion, tilde expansion,
2934parameter, variable and arithmetic expansion and
2935command substitution
2936(done in a left-to-right fashion), word splitting, and pathname
2937expansion.
2938<P>
2939
2940On systems that can support it, there is an additional expansion
2941available: <I>process substitution</I>.
2942<P>
2943
2944Only brace expansion, word splitting, and pathname expansion
2945can change the number of words of the expansion; other expansions
2946expand a single word to a single word.
2947The only exceptions to this are the expansions of
2948&quot;<B>$@</B>&quot; and &quot;<B>${</B><I>name</I><B>[@]}</B>&quot;
2949as explained above (see
2950<FONT SIZE=-1><B>PARAMETERS</B>).
2951
2952</FONT>
2953<A NAME="lbAZ">&nbsp;</A>
2954<H4>Brace Expansion</H4>
2955
2956<P>
2957
2958<I>Brace expansion</I>
2959
2960is a mechanism by which arbitrary strings
2961may be generated. This mechanism is similar to
2962<I>pathname expansion</I>, but the filenames generated
2963need not exist. Patterns to be brace expanded take
2964the form of an optional
2965<I>preamble</I>,
2966
2967followed by either a series of comma-separated strings or
2968a sequence expression between a pair of braces, followed by
2969an optional
2970<I>postscript</I>.
2971
2972The preamble is prefixed to each string contained
2973within the braces, and the postscript is then appended
2974to each resulting string, expanding left to right.
2975<P>
2976
2977Brace expansions may be nested. The results of each expanded
2978string are not sorted; left to right order is preserved.
2979For example, a<B>{</B>d,c,b<B>}</B>e expands into `ade ace abe'.
2980<P>
2981
2982A sequence expression takes the form
2983<B>{</B><I>x</I><B>..</B><I>y</I><B>[..</B><I>incr</I><B>]}</B>,
2984where <I>x</I> and <I>y</I> are either integers or single characters,
2985and <I>incr</I>, an optional increment, is an integer.
2986When integers are supplied, the expression expands to each number between
2987<I>x</I> and <I>y</I>, inclusive.
2988Supplied integers may be prefixed with <I>0</I> to force each term to have the
2989same width. When either <I>x</I> or y begins with a zero, the shell
2990attempts to force all generated terms to contain the same number of digits,
2991zero-padding where necessary.
2992When characters are supplied, the expression expands to each character
2993lexicographically between <I>x</I> and <I>y</I>, inclusive. Note that
2994both <I>x</I> and <I>y</I> must be of the same type.
2995When the increment is supplied, it is used as the difference between
2996each term. The default increment is 1 or -1 as appropriate.
2997<P>
2998
2999Brace expansion is performed before any other expansions,
3000and any characters special to other expansions are preserved
3001in the result. It is strictly textual.
3002<B>Bash</B>
3003
3004does not apply any syntactic interpretation to the context of the
3005expansion or the text between the braces.
3006<P>
3007
3008A correctly-formed brace expansion must contain unquoted opening
3009and closing braces, and at least one unquoted comma or a valid
3010sequence expression.
3011Any incorrectly formed brace expansion is left unchanged.
3012A <B>{</B> or <B>,</B> may be quoted with a backslash to prevent its
3013being considered part of a brace expression.
3014To avoid conflicts with parameter expansion, the string <B>${</B>
3015is not considered eligible for brace expansion.
3016<P>
3017
3018This construct is typically used as shorthand when the common
3019prefix of the strings to be generated is longer than in the
3020above example:
3021<DL COMPACT><DT><DD>
3022<P>
3023
3024mkdir /usr/local/src/bash/{old,new,dist,bugs}
3025</DL>
3026
3027or
3028<DL COMPACT><DT><DD>
3029chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
3030</DL>
3031
3032<P>
3033
3034Brace expansion introduces a slight incompatibility with
3035historical versions of
3036<B>sh</B>.
3037
3038<B>sh</B>
3039
3040does not treat opening or closing braces specially when they
3041appear as part of a word, and preserves them in the output.
3042<B>Bash</B>
3043
3044removes braces from words as a consequence of brace
3045expansion. For example, a word entered to
3046<B>sh</B>
3047
3048as <I>file{1,2}</I>
3049appears identically in the output. The same word is
3050output as
3051<I>file1 file2</I>
3052
3053after expansion by
3054<B>bash</B>.
3055
3056If strict compatibility with
3057<B>sh</B>
3058
3059is desired, start
3060<B>bash</B>
3061
3062with the
3063<B>+B </B>
3064
3065option or disable brace expansion with the
3066<B>+B</B>
3067
3068option to the
3069<B>set</B>
3070
3071command (see
3072<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3073
3074</FONT>
3075below).
3076<A NAME="lbBA">&nbsp;</A>
3077<H4>Tilde Expansion</H4>
3078
3079<P>
3080
3081If a word begins with an unquoted tilde character (`<B>~</B>'), all of
3082the characters preceding the first unquoted slash (or all characters,
3083if there is no unquoted slash) are considered a <I>tilde-prefix</I>.
3084If none of the characters in the tilde-prefix are quoted, the
3085characters in the tilde-prefix following the tilde are treated as a
3086possible <I>login name</I>.
3087If this login name is the null string, the tilde is replaced with the
3088value of the shell parameter
3089<FONT SIZE=-1><B>HOME</B>.
3090
3091</FONT>
3092If
3093<FONT SIZE=-1><B>HOME</B>
3094
3095</FONT>
3096is unset, the home directory of the user executing the shell is
3097substituted instead.
3098Otherwise, the tilde-prefix is replaced with the home directory
3099associated with the specified login name.
3100<P>
3101
3102If the tilde-prefix is a `~+', the value of the shell variable
3103<FONT SIZE=-1><B>PWD</B>
3104
3105</FONT>
3106replaces the tilde-prefix.
3107If the tilde-prefix is a `~-', the value of the shell variable
3108<FONT SIZE=-1><B>OLDPWD</B>,
3109
3110</FONT>
3111if it is set, is substituted.
3112If the characters following the tilde in the tilde-prefix consist
3113of a number <I>N</I>, optionally prefixed
3114by a `+' or a `-', the tilde-prefix is replaced with the corresponding
3115element from the directory stack, as it would be displayed by the
3116<B>dirs</B>
3117
3118builtin invoked with the tilde-prefix as an argument.
3119If the characters following the tilde in the tilde-prefix consist of a
3120number without a leading `+' or `-', `+' is assumed.
3121<P>
3122
3123If the login name is invalid, or the tilde expansion fails, the word
3124is unchanged.
3125<P>
3126
3127Each variable assignment is checked for unquoted tilde-prefixes immediately
3128following a
3129<B>:</B>
3130
3131or the first
3132<B>=</B>.
3133
3134In these cases, tilde expansion is also performed.
3135Consequently, one may use file names with tildes in assignments to
3136<FONT SIZE=-1><B>PATH</B>,
3137
3138</FONT>
3139<FONT SIZE=-1><B>MAILPATH</B>,
3140
3141</FONT>
3142and
3143<FONT SIZE=-1><B>CDPATH</B>,
3144
3145</FONT>
3146and the shell assigns the expanded value.
3147<A NAME="lbBB">&nbsp;</A>
3148<H4>Parameter Expansion</H4>
3149
3150<P>
3151
3152The `<B>$</B>' character introduces parameter expansion,
3153command substitution, or arithmetic expansion. The parameter name
3154or symbol to be expanded may be enclosed in braces, which
3155are optional but serve to protect the variable to be expanded from
3156characters immediately following it which could be
3157interpreted as part of the name.
3158<P>
3159
3160When braces are used, the matching ending brace is the first `<B>}</B>'
3161not escaped by a backslash or within a quoted string, and not within an
3162embedded arithmetic expansion, command substitution, or parameter
3163expansion.
3164<P>
3165
3166
3167<DL COMPACT>
3168<DT>${<I>parameter</I>}<DD>
3169The value of <I>parameter</I> is substituted. The braces are required
3170when
3171<I>parameter</I>
3172
3173is a positional parameter with more than one digit,
3174or when
3175<I>parameter</I>
3176
3177is followed by a character which is not to be
3178interpreted as part of its name.
3179
3180</DL>
3181<P>
3182
3183If the first character of <I>parameter</I> is an exclamation point,
3184a level of variable indirection is introduced.
3185<B>Bash</B> uses the value of the variable formed from the rest of
3186<I>parameter</I> as the name of the variable; this variable is then
3187expanded and that value is used in the rest of the substitution, rather
3188than the value of <I>parameter</I> itself.
3189This is known as <I>indirect expansion</I>.
3190The exceptions to this are the expansions of ${!<I>prefix</I>*} and
3191${<B>!</B><I>name</I>[<I>@</I>]} described below.
3192The exclamation point must immediately follow the left brace in order to
3193introduce indirection.
3194<P>
3195
3196In each of the cases below, <I>word</I> is subject to tilde expansion,
3197parameter expansion, command substitution, and arithmetic expansion.
3198<P>
3199
3200When not performing substring expansion, using the forms documented below,
3201<B>bash</B> tests for a parameter that is unset or null. Omitting the colon
3202results in a test only for a parameter that is unset.
3203<P>
3204
3205
3206<DL COMPACT>
3207<DT>${<I>parameter</I><B>:-</B><I>word</I>}<DD>
3208<B>Use Default Values</B>. If
3209<I>parameter</I>
3210
3211is unset or null, the expansion of
3212<I>word</I>
3213
3214is substituted. Otherwise, the value of
3215<I>parameter</I>
3216
3217is substituted.
3218<DT>${<I>parameter</I><B>:=</B><I>word</I>}<DD>
3219<B>Assign Default Values</B>.
3220If
3221<I>parameter</I>
3222
3223is unset or null, the expansion of
3224<I>word</I>
3225
3226is assigned to
3227<I>parameter</I>.
3228
3229The value of
3230<I>parameter</I>
3231
3232is then substituted. Positional parameters and special parameters may
3233not be assigned to in this way.
3234<DT>${<I>parameter</I><B>:?</B><I>word</I>}<DD>
3235<B>Display Error if Null or Unset</B>.
3236If
3237<I>parameter</I>
3238
3239is null or unset, the expansion of <I>word</I> (or a message to that effect
3240if
3241<I>word</I>
3242
3243is not present) is written to the standard error and the shell, if it
3244is not interactive, exits. Otherwise, the value of <I>parameter</I> is
3245substituted.
3246<DT>${<I>parameter</I><B>:+</B><I>word</I>}<DD>
3247<B>Use Alternate Value</B>.
3248If
3249<I>parameter</I>
3250
3251is null or unset, nothing is substituted, otherwise the expansion of
3252<I>word</I>
3253
3254is substituted.
3255<DT>${<I>parameter</I><B>:</B><I>offset</I>}<DD>
3256
3257<DT>${<I>parameter</I><B>:</B><I>offset</I><B>:</B><I>length</I>}<DD>
3258
3259<B>Substring Expansion.</B>
3260Expands to up to <I>length</I> characters of <I>parameter</I>
3261starting at the character specified by <I>offset</I>.
3262If <I>length</I> is omitted, expands to the substring of
3263<I>parameter</I> starting at the character specified by <I>offset</I>.
3264<I>length</I> and <I>offset</I> are arithmetic expressions (see
3265<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
3266
3267</FONT>
3268below).
3269<I>length</I> must evaluate to a number greater than or equal to zero.
3270If <I>offset</I> evaluates to a number less than zero, the value
3271is used as an offset from the end of the value of <I>parameter</I>.
3272If <I>parameter</I> is <B>@</B>, the result is <I>length</I> positional
3273parameters beginning at <I>offset</I>.
3274If <I>parameter</I> is an indexed array name subscripted by @ or *,
3275the result is the <I>length</I>
3276members of the array beginning with ${<I>parameter</I>[<I>offset</I>]}.
3277A negative <I>offset</I> is taken relative to one greater than the maximum
3278index of the specified array.
3279Substring expansion applied to an associative array produces undefined
3280results.
3281Note that a negative offset must be separated from the colon by at least
3282one space to avoid being confused with the :- expansion.
3283Substring indexing is zero-based unless the positional parameters
3284are used, in which case the indexing starts at 1 by default.
3285If <I>offset</I> is 0, and the positional parameters are used, <B>$0</B> is
3286prefixed to the list.
3287<DT>${<B>!</B><I>prefix</I><B>*</B>}<DD>
3288
3289<DT>${<B>!</B><I>prefix</I><B>@</B>}<DD>
3290
3291<B>Names matching prefix.</B>
3292Expands to the names of variables whose names begin with <I>prefix</I>,
3293separated by the first character of the
3294<FONT SIZE=-1><B>IFS</B>
3295
3296</FONT>
3297special variable.
3298When <I>@</I> is used and the expansion appears within double quotes, each
3299variable name expands to a separate word.
3300<DT>${<B>!</B><I>name</I>[<I>@</I>]}<DD>
3301
3302<DT>${<B>!</B><I>name</I>[<I>*</I>]}<DD>
3303
3304<B>List of array keys.</B>
3305If <I>name</I> is an array variable, expands to the list of array indices
3306(keys) assigned in <I>name</I>.
3307If <I>name</I> is not an array, expands to 0 if <I>name</I> is set and null
3308otherwise.
3309When <I>@</I> is used and the expansion appears within double quotes, each
3310key expands to a separate word.
3311<DT>${<B>#</B><I>parameter</I>}<DD>
3312<B>Parameter length.</B>
3313The length in characters of the value of <I>parameter</I> is substituted.
3314If
3315<I>parameter</I>
3316
3317is
3318<B>*</B>
3319
3320or
3321<B>@</B>,
3322
3323the value substituted is the number of positional parameters.
3324If
3325<I>parameter</I>
3326
3327is an array name subscripted by
3328<B>*</B>
3329
3330or
3331<B>@</B>,
3332
3333the value substituted is the number of elements in the array.
3334<DT>${<I>parameter</I><B>#</B><I>word</I>}<DD>
3335
3336<DT>${<I>parameter</I><B>##</B><I>word</I>}<DD>
3337
3338<B>Remove matching prefix pattern.</B>
3339The
3340<I>word</I>
3341
3342is expanded to produce a pattern just as in pathname
3343expansion. If the pattern matches the beginning of
3344the value of
3345<I>parameter</I>,
3346
3347then the result of the expansion is the expanded value of
3348<I>parameter</I>
3349
3350with the shortest matching pattern (the ``<B>#</B>'' case) or the
3351longest matching pattern (the ``<B>##</B>'' case) deleted.
3352If
3353<I>parameter</I>
3354
3355is
3356<B>@</B>
3357
3358or
3359<B>*</B>,
3360
3361the pattern removal operation is applied to each positional
3362parameter in turn, and the expansion is the resultant list.
3363If
3364<I>parameter</I>
3365
3366is an array variable subscripted with
3367<B>@</B>
3368
3369or
3370<B>*</B>,
3371
3372the pattern removal operation is applied to each member of the
3373array in turn, and the expansion is the resultant list.
3374<DT>${<I>parameter</I><B>%</B><I>word</I>}<DD>
3375
3376<DT>${<I>parameter</I><B>%%</B><I>word</I>}<DD>
3377
3378<B>Remove matching suffix pattern.</B>
3379The <I>word</I> is expanded to produce a pattern just as in
3380pathname expansion.
3381If the pattern matches a trailing portion of the expanded value of
3382<I>parameter</I>,
3383
3384then the result of the expansion is the expanded value of
3385<I>parameter</I>
3386
3387with the shortest matching pattern (the ``<B>%</B>'' case) or the
3388longest matching pattern (the ``<B>%%</B>'' case) deleted.
3389If
3390<I>parameter</I>
3391
3392is
3393<B>@</B>
3394
3395or
3396<B>*</B>,
3397
3398the pattern removal operation is applied to each positional
3399parameter in turn, and the expansion is the resultant list.
3400If
3401<I>parameter</I>
3402
3403is an array variable subscripted with
3404<B>@</B>
3405
3406or
3407<B>*</B>,
3408
3409the pattern removal operation is applied to each member of the
3410array in turn, and the expansion is the resultant list.
3411<DT>${<I>parameter</I><B>/</B><I>pattern</I><B>/</B><I>string</I>}<DD>
3412<B>Pattern substitution.</B>
3413The <I>pattern</I> is expanded to produce a pattern just as in
3414pathname expansion.
3415<I>Parameter</I> is expanded and the longest match of <I>pattern</I>
3416against its value is replaced with <I>string</I>.
3417If <I>pattern</I> begins with <B>/</B>, all matches of <I>pattern</I> are
3418replaced with <I>string</I>. Normally only the first match is replaced.
3419If <I>pattern</I> begins with <B>#</B>, it must match at the beginning
3420of the expanded value of <I>parameter</I>.
3421If <I>pattern</I> begins with <B>%</B>, it must match at the end
3422of the expanded value of <I>parameter</I>.
3423If <I>string</I> is null, matches of <I>pattern</I> are deleted
3424and the <B>/</B> following <I>pattern</I> may be omitted.
3425If
3426<I>parameter</I>
3427
3428is
3429<B>@</B>
3430
3431or
3432<B>*</B>,
3433
3434the substitution operation is applied to each positional
3435parameter in turn, and the expansion is the resultant list.
3436If
3437<I>parameter</I>
3438
3439is an array variable subscripted with
3440<B>@</B>
3441
3442or
3443<B>*</B>,
3444
3445the substitution operation is applied to each member of the
3446array in turn, and the expansion is the resultant list.
3447<DT>${<I>parameter</I><B>^</B><I>pattern</I>}<DD>
3448
3449<DT>${<I>parameter</I><B>^^</B><I>pattern</I>}<DD>
3450<DT>${<I>parameter</I><B>,</B><I>pattern</I>}<DD>
3451<DT>${<I>parameter</I><B>,,</B><I>pattern</I>}<DD>
3452
3453<B>Case modification.</B>
3454This expansion modifies the case of alphabetic characters in <I>parameter</I>.
3455The <I>pattern</I> is expanded to produce a pattern just as in
3456pathname expansion.
3457The <B>^</B> operator converts lowercase letters matching <I>pattern</I>
3458to uppercase; the <B>,</B> operator converts matching uppercase letters
3459to lowercase.
3460The <B>^^</B> and <B>,,</B> expansions convert each matched character in the
3461expanded value; the <B>^</B> and <B>,</B> expansions match and convert only
3462the first character in the expanded value..
3463If <I>pattern</I> is omitted, it is treated like a <B>?</B>, which matches
3464every character.
3465If
3466<I>parameter</I>
3467
3468is
3469<B>@</B>
3470
3471or
3472<B>*</B>,
3473
3474the case modification operation is applied to each positional
3475parameter in turn, and the expansion is the resultant list.
3476If
3477<I>parameter</I>
3478
3479is an array variable subscripted with
3480<B>@</B>
3481
3482or
3483<B>*</B>,
3484
3485the case modification operation is applied to each member of the
3486array in turn, and the expansion is the resultant list.
3487</DL>
3488<A NAME="lbBC">&nbsp;</A>
3489<H4>Command Substitution</H4>
3490
3491<P>
3492
3493<I>Command substitution</I> allows the output of a command to replace
3494the command name. There are two forms:
3495<P>
3496
3497<DL COMPACT><DT><DD>
3498<P>
3499
3500<B>$(</B><I>command</I><B>)</B>
3501</DL>
3502
3503or
3504<DL COMPACT><DT><DD>
3505<B>`</B><I>command</I><B>`</B>
3506</DL>
3507
3508<P>
3509
3510<B>Bash</B>
3511
3512performs the expansion by executing <I>command</I> and
3513replacing the command substitution with the standard output of the
3514command, with any trailing newlines deleted.
3515Embedded newlines are not deleted, but they may be removed during
3516word splitting.
3517The command substitution <B>$(cat </B><I>file</I>) can be replaced by
3518the equivalent but faster <B>$(&lt; </B><I>file</I>).
3519<P>
3520
3521When the old-style backquote form of substitution is used,
3522backslash retains its literal meaning except when followed by
3523<B>$</B>,
3524
3525<B>`</B>,
3526
3527or
3528<B>\</B>.
3529
3530The first backquote not preceded by a backslash terminates the
3531command substitution.
3532When using the $(<I>command</I>) form, all characters between the
3533parentheses make up the command; none are treated specially.
3534<P>
3535
3536Command substitutions may be nested. To nest when using the backquoted form,
3537escape the inner backquotes with backslashes.
3538<P>
3539
3540If the substitution appears within double quotes, word splitting and
3541pathname expansion are not performed on the results.
3542<A NAME="lbBD">&nbsp;</A>
3543<H4>Arithmetic Expansion</H4>
3544
3545<P>
3546
3547Arithmetic expansion allows the evaluation of an arithmetic expression
3548and the substitution of the result. The format for arithmetic expansion is:
3549<DL COMPACT><DT><DD>
3550<P>
3551
3552<B>$((</B><I>expression</I><B>))</B>
3553</DL>
3554
3555<P>
3556
3557The
3558<I>expression</I>
3559
3560is treated as if it were within double quotes, but a double quote
3561inside the parentheses is not treated specially.
3562All tokens in the expression undergo parameter expansion, string
3563expansion, command substitution, and quote removal.
3564Arithmetic expansions may be nested.
3565<P>
3566
3567The evaluation is performed according to the rules listed below under
3568<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
3569
3570</FONT>
3571If
3572<I>expression</I>
3573
3574is invalid,
3575<B>bash</B>
3576
3577prints a message indicating failure and no substitution occurs.
3578<A NAME="lbBE">&nbsp;</A>
3579<H4>Process Substitution</H4>
3580
3581<P>
3582
3583<I>Process substitution</I> is supported on systems that support named
3584pipes (<I>FIFOs</I>) or the <B>/dev/fd</B> method of naming open files.
3585It takes the form of
3586<B>&lt;(</B><I>list</I><B>)</B>
3587or
3588<B>&gt;(</B><I>list</I><B>)</B>.
3589The process <I>list</I> is run with its input or output connected to a
3590<I>FIFO</I> or some file in <B>/dev/fd</B>. The name of this file is
3591passed as an argument to the current command as the result of the
3592expansion. If the <B>&gt;(</B><I>list</I><B>)</B> form is used, writing to
3593the file will provide input for <I>list</I>. If the
3594<B>&lt;(</B><I>list</I><B>)</B> form is used, the file passed as an
3595argument should be read to obtain the output of <I>list</I>.
3596<P>
3597
3598When available, process substitution is performed
3599simultaneously with parameter and variable expansion,
3600command substitution,
3601and arithmetic expansion.
3602<A NAME="lbBF">&nbsp;</A>
3603<H4>Word Splitting</H4>
3604
3605<P>
3606
3607The shell scans the results of
3608parameter expansion,
3609command substitution,
3610and
3611arithmetic expansion
3612that did not occur within double quotes for
3613<I>word splitting</I>.
3614
3615<P>
3616
3617The shell treats each character of
3618<FONT SIZE=-1><B>IFS</B>
3619
3620</FONT>
3621as a delimiter, and splits the results of the other
3622expansions into words on these characters. If
3623<FONT SIZE=-1><B>IFS</B>
3624
3625</FONT>
3626is unset, or its
3627value is exactly
3628<B>&lt;space&gt;&lt;tab&gt;&lt;newline&gt;</B>,
3629
3630the default, then
3631sequences of
3632<B>&lt;space&gt;</B>,
3633
3634<B>&lt;tab&gt;</B>,
3635
3636and
3637<B>&lt;newline&gt;</B>
3638
3639at the beginning and end of the results of the previous
3640expansions are ignored, and
3641any sequence of
3642<FONT SIZE=-1><B>IFS</B>
3643
3644</FONT>
3645characters not at the beginning or end serves to delimit words.
3646If
3647<FONT SIZE=-1><B>IFS</B>
3648
3649</FONT>
3650has a value other than the default, then sequences of
3651the whitespace characters
3652<B>space</B>
3653
3654and
3655<B>tab</B>
3656
3657are ignored at the beginning and end of the
3658word, as long as the whitespace character is in the
3659value of
3660<FONT SIZE=-1><B>IFS</B>
3661
3662</FONT>
3663(an
3664<FONT SIZE=-1><B>IFS</B>
3665
3666</FONT>
3667whitespace character).
3668Any character in
3669<FONT SIZE=-1><B>IFS</B>
3670
3671</FONT>
3672that is not
3673<FONT SIZE=-1><B>IFS</B>
3674
3675</FONT>
3676whitespace, along with any adjacent
3677<FONT SIZE=-1><B>IFS</B>
3678
3679</FONT>
3680whitespace characters, delimits a field.
3681A sequence of
3682<FONT SIZE=-1><B>IFS</B>
3683
3684</FONT>
3685whitespace characters is also treated as a delimiter.
3686If the value of
3687<FONT SIZE=-1><B>IFS</B>
3688
3689</FONT>
3690is null, no word splitting occurs.
3691<P>
3692
3693Explicit null arguments (<B>&quot;&quot;</B> or <B>aqaq</B>) are retained.
3694Unquoted implicit null arguments, resulting from the expansion of
3695parameters that have no values, are removed.
3696If a parameter with no value is expanded within double quotes, a
3697null argument results and is retained.
3698<P>
3699
3700Note that if no expansion occurs, no splitting
3701is performed.
3702<A NAME="lbBG">&nbsp;</A>
3703<H4>Pathname Expansion</H4>
3704
3705<P>
3706
3707After word splitting,
3708unless the
3709<B>-f</B>
3710
3711option has been set,
3712<B>bash</B>
3713
3714scans each word for the characters
3715<B>*</B>,
3716
3717<B>?</B>,
3718
3719and
3720<B>[</B>.
3721
3722If one of these characters appears, then the word is
3723regarded as a
3724<I>pattern</I>,
3725
3726and replaced with an alphabetically sorted list of
3727file names matching the pattern.
3728If no matching file names are found,
3729and the shell option
3730<B>nullglob</B>
3731
3732is not enabled, the word is left unchanged.
3733If the
3734<B>nullglob</B>
3735
3736option is set, and no matches are found,
3737the word is removed.
3738If the
3739<B>failglob</B>
3740
3741shell option is set, and no matches are found, an error message
3742is printed and the command is not executed.
3743If the shell option
3744<B>nocaseglob</B>
3745
3746is enabled, the match is performed without regard to the case
3747of alphabetic characters.
3748When a pattern is used for pathname expansion,
3749the character
3750<B>``.''</B>
3751
3752at the start of a name or immediately following a slash
3753must be matched explicitly, unless the shell option
3754<B>dotglob</B>
3755
3756is set.
3757When matching a pathname, the slash character must always be
3758matched explicitly.
3759In other cases, the
3760<B>``.''</B>
3761
3762character is not treated specially.
3763See the description of
3764<B>shopt</B>
3765
3766below under
3767<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3768
3769</FONT>
3770for a description of the
3771<B>nocaseglob</B>,
3772
3773<B>nullglob</B>,
3774
3775<B>failglob</B>,
3776
3777and
3778<B>dotglob</B>
3779
3780shell options.
3781<P>
3782
3783The
3784<FONT SIZE=-1><B>GLOBIGNORE</B>
3785
3786</FONT>
3787shell variable may be used to restrict the set of file names matching a
3788<I>pattern</I>.
3789
3790If
3791<FONT SIZE=-1><B>GLOBIGNORE</B>
3792
3793</FONT>
3794is set, each matching file name that also matches one of the patterns in
3795<FONT SIZE=-1><B>GLOBIGNORE</B>
3796
3797</FONT>
3798is removed from the list of matches.
3799The file names
3800<B>``.''</B>
3801
3802and
3803<B>``..''</B>
3804
3805are always ignored when
3806<FONT SIZE=-1><B>GLOBIGNORE</B>
3807
3808</FONT>
3809is set and not null. However, setting
3810<FONT SIZE=-1><B>GLOBIGNORE</B>
3811
3812</FONT>
3813to a non-null value has the effect of enabling the
3814<B>dotglob</B>
3815
3816shell option, so all other file names beginning with a
3817<B>``.''</B>
3818
3819will match.
3820To get the old behavior of ignoring file names beginning with a
3821<B>``.''</B>,
3822
3823make
3824<B>``.*''</B>
3825
3826one of the patterns in
3827<FONT SIZE=-1><B>GLOBIGNORE</B>.
3828
3829</FONT>
3830The
3831<B>dotglob</B>
3832
3833option is disabled when
3834<FONT SIZE=-1><B>GLOBIGNORE</B>
3835
3836</FONT>
3837is unset.
3838<P>
3839
3840<B>Pattern Matching</B>
3841<P>
3842
3843Any character that appears in a pattern, other than the special pattern
3844characters described below, matches itself. The NUL character may not
3845occur in a pattern. A backslash escapes the following character; the
3846escaping backslash is discarded when matching.
3847The special pattern characters must be quoted if
3848they are to be matched literally.
3849<P>
3850
3851The special pattern characters have the following meanings:
3852<P>
3853
3854
3855<DL COMPACT>
3856<DT><B>*</B>
3857
3858<DD>
3859Matches any string, including the null string.
3860When the <B>globstar</B> shell option is enabled, and <B>*</B> is used in
3861a filename expansion context, two adjacent <B>*</B>s used as a single
3862pattern will match all files and zero or more directories and
3863subdirectories.
3864If followed by a <B>/</B>, two adjacent <B>*</B>s will match only directories
3865and subdirectories.
3866<DT><B>?</B>
3867
3868<DD>
3869Matches any single character.
3870<DT><B>[...]</B>
3871
3872<DD>
3873Matches any one of the enclosed characters. A pair of characters
3874separated by a hyphen denotes a
3875<I>range expression</I>;
3876any character that sorts between those two characters, inclusive,
3877using the current locale's collating sequence and character set,
3878is matched. If the first character following the
3879<B>[</B>
3880
3881is a
3882<B>!</B>
3883
3884or a
3885<B>^</B>
3886
3887then any character not enclosed is matched.
3888The sorting order of characters in range expressions is determined by
3889the current locale and the value of the <B>LC_COLLATE</B> shell variable,
3890if set.
3891A
3892<B>-</B>
3893
3894may be matched by including it as the first or last character
3895in the set.
3896A
3897<B>]</B>
3898
3899may be matched by including it as the first character
3900in the set.
3901<BR>
3902
3903<P>
3904
3905
3906Within
3907<B>[</B>
3908
3909and
3910<B>]</B>,
3911
3912<I>character classes</I> can be specified using the syntax
3913<B>[:</B><I>class</I><B>:]</B>, where <I>class</I> is one of the
3914following classes defined in the POSIX standard:
3915</DL>
3916<P>
3917
3918<DL COMPACT><DT><DD>
3919<B>
3920</B>
3921
3922alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
3923<BR>
3924
3925A character class matches any character belonging to that class.
3926The <B>word</B> character class matches letters, digits, and the character _.
3927<BR>
3928
3929<P>
3930
3931
3932Within
3933<B>[</B>
3934
3935and
3936<B>]</B>,
3937
3938an <I>equivalence class</I> can be specified using the syntax
3939<B>[=</B><I>c</I><B>=]</B>, which matches all characters with the
3940same collation weight (as defined by the current locale) as
3941the character <I>c</I>.
3942<BR>
3943
3944<P>
3945
3946
3947Within
3948<B>[</B>
3949
3950and
3951<B>]</B>,
3952
3953the syntax <B>[.</B><I>symbol</I><B>.]</B> matches the collating symbol
3954<I>symbol</I>.
3955</DL>
3956
3957
3958<P>
3959
3960If the <B>extglob</B> shell option is enabled using the <B>shopt</B>
3961builtin, several extended pattern matching operators are recognized.
3962In the following description, a <I>pattern-list</I> is a list of one
3963or more patterns separated by a <B>|</B>.
3964Composite patterns may be formed using one or more of the following
3965sub-patterns:
3966<P>
3967
3968<DL COMPACT><DT><DD>
3969<DL COMPACT>
3970<DT><B>?(</B><I>pattern-list</I><B>)</B><DD>
3971Matches zero or one occurrence of the given patterns
3972<DT><B>*(</B><I>pattern-list</I><B>)</B><DD>
3973Matches zero or more occurrences of the given patterns
3974<DT><B>+(</B><I>pattern-list</I><B>)</B><DD>
3975Matches one or more occurrences of the given patterns
3976<DT><B>@(</B><I>pattern-list</I><B>)</B><DD>
3977Matches one of the given patterns
3978<DT><B>!(</B><I>pattern-list</I><B>)</B><DD>
3979Matches anything except one of the given patterns
3980</DL></DL>
3981
3982
3983<A NAME="lbBH">&nbsp;</A>
3984<H4>Quote Removal</H4>
3985
3986<P>
3987
3988After the preceding expansions, all unquoted occurrences of the
3989characters
3990<B>\</B>,
3991
3992<B>aq</B>,
3993
3994and <B>&quot;</B> that did not result from one of the above
3995expansions are removed.
3996<A NAME="lbBI">&nbsp;</A>
3997<H3>REDIRECTION</H3>
3998
3999Before a command is executed, its input and output
4000may be
4001<I>redirected</I>
4002
4003using a special notation interpreted by the shell.
4004Redirection may also be used to open and close files for the
4005current shell execution environment. The following redirection
4006operators may precede or appear anywhere within a
4007<I>simple command</I>
4008
4009or may follow a
4010<I>command</I>.
4011
4012Redirections are processed in the order they appear, from
4013left to right.
4014<P>
4015
4016In the following descriptions, if the file descriptor number is
4017omitted, and the first character of the redirection operator is
4018<B>&lt;</B>,
4019
4020the redirection refers to the standard input (file descriptor
40210). If the first character of the redirection operator is
4022<B>&gt;</B>,
4023
4024the redirection refers to the standard output (file descriptor
40251).
4026<P>
4027
4028The word following the redirection operator in the following
4029descriptions, unless otherwise noted, is subjected to brace expansion,
4030tilde expansion, parameter expansion, command substitution, arithmetic
4031expansion, quote removal, pathname expansion, and word splitting.
4032If it expands to more than one word,
4033<B>bash</B>
4034
4035reports an error.
4036<P>
4037
4038Note that the order of redirections is significant. For example,
4039the command
4040<DL COMPACT><DT><DD>
4041<P>
4042
4043ls <B>&gt;</B> dirlist 2<B>&gt;&amp;</B>1
4044</DL>
4045
4046<P>
4047
4048directs both standard output and standard error to the file
4049<I>dirlist</I>,
4050
4051while the command
4052<DL COMPACT><DT><DD>
4053<P>
4054
4055ls 2<B>&gt;&amp;</B>1 <B>&gt;</B> dirlist
4056</DL>
4057
4058<P>
4059
4060directs only the standard output to file
4061<I>dirlist</I>,
4062
4063because the standard error was duplicated as standard output
4064before the standard output was redirected to
4065<I>dirlist</I>.
4066
4067<P>
4068
4069<B>Bash</B> handles several filenames specially when they are used in
4070redirections, as described in the following table:
4071<DL COMPACT><DT><DD>
4072<P>
4073
4074
4075<DL COMPACT>
4076<DT><B>/dev/fd/</B><I>fd</I>
4077
4078<DD>
4079If <I>fd</I> is a valid integer, file descriptor <I>fd</I> is duplicated.
4080<DT><B>/dev/stdin</B>
4081
4082<DD>
4083File descriptor 0 is duplicated.
4084<DT><B>/dev/stdout</B>
4085
4086<DD>
4087File descriptor 1 is duplicated.
4088<DT><B>/dev/stderr</B>
4089
4090<DD>
4091File descriptor 2 is duplicated.
4092<DT><B>/dev/tcp/</B><I>host</I>/<I>port</I>
4093
4094<DD>
4095If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
4096is an integer port number or service name, <B>bash</B> attempts to open
4097a TCP connection to the corresponding socket.
4098<DT><B>/dev/udp/</B><I>host</I>/<I>port</I>
4099
4100<DD>
4101If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
4102is an integer port number or service name, <B>bash</B> attempts to open
4103a UDP connection to the corresponding socket.
4104
4105</DL></DL>
4106
4107<P>
4108
4109A failure to open or create a file causes the redirection to fail.
4110<P>
4111
4112Redirections using file descriptors greater than 9 should be used with
4113care, as they may conflict with file descriptors the shell uses
4114internally.
4115<A NAME="lbBJ">&nbsp;</A>
4116<H4>Redirecting Input</H4>
4117
4118<P>
4119
4120Redirection of input causes the file whose name results from
4121the expansion of
4122<I>word</I>
4123
4124to be opened for reading on file descriptor
4125<I>n</I>,
4126
4127or the standard input (file descriptor 0) if
4128<I>n</I>
4129
4130is not specified.
4131<P>
4132
4133The general format for redirecting input is:
4134<DL COMPACT><DT><DD>
4135<P>
4136
4137[<I>n</I>]<B>&lt;</B><I>word</I>
4138</DL>
4139
4140<A NAME="lbBK">&nbsp;</A>
4141<H4>Redirecting Output</H4>
4142
4143<P>
4144
4145Redirection of output causes the file whose name results from
4146the expansion of
4147<I>word</I>
4148
4149to be opened for writing on file descriptor
4150<I>n</I>,
4151
4152or the standard output (file descriptor 1) if
4153<I>n</I>
4154
4155is not specified. If the file does not exist it is created;
4156if it does exist it is truncated to zero size.
4157<P>
4158
4159The general format for redirecting output is:
4160<DL COMPACT><DT><DD>
4161<P>
4162
4163[<I>n</I>]<B>&gt;</B><I>word</I>
4164</DL>
4165
4166<P>
4167
4168If the redirection operator is
4169<B>&gt;</B>,
4170
4171and the
4172<B>noclobber</B>
4173
4174option to the
4175<B>set</B>
4176
4177builtin has been enabled, the redirection will fail if the file
4178whose name results from the expansion of <I>word</I> exists and is
4179a regular file.
4180If the redirection operator is
4181<B>&gt;|</B>,
4182
4183or the redirection operator is
4184<B>&gt;</B>
4185
4186and the
4187<B>noclobber</B>
4188
4189option to the
4190<B>set</B>
4191
4192builtin command is not enabled, the redirection is attempted even
4193if the file named by <I>word</I> exists.
4194<A NAME="lbBL">&nbsp;</A>
4195<H4>Appending Redirected Output</H4>
4196
4197<P>
4198
4199Redirection of output in this fashion
4200causes the file whose name results from
4201the expansion of
4202<I>word</I>
4203
4204to be opened for appending on file descriptor
4205<I>n</I>,
4206
4207or the standard output (file descriptor 1) if
4208<I>n</I>
4209
4210is not specified. If the file does not exist it is created.
4211<P>
4212
4213The general format for appending output is:
4214<DL COMPACT><DT><DD>
4215<P>
4216
4217[<I>n</I>]<B>&gt;&gt;</B><I>word</I>
4218</DL>
4219
4220<P>
4221
4222<A NAME="lbBM">&nbsp;</A>
4223<H4>Redirecting Standard Output and Standard Error</H4>
4224
4225<P>
4226
4227This construct allows both the
4228standard output (file descriptor 1) and
4229the standard error output (file descriptor 2)
4230to be redirected to the file whose name is the
4231expansion of
4232<I>word</I>.
4233
4234<P>
4235
4236There are two formats for redirecting standard output and
4237standard error:
4238<DL COMPACT><DT><DD>
4239<P>
4240
4241<B>&amp;&gt;</B><I>word</I>
4242</DL>
4243
4244and
4245<DL COMPACT><DT><DD>
4246<B>&gt;&amp;</B><I>word</I>
4247</DL>
4248
4249<P>
4250
4251Of the two forms, the first is preferred.
4252This is semantically equivalent to
4253<DL COMPACT><DT><DD>
4254<P>
4255
4256<B>&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
4257</DL>
4258
4259<P>
4260
4261<A NAME="lbBN">&nbsp;</A>
4262<H4>Appending Standard Output and Standard Error</H4>
4263
4264<P>
4265
4266This construct allows both the
4267standard output (file descriptor 1) and
4268the standard error output (file descriptor 2)
4269to be appended to the file whose name is the
4270expansion of
4271<I>word</I>.
4272
4273<P>
4274
4275The format for appending standard output and standard error is:
4276<DL COMPACT><DT><DD>
4277<P>
4278
4279<B>&amp;&gt;&gt;</B><I>word</I>
4280</DL>
4281
4282<P>
4283
4284This is semantically equivalent to
4285<DL COMPACT><DT><DD>
4286<P>
4287
4288<B>&gt;&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
4289</DL>
4290
4291<A NAME="lbBO">&nbsp;</A>
4292<H4>Here Documents</H4>
4293
4294<P>
4295
4296This type of redirection instructs the shell to read input from the
4297current source until a line containing only
4298<I>delimiter</I>
4299
4300(with no trailing blanks)
4301is seen. All of
4302the lines read up to that point are then used as the standard
4303input for a command.
4304<P>
4305
4306The format of here-documents is:
4307<DL COMPACT><DT><DD>
4308<P>
4309
4310<PRE>
4311<B>&lt;&lt;</B>[<B>-</B>]<I>word</I>
4312 <I>here-document</I>
4313<I>delimiter</I>
4314</PRE>
4315
4316</DL>
4317
4318<P>
4319
4320No parameter expansion, command substitution, arithmetic expansion,
4321or pathname expansion is performed on
4322<I>word</I>.
4323
4324If any characters in
4325<I>word</I>
4326
4327are quoted, the
4328<I>delimiter</I>
4329
4330is the result of quote removal on
4331<I>word</I>,
4332
4333and the lines in the here-document are not expanded.
4334If <I>word</I> is unquoted,
4335all lines of the here-document are subjected to parameter expansion,
4336command substitution, and arithmetic expansion. In the latter
4337case, the character sequence
4338<B>\&lt;newline&gt;</B>
4339
4340is ignored, and
4341<B>\</B>
4342
4343must be used to quote the characters
4344<B>\</B>,
4345
4346<B>$</B>,
4347
4348and
4349<B>`</B>.
4350
4351<P>
4352
4353If the redirection operator is
4354<B>&lt;&lt;-</B>,
4355
4356then all leading tab characters are stripped from input lines and the
4357line containing
4358<I>delimiter</I>.
4359
4360This allows
4361here-documents within shell scripts to be indented in a
4362natural fashion.
4363<A NAME="lbBP">&nbsp;</A>
4364<H4>Here Strings</H4>
4365
4366A variant of here documents, the format is:
4367<DL COMPACT><DT><DD>
4368<P>
4369
4370<PRE>
4371<B>&lt;&lt;&lt;</B><I>word</I>
4372</PRE>
4373
4374</DL>
4375
4376<P>
4377
4378The <I>word</I> is expanded and supplied to the command on its standard
4379input.
4380<A NAME="lbBQ">&nbsp;</A>
4381<H4>Duplicating File Descriptors</H4>
4382
4383<P>
4384
4385The redirection operator
4386<DL COMPACT><DT><DD>
4387<P>
4388
4389[<I>n</I>]<B>&lt;&amp;</B><I>word</I>
4390</DL>
4391
4392<P>
4393
4394is used to duplicate input file descriptors.
4395If
4396<I>word</I>
4397
4398expands to one or more digits, the file descriptor denoted by
4399<I>n</I>
4400
4401is made to be a copy of that file descriptor.
4402If the digits in
4403<I>word</I>
4404
4405do not specify a file descriptor open for input, a redirection error occurs.
4406If
4407<I>word</I>
4408
4409evaluates to
4410<B>-</B>,
4411
4412file descriptor
4413<I>n</I>
4414
4415is closed. If
4416<I>n</I>
4417
4418is not specified, the standard input (file descriptor 0) is used.
4419<P>
4420
4421The operator
4422<DL COMPACT><DT><DD>
4423<P>
4424
4425[<I>n</I>]<B>&gt;&amp;</B><I>word</I>
4426</DL>
4427
4428<P>
4429
4430is used similarly to duplicate output file descriptors. If
4431<I>n</I>
4432
4433is not specified, the standard output (file descriptor 1) is used.
4434If the digits in
4435<I>word</I>
4436
4437do not specify a file descriptor open for output, a redirection error occurs.
4438As a special case, if <I>n</I> is omitted, and <I>word</I> does not
4439expand to one or more digits, the standard output and standard
4440error are redirected as described previously.
4441<A NAME="lbBR">&nbsp;</A>
4442<H4>Moving File Descriptors</H4>
4443
4444<P>
4445
4446The redirection operator
4447<DL COMPACT><DT><DD>
4448<P>
4449
4450[<I>n</I>]<B>&lt;&amp;</B><I>digit</I><B>-</B>
4451</DL>
4452
4453<P>
4454
4455moves the file descriptor <I>digit</I> to file descriptor
4456<I>n</I>,
4457
4458or the standard input (file descriptor 0) if <I>n</I> is not specified.
4459<I>digit</I> is closed after being duplicated to <I>n</I>.
4460<P>
4461
4462Similarly, the redirection operator
4463<DL COMPACT><DT><DD>
4464<P>
4465
4466[<I>n</I>]<B>&gt;&amp;</B><I>digit</I><B>-</B>
4467</DL>
4468
4469<P>
4470
4471moves the file descriptor <I>digit</I> to file descriptor
4472<I>n</I>,
4473
4474or the standard output (file descriptor 1) if <I>n</I> is not specified.
4475<A NAME="lbBS">&nbsp;</A>
4476<H4>Opening File Descriptors for Reading and Writing</H4>
4477
4478<P>
4479
4480The redirection operator
4481<DL COMPACT><DT><DD>
4482<P>
4483
4484[<I>n</I>]<B>&lt;&gt;</B><I>word</I>
4485</DL>
4486
4487<P>
4488
4489causes the file whose name is the expansion of
4490<I>word</I>
4491
4492to be opened for both reading and writing on file descriptor
4493<I>n</I>,
4494
4495or on file descriptor 0 if
4496<I>n</I>
4497
4498is not specified. If the file does not exist, it is created.
4499<A NAME="lbBT">&nbsp;</A>
4500<H3>ALIASES</H3>
4501
4502<I>Aliases</I> allow a string to be substituted for a word when it is used
4503as the first word of a simple command.
4504The shell maintains a list of aliases that may be set and unset with the
4505<B>alias</B>
4506
4507and
4508<B>unalias</B>
4509
4510builtin commands (see
4511<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4512
4513</FONT>
4514below).
4515The first word of each simple command, if unquoted,
4516is checked to see if it has an
4517alias. If so, that word is replaced by the text of the alias.
4518The characters <B>/</B>, <B>$</B>, <B>`</B>, and <B>=</B> and
4519any of the shell <I>metacharacters</I> or quoting characters
4520listed above may not appear in an alias name.
4521The replacement text may contain any valid shell input,
4522including shell metacharacters.
4523The first word of the replacement text is tested
4524for aliases, but a word that is identical to an alias being expanded
4525is not expanded a second time.
4526This means that one may alias
4527<B>ls</B>
4528
4529to
4530<B>ls -F</B>,
4531
4532for instance, and
4533<B>bash</B>
4534
4535does not try to recursively expand the replacement text.
4536If the last character of the alias value is a
4537<I>blank</I>,
4538
4539then the next command
4540word following the alias is also checked for alias expansion.
4541<P>
4542
4543Aliases are created and listed with the
4544<B>alias</B>
4545
4546command, and removed with the
4547<B>unalias</B>
4548
4549command.
4550<P>
4551
4552There is no mechanism for using arguments in the replacement text.
4553If arguments are needed, a shell function should be used (see
4554<FONT SIZE=-1><B>FUNCTIONS</B>
4555
4556</FONT>
4557below).
4558<P>
4559
4560Aliases are not expanded when the shell is not interactive, unless
4561the
4562<B>expand_aliases</B>
4563
4564shell option is set using
4565<B>shopt</B>
4566
4567(see the description of
4568<B>shopt</B>
4569
4570under
4571<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B></FONT>
4572below).
4573<P>
4574
4575The rules concerning the definition and use of aliases are
4576somewhat confusing.
4577<B>Bash</B>
4578
4579always reads at least one complete line
4580of input before executing any
4581of the commands on that line. Aliases are expanded when a
4582command is read, not when it is executed. Therefore, an
4583alias definition appearing on the same line as another
4584command does not take effect until the next line of input is read.
4585The commands following the alias definition
4586on that line are not affected by the new alias.
4587This behavior is also an issue when functions are executed.
4588Aliases are expanded when a function definition is read,
4589not when the function is executed, because a function definition
4590is itself a compound command. As a consequence, aliases
4591defined in a function are not available until after that
4592function is executed. To be safe, always put
4593alias definitions on a separate line, and do not use
4594<B>alias</B>
4595
4596in compound commands.
4597<P>
4598
4599For almost every purpose, aliases are superseded by
4600shell functions.
4601<A NAME="lbBU">&nbsp;</A>
4602<H3>FUNCTIONS</H3>
4603
4604A shell function, defined as described above under
4605<FONT SIZE=-1><B>SHELL GRAMMAR</B>,
4606
4607</FONT>
4608stores a series of commands for later execution.
4609When the name of a shell function is used as a simple command name,
4610the list of commands associated with that function name is executed.
4611Functions are executed in the context of the
4612current shell; no new process is created to interpret
4613them (contrast this with the execution of a shell script).
4614When a function is executed, the arguments to the
4615function become the positional parameters
4616during its execution.
4617The special parameter
4618<B>#</B>
4619
4620is updated to reflect the change. Special parameter 0
4621is unchanged.
4622The first element of the
4623<FONT SIZE=-1><B>FUNCNAME</B>
4624
4625</FONT>
4626variable is set to the name of the function while the function
4627is executing.
4628All other aspects of the shell execution
4629environment are identical between a function and its caller
4630with the exception that the
4631<FONT SIZE=-1><B>DEBUG</B>
4632
4633</FONT>
4634and
4635<B>RETURN</B>
4636
4637traps (see the description of the
4638<B>trap</B>
4639
4640builtin under
4641<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4642
4643</FONT>
4644below) are not inherited unless the function has been given the
4645<B>trace</B> attribute (see the description of the
4646<FONT SIZE=-1><B>declare</B>
4647
4648</FONT>
4649builtin below) or the
4650<B>-o functrace</B> shell option has been enabled with
4651the <B>set</B> builtin
4652(in which case all functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps).
4653<P>
4654
4655Variables local to the function may be declared with the
4656<B>local</B>
4657
4658builtin command. Ordinarily, variables and their values
4659are shared between the function and its caller.
4660<P>
4661
4662If the builtin command
4663<B>return</B>
4664
4665is executed in a function, the function completes and
4666execution resumes with the next command after the function
4667call.
4668Any command associated with the <B>RETURN</B> trap is executed
4669before execution resumes.
4670When a function completes, the values of the
4671positional parameters and the special parameter
4672<B>#</B>
4673
4674are restored to the values they had prior to the function's
4675execution.
4676<P>
4677
4678Function names and definitions may be listed with the
4679<B>-f</B>
4680
4681option to the
4682<B>declare</B>
4683
4684or
4685<B>typeset</B>
4686
4687builtin commands. The
4688<B>-F</B>
4689
4690option to
4691<B>declare</B>
4692
4693or
4694<B>typeset</B>
4695
4696will list the function names only
4697(and optionally the source file and line number, if the <B>extdebug</B>
4698shell option is enabled).
4699Functions may be exported so that subshells
4700automatically have them defined with the
4701<B>-f</B>
4702
4703option to the
4704<B>export</B>
4705
4706builtin.
4707A function definition may be deleted using the <B>-f</B> option to
4708the
4709<B>unset</B>
4710
4711builtin.
4712Note that shell functions and variables with the same name may result
4713in multiple identically-named entries in the environment passed to the
4714shell's children.
4715Care should be taken in cases where this may cause a problem.
4716<P>
4717
4718Functions may be recursive. No limit is imposed on the number
4719of recursive calls.
4720<A NAME="lbBV">&nbsp;</A>
4721<H3>ARITHMETIC EVALUATION</H3>
4722
4723The shell allows arithmetic expressions to be evaluated, under
4724certain circumstances (see the <B>let</B> and <B>declare</B> builtin
4725commands and <B>Arithmetic Expansion</B>).
4726Evaluation is done in fixed-width integers with no check for overflow,
4727though division by 0 is trapped and flagged as an error.
4728The operators and their precedence, associativity, and values
4729are the same as in the C language.
4730The following list of operators is grouped into levels of
4731equal-precedence operators.
4732The levels are listed in order of decreasing precedence.
4733<P>
4734
4735
4736<DL COMPACT>
4737<DT><B></B><I>id</I>++ <I>id</I>--
4738
4739<DD>
4740variable post-increment and post-decrement
4741<DT><B>++</B><I>id</I> --<I>id</I>
4742
4743<DD>
4744variable pre-increment and pre-decrement
4745<DT><B>- +</B>
4746
4747<DD>
4748unary minus and plus
4749<DT><B>! ~</B>
4750
4751<DD>
4752logical and bitwise negation
4753<DT><B>**</B>
4754
4755<DD>
4756exponentiation
4757<DT><B>* / %</B>
4758
4759<DD>
4760multiplication, division, remainder
4761<DT><B>+ -</B>
4762
4763<DD>
4764addition, subtraction
4765<DT><B>&lt;&lt; &gt;&gt;</B>
4766
4767<DD>
4768left and right bitwise shifts
4769<DT><B>&lt;= &gt;= &lt; &gt;</B>
4770
4771<DD>
4772comparison
4773<DT><B>== !=</B>
4774
4775<DD>
4776equality and inequality
4777<DT><B>&amp;</B>
4778
4779<DD>
4780bitwise AND
4781<DT><B>^</B>
4782
4783<DD>
4784bitwise exclusive OR
4785<DT><B>|</B>
4786
4787<DD>
4788bitwise OR
4789<DT><B>&amp;&amp;</B>
4790
4791<DD>
4792logical AND
4793<DT><B>||</B>
4794
4795<DD>
4796logical OR
4797<DT><B></B><I>expr</I>?<I>expr</I>:<I>expr</I>
4798
4799<DD>
4800conditional operator
4801<DT><B>= *= /= %= += -= &lt;&lt;= &gt;&gt;= &amp;= ^= |=</B>
4802
4803<DD>
4804assignment
4805<DT><B></B><I>expr1</I> , <I>expr2</I>
4806
4807<DD>
4808comma
4809
4810</DL>
4811<P>
4812
4813Shell variables are allowed as operands; parameter expansion is
4814performed before the expression is evaluated.
4815Within an expression, shell variables may also be referenced by name
4816without using the parameter expansion syntax.
4817A shell variable that is null or unset evaluates to 0 when referenced
4818by name without using the parameter expansion syntax.
4819The value of a variable is evaluated as an arithmetic expression
4820when it is referenced, or when a variable which has been given the
4821<I>integer</I> attribute using <B>declare -i</B> is assigned a value.
4822A null value evaluates to 0.
4823A shell variable need not have its integer attribute
4824turned on to be used in an expression.
4825<P>
4826
4827Constants with a leading 0 are interpreted as octal numbers.
4828A leading 0x or 0X denotes hexadecimal.
4829Otherwise, numbers take the form [<I>base#</I>]n, where <I>base</I>
4830is a decimal number between 2 and 64 representing the arithmetic
4831base, and <I>n</I> is a number in that base.
4832If <I>base#</I> is omitted, then base 10 is used.
4833The digits greater than 9 are represented by the lowercase letters,
4834the uppercase letters, @, and _, in that order.
4835If <I>base</I> is less than or equal to 36, lowercase and uppercase
4836letters may be used interchangeably to represent numbers between 10
4837and 35.
4838<P>
4839
4840Operators are evaluated in order of precedence. Sub-expressions in
4841parentheses are evaluated first and may override the precedence
4842rules above.
4843<A NAME="lbBW">&nbsp;</A>
4844<H3>CONDITIONAL EXPRESSIONS</H3>
4845
4846Conditional expressions are used by the <B>[[</B> compound command and
4847the <B>test</B> and <B>[</B> builtin commands to test file attributes
4848and perform string and arithmetic comparisons.
4849Expressions are formed from the following unary or binary primaries.
4850If any <I>file</I> argument to one of the primaries is of the form
4851<I>/dev/fd/n</I>, then file descriptor <I>n</I> is checked.
4852If the <I>file</I> argument to one of the primaries is one of
4853<I>/dev/stdin</I>, <I>/dev/stdout</I>, or <I>/dev/stderr</I>, file
4854descriptor 0, 1, or 2, respectively, is checked.
4855<P>
4856
4857Unless otherwise specified, primaries that operate on files follow symbolic
4858links and operate on the target of the link, rather than the link itself.
4859<P>
4860
4861<DL COMPACT>
4862<DT><B>-a </B><I>file</I>
4863
4864<DD>
4865True if <I>file</I> exists.
4866<DT><B>-b </B><I>file</I>
4867
4868<DD>
4869True if <I>file</I> exists and is a block special file.
4870<DT><B>-c </B><I>file</I>
4871
4872<DD>
4873True if <I>file</I> exists and is a character special file.
4874<DT><B>-d </B><I>file</I>
4875
4876<DD>
4877True if <I>file</I> exists and is a directory.
4878<DT><B>-e </B><I>file</I>
4879
4880<DD>
4881True if <I>file</I> exists.
4882<DT><B>-f </B><I>file</I>
4883
4884<DD>
4885True if <I>file</I> exists and is a regular file.
4886<DT><B>-g </B><I>file</I>
4887
4888<DD>
4889True if <I>file</I> exists and is set-group-id.
4890<DT><B>-h </B><I>file</I>
4891
4892<DD>
4893True if <I>file</I> exists and is a symbolic link.
4894<DT><B>-k </B><I>file</I>
4895
4896<DD>
4897True if <I>file</I> exists and its ``sticky'' bit is set.
4898<DT><B>-p </B><I>file</I>
4899
4900<DD>
4901True if <I>file</I> exists and is a named pipe (FIFO).
4902<DT><B>-r </B><I>file</I>
4903
4904<DD>
4905True if <I>file</I> exists and is readable.
4906<DT><B>-s </B><I>file</I>
4907
4908<DD>
4909True if <I>file</I> exists and has a size greater than zero.
4910<DT><B>-t </B><I>fd</I>
4911
4912<DD>
4913True if file descriptor
4914<I>fd</I>
4915
4916is open and refers to a terminal.
4917<DT><B>-u </B><I>file</I>
4918
4919<DD>
4920True if <I>file</I> exists and its set-user-id bit is set.
4921<DT><B>-w </B><I>file</I>
4922
4923<DD>
4924True if <I>file</I> exists and is writable.
4925<DT><B>-x </B><I>file</I>
4926
4927<DD>
4928True if <I>file</I> exists and is executable.
4929<DT><B>-O </B><I>file</I>
4930
4931<DD>
4932True if <I>file</I> exists and is owned by the effective user id.
4933<DT><B>-G </B><I>file</I>
4934
4935<DD>
4936True if <I>file</I> exists and is owned by the effective group id.
4937<DT><B>-L </B><I>file</I>
4938
4939<DD>
4940True if <I>file</I> exists and is a symbolic link.
4941<DT><B>-S </B><I>file</I>
4942
4943<DD>
4944True if <I>file</I> exists and is a socket.
4945<DT><B>-N </B><I>file</I>
4946
4947<DD>
4948True if <I>file</I> exists and has been modified since it was last read.
4949<DT><I>file1</I> -<B>nt</B> <I>file2</I><DD>
4950True if <I>file1</I> is newer (according to modification date) than <I>file2</I>,
4951or if <I>file1</I> exists and file2 does not.
4952<DT><I>file1</I> -<B>ot</B> <I>file2</I><DD>
4953True if <I>file1</I> is older than <I>file2</I>, or if <I>file2</I> exists
4954and <I>file1</I> does not.
4955<DT><I>file1</I> <B>-ef</B> <I>file2</I><DD>
4956True if <I>file1</I> and <I>file2</I> refer to the same device and
4957inode numbers.
4958<DT><B>-o </B><I>optname</I>
4959
4960<DD>
4961True if shell option
4962<I>optname</I>
4963
4964is enabled.
4965See the list of options under the description of the
4966<B>-o</B>
4967
4968option to the
4969<B>set</B>
4970
4971builtin below.
4972<DT><B>-z </B><I>string</I>
4973
4974<DD>
4975True if the length of <I>string</I> is zero.
4976<DT><I>string</I><DD>
4977
4978<DT><B>-n </B><I>string</I>
4979
4980<DD>
4981
4982True if the length of
4983<I>string</I>
4984
4985is non-zero.
4986<DT><I>string1</I> <B>==</B> <I>string2</I><DD>
4987True if the strings are equal. <B>=</B> may be used in place of
4988<B>==</B> for strict POSIX compliance.
4989<DT><I>string1</I> <B>!=</B> <I>string2</I><DD>
4990True if the strings are not equal.
4991<DT><I>string1</I> <B>&lt;</B> <I>string2</I><DD>
4992True if <I>string1</I> sorts before <I>string2</I> lexicographically
4993in the current locale.
4994<DT><I>string1</I> <B>&gt;</B> <I>string2</I><DD>
4995True if <I>string1</I> sorts after <I>string2</I> lexicographically
4996in the current locale.
4997<DT><I>arg1</I> <B>OP</B> <I>arg2</I>
4998
4999<DD>
5000<FONT SIZE=-1><B>OP</B>
5001
5002</FONT>
5003is one of
5004<B>-eq</B>,
5005
5006<B>-ne</B>,
5007
5008<B>-lt</B>,
5009
5010<B>-le</B>,
5011
5012<B>-gt</B>,
5013
5014or
5015<B>-ge</B>.
5016
5017These arithmetic binary operators return true if <I>arg1</I>
5018is equal to, not equal to, less than, less than or equal to,
5019greater than, or greater than or equal to <I>arg2</I>, respectively.
5020<I>Arg1</I>
5021
5022and
5023<I>arg2</I>
5024
5025may be positive or negative integers.
5026
5027</DL>
5028<A NAME="lbBX">&nbsp;</A>
5029<H3>SIMPLE COMMAND EXPANSION</H3>
5030
5031When a simple command is executed, the shell performs the following
5032expansions, assignments, and redirections, from left to right.
5033<DL COMPACT>
5034<DT>1.<DD>
5035The words that the parser has marked as variable assignments (those
5036preceding the command name) and redirections are saved for later
5037processing.
5038<DT>2.<DD>
5039The words that are not variable assignments or redirections are
5040expanded. If any words remain after expansion, the first word
5041is taken to be the name of the command and the remaining words are
5042the arguments.
5043<DT>3.<DD>
5044Redirections are performed as described above under
5045<FONT SIZE=-1><B>REDIRECTION</B>.
5046
5047</FONT>
5048<DT>4.<DD>
5049The text after the <B>=</B> in each variable assignment undergoes tilde
5050expansion, parameter expansion, command substitution, arithmetic expansion,
5051and quote removal before being assigned to the variable.
5052</DL>
5053<P>
5054
5055If no command name results, the variable assignments affect the current
5056shell environment. Otherwise, the variables are added to the environment
5057of the executed command and do not affect the current shell environment.
5058If any of the assignments attempts to assign a value to a readonly variable,
5059an error occurs, and the command exits with a non-zero status.
5060<P>
5061
5062If no command name results, redirections are performed, but do not
5063affect the current shell environment. A redirection error causes the
5064command to exit with a non-zero status.
5065<P>
5066
5067If there is a command name left after expansion, execution proceeds as
5068described below. Otherwise, the command exits. If one of the expansions
5069contained a command substitution, the exit status of the command is
5070the exit status of the last command substitution performed. If there
5071were no command substitutions, the command exits with a status of zero.
5072<A NAME="lbBY">&nbsp;</A>
5073<H3>COMMAND EXECUTION</H3>
5074
5075After a command has been split into words, if it results in a
5076simple command and an optional list of arguments, the following
5077actions are taken.
5078<P>
5079
5080If the command name contains no slashes, the shell attempts to
5081locate it. If there exists a shell function by that name, that
5082function is invoked as described above in
5083<FONT SIZE=-1><B>FUNCTIONS</B>.
5084
5085</FONT>
5086If the name does not match a function, the shell searches for
5087it in the list of shell builtins. If a match is found, that
5088builtin is invoked.
5089<P>
5090
5091If the name is neither a shell function nor a builtin,
5092and contains no slashes,
5093<B>bash</B>
5094
5095searches each element of the
5096<FONT SIZE=-1><B>PATH</B>
5097
5098</FONT>
5099for a directory containing an executable file by that name.
5100<B>Bash</B>
5101
5102uses a hash table to remember the full pathnames of executable
5103files (see
5104<B>hash</B>
5105
5106under
5107<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5108
5109</FONT>
5110below).
5111A full search of the directories in
5112<FONT SIZE=-1><B>PATH</B>
5113
5114</FONT>
5115is performed only if the command is not found in the hash table.
5116If the search is unsuccessful, the shell searches for a defined shell
5117function named <B>command_not_found_handle</B>.
5118If that function exists, it is invoked with the original command and
5119the original command's arguments as its arguments, and the function's
5120exit status becomes the exit status of the shell.
5121If that function is not defined, the shell prints an error
5122message and returns an exit status of 127.
5123<P>
5124
5125If the search is successful, or if the command name contains
5126one or more slashes, the shell executes the named program in a
5127separate execution environment.
5128Argument 0 is set to the name given, and the remaining arguments
5129to the command are set to the arguments given, if any.
5130<P>
5131
5132If this execution fails because the file is not in executable
5133format, and the file is not a directory, it is assumed to be
5134a <I>shell script</I>, a file
5135containing shell commands. A subshell is spawned to execute
5136it. This subshell reinitializes itself, so
5137that the effect is as if a new shell had been invoked
5138to handle the script, with the exception that the locations of
5139commands remembered by the parent (see
5140<B>hash</B>
5141
5142below under
5143<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>)</FONT>
5144are retained by the child.
5145<P>
5146
5147If the program is a file beginning with
5148<B>#!</B>,
5149
5150the remainder of the first line specifies an interpreter
5151for the program. The shell executes the
5152specified interpreter on operating systems that do not
5153handle this executable format themselves. The arguments to the
5154interpreter consist of a single optional argument following the
5155interpreter name on the first line of the program, followed
5156by the name of the program, followed by the command
5157arguments, if any.
5158<A NAME="lbBZ">&nbsp;</A>
5159<H3>COMMAND EXECUTION ENVIRONMENT</H3>
5160
5161The shell has an <I>execution environment</I>, which consists of the
5162following:
5163<P>
5164<DL COMPACT>
5165<DT>*<DD>
5166open files inherited by the shell at invocation, as modified by
5167redirections supplied to the <B>exec</B> builtin
5168<DT>*<DD>
5169the current working directory as set by <B>cd</B>, <B>pushd</B>, or
5170<B>popd</B>, or inherited by the shell at invocation
5171<DT>*<DD>
5172the file creation mode mask as set by <B>umask</B> or inherited from
5173the shell's parent
5174<DT>*<DD>
5175current traps set by <B>trap</B>
5176<DT>*<DD>
5177shell parameters that are set by variable assignment or with <B>set</B>
5178or inherited from the shell's parent in the environment
5179<DT>*<DD>
5180shell functions defined during execution or inherited from the shell's
5181parent in the environment
5182<DT>*<DD>
5183options enabled at invocation (either by default or with command-line
5184arguments) or by <B>set</B>
5185<DT>*<DD>
5186options enabled by <B>shopt</B>
5187<DT>*<DD>
5188shell aliases defined with <B>alias</B>
5189<DT>*<DD>
5190various process IDs, including those of background jobs, the value
5191of <B>$$</B>, and the value of <B>$PPID</B>
5192</DL>
5193<P>
5194
5195When a simple command other than a builtin or shell function
5196is to be executed, it
5197is invoked in a separate execution environment that consists of
5198the following. Unless otherwise noted, the values are inherited
5199from the shell.
5200<P>
5201<DL COMPACT>
5202<DT>*<DD>
5203the shell's open files, plus any modifications and additions specified
5204by redirections to the command
5205<DT>*<DD>
5206the current working directory
5207<DT>*<DD>
5208the file creation mode mask
5209<DT>*<DD>
5210shell variables and functions marked for export, along with variables
5211exported for the command, passed in the environment
5212<DT>*<DD>
5213traps caught by the shell are reset to the values inherited from the
5214shell's parent, and traps ignored by the shell are ignored
5215</DL>
5216<P>
5217
5218A command invoked in this separate environment cannot affect the
5219shell's execution environment.
5220<P>
5221
5222Command substitution, commands grouped with parentheses,
5223and asynchronous commands are invoked in a
5224subshell environment that is a duplicate of the shell environment,
5225except that traps caught by the shell are reset to the values
5226that the shell inherited from its parent at invocation. Builtin
5227commands that are invoked as part of a pipeline are also executed in a
5228subshell environment. Changes made to the subshell environment
5229cannot affect the shell's execution environment.
5230<P>
5231
5232Subshells spawned to execute command substitutions inherit the value of
5233the <B>-e</B> option from the parent shell. When not in posix mode,
5234Bash clears the <B>-e</B> option in such subshells.
5235<P>
5236
5237If a command is followed by a <B>&amp;</B> and job control is not active, the
5238default standard input for the command is the empty file <I>/dev/null</I>.
5239Otherwise, the invoked command inherits the file descriptors of the calling
5240shell as modified by redirections.
5241<A NAME="lbCA">&nbsp;</A>
5242<H3>ENVIRONMENT</H3>
5243
5244When a program is invoked it is given an array of strings
5245called the
5246<I>environment</I>.
5247
5248This is a list of
5249<I>name</I>-<I>value</I> pairs, of the form
5250<I>name</I>=value.
5251
5252<P>
5253
5254The shell provides several ways to manipulate the environment.
5255On invocation, the shell scans its own environment and
5256creates a parameter for each name found, automatically marking
5257it for
5258<I>export</I>
5259
5260to child processes. Executed commands inherit the environment.
5261The
5262<B>export</B>
5263
5264and
5265<B>declare -x</B>
5266
5267commands allow parameters and functions to be added to and
5268deleted from the environment. If the value of a parameter
5269in the environment is modified, the new value becomes part
5270of the environment, replacing the old. The environment
5271inherited by any executed command consists of the shell's
5272initial environment, whose values may be modified in the shell,
5273less any pairs removed by the
5274<B>unset</B>
5275
5276command, plus any additions via the
5277<B>export</B>
5278
5279and
5280<B>declare -x</B>
5281
5282commands.
5283<P>
5284
5285The environment for any
5286<I>simple command</I>
5287
5288or function may be augmented temporarily by prefixing it with
5289parameter assignments, as described above in
5290<FONT SIZE=-1><B>PARAMETERS</B>.
5291
5292</FONT>
5293These assignment statements affect only the environment seen
5294by that command.
5295<P>
5296
5297If the
5298<B>-k</B>
5299
5300option is set (see the
5301<B>set</B>
5302
5303builtin command below), then
5304<I>all</I>
5305
5306parameter assignments are placed in the environment for a command,
5307not just those that precede the command name.
5308<P>
5309
5310When
5311<B>bash</B>
5312
5313invokes an external command, the variable
5314<B>_</B>
5315
5316is set to the full file name of the command and passed to that
5317command in its environment.
5318<A NAME="lbCB">&nbsp;</A>
5319<H3>EXIT STATUS</H3>
5320
5321<P>
5322
5323The exit status of an executed command is the value returned by the
5324<I>waitpid</I> system call or equivalent function. Exit statuses
5325fall between 0 and 255, though, as explained below, the shell may
5326use values above 125 specially. Exit statuses from shell builtins and
5327compound commands are also limited to this range. Under certain
5328circumstances, the shell will use special values to indicate specific
5329failure modes.
5330<P>
5331
5332For the shell's purposes, a command which exits with a
5333zero exit status has succeeded. An exit status of zero
5334indicates success. A non-zero exit status indicates failure.
5335When a command terminates on a fatal signal <I>N</I>, <B>bash</B> uses
5336the value of 128+<I>N</I> as the exit status.
5337<P>
5338
5339If a command is not found, the child process created to
5340execute it returns a status of 127. If a command is found
5341but is not executable, the return status is 126.
5342<P>
5343
5344If a command fails because of an error during expansion or redirection,
5345the exit status is greater than zero.
5346<P>
5347
5348Shell builtin commands return a status of 0 (<I>true</I>) if
5349successful, and non-zero (<I>false</I>) if an error occurs
5350while they execute.
5351All builtins return an exit status of 2 to indicate incorrect usage.
5352<P>
5353
5354<B>Bash</B> itself returns the exit status of the last command
5355executed, unless a syntax error occurs, in which case it exits
5356with a non-zero value. See also the <B>exit</B> builtin
5357command below.
5358<A NAME="lbCC">&nbsp;</A>
5359<H3>SIGNALS</H3>
5360
5361When <B>bash</B> is interactive, in the absence of any traps, it ignores
5362<FONT SIZE=-1><B>SIGTERM</B>
5363
5364</FONT>
5365(so that <B>kill 0</B> does not kill an interactive shell),
5366and
5367<FONT SIZE=-1><B>SIGINT</B>
5368
5369</FONT>
5370is caught and handled (so that the <B>wait</B> builtin is interruptible).
5371In all cases, <B>bash</B> ignores
5372<FONT SIZE=-1><B>SIGQUIT</B>.
5373
5374</FONT>
5375If job control is in effect,
5376<B>bash</B>
5377
5378ignores
5379<FONT SIZE=-1><B>SIGTTIN</B>,
5380
5381</FONT>
5382<FONT SIZE=-1><B>SIGTTOU</B>,
5383
5384</FONT>
5385and
5386<FONT SIZE=-1><B>SIGTSTP</B>.
5387
5388</FONT>
5389<P>
5390
5391Non-builtin commands run by <B>bash</B> have signal handlers
5392set to the values inherited by the shell from its parent.
5393When job control is not in effect, asynchronous commands
5394ignore
5395<FONT SIZE=-1><B>SIGINT</B>
5396
5397</FONT>
5398and
5399<FONT SIZE=-1><B>SIGQUIT</B>
5400
5401</FONT>
5402in addition to these inherited handlers.
5403Commands run as a result of command substitution ignore the
5404keyboard-generated job control signals
5405<FONT SIZE=-1><B>SIGTTIN</B>,
5406
5407</FONT>
5408<FONT SIZE=-1><B>SIGTTOU</B>,
5409
5410</FONT>
5411and
5412<FONT SIZE=-1><B>SIGTSTP</B>.
5413
5414</FONT>
5415<P>
5416
5417The shell exits by default upon receipt of a
5418<FONT SIZE=-1><B>SIGHUP</B>.
5419
5420</FONT>
5421Before exiting, an interactive shell resends the
5422<FONT SIZE=-1><B>SIGHUP</B>
5423
5424</FONT>
5425to all jobs, running or stopped.
5426Stopped jobs are sent
5427<FONT SIZE=-1><B>SIGCONT</B>
5428
5429</FONT>
5430to ensure that they receive the
5431<FONT SIZE=-1><B>SIGHUP</B>.
5432
5433</FONT>
5434To prevent the shell from
5435sending the signal to a particular job, it should be removed from the
5436jobs table with the
5437<B>disown</B>
5438
5439builtin (see
5440<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5441
5442</FONT>
5443below) or marked
5444to not receive
5445<FONT SIZE=-1><B>SIGHUP</B>
5446
5447</FONT>
5448using
5449<B>disown -h</B>.
5450
5451<P>
5452
5453If the
5454<B>huponexit</B>
5455
5456shell option has been set with
5457<B>shopt</B>,
5458
5459<B>bash</B>
5460
5461sends a
5462<FONT SIZE=-1><B>SIGHUP</B>
5463
5464</FONT>
5465to all jobs when an interactive login shell exits.
5466<P>
5467
5468If <B>bash</B> is waiting for a command to complete and receives a signal
5469for which a trap has been set, the trap will not be executed until
5470the command completes.
5471When <B>bash</B> is waiting for an asynchronous command via the <B>wait</B>
5472builtin, the reception of a signal for which a trap has been set will
5473cause the <B>wait</B> builtin to return immediately with an exit status
5474greater than 128, immediately after which the trap is executed.
5475<A NAME="lbCD">&nbsp;</A>
5476<H3>JOB CONTROL</H3>
5477
5478<I>Job control</I>
5479
5480refers to the ability to selectively stop (<I>suspend</I>)
5481the execution of processes and continue (<I>resume</I>)
5482their execution at a later point. A user typically employs
5483this facility via an interactive interface supplied jointly
5484by the system's terminal driver and
5485<B>bash</B>.
5486
5487<P>
5488
5489The shell associates a
5490<I>job</I>
5491
5492with each pipeline. It keeps a table of currently executing
5493jobs, which may be listed with the
5494<B>jobs</B>
5495
5496command. When
5497<B>bash</B>
5498
5499starts a job asynchronously (in the
5500<I>background</I>),
5501
5502it prints a line that looks like:
5503<DL COMPACT><DT><DD>
5504<P>
5505
5506[1] 25647
5507</DL>
5508
5509<P>
5510
5511indicating that this job is job number 1 and that the process ID
5512of the last process in the pipeline associated with this job is 25647.
5513All of the processes in a single pipeline are members of the same job.
5514<B>Bash</B>
5515
5516uses the
5517<I>job</I>
5518
5519abstraction as the basis for job control.
5520<P>
5521
5522To facilitate the implementation of the user interface to job
5523control, the operating system maintains the notion of a <I>current terminal
5524process group ID</I>. Members of this process group (processes whose
5525process group ID is equal to the current terminal process group ID)
5526receive keyboard-generated signals such as
5527<FONT SIZE=-1><B>SIGINT</B>.
5528
5529</FONT>
5530These processes are said to be in the
5531<I>foreground</I>.
5532
5533<I>Background</I>
5534
5535processes are those whose process group ID differs from the terminal's;
5536such processes are immune to keyboard-generated signals.
5537Only foreground processes are allowed to read from or write to the
5538terminal. Background processes which attempt to read from (write to) the
5539terminal are sent a
5540<FONT SIZE=-1><B>SIGTTIN (SIGTTOU)</B>
5541
5542</FONT>
5543signal by the terminal driver,
5544which, unless caught, suspends the process.
5545<P>
5546
5547If the operating system on which
5548<B>bash</B>
5549
5550is running supports
5551job control,
5552<B>bash</B>
5553
5554contains facilities to use it.
5555Typing the
5556<I>suspend</I>
5557
5558character (typically
5559<B>^Z</B>,
5560
5561Control-Z) while a process is running
5562causes that process to be stopped and returns control to
5563<B>bash</B>.
5564
5565Typing the
5566<I>delayed suspend</I>
5567
5568character (typically
5569<B>^Y</B>,
5570
5571Control-Y) causes the process to be stopped when it
5572attempts to read input from the terminal, and control to
5573be returned to
5574<B>bash</B>.
5575
5576The user may then manipulate the state of this job, using the
5577<B>bg</B>
5578
5579command to continue it in the background, the
5580<B>fg</B>
5581
5582command to continue it in the foreground, or
5583the
5584<B>kill</B>
5585
5586command to kill it. A <B>^Z</B> takes effect immediately,
5587and has the additional side effect of causing pending output
5588and typeahead to be discarded.
5589<P>
5590
5591There are a number of ways to refer to a job in the shell.
5592The character
5593<B>%</B>
5594
5595introduces a job specification (<I>jobspec</I>). Job number
5596<I>n</I>
5597
5598may be referred to as
5599<B>%n</B>.
5600
5601A job may also be referred to using a prefix of the name used to
5602start it, or using a substring that appears in its command line.
5603For example,
5604<B>%ce</B>
5605
5606refers to a stopped
5607<B>ce</B>
5608
5609job. If a prefix matches more than one job,
5610<B>bash</B>
5611
5612reports an error. Using
5613<B>%?ce</B>,
5614
5615on the other hand, refers to any job containing the string
5616<B>ce</B>
5617
5618in its command line. If the substring matches more than one job,
5619<B>bash</B>
5620
5621reports an error. The symbols
5622<B>%%</B>
5623
5624and
5625<B>%+</B>
5626
5627refer to the shell's notion of the
5628<I>current job</I>,
5629
5630which is the last job stopped while it was in
5631the foreground or started in the background.
5632The
5633<I>previous job</I>
5634
5635may be referenced using
5636<B>%-</B>.
5637
5638If there is only a single job, <B>%+</B> and <B>%-</B> can both be used
5639to refer to that job.
5640In output pertaining to jobs (e.g., the output of the
5641<B>jobs</B>
5642
5643command), the current job is always flagged with a
5644<B>+</B>,
5645
5646and the previous job with a
5647<B>-</B>.
5648
5649A single % (with no accompanying job specification) also refers to the
5650current job.
5651<P>
5652
5653Simply naming a job can be used to bring it into the
5654foreground:
5655<B>%1</B>
5656
5657is a synonym for
5658<B>``fg %1''</B>,
5659bringing job 1 from the background into the foreground.
5660Similarly,
5661<B>``%1 &amp;''</B>
5662
5663resumes job 1 in the background, equivalent to
5664<B>``bg %1''</B>.
5665<P>
5666
5667The shell learns immediately whenever a job changes state.
5668Normally,
5669<B>bash</B>
5670
5671waits until it is about to print a prompt before reporting
5672changes in a job's status so as to not interrupt
5673any other output. If the
5674<B>-b</B>
5675
5676option to the
5677<B>set</B>
5678
5679builtin command
5680is enabled,
5681<B>bash</B>
5682
5683reports such changes immediately.
5684Any trap on
5685<FONT SIZE=-1><B>SIGCHLD</B>
5686
5687</FONT>
5688is executed for each child that exits.
5689<P>
5690
5691If an attempt to exit
5692<B>bash</B>
5693
5694is made while jobs are stopped (or, if the <B>checkjobs</B> shell option has
5695been enabled using the <B>shopt</B> builtin, running), the shell prints a
5696warning message, and, if the <B>checkjobs</B> option is enabled, lists the
5697jobs and their statuses.
5698The
5699<B>jobs</B>
5700
5701command may then be used to inspect their status.
5702If a second attempt to exit is made without an intervening command,
5703the shell does not print another warning, and any stopped
5704jobs are terminated.
5705<A NAME="lbCE">&nbsp;</A>
5706<H3>PROMPTING</H3>
5707
5708When executing interactively,
5709<B>bash</B>
5710
5711displays the primary prompt
5712<FONT SIZE=-1><B>PS1</B>
5713
5714</FONT>
5715when it is ready to read a command, and the secondary prompt
5716<FONT SIZE=-1><B>PS2</B>
5717
5718</FONT>
5719when it needs more input to complete a command.
5720<B>Bash</B>
5721
5722allows these prompt strings to be customized by inserting a number of
5723backslash-escaped special characters that are decoded as follows:
5724<DL COMPACT><DT><DD>
5725
5726<DL COMPACT>
5727<DT><B>\a</B>
5728
5729<DD>
5730an ASCII bell character (07)
5731<DT><B>\d</B>
5732
5733<DD>
5734the date in &quot;Weekday Month Date&quot; format (e.g., &quot;Tue May 26&quot;)
5735<DT><B>\D{</B><I>format</I>}
5736
5737<DD>
5738the <I>format</I> is passed to <I>strftime</I>(3) and the result is inserted
5739into the prompt string; an empty <I>format</I> results in a locale-specific
5740time representation. The braces are required
5741<DT><B>\e</B>
5742
5743<DD>
5744an ASCII escape character (033)
5745<DT><B>\h</B>
5746
5747<DD>
5748the hostname up to the first `.'
5749<DT><B>\H</B>
5750
5751<DD>
5752the hostname
5753<DT><B>\j</B>
5754
5755<DD>
5756the number of jobs currently managed by the shell
5757<DT><B>\l</B>
5758
5759<DD>
5760the basename of the shell's terminal device name
5761<DT><B>\n</B>
5762
5763<DD>
5764newline
5765<DT><B>\r</B>
5766
5767<DD>
5768carriage return
5769<DT><B>\s</B>
5770
5771<DD>
5772the name of the shell, the basename of
5773<B>$0</B>
5774
5775(the portion following the final slash)
5776<DT><B>\t</B>
5777
5778<DD>
5779the current time in 24-hour HH:MM:SS format
5780<DT><B>\T</B>
5781
5782<DD>
5783the current time in 12-hour HH:MM:SS format
5784<DT><B>\@</B>
5785
5786<DD>
5787the current time in 12-hour am/pm format
5788<DT><B>\A</B>
5789
5790<DD>
5791the current time in 24-hour HH:MM format
5792<DT><B>\u</B>
5793
5794<DD>
5795the username of the current user
5796<DT><B>\v</B>
5797
5798<DD>
5799the version of <B>bash</B> (e.g., 2.00)
5800<DT><B>\V</B>
5801
5802<DD>
5803the release of <B>bash</B>, version + patch level (e.g., 2.00.0)
5804<DT><B>\w</B>
5805
5806<DD>
5807the current working directory, with <B>$HOME</B> abbreviated with a tilde
5808(uses the <B>$PROMPT_DIRTRIM</B> variable)
5809<DT><B>\W</B>
5810
5811<DD>
5812the basename of the current working directory, with <B>$HOME</B>
5813abbreviated with a tilde
5814<DT><B>\!</B>
5815
5816<DD>
5817the history number of this command
5818<DT><B>\#</B>
5819
5820<DD>
5821the command number of this command
5822<DT><B>\$</B>
5823
5824<DD>
5825if the effective UID is 0, a
5826<B>#</B>,
5827
5828otherwise a
5829<B>$</B>
5830
5831<DT><B>\</B><I>nnn</I>
5832
5833<DD>
5834the character corresponding to the octal number <I>nnn</I>
5835<DT><B>\\</B>
5836
5837<DD>
5838a backslash
5839<DT><B>\[</B>
5840
5841<DD>
5842begin a sequence of non-printing characters, which could be used to
5843embed a terminal control sequence into the prompt
5844<DT><B>\]</B>
5845
5846<DD>
5847end a sequence of non-printing characters
5848
5849</DL></DL>
5850
5851<P>
5852
5853The command number and the history number are usually different:
5854the history number of a command is its position in the history
5855list, which may include commands restored from the history file
5856(see
5857<FONT SIZE=-1><B>HISTORY</B>
5858
5859</FONT>
5860below), while the command number is the position in the sequence
5861of commands executed during the current shell session.
5862After the string is decoded, it is expanded via
5863parameter expansion, command substitution, arithmetic
5864expansion, and quote removal, subject to the value of the
5865<B>promptvars</B>
5866
5867shell option (see the description of the
5868<B>shopt</B>
5869
5870command under
5871<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5872
5873</FONT>
5874below).
5875<A NAME="lbCF">&nbsp;</A>
5876<H3>READLINE</H3>
5877
5878This is the library that handles reading input when using an interactive
5879shell, unless the
5880<B>--noediting</B>
5881
5882option is given at shell invocation.
5883Line editing is also used when using the <B>-e</B> option to the
5884<B>read</B> builtin.
5885By default, the line editing commands are similar to those of emacs.
5886A vi-style line editing interface is also available.
5887Line editing can be enabled at any time using the
5888<B>-o emacs</B>
5889
5890or
5891<B>-o vi</B>
5892
5893options to the
5894<B>set</B>
5895
5896builtin (see
5897<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5898
5899</FONT>
5900below).
5901To turn off line editing after the shell is running, use the
5902<B>+o emacs</B>
5903
5904or
5905<B>+o vi</B>
5906
5907options to the
5908<B>set</B>
5909
5910builtin.
5911<A NAME="lbCG">&nbsp;</A>
5912<H4>Readline Notation</H4>
5913
5914<P>
5915
5916In this section, the emacs-style notation is used to denote
5917keystrokes. Control keys are denoted by C-<I>key</I>, e.g., C-n
5918means Control-N. Similarly,
5919<I>meta</I>
5920
5921keys are denoted by M-<I>key</I>, so M-x means Meta-X. (On keyboards
5922without a
5923<I>meta</I>
5924
5925key, M-<I>x</I> means ESC <I>x</I>, i.e., press the Escape key
5926then the
5927<I>x</I>
5928
5929key. This makes ESC the <I>meta prefix</I>.
5930The combination M-C-<I>x</I> means ESC-Control-<I>x</I>,
5931or press the Escape key
5932then hold the Control key while pressing the
5933<I>x</I>
5934
5935key.)
5936<P>
5937
5938Readline commands may be given numeric
5939<I>arguments</I>,
5940
5941which normally act as a repeat count.
5942Sometimes, however, it is the sign of the argument that is significant.
5943Passing a negative argument to a command that acts in the forward
5944direction (e.g., <B>kill-line</B>) causes that command to act in a
5945backward direction.
5946Commands whose behavior with arguments deviates from this are noted
5947below.
5948<P>
5949
5950When a command is described as <I>killing</I> text, the text
5951deleted is saved for possible future retrieval
5952(<I>yanking</I>). The killed text is saved in a
5953<I>kill ring</I>. Consecutive kills cause the text to be
5954accumulated into one unit, which can be yanked all at once.
5955Commands which do not kill text separate the chunks of text
5956on the kill ring.
5957<A NAME="lbCH">&nbsp;</A>
5958<H4>Readline Initialization</H4>
5959
5960<P>
5961
5962Readline is customized by putting commands in an initialization
5963file (the <I>inputrc</I> file).
5964The name of this file is taken from the value of the
5965<FONT SIZE=-1><B>INPUTRC</B>
5966
5967</FONT>
5968variable. If that variable is unset, the default is
5969<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>.
5970
5971When a program which uses the readline library starts up, the
5972initialization file is read, and the key bindings and variables
5973are set.
5974There are only a few basic constructs allowed in the
5975readline initialization file.
5976Blank lines are ignored.
5977Lines beginning with a <B>#</B> are comments.
5978Lines beginning with a <B>$</B> indicate conditional constructs.
5979Other lines denote key bindings and variable settings.
5980<P>
5981
5982The default key-bindings may be changed with an
5983<I>inputrc </I>
5984
5985file.
5986Other programs that use this library may add their own commands
5987and bindings.
5988<P>
5989
5990For example, placing
5991<DL COMPACT><DT><DD>
5992<P>
5993
5994M-Control-u: universal-argument
5995</DL>
5996
5997or
5998<DL COMPACT><DT><DD>
5999C-Meta-u: universal-argument
6000</DL>
6001
6002into the
6003<I>inputrc</I>
6004
6005would make M-C-u execute the readline command
6006<I>universal-argument</I>.
6007
6008<P>
6009
6010The following symbolic character names are recognized:
6011<I>RUBOUT</I>,
6012
6013<I>DEL</I>,
6014
6015<I>ESC</I>,
6016
6017<I>LFD</I>,
6018
6019<I>NEWLINE</I>,
6020
6021<I>RET</I>,
6022
6023<I>RETURN</I>,
6024
6025<I>SPC</I>,
6026
6027<I>SPACE</I>,
6028
6029and
6030<I>TAB</I>.
6031
6032<P>
6033
6034In addition to command names, readline allows keys to be bound
6035to a string that is inserted when the key is pressed (a <I>macro</I>).
6036<A NAME="lbCI">&nbsp;</A>
6037<H4>Readline Key Bindings</H4>
6038
6039<P>
6040
6041The syntax for controlling key bindings in the
6042<I>inputrc</I>
6043
6044file is simple. All that is required is the name of the
6045command or the text of a macro and a key sequence to which
6046it should be bound. The name may be specified in one of two ways:
6047as a symbolic key name, possibly with <I>Meta-</I> or <I>Control-</I>
6048prefixes, or as a key sequence.
6049<P>
6050
6051When using the form <B>keyname</B>:<I>function-name</I> or <I>macro</I>,
6052<I>keyname</I>
6053
6054is the name of a key spelled out in English. For example:
6055<P>
6056<DL COMPACT><DT><DD>
6057Control-u: universal-argument
6058<BR>
6059
6060Meta-Rubout: backward-kill-word
6061<BR>
6062
6063Control-o: &quot;&gt; output&quot;
6064</DL>
6065
6066<P>
6067
6068In the above example,
6069<I>C-u</I>
6070
6071is bound to the function
6072<B>universal-argument</B>,
6073
6074<I>M-DEL</I>
6075
6076is bound to the function
6077<B>backward-kill-word</B>,
6078
6079and
6080<I>C-o</I>
6081
6082is bound to run the macro
6083expressed on the right hand side (that is, to insert the text
6084<TT>&gt; output</TT>
6085
6086into the line).
6087<P>
6088
6089In the second form, <B>&quot;keyseq&quot;</B>:<I>function-name</I> or <I>macro</I>,
6090<B>keyseq</B>
6091
6092differs from
6093<B>keyname</B>
6094
6095above in that strings denoting
6096an entire key sequence may be specified by placing the sequence
6097within double quotes. Some GNU Emacs style key escapes can be
6098used, as in the following example, but the symbolic character names
6099are not recognized.
6100<P>
6101<DL COMPACT><DT><DD>
6102&quot;\C-u&quot;: universal-argument
6103<BR>
6104
6105&quot;\C-x\C-r&quot;: re-read-init-file
6106<BR>
6107
6108&quot;\e[11~&quot;: &quot;Function Key 1&quot;
6109</DL>
6110
6111<P>
6112
6113In this example,
6114<I>C-u</I>
6115
6116is again bound to the function
6117<B>universal-argument</B>.
6118
6119<I>C-x C-r</I>
6120
6121is bound to the function
6122<B>re-read-init-file</B>,
6123
6124and
6125<I>ESC [ 1 1 ~</I>
6126
6127is bound to insert the text
6128<TT>Function Key 1</TT>.
6129
6130<P>
6131
6132The full set of GNU Emacs style escape sequences is
6133<DL COMPACT><DT><DD>
6134
6135<DL COMPACT>
6136<DT><B>\C-</B>
6137
6138<DD>
6139control prefix
6140<DT><B>\M-</B>
6141
6142<DD>
6143meta prefix
6144<DT><B>\e</B>
6145
6146<DD>
6147an escape character
6148<DT><B>\\</B>
6149
6150<DD>
6151backslash
6152<DT><B>\</B>
6153
6154<DD>
6155literal &quot;
6156<DT><B>\aq</B>
6157
6158<DD>
6159literal aq
6160</DL></DL>
6161
6162
6163<P>
6164
6165In addition to the GNU Emacs style escape sequences, a second
6166set of backslash escapes is available:
6167<DL COMPACT><DT><DD>
6168
6169<DL COMPACT>
6170<DT><B>\a</B>
6171
6172<DD>
6173alert (bell)
6174<DT><B>\b</B>
6175
6176<DD>
6177backspace
6178<DT><B>\d</B>
6179
6180<DD>
6181delete
6182<DT><B>\f</B>
6183
6184<DD>
6185form feed
6186<DT><B>\n</B>
6187
6188<DD>
6189newline
6190<DT><B>\r</B>
6191
6192<DD>
6193carriage return
6194<DT><B>\t</B>
6195
6196<DD>
6197horizontal tab
6198<DT><B>\v</B>
6199
6200<DD>
6201vertical tab
6202<DT><B>\</B><I>nnn</I>
6203
6204<DD>
6205the eight-bit character whose value is the octal value <I>nnn</I>
6206(one to three digits)
6207<DT><B>\x</B><I>HH</I>
6208
6209<DD>
6210the eight-bit character whose value is the hexadecimal value <I>HH</I>
6211(one or two hex digits)
6212</DL></DL>
6213
6214
6215<P>
6216
6217When entering the text of a macro, single or double quotes must
6218be used to indicate a macro definition.
6219Unquoted text is assumed to be a function name.
6220In the macro body, the backslash escapes described above are expanded.
6221Backslash will quote any other character in the macro text,
6222including &quot; and aq.
6223<P>
6224
6225<B>Bash</B>
6226
6227allows the current readline key bindings to be displayed or modified
6228with the
6229<B>bind</B>
6230
6231builtin command. The editing mode may be switched during interactive
6232use by using the
6233<B>-o</B>
6234
6235option to the
6236<B>set</B>
6237
6238builtin command (see
6239<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6240
6241</FONT>
6242below).
6243<A NAME="lbCJ">&nbsp;</A>
6244<H4>Readline Variables</H4>
6245
6246<P>
6247
6248Readline has variables that can be used to further customize its
6249behavior. A variable may be set in the
6250<I>inputrc</I>
6251
6252file with a statement of the form
6253<DL COMPACT><DT><DD>
6254<P>
6255
6256<B>set</B> <I>variable-name</I> <I>value</I>
6257</DL>
6258
6259<P>
6260
6261Except where noted, readline variables can take the values
6262<B>On</B>
6263
6264or
6265<B>Off</B>
6266
6267(without regard to case).
6268Unrecognized variable names are ignored.
6269When a variable value is read, empty or null values, &quot;on&quot; (case-insensitive),
6270and &quot;1&quot; are equivalent to <B>On</B>. All other values are equivalent to
6271<B>Off</B>.
6272The variables and their default values are:
6273<P>
6274
6275
6276<DL COMPACT>
6277<DT><B>bell-style (audible)</B>
6278
6279<DD>
6280Controls what happens when readline wants to ring the terminal bell.
6281If set to <B>none</B>, readline never rings the bell. If set to
6282<B>visible</B>, readline uses a visible bell if one is available.
6283If set to <B>audible</B>, readline attempts to ring the terminal's bell.
6284<DT><B>bind-tty-special-chars (On)</B>
6285
6286<DD>
6287If set to <B>On</B>, readline attempts to bind the control characters
6288treated specially by the kernel's terminal driver to their readline
6289equivalents.
6290<DT><B>comment-begin (``#'')</B>
6291
6292<DD>
6293The string that is inserted when the readline
6294<B>insert-comment</B>
6295
6296command is executed.
6297This command is bound to
6298<B>M-#</B>
6299
6300in emacs mode and to
6301<B>#</B>
6302
6303in vi command mode.
6304<DT><B>completion-ignore-case (Off)</B>
6305
6306<DD>
6307If set to <B>On</B>, readline performs filename matching and completion
6308in a case-insensitive fashion.
6309<DT><B>completion-prefix-display-length (0)</B>
6310
6311<DD>
6312The length in characters of the common prefix of a list of possible
6313completions that is displayed without modification. When set to a
6314value greater than zero, common prefixes longer than this value are
6315replaced with an ellipsis when displaying possible completions.
6316<DT><B>completion-query-items (100)</B>
6317
6318<DD>
6319This determines when the user is queried about viewing
6320the number of possible completions
6321generated by the <B>possible-completions</B> command.
6322It may be set to any integer value greater than or equal to
6323zero. If the number of possible completions is greater than
6324or equal to the value of this variable, the user is asked whether
6325or not he wishes to view them; otherwise they are simply listed
6326on the terminal.
6327<DT><B>convert-meta (On)</B>
6328
6329<DD>
6330If set to <B>On</B>, readline will convert characters with the
6331eighth bit set to an ASCII key sequence
6332by stripping the eighth bit and prefixing an
6333escape character (in effect, using escape as the <I>meta prefix</I>).
6334<DT><B>disable-completion (Off)</B>
6335
6336<DD>
6337If set to <B>On</B>, readline will inhibit word completion. Completion
6338characters will be inserted into the line as if they had been
6339mapped to <B>self-insert</B>.
6340<DT><B>editing-mode (emacs)</B>
6341
6342<DD>
6343Controls whether readline begins with a set of key bindings similar
6344to <I>emacs</I> or <I>vi</I>.
6345<B>editing-mode</B>
6346
6347can be set to either
6348<B>emacs</B>
6349
6350or
6351<B>vi</B>.
6352
6353<DT><B>enable-keypad (Off)</B>
6354
6355<DD>
6356When set to <B>On</B>, readline will try to enable the application
6357keypad when it is called. Some systems need this to enable the
6358arrow keys.
6359<DT><B>expand-tilde (Off)</B>
6360
6361<DD>
6362If set to <B>on</B>, tilde expansion is performed when readline
6363attempts word completion.
6364<DT><B>history-preserve-point (Off)</B>
6365
6366<DD>
6367If set to <B>on</B>, the history code attempts to place point at the
6368same location on each history line retrieved with <B>previous-history</B>
6369or <B>next-history</B>.
6370<DT><B>history-size (0)</B>
6371
6372<DD>
6373Set the maximum number of history entries saved in the history list. If
6374set to zero, the number of entries in the history list is not limited.
6375<DT><B>horizontal-scroll-mode (Off)</B>
6376
6377<DD>
6378When set to <B>On</B>, makes readline use a single line for display,
6379scrolling the input horizontally on a single screen line when it
6380becomes longer than the screen width rather than wrapping to a new line.
6381<DT><B>input-meta (Off)</B>
6382
6383<DD>
6384If set to <B>On</B>, readline will enable eight-bit input (that is,
6385it will not strip the high bit from the characters it reads),
6386regardless of what the terminal claims it can support. The name
6387<B>meta-flag</B>
6388
6389is a synonym for this variable.
6390<DT><B>isearch-terminators (``C-[C-J'')</B>
6391
6392<DD>
6393The string of characters that should terminate an incremental
6394search without subsequently executing the character as a command.
6395If this variable has not been given a value, the characters
6396<I>ESC</I> and <I>C-J</I> will terminate an incremental search.
6397<DT><B>keymap (emacs)</B>
6398
6399<DD>
6400Set the current readline keymap. The set of valid keymap names is
6401<I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
6402vi-command</I>, and
6403<I>vi-insert</I>.
6404
6405<I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is
6406equivalent to <I>emacs-standard</I>. The default value is
6407<I>emacs</I>;
6408
6409the value of
6410<B>editing-mode</B>
6411
6412also affects the default keymap.
6413<DT><B>mark-directories (On)</B>
6414
6415<DD>
6416If set to <B>On</B>, completed directory names have a slash
6417appended.
6418<DT><B>mark-modified-lines (Off)</B>
6419
6420<DD>
6421If set to <B>On</B>, history lines that have been modified are displayed
6422with a preceding asterisk (<B>*</B>).
6423<DT><B>mark-symlinked-directories (Off)</B>
6424
6425<DD>
6426If set to <B>On</B>, completed names which are symbolic links to directories
6427have a slash appended (subject to the value of
6428<B>mark-directories</B>).
6429<DT><B>match-hidden-files (On)</B>
6430
6431<DD>
6432This variable, when set to <B>On</B>, causes readline to match files whose
6433names begin with a `.' (hidden files) when performing filename
6434completion, unless the leading `.' is
6435supplied by the user in the filename to be completed.
6436<DT><B>output-meta (Off)</B>
6437
6438<DD>
6439If set to <B>On</B>, readline will display characters with the
6440eighth bit set directly rather than as a meta-prefixed escape
6441sequence.
6442<DT><B>page-completions (On)</B>
6443
6444<DD>
6445If set to <B>On</B>, readline uses an internal <I>more</I>-like pager
6446to display a screenful of possible completions at a time.
6447<DT><B>print-completions-horizontally (Off)</B>
6448
6449<DD>
6450If set to <B>On</B>, readline will display completions with matches
6451sorted horizontally in alphabetical order, rather than down the screen.
6452<DT><B>revert-all-at-newline (Off)</B>
6453
6454<DD>
6455If set to <B>on</B>, readline will undo all changes to history lines
6456before returning when <B>accept-line</B> is executed. By default,
6457history lines may be modified and retain individual undo lists across
6458calls to <B>readline</B>.
6459<DT><B>show-all-if-ambiguous (Off)</B>
6460
6461<DD>
6462This alters the default behavior of the completion functions. If
6463set to
6464<B>on</B>,
6465
6466words which have more than one possible completion cause the
6467matches to be listed immediately instead of ringing the bell.
6468<DT><B>show-all-if-unmodified (Off)</B>
6469
6470<DD>
6471This alters the default behavior of the completion functions in
6472a fashion similar to <B>show-all-if-ambiguous</B>.
6473If set to
6474<B>on</B>,
6475
6476words which have more than one possible completion without any
6477possible partial completion (the possible completions don't share
6478a common prefix) cause the matches to be listed immediately instead
6479of ringing the bell.
6480<DT><B>visible-stats (Off)</B>
6481
6482<DD>
6483If set to <B>On</B>, a character denoting a file's type as reported
6484by <I>stat</I>(2) is appended to the filename when listing possible
6485completions.
6486
6487</DL>
6488<A NAME="lbCK">&nbsp;</A>
6489<H4>Readline Conditional Constructs</H4>
6490
6491<P>
6492
6493Readline implements a facility similar in spirit to the conditional
6494compilation features of the C preprocessor which allows key
6495bindings and variable settings to be performed as the result
6496of tests. There are four parser directives used.
6497<DL COMPACT>
6498<DT><B>$if</B><DD>
6499The
6500<B>$if</B>
6501
6502construct allows bindings to be made based on the
6503editing mode, the terminal being used, or the application using
6504readline. The text of the test extends to the end of the line;
6505no characters are required to isolate it.
6506<DL COMPACT><DT><DD>
6507<DL COMPACT>
6508<DT><B>mode</B><DD>
6509The <B>mode=</B> form of the <B>$if</B> directive is used to test
6510whether readline is in emacs or vi mode.
6511This may be used in conjunction
6512with the <B>set keymap</B> command, for instance, to set bindings in
6513the <I>emacs-standard</I> and <I>emacs-ctlx</I> keymaps only if
6514readline is starting out in emacs mode.
6515<DT><B>term</B><DD>
6516The <B>term=</B> form may be used to include terminal-specific
6517key bindings, perhaps to bind the key sequences output by the
6518terminal's function keys. The word on the right side of the
6519<B>=</B>
6520
6521is tested against the both full name of the terminal and the portion
6522of the terminal name before the first <B>-</B>. This allows
6523<I>sun</I>
6524
6525to match both
6526<I>sun</I>
6527
6528and
6529<I>sun-cmd</I>,
6530
6531for instance.
6532<DT><B>application</B><DD>
6533The <B>application</B> construct is used to include
6534application-specific settings. Each program using the readline
6535library sets the <I>application name</I>, and an initialization
6536file can test for a particular value.
6537This could be used to bind key sequences to functions useful for
6538a specific program. For instance, the following command adds a
6539key sequence that quotes the current or previous word in Bash:
6540<P>
6541<DL COMPACT><DT><DD>
6542<PRE>
6543<B>$if</B> Bash
6544# Quote the current or previous word
6545&quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
6546<B>$endif</B>
6547</PRE>
6548
6549</DL>
6550
6551</DL></DL>
6552
6553<DT><B>$endif</B><DD>
6554This command, as seen in the previous example, terminates an
6555<B>$if</B> command.
6556<DT><B>$else</B><DD>
6557Commands in this branch of the <B>$if</B> directive are executed if
6558the test fails.
6559<DT><B>$include</B><DD>
6560This directive takes a single filename as an argument and reads commands
6561and bindings from that file. For example, the following directive
6562would read <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>:
6563<P>
6564<DL COMPACT><DT><DD>
6565<PRE>
6566<B>$include</B> <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>
6567</PRE>
6568
6569</DL>
6570
6571</DL>
6572<A NAME="lbCL">&nbsp;</A>
6573<H4>Searching</H4>
6574
6575<P>
6576
6577Readline provides commands for searching through the command history
6578(see
6579<FONT SIZE=-1><B>HISTORY</B>
6580
6581</FONT>
6582below) for lines containing a specified string.
6583There are two search modes:
6584<I>incremental</I>
6585
6586and
6587<I>non-incremental</I>.
6588
6589<P>
6590
6591Incremental searches begin before the user has finished typing the
6592search string.
6593As each character of the search string is typed, readline displays
6594the next entry from the history matching the string typed so far.
6595An incremental search requires only as many characters as needed to
6596find the desired history entry.
6597The characters present in the value of the <B>isearch-terminators</B>
6598variable are used to terminate an incremental search.
6599If that variable has not been assigned a value the Escape and
6600Control-J characters will terminate an incremental search.
6601Control-G will abort an incremental search and restore the original
6602line.
6603When the search is terminated, the history entry containing the
6604search string becomes the current line.
6605<P>
6606
6607To find other matching entries in the history list, type Control-S or
6608Control-R as appropriate.
6609This will search backward or forward in the history for the next
6610entry matching the search string typed so far.
6611Any other key sequence bound to a readline command will terminate
6612the search and execute that command.
6613For instance, a <I>newline</I> will terminate the search and accept
6614the line, thereby executing the command from the history list.
6615<P>
6616
6617Readline remembers the last incremental search string. If two
6618Control-Rs are typed without any intervening characters defining a
6619new search string, any remembered search string is used.
6620<P>
6621
6622Non-incremental searches read the entire search string before starting
6623to search for matching history lines. The search string may be
6624typed by the user or be part of the contents of the current line.
6625<A NAME="lbCM">&nbsp;</A>
6626<H4>Readline Command Names</H4>
6627
6628<P>
6629
6630The following is a list of the names of the commands and the default
6631key sequences to which they are bound.
6632Command names without an accompanying key sequence are unbound by default.
6633In the following descriptions, <I>point</I> refers to the current cursor
6634position, and <I>mark</I> refers to a cursor position saved by the
6635<B>set-mark</B> command.
6636The text between the point and mark is referred to as the <I>region</I>.
6637<A NAME="lbCN">&nbsp;</A>
6638<H4>Commands for Moving</H4>
6639
6640<P>
6641
6642
6643<DL COMPACT>
6644<DT><B>beginning-of-line (C-a)</B>
6645
6646<DD>
6647Move to the start of the current line.
6648<DT><B>end-of-line (C-e)</B>
6649
6650<DD>
6651Move to the end of the line.
6652<DT><B>forward-char (C-f)</B>
6653
6654<DD>
6655Move forward a character.
6656<DT><B>backward-char (C-b)</B>
6657
6658<DD>
6659Move back a character.
6660<DT><B>forward-word (M-f)</B>
6661
6662<DD>
6663Move forward to the end of the next word. Words are composed of
6664alphanumeric characters (letters and digits).
6665<DT><B>backward-word (M-b)</B>
6666
6667<DD>
6668Move back to the start of the current or previous word.
6669Words are composed of alphanumeric characters (letters and digits).
6670<DT><B>shell-forward-word</B>
6671
6672<DD>
6673Move forward to the end of the next word.
6674Words are delimited by non-quoted shell metacharacters.
6675<DT><B>shell-backward-word</B>
6676
6677<DD>
6678Move back to the start of the current or previous word.
6679Words are delimited by non-quoted shell metacharacters.
6680<DT><B>clear-screen (C-l)</B>
6681
6682<DD>
6683Clear the screen leaving the current line at the top of the screen.
6684With an argument, refresh the current line without clearing the
6685screen.
6686<DT><B>redraw-current-line</B>
6687
6688<DD>
6689Refresh the current line.
6690
6691</DL>
6692<A NAME="lbCO">&nbsp;</A>
6693<H4>Commands for Manipulating the History</H4>
6694
6695<P>
6696
6697
6698<DL COMPACT>
6699<DT><B>accept-line (Newline, Return)</B>
6700
6701<DD>
6702Accept the line regardless of where the cursor is. If this line is
6703non-empty, add it to the history list according to the state of the
6704<FONT SIZE=-1><B>HISTCONTROL</B>
6705
6706</FONT>
6707variable. If the line is a modified history
6708line, then restore the history line to its original state.
6709<DT><B>previous-history (C-p)</B>
6710
6711<DD>
6712Fetch the previous command from the history list, moving back in
6713the list.
6714<DT><B>next-history (C-n)</B>
6715
6716<DD>
6717Fetch the next command from the history list, moving forward in the
6718list.
6719<DT><B>beginning-of-history (M-&lt;)</B>
6720
6721<DD>
6722Move to the first line in the history.
6723<DT><B>end-of-history (M-&gt;)</B>
6724
6725<DD>
6726Move to the end of the input history, i.e., the line currently being
6727entered.
6728<DT><B>reverse-search-history (C-r)</B>
6729
6730<DD>
6731Search backward starting at the current line and moving `up' through
6732the history as necessary. This is an incremental search.
6733<DT><B>forward-search-history (C-s)</B>
6734
6735<DD>
6736Search forward starting at the current line and moving `down' through
6737the history as necessary. This is an incremental search.
6738<DT><B>non-incremental-reverse-search-history (M-p)</B>
6739
6740<DD>
6741Search backward through the history starting at the current line
6742using a non-incremental search for a string supplied by the user.
6743<DT><B>non-incremental-forward-search-history (M-n)</B>
6744
6745<DD>
6746Search forward through the history using a non-incremental search for
6747a string supplied by the user.
6748<DT><B>history-search-forward</B>
6749
6750<DD>
6751Search forward through the history for the string of characters
6752between the start of the current line and the point.
6753This is a non-incremental search.
6754<DT><B>history-search-backward</B>
6755
6756<DD>
6757Search backward through the history for the string of characters
6758between the start of the current line and the point.
6759This is a non-incremental search.
6760<DT><B>yank-nth-arg (M-C-y)</B>
6761
6762<DD>
6763Insert the first argument to the previous command (usually
6764the second word on the previous line) at point.
6765With an argument
6766<I>n</I>,
6767
6768insert the <I>n</I>th word from the previous command (the words
6769in the previous command begin with word 0). A negative argument
6770inserts the <I>n</I>th word from the end of the previous command.
6771Once the argument <I>n</I> is computed, the argument is extracted
6772as if the &quot;!<I>n</I>&quot; history expansion had been specified.
6773<DT><B>yank-last-arg (M-., M-_)</B>
6774
6775<DD>
6776Insert the last argument to the previous command (the last word of
6777the previous history entry). With an argument,
6778behave exactly like <B>yank-nth-arg</B>.
6779Successive calls to <B>yank-last-arg</B> move back through the history
6780list, inserting the last argument of each line in turn.
6781The history expansion facilities are used to extract the last argument,
6782as if the &quot;!$&quot; history expansion had been specified.
6783<DT><B>shell-expand-line (M-C-e)</B>
6784
6785<DD>
6786Expand the line as the shell does. This
6787performs alias and history expansion as well as all of the shell
6788word expansions. See
6789<FONT SIZE=-1><B>HISTORY EXPANSION</B>
6790
6791</FONT>
6792below for a description of history expansion.
6793<DT><B>history-expand-line (M-^)</B>
6794
6795<DD>
6796Perform history expansion on the current line.
6797See
6798<FONT SIZE=-1><B>HISTORY EXPANSION</B>
6799
6800</FONT>
6801below for a description of history expansion.
6802<DT><B>magic-space</B>
6803
6804<DD>
6805Perform history expansion on the current line and insert a space.
6806See
6807<FONT SIZE=-1><B>HISTORY EXPANSION</B>
6808
6809</FONT>
6810below for a description of history expansion.
6811<DT><B>alias-expand-line</B>
6812
6813<DD>
6814Perform alias expansion on the current line.
6815See
6816<FONT SIZE=-1><B>ALIASES</B>
6817
6818</FONT>
6819above for a description of alias expansion.
6820<DT><B>history-and-alias-expand-line</B>
6821
6822<DD>
6823Perform history and alias expansion on the current line.
6824<DT><B>insert-last-argument (M-., M-_)</B>
6825
6826<DD>
6827A synonym for <B>yank-last-arg</B>.
6828<DT><B>operate-and-get-next (C-o)</B>
6829
6830<DD>
6831Accept the current line for execution and fetch the next line
6832relative to the current line from the history for editing. Any
6833argument is ignored.
6834<DT><B>edit-and-execute-command (C-xC-e)</B>
6835
6836<DD>
6837Invoke an editor on the current command line, and execute the result as shell
6838commands.
6839<B>Bash</B> attempts to invoke
6840<FONT SIZE=-1><B>$VISUAL</B>,
6841
6842</FONT>
6843<FONT SIZE=-1><B>$EDITOR</B>,
6844
6845</FONT>
6846and <I>emacs</I> as the editor, in that order.
6847
6848</DL>
6849<A NAME="lbCP">&nbsp;</A>
6850<H4>Commands for Changing Text</H4>
6851
6852<P>
6853
6854
6855<DL COMPACT>
6856<DT><B>delete-char (C-d)</B>
6857
6858<DD>
6859Delete the character at point. If point is at the
6860beginning of the line, there are no characters in the line, and
6861the last character typed was not bound to <B>delete-char</B>,
6862then return
6863<FONT SIZE=-1><B>EOF</B>.
6864
6865</FONT>
6866<DT><B>backward-delete-char (Rubout)</B>
6867
6868<DD>
6869Delete the character behind the cursor. When given a numeric argument,
6870save the deleted text on the kill ring.
6871<DT><B>forward-backward-delete-char</B>
6872
6873<DD>
6874Delete the character under the cursor, unless the cursor is at the
6875end of the line, in which case the character behind the cursor is
6876deleted.
6877<DT><B>quoted-insert (C-q, C-v)</B>
6878
6879<DD>
6880Add the next character typed to the line verbatim. This is
6881how to insert characters like <B>C-q</B>, for example.
6882<DT><B>tab-insert (C-v TAB)</B>
6883
6884<DD>
6885Insert a tab character.
6886<DT><B>self-insert (a,&nbsp;b,&nbsp;A,&nbsp;1,&nbsp;!,&nbsp;...)</B>
6887
6888<DD>
6889Insert the character typed.
6890<DT><B>transpose-chars (C-t)</B>
6891
6892<DD>
6893Drag the character before point forward over the character at point,
6894moving point forward as well.
6895If point is at the end of the line, then this transposes
6896the two characters before point.
6897Negative arguments have no effect.
6898<DT><B>transpose-words (M-t)</B>
6899
6900<DD>
6901Drag the word before point past the word after point,
6902moving point over that word as well.
6903If point is at the end of the line, this transposes
6904the last two words on the line.
6905<DT><B>upcase-word (M-u)</B>
6906
6907<DD>
6908Uppercase the current (or following) word. With a negative argument,
6909uppercase the previous word, but do not move point.
6910<DT><B>downcase-word (M-l)</B>
6911
6912<DD>
6913Lowercase the current (or following) word. With a negative argument,
6914lowercase the previous word, but do not move point.
6915<DT><B>capitalize-word (M-c)</B>
6916
6917<DD>
6918Capitalize the current (or following) word. With a negative argument,
6919capitalize the previous word, but do not move point.
6920<DT><B>overwrite-mode</B>
6921
6922<DD>
6923Toggle overwrite mode. With an explicit positive numeric argument,
6924switches to overwrite mode. With an explicit non-positive numeric
6925argument, switches to insert mode. This command affects only
6926<B>emacs</B> mode; <B>vi</B> mode does overwrite differently.
6927Each call to <I>readline()</I> starts in insert mode.
6928In overwrite mode, characters bound to <B>self-insert</B> replace
6929the text at point rather than pushing the text to the right.
6930Characters bound to <B>backward-delete-char</B> replace the character
6931before point with a space. By default, this command is unbound.
6932
6933</DL>
6934<A NAME="lbCQ">&nbsp;</A>
6935<H4>Killing and Yanking</H4>
6936
6937<P>
6938
6939
6940<DL COMPACT>
6941<DT><B>kill-line (C-k)</B>
6942
6943<DD>
6944Kill the text from point to the end of the line.
6945<DT><B>backward-kill-line (C-x Rubout)</B>
6946
6947<DD>
6948Kill backward to the beginning of the line.
6949<DT><B>unix-line-discard (C-u)</B>
6950
6951<DD>
6952Kill backward from point to the beginning of the line.
6953The killed text is saved on the kill-ring.
6954
6955<DT><B>kill-whole-line</B>
6956
6957<DD>
6958Kill all characters on the current line, no matter where point is.
6959<DT><B>kill-word (M-d)</B>
6960
6961<DD>
6962Kill from point to the end of the current word, or if between
6963words, to the end of the next word.
6964Word boundaries are the same as those used by <B>forward-word</B>.
6965<DT><B>backward-kill-word (M-Rubout)</B>
6966
6967<DD>
6968Kill the word behind point.
6969Word boundaries are the same as those used by <B>backward-word</B>.
6970<DT><B>shell-kill-word (M-d)</B>
6971
6972<DD>
6973Kill from point to the end of the current word, or if between
6974words, to the end of the next word.
6975Word boundaries are the same as those used by <B>shell-forward-word</B>.
6976<DT><B>shell-backward-kill-word (M-Rubout)</B>
6977
6978<DD>
6979Kill the word behind point.
6980Word boundaries are the same as those used by <B>shell-backward-word</B>.
6981<DT><B>unix-word-rubout (C-w)</B>
6982
6983<DD>
6984Kill the word behind point, using white space as a word boundary.
6985The killed text is saved on the kill-ring.
6986<DT><B>unix-filename-rubout</B>
6987
6988<DD>
6989Kill the word behind point, using white space and the slash character
6990as the word boundaries.
6991The killed text is saved on the kill-ring.
6992<DT><B>delete-horizontal-space (M-\)</B>
6993
6994<DD>
6995Delete all spaces and tabs around point.
6996<DT><B>kill-region</B>
6997
6998<DD>
6999Kill the text in the current region.
7000<DT><B>copy-region-as-kill</B>
7001
7002<DD>
7003Copy the text in the region to the kill buffer.
7004<DT><B>copy-backward-word</B>
7005
7006<DD>
7007Copy the word before point to the kill buffer.
7008The word boundaries are the same as <B>backward-word</B>.
7009<DT><B>copy-forward-word</B>
7010
7011<DD>
7012Copy the word following point to the kill buffer.
7013The word boundaries are the same as <B>forward-word</B>.
7014<DT><B>yank (C-y)</B>
7015
7016<DD>
7017Yank the top of the kill ring into the buffer at point.
7018<DT><B>yank-pop (M-y)</B>
7019
7020<DD>
7021Rotate the kill ring, and yank the new top. Only works following
7022<B>yank</B>
7023
7024or
7025<B>yank-pop</B>.
7026
7027
7028</DL>
7029<A NAME="lbCR">&nbsp;</A>
7030<H4>Numeric Arguments</H4>
7031
7032<P>
7033
7034
7035<DL COMPACT>
7036<DT><B>digit-argument (M-0, M-1, ..., M--)</B>
7037
7038<DD>
7039Add this digit to the argument already accumulating, or start a new
7040argument. M-- starts a negative argument.
7041<DT><B>universal-argument</B>
7042
7043<DD>
7044This is another way to specify an argument.
7045If this command is followed by one or more digits, optionally with a
7046leading minus sign, those digits define the argument.
7047If the command is followed by digits, executing
7048<B>universal-argument</B>
7049
7050again ends the numeric argument, but is otherwise ignored.
7051As a special case, if this command is immediately followed by a
7052character that is neither a digit or minus sign, the argument count
7053for the next command is multiplied by four.
7054The argument count is initially one, so executing this function the
7055first time makes the argument count four, a second time makes the
7056argument count sixteen, and so on.
7057
7058</DL>
7059<A NAME="lbCS">&nbsp;</A>
7060<H4>Completing</H4>
7061
7062<P>
7063
7064
7065<DL COMPACT>
7066<DT><B>complete (TAB)</B>
7067
7068<DD>
7069Attempt to perform completion on the text before point.
7070<B>Bash</B>
7071
7072attempts completion treating the text as a variable (if the
7073text begins with <B>$</B>), username (if the text begins with
7074<B>~</B>), hostname (if the text begins with <B>@</B>), or
7075command (including aliases and functions) in turn. If none
7076of these produces a match, filename completion is attempted.
7077<DT><B>possible-completions (M-?)</B>
7078
7079<DD>
7080List the possible completions of the text before point.
7081<DT><B>insert-completions (M-*)</B>
7082
7083<DD>
7084Insert all completions of the text before point
7085that would have been generated by
7086<B>possible-completions</B>.
7087<DT><B>menu-complete</B>
7088
7089<DD>
7090Similar to <B>complete</B>, but replaces the word to be completed
7091with a single match from the list of possible completions.
7092Repeated execution of <B>menu-complete</B> steps through the list
7093of possible completions, inserting each match in turn.
7094At the end of the list of completions, the bell is rung
7095(subject to the setting of <B>bell-style</B>)
7096and the original text is restored.
7097An argument of <I>n</I> moves <I>n</I> positions forward in the list
7098of matches; a negative argument may be used to move backward
7099through the list.
7100This command is intended to be bound to <B>TAB</B>, but is unbound
7101by default.
7102<DT><B>delete-char-or-list</B>
7103
7104<DD>
7105Deletes the character under the cursor if not at the beginning or
7106end of the line (like <B>delete-char</B>).
7107If at the end of the line, behaves identically to
7108<B>possible-completions</B>.
7109This command is unbound by default.
7110<DT><B>complete-filename (M-/)</B>
7111
7112<DD>
7113Attempt filename completion on the text before point.
7114<DT><B>possible-filename-completions (C-x /)</B>
7115
7116<DD>
7117List the possible completions of the text before point,
7118treating it as a filename.
7119<DT><B>complete-username (M-~)</B>
7120
7121<DD>
7122Attempt completion on the text before point, treating
7123it as a username.
7124<DT><B>possible-username-completions (C-x ~)</B>
7125
7126<DD>
7127List the possible completions of the text before point,
7128treating it as a username.
7129<DT><B>complete-variable (M-$)</B>
7130
7131<DD>
7132Attempt completion on the text before point, treating
7133it as a shell variable.
7134<DT><B>possible-variable-completions (C-x $)</B>
7135
7136<DD>
7137List the possible completions of the text before point,
7138treating it as a shell variable.
7139<DT><B>complete-hostname (M-@)</B>
7140
7141<DD>
7142Attempt completion on the text before point, treating
7143it as a hostname.
7144<DT><B>possible-hostname-completions (C-x @)</B>
7145
7146<DD>
7147List the possible completions of the text before point,
7148treating it as a hostname.
7149<DT><B>complete-command (M-!)</B>
7150
7151<DD>
7152Attempt completion on the text before point, treating
7153it as a command name. Command completion attempts to
7154match the text against aliases, reserved words, shell
7155functions, shell builtins, and finally executable filenames,
7156in that order.
7157<DT><B>possible-command-completions (C-x !)</B>
7158
7159<DD>
7160List the possible completions of the text before point,
7161treating it as a command name.
7162<DT><B>dynamic-complete-history (M-TAB)</B>
7163
7164<DD>
7165Attempt completion on the text before point, comparing
7166the text against lines from the history list for possible
7167completion matches.
7168<DT><B>dabbrev-expand</B>
7169
7170<DD>
7171Attempt menu completion on the text before point, comparing
7172the text against lines from the history list for possible
7173completion matches.
7174<DT><B>complete-into-braces (M-{)</B>
7175
7176<DD>
7177Perform filename completion and insert the list of possible completions
7178enclosed within braces so the list is available to the shell (see
7179<B>Brace Expansion</B>
7180
7181above).
7182
7183</DL>
7184<A NAME="lbCT">&nbsp;</A>
7185<H4>Keyboard Macros</H4>
7186
7187<P>
7188
7189
7190<DL COMPACT>
7191<DT><B>start-kbd-macro (C-x ()</B>
7192
7193<DD>
7194Begin saving the characters typed into the current keyboard macro.
7195<DT><B>end-kbd-macro (C-x ))</B>
7196
7197<DD>
7198Stop saving the characters typed into the current keyboard macro
7199and store the definition.
7200<DT><B>call-last-kbd-macro (C-x e)</B>
7201
7202<DD>
7203Re-execute the last keyboard macro defined, by making the characters
7204in the macro appear as if typed at the keyboard.
7205
7206</DL>
7207<A NAME="lbCU">&nbsp;</A>
7208<H4>Miscellaneous</H4>
7209
7210<P>
7211
7212
7213<DL COMPACT>
7214<DT><B>re-read-init-file (C-x C-r)</B>
7215
7216<DD>
7217Read in the contents of the <I>inputrc</I> file, and incorporate
7218any bindings or variable assignments found there.
7219<DT><B>abort (C-g)</B>
7220
7221<DD>
7222Abort the current editing command and
7223ring the terminal's bell (subject to the setting of
7224<B>bell-style</B>).
7225
7226<DT><B>do-uppercase-version (M-a, M-b, M-</B><I>x</I>, ...)
7227
7228<DD>
7229If the metafied character <I>x</I> is lowercase, run the command
7230that is bound to the corresponding uppercase character.
7231<DT><B>prefix-meta (ESC)</B>
7232
7233<DD>
7234Metafy the next character typed.
7235<FONT SIZE=-1><B>ESC</B>
7236
7237</FONT>
7238<B>f</B>
7239
7240is equivalent to
7241<B>Meta-f</B>.
7242
7243<DT><B>undo (C-_, C-x C-u)</B>
7244
7245<DD>
7246Incremental undo, separately remembered for each line.
7247<DT><B>revert-line (M-r)</B>
7248
7249<DD>
7250Undo all changes made to this line. This is like executing the
7251<B>undo</B>
7252
7253command enough times to return the line to its initial state.
7254<DT><B>tilde-expand (M-&amp;)</B>
7255
7256<DD>
7257Perform tilde expansion on the current word.
7258<DT><B>set-mark (C-@, M-&lt;space&gt;)</B>
7259
7260<DD>
7261Set the mark to the point. If a
7262numeric argument is supplied, the mark is set to that position.
7263<DT><B>exchange-point-and-mark (C-x C-x)</B>
7264
7265<DD>
7266Swap the point with the mark. The current cursor position is set to
7267the saved position, and the old cursor position is saved as the mark.
7268<DT><B>character-search (C-])</B>
7269
7270<DD>
7271A character is read and point is moved to the next occurrence of that
7272character. A negative count searches for previous occurrences.
7273<DT><B>character-search-backward (M-C-])</B>
7274
7275<DD>
7276A character is read and point is moved to the previous occurrence of that
7277character. A negative count searches for subsequent occurrences.
7278<DT><B>insert-comment (M-#)</B>
7279
7280<DD>
7281Without a numeric argument, the value of the readline
7282<B>comment-begin</B>
7283
7284variable is inserted at the beginning of the current line.
7285If a numeric argument is supplied, this command acts as a toggle: if
7286the characters at the beginning of the line do not match the value
7287of <B>comment-begin</B>, the value is inserted, otherwise
7288the characters in <B>comment-begin</B> are deleted from the beginning of
7289the line.
7290In either case, the line is accepted as if a newline had been typed.
7291The default value of
7292<B>comment-begin</B> causes this command to make the current line
7293a shell comment.
7294If a numeric argument causes the comment character to be removed, the line
7295will be executed by the shell.
7296<DT><B>glob-complete-word (M-g)</B>
7297
7298<DD>
7299The word before point is treated as a pattern for pathname expansion,
7300with an asterisk implicitly appended. This pattern is used to
7301generate a list of matching file names for possible completions.
7302<DT><B>glob-expand-word (C-x *)</B>
7303
7304<DD>
7305The word before point is treated as a pattern for pathname expansion,
7306and the list of matching file names is inserted, replacing the word.
7307If a numeric argument is supplied, an asterisk is appended before
7308pathname expansion.
7309<DT><B>glob-list-expansions (C-x g)</B>
7310
7311<DD>
7312The list of expansions that would have been generated by
7313<B>glob-expand-word</B>
7314
7315is displayed, and the line is redrawn.
7316If a numeric argument is supplied, an asterisk is appended before
7317pathname expansion.
7318<DT><B>dump-functions</B>
7319
7320<DD>
7321Print all of the functions and their key bindings to the
7322readline output stream. If a numeric argument is supplied,
7323the output is formatted in such a way that it can be made part
7324of an <I>inputrc</I> file.
7325<DT><B>dump-variables</B>
7326
7327<DD>
7328Print all of the settable readline variables and their values to the
7329readline output stream. If a numeric argument is supplied,
7330the output is formatted in such a way that it can be made part
7331of an <I>inputrc</I> file.
7332<DT><B>dump-macros</B>
7333
7334<DD>
7335Print all of the readline key sequences bound to macros and the
7336strings they output. If a numeric argument is supplied,
7337the output is formatted in such a way that it can be made part
7338of an <I>inputrc</I> file.
7339<DT><B>display-shell-version (C-x C-v)</B>
7340
7341<DD>
7342Display version information about the current instance of
7343<B>bash</B>.
7344
7345
7346</DL>
7347<A NAME="lbCV">&nbsp;</A>
7348<H4>Programmable Completion</H4>
7349
7350<P>
7351
7352When word completion is attempted for an argument to a command for
7353which a completion specification (a <I>compspec</I>) has been defined
7354using the <B>complete</B> builtin (see
7355<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7356
7357</FONT>
7358below), the programmable completion facilities are invoked.
7359<P>
7360
7361First, the command name is identified.
7362If a compspec has been defined for that command, the
7363compspec is used to generate the list of possible completions for the word.
7364If the command word is a full pathname, a compspec for the full
7365pathname is searched for first.
7366If no compspec is found for the full pathname, an attempt is made to
7367find a compspec for the portion following the final slash.
7368<P>
7369
7370Once a compspec has been found, it is used to generate the list of
7371matching words.
7372If a compspec is not found, the default <B>bash</B> completion as
7373described above under <B>Completing</B> is performed.
7374<P>
7375
7376First, the actions specified by the compspec are used.
7377Only matches which are prefixed by the word being completed are
7378returned.
7379When the
7380<B>-f</B>
7381
7382or
7383<B>-d</B>
7384
7385option is used for filename or directory name completion, the shell
7386variable
7387<FONT SIZE=-1><B>FIGNORE</B>
7388
7389</FONT>
7390is used to filter the matches.
7391<P>
7392
7393Any completions specified by a filename expansion pattern to the
7394<B>-G</B> option are generated next.
7395The words generated by the pattern need not match the word
7396being completed.
7397The
7398<FONT SIZE=-1><B>GLOBIGNORE</B>
7399
7400</FONT>
7401shell variable is not used to filter the matches, but the
7402<FONT SIZE=-1><B>FIGNORE</B>
7403
7404</FONT>
7405variable is used.
7406<P>
7407
7408Next, the string specified as the argument to the <B>-W</B> option
7409is considered.
7410The string is first split using the characters in the
7411<FONT SIZE=-1><B>IFS</B>
7412
7413</FONT>
7414special variable as delimiters.
7415Shell quoting is honored.
7416Each word is then expanded using
7417brace expansion, tilde expansion, parameter and variable expansion,
7418command substitution, and arithmetic expansion,
7419as described above under
7420<FONT SIZE=-1><B>EXPANSION</B>.
7421
7422</FONT>
7423The results are split using the rules described above under
7424<B>Word Splitting</B>.
7425The results of the expansion are prefix-matched against the word being
7426completed, and the matching words become the possible completions.
7427<P>
7428
7429After these matches have been generated, any shell function or command
7430specified with the <B>-F</B> and <B>-C</B> options is invoked.
7431When the command or function is invoked, the
7432<FONT SIZE=-1><B>COMP_LINE</B>,
7433
7434</FONT>
7435<FONT SIZE=-1><B>COMP_POINT</B>,
7436
7437</FONT>
7438<FONT SIZE=-1><B>COMP_KEY</B>,
7439
7440</FONT>
7441and
7442<FONT SIZE=-1><B>COMP_TYPE</B>
7443
7444</FONT>
7445variables are assigned values as described above under
7446<B>Shell Variables</B>.
7447If a shell function is being invoked, the
7448<FONT SIZE=-1><B>COMP_WORDS</B>
7449
7450</FONT>
7451and
7452<FONT SIZE=-1><B>COMP_CWORD</B>
7453
7454</FONT>
7455variables are also set.
7456When the function or command is invoked, the first argument is the
7457name of the command whose arguments are being completed, the
7458second argument is the word being completed, and the third argument
7459is the word preceding the word being completed on the current command line.
7460No filtering of the generated completions against the word being completed
7461is performed; the function or command has complete freedom in generating
7462the matches.
7463<P>
7464
7465Any function specified with <B>-F</B> is invoked first.
7466The function may use any of the shell facilities, including the
7467<B>compgen</B> builtin described below, to generate the matches.
7468It must put the possible completions in the
7469<FONT SIZE=-1><B>COMPREPLY</B>
7470
7471</FONT>
7472array variable.
7473<P>
7474
7475Next, any command specified with the <B>-C</B> option is invoked
7476in an environment equivalent to command substitution.
7477It should print a list of completions, one per line, to the
7478standard output.
7479Backslash may be used to escape a newline, if necessary.
7480<P>
7481
7482After all of the possible completions are generated, any filter
7483specified with the <B>-X</B> option is applied to the list.
7484The filter is a pattern as used for pathname expansion; a <B>&amp;</B>
7485in the pattern is replaced with the text of the word being completed.
7486A literal <B>&amp;</B> may be escaped with a backslash; the backslash
7487is removed before attempting a match.
7488Any completion that matches the pattern will be removed from the list.
7489A leading <B>!</B> negates the pattern; in this case any completion
7490not matching the pattern will be removed.
7491<P>
7492
7493Finally, any prefix and suffix specified with the <B>-P</B> and <B>-S</B>
7494options are added to each member of the completion list, and the result is
7495returned to the readline completion code as the list of possible
7496completions.
7497<P>
7498
7499If the previously-applied actions do not generate any matches, and the
7500<B>-o dirnames</B> option was supplied to <B>complete</B> when the
7501compspec was defined, directory name completion is attempted.
7502<P>
7503
7504If the <B>-o plusdirs</B> option was supplied to <B>complete</B> when the
7505compspec was defined, directory name completion is attempted and any
7506matches are added to the results of the other actions.
7507<P>
7508
7509By default, if a compspec is found, whatever it generates is returned
7510to the completion code as the full set of possible completions.
7511The default <B>bash</B> completions are not attempted, and the readline
7512default of filename completion is disabled.
7513If the <B>-o bashdefault</B> option was supplied to <B>complete</B> when
7514the compspec was defined, the <B>bash</B> default completions are attempted
7515if the compspec generates no matches.
7516If the <B>-o default</B> option was supplied to <B>complete</B> when the
7517compspec was defined, readline's default completion will be performed
7518if the compspec (and, if attempted, the default <B>bash</B> completions)
7519generate no matches.
7520<P>
7521
7522When a compspec indicates that directory name completion is desired,
7523the programmable completion functions force readline to append a slash
7524to completed names which are symbolic links to directories, subject to
7525the value of the <B>mark-directories</B> readline variable, regardless
7526of the setting of the <B>mark-symlinked-directories</B> readline variable.
7527<A NAME="lbCW">&nbsp;</A>
7528<H3>HISTORY</H3>
7529
7530When the
7531<B>-o history</B>
7532
7533option to the
7534<B>set</B>
7535
7536builtin is enabled, the shell provides access to the
7537<I>command history</I>,
7538the list of commands previously typed.
7539The value of the <B>HISTSIZE</B> variable is used as the
7540number of commands to save in a history list.
7541The text of the last
7542<FONT SIZE=-1><B>HISTSIZE</B>
7543
7544</FONT>
7545commands (default 500) is saved. The shell
7546stores each command in the history list prior to parameter and
7547variable expansion (see
7548<FONT SIZE=-1><B>EXPANSION</B>
7549
7550</FONT>
7551above) but after history expansion is performed, subject to the
7552values of the shell variables
7553<FONT SIZE=-1><B>HISTIGNORE</B>
7554
7555</FONT>
7556and
7557<FONT SIZE=-1><B>HISTCONTROL</B>.
7558
7559</FONT>
7560<P>
7561
7562On startup, the history is initialized from the file named by
7563the variable
7564<FONT SIZE=-1><B>HISTFILE</B>
7565
7566</FONT>
7567(default <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>).
7568The file named by the value of
7569<FONT SIZE=-1><B>HISTFILE</B>
7570
7571</FONT>
7572is truncated, if necessary, to contain no more than
7573the number of lines specified by the value of
7574<FONT SIZE=-1><B>HISTFILESIZE</B>.
7575
7576</FONT>
7577When the history file is read,
7578lines beginning with the history comment character followed immediately
7579by a digit are interpreted as timestamps for the preceding history line.
7580These timestamps are optionally displayed depending on the value of the
7581<FONT SIZE=-1><B>HISTTIMEFORMAT</B>
7582
7583</FONT>
7584variable.
7585When an interactive shell exits, the last
7586<FONT SIZE=-1><B>$HISTSIZE</B>
7587
7588</FONT>
7589lines are copied from the history list to
7590<FONT SIZE=-1><B>$HISTFILE</B>.
7591
7592</FONT>
7593If the
7594<B>histappend</B>
7595
7596shell option is enabled
7597(see the description of
7598<B>shopt</B>
7599
7600under
7601<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7602
7603</FONT>
7604below), the lines are appended to the history file,
7605otherwise the history file is overwritten.
7606If
7607<FONT SIZE=-1><B>HISTFILE</B>
7608
7609</FONT>
7610is unset, or if the history file is unwritable, the history is
7611not saved.
7612If the
7613<FONT SIZE=-1>
7614</FONT>
7615variable is set, time stamps are written to the history file, marked
7616with the history comment character, so
7617they may be preserved across shell sessions.
7618This uses the history comment character to distinguish timestamps from
7619other history lines.
7620After saving the history, the history file is truncated
7621to contain no more than
7622<FONT SIZE=-1><B>HISTFILESIZE</B>
7623
7624</FONT>
7625lines. If
7626<FONT SIZE=-1><B>HISTFILESIZE</B>
7627
7628</FONT>
7629is not set, no truncation is performed.
7630<P>
7631
7632The builtin command
7633<B>fc</B>
7634
7635(see
7636<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7637
7638</FONT>
7639below) may be used to list or edit and re-execute a portion of
7640the history list.
7641The
7642<B>history</B>
7643
7644builtin may be used to display or modify the history list and
7645manipulate the history file.
7646When using command-line editing, search commands
7647are available in each editing mode that provide access to the
7648history list.
7649<P>
7650
7651The shell allows control over which commands are saved on the history
7652list. The
7653<FONT SIZE=-1><B>HISTCONTROL</B>
7654
7655</FONT>
7656and
7657<FONT SIZE=-1><B>HISTIGNORE</B>
7658
7659</FONT>
7660variables may be set to cause the shell to save only a subset of the
7661commands entered.
7662The
7663<B>cmdhist</B>
7664
7665shell option, if enabled, causes the shell to attempt to save each
7666line of a multi-line command in the same history entry, adding
7667semicolons where necessary to preserve syntactic correctness.
7668The
7669<B>lithist</B>
7670
7671shell option causes the shell to save the command with embedded newlines
7672instead of semicolons. See the description of the
7673<B>shopt</B>
7674
7675builtin below under
7676<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7677
7678</FONT>
7679for information on setting and unsetting shell options.
7680<A NAME="lbCX">&nbsp;</A>
7681<H3>HISTORY EXPANSION</H3>
7682
7683<P>
7684
7685The shell supports a history expansion feature that
7686is similar to the history expansion in
7687<B>csh.</B>
7688
7689This section describes what syntax features are available. This
7690feature is enabled by default for interactive shells, and can be
7691disabled using the
7692<B>+H</B>
7693
7694option to the
7695<B>set</B>
7696
7697builtin command (see
7698<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7699
7700</FONT>
7701below). Non-interactive shells do not perform history expansion
7702by default.
7703<P>
7704
7705History expansions introduce words from the history list into
7706the input stream, making it easy to repeat commands, insert the
7707arguments to a previous command into the current input line, or
7708fix errors in previous commands quickly.
7709<P>
7710
7711History expansion is performed immediately after a complete line
7712is read, before the shell breaks it into words.
7713It takes place in two parts.
7714The first is to determine which line from the history list
7715to use during substitution.
7716The second is to select portions of that line for inclusion into
7717the current one.
7718The line selected from the history is the <I>event</I>,
7719and the portions of that line that are acted upon are <I>words</I>.
7720Various <I>modifiers</I> are available to manipulate the selected words.
7721The line is broken into words in the same fashion as when reading input,
7722so that several <I>metacharacter</I>-separated words surrounded by
7723quotes are considered one word.
7724History expansions are introduced by the appearance of the
7725history expansion character, which is <B>!</B> by default.
7726Only backslash (<B>\</B>) and single quotes can quote
7727the history expansion character.
7728<P>
7729
7730Several characters inhibit history expansion if found immediately
7731following the history expansion character, even if it is unquoted:
7732space, tab, newline, carriage return, and <B>=</B>.
7733If the <B>extglob</B> shell option is enabled, <B>(</B> will also
7734inhibit expansion.
7735<P>
7736
7737Several shell options settable with the
7738<B>shopt</B>
7739
7740builtin may be used to tailor the behavior of history expansion.
7741If the
7742<B>histverify</B>
7743
7744shell option is enabled (see the description of the
7745<B>shopt</B>
7746
7747builtin), and
7748<B>readline</B>
7749
7750is being used, history substitutions are not immediately passed to
7751the shell parser.
7752Instead, the expanded line is reloaded into the
7753<B>readline</B>
7754
7755editing buffer for further modification.
7756If
7757<B>readline</B>
7758
7759is being used, and the
7760<B>histreedit</B>
7761
7762shell option is enabled, a failed history substitution will be reloaded
7763into the
7764<B>readline</B>
7765
7766editing buffer for correction.
7767The
7768<B>-p</B>
7769
7770option to the
7771<B>history</B>
7772
7773builtin command may be used to see what a history expansion will
7774do before using it.
7775The
7776<B>-s</B>
7777
7778option to the
7779<B>history</B>
7780
7781builtin may be used to add commands to the end of the history list
7782without actually executing them, so that they are available for
7783subsequent recall.
7784<P>
7785
7786The shell allows control of the various characters used by the
7787history expansion mechanism (see the description of
7788<B>histchars</B>
7789
7790above under
7791<B>Shell Variables</B>).
7792
7793The shell uses
7794the history comment character to mark history timestamps when
7795writing the history file.
7796<A NAME="lbCY">&nbsp;</A>
7797<H4>Event Designators</H4>
7798
7799<P>
7800
7801An event designator is a reference to a command line entry in the
7802history list.
7803<P>
7804
7805
7806<DL COMPACT>
7807<DT><B>!</B>
7808
7809<DD>
7810Start a history substitution, except when followed by a
7811<B>blank</B>,
7812
7813newline, carriage return, =
7814or ( (when the <B>extglob</B> shell option is enabled using
7815the <B>shopt</B> builtin).
7816<DT><B>!</B><I>n</I>
7817
7818<DD>
7819Refer to command line
7820<I>n</I>.
7821
7822<DT><B>!-</B><I>n</I>
7823
7824<DD>
7825Refer to the current command line minus
7826<I>n</I>.
7827
7828<DT><B>!!</B>
7829
7830<DD>
7831Refer to the previous command. This is a synonym for `!-1'.
7832<DT><B>!</B><I>string</I>
7833
7834<DD>
7835Refer to the most recent command starting with
7836<I>string</I>.
7837
7838<DT><B>!?</B><I>string</I><B>[?]</B>
7839
7840<DD>
7841Refer to the most recent command containing
7842<I>string</I>.
7843
7844The trailing <B>?</B> may be omitted if
7845<I>string</I>
7846
7847is followed immediately by a newline.
7848<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>
7849
7850<DD>
7851Quick substitution. Repeat the last command, replacing
7852<I>string1</I>
7853
7854with
7855<I>string2</I>.
7856
7857Equivalent to
7858``!!:s/<I>string1</I>/<I>string2</I>/''
7859(see <B>Modifiers</B> below).
7860<DT><B>!#</B>
7861
7862<DD>
7863The entire command line typed so far.
7864
7865</DL>
7866<A NAME="lbCZ">&nbsp;</A>
7867<H4>Word Designators</H4>
7868
7869<P>
7870
7871Word designators are used to select desired words from the event.
7872A
7873<B>:</B>
7874
7875separates the event specification from the word designator.
7876It may be omitted if the word designator begins with a
7877<B>^</B>,
7878
7879<B>$</B>,
7880
7881<B>*</B>,
7882
7883<B>-</B>,
7884
7885or
7886<B>%</B>.
7887
7888Words are numbered from the beginning of the line,
7889with the first word being denoted by 0 (zero).
7890Words are inserted into the current line separated by single spaces.
7891<P>
7892
7893
7894<DL COMPACT>
7895<DT><B>0 (zero)</B>
7896
7897<DD>
7898The zeroth word. For the shell, this is the command
7899word.
7900<DT><I>n</I>
7901
7902<DD>
7903The <I>n</I>th word.
7904<DT><B>^</B>
7905
7906<DD>
7907The first argument. That is, word 1.
7908<DT><B>$</B>
7909
7910<DD>
7911The last argument.
7912<DT><B>%</B>
7913
7914<DD>
7915The word matched by the most recent `?<I>string</I>?' search.
7916<DT><I>x</I><B>-</B>y
7917
7918<DD>
7919A range of words; `-<I>y</I>' abbreviates `0-<I>y</I>'.
7920<DT><B>*</B>
7921
7922<DD>
7923All of the words but the zeroth. This is a synonym
7924for `<I>1-$</I>'. It is not an error to use
7925<B>*</B>
7926
7927if there is just one
7928word in the event; the empty string is returned in that case.
7929<DT><B>x*</B>
7930
7931<DD>
7932Abbreviates <I>x-$</I>.
7933<DT><B>x-</B>
7934
7935<DD>
7936Abbreviates <I>x-$</I> like <B>x*</B>, but omits the last word.
7937
7938</DL>
7939<P>
7940
7941If a word designator is supplied without an event specification, the
7942previous command is used as the event.
7943<A NAME="lbDA">&nbsp;</A>
7944<H4>Modifiers</H4>
7945
7946<P>
7947
7948After the optional word designator, there may appear a sequence of
7949one or more of the following modifiers, each preceded by a `:'.
7950<P>
7951
7952
7953<P>
7954
7955<DL COMPACT>
7956<DT><B>h</B>
7957
7958<DD>
7959Remove a trailing file name component, leaving only the head.
7960<DT><B>t</B>
7961
7962<DD>
7963Remove all leading file name components, leaving the tail.
7964<DT><B>r</B>
7965
7966<DD>
7967Remove a trailing suffix of the form <I>.xxx</I>, leaving the
7968basename.
7969<DT><B>e</B>
7970
7971<DD>
7972Remove all but the trailing suffix.
7973<DT><B>p</B>
7974
7975<DD>
7976Print the new command but do not execute it.
7977<DT><B>q</B>
7978
7979<DD>
7980Quote the substituted words, escaping further substitutions.
7981<DT><B>x</B>
7982
7983<DD>
7984Quote the substituted words as with
7985<B>q</B>,
7986
7987but break into words at
7988<B>blanks</B>
7989
7990and newlines.
7991<DT><B>s/</B><I>old</I>/<I>new</I>/
7992
7993<DD>
7994Substitute
7995<I>new</I>
7996
7997for the first occurrence of
7998<I>old</I>
7999
8000in the event line. Any delimiter can be used in place of /. The
8001final delimiter is optional if it is the last character of the
8002event line. The delimiter may be quoted in
8003<I>old</I>
8004
8005and
8006<I>new</I>
8007
8008with a single backslash. If &amp; appears in
8009<I>new</I>,
8010
8011it is replaced by
8012<I>old</I>.
8013
8014A single backslash will quote the &amp;. If
8015<I>old</I>
8016
8017is null, it is set to the last
8018<I>old</I>
8019
8020substituted, or, if no previous history substitutions took place,
8021the last
8022<I>string</I>
8023
8024in a
8025<B>!?</B><I>string</I><B>[?]</B>
8026
8027search.
8028<DT><B>&amp;</B>
8029
8030<DD>
8031Repeat the previous substitution.
8032<DT><B>g</B>
8033
8034<DD>
8035Cause changes to be applied over the entire event line. This is
8036used in conjunction with `<B>:s</B>' (e.g., `<B>:gs/</B><I>old</I>/<I>new</I>/')
8037or `<B>:&amp;</B>'. If used with
8038`<B>:s</B>', any delimiter can be used
8039in place of /, and the final delimiter is optional
8040if it is the last character of the event line.
8041An <B>a</B> may be used as a synonym for <B>g</B>.
8042<DT><B>G</B>
8043
8044<DD>
8045Apply the following `<B>s</B>' modifier once to each word in the event line.
8046
8047</DL>
8048<A NAME="lbDB">&nbsp;</A>
8049<H3>SHELL BUILTIN COMMANDS</H3>
8050
8051
8052
8053<P>
8054
8055Unless otherwise noted, each builtin command documented in this
8056section as accepting options preceded by
8057<B>-</B>
8058
8059accepts
8060<B>--</B>
8061
8062to signify the end of the options.
8063For example, the <B>:</B>, <B>true</B>, <B>false</B>, and <B>test</B> builtins
8064do not accept options.
8065<P>
8066
8067<DL COMPACT>
8068<DT><B>:</B> [<I>arguments</I>]<DD>
8069
8070No effect; the command does nothing beyond expanding
8071<I>arguments</I>
8072
8073and performing any specified
8074redirections. A zero exit code is returned.
8075<DT><B> . </B> <I>filename</I> [<I>arguments</I>]<DD>
8076
8077<DT><B>source</B> <I>filename</I> [<I>arguments</I>]<DD>
8078
8079Read and execute commands from
8080<I>filename</I>
8081
8082in the current
8083shell environment and return the exit status of the last command
8084executed from
8085<I>filename</I>.
8086
8087If
8088<I>filename</I>
8089
8090does not contain a slash, file names in
8091<FONT SIZE=-1><B>PATH</B>
8092
8093</FONT>
8094are used to find the directory containing
8095<I>filename</I>.
8096
8097The file searched for in
8098<FONT SIZE=-1><B>PATH</B>
8099
8100</FONT>
8101need not be executable.
8102When <B>bash</B> is not in <I>posix mode</I>, the current directory is
8103searched if no file is found in
8104<FONT SIZE=-1><B>PATH</B>.
8105
8106</FONT>
8107If the
8108<B>sourcepath</B>
8109
8110option to the
8111<B>shopt</B>
8112
8113builtin command is turned off, the
8114<FONT SIZE=-1><B>PATH</B>
8115
8116</FONT>
8117is not searched.
8118If any <I>arguments</I> are supplied, they become the positional
8119parameters when <I>filename</I> is executed. Otherwise the positional
8120parameters are unchanged.
8121The return status is the status of the last command exited within
8122the script (0 if no commands are executed), and false if
8123<I>filename</I>
8124
8125is not found or cannot be read.
8126<DT><B>alias</B> [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
8127<B>Alias</B> with no arguments or with the
8128<B>-p</B>
8129
8130option prints the list of aliases in the form
8131<B>alias</B> <I>name</I>=<I>value</I> on standard output.
8132When arguments are supplied, an alias is defined for
8133each <I>name</I> whose <I>value</I> is given.
8134A trailing space in <I>value</I> causes the next word to be
8135checked for alias substitution when the alias is expanded.
8136For each <I>name</I> in the argument list for which no <I>value</I>
8137is supplied, the name and value of the alias is printed.
8138<B>Alias</B> returns true unless a <I>name</I> is given for which
8139no alias has been defined.
8140<DT><B>bg</B> [<I>jobspec</I> ...]<DD>
8141Resume each suspended job <I>jobspec</I> in the background, as if it
8142had been started with
8143<B>&amp;</B>.
8144
8145If
8146<I>jobspec</I>
8147
8148is not present, the shell's notion of the <I>current job</I> is used.
8149<B>bg</B>
8150
8151<I>jobspec</I>
8152
8153returns 0 unless run when job control is disabled or, when run with
8154job control enabled, any specified <I>jobspec</I> was not found
8155or was started without job control.
8156<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] [<B>-lpsvPSV</B>]<DD>
8157
8158<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>
8159<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-f</B> <I>filename</I><DD>
8160<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-x</B> <I>keyseq</I>:<I>shell-command</I><DD>
8161<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <I>keyseq</I>:<I>function-name</I><DD>
8162<DT><B>bind</B> <I>readline-command</I><DD>
8163
8164Display current
8165<B>readline</B>
8166
8167key and function bindings, bind a key sequence to a
8168<B>readline</B>
8169
8170function or macro, or set a
8171<B>readline</B>
8172
8173variable.
8174Each non-option argument is a command as it would appear in
8175<I>.inputrc</I>,
8176
8177but each binding or command must be passed as a separate argument;
8178e.g., '&quot;\C-x\C-r&quot;: re-read-init-file'.
8179Options, if supplied, have the following meanings:
8180<DL COMPACT><DT><DD>
8181
8182<DL COMPACT>
8183<DT><B>-m </B><I>keymap</I>
8184
8185<DD>
8186Use
8187<I>keymap</I>
8188
8189as the keymap to be affected by the subsequent bindings.
8190Acceptable
8191<I>keymap</I>
8192
8193names are
8194<I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
8195vi-move, vi-command</I>, and
8196<I>vi-insert</I>.
8197
8198<I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is
8199equivalent to <I>emacs-standard</I>.
8200<DT><B>-l</B>
8201
8202<DD>
8203List the names of all <B>readline</B> functions.
8204<DT><B>-p</B>
8205
8206<DD>
8207Display <B>readline</B> function names and bindings in such a way
8208that they can be re-read.
8209<DT><B>-P</B>
8210
8211<DD>
8212List current <B>readline</B> function names and bindings.
8213<DT><B>-s</B>
8214
8215<DD>
8216Display <B>readline</B> key sequences bound to macros and the strings
8217they output in such a way that they can be re-read.
8218<DT><B>-S</B>
8219
8220<DD>
8221Display <B>readline</B> key sequences bound to macros and the strings
8222they output.
8223<DT><B>-v</B>
8224
8225<DD>
8226Display <B>readline</B> variable names and values in such a way that they
8227can be re-read.
8228<DT><B>-V</B>
8229
8230<DD>
8231List current <B>readline</B> variable names and values.
8232<DT><B>-f </B><I>filename</I>
8233
8234<DD>
8235Read key bindings from <I>filename</I>.
8236<DT><B>-q </B><I>function</I>
8237
8238<DD>
8239Query about which keys invoke the named <I>function</I>.
8240<DT><B>-u </B><I>function</I>
8241
8242<DD>
8243Unbind all keys bound to the named <I>function</I>.
8244<DT><B>-r </B><I>keyseq</I>
8245
8246<DD>
8247Remove any current binding for <I>keyseq</I>.
8248<DT><B>-x </B><I>keyseq</I>:<I>shell-command</I>
8249
8250<DD>
8251Cause <I>shell-command</I> to be executed whenever <I>keyseq</I> is
8252entered.
8253When <I>shell-command</I> is executed, the shell sets the
8254<B>READLINE_LINE</B>
8255
8256variable to the contents of the <B>readline</B> line buffer and the
8257<B>READLINE_POINT</B>
8258
8259variable to the current location of the insertion point.
8260If the executed command changes the value of
8261<B>READLINE_LINE</B>
8262
8263or
8264<B>READLINE_POINT</B>,
8265
8266those new values will be reflected in the editing state.
8267
8268</DL>
8269<P>
8270
8271The return value is 0 unless an unrecognized option is given or an
8272error occurred.
8273</DL>
8274
8275<DT><B>break</B> [<I>n</I>]<DD>
8276Exit from within a
8277<B>for</B>,
8278
8279<B>while</B>,
8280
8281<B>until</B>,
8282
8283or
8284<B>select</B>
8285
8286loop. If <I>n</I> is specified, break <I>n</I> levels.
8287<I>n</I>
8288
8289must be >= 1. If
8290<I>n</I>
8291
8292is greater than the number of enclosing loops, all enclosing loops
8293are exited.
8294The return value is 0 unless <I>n</I> is not greater than or equal to 1.
8295<DT><B>builtin</B> <I>shell-builtin</I> [<I>arguments</I>]<DD>
8296Execute the specified shell builtin, passing it
8297<I>arguments</I>,
8298
8299and return its exit status.
8300This is useful when defining a
8301function whose name is the same as a shell builtin,
8302retaining the functionality of the builtin within the function.
8303The <B>cd</B> builtin is commonly redefined this way.
8304The return status is false if
8305<I>shell-builtin</I>
8306
8307is not a shell builtin command.
8308<DT><B>caller</B> [<I>expr</I>]<DD>
8309Returns the context of any active subroutine call (a shell function or
8310a script executed with the <B>.</B> or <B>source</B> builtins.
8311Without <I>expr</I>, <B>caller</B> displays the line number and source
8312filename of the current subroutine call.
8313If a non-negative integer is supplied as <I>expr</I>, <B>caller</B>
8314displays the line number, subroutine name, and source file corresponding
8315to that position in the current execution call stack. This extra
8316information may be used, for example, to print a stack trace. The
8317current frame is frame 0.
8318The return value is 0 unless the shell is not executing a subroutine
8319call or <I>expr</I> does not correspond to a valid position in the
8320call stack.
8321<DT><B>cd</B> [<B>-L|-P</B>] [<I>dir</I>]<DD>
8322Change the current directory to <I>dir</I>. The variable
8323<FONT SIZE=-1><B>HOME</B>
8324
8325</FONT>
8326is the
8327default
8328<I>dir</I>.
8329
8330The variable
8331<FONT SIZE=-1><B>CDPATH</B>
8332
8333</FONT>
8334defines the search path for the directory containing
8335<I>dir</I>.
8336
8337Alternative directory names in
8338<FONT SIZE=-1><B>CDPATH</B>
8339
8340</FONT>
8341are separated by a colon (:). A null directory name in
8342<FONT SIZE=-1><B>CDPATH</B>
8343
8344</FONT>
8345is the same as the current directory, i.e., ``<B>.</B>''. If
8346<I>dir</I>
8347
8348begins with a slash (/),
8349then
8350<FONT SIZE=-1><B>CDPATH</B>
8351
8352</FONT>
8353is not used. The
8354<B>-P</B>
8355
8356option says to use the physical directory structure instead of
8357following symbolic links (see also the
8358<B>-P</B>
8359
8360option to the
8361<B>set</B>
8362
8363builtin command); the
8364<B>-L</B>
8365
8366option forces symbolic links to be followed. An argument of
8367<B>-</B>
8368
8369is equivalent to
8370<FONT SIZE=-1><B>$OLDPWD</B>.
8371
8372</FONT>
8373If a non-empty directory name from <B>CDPATH</B> is used, or if
8374<B>-</B> is the first argument, and the directory change is
8375successful, the absolute pathname of the new working directory is
8376written to the standard output.
8377The return value is true if the directory was successfully changed;
8378false otherwise.
8379<DT><B>command</B> [<B>-pVv</B>] <I>command</I> [<I>arg</I> ...]<DD>
8380Run
8381<I>command</I>
8382
8383with
8384<I>args</I>
8385
8386suppressing the normal shell function lookup. Only builtin
8387commands or commands found in the
8388<FONT SIZE=-1><B>PATH</B>
8389
8390</FONT>
8391are executed. If the
8392<B>-p</B>
8393
8394option is given, the search for
8395<I>command</I>
8396
8397is performed using a default value for
8398<B>PATH</B>
8399
8400that is guaranteed to find all of the standard utilities.
8401If either the
8402<B>-V</B>
8403
8404or
8405<B>-v</B>
8406
8407option is supplied, a description of
8408<I>command</I>
8409
8410is printed. The
8411<B>-v</B>
8412
8413option causes a single word indicating the command or file name
8414used to invoke
8415<I>command</I>
8416
8417to be displayed; the
8418<B>-V</B>
8419
8420option produces a more verbose description.
8421If the
8422<B>-V</B>
8423
8424or
8425<B>-v</B>
8426
8427option is supplied, the exit status is 0 if
8428<I>command</I>
8429
8430was found, and 1 if not. If neither option is supplied and
8431an error occurred or
8432<I>command</I>
8433
8434cannot be found, the exit status is 127. Otherwise, the exit status of the
8435<B>command</B>
8436
8437builtin is the exit status of
8438<I>command</I>.
8439
8440<DT><B>compgen</B> [<I>option</I>] [<I>word</I>]<DD>
8441Generate possible completion matches for <I>word</I> according to
8442the <I>option</I>s, which may be any option accepted by the
8443<B>complete</B>
8444
8445builtin with the exception of <B>-p</B> and <B>-r</B>, and write
8446the matches to the standard output.
8447When using the <B>-F</B> or <B>-C</B> options, the various shell variables
8448set by the programmable completion facilities, while available, will not
8449have useful values.
8450<P>
8451The matches will be generated in the same way as if the programmable
8452completion code had generated them directly from a completion specification
8453with the same flags.
8454If <I>word</I> is specified, only those completions matching <I>word</I>
8455will be displayed.
8456<P>
8457The return value is true unless an invalid option is supplied, or no
8458matches were generated.
8459<DT><B>complete</B> [<B>-abcdefgjksuv</B>] [<B>-o</B> <I>comp-option</I>] [<B>-E</B>] [<B>-A</B> <I>action</I>] [<B>-G</B> <I>globpat</I>] [<B>-W</B> <I>wordlist</I>] [<B>-F</B> <I>function</I>] [<B>-C</B> <I>command</I>]<DD>
8460<BR>
8461
8462[<B>-X</B> <I>filterpat</I>] [<B>-P</B> <I>prefix</I>] [<B>-S</B> <I>suffix</I>] <I>name</I> [<I>name ...</I>]
8463
8464<DT><B>complete</B> <B>-pr</B> [<B>-E</B>] [<I>name</I> ...]<DD>
8465
8466Specify how arguments to each <I>name</I> should be completed.
8467If the <B>-p</B> option is supplied, or if no options are supplied,
8468existing completion specifications are printed in a way that allows
8469them to be reused as input.
8470The <B>-r</B> option removes a completion specification for
8471each <I>name</I>, or, if no <I>name</I>s are supplied, all
8472completion specifications.
8473The <B>-E</B> option indicates that the remaining options and actions should
8474apply to ``empty'' command completion; that is, completion attempted on a
8475blank line.
8476<P>
8477The process of applying these completion specifications when word completion
8478is attempted is described above under <B>Programmable Completion</B>.
8479<P>
8480Other options, if specified, have the following meanings.
8481The arguments to the <B>-G</B>, <B>-W</B>, and <B>-X</B> options
8482(and, if necessary, the <B>-P</B> and <B>-S</B> options)
8483should be quoted to protect them from expansion before the
8484<B>complete</B>
8485
8486builtin is invoked.
8487<DL COMPACT><DT><DD>
8488
8489<DL COMPACT>
8490<DT><B>-o</B> <I>comp-option</I><DD>
8491The <I>comp-option</I> controls several aspects of the compspec's behavior
8492beyond the simple generation of completions.
8493<I>comp-option</I> may be one of:
8494<DL COMPACT><DT><DD>
8495<DL COMPACT>
8496<DT><B>bashdefault</B>
8497
8498<DD>
8499Perform the rest of the default <B>bash</B> completions if the compspec
8500generates no matches.
8501<DT><B>default</B>
8502
8503<DD>
8504Use readline's default filename completion if the compspec generates
8505no matches.
8506<DT><B>dirnames</B>
8507
8508<DD>
8509Perform directory name completion if the compspec generates no matches.
8510<DT><B>filenames</B>
8511
8512<DD>
8513Tell readline that the compspec generates filenames, so it can perform any
8514filename-specific processing (like adding a slash to directory names,
8515quoting special characters, or suppressing trailing spaces).
8516Intended to be used with shell functions.
8517<DT><B>nospace</B>
8518
8519<DD>
8520Tell readline not to append a space (the default) to words completed at
8521the end of the line.
8522<DT><B>plusdirs</B>
8523
8524<DD>
8525After any matches defined by the compspec are generated,
8526directory name completion is attempted and any
8527matches are added to the results of the other actions.
8528</DL></DL>
8529
8530<DT><B>-A</B> <I>action</I><DD>
8531The <I>action</I> may be one of the following to generate a list of possible
8532completions:
8533<DL COMPACT><DT><DD>
8534<DL COMPACT>
8535<DT><B>alias</B>
8536
8537<DD>
8538Alias names. May also be specified as <B>-a</B>.
8539<DT><B>arrayvar</B>
8540
8541<DD>
8542Array variable names.
8543<DT><B>binding</B>
8544
8545<DD>
8546<B>Readline</B> key binding names.
8547<DT><B>builtin</B>
8548
8549<DD>
8550Names of shell builtin commands. May also be specified as <B>-b</B>.
8551<DT><B>command</B>
8552
8553<DD>
8554Command names. May also be specified as <B>-c</B>.
8555<DT><B>directory</B>
8556
8557<DD>
8558Directory names. May also be specified as <B>-d</B>.
8559<DT><B>disabled</B>
8560
8561<DD>
8562Names of disabled shell builtins.
8563<DT><B>enabled</B>
8564
8565<DD>
8566Names of enabled shell builtins.
8567<DT><B>export</B>
8568
8569<DD>
8570Names of exported shell variables. May also be specified as <B>-e</B>.
8571<DT><B>file</B>
8572
8573<DD>
8574File names. May also be specified as <B>-f</B>.
8575<DT><B>function</B>
8576
8577<DD>
8578Names of shell functions.
8579<DT><B>group</B>
8580
8581<DD>
8582Group names. May also be specified as <B>-g</B>.
8583<DT><B>helptopic</B>
8584
8585<DD>
8586Help topics as accepted by the <B>help</B> builtin.
8587<DT><B>hostname</B>
8588
8589<DD>
8590Hostnames, as taken from the file specified by the
8591<FONT SIZE=-1><B>HOSTFILE</B>
8592
8593</FONT>
8594shell variable.
8595<DT><B>job</B>
8596
8597<DD>
8598Job names, if job control is active. May also be specified as <B>-j</B>.
8599<DT><B>keyword</B>
8600
8601<DD>
8602Shell reserved words. May also be specified as <B>-k</B>.
8603<DT><B>running</B>
8604
8605<DD>
8606Names of running jobs, if job control is active.
8607<DT><B>service</B>
8608
8609<DD>
8610Service names. May also be specified as <B>-s</B>.
8611<DT><B>setopt</B>
8612
8613<DD>
8614Valid arguments for the <B>-o</B> option to the <B>set</B> builtin.
8615<DT><B>shopt</B>
8616
8617<DD>
8618Shell option names as accepted by the <B>shopt</B> builtin.
8619<DT><B>signal</B>
8620
8621<DD>
8622Signal names.
8623<DT><B>stopped</B>
8624
8625<DD>
8626Names of stopped jobs, if job control is active.
8627<DT><B>user</B>
8628
8629<DD>
8630User names. May also be specified as <B>-u</B>.
8631<DT><B>variable</B>
8632
8633<DD>
8634Names of all shell variables. May also be specified as <B>-v</B>.
8635</DL></DL>
8636
8637<DT><B>-G</B> <I>globpat</I><DD>
8638The filename expansion pattern <I>globpat</I> is expanded to generate
8639the possible completions.
8640<DT><B>-W</B> <I>wordlist</I><DD>
8641The <I>wordlist</I> is split using the characters in the
8642<FONT SIZE=-1><B>IFS</B>
8643
8644</FONT>
8645special variable as delimiters, and each resultant word is expanded.
8646The possible completions are the members of the resultant list which
8647match the word being completed.
8648<DT><B>-C</B> <I>command</I><DD>
8649<I>command</I> is executed in a subshell environment, and its output is
8650used as the possible completions.
8651<DT><B>-F</B> <I>function</I><DD>
8652The shell function <I>function</I> is executed in the current shell
8653environment.
8654When it finishes, the possible completions are retrieved from the value
8655of the
8656<FONT SIZE=-1><B>COMPREPLY</B>
8657
8658</FONT>
8659array variable.
8660<DT><B>-X</B> <I>filterpat</I><DD>
8661<I>filterpat</I> is a pattern as used for filename expansion.
8662It is applied to the list of possible completions generated by the
8663preceding options and arguments, and each completion matching
8664<I>filterpat</I> is removed from the list.
8665A leading <B>!</B> in <I>filterpat</I> negates the pattern; in this
8666case, any completion not matching <I>filterpat</I> is removed.
8667<DT><B>-P</B> <I>prefix</I><DD>
8668<I>prefix</I> is added at the beginning of each possible completion
8669after all other options have been applied.
8670<DT><B>-S</B> <I>suffix</I><DD>
8671<I>suffix</I> is appended to each possible completion
8672after all other options have been applied.
8673
8674</DL>
8675<P>
8676
8677The return value is true unless an invalid option is supplied, an option
8678other than <B>-p</B> or <B>-r</B> is supplied without a <I>name</I>
8679argument, an attempt is made to remove a completion specification for
8680a <I>name</I> for which no specification exists, or
8681an error occurs adding a completion specification.
8682</DL>
8683
8684<DT><B>compopt</B> [<B>-o</B> <I>option</I>] [<B>+o</B> <I>option</I>] [<I>name</I>]<DD>
8685Modify completion options for each <I>name</I> according to the
8686<I>option</I>s, or for the
8687currently-execution completion if no <I>name</I>s are supplied.
8688If no <I>option</I>s are given, display the completion options for each
8689<I>name</I> or the current completion.
8690The possible values of <I>option</I> are those valid for the <B>complete</B>
8691builtin described above.
8692</DL>
8693<P>
8694
8695The return value is true unless an invalid option is supplied, an attempt
8696is made to modify the options for a <I>name</I> for which no completion
8697specification exists, or an output error occurs.
8698<DL COMPACT>
8699<DT><B>continue</B> [<I>n</I>]<DD>
8700Resume the next iteration of the enclosing
8701<B>for</B>,
8702
8703<B>while</B>,
8704
8705<B>until</B>,
8706
8707or
8708<B>select</B>
8709
8710loop.
8711If
8712<I>n</I>
8713
8714is specified, resume at the <I>n</I>th enclosing loop.
8715<I>n</I>
8716
8717must be >= 1. If
8718<I>n</I>
8719
8720is greater than the number of enclosing loops, the last enclosing loop
8721(the ``top-level'' loop) is resumed.
8722The return value is 0 unless <I>n</I> is not greater than or equal to 1.
8723<DT><B>declare</B> [<B>-aAfFilrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
8724
8725<DT><B>typeset</B> [<B>-aAfFilrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
8726
8727Declare variables and/or give them attributes.
8728If no <I>name</I>s are given then display the values of variables.
8729The
8730<B>-p</B>
8731
8732option will display the attributes and values of each
8733<I>name</I>.
8734
8735When
8736<B>-p</B>
8737
8738is used with <I>name</I> arguments, additional options are ignored.
8739When
8740<B>-p</B>
8741
8742is supplied without <I>name</I> arguments, it will display the attributes
8743and values of all variables having the attributes specified by the
8744additional options.
8745If no other options are supplied with <B>-p</B>, <B>declare</B> will display
8746the attributes and values of all shell variables. The <B>-f</B> option
8747will restrict the display to shell functions.
8748The
8749<B>-F</B>
8750
8751option inhibits the display of function definitions; only the
8752function name and attributes are printed.
8753If the <B>extdebug</B> shell option is enabled using <B>shopt</B>,
8754the source file name and line number where the function is defined
8755are displayed as well. The
8756<B>-F</B>
8757
8758option implies
8759<B>-f</B>.
8760
8761The following options can
8762be used to restrict output to variables with the specified attribute or
8763to give variables attributes:
8764<DL COMPACT><DT><DD>
8765
8766<DL COMPACT>
8767<DT><B>-a</B>
8768
8769<DD>
8770Each <I>name</I> is an indexed array variable (see
8771<B>Arrays</B>
8772
8773above).
8774<DT><B>-A</B>
8775
8776<DD>
8777Each <I>name</I> is an associative array variable (see
8778<B>Arrays</B>
8779
8780above).
8781<DT><B>-f</B>
8782
8783<DD>
8784Use function names only.
8785<DT><B>-i</B>
8786
8787<DD>
8788The variable is treated as an integer; arithmetic evaluation (see
8789<FONT SIZE=-1><B>ARITHMETIC EVALUATION ) </B>
8790
8791</FONT>
8792is performed when the variable is assigned a value.
8793<DT><B>-l</B>
8794
8795<DD>
8796When the variable is assigned a value, all upper-case characters are
8797converted to lower-case.
8798The upper-case attribute is disabled.
8799<DT><B>-r</B>
8800
8801<DD>
8802Make <I>name</I>s readonly. These names cannot then be assigned values
8803by subsequent assignment statements or unset.
8804<DT><B>-t</B>
8805
8806<DD>
8807Give each <I>name</I> the <I>trace</I> attribute.
8808Traced functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps from
8809the calling shell.
8810The trace attribute has no special meaning for variables.
8811<DT><B>-u</B>
8812
8813<DD>
8814When the variable is assigned a value, all lower-case characters are
8815converted to upper-case.
8816The lower-case attribute is disabled.
8817<DT><B>-x</B>
8818
8819<DD>
8820Mark <I>name</I>s for export to subsequent commands via the environment.
8821
8822</DL>
8823<P>
8824
8825Using `+' instead of `-'
8826turns off the attribute instead,
8827with the exceptions that <B>+a</B>
8828may not be used to destroy an array variable and <B>+r will not
8829remove the readonly attribute.
8830When used in a function,
8831makes each
8832</B><I>name</I> local, as with the
8833<B>local</B>
8834
8835command.
8836If a variable name is followed by =<I>value</I>, the value of
8837the variable is set to <I>value</I>.
8838The return value is 0 unless an invalid option is encountered,
8839an attempt is made to define a function using
8840
8841<TT>-f foo=bar</TT>,
8842an attempt is made to assign a value to a readonly variable,
8843an attempt is made to assign a value to an array variable without
8844using the compound assignment syntax (see
8845<B>Arrays</B>
8846
8847above), one of the <I>names</I> is not a valid shell variable name,
8848an attempt is made to turn off readonly status for a readonly variable,
8849an attempt is made to turn off array status for an array variable,
8850or an attempt is made to display a non-existent function with <B>-f</B>.
8851</DL>
8852
8853<DT><B>dirs [+</B><I>n</I>] [-<I>n</I>] [<B>-cplv</B>]
8854
8855<DD>
8856Without options, displays the list of currently remembered directories.
8857The default display is on a single line with directory names separated
8858by spaces.
8859Directories are added to the list with the
8860<B>pushd</B>
8861
8862command; the
8863<B>popd</B>
8864
8865command removes entries from the list.
8866<DL COMPACT><DT><DD>
8867
8868<DL COMPACT>
8869<DT><B>+</B><I>n</I><DD>
8870Displays the <I>n</I>th entry counting from the left of the list
8871shown by
8872<B>dirs</B>
8873
8874when invoked without options, starting with zero.
8875<DT><B>-</B><I>n</I><DD>
8876Displays the <I>n</I>th entry counting from the right of the list
8877shown by
8878<B>dirs</B>
8879
8880when invoked without options, starting with zero.
8881<DT><B>-c</B>
8882
8883<DD>
8884Clears the directory stack by deleting all of the entries.
8885<DT><B>-l</B>
8886
8887<DD>
8888Produces a longer listing; the default listing format uses a
8889tilde to denote the home directory.
8890<DT><B>-p</B>
8891
8892<DD>
8893Print the directory stack with one entry per line.
8894<DT><B>-v</B>
8895
8896<DD>
8897Print the directory stack with one entry per line,
8898prefixing each entry with its index in the stack.
8899
8900</DL>
8901<P>
8902
8903The return value is 0 unless an
8904invalid option is supplied or <I>n</I> indexes beyond the end
8905of the directory stack.
8906</DL>
8907
8908<DT><B>disown</B> [<B>-ar</B>] [<B>-h</B>] [<I>jobspec</I> ...]<DD>
8909Without options, each
8910<I>jobspec</I>
8911
8912is removed from the table of active jobs.
8913If
8914<I>jobspec</I>
8915
8916is not present, and neither <B>-a nor -r</B> is supplied,
8917the shell's notion of the <I>current job</I> is used.
8918If the <B>-h</B> option is given, each
8919<I>jobspec</I>
8920
8921is not removed from the table, but is marked so that
8922<FONT SIZE=-1><B>SIGHUP</B>
8923
8924</FONT>
8925is not sent to the job if the shell receives a
8926<FONT SIZE=-1><B>SIGHUP</B>.
8927
8928</FONT>
8929If no
8930<I>jobspec</I>
8931
8932is present, and neither the
8933<B>-a</B>
8934
8935nor the
8936<B>-r</B>
8937
8938option is supplied, the <I>current job</I> is used.
8939If no
8940<I>jobspec</I>
8941
8942is supplied, the
8943<B>-a</B>
8944
8945option means to remove or mark all jobs; the
8946<B>-r</B>
8947
8948option without a
8949<I>jobspec</I>
8950
8951argument restricts operation to running jobs.
8952The return value is 0 unless a
8953<I>jobspec</I>
8954
8955does not specify a valid job.
8956<DT><B>echo</B> [<B>-neE</B>] [<I>arg</I> ...]<DD>
8957Output the <I>arg</I>s, separated by spaces, followed by a newline.
8958The return status is always 0.
8959If <B>-n</B> is specified, the trailing newline is
8960suppressed. If the <B>-e</B> option is given, interpretation of
8961the following backslash-escaped characters is enabled. The
8962<B>-E</B>
8963
8964option disables the interpretation of these escape characters,
8965even on systems where they are interpreted by default.
8966The <B>xpg_echo</B> shell option may be used to
8967dynamically determine whether or not <B>echo</B> expands these
8968escape characters by default.
8969<B>echo</B>
8970
8971does not interpret <B>--</B> to mean the end of options.
8972<B>echo</B>
8973
8974interprets the following escape sequences:
8975<DL COMPACT><DT><DD>
8976
8977<DL COMPACT>
8978<DT><B>\a</B>
8979
8980<DD>
8981alert (bell)
8982<DT><B>\b</B>
8983
8984<DD>
8985backspace
8986<DT><B>\c</B>
8987
8988<DD>
8989suppress further output
8990<DT><B>\e</B>
8991
8992<DD>
8993an escape character
8994<DT><B>\f</B>
8995
8996<DD>
8997form feed
8998<DT><B>\n</B>
8999
9000<DD>
9001new line
9002<DT><B>\r</B>
9003
9004<DD>
9005carriage return
9006<DT><B>\t</B>
9007
9008<DD>
9009horizontal tab
9010<DT><B>\v</B>
9011
9012<DD>
9013vertical tab
9014<DT><B>\\</B>
9015
9016<DD>
9017backslash
9018<DT><B>\0</B><I>nnn</I>
9019
9020<DD>
9021the eight-bit character whose value is the octal value <I>nnn</I>
9022(zero to three octal digits)
9023<DT><B>\x</B><I>HH</I>
9024
9025<DD>
9026the eight-bit character whose value is the hexadecimal value <I>HH</I>
9027(one or two hex digits)
9028
9029</DL></DL>
9030
9031<DT><B>enable</B> [<B>-a</B>] [<B>-dnps</B>] [<B>-f</B> <I>filename</I>] [<I>name</I> ...]<DD>
9032Enable and disable builtin shell commands.
9033Disabling a builtin allows a disk command which has the same name
9034as a shell builtin to be executed without specifying a full pathname,
9035even though the shell normally searches for builtins before disk commands.
9036If <B>-n</B> is used, each <I>name</I>
9037is disabled; otherwise,
9038<I>names</I> are enabled. For example, to use the
9039<B>test</B>
9040
9041binary found via the
9042<FONT SIZE=-1><B>PATH</B>
9043
9044</FONT>
9045instead of the shell builtin version, run
9046<TT>enable -n test</TT>.
9047
9048The
9049<B>-f</B>
9050
9051option means to load the new builtin command
9052<I>name</I>
9053
9054from shared object
9055<I>filename</I>,
9056
9057on systems that support dynamic loading. The
9058<B>-d</B>
9059
9060option will delete a builtin previously loaded with
9061<B>-f</B>.
9062
9063If no <I>name</I> arguments are given, or if the
9064<B>-p</B>
9065
9066option is supplied, a list of shell builtins is printed.
9067With no other option arguments, the list consists of all enabled
9068shell builtins.
9069If <B>-n</B> is supplied, only disabled builtins are printed.
9070If <B>-a</B> is supplied, the list printed includes all builtins, with an
9071indication of whether or not each is enabled.
9072If <B>-s</B> is supplied, the output is restricted to the POSIX
9073<I>special</I> builtins.
9074The return value is 0 unless a
9075<I>name</I>
9076
9077is not a shell builtin or there is an error loading a new builtin
9078from a shared object.
9079<DT><B>eval</B> [<I>arg</I> ...]<DD>
9080The <I>arg</I>s are read and concatenated together into a single
9081command. This command is then read and executed by the shell, and
9082its exit status is returned as the value of
9083<B>eval</B>.
9084
9085If there are no
9086<I>args</I>,
9087
9088or only null arguments,
9089<B>eval</B>
9090
9091returns 0.
9092<DT><B>exec</B> [<B>-cl</B>] [<B>-a</B> <I>name</I>] [<I>command</I> [<I>arguments</I>]]<DD>
9093If
9094<I>command</I>
9095
9096is specified, it replaces the shell.
9097No new process is created. The
9098<I>arguments</I>
9099
9100become the arguments to <I>command</I>.
9101If the
9102<B>-l</B>
9103
9104option is supplied,
9105the shell places a dash at the beginning of the zeroth argument passed to
9106<I>command</I>.
9107
9108This is what
9109<I>login</I>(1)
9110
9111does. The
9112<B>-c</B>
9113
9114option causes
9115<I>command</I>
9116
9117to be executed with an empty environment. If
9118<B>-a</B>
9119
9120is supplied, the shell passes
9121<I>name</I>
9122
9123as the zeroth argument to the executed command. If
9124<I>command</I>
9125
9126cannot be executed for some reason, a non-interactive shell exits,
9127unless the shell option
9128<B>execfail</B>
9129
9130is enabled, in which case it returns failure.
9131An interactive shell returns failure if the file cannot be executed.
9132If
9133<I>command</I>
9134
9135is not specified, any redirections take effect in the current shell,
9136and the return status is 0. If there is a redirection error, the
9137return status is 1.
9138<DT><B>exit</B> [<I>n</I>]<DD>
9139Cause the shell to exit
9140with a status of <I>n</I>. If
9141<I>n</I>
9142
9143is omitted, the exit status
9144is that of the last command executed.
9145A trap on
9146<FONT SIZE=-1><B>EXIT</B>
9147
9148</FONT>
9149is executed before the shell terminates.
9150<DT><B>export</B> [<B>-fn</B>] [<I>name</I>[=<I>word</I>]] ...<DD>
9151
9152<DT><B>export -p</B>
9153
9154<DD>
9155
9156The supplied
9157<I>names</I>
9158
9159are marked for automatic export to the environment of
9160subsequently executed commands. If the
9161<B>-f</B>
9162
9163option is given,
9164the
9165<I>names</I>
9166
9167refer to functions.
9168If no
9169<I>names</I>
9170
9171are given, or if the
9172<B>-p</B>
9173
9174option is supplied, a list
9175of all names that are exported in this shell is printed.
9176The
9177<B>-n</B>
9178
9179option causes the export property to be removed from each
9180<I>name</I>.
9181If a variable name is followed by =<I>word</I>, the value of
9182the variable is set to <I>word</I>.
9183<B>export</B>
9184
9185returns an exit status of 0 unless an invalid option is
9186encountered,
9187one of the <I>names</I> is not a valid shell variable name, or
9188<B>-f</B>
9189
9190is supplied with a
9191<I>name</I>
9192
9193that is not a function.
9194<DT><B>fc</B> [<B>-e</B> <I>ename</I>] [<B>-lnr</B>] [<I>first</I>] [<I>last</I>]<DD>
9195
9196<DT><B>fc</B> <B>-s</B> [<I>pat</I>=<I>rep</I>] [<I>cmd</I>]<DD>
9197
9198Fix Command. In the first form, a range of commands from
9199<I>first</I>
9200
9201to
9202<I>last</I>
9203
9204is selected from the history list.
9205<I>First</I>
9206
9207and
9208<I>last</I>
9209
9210may be specified as a string (to locate the last command beginning
9211with that string) or as a number (an index into the history list,
9212where a negative number is used as an offset from the current
9213command number). If
9214<I>last</I>
9215
9216is not specified it is set to
9217the current command for listing (so that
9218
9219<TT>fc -l -10</TT>
9220prints the last 10 commands) and to
9221<I>first</I>
9222
9223otherwise.
9224If
9225<I>first</I>
9226
9227is not specified it is set to the previous
9228command for editing and -16 for listing.
9229<P>
9230The
9231<B>-n</B>
9232
9233option suppresses
9234the command numbers when listing. The
9235<B>-r</B>
9236
9237option reverses the order of
9238the commands. If the
9239<B>-l</B>
9240
9241option is given,
9242the commands are listed on
9243standard output. Otherwise, the editor given by
9244<I>ename</I>
9245
9246is invoked
9247on a file containing those commands. If
9248<I>ename</I>
9249
9250is not given, the
9251value of the
9252<FONT SIZE=-1><B>FCEDIT</B>
9253
9254</FONT>
9255variable is used, and
9256the value of
9257<FONT SIZE=-1><B>EDITOR</B>
9258
9259</FONT>
9260if
9261<FONT SIZE=-1><B>FCEDIT</B>
9262
9263</FONT>
9264is not set. If neither variable is set,
9265
9266<I>vi</I>
9267
9268is used. When editing is complete, the edited commands are
9269echoed and executed.
9270<P>
9271In the second form, <I>command</I> is re-executed after each instance
9272of <I>pat</I> is replaced by <I>rep</I>.
9273A useful alias to use with this is
9274
9275<TT>r='fc -s'</TT>,
9276so that typing
9277
9278<TT>r cc</TT>
9279runs the last command beginning with
9280
9281<TT>cc</TT>
9282and typing
9283
9284<TT>r</TT>
9285re-executes the last command.
9286<P>
9287If the first form is used, the return value is 0 unless an invalid
9288option is encountered or
9289<I>first</I>
9290
9291or
9292<I>last</I>
9293
9294specify history lines out of range.
9295If the
9296<B>-e</B>
9297
9298option is supplied, the return value is the value of the last
9299command executed or failure if an error occurs with the temporary
9300file of commands. If the second form is used, the return status
9301is that of the command re-executed, unless
9302<I>cmd</I>
9303
9304does not specify a valid history line, in which case
9305<B>fc</B>
9306
9307returns failure.
9308<DT><B>fg</B> [<I>jobspec</I>]<DD>
9309Resume
9310<I>jobspec</I>
9311
9312in the foreground, and make it the current job.
9313If
9314<I>jobspec</I>
9315
9316is not present, the shell's notion of the <I>current job</I> is used.
9317The return value is that of the command placed into the foreground,
9318or failure if run when job control is disabled or, when run with
9319job control enabled, if
9320<I>jobspec</I>
9321
9322does not specify a valid job or
9323<I>jobspec</I>
9324
9325specifies a job that was started without job control.
9326<DT><B>getopts</B> <I>optstring</I> <I>name</I> [<I>args</I>]<DD>
9327<B>getopts</B>
9328
9329is used by shell procedures to parse positional parameters.
9330<I>optstring</I>
9331
9332contains the option characters to be recognized; if a character
9333is followed by a colon, the option is expected to have an
9334argument, which should be separated from it by white space.
9335The colon and question mark characters may not be used as
9336option characters.
9337Each time it is invoked,
9338<B>getopts</B>
9339
9340places the next option in the shell variable
9341<I>name</I>,
9342
9343initializing
9344<I>name</I>
9345
9346if it does not exist,
9347and the index of the next argument to be processed into the
9348variable
9349<FONT SIZE=-1><B>OPTIND</B>.
9350
9351</FONT>
9352<FONT SIZE=-1><B>OPTIND</B>
9353
9354</FONT>
9355is initialized to 1 each time the shell or a shell script
9356is invoked. When an option requires an argument,
9357<B>getopts</B>
9358
9359places that argument into the variable
9360<FONT SIZE=-1><B>OPTARG</B>.
9361
9362</FONT>
9363The shell does not reset
9364<FONT SIZE=-1><B>OPTIND</B>
9365
9366</FONT>
9367automatically; it must be manually reset between multiple
9368calls to
9369<B>getopts</B>
9370
9371within the same shell invocation if a new set of parameters
9372is to be used.
9373<P>
9374When the end of options is encountered, <B>getopts</B> exits with a
9375return value greater than zero.
9376<B>OPTIND</B> is set to the index of the first non-option argument,
9377and <B>name</B> is set to ?.
9378<P>
9379<B>getopts</B>
9380
9381normally parses the positional parameters, but if more arguments are
9382given in
9383<I>args</I>,
9384
9385<B>getopts</B>
9386
9387parses those instead.
9388<P>
9389<B>getopts</B>
9390
9391can report errors in two ways. If the first character of
9392<I>optstring</I>
9393
9394is a colon,
9395<I>silent</I>
9396
9397error reporting is used. In normal operation diagnostic messages
9398are printed when invalid options or missing option arguments are
9399encountered.
9400If the variable
9401<FONT SIZE=-1><B>OPTERR</B>
9402
9403</FONT>
9404is set to 0, no error messages will be displayed, even if the first
9405character of
9406<I>optstring</I>
9407
9408is not a colon.
9409<P>
9410If an invalid option is seen,
9411<B>getopts</B>
9412
9413places ? into
9414<I>name</I>
9415
9416and, if not silent,
9417prints an error message and unsets
9418<FONT SIZE=-1><B>OPTARG</B>.
9419
9420</FONT>
9421If
9422<B>getopts</B>
9423
9424is silent,
9425the option character found is placed in
9426<FONT SIZE=-1><B>OPTARG</B>
9427
9428</FONT>
9429and no diagnostic message is printed.
9430<P>
9431If a required argument is not found, and
9432<B>getopts</B>
9433
9434is not silent,
9435a question mark (<B>?</B>) is placed in
9436<I>name</I>,
9437
9438<FONT SIZE=-1><B>OPTARG</B>
9439
9440</FONT>
9441is unset, and a diagnostic message is printed.
9442If
9443<B>getopts</B>
9444
9445is silent, then a colon (<B>:</B>) is placed in
9446<I>name</I>
9447
9448and
9449<FONT SIZE=-1><B>OPTARG</B>
9450
9451</FONT>
9452is set to the option character found.
9453<P>
9454<B>getopts</B>
9455
9456returns true if an option, specified or unspecified, is found.
9457It returns false if the end of options is encountered or an
9458error occurs.
9459<DT><B>hash</B> [<B>-lr</B>] [<B>-p</B> <I>filename</I>] [<B>-dt</B>] [<I>name</I>]<DD>
9460For each
9461<I>name</I>,
9462
9463the full file name of the command is determined by searching
9464the directories in
9465<B>$PATH</B>
9466
9467and remembered.
9468If the
9469<B>-p</B>
9470
9471option is supplied, no path search is performed, and
9472<I>filename</I>
9473
9474is used as the full file name of the command.
9475The
9476<B>-r</B>
9477
9478option causes the shell to forget all
9479remembered locations.
9480The
9481<B>-d</B>
9482
9483option causes the shell to forget the remembered location of each <I>name</I>.
9484If the
9485<B>-t</B>
9486
9487option is supplied, the full pathname to which each <I>name</I> corresponds
9488is printed. If multiple <I>name</I> arguments are supplied with <B>-t</B>,
9489the <I>name</I> is printed before the hashed full pathname.
9490The
9491<B>-l</B>
9492
9493option causes output to be displayed in a format that may be reused as input.
9494If no arguments are given, or if only <B>-l</B> is supplied,
9495information about remembered commands is printed.
9496The return status is true unless a
9497<I>name</I>
9498
9499is not found or an invalid option is supplied.
9500<DT><B>help</B> [<B>-dms</B>] [<I>pattern</I>]<DD>
9501Display helpful information about builtin commands. If
9502<I>pattern</I>
9503
9504is specified,
9505<B>help</B>
9506
9507gives detailed help on all commands matching
9508<I>pattern</I>;
9509
9510otherwise help for all the builtins and shell control structures
9511is printed.
9512<DL COMPACT><DT><DD>
9513
9514<DL COMPACT>
9515<DT><B>-d</B>
9516
9517<DD>
9518Display a short description of each <I>pattern</I>
9519<DT><B>&nbsp;-m</B>
9520
9521<DD>
9522Display the description of each <I>pattern</I> in a manpage-like format
9523<DT><B>-s</B>
9524
9525<DD>
9526Display only a short usage synopsis for each <I>pattern</I>
9527
9528</DL></DL>
9529
9530The return status is 0 unless no command matches
9531<I>pattern</I>.
9532
9533<DT><B>history [</B><I>n</I>]<DD>
9534
9535<DT><B>history</B> <B>-c</B><DD>
9536<DT><B>history -d</B> <I>offset</I><DD>
9537<DT><B>history</B> <B>-anrw</B> [<I>filename</I>]<DD>
9538<DT><B>history</B> <B>-p</B> <I>arg</I> [<I>arg ...</I>]<DD>
9539<DT><B>history</B> <B>-s</B> <I>arg</I> [<I>arg ...</I>]<DD>
9540
9541With no options, display the command
9542history list with line numbers. Lines listed
9543with a
9544<B>*</B>
9545
9546have been modified. An argument of
9547<I>n</I>
9548
9549lists only the last
9550<I>n</I>
9551
9552lines.
9553If the shell variable <B>HISTTIMEFORMAT</B> is set and not null,
9554it is used as a format string for <I>strftime</I>(3) to display
9555the time stamp associated with each displayed history entry.
9556No intervening blank is printed between the formatted time stamp
9557and the history line.
9558If <I>filename</I> is supplied, it is used as the
9559name of the history file; if not, the value of
9560<FONT SIZE=-1><B>HISTFILE</B>
9561
9562</FONT>
9563is used. Options, if supplied, have the following meanings:
9564<DL COMPACT><DT><DD>
9565
9566<DL COMPACT>
9567<DT><B>-c</B>
9568
9569<DD>
9570Clear the history list by deleting all the entries.
9571<DT><B>-d</B> <I>offset</I><DD>
9572Delete the history entry at position <I>offset</I>.
9573<DT><B>-a</B>
9574
9575<DD>
9576Append the ``new'' history lines (history lines entered since the
9577beginning of the current <B>bash</B> session) to the history file.
9578<DT><B>-n</B>
9579
9580<DD>
9581Read the history lines not already read from the history
9582file into the current history list. These are lines
9583appended to the history file since the beginning of the
9584current <B>bash</B> session.
9585<DT><B>-r</B>
9586
9587<DD>
9588Read the contents of the history file
9589and use them as the current history.
9590<DT><B>-w</B>
9591
9592<DD>
9593Write the current history to the history file, overwriting the
9594history file's contents.
9595<DT><B>-p</B>
9596
9597<DD>
9598Perform history substitution on the following <I>args</I> and display
9599the result on the standard output.
9600Does not store the results in the history list.
9601Each <I>arg</I> must be quoted to disable normal history expansion.
9602<DT><B>-s</B>
9603
9604<DD>
9605Store the
9606<I>args</I>
9607
9608in the history list as a single entry. The last command in the
9609history list is removed before the
9610<I>args</I>
9611
9612are added.
9613
9614</DL>
9615<P>
9616
9617If the <B>HISTTIMEFORMAT</B> is set, the time stamp information
9618associated with each history entry is written to the history file,
9619marked with the history comment character.
9620When the history file is read, lines beginning with the history
9621comment character followed immediately by a digit are interpreted
9622as timestamps for the previous history line.
9623The return value is 0 unless an invalid option is encountered, an
9624error occurs while reading or writing the history file, an invalid
9625<I>offset</I> is supplied as an argument to <B>-d</B>, or the
9626history expansion supplied as an argument to <B>-p</B> fails.
9627</DL>
9628
9629<DT><B>jobs</B> [<B>-lnprs</B>] [ <I>jobspec</I> ... ]<DD>
9630
9631<DT><B>jobs</B> <B>-x</B> <I>command</I> [ <I>args</I> ... ]<DD>
9632
9633The first form lists the active jobs. The options have the following
9634meanings:
9635<DL COMPACT><DT><DD>
9636
9637<DL COMPACT>
9638<DT><B>-l</B>
9639
9640<DD>
9641List process IDs
9642in addition to the normal information.
9643<DT><B>-p</B>
9644
9645<DD>
9646List only the process ID of the job's process group
9647leader.
9648<DT><B>-n</B>
9649
9650<DD>
9651Display information only about jobs that have changed status since
9652the user was last notified of their status.
9653<DT><B>-r</B>
9654
9655<DD>
9656Restrict output to running jobs.
9657<DT><B>-s</B>
9658
9659<DD>
9660Restrict output to stopped jobs.
9661
9662</DL>
9663<P>
9664
9665If
9666<I>jobspec</I>
9667
9668is given, output is restricted to information about that job.
9669The return status is 0 unless an invalid option is encountered
9670or an invalid
9671<I>jobspec</I>
9672
9673is supplied.
9674<P>
9675
9676If the
9677<B>-x</B>
9678
9679option is supplied,
9680<B>jobs</B>
9681
9682replaces any
9683<I>jobspec</I>
9684
9685found in
9686<I>command</I>
9687
9688or
9689<I>args</I>
9690
9691with the corresponding process group ID, and executes
9692<I>command</I>
9693
9694passing it
9695<I>args</I>,
9696
9697returning its exit status.
9698</DL>
9699
9700<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>
9701
9702<DT><B>kill</B> <B>-l</B> [<I>sigspec</I> | <I>exit_status</I>]<DD>
9703
9704Send the signal named by
9705<I>sigspec</I>
9706
9707or
9708<I>signum</I>
9709
9710to the processes named by
9711<I>pid</I>
9712
9713or
9714<I>jobspec</I>.
9715
9716<I>sigspec</I>
9717
9718is either a case-insensitive signal name such as
9719<FONT SIZE=-1><B>SIGKILL</B>
9720
9721</FONT>
9722(with or without the
9723<FONT SIZE=-1><B>SIG</B>
9724
9725</FONT>
9726prefix) or a signal number;
9727<I>signum</I>
9728
9729is a signal number.
9730If
9731<I>sigspec</I>
9732
9733is not present, then
9734<FONT SIZE=-1><B>SIGTERM</B>
9735
9736</FONT>
9737is assumed.
9738An argument of
9739<B>-l</B>
9740
9741lists the signal names.
9742If any arguments are supplied when
9743<B>-l</B>
9744
9745is given, the names of the signals corresponding to the arguments are
9746listed, and the return status is 0.
9747The <I>exit_status</I> argument to
9748<B>-l</B>
9749
9750is a number specifying either a signal number or the exit status of
9751a process terminated by a signal.
9752<B>kill</B>
9753
9754returns true if at least one signal was successfully sent, or false
9755if an error occurs or an invalid option is encountered.
9756<DT><B>let</B> <I>arg</I> [<I>arg</I> ...]<DD>
9757Each
9758<I>arg</I>
9759
9760is an arithmetic expression to be evaluated (see
9761<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>).
9762
9763</FONT>
9764If the last
9765<I>arg</I>
9766
9767evaluates to 0,
9768<B>let</B>
9769
9770returns 1; 0 is returned otherwise.
9771<DT><B>local</B> [<I>option</I>] [<I>name</I>[=<I>value</I>] ...]<DD>
9772For each argument, a local variable named
9773<I>name </I>
9774
9775is created, and assigned
9776<I>value</I>.
9777
9778The <I>option</I> can be any of the options accepted by <B>declare</B>.
9779When
9780<B>local</B>
9781
9782is used within a function, it causes the variable
9783<I>name</I>
9784
9785to have a visible scope restricted to that function and its children.
9786With no operands,
9787<B>local</B>
9788
9789writes a list of local variables to the standard output. It is
9790an error to use
9791<B>local</B>
9792
9793when not within a function. The return status is 0 unless
9794<B>local</B>
9795
9796is used outside a function, an invalid
9797<I>name</I>
9798
9799is supplied, or
9800<I>name</I> is a readonly variable.
9801<DT><B>logout</B>
9802
9803<DD>
9804Exit a login shell.
9805<DT><B>mapfile</B> [<B>-n</B> <I>count</I>] [<B>-O</B> <I>origin</I>] [<B>-s</B> <I>count</I>] [<B>-t</B>] [<B>-u</B> <I>fd</I>] [<B>-C</B> <I>callback</I>] [<B>-c</B> <I>quantum</I>] [<I>array</I>]<DD>
9806
9807<DT><B>readarray</B> [<B>-n</B> <I>count</I>] [<B>-O</B> <I>origin</I>] [<B>-s</B> <I>count</I>] [<B>-t</B>] [<B>-u</B> <I>fd</I>] [<B>-C</B> <I>callback</I>] [<B>-c</B> <I>quantum</I>] [<I>array</I>]<DD>
9808
9809Read lines from the standard input into array variable
9810<I>array</I>,
9811
9812or from file descriptor
9813<I>fd</I>
9814
9815if the
9816<B>-u</B>
9817
9818option is supplied.
9819The variable <B>MAPFILE</B> is the default <I>array</I>.
9820Options, if supplied, have the following meanings:
9821<DL COMPACT><DT><DD>
9822
9823<DL COMPACT>
9824<DT><B>-n</B>
9825
9826<DD>
9827Copy at most
9828<I>count</I>
9829
9830lines. If <I>count</I> is 0, all lines are copied.
9831<DT><B>-O</B>
9832
9833<DD>
9834Begin assigning to
9835<I>array</I>
9836
9837at index
9838<I>origin</I>.
9839
9840The default index is 0.
9841<DT><B>-s</B>
9842
9843<DD>
9844Discard the first <I>count</I> lines read.
9845<DT><B>-t</B>
9846
9847<DD>
9848Remove a trailing line from each line read.
9849<DT><B>-u</B>
9850
9851<DD>
9852Read lines from file descriptor <I>fd</I> instead of the standard input.
9853<DT><B>-C</B>
9854
9855<DD>
9856Evaluate
9857<I>callback</I>
9858
9859each time <I>quantum</I> lines are read. The <B>-c</B> option specifies
9860<I>quantum</I>.
9861
9862<DT><B>-c</B>
9863
9864<DD>
9865Specify the number of lines read between each call to
9866<I>callback</I>.
9867
9868
9869</DL>
9870<P>
9871
9872If
9873<B>-C</B>
9874
9875is specified without
9876<B>-c</B>,
9877
9878the default quantum is 5000.
9879When <I>callback</I> is evaluated, it is supplied the index of the next
9880array element to be assigned as an additional argument.
9881<I>callback</I> is evaluated after the line is read but before the
9882array element is assigned.
9883<P>
9884
9885If not supplied with an explicit origin, <B>mapfile</B> will clear <I>array</I>
9886before assigning to it.
9887<P>
9888
9889<B>mapfile</B> returns successfully unless an invalid option or option
9890argument is supplied, or <I>array</I> is invalid or unassignable.
9891</DL>
9892
9893<DT><B>popd</B> [-<B>n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
9894Removes entries from the directory stack. With no arguments,
9895removes the top directory from the stack, and performs a
9896<B>cd</B>
9897
9898to the new top directory.
9899Arguments, if supplied, have the following meanings:
9900<DL COMPACT><DT><DD>
9901
9902<DL COMPACT>
9903<DT><B>-n</B>
9904
9905<DD>
9906Suppresses the normal change of directory when removing directories
9907from the stack, so that only the stack is manipulated.
9908<DT><B>+</B><I>n</I><DD>
9909Removes the <I>n</I>th entry counting from the left of the list
9910shown by
9911<B>dirs</B>,
9912
9913starting with zero. For example:
9914
9915<TT>popd +0</TT>
9916removes the first directory,
9917
9918<TT>popd +1</TT>
9919the second.
9920<DT><B>-</B><I>n</I><DD>
9921Removes the <I>n</I>th entry counting from the right of the list
9922shown by
9923<B>dirs</B>,
9924
9925starting with zero. For example:
9926
9927<TT>popd -0</TT>
9928removes the last directory,
9929
9930<TT>popd -1</TT>
9931the next to last.
9932
9933</DL>
9934<P>
9935
9936If the
9937<B>popd</B>
9938
9939command is successful, a
9940<B>dirs</B>
9941
9942is performed as well, and the return status is 0.
9943<B>popd</B>
9944
9945returns false if an invalid option is encountered, the directory stack
9946is empty, a non-existent directory stack entry is specified, or the
9947directory change fails.
9948</DL>
9949
9950<DT><B>printf</B> [<B>-v</B> <I>var</I>] <I>format</I> [<I>arguments</I>]<DD>
9951Write the formatted <I>arguments</I> to the standard output under the
9952control of the <I>format</I>.
9953The <I>format</I> is a character string which contains three types of objects:
9954plain characters, which are simply copied to standard output, character
9955escape sequences, which are converted and copied to the standard output, and
9956format specifications, each of which causes printing of the next successive
9957<I>argument</I>.
9958In addition to the standard <I>printf</I>(1) formats, <B>%b</B> causes
9959<B>printf</B> to expand backslash escape sequences in the corresponding
9960<I>argument</I> (except that <B>\c</B> terminates output, backslashes in
9961<B>\aq</B>, <B>\&quot;</B>, and <B>\?</B> are not removed, and octal escapes
9962beginning with <B>\0</B> may contain up to four digits),
9963and <B>%q</B> causes <B>printf</B> to output the corresponding
9964<I>argument</I> in a format that can be reused as shell input.
9965<P>
9966The <B>-v</B> option causes the output to be assigned to the variable
9967<I>var</I> rather than being printed to the standard output.
9968<P>
9969The <I>format</I> is reused as necessary to consume all of the <I>arguments</I>.
9970If the <I>format</I> requires more <I>arguments</I> than are supplied, the
9971extra format specifications behave as if a zero value or null string, as
9972appropriate, had been supplied. The return value is zero on success,
9973non-zero on failure.
9974<DT><B>pushd</B> [<B>-n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
9975
9976<DT><B>pushd</B> [<B>-n</B>] [<I>dir</I>]<DD>
9977
9978Adds a directory to the top of the directory stack, or rotates
9979the stack, making the new top of the stack the current working
9980directory. With no arguments, exchanges the top two directories
9981and returns 0, unless the directory stack is empty.
9982Arguments, if supplied, have the following meanings:
9983<DL COMPACT><DT><DD>
9984
9985<DL COMPACT>
9986<DT><B>-n</B>
9987
9988<DD>
9989Suppresses the normal change of directory when adding directories
9990to the stack, so that only the stack is manipulated.
9991<DT><B>+</B><I>n</I><DD>
9992Rotates the stack so that the <I>n</I>th directory
9993(counting from the left of the list shown by
9994<B>dirs</B>,
9995
9996starting with zero)
9997is at the top.
9998<DT><B>-</B><I>n</I><DD>
9999Rotates the stack so that the <I>n</I>th directory
10000(counting from the right of the list shown by
10001<B>dirs</B>,
10002
10003starting with zero) is at the top.
10004<DT><I>dir</I>
10005
10006<DD>
10007Adds
10008<I>dir</I>
10009
10010to the directory stack at the top, making it the
10011new current working directory.
10012
10013</DL>
10014<P>
10015
10016If the
10017<B>pushd</B>
10018
10019command is successful, a
10020<B>dirs</B>
10021
10022is performed as well.
10023If the first form is used,
10024<B>pushd</B>
10025
10026returns 0 unless the cd to
10027<I>dir</I>
10028
10029fails. With the second form,
10030<B>pushd</B>
10031
10032returns 0 unless the directory stack is empty,
10033a non-existent directory stack element is specified,
10034or the directory change to the specified new current directory
10035fails.
10036</DL>
10037
10038<DT><B>pwd</B> [<B>-LP</B>]<DD>
10039Print the absolute pathname of the current working directory.
10040The pathname printed contains no symbolic links if the
10041<B>-P</B>
10042
10043option is supplied or the
10044<B>-o physical</B>
10045
10046option to the
10047<B>set</B>
10048
10049builtin command is enabled.
10050If the
10051<B>-L</B>
10052
10053option is used, the pathname printed may contain symbolic links.
10054The return status is 0 unless an error occurs while
10055reading the name of the current directory or an
10056invalid option is supplied.
10057<DT><B>read</B> [<B>-ers</B>] [<B>-a</B> <I>aname</I>] [<B>-d</B> <I>delim</I>] [<B>-</B> <I>text</I>] [<B>-n</B> <I>nchars</I>] [<B>-p</B> <I>prompt</I>] [<B>-t</B> <I>timeout</I>] [<B>-u</B> <I>fd</I>] [<I>name</I> ...]<DD>
10058One line is read from the standard input, or from the file descriptor
10059<I>fd</I> supplied as an argument to the <B>-u</B> option, and the first word
10060is assigned to the first
10061<I>name</I>,
10062
10063the second word to the second
10064<I>name</I>,
10065
10066and so on, with leftover words and their intervening separators assigned
10067to the last
10068<I>name</I>.
10069
10070If there are fewer words read from the input stream than names,
10071the remaining names are assigned empty values.
10072The characters in
10073<FONT SIZE=-1><B>IFS</B>
10074
10075</FONT>
10076are used to split the line into words.
10077The backslash character (<B>\</B>) may be used to remove any special
10078meaning for the next character read and for line continuation.
10079Options, if supplied, have the following meanings:
10080<DL COMPACT><DT><DD>
10081
10082<DL COMPACT>
10083<DT><B>-a </B><I>aname</I>
10084
10085<DD>
10086The words are assigned to sequential indices
10087of the array variable
10088<I>aname</I>,
10089
10090starting at 0.
10091<I>aname</I>
10092
10093is unset before any new values are assigned.
10094Other <I>name</I> arguments are ignored.
10095<DT><B>-d </B><I>delim</I>
10096
10097<DD>
10098The first character of <I>delim</I> is used to terminate the input line,
10099rather than newline.
10100<DT><B>-e</B>
10101
10102<DD>
10103If the standard input
10104is coming from a terminal,
10105<B>readline</B>
10106
10107(see
10108<FONT SIZE=-1><B>READLINE</B>
10109
10110</FONT>
10111above) is used to obtain the line.
10112Readline uses the current (or default, if line editing was not previously
10113active) editing settings.
10114<DT><B>-i </B><I>text</I>
10115
10116<DD>
10117If
10118<B>readline</B>
10119
10120is being used to read the line, <I>text</I> is placed into the editing
10121buffer before editing begins.
10122<DT><B>-n </B><I>nchars</I>
10123
10124<DD>
10125<B>read</B> returns after reading <I>nchars</I> characters rather than
10126waiting for a complete line of input.
10127<DT><B>-p </B><I>prompt</I>
10128
10129<DD>
10130Display <I>prompt</I> on standard error, without a
10131trailing newline, before attempting to read any input. The prompt
10132is displayed only if input is coming from a terminal.
10133<DT><B>-r</B>
10134
10135<DD>
10136Backslash does not act as an escape character.
10137The backslash is considered to be part of the line.
10138In particular, a backslash-newline pair may not be used as a line
10139continuation.
10140<DT><B>-s</B>
10141
10142<DD>
10143Silent mode. If input is coming from a terminal, characters are
10144not echoed.
10145<DT><B>-t </B><I>timeout</I>
10146
10147<DD>
10148Cause <B>read</B> to time out and return failure if a complete line of
10149input is not read within <I>timeout</I> seconds.
10150<I>timeout</I> may be a decimal number with a fractional portion following
10151the decimal point.
10152This option is only effective if <B>read</B> is reading input from a
10153terminal, pipe, or other special file; it has no effect when reading
10154from regular files.
10155If <I>timeout</I> is 0, <B>read</B> returns success if input is available on
10156the specified file descriptor, failure otherwise.
10157The exit status is greater than 128 if the timeout is exceeded.
10158<DT><B>-u </B><I>fd</I>
10159
10160<DD>
10161Read input from file descriptor <I>fd</I>.
10162
10163</DL>
10164<P>
10165
10166If no
10167<I>names</I>
10168
10169are supplied, the line read is assigned to the variable
10170<FONT SIZE=-1><B>REPLY</B>.
10171
10172</FONT>
10173The return code is zero, unless end-of-file is encountered, <B>read</B>
10174times out (in which case the return code is greater than 128), or an
10175invalid file descriptor is supplied as the argument to <B>-u</B>.
10176</DL>
10177
10178<DT><B>readonly</B> [<B>-aApf</B>] [<I>name</I>[=<I>word</I>] ...]<DD>
10179
10180The given
10181<I>names</I> are marked readonly; the values of these
10182<I>names</I>
10183
10184may not be changed by subsequent assignment.
10185If the
10186<B>-f</B>
10187
10188option is supplied, the functions corresponding to the
10189<I>names</I> are so
10190marked.
10191The
10192<B>-a</B>
10193
10194option restricts the variables to indexed arrays; the
10195<B>-A</B>
10196
10197option restricts the variables to associative arrays.
10198If no
10199<I>name</I>
10200
10201arguments are given, or if the
10202<B>-p</B>
10203
10204option is supplied, a list of all readonly names is printed.
10205The
10206<B>-p</B>
10207
10208option causes output to be displayed in a format that
10209may be reused as input.
10210If a variable name is followed by =<I>word</I>, the value of
10211the variable is set to <I>word</I>.
10212The return status is 0 unless an invalid option is encountered,
10213one of the
10214<I>names</I>
10215
10216is not a valid shell variable name, or
10217<B>-f</B>
10218
10219is supplied with a
10220<I>name</I>
10221
10222that is not a function.
10223<DT><B>return</B> [<I>n</I>]<DD>
10224Causes a function to exit with the return value specified by
10225<I>n</I>.
10226
10227If
10228<I>n</I>
10229
10230is omitted, the return status is that of the last command
10231executed in the function body. If used outside a function,
10232but during execution of a script by the
10233<B>.</B>
10234
10235(<B>source</B>) command, it causes the shell to stop executing
10236that script and return either
10237<I>n</I>
10238
10239or the exit status of the last command executed within the
10240script as the exit status of the script. If used outside a
10241function and not during execution of a script by <B>.</B>,
10242the return status is false.
10243Any command associated with the <B>RETURN</B> trap is executed
10244before execution resumes after the function or script.
10245<DT><B>set</B> [<B>--abefhkmnptuvxBCEHPT</B>] [<B>-o</B> <I>option</I>] [<I>arg</I> ...]<DD>
10246
10247<DT><B>set</B> [<B>+abefhkmnptuvxBCEHPT</B>] [<B>+o</B> <I>option</I>] [<I>arg</I> ...]<DD>
10248
10249Without options, the name and value of each shell variable are displayed
10250in a format that can be reused as input
10251for setting or resetting the currently-set variables.
10252Read-only variables cannot be reset.
10253In <I>posix mode</I>, only shell variables are listed.
10254The output is sorted according to the current locale.
10255When options are specified, they set or unset shell attributes.
10256Any arguments remaining after option processing are treated
10257as values for the positional parameters and are assigned, in order, to
10258<B>$1</B>,
10259
10260<B>$2</B>,
10261
10262<B>...</B>
10263
10264<B>$</B><I>n</I>.
10265
10266Options, if specified, have the following meanings:
10267<DL COMPACT><DT><DD>
10268
10269<DL COMPACT>
10270<DT><B>-a</B>
10271
10272<DD>
10273Automatically mark variables and functions which are modified or
10274created for export to the environment of subsequent commands.
10275<DT><B>-b</B>
10276
10277<DD>
10278Report the status of terminated background jobs
10279immediately, rather than before the next primary prompt. This is
10280effective only when job control is enabled.
10281<DT><B>-e</B>
10282
10283<DD>
10284Exit immediately if a <I>simple command</I> (see
10285<FONT SIZE=-1><B>SHELL GRAMMAR</B>
10286
10287</FONT>
10288above) exits with a non-zero status.
10289The shell does not exit if the
10290command that fails is part of the command list immediately following a
10291<B>while</B>
10292
10293or
10294<B>until</B>
10295
10296keyword,
10297part of the test in an
10298<B>if</B>
10299
10300statement, part of a command executed in a
10301<B>&amp;&amp;</B>
10302
10303or
10304<B>||</B>
10305
10306list,
10307any command in a pipeline but the last,
10308or if the command's return value is
10309being inverted via
10310<B>!</B>.
10311
10312Failing simple commands that are part of shell functions or command lists
10313enclosed in braces or parentheses satisfying the above conditions do not
10314cause the shell to exit.
10315A trap on <B>ERR</B>, if set, is executed before the shell exits.
10316<DT><B>-f</B>
10317
10318<DD>
10319Disable pathname expansion.
10320<DT><B>-h</B>
10321
10322<DD>
10323Remember the location of commands as they are looked up for execution.
10324This is enabled by default.
10325<DT><B>-k</B>
10326
10327<DD>
10328All arguments in the form of assignment statements
10329are placed in the environment for a command, not just
10330those that precede the command name.
10331<DT><B>-m</B>
10332
10333<DD>
10334Monitor mode. Job control is enabled. This option is on
10335by default for interactive shells on systems that support
10336it (see
10337<FONT SIZE=-1><B>JOB CONTROL</B>
10338
10339</FONT>
10340above). Background processes run in a separate process
10341group and a line containing their exit status is printed
10342upon their completion.
10343<DT><B>-n</B>
10344
10345<DD>
10346Read commands but do not execute them. This may be used to
10347check a shell script for syntax errors. This is ignored by
10348interactive shells.
10349<DT><B>-o </B><I>option-name</I>
10350
10351<DD>
10352The <I>option-name</I> can be one of the following:
10353<DL COMPACT><DT><DD>
10354<DL COMPACT>
10355<DT><B>allexport</B>
10356
10357<DD>
10358Same as
10359<B>-a</B>.
10360
10361<DT><B>braceexpand</B>
10362
10363<DD>
10364Same as
10365<B>-B</B>.
10366
10367<DT><B>emacs</B>
10368
10369<DD>
10370Use an emacs-style command line editing interface. This is enabled
10371by default when the shell is interactive, unless the shell is started
10372with the
10373<B>--noediting</B>
10374
10375option.
10376This also affects the editing interface used for <B>read -e</B>.
10377<DT><B>errtrace</B>
10378
10379<DD>
10380Same as
10381<B>-E</B>.
10382
10383<DT><B>functrace</B>
10384
10385<DD>
10386Same as
10387<B>-T</B>.
10388
10389<DT><B>errexit</B>
10390
10391<DD>
10392Same as
10393<B>-e</B>.
10394
10395<DT><B>hashall</B>
10396
10397<DD>
10398Same as
10399<B>-h</B>.
10400
10401<DT><B>histexpand</B>
10402
10403<DD>
10404Same as
10405<B>-H</B>.
10406
10407<DT><B>history</B>
10408
10409<DD>
10410Enable command history, as described above under
10411<FONT SIZE=-1><B>HISTORY</B>.
10412
10413</FONT>
10414This option is on by default in interactive shells.
10415<DT><B>ignoreeof</B>
10416
10417<DD>
10418The effect is as if the shell command
10419<TT>IGNOREEOF=10</TT>
10420
10421had been executed
10422(see
10423<B>Shell Variables</B>
10424
10425above).
10426<DT><B>keyword</B>
10427
10428<DD>
10429Same as
10430<B>-k</B>.
10431
10432<DT><B>monitor</B>
10433
10434<DD>
10435Same as
10436<B>-m</B>.
10437
10438<DT><B>noclobber</B>
10439
10440<DD>
10441Same as
10442<B>-C</B>.
10443
10444<DT><B>noexec</B>
10445
10446<DD>
10447Same as
10448<B>-n</B>.
10449
10450<DT><B>noglob</B>
10451
10452<DD>
10453Same as
10454<B>-f</B>.
10455
10456<DT><B>nolog</B>
10457
10458<DD>
10459Currently ignored.
10460<DT><B>notify</B>
10461
10462<DD>
10463Same as
10464<B>-b</B>.
10465
10466<DT><B>nounset</B>
10467
10468<DD>
10469Same as
10470<B>-u</B>.
10471
10472<DT><B>onecmd</B>
10473
10474<DD>
10475Same as
10476<B>-t</B>.
10477
10478<DT><B>physical</B>
10479
10480<DD>
10481Same as
10482<B>-P</B>.
10483
10484<DT><B>pipefail</B>
10485
10486<DD>
10487If set, the return value of a pipeline is the value of the last
10488(rightmost) command to exit with a non-zero status, or zero if all
10489commands in the pipeline exit successfully.
10490This option is disabled by default.
10491<DT><B>posix</B>
10492
10493<DD>
10494Change the behavior of
10495<B>bash</B>
10496
10497where the default operation differs
10498from the POSIX standard to match the standard (<I>posix mode</I>).
10499<DT><B>privileged</B>
10500
10501<DD>
10502Same as
10503<B>-p</B>.
10504
10505<DT><B>verbose</B>
10506
10507<DD>
10508Same as
10509<B>-v</B>.
10510
10511<DT><B>vi</B>
10512
10513<DD>
10514Use a vi-style command line editing interface.
10515This also affects the editing interface used for <B>read -e</B>.
10516<DT><B>xtrace</B>
10517
10518<DD>
10519Same as
10520<B>-x</B>.
10521
10522<P>
10523</DL>
10524<P>
10525
10526If
10527<B>-o</B>
10528
10529is supplied with no <I>option-name</I>, the values of the current options are
10530printed.
10531If
10532<B>+o</B>
10533
10534is supplied with no <I>option-name</I>, a series of
10535<B>set</B>
10536
10537commands to recreate the current option settings is displayed on
10538the standard output.
10539</DL>
10540
10541<DT><B>-p</B>
10542
10543<DD>
10544Turn on
10545<I>privileged</I>
10546
10547mode. In this mode, the
10548<FONT SIZE=-1><B>$ENV</B>
10549
10550</FONT>
10551and
10552<FONT SIZE=-1><B>$BASH_ENV</B>
10553
10554</FONT>
10555files are not processed, shell functions are not inherited from the
10556environment, and the
10557<FONT SIZE=-1><B>SHELLOPTS</B>,
10558
10559</FONT>
10560<B>CDPATH</B>,
10561
10562and
10563<B>GLOBIGNORE</B>
10564
10565variables, if they appear in the environment, are ignored.
10566If the shell is started with the effective user (group) id not equal to the
10567real user (group) id, and the <B>-p</B> option is not supplied, these actions
10568are taken and the effective user id is set to the real user id.
10569If the <B>-p</B> option is supplied at startup, the effective user id is
10570not reset.
10571Turning this option off causes the effective user
10572and group ids to be set to the real user and group ids.
10573<DT><B>-t</B>
10574
10575<DD>
10576Exit after reading and executing one command.
10577<DT><B>-u</B>
10578
10579<DD>
10580Treat unset variables as an error when performing
10581parameter expansion. If expansion is attempted on an
10582unset variable, the shell prints an error message, and,
10583if not interactive, exits with a non-zero status.
10584<DT><B>-v</B>
10585
10586<DD>
10587Print shell input lines as they are read.
10588<DT><B>-x</B>
10589
10590<DD>
10591After expanding each <I>simple command</I>,
10592<B>for</B> command, <B>case</B> command, <B>select</B> command, or
10593arithmetic <B>for</B> command, display the expanded value of
10594<FONT SIZE=-1><B>PS4</B>,
10595
10596</FONT>
10597followed by the command and its expanded arguments
10598or associated word list.
10599<DT><B>-B</B>
10600
10601<DD>
10602The shell performs brace expansion (see
10603<B>Brace Expansion</B>
10604
10605above). This is on by default.
10606<DT><B>-C</B>
10607
10608<DD>
10609If set,
10610<B>bash</B>
10611
10612does not overwrite an existing file with the
10613<B>&gt;</B>,
10614
10615<B>&gt;&amp;</B>,
10616
10617and
10618<B>&lt;&gt;</B>
10619
10620redirection operators. This may be overridden when
10621creating output files by using the redirection operator
10622<B>&gt;|</B>
10623
10624instead of
10625<B>&gt;</B>.
10626
10627<DT><B>-E</B>
10628
10629<DD>
10630If set, any trap on <B>ERR</B> is inherited by shell functions, command
10631substitutions, and commands executed in a subshell environment.
10632The <B>ERR</B> trap is normally not inherited in such cases.
10633<DT><B>-H</B>
10634
10635<DD>
10636Enable
10637<B>!</B>
10638
10639style history substitution. This option is on by
10640default when the shell is interactive.
10641<DT><B>-P</B>
10642
10643<DD>
10644If set, the shell does not follow symbolic links when executing
10645commands such as
10646<B>cd</B>
10647
10648that change the current working directory. It uses the
10649physical directory structure instead. By default,
10650<B>bash</B>
10651
10652follows the logical chain of directories when performing commands
10653which change the current directory.
10654<DT><B>-T</B>
10655
10656<DD>
10657If set, any traps on <B>DEBUG</B> and <B>RETURN</B> are inherited by shell
10658functions, command substitutions, and commands executed in a
10659subshell environment.
10660The <B>DEBUG</B> and <B>RETURN</B> traps are normally not inherited
10661in such cases.
10662<DT><B>--</B>
10663
10664<DD>
10665If no arguments follow this option, then the positional parameters are
10666unset. Otherwise, the positional parameters are set to the
10667<I>arg</I>s, even if some of them begin with a
10668<B>-</B>.
10669
10670<DT><B>-</B>
10671
10672<DD>
10673Signal the end of options, cause all remaining <I>arg</I>s to be
10674assigned to the positional parameters. The
10675<B>-x</B>
10676
10677and
10678<B>-v</B>
10679
10680options are turned off.
10681If there are no <I>arg</I>s,
10682the positional parameters remain unchanged.
10683
10684</DL>
10685<P>
10686
10687The options are off by default unless otherwise noted.
10688Using + rather than - causes these options to be turned off.
10689The options can also be specified as arguments to an invocation of
10690the shell.
10691The current set of options may be found in
10692<B>$-</B>.
10693
10694The return status is always true unless an invalid option is encountered.
10695</DL>
10696
10697<DT><B>shift</B> [<I>n</I>]<DD>
10698The positional parameters from <I>n</I>+1 ... are renamed to
10699<B>$1</B>
10700
10701<B>....</B>
10702
10703Parameters represented by the numbers <B>$#</B>
10704down to <B>$#</B>-<I>n</I>+1 are unset.
10705<I>n</I>
10706
10707must be a non-negative number less than or equal to <B>$#</B>.
10708If
10709<I>n</I>
10710
10711is 0, no parameters are changed.
10712If
10713<I>n </I>
10714
10715is not given, it is assumed to be 1.
10716If
10717<I>n</I>
10718
10719is greater than <B>$#</B>, the positional parameters are not changed.
10720The return status is greater than zero if
10721<I>n</I>
10722
10723is greater than
10724<B>$#</B>
10725
10726or less than zero; otherwise 0.
10727<DT><B>shopt</B> [<B>-pqsu</B>] [<B>-o</B>] [<I>optname</I> ...]<DD>
10728Toggle the values of variables controlling optional shell behavior.
10729With no options, or with the
10730<B>-p</B>
10731
10732option, a list of all settable options is displayed, with
10733an indication of whether or not each is set.
10734The <B>-p</B> option causes output to be displayed in a form that
10735may be reused as input.
10736Other options have the following meanings:
10737<DL COMPACT><DT><DD>
10738
10739<DL COMPACT>
10740<DT><B>-s</B>
10741
10742<DD>
10743Enable (set) each <I>optname</I>.
10744<DT><B>-u</B>
10745
10746<DD>
10747Disable (unset) each <I>optname</I>.
10748<DT><B>-q</B>
10749
10750<DD>
10751Suppresses normal output (quiet mode); the return status indicates
10752whether the <I>optname</I> is set or unset.
10753If multiple <I>optname</I> arguments are given with
10754<B>-q</B>,
10755
10756the return status is zero if all <I>optnames</I> are enabled; non-zero
10757otherwise.
10758<DT><B>-o</B>
10759
10760<DD>
10761Restricts the values of <I>optname</I> to be those defined for the
10762<B>-o</B>
10763
10764option to the
10765<B>set</B>
10766
10767builtin.
10768
10769</DL>
10770<P>
10771
10772If either
10773<B>-s</B>
10774
10775or
10776<B>-u</B>
10777
10778is used with no <I>optname</I> arguments, the display is limited to
10779those options which are set or unset, respectively.
10780Unless otherwise noted, the <B>shopt</B> options are disabled (unset)
10781by default.
10782<P>
10783
10784The return status when listing options is zero if all <I>optnames</I>
10785are enabled, non-zero otherwise. When setting or unsetting options,
10786the return status is zero unless an <I>optname</I> is not a valid shell
10787option.
10788<P>
10789
10790The list of <B>shopt</B> options is:
10791<P>
10792
10793
10794
10795<DL COMPACT>
10796<DT><B>autocd</B>
10797
10798<DD>
10799If set, a command name that is the name of a directory is executed as if
10800it were the argument to the <B>cd</B> command.
10801This option is only used by interactive shells.
10802<DT><B>cdable_vars</B>
10803
10804<DD>
10805If set, an argument to the
10806<B>cd</B>
10807
10808builtin command that
10809is not a directory is assumed to be the name of a variable whose
10810value is the directory to change to.
10811<DT><B>cdspell</B>
10812
10813<DD>
10814If set, minor errors in the spelling of a directory component in a
10815<B>cd</B>
10816
10817command will be corrected.
10818The errors checked for are transposed characters,
10819a missing character, and one character too many.
10820If a correction is found, the corrected file name is printed,
10821and the command proceeds.
10822This option is only used by interactive shells.
10823<DT><B>checkhash</B>
10824
10825<DD>
10826If set, <B>bash</B> checks that a command found in the hash
10827table exists before trying to execute it. If a hashed command no
10828longer exists, a normal path search is performed.
10829<DT><B>checkjobs</B>
10830
10831<DD>
10832If set, <B>bash</B> lists the status of any stopped and running jobs before
10833exiting an interactive shell. If any jobs are running, this causes
10834the exit to be deferred until a second exit is attempted without an
10835intervening command (see <B>JOB CONTROL</B> above). The shell always
10836postpones exiting if any jobs are stopped.
10837<DT><B>checkwinsize</B>
10838
10839<DD>
10840If set, <B>bash</B> checks the window size after each command
10841and, if necessary, updates the values of
10842<FONT SIZE=-1><B>LINES</B>
10843
10844</FONT>
10845and
10846<FONT SIZE=-1><B>COLUMNS</B>.
10847
10848</FONT>
10849<DT><B>cmdhist</B>
10850
10851<DD>
10852If set,
10853<B>bash</B>
10854
10855attempts to save all lines of a multiple-line
10856command in the same history entry. This allows
10857easy re-editing of multi-line commands.
10858<DT><B>compat31</B>
10859
10860<DD>
10861If set,
10862<B>bash</B>
10863
10864changes its behavior to that of version 3.1 with respect to quoted
10865arguments to the conditional command's =~ operator.
10866<DT><B>dirspell</B>
10867
10868<DD>
10869If set,
10870<B>bash</B>
10871
10872attempts spelling correction on directory names during word completion
10873if the directory name initially supplied does not exist.
10874<DT><B>dotglob</B>
10875
10876<DD>
10877If set,
10878<B>bash</B>
10879
10880includes filenames beginning with a `.' in the results of pathname
10881expansion.
10882<DT><B>execfail</B>
10883
10884<DD>
10885If set, a non-interactive shell will not exit if
10886it cannot execute the file specified as an argument to the
10887<B>exec</B>
10888
10889builtin command. An interactive shell does not exit if
10890<B>exec</B>
10891
10892fails.
10893<DT><B>expand_aliases</B>
10894
10895<DD>
10896If set, aliases are expanded as described above under
10897<FONT SIZE=-1><B>ALIASES</B>.
10898
10899</FONT>
10900This option is enabled by default for interactive shells.
10901<DT><B>extdebug</B>
10902
10903<DD>
10904If set, behavior intended for use by debuggers is enabled:
10905<DL COMPACT><DT><DD>
10906<DL COMPACT>
10907<DT><B>1.</B>
10908
10909<DD>
10910The <B>-F</B> option to the <B>declare</B> builtin displays the source
10911file name and line number corresponding to each function name supplied
10912as an argument.
10913<DT><B>2.</B>
10914
10915<DD>
10916If the command run by the <B>DEBUG</B> trap returns a non-zero value, the
10917next command is skipped and not executed.
10918<DT><B>3.</B>
10919
10920<DD>
10921If the command run by the <B>DEBUG</B> trap returns a value of 2, and the
10922shell is executing in a subroutine (a shell function or a shell script
10923executed by the <B>.</B> or <B>source</B> builtins), a call to
10924<B>return</B> is simulated.
10925<DT><B>4.</B>
10926
10927<DD>
10928<B>BASH_ARGC</B> and <B>BASH_ARGV</B> are updated as described in their
10929descriptions above.
10930<DT><B>5.</B>
10931
10932<DD>
10933Function tracing is enabled: command substitution, shell functions, and
10934subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
10935<B>DEBUG</B> and <B>RETURN</B> traps.
10936<DT><B>6.</B>
10937
10938<DD>
10939Error tracing is enabled: command substitution, shell functions, and
10940subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
10941<B>ERROR</B> trap.
10942</DL></DL>
10943
10944<DT><B>extglob</B>
10945
10946<DD>
10947If set, the extended pattern matching features described above under
10948<B>Pathname Expansion</B> are enabled.
10949<DT><B>extquote</B>
10950
10951<DD>
10952If set, <B>$</B>aq<I>string</I>aq and <B>$</B>&quot;<I>string</I>&quot; quoting is
10953performed within <B>${</B><I>parameter</I><B>}</B> expansions
10954enclosed in double quotes. This option is enabled by default.
10955<DT><B>failglob</B>
10956
10957<DD>
10958If set, patterns which fail to match filenames during pathname expansion
10959result in an expansion error.
10960<DT><B>force_fignore</B>
10961
10962<DD>
10963If set, the suffixes specified by the <B>FIGNORE</B> shell variable
10964cause words to be ignored when performing word completion even if
10965the ignored words are the only possible completions.
10966See
10967<FONT SIZE=-1><B>SHELL VARIABLES</B></FONT>
10968above for a description of <B>FIGNORE</B>.
10969This option is enabled by default.
10970<DT><B>globstar</B>
10971
10972<DD>
10973If set, the pattern <B>**</B> used in a filename expansion context will
10974match a files and zero or more directories and subdirectories.
10975If the pattern is followed by a <B>/</B>, only directories and
10976subdirectories match.
10977<DT><B>gnu_errfmt</B>
10978
10979<DD>
10980If set, shell error messages are written in the standard GNU error
10981message format.
10982<DT><B>histappend</B>
10983
10984<DD>
10985If set, the history list is appended to the file named by the value
10986of the
10987<B>HISTFILE</B>
10988
10989variable when the shell exits, rather than overwriting the file.
10990<DT><B>histreedit</B>
10991
10992<DD>
10993If set, and
10994<B>readline</B>
10995
10996is being used, a user is given the opportunity to re-edit a
10997failed history substitution.
10998<DT><B>histverify</B>
10999
11000<DD>
11001If set, and
11002<B>readline</B>
11003
11004is being used, the results of history substitution are not immediately
11005passed to the shell parser. Instead, the resulting line is loaded into
11006the <B>readline</B> editing buffer, allowing further modification.
11007<DT><B>hostcomplete</B>
11008
11009<DD>
11010If set, and
11011<B>readline</B>
11012
11013is being used, <B>bash</B> will attempt to perform hostname completion when a
11014word containing a <B>@</B> is being completed (see
11015<B>Completing</B>
11016
11017under
11018<FONT SIZE=-1><B>READLINE</B>
11019
11020</FONT>
11021above).
11022This is enabled by default.
11023<DT><B>huponexit</B>
11024
11025<DD>
11026If set, <B>bash</B> will send
11027<FONT SIZE=-1><B>SIGHUP</B>
11028
11029</FONT>
11030to all jobs when an interactive login shell exits.
11031<DT><B>interactive_comments</B>
11032
11033<DD>
11034If set, allow a word beginning with
11035<B>#</B>
11036
11037to cause that word and all remaining characters on that
11038line to be ignored in an interactive shell (see
11039<FONT SIZE=-1><B>COMMENTS</B>
11040
11041</FONT>
11042above). This option is enabled by default.
11043<DT><B>lithist</B>
11044
11045<DD>
11046If set, and the
11047<B>cmdhist</B>
11048
11049option is enabled, multi-line commands are saved to the history with
11050embedded newlines rather than using semicolon separators where possible.
11051<DT><B>login_shell</B>
11052
11053<DD>
11054The shell sets this option if it is started as a login shell (see
11055<FONT SIZE=-1><B>INVOCATION</B>
11056
11057</FONT>
11058above).
11059The value may not be changed.
11060<DT><B>mailwarn</B>
11061
11062<DD>
11063If set, and a file that <B>bash</B> is checking for mail has been
11064accessed since the last time it was checked, the message ``The mail in
11065<I>mailfile</I> has been read'' is displayed.
11066<DT><B>no_empty_cmd_completion</B>
11067
11068<DD>
11069If set, and
11070<B>readline</B>
11071
11072is being used,
11073<B>bash</B>
11074
11075will not attempt to search the <B>PATH</B> for possible completions when
11076completion is attempted on an empty line.
11077<DT><B>nocaseglob</B>
11078
11079<DD>
11080If set,
11081<B>bash</B>
11082
11083matches filenames in a case-insensitive fashion when performing pathname
11084expansion (see
11085<B>Pathname Expansion</B>
11086
11087above).
11088<DT><B>nocasematch</B>
11089
11090<DD>
11091If set,
11092<B>bash</B>
11093
11094matches patterns in a case-insensitive fashion when performing matching
11095while executing <B>case</B> or <B>[[</B> conditional commands.
11096<DT><B>nullglob</B>
11097
11098<DD>
11099If set,
11100<B>bash</B>
11101
11102allows patterns which match no
11103files (see
11104<B>Pathname Expansion</B>
11105
11106above)
11107to expand to a null string, rather than themselves.
11108<DT><B>progcomp</B>
11109
11110<DD>
11111If set, the programmable completion facilities (see
11112<B>Programmable Completion</B> above) are enabled.
11113This option is enabled by default.
11114<DT><B>promptvars</B>
11115
11116<DD>
11117If set, prompt strings undergo
11118parameter expansion, command substitution, arithmetic
11119expansion, and quote removal after being expanded as described in
11120<FONT SIZE=-1><B>PROMPTING</B>
11121
11122</FONT>
11123above. This option is enabled by default.
11124<DT><B>restricted_shell</B>
11125
11126<DD>
11127The shell sets this option if it is started in restricted mode (see
11128<FONT SIZE=-1><B>RESTRICTED SHELL</B>
11129
11130</FONT>
11131below).
11132The value may not be changed.
11133This is not reset when the startup files are executed, allowing
11134the startup files to discover whether or not a shell is restricted.
11135<DT><B>shift_verbose</B>
11136
11137<DD>
11138If set, the
11139<B>shift</B>
11140
11141builtin prints an error message when the shift count exceeds the
11142number of positional parameters.
11143<DT><B>sourcepath</B>
11144
11145<DD>
11146If set, the
11147<B>source</B> (<B>.</B>) builtin uses the value of
11148<FONT SIZE=-1><B>PATH</B>
11149
11150</FONT>
11151to find the directory containing the file supplied as an argument.
11152This option is enabled by default.
11153<DT><B>xpg_echo</B>
11154
11155<DD>
11156If set, the <B>echo</B> builtin expands backslash-escape sequences
11157by default.
11158</DL></DL>
11159
11160<DT><B>suspend</B> [<B>-f</B>]<DD>
11161Suspend the execution of this shell until it receives a
11162<FONT SIZE=-1><B>SIGCONT</B>
11163
11164</FONT>
11165signal. A login shell cannot be suspended; the
11166<B>-f</B>
11167
11168option can be used to override this and force the suspension.
11169The return status is 0 unless the shell is a login shell and
11170<B>-f</B>
11171
11172is not supplied, or if job control is not enabled.
11173<DT><B>test</B> <I>expr</I><DD>
11174
11175<DT><B>[</B> <I>expr</I> <B>]</B><DD>
11176Return a status of 0 or 1 depending on
11177the evaluation of the conditional expression
11178<I>expr</I>.
11179
11180Each operator and operand must be a separate argument.
11181Expressions are composed of the primaries described above under
11182<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
11183
11184</FONT>
11185<B>test</B> does not accept any options, nor does it accept and ignore
11186an argument of <B>--</B> as signifying the end of options.
11187<P>
11188
11189
11190Expressions may be combined using the following operators, listed
11191in decreasing order of precedence.
11192The evaluation depends on the number of arguments; see below.
11193<DL COMPACT><DT><DD>
11194
11195<DL COMPACT>
11196<DT><B>! </B><I>expr</I>
11197
11198<DD>
11199True if
11200<I>expr</I>
11201
11202is false.
11203<DT><B>( </B><I>expr</I> )
11204
11205<DD>
11206Returns the value of <I>expr</I>.
11207This may be used to override the normal precedence of operators.
11208<DT><I>expr1</I> -<B>a</B> <I>expr2</I><DD>
11209True if both
11210<I>expr1</I>
11211
11212and
11213<I>expr2</I>
11214
11215are true.
11216<DT><I>expr1</I> -<B>o</B> <I>expr2</I><DD>
11217True if either
11218<I>expr1</I>
11219
11220or
11221<I>expr2</I>
11222
11223is true.
11224
11225</DL>
11226<P>
11227
11228<B>test</B> and <B>[</B> evaluate conditional
11229expressions using a set of rules based on the number of arguments.
11230<P>
11231
11232
11233
11234<DL COMPACT>
11235<DT>0 arguments<DD>
11236The expression is false.
11237<DT>1 argument<DD>
11238The expression is true if and only if the argument is not null.
11239<DT>2 arguments<DD>
11240If the first argument is <B>!</B>, the expression is true if and
11241only if the second argument is null.
11242If the first argument is one of the unary conditional operators listed above
11243under
11244<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
11245
11246</FONT>
11247the expression is true if the unary test is true.
11248If the first argument is not a valid unary conditional operator, the expression
11249is false.
11250<DT>3 arguments<DD>
11251If the second argument is one of the binary conditional operators listed above
11252under
11253<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
11254
11255</FONT>
11256the result of the expression is the result of the binary test using
11257the first and third arguments as operands.
11258The <B>-a</B> and <B>-o</B> operators are considered binary operators
11259when there are three arguments.
11260If the first argument is <B>!</B>, the value is the negation of
11261the two-argument test using the second and third arguments.
11262If the first argument is exactly <B>(</B> and the third argument is
11263exactly <B>)</B>, the result is the one-argument test of the second
11264argument.
11265Otherwise, the expression is false.
11266<DT>4 arguments<DD>
11267If the first argument is <B>!</B>, the result is the negation of
11268the three-argument expression composed of the remaining arguments.
11269Otherwise, the expression is parsed and evaluated according to
11270precedence using the rules listed above.
11271<DT>5 or more arguments<DD>
11272The expression is parsed and evaluated according to precedence
11273using the rules listed above.
11274</DL></DL>
11275
11276
11277<DT><B>times</B>
11278
11279<DD>
11280Print the accumulated user and system times for the shell and
11281for processes run from the shell. The return status is 0.
11282<DT><B>trap</B> [<B>-lp</B>] [[<I>arg</I>] <I>sigspec</I> ...]<DD>
11283The command
11284<I>arg</I>
11285
11286is to be read and executed when the shell receives
11287signal(s)
11288<I>sigspec</I>.
11289
11290If
11291<I>arg</I>
11292
11293is absent (and there is a single <I>sigspec</I>) or
11294<B>-</B>,
11295
11296each specified signal is
11297reset to its original disposition (the value it had
11298upon entrance to the shell).
11299If
11300<I>arg</I>
11301
11302is the null string the signal specified by each
11303<I>sigspec</I>
11304
11305is ignored by the shell and by the commands it invokes.
11306If
11307<I>arg</I>
11308
11309is not present and
11310<B>-p</B>
11311
11312has been supplied, then the trap commands associated with each
11313<I>sigspec</I>
11314
11315are displayed.
11316If no arguments are supplied or if only
11317<B>-p</B>
11318
11319is given,
11320<B>trap</B>
11321
11322prints the list of commands associated with each signal.
11323The
11324<B>-l</B>
11325
11326option causes the shell to print a list of signal names and
11327their corresponding numbers.
11328Each
11329<I>sigspec</I>
11330
11331is either
11332a signal name defined in &lt;<I>signal.h</I>&gt;, or a signal number.
11333Signal names are case insensitive and the SIG prefix is optional.
11334If a
11335<I>sigspec</I>
11336
11337is
11338<FONT SIZE=-1><B>EXIT</B>
11339
11340</FONT>
11341(0) the command
11342<I>arg</I>
11343
11344is executed on exit from the shell.
11345If a
11346<I>sigspec</I>
11347
11348is
11349<FONT SIZE=-1><B>DEBUG</B>,
11350
11351</FONT>
11352the command
11353<I>arg</I>
11354
11355is executed before every <I>simple command</I>, <I>for</I> command,
11356<I>case</I> command, <I>select</I> command, every arithmetic <I>for</I>
11357command, and before the first command executes in a shell function (see
11358<FONT SIZE=-1><B>SHELL GRAMMAR</B>
11359
11360</FONT>
11361above).
11362Refer to the description of the <B>extdebug</B> option to the
11363<B>shopt</B> builtin for details of its effect on the <B>DEBUG</B> trap.
11364If a
11365<I>sigspec</I>
11366
11367is
11368<FONT SIZE=-1><B>ERR</B>,
11369
11370</FONT>
11371the command
11372<I>arg</I>
11373
11374is executed whenever a simple command has a non-zero exit status,
11375subject to the following conditions.
11376The
11377<FONT SIZE=-1><B>ERR</B>
11378
11379</FONT>
11380trap is not executed if the failed
11381command is part of the command list immediately following a
11382<B>while</B>
11383
11384or
11385<B>until</B>
11386
11387keyword,
11388part of the test in an
11389<I>if</I>
11390
11391statement, part of a command executed in a
11392<B>&amp;&amp;</B>
11393
11394or
11395<B>||</B>
11396
11397list, or if the command's return value is
11398being inverted via
11399<B>!</B>.
11400
11401These are the same conditions obeyed by the <B>errexit</B> option.
11402If a
11403<I>sigspec</I>
11404
11405is
11406<FONT SIZE=-1><B>RETURN</B>,
11407
11408</FONT>
11409the command
11410<I>arg</I>
11411
11412is executed each time a shell function or a script executed with the
11413<B>.</B> or <B>source</B> builtins finishes executing.
11414Signals ignored upon entry to the shell cannot be trapped or reset.
11415Trapped signals that are not being ignored are reset to their original
11416values in a child process when it is created.
11417The return status is false if any
11418<I>sigspec</I>
11419
11420is invalid; otherwise
11421<B>trap</B>
11422
11423returns true.
11424<DT><B>type</B> [<B>-aftpP</B>] <I>name</I> [<I>name</I> ...]<DD>
11425With no options,
11426indicate how each
11427<I>name</I>
11428
11429would be interpreted if used as a command name.
11430If the
11431<B>-t</B>
11432
11433option is used,
11434<B>type</B>
11435
11436prints a string which is one of
11437<I>alias</I>,
11438
11439<I>keyword</I>,
11440
11441<I>function</I>,
11442
11443<I>builtin</I>,
11444
11445or
11446<I>file </I>
11447
11448if
11449<I>name</I>
11450
11451is an alias, shell reserved word, function, builtin, or disk file,
11452respectively.
11453If the
11454<I>name</I>
11455
11456is not found, then nothing is printed, and an exit status of false
11457is returned.
11458If the
11459<B>-p</B>
11460
11461option is used,
11462<B>type</B>
11463
11464either returns the name of the disk file
11465that would be executed if
11466<I>name</I>
11467
11468were specified as a command name,
11469or nothing if
11470<TT>type -t name</TT>
11471
11472would not return
11473<I>file</I>.
11474
11475The
11476<B>-P</B>
11477
11478option forces a
11479<FONT SIZE=-1><B>PATH</B>
11480
11481</FONT>
11482search for each <I>name</I>, even if
11483<TT>type -t name</TT>
11484
11485would not return
11486<I>file</I>.
11487
11488If a command is hashed,
11489<B>-p</B>
11490
11491and
11492<B>-P</B>
11493
11494print the hashed value, not necessarily the file that appears
11495first in
11496<FONT SIZE=-1><B>PATH</B>.
11497
11498</FONT>
11499If the
11500<B>-a</B>
11501
11502option is used,
11503<B>type</B>
11504
11505prints all of the places that contain
11506an executable named
11507<I>name</I>.
11508
11509This includes aliases and functions,
11510if and only if the
11511<B>-p</B>
11512
11513option is not also used.
11514The table of hashed commands is not consulted
11515when using
11516<B>-a</B>.
11517
11518The
11519<B>-f</B>
11520
11521option suppresses shell function lookup, as with the <B>command</B> builtin.
11522<B>type</B>
11523
11524returns true if all of the arguments are found, false if
11525any are not found.
11526<DT><B>ulimit</B> [<B>-HSTabcdefilmnpqrstuvx</B> [<I>limit</I>]]<DD>
11527Provides control over the resources available to the shell and to
11528processes started by it, on systems that allow such control.
11529The <B>-H</B> and <B>-S</B> options specify that the hard or soft limit is
11530set for the given resource.
11531A hard limit cannot be increased by a non-root user once it is set;
11532a soft limit may be increased up to the value of the hard limit.
11533If neither <B>-H</B> nor <B>-S</B> is specified, both the soft and hard
11534limits are set.
11535The value of
11536<I>limit</I>
11537
11538can be a number in the unit specified for the resource
11539or one of the special values
11540<B>hard</B>,
11541
11542<B>soft</B>,
11543
11544or
11545<B>unlimited</B>,
11546
11547which stand for the current hard limit, the current soft limit, and
11548no limit, respectively.
11549If
11550<I>limit</I>
11551
11552is omitted, the current value of the soft limit of the resource is
11553printed, unless the <B>-H</B> option is given. When more than one
11554resource is specified, the limit name and unit are printed before the value.
11555Other options are interpreted as follows:
11556<DL COMPACT><DT><DD>
11557
11558<DL COMPACT>
11559<DT><B>-a</B>
11560
11561<DD>
11562All current limits are reported
11563<DT><B>-b</B>
11564
11565<DD>
11566The maximum socket buffer size
11567<DT><B>-c</B>
11568
11569<DD>
11570The maximum size of core files created
11571<DT><B>-d</B>
11572
11573<DD>
11574The maximum size of a process's data segment
11575<DT><B>-e</B>
11576
11577<DD>
11578The maximum scheduling priority (&quot;nice&quot;)
11579<DT><B>-f</B>
11580
11581<DD>
11582The maximum size of files written by the shell and its children
11583<DT><B>-i</B>
11584
11585<DD>
11586The maximum number of pending signals
11587<DT><B>-l</B>
11588
11589<DD>
11590The maximum size that may be locked into memory
11591<DT><B>-m</B>
11592
11593<DD>
11594The maximum resident set size
11595<DT><B>-n</B>
11596
11597<DD>
11598The maximum number of open file descriptors (most systems do not
11599allow this value to be set)
11600<DT><B>-p</B>
11601
11602<DD>
11603The pipe size in 512-byte blocks (this may not be set)
11604<DT><B>-q</B>
11605
11606<DD>
11607The maximum number of bytes in POSIX message queues
11608<DT><B>-r</B>
11609
11610<DD>
11611The maximum real-time scheduling priority
11612<DT><B>-s</B>
11613
11614<DD>
11615The maximum stack size
11616<DT><B>-t</B>
11617
11618<DD>
11619The maximum amount of cpu time in seconds
11620<DT><B>-u</B>
11621
11622<DD>
11623The maximum number of processes available to a single user
11624<DT><B>-v</B>
11625
11626<DD>
11627The maximum amount of virtual memory available to the shell
11628<DT><B>-x</B>
11629
11630<DD>
11631The maximum number of file locks
11632<DT><B>-T</B>
11633
11634<DD>
11635The maximum number of threads
11636
11637</DL>
11638<P>
11639
11640If
11641<I>limit</I>
11642
11643is given, it is the new value of the specified resource (the
11644<B>-a</B>
11645
11646option is display only).
11647If no option is given, then
11648<B>-f</B>
11649
11650is assumed. Values are in 1024-byte increments, except for
11651<B>-t</B>,
11652
11653which is in seconds,
11654<B>-p</B>,
11655
11656which is in units of 512-byte blocks,
11657and
11658<B>-T</B>,
11659
11660<B>-b</B>,
11661
11662<B>-n</B>,
11663
11664and
11665<B>-u</B>,
11666
11667which are unscaled values.
11668The return status is 0 unless an invalid option or argument is supplied,
11669or an error occurs while setting a new limit.
11670</DL>
11671
11672<DT><B>umask</B> [<B>-p</B>] [<B>-S</B>] [<I>mode</I>]<DD>
11673The user file-creation mask is set to
11674<I>mode</I>.
11675
11676If
11677<I>mode</I>
11678
11679begins with a digit, it
11680is interpreted as an octal number; otherwise
11681it is interpreted as a symbolic mode mask similar
11682to that accepted by
11683<I>chmod</I>(1).
11684
11685If
11686<I>mode</I>
11687
11688is omitted, the current value of the mask is printed.
11689The
11690<B>-S</B>
11691
11692option causes the mask to be printed in symbolic form; the
11693default output is an octal number.
11694If the
11695<B>-p</B>
11696
11697option is supplied, and
11698<I>mode</I>
11699
11700is omitted, the output is in a form that may be reused as input.
11701The return status is 0 if the mode was successfully changed or if
11702no <I>mode</I> argument was supplied, and false otherwise.
11703<DT><B>unalias</B> [-<B>a</B>] [<I>name</I> ...]<DD>
11704Remove each <I>name</I> from the list of defined aliases. If
11705<B>-a</B>
11706
11707is supplied, all alias definitions are removed. The return
11708value is true unless a supplied
11709<I>name</I>
11710
11711is not a defined alias.
11712<DT><B>unset</B> [-<B>fv</B>] [<I>name</I> ...]<DD>
11713For each
11714<I>name</I>,
11715
11716remove the corresponding variable or function.
11717If no options are supplied, or the
11718<B>-v</B>
11719
11720option is given, each
11721<I>name</I>
11722
11723refers to a shell variable.
11724Read-only variables may not be unset.
11725If
11726<B>-f</B>
11727
11728is specified, each
11729<I>name</I>
11730
11731refers to a shell function, and the function definition
11732is removed.
11733Each unset variable or function is removed from the environment
11734passed to subsequent commands.
11735If any of
11736<FONT SIZE=-1><B>RANDOM</B>,
11737
11738</FONT>
11739<FONT SIZE=-1><B>SECONDS</B>,
11740
11741</FONT>
11742<FONT SIZE=-1><B>LINENO</B>,
11743
11744</FONT>
11745<FONT SIZE=-1><B>HISTCMD</B>,
11746
11747</FONT>
11748<FONT SIZE=-1><B>FUNCNAME</B>,
11749
11750</FONT>
11751<FONT SIZE=-1><B>GROUPS</B>,
11752
11753</FONT>
11754or
11755<FONT SIZE=-1><B>DIRSTACK</B>
11756
11757</FONT>
11758are unset, they lose their special properties, even if they are
11759subsequently reset. The exit status is true unless a
11760<I>name</I>
11761
11762is readonly.
11763<DT><B>wait</B> [<I>n ...</I>]<DD>
11764Wait for each specified process and return its termination status.
11765Each
11766<I>n</I>
11767
11768may be a process
11769ID or a job specification; if a job spec is given, all processes
11770in that job's pipeline are waited for. If
11771<I>n</I>
11772
11773is not given, all currently active child processes
11774are waited for, and the return status is zero. If
11775<I>n</I>
11776
11777specifies a non-existent process or job, the return status is
11778127. Otherwise, the return status is the exit status of the last
11779process or job waited for.
11780
11781
11782</DL>
11783<A NAME="lbDC">&nbsp;</A>
11784<H3>RESTRICTED SHELL</H3>
11785
11786
11787
11788<P>
11789
11790If
11791<B>bash</B>
11792
11793is started with the name
11794<B>rbash</B>,
11795
11796or the
11797<B>-r</B>
11798
11799option is supplied at invocation,
11800the shell becomes restricted.
11801A restricted shell is used to
11802set up an environment more controlled than the standard shell.
11803It behaves identically to
11804<B>bash</B>
11805
11806with the exception that the following are disallowed or not performed:
11807<DL COMPACT>
11808<DT>*<DD>
11809changing directories with <B>cd</B>
11810<DT>*<DD>
11811setting or unsetting the values of
11812<B>SHELL</B>,
11813
11814<B>PATH</B>,
11815
11816<B>ENV</B>,
11817
11818or
11819<B>BASH_ENV</B>
11820
11821<DT>*<DD>
11822specifying command names containing
11823<B>/</B>
11824
11825<DT>*<DD>
11826specifying a file name containing a
11827<B>/</B>
11828
11829as an argument to the
11830<B>.</B>
11831
11832builtin command
11833<DT>*<DD>
11834Specifying a filename containing a slash as an argument to the
11835<B>-p</B>
11836
11837option to the
11838<B>hash</B>
11839
11840builtin command
11841<DT>*<DD>
11842importing function definitions from the shell environment at startup
11843<DT>*<DD>
11844parsing the value of <B>SHELLOPTS</B> from the shell environment at startup
11845<DT>*<DD>
11846redirecting output using the &gt;, &gt;|, &lt;&gt;, &gt;&amp;, &amp;&gt;, and &gt;&gt; redirection operators
11847<DT>*<DD>
11848using the
11849<B>exec</B>
11850
11851builtin command to replace the shell with another command
11852<DT>*<DD>
11853adding or deleting builtin commands with the
11854<B>-f</B>
11855
11856and
11857<B>-d</B>
11858
11859options to the
11860<B>enable</B>
11861
11862builtin command
11863<DT>*<DD>
11864Using the <B>enable</B> builtin command to enable disabled shell builtins
11865<DT>*<DD>
11866specifying the
11867<B>-p</B>
11868
11869option to the
11870<B>command</B>
11871
11872builtin command
11873<DT>*<DD>
11874turning off restricted mode with
11875<B>set +r</B> or <B>set +o restricted</B>.
11876</DL>
11877<P>
11878
11879These restrictions are enforced after any startup files are read.
11880<P>
11881
11882
11883 When a command that is found to be a shell script is executed
11884(see
11885<FONT SIZE=-1><B>COMMAND EXECUTION</B>
11886
11887</FONT>
11888
11889above),
11890
11891<B>rbash</B>
11892
11893turns off any restrictions in the shell spawned to execute the
11894script.
11895
11896
11897<A NAME="lbDD">&nbsp;</A>
11898<H3>SEE ALSO</H3>
11899
11900
11901<DL COMPACT>
11902<DT><I>Bash Reference Manual</I>, Brian Fox and Chet Ramey<DD>
11903<DT><I>The Gnu Readline Library</I>, Brian Fox and Chet Ramey<DD>
11904<DT><I>The Gnu History Library</I>, Brian Fox and Chet Ramey<DD>
11905<DT><I>Portable Operating System Interface (POSIX) Part 2: Shell and Utilities</I>, IEEE<DD>
11906<DT><I>sh</I>(1), <I>ksh</I>(1), <I>csh</I>(1)<DD>
11907<DT><I>emacs</I>(1), <I>vi</I>(1)<DD>
11908<DT><I>readline</I>(3)<DD>
11909
11910</DL>
11911<A NAME="lbDE">&nbsp;</A>
11912<H3>FILES</H3>
11913
11914
11915<DL COMPACT>
11916<DT>
11917<A HREF="file:/bin/bash"><I>/bin/bash</I></A>
11918
11919<DD>
11920The <B>bash</B> executable
11921<DT>
11922<A HREF="file:/etc/profile"><I>/etc/profile</I></A>
11923
11924<DD>
11925The systemwide initialization file, executed for login shells
11926<DT>
11927<A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>
11928
11929<DD>
11930The personal initialization file, executed for login shells
11931<DT>
11932<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
11933
11934<DD>
11935The individual per-interactive-shell startup file
11936<DT>
11937<A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>
11938
11939<DD>
11940The individual login shell cleanup file, executed when a login shell exits
11941<DT>
11942<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
11943
11944<DD>
11945Individual <I>readline</I> initialization file
11946
11947</DL>
11948<A NAME="lbDF">&nbsp;</A>
11949<H3>AUTHORS</H3>
11950
11951Brian Fox, Free Software Foundation
11952<BR>
11953
11954<A HREF="mailto:bfox@gnu.org">bfox@gnu.org</A>
11955<P>
11956
11957Chet Ramey, Case Western Reserve University
11958<BR>
11959
11960<A HREF="mailto:chet@po.cwru.edu">chet@po.cwru.edu</A>
11961<A NAME="lbDG">&nbsp;</A>
11962<H3>BUG REPORTS</H3>
11963
11964If you find a bug in
11965<B>bash,</B>
11966
11967you should report it. But first, you should
11968make sure that it really is a bug, and that it appears in the latest
11969version of
11970<B>bash</B>.
11971
11972The latest version is always available from
11973<I><A HREF="ftp://ftp.gnu.org/pub/bash/">ftp://ftp.gnu.org/pub/bash/</A></I>.
11974<P>
11975
11976Once you have determined that a bug actually exists, use the
11977<I>bashbug</I>
11978
11979command to submit a bug report.
11980If you have a fix, you are encouraged to mail that as well!
11981Suggestions and `philosophical' bug reports may be mailed
11982to <I><A HREF="mailto:bug-bash@gnu.org">bug-bash@gnu.org</A></I> or posted to the Usenet
11983newsgroup
11984<A HREF="news:gnu.bash.bug">gnu.bash.bug</A>.
11985
11986<P>
11987
11988ALL bug reports should include:
11989<P>
11990
11991
11992<DL COMPACT>
11993<DT>The version number of <B>bash</B><DD>
11994<DT>The hardware and operating system<DD>
11995<DT>The compiler used to compile<DD>
11996<DT>A description of the bug behaviour<DD>
11997<DT>A short script or `recipe' which exercises the bug<DD>
11998
11999</DL>
12000<P>
12001
12002<I>bashbug</I>
12003
12004inserts the first three items automatically into the template
12005it provides for filing a bug report.
12006<P>
12007
12008Comments and bug reports concerning
12009this manual page should be directed to
12010<I><A HREF="mailto:chet@po.cwru.edu">chet@po.cwru.edu</A></I>.
12011
12012<A NAME="lbDH">&nbsp;</A>
12013<H3>BUGS</H3>
12014
12015<P>
12016
12017It's too big and too slow.
12018<P>
12019
12020There are some subtle differences between
12021<B>bash</B>
12022
12023and traditional versions of
12024<B>sh</B>,
12025
12026mostly because of the
12027<FONT SIZE=-1><B>POSIX</B>
12028
12029</FONT>
12030specification.
12031<P>
12032
12033Aliases are confusing in some uses.
12034<P>
12035
12036Shell builtin commands and functions are not stoppable/restartable.
12037<P>
12038
12039Compound commands and command sequences of the form `a ; b ; c'
12040are not handled gracefully when process suspension is attempted.
12041When a process is stopped, the shell immediately executes the next
12042command in the sequence.
12043It suffices to place the sequence of commands between
12044parentheses to force it into a subshell, which may be stopped as
12045a unit.
12046<P>
12047
12048Array variables may not (yet) be exported.
12049<P>
12050
12051There may be only one active coprocess at a time.
12052
12053
12054
12055<HR>
12056<TABLE WIDTH=100%>
12057<TR>
12058<TH ALIGN=LEFT width=33%>GNU Bash-4.0<TH ALIGN=CENTER width=33%>2008 December 29<TH ALIGN=RIGHT width=33%>BASH(1)
12059</TR>
12060</TABLE>
12061<HR>
12062<A NAME="index">&nbsp;</A><H2>Index</H2>
12063<DL>
12064<DT><A HREF="#lbAB">NAME</A><DD>
12065<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
12066<DT><A HREF="#lbAD">COPYRIGHT</A><DD>
12067<DT><A HREF="#lbAE">DESCRIPTION</A><DD>
12068<DT><A HREF="#lbAF">OPTIONS</A><DD>
12069<DT><A HREF="#lbAG">ARGUMENTS</A><DD>
12070<DT><A HREF="#lbAH">INVOCATION</A><DD>
12071<DT><A HREF="#lbAI">DEFINITIONS</A><DD>
12072<DT><A HREF="#lbAJ">RESERVED WORDS</A><DD>
12073<DT><A HREF="#lbAK">SHELL GRAMMAR</A><DD>
12074<DL>
12075<DT><A HREF="#lbAL">Simple Commands</A><DD>
12076<DT><A HREF="#lbAM">Pipelines</A><DD>
12077<DT><A HREF="#lbAN">Lists</A><DD>
12078<DT><A HREF="#lbAO">Compound Commands</A><DD>
12079<DT><A HREF="#lbAP">Coprocesses</A><DD>
12080<DT><A HREF="#lbAQ">Shell Function Definitions</A><DD>
12081</DL>
12082<DT><A HREF="#lbAR">COMMENTS</A><DD>
12083<DT><A HREF="#lbAS">QUOTING</A><DD>
12084<DT><A HREF="#lbAT">PARAMETERS</A><DD>
12085<DL>
12086<DT><A HREF="#lbAU">Positional Parameters</A><DD>
12087<DT><A HREF="#lbAV">Special Parameters</A><DD>
12088<DT><A HREF="#lbAW">Shell Variables</A><DD>
12089<DT><A HREF="#lbAX">Arrays</A><DD>
12090</DL>
12091<DT><A HREF="#lbAY">EXPANSION</A><DD>
12092<DL>
12093<DT><A HREF="#lbAZ">Brace Expansion</A><DD>
12094<DT><A HREF="#lbBA">Tilde Expansion</A><DD>
12095<DT><A HREF="#lbBB">Parameter Expansion</A><DD>
12096<DT><A HREF="#lbBC">Command Substitution</A><DD>
12097<DT><A HREF="#lbBD">Arithmetic Expansion</A><DD>
12098<DT><A HREF="#lbBE">Process Substitution</A><DD>
12099<DT><A HREF="#lbBF">Word Splitting</A><DD>
12100<DT><A HREF="#lbBG">Pathname Expansion</A><DD>
12101<DT><A HREF="#lbBH">Quote Removal</A><DD>
12102</DL>
12103<DT><A HREF="#lbBI">REDIRECTION</A><DD>
12104<DL>
12105<DT><A HREF="#lbBJ">Redirecting Input</A><DD>
12106<DT><A HREF="#lbBK">Redirecting Output</A><DD>
12107<DT><A HREF="#lbBL">Appending Redirected Output</A><DD>
12108<DT><A HREF="#lbBM">Redirecting Standard Output and Standard Error</A><DD>
12109<DT><A HREF="#lbBN">Appending Standard Output and Standard Error</A><DD>
12110<DT><A HREF="#lbBO">Here Documents</A><DD>
12111<DT><A HREF="#lbBP">Here Strings</A><DD>
12112<DT><A HREF="#lbBQ">Duplicating File Descriptors</A><DD>
12113<DT><A HREF="#lbBR">Moving File Descriptors</A><DD>
12114<DT><A HREF="#lbBS">Opening File Descriptors for Reading and Writing</A><DD>
12115</DL>
12116<DT><A HREF="#lbBT">ALIASES</A><DD>
12117<DT><A HREF="#lbBU">FUNCTIONS</A><DD>
12118<DT><A HREF="#lbBV">ARITHMETIC EVALUATION</A><DD>
12119<DT><A HREF="#lbBW">CONDITIONAL EXPRESSIONS</A><DD>
12120<DT><A HREF="#lbBX">SIMPLE COMMAND EXPANSION</A><DD>
12121<DT><A HREF="#lbBY">COMMAND EXECUTION</A><DD>
12122<DT><A HREF="#lbBZ">COMMAND EXECUTION ENVIRONMENT</A><DD>
12123<DT><A HREF="#lbCA">ENVIRONMENT</A><DD>
12124<DT><A HREF="#lbCB">EXIT STATUS</A><DD>
12125<DT><A HREF="#lbCC">SIGNALS</A><DD>
12126<DT><A HREF="#lbCD">JOB CONTROL</A><DD>
12127<DT><A HREF="#lbCE">PROMPTING</A><DD>
12128<DT><A HREF="#lbCF">READLINE</A><DD>
12129<DL>
12130<DT><A HREF="#lbCG">Readline Notation</A><DD>
12131<DT><A HREF="#lbCH">Readline Initialization</A><DD>
12132<DT><A HREF="#lbCI">Readline Key Bindings</A><DD>
12133<DT><A HREF="#lbCJ">Readline Variables</A><DD>
12134<DT><A HREF="#lbCK">Readline Conditional Constructs</A><DD>
12135<DT><A HREF="#lbCL">Searching</A><DD>
12136<DT><A HREF="#lbCM">Readline Command Names</A><DD>
12137<DT><A HREF="#lbCN">Commands for Moving</A><DD>
12138<DT><A HREF="#lbCO">Commands for Manipulating the History</A><DD>
12139<DT><A HREF="#lbCP">Commands for Changing Text</A><DD>
12140<DT><A HREF="#lbCQ">Killing and Yanking</A><DD>
12141<DT><A HREF="#lbCR">Numeric Arguments</A><DD>
12142<DT><A HREF="#lbCS">Completing</A><DD>
12143<DT><A HREF="#lbCT">Keyboard Macros</A><DD>
12144<DT><A HREF="#lbCU">Miscellaneous</A><DD>
12145<DT><A HREF="#lbCV">Programmable Completion</A><DD>
12146</DL>
12147<DT><A HREF="#lbCW">HISTORY</A><DD>
12148<DT><A HREF="#lbCX">HISTORY EXPANSION</A><DD>
12149<DL>
12150<DT><A HREF="#lbCY">Event Designators</A><DD>
12151<DT><A HREF="#lbCZ">Word Designators</A><DD>
12152<DT><A HREF="#lbDA">Modifiers</A><DD>
12153</DL>
12154<DT><A HREF="#lbDB">SHELL BUILTIN COMMANDS</A><DD>
12155<DT><A HREF="#lbDC">RESTRICTED SHELL</A><DD>
12156<DT><A HREF="#lbDD">SEE ALSO</A><DD>
12157<DT><A HREF="#lbDE">FILES</A><DD>
12158<DT><A HREF="#lbDF">AUTHORS</A><DD>
12159<DT><A HREF="#lbDG">BUG REPORTS</A><DD>
12160<DT><A HREF="#lbDH">BUGS</A><DD>
12161</DL>
12162<HR>
12163This document was created by man2html from bash.1.<BR>
12164Time: 05 February 2009 08:05:34 EST
12165</BODY>
12166</HTML>