]> git.ipfire.org Git - thirdparty/bash.git/blame - doc/bash.html
Bash-4.3 patch 46
[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>
ac50fbac 6<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2014 February 2<TH ALIGN=RIGHT width=33%>BASH(1)
17345e5a
JA
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]
ac50fbac 40[command_string | file]
17345e5a
JA
41<A NAME="lbAD">&nbsp;</A>
42<H3>COPYRIGHT</H3>
43
44
ac50fbac 45Bash is Copyright &#169; 1989-2013 by the Free Software Foundation, Inc.
17345e5a
JA
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
495aee44
CR
70All of the single-character shell options documented in the
71description of the <B>set</B> builtin command can be used as options
72when the shell is invoked.
73In addition, <B>bash</B>
17345e5a
JA
74interprets the following options when it is invoked:
75<P>
76
77
78<DL COMPACT>
ac50fbac 79<DT><B>-c</B>
17345e5a
JA
80
81<DD>
82If the
83<B>-c</B>
84
ac50fbac
CR
85option is present, then commands are read from the first non-option argument
86<I>command_string</I>.
17345e5a
JA
87
88If there are arguments after the
ac50fbac 89<I>command_string</I>,
17345e5a
JA
90
91they are assigned to the positional parameters, starting with
92<B>$0</B>.
93
94<DT><B>-i</B>
95
96<DD>
97If the
98<B>-i</B>
99
100option is present, the shell is
101<I>interactive</I>.
102
103<DT><B>-l</B>
104
105<DD>
106Make
107<B>bash</B>
108
109act as if it had been invoked as a login shell (see
110<FONT SIZE=-1><B>INVOCATION</B>
111
112</FONT>
113below).
114<DT><B>-r</B>
115
116<DD>
117If the
118<B>-r</B>
119
120option is present, the shell becomes
121<I>restricted</I>
122
123(see
124<FONT SIZE=-1><B>RESTRICTED SHELL</B>
125
126</FONT>
127below).
128<DT><B>-s</B>
129
130<DD>
131If the
132<B>-s</B>
133
134option is present, or if no arguments remain after option
135processing, then commands are read from the standard input.
136This option allows the positional parameters to be set
137when invoking an interactive shell.
138<DT><B>-D</B>
139
140<DD>
141A list of all double-quoted strings preceded by <B>$</B>
142is printed on the standard output.
143These are the strings that
144are subject to language translation when the current locale
145is not <B>C</B> or <B>POSIX</B>.
146This implies the <B>-n</B> option; no commands will be executed.
147<DT><B>[-+]O [</B><I>shopt_option</I>]
148
149<DD>
150<I>shopt_option</I> is one of the shell options accepted by the
151<B>shopt</B> builtin (see
152<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
153
154</FONT>
155below).
156If <I>shopt_option</I> is present, <B>-O</B> sets the value of that option;
157<B>+O</B> unsets it.
158If <I>shopt_option</I> is not supplied, the names and values of the shell
159options accepted by <B>shopt</B> are printed on the standard output.
160If the invocation option is <B>+O</B>, the output is displayed in a format
161that may be reused as input.
162<DT><B>--</B>
163
164<DD>
165A
166<B>--</B>
167
168signals the end of options and disables further option processing.
169Any arguments after the
170<B>--</B>
171
172are treated as filenames and arguments. An argument of
173<B>-</B>
174
175is equivalent to <B>--</B>.
176
177</DL>
178<P>
179
180<B>Bash</B>
181
182also interprets a number of multi-character options.
183These options must appear on the command line before the
184single-character options to be recognized.
185<P>
186
187
188<DL COMPACT>
189<DT><B>--debugger</B>
190
191<DD>
192Arrange for the debugger profile to be executed before the shell
193starts.
194Turns on extended debugging mode (see the description of the
195<B>extdebug</B>
196
197option to the
198<B>shopt</B>
199
17345e5a
JA
200builtin below).
201<DT><B>--dump-po-strings</B>
202
203<DD>
204Equivalent to <B>-D</B>, but the output is in the GNU <I>gettext</I>
205<B>po</B> (portable object) file format.
206<DT><B>--dump-strings</B>
207
208<DD>
209Equivalent to <B>-D</B>.
210<DT><B>--help</B>
211
212<DD>
213Display a usage message on standard output and exit successfully.
214<DT><B>--init-file</B> <I>file</I><DD>
215
216<DT><B>--rcfile</B> <I>file</I><DD>
217
218Execute commands from
219<I>file</I>
220
221instead of the standard personal initialization file
222<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
223
224if the shell is interactive (see
225<FONT SIZE=-1><B>INVOCATION</B>
226
227</FONT>
228below).
229<DT><B>--login</B>
230
231<DD>
232Equivalent to <B>-l</B>.
233<DT><B>--noediting</B>
234
235<DD>
236Do not use the GNU
237<B>readline</B>
238
239library to read command lines when the shell is interactive.
240<DT><B>--noprofile</B>
241
242<DD>
243Do not read either the system-wide startup file
244
245<A HREF="file:/etc/profile"><I>/etc/profile</I></A>
246
247or any of the personal initialization files
248<A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>,
249
250<A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>,
251
252or
253<A HREF="file:~/.profile"><I>~/.profile</I></A>.
254
255By default,
256<B>bash</B>
257
258reads these files when it is invoked as a login shell (see
259<FONT SIZE=-1><B>INVOCATION</B>
260
261</FONT>
262below).
263<DT><B>--norc</B>
264
265<DD>
266Do not read and execute the personal initialization file
267<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
268
269if the shell is interactive.
270This option is on by default if the shell is invoked as
271<B>sh</B>.
272
273<DT><B>--posix</B>
274
275<DD>
276Change the behavior of <B>bash</B> where the default operation differs
277from the POSIX standard to match the standard (<I>posix mode</I>).
ac50fbac
CR
278See
279<FONT SIZE=-1><B>SEE ALSO</B>
280
281</FONT>
282below for a reference to a document that details how posix mode affects
283bash's behavior.
17345e5a
JA
284<DT><B>--restricted</B>
285
286<DD>
287The shell becomes restricted (see
288<FONT SIZE=-1><B>RESTRICTED SHELL</B>
289
290</FONT>
291below).
292<DT><B>--verbose</B>
293
294<DD>
295Equivalent to <B>-v</B>.
296<DT><B>--version</B>
297
298<DD>
299Show version information for this instance of
300<B>bash</B>
301
302on the standard output and exit successfully.
303
304</DL>
305<A NAME="lbAG">&nbsp;</A>
306<H3>ARGUMENTS</H3>
307
308If arguments remain after option processing, and neither the
309<B>-c</B>
310
311nor the
312<B>-s</B>
313
314option has been supplied, the first argument is assumed to
315be the name of a file containing shell commands.
316If
317<B>bash</B>
318
319is invoked in this fashion,
320<B>$0</B>
321
322is set to the name of the file, and the positional parameters
323are set to the remaining arguments.
324<B>Bash</B>
325
326reads and executes commands from this file, then exits.
327<B>Bash</B>'s exit status is the exit status of the last command
328executed in the script.
329If no commands are executed, the exit status is 0.
330An attempt is first made to open the file in the current directory, and,
331if no file is found, then the shell searches the directories in
332<FONT SIZE=-1><B>PATH</B>
333
334</FONT>
335for the script.
336<A NAME="lbAH">&nbsp;</A>
337<H3>INVOCATION</H3>
338
339A <I>login shell</I> is one whose first character of argument zero is a
340<B>-</B>,
341
342or one started with the
343<B>--login</B>
344
345option.
346<P>
347
348An <I>interactive</I> shell is one started without non-option arguments
349and without the
350<B>-c</B>
351
352option
353whose standard input and error are
354both connected to terminals (as determined by
355<I>isatty</I>(3)),
356
357or one started with the
358<B>-i</B>
359
360option.
361<FONT SIZE=-1><B>PS1</B>
362
363</FONT>
364is set and
365<B>$-</B>
366
367includes
368<B>i</B>
369
370if
371<B>bash</B>
372
373is interactive,
374allowing a shell script or a startup file to test this state.
375<P>
376
377The following paragraphs describe how
378<B>bash</B>
379
380executes its startup files.
381If any of the files exist but cannot be read,
382<B>bash</B>
383
384reports an error.
ac50fbac 385Tildes are expanded in filenames as described below under
17345e5a
JA
386<B>Tilde Expansion</B>
387
388in the
389<FONT SIZE=-1><B>EXPANSION</B>
390
391</FONT>
392section.
393<P>
394
395When
396<B>bash</B>
397
398is invoked as an interactive login shell, or as a non-interactive shell
399with the <B>--login</B> option, it first reads and
400executes commands from the file <A HREF="file:/etc/profile"><I>/etc/profile</I></A>, if that
401file exists.
402After reading that file, it looks for <A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>,
403<A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>, and <A HREF="file:~/.profile"><I>~/.profile</I></A>, in that order, and reads
404and executes commands from the first one that exists and is readable.
405The
406<B>--noprofile</B>
407
408option may be used when the shell is started to inhibit this behavior.
409<P>
410
411When a login shell exits,
412<B>bash</B>
413
414reads and executes commands from the file <A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>, if it
415exists.
416<P>
417
418When an interactive shell that is not a login shell is started,
419<B>bash</B>
420
421reads and executes commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists.
422This may be inhibited by using the
423<B>--norc</B>
424
425option.
426The <B>--rcfile</B> <I>file</I> option will force
427<B>bash</B>
428
429to read and execute commands from <I>file</I> instead of <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
430<P>
431
432When
433<B>bash</B>
434
435is started non-interactively, to run a shell script, for example, it
436looks for the variable
437<FONT SIZE=-1><B>BASH_ENV</B>
438
439</FONT>
440in the environment, expands its value if it appears there, and uses the
441expanded value as the name of a file to read and execute.
442<B>Bash</B>
443
444behaves as if the following command were executed:
445<P>
446<DL COMPACT><DT><DD>
447<TT>if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi</TT>
448
449</DL>
450
451<P>
452but the value of the
453<FONT SIZE=-1><B>PATH</B>
454
455</FONT>
ac50fbac 456variable is not used to search for the filename.
17345e5a
JA
457<P>
458
459If
460<B>bash</B>
461
462is invoked with the name
463<B>sh</B>,
464
465it tries to mimic the startup behavior of historical versions of
466<B>sh</B>
467
468as closely as possible,
469while conforming to the POSIX standard as well.
470When invoked as an interactive login shell, or a non-interactive
471shell with the <B>--login</B> option, it first attempts to
472read and execute commands from
473<A HREF="file:/etc/profile"><I>/etc/profile</I></A>
474
475and
476<A HREF="file:~/.profile"><I>~/.profile</I></A>,
477
478in that order.
479The
480<B>--noprofile</B>
481
482option may be used to inhibit this behavior.
483When invoked as an interactive shell with the name
484<B>sh</B>,
485
486<B>bash</B>
487
488looks for the variable
489<FONT SIZE=-1><B>ENV</B>,
490
491</FONT>
492expands its value if it is defined, and uses the
493expanded value as the name of a file to read and execute.
494Since a shell invoked as
495<B>sh</B>
496
497does not attempt to read and execute commands from any other startup
498files, the
499<B>--rcfile</B>
500
501option has no effect.
502A non-interactive shell invoked with the name
503<B>sh</B>
504
505does not attempt to read any other startup files.
506When invoked as
507<B>sh</B>,
508
509<B>bash</B>
510
511enters
512<I>posix</I>
513
514mode after the startup files are read.
515<P>
516
517When
518<B>bash</B>
519
520is started in
521<I>posix</I>
522
523mode, as with the
524<B>--posix</B>
525
526command line option, it follows the POSIX standard for startup files.
527In this mode, interactive shells expand the
528<FONT SIZE=-1><B>ENV</B>
529
530</FONT>
531variable and commands are read and executed from the file
532whose name is the expanded value.
533No other startup files are read.
534<P>
535
536<B>Bash</B>
537
538attempts to determine when it is being run with its standard input
495aee44 539connected to a network connection, as when executed by the remote shell
17345e5a
JA
540daemon, usually <I>rshd</I>, or the secure shell daemon <I>sshd</I>.
541If
542<B>bash</B>
543
544determines it is being run in this fashion, it reads and executes
545commands from <A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>, if that file exists and is readable.
546It will not do this if invoked as <B>sh</B>.
547The
548<B>--norc</B>
549
550option may be used to inhibit this behavior, and the
551<B>--rcfile</B>
552
ac50fbac
CR
553option may be used to force another file to be read, but neither
554<I>rshd</I> nor <I>sshd</I> generally invoke the shell with those options
17345e5a
JA
555or allow them to be specified.
556<P>
557
558If the shell is started with the effective user (group) id not equal to the
559real user (group) id, and the <B>-p</B> option is not supplied, no startup
560files are read, shell functions are not inherited from the environment, the
0001803f
CR
561<FONT SIZE=-1><B>SHELLOPTS</B>,
562
563</FONT>
564<FONT SIZE=-1><B>BASHOPTS</B>,
565
566</FONT>
567<FONT SIZE=-1><B>CDPATH</B>,
17345e5a
JA
568
569</FONT>
0001803f
CR
570and
571<FONT SIZE=-1><B>GLOBIGNORE</B>
572
573</FONT>
574variables, if they appear in the environment, are ignored,
17345e5a
JA
575and the effective user id is set to the real user id.
576If the <B>-p</B> option is supplied at invocation, the startup behavior is
577the same, but the effective user id is not reset.
578<A NAME="lbAI">&nbsp;</A>
579<H3>DEFINITIONS</H3>
580
581<P>
582
583The following definitions are used throughout the rest of this
584document.
585
586<DL COMPACT>
587<DT><B>blank </B>
588
589<DD>
590A space or tab.
591<DT><B>word</B>
592
593<DD>
594A sequence of characters considered as a single unit by the shell.
595Also known as a
596<B>token</B>.
597
598<DT><B>name</B>
599
600<DD>
601A
602<I>word</I>
603
604consisting only of alphanumeric characters and underscores, and
605beginning with an alphabetic character or an underscore. Also
606referred to as an
607<B>identifier</B>.
608
609<DT><B>metacharacter</B>
610
611<DD>
612A character that, when unquoted, separates words. One of the following:
613<BR>
614
615<DL COMPACT><DT><DD>
616<P>
617
618<B>| &amp; ; ( ) &lt; &gt; space tab</B>
619
620</DL>
621
622</DL>
623<P>
624
625<DL COMPACT>
626<DT><B>control operator</B>
627
628<DD>
629A <I>token</I> that performs a control function. It is one of the following
630symbols:
631<DL COMPACT><DT><DD>
632<P>
633
634<B>|| &amp; &amp;&amp; ; ;; ( ) | |&amp; &lt;newline&gt;</B>
635
636</DL>
637
638
639</DL>
640<A NAME="lbAJ">&nbsp;</A>
641<H3>RESERVED WORDS</H3>
642
643<I>Reserved words</I> are words that have a special meaning to the shell.
644The following words are recognized as reserved when unquoted and either
645the first word of a simple command (see
646<FONT SIZE=-1><B>SHELL GRAMMAR</B>
647
648</FONT>
649below) or the third word of a
650<B>case </B>
651
652or
653<B>for</B>
654
655command:
656<DL COMPACT><DT><DD>
657
658<P>
659
660<B>
661</B>
662
ac50fbac 663! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
17345e5a
JA
664</DL>
665
666
667<A NAME="lbAK">&nbsp;</A>
668<H3>SHELL GRAMMAR</H3>
669
670<A NAME="lbAL">&nbsp;</A>
671<H4>Simple Commands</H4>
672
673<P>
674
675A <I>simple command</I> is a sequence of optional variable assignments
676followed by <B>blank</B>-separated words and redirections, and
677terminated by a <I>control operator</I>. The first word
678specifies the command to be executed, and is passed as argument zero.
679The remaining words are passed as arguments to the invoked command.
680<P>
681
682The return value of a <I>simple command</I> is its exit status, or
683128+<I>n</I> if the command is terminated by signal
684<I>n</I>.
685
686<A NAME="lbAM">&nbsp;</A>
687<H4>Pipelines</H4>
688
689<P>
690
691A <I>pipeline</I> is a sequence of one or more commands separated by
692one of the control operators
693<B>|</B>
694
695or <B>|&amp;</B>.
696The format for a pipeline is:
697<DL COMPACT><DT><DD>
698<P>
699
700[<B>time</B> [<B>-p</B>]] [ ! ] <I>command</I> [ [<B>|</B>|<B>|&amp;</B>] <I>command2</I> ... ]
701</DL>
702
703<P>
704
705The standard output of
706<I>command</I>
707
708is connected via a pipe to the standard input of
709<I>command2</I>.
710
711This connection is performed before any redirections specified by the
712command (see
713<FONT SIZE=-1><B>REDIRECTION</B>
714
715</FONT>
716below).
ac50fbac
CR
717If <B>|&amp;</B> is used, <I>command</I>'s standard error, in addition to its
718standard output, is connected to
719<I>command2</I>'s standard input through the pipe;
720it is shorthand for <B>2&gt;&amp;1 |</B>.
721This implicit redirection of the standard error to the standard output is
722performed after any redirections specified by the command.
17345e5a
JA
723<P>
724
725The return status of a pipeline is the exit status of the last
726command, unless the <B>pipefail</B> option is enabled.
727If <B>pipefail</B> is enabled, the pipeline's return status is the
728value of the last (rightmost) command to exit with a non-zero status,
729or zero if all commands exit successfully.
730If the reserved word
731<B>!</B>
732
733precedes a pipeline, the exit status of that pipeline is the logical
734negation of the exit status as described above.
735The shell waits for all commands in the pipeline to
736terminate before returning a value.
737<P>
738
739If the
740<B>time</B>
741
742reserved word precedes a pipeline, the elapsed as well as user and
743system time consumed by its execution are reported when the pipeline
744terminates.
745The <B>-p</B> option changes the output format to that specified by POSIX.
495aee44
CR
746When the shell is in <I>posix mode</I>, it does not recognize
747<B>time</B> as a reserved word if the next token begins with a `-'.
17345e5a
JA
748The
749<FONT SIZE=-1><B>TIMEFORMAT</B>
750
751</FONT>
752variable may be set to a format string that specifies how the timing
753information should be displayed; see the description of
754<FONT SIZE=-1><B>TIMEFORMAT</B>
755
756</FONT>
757under
758<B>Shell Variables</B>
759
760below.
761<P>
762
495aee44
CR
763When the shell is in <I>posix mode</I>, <B>time</B>
764may be followed by a newline. In this case, the shell displays the
765total user and system time consumed by the shell and its children.
766The
767<FONT SIZE=-1><B>TIMEFORMAT</B>
768
769</FONT>
770variable may be used to specify the format of
771the time information.
772<P>
773
17345e5a
JA
774Each command in a pipeline is executed as a separate process (i.e., in a
775subshell).
776<A NAME="lbAN">&nbsp;</A>
777<H4>Lists</H4>
778
779<P>
780
781A <I>list</I> is a sequence of one or more pipelines separated by one
782of the operators
783<B>;</B>,
784
785<B>&amp;</B>,
786
787<B>&amp;&amp;</B>,
788
789or
790<B>||</B>,
791
792and optionally terminated by one of
793<B>;</B>,
794
795<B>&amp;</B>,
796
797or
798<B>&lt;newline&gt;</B>.
799
800<P>
801
802Of these list operators,
803<B>&amp;&amp;</B>
804
805and
806<B>||</B>
807
808have equal precedence, followed by
809<B>;</B>
810
811and
812<B>&amp;</B>,
813
814which have equal precedence.
815<P>
816
817A sequence of one or more newlines may appear in a <I>list</I> instead
818of a semicolon to delimit commands.
819<P>
820
821If a command is terminated by the control operator
822<B>&amp;</B>,
823
824the shell executes the command in the <I>background</I>
825in a subshell. The shell does not wait for the command to
826finish, and the return status is 0. Commands separated by a
827<B>;</B>
828
829are executed sequentially; the shell waits for each
830command to terminate in turn. The return status is the
831exit status of the last command executed.
832<P>
833
834AND and OR lists are sequences of one of more pipelines separated by the
835<B>&amp;&amp;</B> and <B>||</B> control operators, respectively.
836AND and OR lists are executed with left associativity.
837An AND list has the form
838<DL COMPACT><DT><DD>
839<P>
840
841<I>command1</I> <B>&amp;&amp;</B> <I>command2</I>
842</DL>
843
844<P>
845
846<I>command2</I>
847
848is executed if, and only if,
849<I>command1</I>
850
851returns an exit status of zero.
852<P>
853
854An OR list has the form
855<DL COMPACT><DT><DD>
856<P>
857
858<I>command1</I> <B>||</B> <I>command2</I>
859<P>
860
861</DL>
862
863<P>
864
865<I>command2</I>
866
867is executed if and only if
868<I>command1</I>
869
870returns a non-zero exit status.
871The return status of
872AND and OR lists is the exit status of the last command
873executed in the list.
874<A NAME="lbAO">&nbsp;</A>
875<H4>Compound Commands</H4>
876
877<P>
878
ac50fbac
CR
879A <I>compound command</I> is one of the following.
880In most cases a <I>list</I> in a command's description may be separated from
881the rest of the command by one or more newlines, and may be followed by a
882newline in place of a semicolon.
17345e5a
JA
883<DL COMPACT>
884<DT>(<I>list</I>)<DD>
885<I>list</I> is executed in a subshell environment (see
886<FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B></FONT>
887below).
888Variable assignments and builtin
889commands that affect the shell's environment do not remain in effect
890after the command completes. The return status is the exit status of
891<I>list</I>.
892<DT>{ <I>list</I>; }<DD>
893<I>list</I> is simply executed in the current shell environment.
894<I>list</I> must be terminated with a newline or semicolon.
895This is known as a <I>group command</I>.
896The return status is the exit status of
897<I>list</I>.
898Note that unlike the metacharacters <B>(</B> and <B>)</B>, <B>{</B> and
899<B>}</B> are <I>reserved words</I> and must occur where a reserved
900word is permitted to be recognized. Since they do not cause a word
901break, they must be separated from <I>list</I> by whitespace or another
902shell metacharacter.
903<DT>((<I>expression</I>))<DD>
904The <I>expression</I> is evaluated according to the rules described
905below under
906<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
907
908</FONT>
909If the value of the expression is non-zero, the return status is 0;
910otherwise the return status is 1. This is exactly equivalent to
911<B>let &quot;</B><I>expression</I>&quot;.
912<DT><B>[[</B> <I>expression</I> <B>]]</B><DD>
913Return a status of 0 or 1 depending on the evaluation of
914the conditional expression <I>expression</I>.
915Expressions are composed of the primaries described below under
916<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
917
918</FONT>
919Word splitting and pathname expansion are not performed on the words
ac50fbac
CR
920between the <B>[[</B> and <B>]]</B>; tilde expansion,
921parameter and variable expansion,
922arithmetic expansion, command substitution, process
17345e5a
JA
923substitution, and quote removal are performed.
924Conditional operators such as <B>-f</B> must be unquoted to be recognized
925as primaries.
926<P>
927
928
495aee44 929When used with <B>[[</B>, the <B>&lt;</B> and <B>&gt;</B> operators sort
0001803f
CR
930lexicographically using the current locale.
931<P>
932
933
17345e5a
JA
934When the <B>==</B> and <B>!=</B> operators are used, the string to the
935right of the operator is considered a pattern and matched according
ac50fbac
CR
936to the rules described below under <B>Pattern Matching</B>,
937as if the <B>extglob</B> shell option were enabled.
938The <B>=</B> operator is equivalent to <B>==</B>.
17345e5a
JA
939If the shell option
940<B>nocasematch</B>
941
942is enabled, the match is performed without regard to the case
943of alphabetic characters.
944The return value is 0 if the string matches (<B>==</B>) or does not match
945(<B>!=</B>) the pattern, and 1 otherwise.
ac50fbac
CR
946Any part of the pattern may be quoted to force the quoted portion
947to be matched as a string.
17345e5a
JA
948<P>
949
950
951An additional binary operator, <B>=~</B>, is available, with the same
952precedence as <B>==</B> and <B>!=</B>.
953When it is used, the string to the right of the operator is considered
954an extended regular expression and matched accordingly (as in <I>regex</I>(3)).
955The return value is 0 if the string matches
956the pattern, and 1 otherwise.
957If the regular expression is syntactically incorrect, the conditional
958expression's return value is 2.
959If the shell option
960<B>nocasematch</B>
961
962is enabled, the match is performed without regard to the case
963of alphabetic characters.
ac50fbac
CR
964Any part of the pattern may be quoted to force the quoted portion
965to be matched as a string.
966Bracket expressions in regular expressions must be treated carefully,
967since normal quoting characters lose their meanings between brackets.
968If the pattern is stored in a shell variable, quoting the variable
969expansion forces the entire pattern to be matched as a string.
17345e5a 970Substrings matched by parenthesized subexpressions within the regular
0001803f
CR
971expression are saved in the array variable
972<FONT SIZE=-1><B>BASH_REMATCH</B>.
973
974</FONT>
975The element of
976<FONT SIZE=-1><B>BASH_REMATCH</B>
977
978</FONT>
979with index 0 is the portion of the string
17345e5a 980matching the entire regular expression.
0001803f
CR
981The element of
982<FONT SIZE=-1><B>BASH_REMATCH</B>
983
984</FONT>
985with index <I>n</I> is the portion of the
17345e5a
JA
986string matching the <I>n</I>th parenthesized subexpression.
987<P>
988
989
990Expressions may be combined using the following operators, listed
991in decreasing order of precedence:
992<P>
993
994
995<DL COMPACT><DT><DD>
996
997<DL COMPACT>
998<DT><B>( </B><I>expression</I> )
999
1000<DD>
1001Returns the value of <I>expression</I>.
1002This may be used to override the normal precedence of operators.
1003<DT><B>! </B><I>expression</I>
1004
1005<DD>
1006True if
1007<I>expression</I>
1008
1009is false.
1010<DT><I>expression1</I> <B>&amp;&amp;</B> <I>expression2</I><DD>
1011True if both
1012<I>expression1</I>
1013
1014and
1015<I>expression2</I>
1016
1017are true.
495aee44 1018<DT><I>expression1</I> <B>||</B> <I>expression2</I><DD>
17345e5a
JA
1019True if either
1020<I>expression1</I>
1021
1022or
1023<I>expression2</I>
1024
1025is true.
1026
1027</DL>
1028<P>
1029
495aee44 1030The <B>&amp;&amp;</B> and <B>||</B>
17345e5a
JA
1031operators do not evaluate <I>expression2</I> if the value of
1032<I>expression1</I> is sufficient to determine the return value of
1033the entire conditional expression.
1034</DL>
1035
0001803f 1036<DT><B>for</B> <I>name</I> [ [ <B>in</B> [ <I>word ...</I> ] ] ; ] <B>do</B> <I>list</I> ; <B>done</B><DD>
17345e5a
JA
1037The list of words following <B>in</B> is expanded, generating a list
1038of items.
1039The variable <I>name</I> is set to each element of this list
1040in turn, and <I>list</I> is executed each time.
1041If the <B>in</B> <I>word</I> is omitted, the <B>for</B> command executes
1042<I>list</I> once for each positional parameter that is set (see
1043<FONT SIZE=-1><B>PARAMETERS</B>
1044
1045</FONT>
1046below).
1047The return status is the exit status of the last command that executes.
1048If the expansion of the items following <B>in</B> results in an empty
1049list, no commands are executed, and the return status is 0.
1050<DT><B>for</B> (( <I>expr1</I> ; <I>expr2</I> ; <I>expr3</I> )) ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1051First, the arithmetic expression <I>expr1</I> is evaluated according
1052to the rules described below under
1053<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
1054
1055</FONT>
1056The arithmetic expression <I>expr2</I> is then evaluated repeatedly
1057until it evaluates to zero.
1058Each time <I>expr2</I> evaluates to a non-zero value, <I>list</I> is
1059executed and the arithmetic expression <I>expr3</I> is evaluated.
1060If any expression is omitted, it behaves as if it evaluates to 1.
1061The return value is the exit status of the last command in <I>list</I>
1062that is executed, or false if any of the expressions is invalid.
1063<DT><B>select</B> <I>name</I> [ <B>in</B> <I>word</I> ] ; <B>do</B> <I>list</I> ; <B>done</B><DD>
1064The list of words following <B>in</B> is expanded, generating a list
1065of items. The set of expanded words is printed on the standard
1066error, each preceded by a number. If the <B>in</B>
1067<I>word</I> is omitted, the positional parameters are printed (see
1068<FONT SIZE=-1><B>PARAMETERS</B>
1069
1070</FONT>
1071below). The
0001803f 1072<FONT SIZE=-1><B>PS3</B>
17345e5a 1073
0001803f 1074</FONT>
17345e5a
JA
1075prompt is then displayed and a line read from the standard input.
1076If the line consists of a number corresponding to one of
1077the displayed words, then the value of
1078<I>name</I>
1079
1080is set to that word. If the line is empty, the words and prompt
1081are displayed again. If EOF is read, the command completes. Any
1082other value read causes
1083<I>name</I>
1084
1085to be set to null. The line read is saved in the variable
0001803f 1086<FONT SIZE=-1><B>REPLY</B>.
17345e5a 1087
0001803f 1088</FONT>
17345e5a
JA
1089The
1090<I>list</I>
1091
1092is executed after each selection until a
1093<B>break</B>
1094
1095command is executed.
1096The exit status of
1097<B>select</B>
1098
1099is the exit status of the last command executed in
1100<I>list</I>,
1101
1102or zero if no commands were executed.
1103<DT><B>case</B> <I>word</I> <B>in</B> [ [(] <I>pattern</I> [ <B>|</B> <I>pattern</I> ]
1104<DD>
1105A <B>case</B> command first expands <I>word</I>, and tries to match
1106it against each <I>pattern</I> in turn, using the same matching rules
1107as for pathname expansion (see
1108<B>Pathname Expansion</B>
1109
1110below).
1111The <I>word</I> is expanded using tilde
1112expansion, parameter and variable expansion, arithmetic substitution,
1113command substitution, process substitution and quote removal.
1114Each <I>pattern</I> examined is expanded using tilde
1115expansion, parameter and variable expansion, arithmetic substitution,
1116command substitution, and process substitution.
1117If the shell option
1118<B>nocasematch</B>
1119
1120is enabled, the match is performed without regard to the case
1121of alphabetic characters.
1122When a match is found, the corresponding <I>list</I> is executed.
1123If the <B>;;</B> operator is used, no subsequent matches are attempted after
1124the first pattern match.
1125Using <B>;&amp;</B> in place of <B>;;</B> causes execution to continue with
1126the <I>list</I> associated with the next set of patterns.
1127Using <B>;;&amp;</B> in place of <B>;;</B> causes the shell to test the next
1128pattern list in the statement, if any, and execute any associated <I>list</I>
1129on a successful match.
1130The exit status is zero if no
1131pattern matches. Otherwise, it is the exit status of the
1132last command executed in <I>list</I>.
ac50fbac 1133<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>
17345e5a
JA
1134The
1135<B>if </B>
1136
1137<I>list</I>
1138
1139is executed. If its exit status is zero, the
1140<B>then</B> <I>list</I> is executed. Otherwise, each <B>elif</B>
1141<I>list</I> is executed in turn, and if its exit status is zero,
1142the corresponding <B>then</B> <I>list</I> is executed and the
1143command completes. Otherwise, the <B>else</B> <I>list</I> is
1144executed, if present. The exit status is the exit status of the
1145last command executed, or zero if no condition tested true.
495aee44 1146<DT><B>while</B> <I>list-1</I>; <B>do</B> <I>list-2</I>; <B>done</B><DD>
17345e5a 1147
495aee44 1148<DT><B>until</B> <I>list-1</I>; <B>do</B> <I>list-2</I>; <B>done</B><DD>
17345e5a 1149
495aee44
CR
1150The <B>while</B> command continuously executes the list
1151<I>list-2</I> as long as the last command in the list <I>list-1</I> returns
17345e5a
JA
1152an exit status of zero. The <B>until</B> command is identical
1153to the <B>while</B> command, except that the test is negated;
495aee44 1154<I>list-2</I>
17345e5a
JA
1155
1156is executed as long as the last command in
495aee44 1157<I>list-1</I>
17345e5a
JA
1158
1159returns a non-zero exit status.
1160The exit status of the <B>while</B> and <B>until</B> commands
1161is the exit status
495aee44 1162of the last command executed in <I>list-2</I>, or zero if
17345e5a
JA
1163none was executed.
1164</DL>
1165<A NAME="lbAP">&nbsp;</A>
1166<H4>Coprocesses</H4>
1167
1168<P>
1169
1170A <I>coprocess</I> is a shell command preceded by the <B>coproc</B> reserved
1171word.
1172A coprocess is executed asynchronously in a subshell, as if the command
1173had been terminated with the <B>&amp;</B> control operator, with a two-way pipe
1174established between the executing shell and the coprocess.
1175<P>
1176
1177The format for a coprocess is:
1178<DL COMPACT><DT><DD>
1179<P>
1180
1181<B>coproc</B> [<I>NAME</I>] <I>command</I> [<I>redirections</I>]
1182</DL>
1183
1184<P>
1185
1186This creates a coprocess named <I>NAME</I>.
ac50fbac 1187If <I>NAME</I> is not supplied, the default name is <B>COPROC</B>.
17345e5a
JA
1188<I>NAME</I> must not be supplied if <I>command</I> is a <I>simple
1189command</I> (see above); otherwise, it is interpreted as the first word
1190of the simple command.
ac50fbac 1191When the coprocess is executed, the shell creates an array variable (see
17345e5a
JA
1192<B>Arrays</B>
1193
1194below) named <I>NAME</I> in the context of the executing shell.
1195The standard output of
1196<I>command</I>
1197
1198is connected via a pipe to a file descriptor in the executing shell,
1199and that file descriptor is assigned to <I>NAME</I>[0].
1200The standard input of
1201<I>command</I>
1202
1203is connected via a pipe to a file descriptor in the executing shell,
1204and that file descriptor is assigned to <I>NAME</I>[1].
1205This pipe is established before any redirections specified by the
1206command (see
1207<FONT SIZE=-1><B>REDIRECTION</B>
1208
1209</FONT>
1210below).
1211The file descriptors can be utilized as arguments to shell commands
1212and redirections using standard word expansions.
ac50fbac 1213The file descriptors are not available in subshells.
495aee44 1214The process ID of the shell spawned to execute the coprocess is
17345e5a
JA
1215available as the value of the variable <I>NAME</I>_PID.
1216The <B>wait</B>
1217builtin command may be used to wait for the coprocess to terminate.
1218<P>
1219
ac50fbac
CR
1220Since the coprocess is created as an asynchronous command,
1221the <B>coproc</B> command always returns success.
17345e5a
JA
1222The return status of a coprocess is the exit status of <I>command</I>.
1223<A NAME="lbAQ">&nbsp;</A>
1224<H4>Shell Function Definitions</H4>
1225
1226<P>
1227
1228A shell function is an object that is called like a simple command and
1229executes a compound command with a new set of positional parameters.
1230Shell functions are declared as follows:
1231<DL COMPACT>
495aee44
CR
1232<DT><I>name</I> () <I>compound-command</I> [<I>redirection</I>]<DD>
1233
1234<DT><B>function</B> <I>name</I> [()] <I>compound-command</I> [<I>redirection</I>]<DD>
1235
17345e5a
JA
1236This defines a function named <I>name</I>.
1237The reserved word <B>function</B> is optional.
1238If the <B>function</B> reserved word is supplied, the parentheses are optional.
1239The <I>body</I> of the function is the compound command
1240<I>compound-command </I>
1241
1242(see <B>Compound Commands</B> above).
1243That command is usually a <I>list</I> of commands between { and }, but
1244may be any command listed under <B>Compound Commands</B> above.
1245<I>compound-command</I> is executed whenever <I>name</I> is specified as the
1246name of a simple command.
ac50fbac
CR
1247When in <I>posix mode</I>, <I>name</I> may not be the name of one of the
1248POSIX <I>special builtins</I>.
17345e5a
JA
1249Any redirections (see
1250<FONT SIZE=-1><B>REDIRECTION</B>
1251
1252</FONT>
1253below) specified when a function is defined are performed
1254when the function is executed.
1255The exit status of a function definition is zero unless a syntax error
1256occurs or a readonly function with the same name already exists.
1257When executed, the exit status of a function is the exit status of the
1258last command executed in the body. (See
1259<FONT SIZE=-1><B>FUNCTIONS</B>
1260
1261</FONT>
1262below.)
1263</DL>
1264<A NAME="lbAR">&nbsp;</A>
1265<H3>COMMENTS</H3>
1266
1267In a non-interactive shell, or an interactive shell in which the
1268<B>interactive_comments</B>
1269
1270option to the
1271<B>shopt</B>
1272
1273builtin is enabled (see
1274<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1275
1276</FONT>
1277below), a word beginning with
1278<B>#</B>
1279
1280causes that word and all remaining characters on that line to
1281be ignored. An interactive shell without the
1282<B>interactive_comments</B>
1283
1284option enabled does not allow comments. The
1285<B>interactive_comments</B>
1286
1287option is on by default in interactive shells.
1288<A NAME="lbAS">&nbsp;</A>
1289<H3>QUOTING</H3>
1290
1291<I>Quoting</I> is used to remove the special meaning of certain
1292characters or words to the shell. Quoting can be used to
1293disable special treatment for special characters, to prevent
1294reserved words from being recognized as such, and to prevent
1295parameter expansion.
1296<P>
1297
1298Each of the <I>metacharacters</I> listed above under
1299<FONT SIZE=-1><B>DEFINITIONS</B>
1300
1301</FONT>
1302has special meaning to the shell and must be quoted if it is to
1303represent itself.
1304<P>
1305
1306When the command history expansion facilities are being used
1307(see
1308<FONT SIZE=-1><B>HISTORY EXPANSION</B>
1309
1310</FONT>
1311below), the
1312<I>history expansion</I> character, usually <B>!</B>, must be quoted
1313to prevent history expansion.
1314<P>
1315
1316There are three quoting mechanisms: the
1317<I>escape character</I>,
1318
1319single quotes, and double quotes.
1320<P>
1321
1322A non-quoted backslash (<B>\</B>) is the
1323<I>escape character</I>.
1324
1325It preserves the literal value of the next character that follows,
1326with the exception of &lt;newline&gt;. If a <B>\</B>&lt;newline&gt; pair
1327appears, and the backslash is not itself quoted, the <B>\</B>&lt;newline&gt;
1328is treated as a line continuation (that is, it is removed from the
1329input stream and effectively ignored).
1330<P>
1331
1332Enclosing characters in single quotes preserves the literal value
1333of each character within the quotes. A single quote may not occur
1334between single quotes, even when preceded by a backslash.
1335<P>
1336
1337Enclosing characters in double quotes preserves the literal value
1338of all characters within the quotes, with the exception of
1339<B>$</B>,
1340
1341<B>`</B>,
1342
1343<B>\</B>,
1344
1345and, when history expansion is enabled,
1346<B>!</B>.
1347
1348The characters
1349<B>$</B>
1350
1351and
1352<B>`</B>
1353
1354retain their special meaning within double quotes. The backslash
1355retains its special meaning only when followed by one of the following
1356characters:
1357<B>$</B>,
1358
1359<B>`</B>,
1360
1361<B>&quot;</B>,
1362<B>\</B>,
1363
1364or
1365<B>&lt;newline&gt;</B>.
1366
1367A double quote may be quoted within double quotes by preceding it with
1368a backslash.
1369If enabled, history expansion will be performed unless an
1370<B>!</B>
1371
1372appearing in double quotes is escaped using a backslash.
1373The backslash preceding the
1374<B>!</B>
1375
1376is not removed.
1377<P>
1378
1379The special parameters
1380<B>*</B>
1381
1382and
1383<B>@</B>
1384
1385have special meaning when in double
1386quotes (see
1387<FONT SIZE=-1><B>PARAMETERS</B>
1388
1389</FONT>
1390below).
1391<P>
1392
1393Words of the form <B>$</B>aq<I>string</I>aq are treated specially. The
1394word expands to <I>string</I>, with backslash-escaped characters replaced
1395as specified by the ANSI C standard. Backslash escape sequences, if
1396present, are decoded as follows:
1397<DL COMPACT><DT><DD>
1398
1399<DL COMPACT>
1400<DT><B>\a</B>
1401
1402<DD>
1403alert (bell)
1404<DT><B>\b</B>
1405
1406<DD>
1407backspace
1408<DT><B>\e</B>
1409
0001803f
CR
1410<DD>
1411<DT><B>\E</B>
1412
17345e5a
JA
1413<DD>
1414an escape character
1415<DT><B>\f</B>
1416
1417<DD>
1418form feed
1419<DT><B>\n</B>
1420
1421<DD>
1422new line
1423<DT><B>\r</B>
1424
1425<DD>
1426carriage return
1427<DT><B>\t</B>
1428
1429<DD>
1430horizontal tab
1431<DT><B>\v</B>
1432
1433<DD>
1434vertical tab
1435<DT><B>\\</B>
1436
1437<DD>
1438backslash
1439<DT><B>\aq</B>
1440
1441<DD>
1442single quote
0001803f
CR
1443<DT><B>\dq</B>
1444
1445<DD>
1446double quote
17345e5a
JA
1447<DT><B>\</B><I>nnn</I>
1448
1449<DD>
1450the eight-bit character whose value is the octal value <I>nnn</I>
1451(one to three digits)
1452<DT><B>\x</B><I>HH</I>
1453
1454<DD>
1455the eight-bit character whose value is the hexadecimal value <I>HH</I>
1456(one or two hex digits)
495aee44
CR
1457<DT><B>\u</B><I>HHHH</I>
1458
1459<DD>
1460the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1461<I>HHHH</I> (one to four hex digits)
1462<DT><B>\U</B><I>HHHHHHHH</I>
1463
1464<DD>
1465the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1466<I>HHHHHHHH</I> (one to eight hex digits)
17345e5a
JA
1467<DT><B>\c</B><I>x</I>
1468
1469<DD>
1470a control-<I>x</I> character
1471
1472</DL></DL>
1473
1474<P>
1475
1476The expanded result is single-quoted, as if the dollar sign had
1477not been present.
1478<P>
1479
0001803f
CR
1480A double-quoted string preceded by a dollar sign (<B>$</B>dq<I>string</I>dq)
1481will cause the string to be translated according to the current locale.
17345e5a
JA
1482If the current locale is <B>C</B> or <B>POSIX</B>, the dollar sign
1483is ignored.
1484If the string is translated and replaced, the replacement is
1485double-quoted.
1486<A NAME="lbAT">&nbsp;</A>
1487<H3>PARAMETERS</H3>
1488
1489A
1490<I>parameter</I>
1491
1492is an entity that stores values.
1493It can be a
1494<I>name</I>,
1495
1496a number, or one of the special characters listed below under
1497<B>Special Parameters</B>.
1498
1499A
1500<I>variable</I>
1501
1502is a parameter denoted by a
1503<I>name</I>.
1504
1505A variable has a <I>value</I> and zero or more <I>attributes</I>.
1506Attributes are assigned using the
1507<B>declare</B>
1508
1509builtin command (see
1510<B>declare</B>
1511
1512below in
1513<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>).
1514
1515</FONT>
1516<P>
1517
1518A parameter is set if it has been assigned a value. The null string is
1519a valid value. Once a variable is set, it may be unset only by using
1520the
1521<B>unset</B>
1522
1523builtin command (see
1524<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1525
1526</FONT>
1527below).
1528<P>
1529
1530A
1531<I>variable</I>
1532
1533may be assigned to by a statement of the form
1534<DL COMPACT><DT><DD>
1535<P>
1536
1537<I>name</I>=[<I>value</I>]
1538</DL>
1539
1540<P>
1541
1542If
1543<I>value</I>
1544
1545is not given, the variable is assigned the null string. All
1546<I>values</I>
1547
1548undergo tilde expansion, parameter and variable expansion,
1549command substitution, arithmetic expansion, and quote
1550removal (see
1551<FONT SIZE=-1><B>EXPANSION</B>
1552
1553</FONT>
1554below). If the variable has its
1555<B>integer</B>
1556
1557attribute set, then
1558<I>value</I>
1559
1560is evaluated as an arithmetic expression even if the $((...)) expansion is
1561not used (see
1562<B>Arithmetic Expansion</B>
1563
1564below).
1565Word splitting is not performed, with the exception
1566of <B>&quot;$@&quot;</B> as explained below under
1567<B>Special Parameters</B>.
1568
1569Pathname expansion is not performed.
1570Assignment statements may also appear as arguments to the
1571<B>alias</B>,
1572
1573<B>declare</B>,
1574
1575<B>typeset</B>,
1576
1577<B>export</B>,
1578
1579<B>readonly</B>,
1580
1581and
1582<B>local</B>
1583
1584builtin commands.
ac50fbac
CR
1585When in <I>posix mode</I>, these builtins may appear in a command after
1586one or more instances of the <B>command</B> builtin and retain these
1587assignment statement properties.
17345e5a
JA
1588<P>
1589
1590In the context where an assignment statement is assigning a value
1591to a shell variable or array index, the += operator can be used to
1592append to or add to the variable's previous value.
495aee44 1593When += is applied to a variable for which the <I>integer</I> attribute has been
17345e5a
JA
1594set, <I>value</I> is evaluated as an arithmetic expression and added to the
1595variable's current value, which is also evaluated.
1596When += is applied to an array variable using compound assignment (see
1597<B>Arrays</B>
1598
1599below), the
1600variable's value is not unset (as it is when using =), and new values are
1601appended to the array beginning at one greater than the array's maximum index
1602(for indexed arrays) or added as additional key-value pairs in an
1603associative array.
1604When applied to a string-valued variable, <I>value</I> is expanded and
1605appended to the variable's value.
ac50fbac
CR
1606<P>
1607
1608A variable can be assigned the <I>nameref</I> attribute using the
1609<B>-n</B> option to the <B>declare</B> or <B>local</B> builtin commands
1610(see the descriptions of <B>declare</B> and <B>local</B> below)
1611to create a <I>nameref</I>, or a reference to another variable.
1612This allows variables to be manipulated indirectly.
1613Whenever the nameref variable is referenced or assigned to, the operation
1614is actually performed on the variable specified by the nameref variable's
1615value.
1616A nameref is commonly used within shell functions to refer to a variable
1617whose name is passed as an argument to the function.
1618For instance, if a variable name is passed to a shell function as its first
1619argument, running
1620<P>
1621<DL COMPACT><DT><DD>
1622<TT>declare -n ref=$1</TT>
1623
1624</DL>
1625
1626<P>
1627inside the function creates a nameref variable <B>ref</B> whose value is
1628the variable name passed as the first argument.
1629References and assignments to <B>ref</B> are treated as references and
1630assignments to the variable whose name was passed as <B>$1</B>.
1631If the control variable in a <B>for</B> loop has the nameref attribute,
1632the list of words can be a list of shell variables, and a name reference
1633will be established for each word in the list, in turn, when the loop is
1634executed.
1635Array variables cannot be given the <B>-n</B> attribute.
1636However, nameref variables can reference array variables and subscripted
1637array variables.
1638Namerefs can be unset using the <B>-n</B> option to the <B>unset</B> builtin.
1639Otherwise, if <B>unset</B> is executed with the name of a nameref variable
1640as an argument, the variable referenced by the nameref variable will be unset.
17345e5a
JA
1641<A NAME="lbAU">&nbsp;</A>
1642<H4>Positional Parameters</H4>
1643
1644<P>
1645
1646A
1647<I>positional parameter</I>
1648
1649is a parameter denoted by one or more
1650digits, other than the single digit 0. Positional parameters are
1651assigned from the shell's arguments when it is invoked,
1652and may be reassigned using the
1653<B>set</B>
1654
1655builtin command. Positional parameters may not be assigned to
1656with assignment statements. The positional parameters are
1657temporarily replaced when a shell function is executed (see
1658<FONT SIZE=-1><B>FUNCTIONS</B>
1659
1660</FONT>
1661below).
1662<P>
1663
1664When a positional parameter consisting of more than a single
1665digit is expanded, it must be enclosed in braces (see
1666<FONT SIZE=-1><B>EXPANSION</B>
1667
1668</FONT>
1669below).
1670<A NAME="lbAV">&nbsp;</A>
1671<H4>Special Parameters</H4>
1672
1673<P>
1674
1675The shell treats several parameters specially. These parameters may
1676only be referenced; assignment to them is not allowed.
1677
1678<DL COMPACT>
1679<DT><B>*</B>
1680
1681<DD>
ac50fbac
CR
1682Expands to the positional parameters, starting from one.
1683When the expansion is not within double quotes, each positional parameter
1684expands to a separate word.
1685In contexts where it is performed, those words
1686are subject to further word splitting and pathname expansion.
1687When the expansion occurs within double quotes, it expands to a single word
17345e5a
JA
1688with the value of each parameter separated by the first character
1689of the
1690<FONT SIZE=-1><B>IFS</B>
1691
1692</FONT>
1693special variable. That is, &quot;<B>$*</B>&quot; is equivalent
1694to &quot;<B>$1</B><I>c</I><B>$2</B><I>c</I><B>...</B>&quot;, where
1695<I>c</I>
1696
1697is the first character of the value of the
1698<FONT SIZE=-1><B>IFS</B>
1699
1700</FONT>
1701variable. If
1702<FONT SIZE=-1><B>IFS</B>
1703
1704</FONT>
1705is unset, the parameters are separated by spaces.
1706If
1707<FONT SIZE=-1><B>IFS</B>
1708
1709</FONT>
1710is null, the parameters are joined without intervening separators.
1711<DT><B>@</B>
1712
1713<DD>
1714Expands to the positional parameters, starting from one. When the
1715expansion occurs within double quotes, each parameter expands to a
1716separate word. That is, &quot;<B>$@</B>&quot; is equivalent to
1717&quot;<B>$1</B>&quot; &quot;<B>$2</B>&quot; ...
1718If the double-quoted expansion occurs within a word, the expansion of
1719the first parameter is joined with the beginning part of the original
1720word, and the expansion of the last parameter is joined with the last
1721part of the original word.
1722When there are no positional parameters, &quot;<B>$@</B>&quot; and
1723<B>$@</B>
1724
1725expand to nothing (i.e., they are removed).
1726<DT><B>#</B>
1727
1728<DD>
1729Expands to the number of positional parameters in decimal.
1730<DT><B>?</B>
1731
1732<DD>
1733Expands to the exit status of the most recently executed foreground
1734pipeline.
1735<DT><B>-</B>
1736
1737<DD>
1738Expands to the current option flags as specified upon invocation,
1739by the
1740<B>set</B>
1741
1742builtin command, or those set by the shell itself
1743(such as the
1744<B>-i</B>
1745
1746option).
1747<DT><B>$</B>
1748
1749<DD>
1750Expands to the process ID of the shell. In a () subshell, it
1751expands to the process ID of the current shell, not the
1752subshell.
1753<DT><B>!</B>
1754
1755<DD>
ac50fbac
CR
1756Expands to the process ID of the job most recently placed into the
1757background, whether executed as an asynchronous command or using
1758the <B>bg</B> builtin (see
1759<FONT SIZE=-1><B>JOB CONTROL</B>
1760
1761</FONT>
1762below).
17345e5a
JA
1763<DT><B>0</B>
1764
1765<DD>
1766Expands to the name of the shell or shell script. This is set at
1767shell initialization. If
1768<B>bash</B>
1769
1770is invoked with a file of commands,
1771<B>$0</B>
1772
1773is set to the name of that file. If
1774<B>bash</B>
1775
1776is started with the
1777<B>-c</B>
1778
1779option, then
1780<B>$0</B>
1781
1782is set to the first argument after the string to be
1783executed, if one is present. Otherwise, it is set
ac50fbac 1784to the filename used to invoke
17345e5a
JA
1785<B>bash</B>,
1786
1787as given by argument zero.
1788<DT><B>_</B>
1789
1790<DD>
1791At shell startup, set to the absolute pathname used to invoke the
1792shell or shell script being executed as passed in the environment
1793or argument list.
1794Subsequently, expands to the last argument to the previous command,
1795after expansion.
1796Also set to the full pathname used to invoke each command executed
1797and placed in the environment exported to that command.
1798When checking mail, this parameter holds the name of the mail file
1799currently being checked.
1800
1801</DL>
1802<A NAME="lbAW">&nbsp;</A>
1803<H4>Shell Variables</H4>
1804
1805<P>
1806
1807The following variables are set by the shell:
1808<P>
1809
1810
1811<DL COMPACT>
1812<DT><B>BASH</B>
1813
1814<DD>
ac50fbac 1815Expands to the full filename used to invoke this instance of
17345e5a
JA
1816<B>bash</B>.
1817
0001803f
CR
1818<DT><B>BASHOPTS</B>
1819
1820<DD>
1821A colon-separated list of enabled shell options. Each word in
1822the list is a valid argument for the
1823<B>-s</B>
1824
1825option to the
1826<B>shopt</B>
1827
1828builtin command (see
1829<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
1830
1831</FONT>
1832below). The options appearing in
1833<FONT SIZE=-1><B>BASHOPTS</B>
1834
1835</FONT>
1836are those reported as
1837<I>on</I>
1838
1839by <B>shopt</B>.
1840If this variable is in the environment when
1841<B>bash</B>
1842
1843starts up, each shell option in the list will be enabled before
1844reading any startup files.
1845This variable is read-only.
17345e5a
JA
1846<DT><B>BASHPID</B>
1847
1848<DD>
495aee44 1849Expands to the process ID of the current <B>bash</B> process.
17345e5a
JA
1850This differs from <B>$$</B> under certain circumstances, such as subshells
1851that do not require <B>bash</B> to be re-initialized.
1852<DT><B>BASH_ALIASES</B>
1853
1854<DD>
1855An associative array variable whose members correspond to the internal
495aee44 1856list of aliases as maintained by the <B>alias</B> builtin.
17345e5a
JA
1857Elements added to this array appear in the alias list; unsetting array
1858elements cause aliases to be removed from the alias list.
1859<DT><B>BASH_ARGC</B>
1860
1861<DD>
1862An array variable whose values are the number of parameters in each
1863frame of the current <B>bash</B> execution call stack.
1864The number of
1865parameters to the current subroutine (shell function or script executed
1866with <B>.</B> or <B>source</B>) is at the top of the stack.
1867When a subroutine is executed, the number of parameters passed is pushed onto
0001803f
CR
1868<FONT SIZE=-1><B>BASH_ARGC</B>.
1869
1870</FONT>
1871The shell sets
1872<FONT SIZE=-1><B>BASH_ARGC</B>
1873
1874</FONT>
1875only when in extended debugging mode (see the description of the
17345e5a
JA
1876<B>extdebug</B>
1877
1878option to the
1879<B>shopt</B>
1880
1881builtin below)
1882<DT><B>BASH_ARGV</B>
1883
1884<DD>
1885An array variable containing all of the parameters in the current <B>bash</B>
1886execution call stack. The final parameter of the last subroutine call
1887is at the top of the stack; the first parameter of the initial call is
1888at the bottom. When a subroutine is executed, the parameters supplied
0001803f
CR
1889are pushed onto
1890<FONT SIZE=-1><B>BASH_ARGV</B>.
1891
1892</FONT>
1893The shell sets
1894<FONT SIZE=-1><B>BASH_ARGV</B>
1895
1896</FONT>
1897only when in extended debugging mode
17345e5a
JA
1898(see the description of the
1899<B>extdebug</B>
1900
1901option to the
1902<B>shopt</B>
1903
1904builtin below)
1905<DT><B>BASH_CMDS</B>
1906
1907<DD>
1908An associative array variable whose members correspond to the internal
1909hash table of commands as maintained by the <B>hash</B> builtin.
1910Elements added to this array appear in the hash table; unsetting array
1911elements cause commands to be removed from the hash table.
1912<DT><B>BASH_COMMAND</B>
1913
1914<DD>
1915The command currently being executed or about to be executed, unless the
1916shell is executing a command as the result of a trap,
1917in which case it is the command executing at the time of the trap.
1918<DT><B>BASH_EXECUTION_STRING</B>
1919
1920<DD>
1921The command argument to the <B>-c</B> invocation option.
1922<DT><B>BASH_LINENO</B>
1923
1924<DD>
1925An array variable whose members are the line numbers in source files
495aee44
CR
1926where each corresponding member of
1927<FONT SIZE=-1><B>FUNCNAME</B>
0001803f
CR
1928
1929</FONT>
495aee44 1930was invoked.
17345e5a 1931<B>${BASH_LINENO[</B><I>$i</I><B>]}</B> is the line number in the source
495aee44
CR
1932file (<B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B>) where
1933<B>${FUNCNAME[</B><I>$i</I><B>]}</B> was called
17345e5a
JA
1934(or <B>${BASH_LINENO[</B><I>$i-1</I><B>]}</B> if referenced within another
1935shell function).
0001803f
CR
1936Use
1937<FONT SIZE=-1><B>LINENO</B>
1938
1939</FONT>
1940to obtain the current line number.
17345e5a
JA
1941<DT><B>BASH_REMATCH</B>
1942
1943<DD>
1944An array variable whose members are assigned by the <B>=~</B> binary
1945operator to the <B>[[</B> conditional command.
1946The element with index 0 is the portion of the string
1947matching the entire regular expression.
1948The element with index <I>n</I> is the portion of the
1949string matching the <I>n</I>th parenthesized subexpression.
1950This variable is read-only.
1951<DT><B>BASH_SOURCE</B>
1952
1953<DD>
495aee44
CR
1954An array variable whose members are the source filenames
1955where the corresponding shell function names in the
0001803f
CR
1956<FONT SIZE=-1><B>FUNCNAME</B>
1957
1958</FONT>
495aee44
CR
1959array variable are defined.
1960The shell function
1961<B>${FUNCNAME[</B><I>$i</I><B>]}</B> is defined in the file
1962<B>${BASH_SOURCE[</B><I>$i</I><B>]}</B> and called from
1963<B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B>.
17345e5a
JA
1964<DT><B>BASH_SUBSHELL</B>
1965
1966<DD>
ac50fbac
CR
1967Incremented by one within each subshell or subshell environment when
1968the shell begins executing in that environment.
17345e5a
JA
1969The initial value is 0.
1970<DT><B>BASH_VERSINFO</B>
1971
1972<DD>
1973A readonly array variable whose members hold version information for
1974this instance of
1975<B>bash</B>.
1976
1977The values assigned to the array members are as follows:
1978<P>
1979<DL COMPACT><DT><DD>
17345e5a
JA
1980<DL COMPACT>
1981<DT><B>BASH_VERSINFO[</B>0]
1982
1983<DD>
1984The major version number (the <I>release</I>).
1985<DT><B>BASH_VERSINFO[</B>1]
1986
1987<DD>
1988The minor version number (the <I>version</I>).
1989<DT><B>BASH_VERSINFO[</B>2]
1990
1991<DD>
1992The patch level.
1993<DT><B>BASH_VERSINFO[</B>3]
1994
1995<DD>
1996The build version.
1997<DT><B>BASH_VERSINFO[</B>4]
1998
1999<DD>
2000The release status (e.g., <I>beta1</I>).
2001<DT><B>BASH_VERSINFO[</B>5]
2002
2003<DD>
0001803f
CR
2004The value of
2005<FONT SIZE=-1><B>MACHTYPE</B>.
2006
2007</FONT>
17345e5a
JA
2008</DL></DL>
2009
2010<DT><B>BASH_VERSION</B>
2011
2012<DD>
2013Expands to a string describing the version of this instance of
2014<B>bash</B>.
2015
2016<DT><B>COMP_CWORD</B>
2017
2018<DD>
2019An index into <B>${COMP_WORDS}</B> of the word containing the current
2020cursor position.
2021This variable is available only in shell functions invoked by the
2022programmable completion facilities (see <B>Programmable Completion</B>
2023below).
2024<DT><B>COMP_KEY</B>
2025
2026<DD>
2027The key (or final key of a key sequence) used to invoke the current
2028completion function.
2029<DT><B>COMP_LINE</B>
2030
2031<DD>
2032The current command line.
2033This variable is available only in shell functions and external
2034commands invoked by the
2035programmable completion facilities (see <B>Programmable Completion</B>
2036below).
2037<DT><B>COMP_POINT</B>
2038
2039<DD>
2040The index of the current cursor position relative to the beginning of
2041the current command.
2042If the current cursor position is at the end of the current command,
2043the value of this variable is equal to <B>${#COMP_LINE}</B>.
2044This variable is available only in shell functions and external
2045commands invoked by the
2046programmable completion facilities (see <B>Programmable Completion</B>
2047below).
2048<DT><B>COMP_TYPE</B>
2049
2050<DD>
2051Set to an integer value corresponding to the type of completion attempted
2052that caused a completion function to be called:
2053<I>TAB</I>, for normal completion,
2054<I>?</I>, for listing completions after successive tabs,
2055<I>!</I>, for listing alternatives on partial word completion,
2056<I>@</I>, to list completions if the word is not unmodified,
2057or
2058<I>%</I>, for menu completion.
2059This variable is available only in shell functions and external
2060commands invoked by the
2061programmable completion facilities (see <B>Programmable Completion</B>
2062below).
2063<DT><B>COMP_WORDBREAKS</B>
2064
2065<DD>
0001803f 2066The set of characters that the <B>readline</B> library treats as word
17345e5a
JA
2067separators when performing word completion.
2068If
2069<FONT SIZE=-1><B>COMP_WORDBREAKS</B>
2070
2071</FONT>
2072is unset, it loses its special properties, even if it is
2073subsequently reset.
2074<DT><B>COMP_WORDS</B>
2075
2076<DD>
2077An array variable (see <B>Arrays</B> below) consisting of the individual
2078words in the current command line.
0001803f
CR
2079The line is split into words as <B>readline</B> would split it, using
2080<FONT SIZE=-1><B>COMP_WORDBREAKS</B>
2081
2082</FONT>
2083as described above.
17345e5a
JA
2084This variable is available only in shell functions invoked by the
2085programmable completion facilities (see <B>Programmable Completion</B>
2086below).
495aee44
CR
2087<DT><B>COPROC</B>
2088
2089<DD>
2090An array variable (see <B>Arrays</B> below) created to hold the file descriptors
2091for output from and input to an unnamed coprocess (see <B>Coprocesses</B>
2092above).
17345e5a
JA
2093<DT><B>DIRSTACK</B>
2094
2095<DD>
2096An array variable (see
2097<B>Arrays</B>
2098
2099below) containing the current contents of the directory stack.
2100Directories appear in the stack in the order they are displayed by the
2101<B>dirs</B>
2102
2103builtin.
2104Assigning to members of this array variable may be used to modify
2105directories already in the stack, but the
2106<B>pushd</B>
2107
2108and
2109<B>popd</B>
2110
2111builtins must be used to add and remove directories.
2112Assignment to this variable will not change the current directory.
2113If
2114<FONT SIZE=-1><B>DIRSTACK</B>
2115
2116</FONT>
2117is unset, it loses its special properties, even if it is
2118subsequently reset.
2119<DT><B>EUID</B>
2120
2121<DD>
2122Expands to the effective user ID of the current user, initialized at
2123shell startup. This variable is readonly.
2124<DT><B>FUNCNAME</B>
2125
2126<DD>
2127An array variable containing the names of all shell functions
2128currently in the execution call stack.
2129The element with index 0 is the name of any currently-executing
2130shell function.
495aee44 2131The bottom-most element (the one with the highest index) is
17345e5a
JA
2132<TT>&quot;main&quot;</TT>.
2133
2134This variable exists only when a shell function is executing.
2135Assignments to
2136<FONT SIZE=-1><B>FUNCNAME</B>
2137
2138</FONT>
2139have no effect and return an error status.
2140If
2141<FONT SIZE=-1><B>FUNCNAME</B>
2142
2143</FONT>
2144is unset, it loses its special properties, even if it is
2145subsequently reset.
495aee44
CR
2146<P>
2147
2148
2149This variable can be used with <B>BASH_LINENO</B> and <B>BASH_SOURCE</B>.
2150Each element of <B>FUNCNAME</B> has corresponding elements in
2151<B>BASH_LINENO</B> and <B>BASH_SOURCE</B> to describe the call stack.
2152For instance, <B>${FUNCNAME[</B><I>$i</I><B>]}</B> was called from the file
2153<B>${BASH_SOURCE[</B><I>$i+1</I><B>]}</B> at line number
2154<B>${BASH_LINENO[</B><I>$i</I><B>]}</B>.
2155The <B>caller</B> builtin displays the current call stack using this
2156information.
17345e5a
JA
2157<DT><B>GROUPS</B>
2158
2159<DD>
2160An array variable containing the list of groups of which the current
2161user is a member.
2162Assignments to
2163<FONT SIZE=-1><B>GROUPS</B>
2164
2165</FONT>
2166have no effect and return an error status.
2167If
2168<FONT SIZE=-1><B>GROUPS</B>
2169
2170</FONT>
2171is unset, it loses its special properties, even if it is
2172subsequently reset.
2173<DT><B>HISTCMD</B>
2174
2175<DD>
2176The history number, or index in the history list, of the current
2177command.
2178If
2179<FONT SIZE=-1><B>HISTCMD</B>
2180
2181</FONT>
2182is unset, it loses its special properties, even if it is
2183subsequently reset.
2184<DT><B>HOSTNAME</B>
2185
2186<DD>
2187Automatically set to the name of the current host.
2188<DT><B>HOSTTYPE</B>
2189
2190<DD>
2191Automatically set to a string that uniquely
2192describes the type of machine on which
2193<B>bash</B>
2194
2195is executing.
2196The default is system-dependent.
2197<DT><B>LINENO</B>
2198
2199<DD>
2200Each time this parameter is referenced, the shell substitutes
2201a decimal number representing the current sequential line number
2202(starting with 1) within a script or function. When not in a
2203script or function, the value substituted is not guaranteed to
2204be meaningful.
2205If
2206<FONT SIZE=-1><B>LINENO</B>
2207
2208</FONT>
2209is unset, it loses its special properties, even if it is
2210subsequently reset.
2211<DT><B>MACHTYPE</B>
2212
2213<DD>
2214Automatically set to a string that fully describes the system
2215type on which
2216<B>bash</B>
2217
2218is executing, in the standard GNU <I>cpu-company-system</I> format.
2219The default is system-dependent.
495aee44
CR
2220<DT><B>MAPFILE</B>
2221
2222<DD>
2223An array variable (see <B>Arrays</B> below) created to hold the text
2224read by the <B>mapfile</B> builtin when no variable name is supplied.
17345e5a
JA
2225<DT><B>OLDPWD</B>
2226
2227<DD>
2228The previous working directory as set by the
2229<B>cd</B>
2230
2231command.
2232<DT><B>OPTARG</B>
2233
2234<DD>
2235The value of the last option argument processed by the
2236<B>getopts</B>
2237
2238builtin command (see
2239<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2240
2241</FONT>
2242below).
2243<DT><B>OPTIND</B>
2244
2245<DD>
2246The index of the next argument to be processed by the
2247<B>getopts</B>
2248
2249builtin command (see
2250<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2251
2252</FONT>
2253below).
2254<DT><B>OSTYPE</B>
2255
2256<DD>
2257Automatically set to a string that
2258describes the operating system on which
2259<B>bash</B>
2260
2261is executing.
2262The default is system-dependent.
2263<DT><B>PIPESTATUS</B>
2264
2265<DD>
2266An array variable (see
2267<B>Arrays</B>
2268
2269below) containing a list of exit status values from the processes
2270in the most-recently-executed foreground pipeline (which may
2271contain only a single command).
2272<DT><B>PPID</B>
2273
2274<DD>
2275The process ID of the shell's parent. This variable is readonly.
2276<DT><B>PWD</B>
2277
2278<DD>
2279The current working directory as set by the
2280<B>cd</B>
2281
2282command.
2283<DT><B>RANDOM</B>
2284
2285<DD>
2286Each time this parameter is referenced, a random integer between
22870 and 32767 is
2288generated. The sequence of random numbers may be initialized by assigning
2289a value to
2290<FONT SIZE=-1><B>RANDOM</B>.
2291
2292</FONT>
2293If
2294<FONT SIZE=-1><B>RANDOM</B>
2295
2296</FONT>
2297is unset, it loses its special properties, even if it is
2298subsequently reset.
495aee44
CR
2299<DT><B>READLINE_LINE</B>
2300
2301<DD>
2302The contents of the
2303<B>readline</B>
2304
2305line buffer, for use with
2306<TT>bind -x</TT>
2307
2308(see
2309<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2310
2311</FONT>
2312below).
2313<DT><B>READLINE_POINT</B>
2314
2315<DD>
2316The position of the insertion point in the
2317<B>readline</B>
2318
2319line buffer, for use with
2320<TT>bind -x</TT>
2321
2322(see
2323<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2324
2325</FONT>
2326below).
17345e5a
JA
2327<DT><B>REPLY</B>
2328
2329<DD>
2330Set to the line of input read by the
2331<B>read</B>
2332
2333builtin command when no arguments are supplied.
2334<DT><B>SECONDS</B>
2335
2336<DD>
2337Each time this parameter is
2338referenced, the number of seconds since shell invocation is returned. If a
2339value is assigned to
2340<FONT SIZE=-1><B>SECONDS</B>,
2341
2342</FONT>
2343the value returned upon subsequent
2344references is
2345the number of seconds since the assignment plus the value assigned.
2346If
2347<FONT SIZE=-1><B>SECONDS</B>
2348
2349</FONT>
2350is unset, it loses its special properties, even if it is
2351subsequently reset.
2352<DT><B>SHELLOPTS</B>
2353
2354<DD>
2355A colon-separated list of enabled shell options. Each word in
2356the list is a valid argument for the
2357<B>-o</B>
2358
2359option to the
2360<B>set</B>
2361
2362builtin command (see
2363<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2364
2365</FONT>
2366below). The options appearing in
2367<FONT SIZE=-1><B>SHELLOPTS</B>
2368
2369</FONT>
2370are those reported as
2371<I>on</I>
2372
2373by <B>set -o</B>.
2374If this variable is in the environment when
2375<B>bash</B>
2376
2377starts up, each shell option in the list will be enabled before
2378reading any startup files.
2379This variable is read-only.
2380<DT><B>SHLVL</B>
2381
2382<DD>
2383Incremented by one each time an instance of
2384<B>bash</B>
2385
2386is started.
2387<DT><B>UID</B>
2388
2389<DD>
2390Expands to the user ID of the current user, initialized at shell startup.
2391This variable is readonly.
2392
2393</DL>
2394<P>
2395
2396The following variables are used by the shell. In some cases,
2397<B>bash</B>
2398
2399assigns a default value to a variable; these cases are noted
2400below.
2401<P>
2402
2403
2404<DL COMPACT>
ac50fbac
CR
2405<DT><B>BASH_COMPAT</B>
2406
2407<DD>
2408The value is used to set the shell's compatibility level.
2409See the description of the <B>shopt</B> builtin below under
2410<B>SHELL BUILTIN COMMANDS</B>
2411for a description of the various compatibility
2412levels and their effects.
2413The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42)
2414corresponding to the desired compatibility level.
2415If <B>BASH_COMPAT</B> is unset or set to the empty string, the compatibility
2416level is set to the default for the current version.
2417If <B>BASH_COMPAT</B> is set to a value that is not one of the valid
2418compatibility levels, the shell prints an error message and sets the
2419compatibility level to the default for the current version.
2420The valid compatibility levels correspond to the compatibility options
2421accepted by the <B>shopt</B> builtin described below (for example,
2422<B>compat42</B> means that 4.2 and 42 are valid values).
2423The current version is also a valid value.
17345e5a
JA
2424<DT><B>BASH_ENV</B>
2425
2426<DD>
2427If this parameter is set when <B>bash</B> is executing a shell script,
2428its value is interpreted as a filename containing commands to
2429initialize the shell, as in
2430<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>.
2431
2432The value of
2433<FONT SIZE=-1><B>BASH_ENV</B>
2434
2435</FONT>
2436is subjected to parameter expansion, command substitution, and arithmetic
ac50fbac 2437expansion before being interpreted as a filename.
17345e5a
JA
2438<FONT SIZE=-1><B>PATH</B>
2439
2440</FONT>
ac50fbac 2441is not used to search for the resultant filename.
0001803f
CR
2442<DT><B>BASH_XTRACEFD</B>
2443
2444<DD>
2445If set to an integer corresponding to a valid file descriptor, <B>bash</B>
2446will write the trace output generated when
2447<TT>set -x</TT>
2448
2449is enabled to that file descriptor.
2450The file descriptor is closed when
2451<FONT SIZE=-1><B>BASH_XTRACEFD</B>
2452
2453</FONT>
2454is unset or assigned a new value.
2455Unsetting
2456<FONT SIZE=-1><B>BASH_XTRACEFD</B>
2457
2458</FONT>
2459or assigning it the empty string causes the
2460trace output to be sent to the standard error.
2461Note that setting
2462<FONT SIZE=-1><B>BASH_XTRACEFD</B>
2463
2464</FONT>
2465to 2 (the standard error file
2466descriptor) and then unsetting it will result in the standard error
2467being closed.
495aee44
CR
2468<DT><B>CDPATH</B>
2469
2470<DD>
2471The search path for the
2472<B>cd</B>
2473
2474command.
2475This is a colon-separated list of directories in which the shell looks
2476for destination directories specified by the
2477<B>cd</B>
2478
2479command.
2480A sample value is
2481<TT>&quot;.:~:/usr&quot;</TT>.
2482
ac50fbac
CR
2483<DT><B>CHILD_MAX</B>
2484
2485<DD>
2486Set the number of exited child status values for the shell to remember.
2487Bash will not allow this value to be decreased below a POSIX-mandated
2488minimum, and there is a maximum value (currently 8192) that this may
2489not exceed.
2490The minimum value is system-dependent.
17345e5a
JA
2491<DT><B>COLUMNS</B>
2492
2493<DD>
495aee44 2494Used by the <B>select</B> compound command to determine the terminal width
ac50fbac
CR
2495when printing selection lists.
2496Automatically set if the
2497<B>checkwinsize</B>
2498
2499option is enabled or in an interactive shell upon receipt of a
495aee44
CR
2500<FONT SIZE=-1><B>SIGWINCH</B>.
2501
2502</FONT>
17345e5a
JA
2503<DT><B>COMPREPLY</B>
2504
2505<DD>
2506An array variable from which <B>bash</B> reads the possible completions
2507generated by a shell function invoked by the programmable completion
2508facility (see <B>Programmable Completion</B> below).
ac50fbac 2509Each array element contains one possible completion.
17345e5a
JA
2510<DT><B>EMACS</B>
2511
2512<DD>
2513If <B>bash</B> finds this variable in the environment when the shell starts
2514with value
2515<TT>t</TT>,
2516
495aee44 2517it assumes that the shell is running in an Emacs shell buffer and disables
17345e5a 2518line editing.
495aee44
CR
2519<DT><B>ENV</B>
2520
2521<DD>
2522Similar to
2523<FONT SIZE=-1><B>BASH_ENV</B>;
2524
2525</FONT>
2526used when the shell is invoked in POSIX mode.
17345e5a
JA
2527<DT><B>FCEDIT</B>
2528
2529<DD>
2530The default editor for the
2531<B>fc</B>
2532
2533builtin command.
2534<DT><B>FIGNORE</B>
2535
2536<DD>
2537A colon-separated list of suffixes to ignore when performing
2538filename completion (see
2539<FONT SIZE=-1><B>READLINE</B>
2540
2541</FONT>
2542below).
2543A filename whose suffix matches one of the entries in
2544<FONT SIZE=-1><B>FIGNORE</B>
2545
2546</FONT>
2547is excluded from the list of matched filenames.
2548A sample value is
2549<TT>&quot;.o:~&quot;</TT>.
2550
495aee44
CR
2551<DT><B>FUNCNEST</B>
2552
2553<DD>
2554If set to a numeric value greater than 0, defines a maximum function
2555nesting level. Function invocations that exceed this nesting level
2556will cause the current command to abort.
17345e5a
JA
2557<DT><B>GLOBIGNORE</B>
2558
2559<DD>
2560A colon-separated list of patterns defining the set of filenames to
2561be ignored by pathname expansion.
2562If a filename matched by a pathname expansion pattern also matches one
2563of the patterns in
2564<FONT SIZE=-1><B>GLOBIGNORE</B>,
2565
2566</FONT>
2567it is removed from the list of matches.
2568<DT><B>HISTCONTROL</B>
2569
2570<DD>
2571A colon-separated list of values controlling how commands are saved on
2572the history list.
2573If the list of values includes
2574<I>ignorespace</I>,
2575
2576lines which begin with a
2577<B>space</B>
2578
2579character are not saved in the history list.
2580A value of
2581<I>ignoredups</I>
2582
2583causes lines matching the previous history entry to not be saved.
2584A value of
2585<I>ignoreboth</I>
2586
2587is shorthand for <I>ignorespace</I> and <I>ignoredups</I>.
2588A value of
2589<I>erasedups</I>
2590
2591causes all previous lines matching the current line to be removed from
2592the history list before that line is saved.
2593Any value not in the above list is ignored.
0001803f
CR
2594If
2595<FONT SIZE=-1><B>HISTCONTROL</B>
2596
2597</FONT>
2598is unset, or does not include a valid value,
17345e5a
JA
2599all lines read by the shell parser are saved on the history list,
2600subject to the value of
0001803f 2601<FONT SIZE=-1><B>HISTIGNORE</B>.
17345e5a 2602
0001803f 2603</FONT>
17345e5a
JA
2604The second and subsequent lines of a multi-line compound command are
2605not tested, and are added to the history regardless of the value of
0001803f 2606<FONT SIZE=-1><B>HISTCONTROL</B>.
17345e5a 2607
0001803f 2608</FONT>
17345e5a
JA
2609<DT><B>HISTFILE</B>
2610
2611<DD>
2612The name of the file in which command history is saved (see
2613<FONT SIZE=-1><B>HISTORY</B>
2614
2615</FONT>
2616below). The default value is <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>. If unset, the
ac50fbac 2617command history is not saved when a shell exits.
17345e5a
JA
2618<DT><B>HISTFILESIZE</B>
2619
2620<DD>
2621The maximum number of lines contained in the history file. When this
2622variable is assigned a value, the history file is truncated, if
ac50fbac
CR
2623necessary,
2624to contain no more than that number of lines by removing the oldest entries.
2625The history file is also truncated to this size after
2626writing it when a shell exits.
2627If the value is 0, the history file is truncated to zero size.
2628Non-numeric values and numeric values less than zero inhibit truncation.
2629The shell sets the default value to the value of <B>HISTSIZE</B>
2630after reading any startup files.
17345e5a
JA
2631<DT><B>HISTIGNORE</B>
2632
2633<DD>
2634A colon-separated list of patterns used to decide which command lines
2635should be saved on the history list. Each pattern is anchored at the
2636beginning of the line and must match the complete line (no implicit
2637`<B>*</B>' is appended). Each pattern is tested against the line
2638after the checks specified by
0001803f 2639<FONT SIZE=-1><B>HISTCONTROL</B>
17345e5a 2640
0001803f 2641</FONT>
17345e5a
JA
2642are applied.
2643In addition to the normal shell pattern matching characters, `<B>&amp;</B>'
2644matches the previous history line. `<B>&amp;</B>' may be escaped using a
2645backslash; the backslash is removed before attempting a match.
2646The second and subsequent lines of a multi-line compound command are
2647not tested, and are added to the history regardless of the value of
0001803f 2648<FONT SIZE=-1><B>HISTIGNORE</B>.
17345e5a 2649
0001803f 2650</FONT>
17345e5a
JA
2651<DT><B>HISTSIZE</B>
2652
2653<DD>
2654The number of commands to remember in the command history (see
2655<FONT SIZE=-1><B>HISTORY</B>
2656
2657</FONT>
ac50fbac
CR
2658below).
2659If the value is 0, commands are not saved in the history list.
2660Numeric values less than zero result in every command being saved
2661on the history list (there is no limit).
2662The shell sets the default value to 500 after reading any startup files.
17345e5a
JA
2663<DT><B>HISTTIMEFORMAT</B>
2664
2665<DD>
2666If this variable is set and not null, its value is used as a format string
2667for <I>strftime</I>(3) to print the time stamp associated with each history
2668entry displayed by the <B>history</B> builtin.
2669If this variable is set, time stamps are written to the history file so
2670they may be preserved across shell sessions.
2671This uses the history comment character to distinguish timestamps from
2672other history lines.
2673<DT><B>HOME</B>
2674
2675<DD>
2676The home directory of the current user; the default argument for the
2677<B>cd</B> builtin command.
2678The value of this variable is also used when performing tilde expansion.
2679<DT><B>HOSTFILE</B>
2680
2681<DD>
2682Contains the name of a file in the same format as
2683
2684<I>/etc/hosts</I>
2685
2686that should be read when the shell needs to complete a
2687hostname.
2688The list of possible hostname completions may be changed while the
2689shell is running;
2690the next time hostname completion is attempted after the
2691value is changed,
2692<B>bash</B>
2693
2694adds the contents of the new file to the existing list.
2695If
2696<FONT SIZE=-1><B>HOSTFILE</B>
2697
2698</FONT>
0001803f
CR
2699is set, but has no value, or does not name a readable file,
2700<B>bash</B> attempts to read
17345e5a
JA
2701
2702<I>/etc/hosts</I>
2703
2704to obtain the list of possible hostname completions.
2705When
2706<FONT SIZE=-1><B>HOSTFILE</B>
2707
2708</FONT>
2709is unset, the hostname list is cleared.
2710<DT><B>IFS</B>
2711
2712<DD>
2713The
2714<I>Internal Field Separator</I>
2715
2716that is used
2717for word splitting after expansion and to
2718split lines into words with the
2719<B>read</B>
2720
2721builtin command. The default value is
2722``&lt;space&gt;&lt;tab&gt;&lt;newline&gt;''.
2723<DT><B>IGNOREEOF</B>
2724
2725<DD>
2726Controls the
2727action of an interactive shell on receipt of an
2728<FONT SIZE=-1><B>EOF</B>
2729
2730</FONT>
2731character as the sole input. If set, the value is the number of
2732consecutive
2733<FONT SIZE=-1><B>EOF</B>
2734
2735</FONT>
2736characters which must be
2737typed as the first characters on an input line before
2738<B>bash</B>
2739
2740exits. If the variable exists but does not have a numeric value, or
2741has no value, the default value is 10. If it does not exist,
2742<FONT SIZE=-1><B>EOF</B>
2743
2744</FONT>
2745signifies the end of input to the shell.
2746<DT><B>INPUTRC</B>
2747
2748<DD>
2749The filename for the
2750<B>readline</B>
2751
2752startup file, overriding the default of
2753
2754<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
2755
2756(see
2757<FONT SIZE=-1><B>READLINE</B>
2758
2759</FONT>
2760below).
2761<DT><B>LANG</B>
2762
2763<DD>
2764Used to determine the locale category for any category not specifically
2765selected with a variable starting with <B>LC_</B>.
2766<DT><B>LC_ALL</B>
2767
2768<DD>
0001803f
CR
2769This variable overrides the value of
2770<FONT SIZE=-1><B>LANG</B>
2771
2772</FONT>
2773and any other
17345e5a
JA
2774<B>LC_</B> variable specifying a locale category.
2775<DT><B>LC_COLLATE</B>
2776
2777<DD>
2778This variable determines the collation order used when sorting the
2779results of pathname expansion, and determines the behavior of range
2780expressions, equivalence classes, and collating sequences within
2781pathname expansion and pattern matching.
2782<DT><B>LC_CTYPE</B>
2783
2784<DD>
2785This variable determines the interpretation of characters and the
2786behavior of character classes within pathname expansion and pattern
2787matching.
2788<DT><B>LC_MESSAGES</B>
2789
2790<DD>
2791This variable determines the locale used to translate double-quoted
2792strings preceded by a <B>$</B>.
2793<DT><B>LC_NUMERIC</B>
2794
2795<DD>
2796This variable determines the locale category used for number formatting.
2797<DT><B>LINES</B>
2798
2799<DD>
495aee44 2800Used by the <B>select</B> compound command to determine the column length
ac50fbac
CR
2801for printing selection lists.
2802Automatically set if the
2803<B>checkwinsize</B>
2804
2805option is enabled or in an interactive shell upon receipt of a
0001803f
CR
2806<FONT SIZE=-1><B>SIGWINCH</B>.
2807
2808</FONT>
17345e5a
JA
2809<DT><B>MAIL</B>
2810
2811<DD>
495aee44 2812If this parameter is set to a file or directory name and the
17345e5a
JA
2813<FONT SIZE=-1><B>MAILPATH</B>
2814
2815</FONT>
2816variable is not set,
2817<B>bash</B>
2818
495aee44
CR
2819informs the user of the arrival of mail in the specified file or
2820Maildir-format directory.
17345e5a
JA
2821<DT><B>MAILCHECK</B>
2822
2823<DD>
2824Specifies how
2825often (in seconds)
2826<B>bash</B>
2827
2828checks for mail. The default is 60 seconds. When it is time to check
2829for mail, the shell does so before displaying the primary prompt.
2830If this variable is unset, or set to a value that is not a number
2831greater than or equal to zero, the shell disables mail checking.
2832<DT><B>MAILPATH</B>
2833
2834<DD>
ac50fbac 2835A colon-separated list of filenames to be checked for mail.
17345e5a 2836The message to be printed when mail arrives in a particular file
ac50fbac 2837may be specified by separating the filename from the message with a `?'.
17345e5a
JA
2838When used in the text of the message, <B>$_</B> expands to the name of
2839the current mailfile.
2840Example:
2841<DL COMPACT><DT><DD>
2842<P>
2843
2844<B>MAILPATH</B>=aq/var/mail/bfox?&quot;You have mail&quot;:~/shell-mail?&quot;$_ has mail!&quot;aq
2845<P>
2846
2847<B>Bash</B>
2848
2849supplies a default value for this variable, but the location of the user
2850mail files that it uses is system dependent (e.g., /var/mail/<B>$USER</B>).
2851</DL>
2852
2853<DT><B>OPTERR</B>
2854
2855<DD>
2856If set to the value 1,
2857<B>bash</B>
2858
2859displays error messages generated by the
2860<B>getopts</B>
2861
2862builtin command (see
2863<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
2864
2865</FONT>
2866below).
2867<FONT SIZE=-1><B>OPTERR</B>
2868
2869</FONT>
2870is initialized to 1 each time the shell is invoked or a shell
2871script is executed.
2872<DT><B>PATH</B>
2873
2874<DD>
2875The search path for commands. It
2876is a colon-separated list of directories in which
2877the shell looks for commands (see
2878<FONT SIZE=-1><B>COMMAND EXECUTION</B>
2879
2880</FONT>
2881below).
0001803f
CR
2882A zero-length (null) directory name in the value of
2883<FONT SIZE=-1><B>PATH</B>
2884
2885</FONT>
2886indicates the current directory.
17345e5a
JA
2887A null directory name may appear as two adjacent colons, or as an initial
2888or trailing colon.
2889The default path is system-dependent,
2890and is set by the administrator who installs
2891<B>bash</B>.
2892
2893A common value is
ac50fbac 2894<TT>/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin</TT>.
17345e5a
JA
2895
2896<DT><B>POSIXLY_CORRECT</B>
2897
2898<DD>
2899If this variable is in the environment when <B>bash</B> starts, the shell
2900enters <I>posix mode</I> before reading the startup files, as if the
2901<B>--posix</B>
2902
2903invocation option had been supplied. If it is set while the shell is
2904running, <B>bash</B> enables <I>posix mode</I>, as if the command
2905<TT>set -o posix</TT>
2906
2907had been executed.
2908<DT><B>PROMPT_COMMAND</B>
2909
2910<DD>
2911If set, the value is executed as a command prior to issuing each primary
2912prompt.
2913<DT><B>PROMPT_DIRTRIM</B>
2914
2915<DD>
2916If set to a number greater than zero, the value is used as the number of
0001803f
CR
2917trailing directory components to retain when expanding the <B>\w</B> and
2918<B>\W</B> prompt string escapes (see
17345e5a
JA
2919<FONT SIZE=-1><B>PROMPTING</B>
2920
2921</FONT>
2922below). Characters removed are replaced with an ellipsis.
2923<DT><B>PS1</B>
2924
2925<DD>
2926The value of this parameter is expanded (see
2927<FONT SIZE=-1><B>PROMPTING</B>
2928
2929</FONT>
2930below) and used as the primary prompt string. The default value is
2931``<B>\s-\v\$ </B>''.
2932<DT><B>PS2</B>
2933
2934<DD>
2935The value of this parameter is expanded as with
0001803f 2936<FONT SIZE=-1><B>PS1</B>
17345e5a 2937
0001803f 2938</FONT>
17345e5a
JA
2939and used as the secondary prompt string. The default is
2940``<B>&gt; </B>''.
2941<DT><B>PS3</B>
2942
2943<DD>
2944The value of this parameter is used as the prompt for the
2945<B>select</B>
2946
2947command (see
2948<FONT SIZE=-1><B>SHELL GRAMMAR</B>
2949
2950</FONT>
2951above).
2952<DT><B>PS4</B>
2953
2954<DD>
2955The value of this parameter is expanded as with
0001803f 2956<FONT SIZE=-1><B>PS1</B>
17345e5a 2957
0001803f 2958</FONT>
17345e5a
JA
2959and the value is printed before each command
2960<B>bash</B>
2961
2962displays during an execution trace. The first character of
2963<FONT SIZE=-1><B>PS4</B>
2964
2965</FONT>
2966is replicated multiple times, as necessary, to indicate multiple
2967levels of indirection. The default is ``<B>+ </B>''.
2968<DT><B>SHELL</B>
2969
2970<DD>
2971The full pathname to the shell is kept in this environment variable.
2972If it is not set when the shell starts,
2973<B>bash</B>
2974
2975assigns to it the full pathname of the current user's login shell.
2976<DT><B>TIMEFORMAT</B>
2977
2978<DD>
2979The value of this parameter is used as a format string specifying
2980how the timing information for pipelines prefixed with the
2981<B>time</B>
2982
2983reserved word should be displayed.
2984The <B>%</B> character introduces an escape sequence that is
2985expanded to a time value or other information.
2986The escape sequences and their meanings are as follows; the
2987braces denote optional portions.
2988<P>
2989<DL COMPACT><DT><DD>
2990
2991<DL COMPACT>
2992<DT><B>%%</B>
2993
2994<DD>
2995A literal <B>%</B>.
2996<DT><B>%[</B><I>p</I>][l]R
2997
2998<DD>
2999The elapsed time in seconds.
3000<DT><B>%[</B><I>p</I>][l]U
3001
3002<DD>
3003The number of CPU seconds spent in user mode.
3004<DT><B>%[</B><I>p</I>][l]S
3005
3006<DD>
3007The number of CPU seconds spent in system mode.
3008<DT><B>%P</B>
3009
3010<DD>
3011The CPU percentage, computed as (%U + %S) / %R.
3012
3013</DL></DL>
3014
3015<DT><DD>
3016The optional <I>p</I> is a digit specifying the <I>precision</I>,
3017the number of fractional digits after a decimal point.
3018A value of 0 causes no decimal point or fraction to be output.
3019At most three places after the decimal point may be specified;
3020values of <I>p</I> greater than 3 are changed to 3.
3021If <I>p</I> is not specified, the value 3 is used.
3022<DT><DD>
3023The optional <B>l</B> specifies a longer format, including
3024minutes, of the form <I>MM</I>m<I>SS</I>.<I>FF</I>s.
3025The value of <I>p</I> determines whether or not the fraction is
3026included.
3027<DT><DD>
3028If this variable is not set, <B>bash</B> acts as if it had the
ac50fbac 3029value <B>$aq\nreal\t%3lR\nuser\t%3lU\nsys\t%3lSaq</B>.
17345e5a
JA
3030If the value is null, no timing information is displayed.
3031A trailing newline is added when the format string is displayed.
ac50fbac 3032
17345e5a
JA
3033<DT><B>TMOUT</B>
3034
3035<DD>
0001803f
CR
3036If set to a value greater than zero,
3037<FONT SIZE=-1><B>TMOUT</B>
3038
3039</FONT>
3040is treated as the
17345e5a
JA
3041default timeout for the <B>read</B> builtin.
3042The <B>select</B> command terminates if input does not arrive
0001803f
CR
3043after
3044<FONT SIZE=-1><B>TMOUT</B>
3045
3046</FONT>
3047seconds when input is coming from a terminal.
17345e5a 3048In an interactive shell, the value is interpreted as the
ac50fbac
CR
3049number of seconds to wait for a line of input after issuing the
3050primary prompt.
17345e5a
JA
3051<B>Bash</B>
3052
ac50fbac
CR
3053terminates after waiting for that number of seconds if a complete
3054line of input does not arrive.
17345e5a
JA
3055<DT><B>TMPDIR</B>
3056
3057<DD>
495aee44
CR
3058If set, <B>bash</B> uses its value as the name of a directory in which
3059<B>bash</B> creates temporary files for the shell's use.
17345e5a
JA
3060<DT><B>auto_resume</B>
3061
3062<DD>
3063This variable controls how the shell interacts with the user and
3064job control. If this variable is set, single word simple
3065commands without redirections are treated as candidates for resumption
3066of an existing stopped job. There is no ambiguity allowed; if there is
3067more than one job beginning with the string typed, the job most recently
3068accessed is selected. The
3069<I>name</I>
3070
3071of a stopped job, in this context, is the command line used to
3072start it.
3073If set to the value
3074<I>exact</I>,
3075
3076the string supplied must match the name of a stopped job exactly;
3077if set to
3078<I>substring</I>,
3079
3080the string supplied needs to match a substring of the name of a
3081stopped job. The
3082<I>substring</I>
3083
3084value provides functionality analogous to the
3085<B>%?</B>
3086
3087job identifier (see
3088<FONT SIZE=-1><B>JOB CONTROL</B>
3089
3090</FONT>
3091below). If set to any other value, the supplied string must
3092be a prefix of a stopped job's name; this provides functionality
3093analogous to the <B>%</B><I>string</I> job identifier.
3094<DT><B>histchars</B>
3095
3096<DD>
3097The two or three characters which control history expansion
3098and tokenization (see
3099<FONT SIZE=-1><B>HISTORY EXPANSION</B>
3100
3101</FONT>
3102below). The first character is the <I>history expansion</I> character,
3103the character which signals the start of a history
3104expansion, normally `<B>!</B>'.
3105The second character is the <I>quick substitution</I>
3106character, which is used as shorthand for re-running the previous
3107command entered, substituting one string for another in the command.
3108The default is `<B>^</B>'.
3109The optional third character is the character
3110which indicates that the remainder of the line is a comment when found
3111as the first character of a word, normally `<B>#</B>'. The history
3112comment character causes history substitution to be skipped for the
3113remaining words on the line. It does not necessarily cause the shell
3114parser to treat the rest of the line as a comment.
3115
3116</DL>
3117<A NAME="lbAX">&nbsp;</A>
3118<H4>Arrays</H4>
3119
3120<B>Bash</B>
3121
3122provides one-dimensional indexed and associative array variables.
3123Any variable may be used as an indexed array; the
3124<B>declare</B>
3125
3126builtin will explicitly declare an array.
3127There is no maximum
3128limit on the size of an array, nor any requirement that members
3129be indexed or assigned contiguously.
3130Indexed arrays are referenced using integers (including arithmetic
3131expressions) and are zero-based; associative arrays are referenced
3132using arbitrary strings.
ac50fbac 3133Unless otherwise noted, indexed array indices must be non-negative integers.
17345e5a
JA
3134<P>
3135
3136An indexed array is created automatically if any variable is assigned to
3137using the syntax <I>name</I>[<I>subscript</I>]=<I>value</I>. The
3138<I>subscript</I>
3139
495aee44 3140is treated as an arithmetic expression that must evaluate to a number.
495aee44 3141To explicitly declare an indexed array, use
17345e5a
JA
3142<B>declare -a </B><I>name</I>
3143
3144(see
3145<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3146
3147</FONT>
3148below).
3149<B>declare -a </B><I>name</I>[<I>subscript</I>]
3150
3151is also accepted; the <I>subscript</I> is ignored.
3152<P>
3153
3154Associative arrays are created using
3155<B>declare -A </B><I>name</I>.
3156
3157<P>
3158
3159Attributes may be
3160specified for an array variable using the
3161<B>declare</B>
3162
3163and
3164<B>readonly</B>
3165
3166builtins. Each attribute applies to all members of an array.
3167<P>
3168
3169Arrays are assigned to using compound assignments of the form
3170<I>name</I>=<B>(</B>value<I>1</I> ... value<I>n</I><B>)</B>, where each
3171<I>value</I> is of the form [<I>subscript</I>]=<I>string</I>.
ac50fbac 3172Indexed array assignments do not require anything but <I>string</I>.
17345e5a
JA
3173When assigning to indexed arrays, if the optional brackets and subscript
3174are supplied, that index is assigned to;
3175otherwise the index of the element assigned is the last index assigned
3176to by the statement plus one. Indexing starts at zero.
3177<P>
3178
3179When assigning to an associative array, the subscript is required.
3180<P>
3181
3182This syntax is also accepted by the
3183<B>declare</B>
3184
3185builtin. Individual array elements may be assigned to using the
3186<I>name</I>[<I>subscript</I>]=<I>value</I> syntax introduced above.
ac50fbac
CR
3187When assigning to an indexed array, if
3188<I>name</I>
3189
3190is subscripted by a negative number, that number is
3191interpreted as relative to one greater than the maximum index of
3192<I>name</I>, so negative indices count back from the end of the
3193array, and an index of -1 references the last element.
17345e5a
JA
3194<P>
3195
3196Any element of an array may be referenced using
3197${<I>name</I>[<I>subscript</I>]}. The braces are required to avoid
3198conflicts with pathname expansion. If
3199<I>subscript</I> is <B>@</B> or <B>*</B>, the word expands to
3200all members of <I>name</I>. These subscripts differ only when the
3201word appears within double quotes. If the word is double-quoted,
3202${<I>name</I>[*]} expands to a single
3203word with the value of each array member separated by the first
3204character of the
3205<FONT SIZE=-1><B>IFS</B>
3206
3207</FONT>
3208special variable, and ${<I>name</I>[@]} expands each element of
3209<I>name</I> to a separate word. When there are no array members,
3210${<I>name</I>[@]} expands to nothing.
3211If the double-quoted expansion occurs within a word, the expansion of
3212the first parameter is joined with the beginning part of the original
3213word, and the expansion of the last parameter is joined with the last
3214part of the original word.
3215This is analogous to the expansion
3216of the special parameters <B>*</B> and <B>@</B> (see
3217<B>Special Parameters</B>
3218
3219above). ${#<I>name</I>[<I>subscript</I>]} expands to the length of
3220${<I>name</I>[<I>subscript</I>]}. If <I>subscript</I> is <B>*</B> or
3221<B>@</B>, the expansion is the number of elements in the array.
3222Referencing an array variable without a subscript is equivalent to
3223referencing the array with a subscript of 0.
ac50fbac
CR
3224If the
3225<I>subscript</I>
3226
3227used to reference an element of an indexed array
3228evaluates to a number less than zero, it is
3229interpreted as relative to one greater than the maximum index of the array,
3230so negative indices count back from the end of the
3231array, and an index of -1 references the last element.
17345e5a
JA
3232<P>
3233
0001803f
CR
3234An array variable is considered set if a subscript has been assigned a
3235value. The null string is a valid value.
3236<P>
3237
ac50fbac
CR
3238It is possible to obtain the keys (indices) of an array as well as the values.
3239${<B>!</B><I>name</I>[<I>@</I>]} and ${<B>!</B><I>name</I>[<I>*</I>]}
3240expand to the indices assigned in array variable <I>name</I>.
3241The treatment when in double quotes is similar to the expansion of the
3242special parameters <I>@</I> and <I>*</I> within double quotes.
3243<P>
3244
17345e5a
JA
3245The
3246<B>unset</B>
3247
3248builtin is used to destroy arrays. <B>unset</B> <I>name</I>[<I>subscript</I>]
3249destroys the array element at index <I>subscript</I>.
ac50fbac 3250Negative subscripts to indexed arrays are interpreted as described above.
0001803f
CR
3251Care must be taken to avoid unwanted side effects caused by pathname
3252expansion.
17345e5a
JA
3253<B>unset</B> <I>name</I>, where <I>name</I> is an array, or
3254<B>unset</B> <I>name</I>[<I>subscript</I>], where
3255<I>subscript</I> is <B>*</B> or <B>@</B>, removes the entire array.
3256<P>
3257
3258The
3259<B>declare</B>,
3260
3261<B>local</B>,
3262
3263and
3264<B>readonly</B>
3265
3266builtins each accept a
3267<B>-a</B>
3268
3269option to specify an indexed array and a
3270<B>-A</B>
3271
3272option to specify an associative array.
ac50fbac
CR
3273If both options are supplied,
3274<B>-A</B>
3275
3276takes precedence.
17345e5a
JA
3277The
3278<B>read</B>
3279
3280builtin accepts a
3281<B>-a</B>
3282
3283option to assign a list of words read from the standard input
3284to an array. The
3285<B>set</B>
3286
3287and
3288<B>declare</B>
3289
3290builtins display array values in a way that allows them to be
3291reused as assignments.
3292<A NAME="lbAY">&nbsp;</A>
3293<H3>EXPANSION</H3>
3294
3295Expansion is performed on the command line after it has been split into
3296words. There are seven kinds of expansion performed:
3297<I>brace expansion</I>,
3298
3299<I>tilde expansion</I>,
3300
3301<I>parameter and variable expansion</I>,
3302
3303<I>command substitution</I>,
3304
3305<I>arithmetic expansion</I>,
3306
3307<I>word splitting</I>,
3308
3309and
3310<I>pathname expansion</I>.
3311
3312<P>
3313
ac50fbac
CR
3314The order of expansions is:
3315brace expansion;
3316tilde expansion, parameter and variable expansion, arithmetic expansion,
3317and command substitution (done in a left-to-right fashion);
3318word splitting;
3319and pathname expansion.
17345e5a
JA
3320<P>
3321
3322On systems that can support it, there is an additional expansion
3323available: <I>process substitution</I>.
ac50fbac
CR
3324This is performed at the
3325same time as tilde, parameter, variable, and arithmetic expansion and
3326command substitution.
17345e5a
JA
3327<P>
3328
3329Only brace expansion, word splitting, and pathname expansion
3330can change the number of words of the expansion; other expansions
3331expand a single word to a single word.
3332The only exceptions to this are the expansions of
3333&quot;<B>$@</B>&quot; and &quot;<B>${</B><I>name</I><B>[@]}</B>&quot;
3334as explained above (see
3335<FONT SIZE=-1><B>PARAMETERS</B>).
3336
3337</FONT>
3338<A NAME="lbAZ">&nbsp;</A>
3339<H4>Brace Expansion</H4>
3340
3341<P>
3342
3343<I>Brace expansion</I>
3344
3345is a mechanism by which arbitrary strings
3346may be generated. This mechanism is similar to
3347<I>pathname expansion</I>, but the filenames generated
3348need not exist. Patterns to be brace expanded take
3349the form of an optional
3350<I>preamble</I>,
3351
3352followed by either a series of comma-separated strings or
3353a sequence expression between a pair of braces, followed by
3354an optional
3355<I>postscript</I>.
3356
3357The preamble is prefixed to each string contained
3358within the braces, and the postscript is then appended
3359to each resulting string, expanding left to right.
3360<P>
3361
3362Brace expansions may be nested. The results of each expanded
3363string are not sorted; left to right order is preserved.
3364For example, a<B>{</B>d,c,b<B>}</B>e expands into `ade ace abe'.
3365<P>
3366
3367A sequence expression takes the form
3368<B>{</B><I>x</I><B>..</B><I>y</I><B>[..</B><I>incr</I><B>]}</B>,
3369where <I>x</I> and <I>y</I> are either integers or single characters,
3370and <I>incr</I>, an optional increment, is an integer.
3371When integers are supplied, the expression expands to each number between
3372<I>x</I> and <I>y</I>, inclusive.
3373Supplied integers may be prefixed with <I>0</I> to force each term to have the
ac50fbac
CR
3374same width.
3375When either <I>x</I> or y begins with a zero, the shell
17345e5a
JA
3376attempts to force all generated terms to contain the same number of digits,
3377zero-padding where necessary.
3378When characters are supplied, the expression expands to each character
ac50fbac
CR
3379lexicographically between <I>x</I> and <I>y</I>, inclusive,
3380using the default C locale.
3381Note that both <I>x</I> and <I>y</I> must be of the same type.
17345e5a
JA
3382When the increment is supplied, it is used as the difference between
3383each term. The default increment is 1 or -1 as appropriate.
3384<P>
3385
3386Brace expansion is performed before any other expansions,
3387and any characters special to other expansions are preserved
3388in the result. It is strictly textual.
3389<B>Bash</B>
3390
3391does not apply any syntactic interpretation to the context of the
3392expansion or the text between the braces.
3393<P>
3394
3395A correctly-formed brace expansion must contain unquoted opening
3396and closing braces, and at least one unquoted comma or a valid
3397sequence expression.
3398Any incorrectly formed brace expansion is left unchanged.
3399A <B>{</B> or <B>,</B> may be quoted with a backslash to prevent its
3400being considered part of a brace expression.
3401To avoid conflicts with parameter expansion, the string <B>${</B>
3402is not considered eligible for brace expansion.
3403<P>
3404
3405This construct is typically used as shorthand when the common
3406prefix of the strings to be generated is longer than in the
3407above example:
3408<DL COMPACT><DT><DD>
3409<P>
3410
3411mkdir /usr/local/src/bash/{old,new,dist,bugs}
3412</DL>
3413
3414or
3415<DL COMPACT><DT><DD>
3416chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
3417</DL>
3418
3419<P>
3420
3421Brace expansion introduces a slight incompatibility with
3422historical versions of
3423<B>sh</B>.
3424
3425<B>sh</B>
3426
3427does not treat opening or closing braces specially when they
3428appear as part of a word, and preserves them in the output.
3429<B>Bash</B>
3430
3431removes braces from words as a consequence of brace
3432expansion. For example, a word entered to
3433<B>sh</B>
3434
3435as <I>file{1,2}</I>
3436appears identically in the output. The same word is
3437output as
3438<I>file1 file2</I>
3439
3440after expansion by
3441<B>bash</B>.
3442
3443If strict compatibility with
3444<B>sh</B>
3445
3446is desired, start
3447<B>bash</B>
3448
3449with the
3450<B>+B </B>
3451
3452option or disable brace expansion with the
3453<B>+B</B>
3454
3455option to the
3456<B>set</B>
3457
3458command (see
3459<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
3460
3461</FONT>
3462below).
3463<A NAME="lbBA">&nbsp;</A>
3464<H4>Tilde Expansion</H4>
3465
3466<P>
3467
3468If a word begins with an unquoted tilde character (`<B>~</B>'), all of
3469the characters preceding the first unquoted slash (or all characters,
3470if there is no unquoted slash) are considered a <I>tilde-prefix</I>.
3471If none of the characters in the tilde-prefix are quoted, the
3472characters in the tilde-prefix following the tilde are treated as a
3473possible <I>login name</I>.
3474If this login name is the null string, the tilde is replaced with the
3475value of the shell parameter
3476<FONT SIZE=-1><B>HOME</B>.
3477
3478</FONT>
3479If
3480<FONT SIZE=-1><B>HOME</B>
3481
3482</FONT>
3483is unset, the home directory of the user executing the shell is
3484substituted instead.
3485Otherwise, the tilde-prefix is replaced with the home directory
3486associated with the specified login name.
3487<P>
3488
3489If the tilde-prefix is a `~+', the value of the shell variable
3490<FONT SIZE=-1><B>PWD</B>
3491
3492</FONT>
3493replaces the tilde-prefix.
3494If the tilde-prefix is a `~-', the value of the shell variable
3495<FONT SIZE=-1><B>OLDPWD</B>,
3496
3497</FONT>
3498if it is set, is substituted.
3499If the characters following the tilde in the tilde-prefix consist
3500of a number <I>N</I>, optionally prefixed
3501by a `+' or a `-', the tilde-prefix is replaced with the corresponding
3502element from the directory stack, as it would be displayed by the
3503<B>dirs</B>
3504
3505builtin invoked with the tilde-prefix as an argument.
3506If the characters following the tilde in the tilde-prefix consist of a
3507number without a leading `+' or `-', `+' is assumed.
3508<P>
3509
3510If the login name is invalid, or the tilde expansion fails, the word
3511is unchanged.
3512<P>
3513
3514Each variable assignment is checked for unquoted tilde-prefixes immediately
3515following a
3516<B>:</B>
3517
3518or the first
3519<B>=</B>.
3520
3521In these cases, tilde expansion is also performed.
ac50fbac 3522Consequently, one may use filenames with tildes in assignments to
17345e5a
JA
3523<FONT SIZE=-1><B>PATH</B>,
3524
3525</FONT>
3526<FONT SIZE=-1><B>MAILPATH</B>,
3527
3528</FONT>
3529and
3530<FONT SIZE=-1><B>CDPATH</B>,
3531
3532</FONT>
3533and the shell assigns the expanded value.
3534<A NAME="lbBB">&nbsp;</A>
3535<H4>Parameter Expansion</H4>
3536
3537<P>
3538
3539The `<B>$</B>' character introduces parameter expansion,
3540command substitution, or arithmetic expansion. The parameter name
3541or symbol to be expanded may be enclosed in braces, which
3542are optional but serve to protect the variable to be expanded from
3543characters immediately following it which could be
3544interpreted as part of the name.
3545<P>
3546
3547When braces are used, the matching ending brace is the first `<B>}</B>'
3548not escaped by a backslash or within a quoted string, and not within an
3549embedded arithmetic expansion, command substitution, or parameter
3550expansion.
3551<P>
3552
3553
3554<DL COMPACT>
3555<DT>${<I>parameter</I>}<DD>
3556The value of <I>parameter</I> is substituted. The braces are required
3557when
3558<I>parameter</I>
3559
3560is a positional parameter with more than one digit,
3561or when
3562<I>parameter</I>
3563
3564is followed by a character which is not to be
3565interpreted as part of its name.
ac50fbac
CR
3566The <I>parameter</I> is a shell parameter as described above
3567<B>PARAMETERS</B>) or an array reference (<B>Arrays</B>).
17345e5a
JA
3568
3569</DL>
3570<P>
3571
0001803f 3572If the first character of <I>parameter</I> is an exclamation point (<B>!</B>),
ac50fbac 3573it introduces a level of variable indirection.
17345e5a
JA
3574<B>Bash</B> uses the value of the variable formed from the rest of
3575<I>parameter</I> as the name of the variable; this variable is then
3576expanded and that value is used in the rest of the substitution, rather
3577than the value of <I>parameter</I> itself.
3578This is known as <I>indirect expansion</I>.
ac50fbac 3579The exceptions to this are the expansions of ${<B>!</B><I>prefix</I><B>*</B>} and
17345e5a
JA
3580${<B>!</B><I>name</I>[<I>@</I>]} described below.
3581The exclamation point must immediately follow the left brace in order to
3582introduce indirection.
3583<P>
3584
3585In each of the cases below, <I>word</I> is subject to tilde expansion,
3586parameter expansion, command substitution, and arithmetic expansion.
3587<P>
3588
ac50fbac
CR
3589When not performing substring expansion, using the forms documented below
3590(e.g., <B>:-</B>),
17345e5a
JA
3591<B>bash</B> tests for a parameter that is unset or null. Omitting the colon
3592results in a test only for a parameter that is unset.
3593<P>
3594
3595
3596<DL COMPACT>
3597<DT>${<I>parameter</I><B>:-</B><I>word</I>}<DD>
3598<B>Use Default Values</B>. If
3599<I>parameter</I>
3600
3601is unset or null, the expansion of
3602<I>word</I>
3603
3604is substituted. Otherwise, the value of
3605<I>parameter</I>
3606
3607is substituted.
3608<DT>${<I>parameter</I><B>:=</B><I>word</I>}<DD>
3609<B>Assign Default Values</B>.
3610If
3611<I>parameter</I>
3612
3613is unset or null, the expansion of
3614<I>word</I>
3615
3616is assigned to
3617<I>parameter</I>.
3618
3619The value of
3620<I>parameter</I>
3621
3622is then substituted. Positional parameters and special parameters may
3623not be assigned to in this way.
3624<DT>${<I>parameter</I><B>:?</B><I>word</I>}<DD>
3625<B>Display Error if Null or Unset</B>.
3626If
3627<I>parameter</I>
3628
3629is null or unset, the expansion of <I>word</I> (or a message to that effect
3630if
3631<I>word</I>
3632
3633is not present) is written to the standard error and the shell, if it
3634is not interactive, exits. Otherwise, the value of <I>parameter</I> is
3635substituted.
3636<DT>${<I>parameter</I><B>:+</B><I>word</I>}<DD>
3637<B>Use Alternate Value</B>.
3638If
3639<I>parameter</I>
3640
3641is null or unset, nothing is substituted, otherwise the expansion of
3642<I>word</I>
3643
3644is substituted.
3645<DT>${<I>parameter</I><B>:</B><I>offset</I>}<DD>
3646
3647<DT>${<I>parameter</I><B>:</B><I>offset</I><B>:</B><I>length</I>}<DD>
3648
495aee44 3649<B>Substring Expansion</B>.
ac50fbac 3650Expands to up to <I>length</I> characters of the value of <I>parameter</I>
17345e5a 3651starting at the character specified by <I>offset</I>.
ac50fbac
CR
3652If <I>parameter</I> is <B>@</B>, an indexed array subscripted by
3653<B>@</B> or <B>*</B>, or an associative array name, the results differ as
3654described below.
3655If <I>length</I> is omitted, expands to the substring of the value of
3656<I>parameter</I> starting at the character specified by <I>offset</I>
3657and extending to the end of the value.
17345e5a
JA
3658<I>length</I> and <I>offset</I> are arithmetic expressions (see
3659<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
3660
3661</FONT>
3662below).
ac50fbac 3663<P>
17345e5a 3664If <I>offset</I> evaluates to a number less than zero, the value
ac50fbac
CR
3665is used as an offset in characters
3666from the end of the value of <I>parameter</I>.
3667If <I>length</I> evaluates to a number less than zero,
3668it is interpreted as an offset in characters
3669from the end of the value of <I>parameter</I> rather than
3670a number of characters, and the expansion is the characters between
3671<I>offset</I> and that result.
3672Note that a negative offset must be separated from the colon by at least
3673one space to avoid being confused with the <B>:-</B> expansion.
3674<P>
17345e5a
JA
3675If <I>parameter</I> is <B>@</B>, the result is <I>length</I> positional
3676parameters beginning at <I>offset</I>.
ac50fbac
CR
3677A negative <I>offset</I> is taken relative to one greater than the greatest
3678positional parameter, so an offset of -1 evaluates to the last positional
3679parameter.
3680It is an expansion error if <I>length</I> evaluates to a number less than
3681zero.
3682<P>
17345e5a
JA
3683If <I>parameter</I> is an indexed array name subscripted by @ or *,
3684the result is the <I>length</I>
3685members of the array beginning with ${<I>parameter</I>[<I>offset</I>]}.
3686A negative <I>offset</I> is taken relative to one greater than the maximum
3687index of the specified array.
ac50fbac
CR
3688It is an expansion error if <I>length</I> evaluates to a number less than
3689zero.
3690<P>
17345e5a
JA
3691Substring expansion applied to an associative array produces undefined
3692results.
ac50fbac 3693<P>
17345e5a
JA
3694Substring indexing is zero-based unless the positional parameters
3695are used, in which case the indexing starts at 1 by default.
3696If <I>offset</I> is 0, and the positional parameters are used, <B>$0</B> is
3697prefixed to the list.
3698<DT>${<B>!</B><I>prefix</I><B>*</B>}<DD>
3699
3700<DT>${<B>!</B><I>prefix</I><B>@</B>}<DD>
3701
495aee44 3702<B>Names matching prefix</B>.
17345e5a
JA
3703Expands to the names of variables whose names begin with <I>prefix</I>,
3704separated by the first character of the
3705<FONT SIZE=-1><B>IFS</B>
3706
3707</FONT>
3708special variable.
3709When <I>@</I> is used and the expansion appears within double quotes, each
3710variable name expands to a separate word.
3711<DT>${<B>!</B><I>name</I>[<I>@</I>]}<DD>
3712
3713<DT>${<B>!</B><I>name</I>[<I>*</I>]}<DD>
3714
495aee44 3715<B>List of array keys</B>.
17345e5a
JA
3716If <I>name</I> is an array variable, expands to the list of array indices
3717(keys) assigned in <I>name</I>.
3718If <I>name</I> is not an array, expands to 0 if <I>name</I> is set and null
3719otherwise.
3720When <I>@</I> is used and the expansion appears within double quotes, each
3721key expands to a separate word.
3722<DT>${<B>#</B><I>parameter</I>}<DD>
495aee44 3723<B>Parameter length</B>.
17345e5a
JA
3724The length in characters of the value of <I>parameter</I> is substituted.
3725If
3726<I>parameter</I>
3727
3728is
3729<B>*</B>
3730
3731or
3732<B>@</B>,
3733
3734the value substituted is the number of positional parameters.
3735If
3736<I>parameter</I>
3737
3738is an array name subscripted by
3739<B>*</B>
3740
3741or
3742<B>@</B>,
3743
3744the value substituted is the number of elements in the array.
ac50fbac
CR
3745If
3746<I>parameter</I>
3747
3748is an indexed array name subscripted by a negative number, that number is
3749interpreted as relative to one greater than the maximum index of
3750<I>parameter</I>, so negative indices count back from the end of the
3751array, and an index of -1 references the last element.
17345e5a
JA
3752<DT>${<I>parameter</I><B>#</B><I>word</I>}<DD>
3753
3754<DT>${<I>parameter</I><B>##</B><I>word</I>}<DD>
3755
495aee44 3756<B>Remove matching prefix pattern</B>.
17345e5a
JA
3757The
3758<I>word</I>
3759
3760is expanded to produce a pattern just as in pathname
3761expansion. If the pattern matches the beginning of
3762the value of
3763<I>parameter</I>,
3764
3765then the result of the expansion is the expanded value of
3766<I>parameter</I>
3767
3768with the shortest matching pattern (the ``<B>#</B>'' case) or the
3769longest matching pattern (the ``<B>##</B>'' case) deleted.
3770If
3771<I>parameter</I>
3772
3773is
3774<B>@</B>
3775
3776or
3777<B>*</B>,
3778
3779the pattern removal operation is applied to each positional
3780parameter in turn, and the expansion is the resultant list.
3781If
3782<I>parameter</I>
3783
3784is an array variable subscripted with
3785<B>@</B>
3786
3787or
3788<B>*</B>,
3789
3790the pattern removal operation is applied to each member of the
3791array in turn, and the expansion is the resultant list.
3792<DT>${<I>parameter</I><B>%</B><I>word</I>}<DD>
3793
3794<DT>${<I>parameter</I><B>%%</B><I>word</I>}<DD>
3795
495aee44 3796<B>Remove matching suffix pattern</B>.
17345e5a
JA
3797The <I>word</I> is expanded to produce a pattern just as in
3798pathname expansion.
3799If the pattern matches a trailing portion of the expanded value of
3800<I>parameter</I>,
3801
3802then the result of the expansion is the expanded value of
3803<I>parameter</I>
3804
3805with the shortest matching pattern (the ``<B>%</B>'' case) or the
3806longest matching pattern (the ``<B>%%</B>'' case) deleted.
3807If
3808<I>parameter</I>
3809
3810is
3811<B>@</B>
3812
3813or
3814<B>*</B>,
3815
3816the pattern removal operation is applied to each positional
3817parameter in turn, and the expansion is the resultant list.
3818If
3819<I>parameter</I>
3820
3821is an array variable subscripted with
3822<B>@</B>
3823
3824or
3825<B>*</B>,
3826
3827the pattern removal operation is applied to each member of the
3828array in turn, and the expansion is the resultant list.
3829<DT>${<I>parameter</I><B>/</B><I>pattern</I><B>/</B><I>string</I>}<DD>
495aee44 3830<B>Pattern substitution</B>.
17345e5a
JA
3831The <I>pattern</I> is expanded to produce a pattern just as in
3832pathname expansion.
3833<I>Parameter</I> is expanded and the longest match of <I>pattern</I>
3834against its value is replaced with <I>string</I>.
3835If <I>pattern</I> begins with <B>/</B>, all matches of <I>pattern</I> are
3836replaced with <I>string</I>. Normally only the first match is replaced.
3837If <I>pattern</I> begins with <B>#</B>, it must match at the beginning
3838of the expanded value of <I>parameter</I>.
3839If <I>pattern</I> begins with <B>%</B>, it must match at the end
3840of the expanded value of <I>parameter</I>.
3841If <I>string</I> is null, matches of <I>pattern</I> are deleted
3842and the <B>/</B> following <I>pattern</I> may be omitted.
3843If
3844<I>parameter</I>
3845
3846is
3847<B>@</B>
3848
3849or
3850<B>*</B>,
3851
3852the substitution operation is applied to each positional
3853parameter in turn, and the expansion is the resultant list.
3854If
3855<I>parameter</I>
3856
3857is an array variable subscripted with
3858<B>@</B>
3859
3860or
3861<B>*</B>,
3862
3863the substitution operation is applied to each member of the
3864array in turn, and the expansion is the resultant list.
3865<DT>${<I>parameter</I><B>^</B><I>pattern</I>}<DD>
3866
3867<DT>${<I>parameter</I><B>^^</B><I>pattern</I>}<DD>
3868<DT>${<I>parameter</I><B>,</B><I>pattern</I>}<DD>
3869<DT>${<I>parameter</I><B>,,</B><I>pattern</I>}<DD>
3870
495aee44 3871<B>Case modification</B>.
17345e5a
JA
3872This expansion modifies the case of alphabetic characters in <I>parameter</I>.
3873The <I>pattern</I> is expanded to produce a pattern just as in
3874pathname expansion.
ac50fbac
CR
3875Each character in the expanded value of <I>parameter</I> is tested against
3876<I>pattern</I>, and, if it matches the pattern, its case is converted.
3877The pattern should not attempt to match more than one character.
17345e5a
JA
3878The <B>^</B> operator converts lowercase letters matching <I>pattern</I>
3879to uppercase; the <B>,</B> operator converts matching uppercase letters
3880to lowercase.
3881The <B>^^</B> and <B>,,</B> expansions convert each matched character in the
3882expanded value; the <B>^</B> and <B>,</B> expansions match and convert only
495aee44 3883the first character in the expanded value.
17345e5a
JA
3884If <I>pattern</I> is omitted, it is treated like a <B>?</B>, which matches
3885every character.
3886If
3887<I>parameter</I>
3888
3889is
3890<B>@</B>
3891
3892or
3893<B>*</B>,
3894
3895the case modification operation is applied to each positional
3896parameter in turn, and the expansion is the resultant list.
3897If
3898<I>parameter</I>
3899
3900is an array variable subscripted with
3901<B>@</B>
3902
3903or
3904<B>*</B>,
3905
3906the case modification operation is applied to each member of the
3907array in turn, and the expansion is the resultant list.
3908</DL>
3909<A NAME="lbBC">&nbsp;</A>
3910<H4>Command Substitution</H4>
3911
3912<P>
3913
3914<I>Command substitution</I> allows the output of a command to replace
3915the command name. There are two forms:
17345e5a
JA
3916<DL COMPACT><DT><DD>
3917<P>
3918
3919<B>$(</B><I>command</I><B>)</B>
3920</DL>
3921
3922or
3923<DL COMPACT><DT><DD>
3924<B>`</B><I>command</I><B>`</B>
3925</DL>
3926
3927<P>
3928
3929<B>Bash</B>
3930
3931performs the expansion by executing <I>command</I> and
3932replacing the command substitution with the standard output of the
3933command, with any trailing newlines deleted.
3934Embedded newlines are not deleted, but they may be removed during
3935word splitting.
3936The command substitution <B>$(cat </B><I>file</I>) can be replaced by
3937the equivalent but faster <B>$(&lt; </B><I>file</I>).
3938<P>
3939
3940When the old-style backquote form of substitution is used,
3941backslash retains its literal meaning except when followed by
3942<B>$</B>,
3943
3944<B>`</B>,
3945
3946or
3947<B>\</B>.
3948
3949The first backquote not preceded by a backslash terminates the
3950command substitution.
3951When using the $(<I>command</I>) form, all characters between the
3952parentheses make up the command; none are treated specially.
3953<P>
3954
3955Command substitutions may be nested. To nest when using the backquoted form,
3956escape the inner backquotes with backslashes.
3957<P>
3958
3959If the substitution appears within double quotes, word splitting and
3960pathname expansion are not performed on the results.
3961<A NAME="lbBD">&nbsp;</A>
3962<H4>Arithmetic Expansion</H4>
3963
3964<P>
3965
3966Arithmetic expansion allows the evaluation of an arithmetic expression
3967and the substitution of the result. The format for arithmetic expansion is:
3968<DL COMPACT><DT><DD>
3969<P>
3970
3971<B>$((</B><I>expression</I><B>))</B>
3972</DL>
3973
3974<P>
3975
3976The
3977<I>expression</I>
3978
3979is treated as if it were within double quotes, but a double quote
3980inside the parentheses is not treated specially.
ac50fbac
CR
3981All tokens in the expression undergo parameter and variable expansion,
3982command substitution, and quote removal.
3983The result is treated as the arithmetic expression to be evaluated.
17345e5a
JA
3984Arithmetic expansions may be nested.
3985<P>
3986
3987The evaluation is performed according to the rules listed below under
3988<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>.
3989
3990</FONT>
3991If
3992<I>expression</I>
3993
3994is invalid,
3995<B>bash</B>
3996
3997prints a message indicating failure and no substitution occurs.
3998<A NAME="lbBE">&nbsp;</A>
3999<H4>Process Substitution</H4>
4000
4001<P>
4002
4003<I>Process substitution</I> is supported on systems that support named
4004pipes (<I>FIFOs</I>) or the <B>/dev/fd</B> method of naming open files.
4005It takes the form of
4006<B>&lt;(</B><I>list</I><B>)</B>
4007or
4008<B>&gt;(</B><I>list</I><B>)</B>.
4009The process <I>list</I> is run with its input or output connected to a
4010<I>FIFO</I> or some file in <B>/dev/fd</B>. The name of this file is
4011passed as an argument to the current command as the result of the
4012expansion. If the <B>&gt;(</B><I>list</I><B>)</B> form is used, writing to
4013the file will provide input for <I>list</I>. If the
4014<B>&lt;(</B><I>list</I><B>)</B> form is used, the file passed as an
4015argument should be read to obtain the output of <I>list</I>.
4016<P>
4017
4018When available, process substitution is performed
4019simultaneously with parameter and variable expansion,
4020command substitution,
4021and arithmetic expansion.
4022<A NAME="lbBF">&nbsp;</A>
4023<H4>Word Splitting</H4>
4024
4025<P>
4026
4027The shell scans the results of
4028parameter expansion,
4029command substitution,
4030and
4031arithmetic expansion
4032that did not occur within double quotes for
4033<I>word splitting</I>.
4034
4035<P>
4036
4037The shell treats each character of
4038<FONT SIZE=-1><B>IFS</B>
4039
4040</FONT>
4041as a delimiter, and splits the results of the other
ac50fbac
CR
4042expansions into words using these characters as field terminators.
4043If
17345e5a
JA
4044<FONT SIZE=-1><B>IFS</B>
4045
4046</FONT>
4047is unset, or its
4048value is exactly
4049<B>&lt;space&gt;&lt;tab&gt;&lt;newline&gt;</B>,
4050
4051the default, then
4052sequences of
4053<B>&lt;space&gt;</B>,
4054
4055<B>&lt;tab&gt;</B>,
4056
4057and
4058<B>&lt;newline&gt;</B>
4059
4060at the beginning and end of the results of the previous
4061expansions are ignored, and
4062any sequence of
4063<FONT SIZE=-1><B>IFS</B>
4064
4065</FONT>
4066characters not at the beginning or end serves to delimit words.
4067If
4068<FONT SIZE=-1><B>IFS</B>
4069
4070</FONT>
4071has a value other than the default, then sequences of
4072the whitespace characters
4073<B>space</B>
4074
4075and
4076<B>tab</B>
4077
4078are ignored at the beginning and end of the
4079word, as long as the whitespace character is in the
4080value of
4081<FONT SIZE=-1><B>IFS</B>
4082
4083</FONT>
4084(an
4085<FONT SIZE=-1><B>IFS</B>
4086
4087</FONT>
4088whitespace character).
4089Any character in
4090<FONT SIZE=-1><B>IFS</B>
4091
4092</FONT>
4093that is not
4094<FONT SIZE=-1><B>IFS</B>
4095
4096</FONT>
4097whitespace, along with any adjacent
4098<FONT SIZE=-1><B>IFS</B>
4099
4100</FONT>
4101whitespace characters, delimits a field.
4102A sequence of
4103<FONT SIZE=-1><B>IFS</B>
4104
4105</FONT>
4106whitespace characters is also treated as a delimiter.
4107If the value of
4108<FONT SIZE=-1><B>IFS</B>
4109
4110</FONT>
4111is null, no word splitting occurs.
4112<P>
4113
4114Explicit null arguments (<B>&quot;&quot;</B> or <B>aqaq</B>) are retained.
4115Unquoted implicit null arguments, resulting from the expansion of
4116parameters that have no values, are removed.
4117If a parameter with no value is expanded within double quotes, a
4118null argument results and is retained.
4119<P>
4120
4121Note that if no expansion occurs, no splitting
4122is performed.
4123<A NAME="lbBG">&nbsp;</A>
4124<H4>Pathname Expansion</H4>
4125
4126<P>
4127
4128After word splitting,
4129unless the
4130<B>-f</B>
4131
4132option has been set,
4133<B>bash</B>
4134
4135scans each word for the characters
4136<B>*</B>,
4137
4138<B>?</B>,
4139
4140and
4141<B>[</B>.
4142
4143If one of these characters appears, then the word is
4144regarded as a
4145<I>pattern</I>,
4146
4147and replaced with an alphabetically sorted list of
ac50fbac
CR
4148filenames matching the pattern
4149(see
4150<FONT SIZE=-1><B>Pattern Matching</B>
4151
4152</FONT>
4153below).
4154If no matching filenames are found,
17345e5a
JA
4155and the shell option
4156<B>nullglob</B>
4157
4158is not enabled, the word is left unchanged.
4159If the
4160<B>nullglob</B>
4161
4162option is set, and no matches are found,
4163the word is removed.
4164If the
4165<B>failglob</B>
4166
4167shell option is set, and no matches are found, an error message
4168is printed and the command is not executed.
4169If the shell option
4170<B>nocaseglob</B>
4171
4172is enabled, the match is performed without regard to the case
4173of alphabetic characters.
4174When a pattern is used for pathname expansion,
4175the character
4176<B>``.''</B>
4177
4178at the start of a name or immediately following a slash
4179must be matched explicitly, unless the shell option
4180<B>dotglob</B>
4181
4182is set.
4183When matching a pathname, the slash character must always be
4184matched explicitly.
4185In other cases, the
4186<B>``.''</B>
4187
4188character is not treated specially.
4189See the description of
4190<B>shopt</B>
4191
4192below under
4193<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
4194
4195</FONT>
4196for a description of the
4197<B>nocaseglob</B>,
4198
4199<B>nullglob</B>,
4200
4201<B>failglob</B>,
4202
4203and
4204<B>dotglob</B>
4205
4206shell options.
4207<P>
4208
4209The
4210<FONT SIZE=-1><B>GLOBIGNORE</B>
4211
4212</FONT>
ac50fbac 4213shell variable may be used to restrict the set of filenames matching a
17345e5a
JA
4214<I>pattern</I>.
4215
4216If
4217<FONT SIZE=-1><B>GLOBIGNORE</B>
4218
4219</FONT>
ac50fbac 4220is set, each matching filename that also matches one of the patterns in
17345e5a
JA
4221<FONT SIZE=-1><B>GLOBIGNORE</B>
4222
4223</FONT>
4224is removed from the list of matches.
ac50fbac 4225The filenames
17345e5a
JA
4226<B>``.''</B>
4227
4228and
4229<B>``..''</B>
4230
4231are always ignored when
4232<FONT SIZE=-1><B>GLOBIGNORE</B>
4233
4234</FONT>
4235is set and not null. However, setting
4236<FONT SIZE=-1><B>GLOBIGNORE</B>
4237
4238</FONT>
4239to a non-null value has the effect of enabling the
4240<B>dotglob</B>
4241
ac50fbac 4242shell option, so all other filenames beginning with a
17345e5a
JA
4243<B>``.''</B>
4244
4245will match.
ac50fbac 4246To get the old behavior of ignoring filenames beginning with a
17345e5a
JA
4247<B>``.''</B>,
4248
4249make
4250<B>``.*''</B>
4251
4252one of the patterns in
4253<FONT SIZE=-1><B>GLOBIGNORE</B>.
4254
4255</FONT>
4256The
4257<B>dotglob</B>
4258
4259option is disabled when
4260<FONT SIZE=-1><B>GLOBIGNORE</B>
4261
4262</FONT>
4263is unset.
4264<P>
4265
4266<B>Pattern Matching</B>
4267<P>
4268
4269Any character that appears in a pattern, other than the special pattern
4270characters described below, matches itself. The NUL character may not
4271occur in a pattern. A backslash escapes the following character; the
4272escaping backslash is discarded when matching.
4273The special pattern characters must be quoted if
4274they are to be matched literally.
4275<P>
4276
4277The special pattern characters have the following meanings:
4278<P>
4279
4280
495aee44 4281<DL COMPACT><DT><DD>
17345e5a
JA
4282<DL COMPACT>
4283<DT><B>*</B>
4284
4285<DD>
4286Matches any string, including the null string.
4287When the <B>globstar</B> shell option is enabled, and <B>*</B> is used in
0001803f 4288a pathname expansion context, two adjacent <B>*</B>s used as a single
17345e5a
JA
4289pattern will match all files and zero or more directories and
4290subdirectories.
4291If followed by a <B>/</B>, two adjacent <B>*</B>s will match only directories
4292and subdirectories.
4293<DT><B>?</B>
4294
4295<DD>
4296Matches any single character.
4297<DT><B>[...]</B>
4298
4299<DD>
4300Matches any one of the enclosed characters. A pair of characters
4301separated by a hyphen denotes a
4302<I>range expression</I>;
ac50fbac 4303any character that falls between those two characters, inclusive,
17345e5a
JA
4304using the current locale's collating sequence and character set,
4305is matched. If the first character following the
4306<B>[</B>
4307
4308is a
4309<B>!</B>
4310
4311or a
4312<B>^</B>
4313
4314then any character not enclosed is matched.
4315The sorting order of characters in range expressions is determined by
ac50fbac 4316the current locale and the values of the
0001803f
CR
4317<FONT SIZE=-1><B>LC_COLLATE</B>
4318
4319</FONT>
ac50fbac
CR
4320or
4321<FONT SIZE=-1><B>LC_ALL</B>
4322
4323</FONT>
4324shell variables, if set.
4325To obtain the traditional interpretation of range expressions, where
4326<B>[a-d]</B>
4327
4328is equivalent to
4329<B>[abcd]</B>,
4330
4331set value of the
4332<B>LC_ALL</B>
4333
4334shell variable to
4335<B>C</B>,
4336
4337or enable the
4338<B>globasciiranges</B>
4339
4340shell option.
17345e5a
JA
4341A
4342<B>-</B>
4343
4344may be matched by including it as the first or last character
4345in the set.
4346A
4347<B>]</B>
4348
4349may be matched by including it as the first character
4350in the set.
4351<BR>
4352
4353<P>
4354
4355
4356Within
4357<B>[</B>
4358
4359and
4360<B>]</B>,
4361
4362<I>character classes</I> can be specified using the syntax
4363<B>[:</B><I>class</I><B>:]</B>, where <I>class</I> is one of the
4364following classes defined in the POSIX standard:
4365</DL>
4366<P>
4367
4368<DL COMPACT><DT><DD>
4369<B>
4370</B>
4371
4372alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
4373<BR>
4374
4375A character class matches any character belonging to that class.
4376The <B>word</B> character class matches letters, digits, and the character _.
4377<BR>
4378
4379<P>
4380
4381
4382Within
4383<B>[</B>
4384
4385and
4386<B>]</B>,
4387
4388an <I>equivalence class</I> can be specified using the syntax
4389<B>[=</B><I>c</I><B>=]</B>, which matches all characters with the
4390same collation weight (as defined by the current locale) as
4391the character <I>c</I>.
4392<BR>
4393
4394<P>
4395
4396
4397Within
4398<B>[</B>
4399
4400and
4401<B>]</B>,
4402
4403the syntax <B>[.</B><I>symbol</I><B>.]</B> matches the collating symbol
4404<I>symbol</I>.
4405</DL>
4406
495aee44
CR
4407</DL>
4408
17345e5a
JA
4409
4410<P>
4411
4412If the <B>extglob</B> shell option is enabled using the <B>shopt</B>
4413builtin, several extended pattern matching operators are recognized.
4414In the following description, a <I>pattern-list</I> is a list of one
4415or more patterns separated by a <B>|</B>.
4416Composite patterns may be formed using one or more of the following
4417sub-patterns:
4418<P>
4419
4420<DL COMPACT><DT><DD>
4421<DL COMPACT>
4422<DT><B>?(</B><I>pattern-list</I><B>)</B><DD>
4423Matches zero or one occurrence of the given patterns
4424<DT><B>*(</B><I>pattern-list</I><B>)</B><DD>
4425Matches zero or more occurrences of the given patterns
4426<DT><B>+(</B><I>pattern-list</I><B>)</B><DD>
4427Matches one or more occurrences of the given patterns
4428<DT><B>@(</B><I>pattern-list</I><B>)</B><DD>
4429Matches one of the given patterns
4430<DT><B>!(</B><I>pattern-list</I><B>)</B><DD>
4431Matches anything except one of the given patterns
4432</DL></DL>
4433
4434
4435<A NAME="lbBH">&nbsp;</A>
4436<H4>Quote Removal</H4>
4437
4438<P>
4439
4440After the preceding expansions, all unquoted occurrences of the
4441characters
4442<B>\</B>,
4443
4444<B>aq</B>,
4445
4446and <B>&quot;</B> that did not result from one of the above
4447expansions are removed.
4448<A NAME="lbBI">&nbsp;</A>
4449<H3>REDIRECTION</H3>
4450
4451Before a command is executed, its input and output
4452may be
4453<I>redirected</I>
4454
4455using a special notation interpreted by the shell.
ac50fbac
CR
4456Redirection allows commands' file handles to be
4457duplicated, opened, closed,
4458made to refer to different files,
4459and can change the files the command reads from and writes to.
4460Redirection may also be used to modify file handles in the
4461current shell execution environment.
4462The following redirection
17345e5a
JA
4463operators may precede or appear anywhere within a
4464<I>simple command</I>
4465
4466or may follow a
4467<I>command</I>.
4468
4469Redirections are processed in the order they appear, from
4470left to right.
4471<P>
4472
0001803f
CR
4473Each redirection that may be preceded by a file descriptor number
4474may instead be preceded by a word of the form {<I>varname</I>}.
4475In this case, for each redirection operator except
4476&gt;&amp;- and &lt;&amp;-, the shell will allocate a file descriptor greater
ac50fbac
CR
4477than or equal to 10 and assign it to <I>varname</I>.
4478If &gt;&amp;- or &lt;&amp;- is preceded
0001803f
CR
4479by {<I>varname</I>}, the value of <I>varname</I> defines the file
4480descriptor to close.
4481<P>
4482
17345e5a
JA
4483In the following descriptions, if the file descriptor number is
4484omitted, and the first character of the redirection operator is
4485<B>&lt;</B>,
4486
4487the redirection refers to the standard input (file descriptor
44880). If the first character of the redirection operator is
4489<B>&gt;</B>,
4490
4491the redirection refers to the standard output (file descriptor
44921).
4493<P>
4494
4495The word following the redirection operator in the following
ac50fbac
CR
4496descriptions, unless otherwise noted, is subjected to
4497brace expansion, tilde expansion, parameter and variable expansion,
4498command substitution, arithmetic expansion, quote removal,
4499pathname expansion, and word splitting.
17345e5a
JA
4500If it expands to more than one word,
4501<B>bash</B>
4502
4503reports an error.
4504<P>
4505
4506Note that the order of redirections is significant. For example,
4507the command
4508<DL COMPACT><DT><DD>
4509<P>
4510
4511ls <B>&gt;</B> dirlist 2<B>&gt;&amp;</B>1
4512</DL>
4513
4514<P>
4515
4516directs both standard output and standard error to the file
4517<I>dirlist</I>,
4518
4519while the command
4520<DL COMPACT><DT><DD>
4521<P>
4522
4523ls 2<B>&gt;&amp;</B>1 <B>&gt;</B> dirlist
4524</DL>
4525
4526<P>
4527
4528directs only the standard output to file
4529<I>dirlist</I>,
4530
0001803f 4531because the standard error was duplicated from the standard output
17345e5a
JA
4532before the standard output was redirected to
4533<I>dirlist</I>.
4534
4535<P>
4536
4537<B>Bash</B> handles several filenames specially when they are used in
4538redirections, as described in the following table:
4539<DL COMPACT><DT><DD>
4540<P>
4541
4542
4543<DL COMPACT>
4544<DT><B>/dev/fd/</B><I>fd</I>
4545
4546<DD>
4547If <I>fd</I> is a valid integer, file descriptor <I>fd</I> is duplicated.
4548<DT><B>/dev/stdin</B>
4549
4550<DD>
4551File descriptor 0 is duplicated.
4552<DT><B>/dev/stdout</B>
4553
4554<DD>
4555File descriptor 1 is duplicated.
4556<DT><B>/dev/stderr</B>
4557
4558<DD>
4559File descriptor 2 is duplicated.
4560<DT><B>/dev/tcp/</B><I>host</I>/<I>port</I>
4561
4562<DD>
4563If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
4564is an integer port number or service name, <B>bash</B> attempts to open
ac50fbac 4565the corresponding TCP socket.
17345e5a
JA
4566<DT><B>/dev/udp/</B><I>host</I>/<I>port</I>
4567
4568<DD>
4569If <I>host</I> is a valid hostname or Internet address, and <I>port</I>
4570is an integer port number or service name, <B>bash</B> attempts to open
ac50fbac 4571the corresponding UDP socket.
17345e5a
JA
4572
4573</DL></DL>
4574
4575<P>
4576
4577A failure to open or create a file causes the redirection to fail.
4578<P>
4579
4580Redirections using file descriptors greater than 9 should be used with
4581care, as they may conflict with file descriptors the shell uses
4582internally.
4583<A NAME="lbBJ">&nbsp;</A>
4584<H4>Redirecting Input</H4>
4585
4586<P>
4587
4588Redirection of input causes the file whose name results from
4589the expansion of
4590<I>word</I>
4591
4592to be opened for reading on file descriptor
4593<I>n</I>,
4594
4595or the standard input (file descriptor 0) if
4596<I>n</I>
4597
4598is not specified.
4599<P>
4600
4601The general format for redirecting input is:
4602<DL COMPACT><DT><DD>
4603<P>
4604
4605[<I>n</I>]<B>&lt;</B><I>word</I>
4606</DL>
4607
4608<A NAME="lbBK">&nbsp;</A>
4609<H4>Redirecting Output</H4>
4610
4611<P>
4612
4613Redirection of output causes the file whose name results from
4614the expansion of
4615<I>word</I>
4616
4617to be opened for writing on file descriptor
4618<I>n</I>,
4619
4620or the standard output (file descriptor 1) if
4621<I>n</I>
4622
4623is not specified. If the file does not exist it is created;
4624if it does exist it is truncated to zero size.
4625<P>
4626
4627The general format for redirecting output is:
4628<DL COMPACT><DT><DD>
4629<P>
4630
4631[<I>n</I>]<B>&gt;</B><I>word</I>
4632</DL>
4633
4634<P>
4635
4636If the redirection operator is
4637<B>&gt;</B>,
4638
4639and the
4640<B>noclobber</B>
4641
4642option to the
4643<B>set</B>
4644
4645builtin has been enabled, the redirection will fail if the file
4646whose name results from the expansion of <I>word</I> exists and is
4647a regular file.
4648If the redirection operator is
4649<B>&gt;|</B>,
4650
4651or the redirection operator is
4652<B>&gt;</B>
4653
4654and the
4655<B>noclobber</B>
4656
4657option to the
4658<B>set</B>
4659
4660builtin command is not enabled, the redirection is attempted even
4661if the file named by <I>word</I> exists.
4662<A NAME="lbBL">&nbsp;</A>
4663<H4>Appending Redirected Output</H4>
4664
4665<P>
4666
4667Redirection of output in this fashion
4668causes the file whose name results from
4669the expansion of
4670<I>word</I>
4671
4672to be opened for appending on file descriptor
4673<I>n</I>,
4674
4675or the standard output (file descriptor 1) if
4676<I>n</I>
4677
4678is not specified. If the file does not exist it is created.
4679<P>
4680
4681The general format for appending output is:
4682<DL COMPACT><DT><DD>
4683<P>
4684
4685[<I>n</I>]<B>&gt;&gt;</B><I>word</I>
4686</DL>
4687
4688<P>
4689
4690<A NAME="lbBM">&nbsp;</A>
4691<H4>Redirecting Standard Output and Standard Error</H4>
4692
4693<P>
4694
4695This construct allows both the
4696standard output (file descriptor 1) and
4697the standard error output (file descriptor 2)
4698to be redirected to the file whose name is the
4699expansion of
4700<I>word</I>.
4701
4702<P>
4703
4704There are two formats for redirecting standard output and
4705standard error:
4706<DL COMPACT><DT><DD>
4707<P>
4708
4709<B>&amp;&gt;</B><I>word</I>
4710</DL>
4711
4712and
4713<DL COMPACT><DT><DD>
4714<B>&gt;&amp;</B><I>word</I>
4715</DL>
4716
4717<P>
4718
4719Of the two forms, the first is preferred.
4720This is semantically equivalent to
4721<DL COMPACT><DT><DD>
4722<P>
4723
4724<B>&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
4725</DL>
4726
4727<P>
4728
ac50fbac
CR
4729When using the second form, <I>word</I> may not expand to a number or
4730<B>-</B>. If it does, other redirection operators apply
4731(see <B>Duplicating File Descriptors</B> below) for compatibility
4732reasons.
17345e5a
JA
4733<A NAME="lbBN">&nbsp;</A>
4734<H4>Appending Standard Output and Standard Error</H4>
4735
4736<P>
4737
4738This construct allows both the
4739standard output (file descriptor 1) and
4740the standard error output (file descriptor 2)
4741to be appended to the file whose name is the
4742expansion of
4743<I>word</I>.
4744
4745<P>
4746
4747The format for appending standard output and standard error is:
4748<DL COMPACT><DT><DD>
4749<P>
4750
4751<B>&amp;&gt;&gt;</B><I>word</I>
4752</DL>
4753
4754<P>
4755
4756This is semantically equivalent to
4757<DL COMPACT><DT><DD>
4758<P>
4759
4760<B>&gt;&gt;</B><I>word</I> 2<B>&gt;&amp;</B>1
4761</DL>
4762
ac50fbac
CR
4763<P>
4764
4765(see <B>Duplicating File Descriptors</B> below).
17345e5a
JA
4766<A NAME="lbBO">&nbsp;</A>
4767<H4>Here Documents</H4>
4768
4769<P>
4770
4771This type of redirection instructs the shell to read input from the
4772current source until a line containing only
4773<I>delimiter</I>
4774
4775(with no trailing blanks)
4776is seen. All of
4777the lines read up to that point are then used as the standard
4778input for a command.
4779<P>
4780
4781The format of here-documents is:
4782<DL COMPACT><DT><DD>
4783<P>
4784
4785<PRE>
4786<B>&lt;&lt;</B>[<B>-</B>]<I>word</I>
4787 <I>here-document</I>
4788<I>delimiter</I>
4789</PRE>
4790
4791</DL>
4792
4793<P>
4794
ac50fbac
CR
4795No parameter and variable expansion, command substitution,
4796arithmetic expansion, or pathname expansion is performed on
17345e5a
JA
4797<I>word</I>.
4798
4799If any characters in
4800<I>word</I>
4801
4802are quoted, the
4803<I>delimiter</I>
4804
4805is the result of quote removal on
4806<I>word</I>,
4807
4808and the lines in the here-document are not expanded.
4809If <I>word</I> is unquoted,
ac50fbac
CR
4810all lines of the here-document are subjected to
4811parameter expansion, command substitution, and arithmetic expansion,
4812the character sequence
17345e5a
JA
4813<B>\&lt;newline&gt;</B>
4814
4815is ignored, and
4816<B>\</B>
4817
4818must be used to quote the characters
4819<B>\</B>,
4820
4821<B>$</B>,
4822
4823and
4824<B>`</B>.
4825
4826<P>
4827
4828If the redirection operator is
4829<B>&lt;&lt;-</B>,
4830
4831then all leading tab characters are stripped from input lines and the
4832line containing
4833<I>delimiter</I>.
4834
4835This allows
4836here-documents within shell scripts to be indented in a
4837natural fashion.
4838<A NAME="lbBP">&nbsp;</A>
4839<H4>Here Strings</H4>
4840
4841A variant of here documents, the format is:
4842<DL COMPACT><DT><DD>
4843<P>
4844
4845<PRE>
4846<B>&lt;&lt;&lt;</B><I>word</I>
4847</PRE>
4848
4849</DL>
4850
4851<P>
4852
ac50fbac
CR
4853The <I>word</I> undergoes
4854brace expansion, tilde expansion, parameter and variable expansion,
4855command substitution, arithmetic expansion, and quote removal.
4856Pathname expansion and word splitting are not performed.
4857The result is supplied as a single string to the command on its
4858standard input.
17345e5a
JA
4859<A NAME="lbBQ">&nbsp;</A>
4860<H4>Duplicating File Descriptors</H4>
4861
4862<P>
4863
4864The redirection operator
4865<DL COMPACT><DT><DD>
4866<P>
4867
4868[<I>n</I>]<B>&lt;&amp;</B><I>word</I>
4869</DL>
4870
4871<P>
4872
4873is used to duplicate input file descriptors.
4874If
4875<I>word</I>
4876
4877expands to one or more digits, the file descriptor denoted by
4878<I>n</I>
4879
4880is made to be a copy of that file descriptor.
4881If the digits in
4882<I>word</I>
4883
4884do not specify a file descriptor open for input, a redirection error occurs.
4885If
4886<I>word</I>
4887
4888evaluates to
4889<B>-</B>,
4890
4891file descriptor
4892<I>n</I>
4893
4894is closed. If
4895<I>n</I>
4896
4897is not specified, the standard input (file descriptor 0) is used.
4898<P>
4899
4900The operator
4901<DL COMPACT><DT><DD>
4902<P>
4903
4904[<I>n</I>]<B>&gt;&amp;</B><I>word</I>
4905</DL>
4906
4907<P>
4908
4909is used similarly to duplicate output file descriptors. If
4910<I>n</I>
4911
4912is not specified, the standard output (file descriptor 1) is used.
4913If the digits in
4914<I>word</I>
4915
4916do not specify a file descriptor open for output, a redirection error occurs.
ac50fbac
CR
4917If
4918<I>word</I>
4919
4920evaluates to
4921<B>-</B>,
4922
4923file descriptor
4924<I>n</I>
4925
4926is closed.
17345e5a 4927As a special case, if <I>n</I> is omitted, and <I>word</I> does not
ac50fbac 4928expand to one or more digits or <B>-</B>, the standard output and standard
17345e5a
JA
4929error are redirected as described previously.
4930<A NAME="lbBR">&nbsp;</A>
4931<H4>Moving File Descriptors</H4>
4932
4933<P>
4934
4935The redirection operator
4936<DL COMPACT><DT><DD>
4937<P>
4938
4939[<I>n</I>]<B>&lt;&amp;</B><I>digit</I><B>-</B>
4940</DL>
4941
4942<P>
4943
4944moves the file descriptor <I>digit</I> to file descriptor
4945<I>n</I>,
4946
4947or the standard input (file descriptor 0) if <I>n</I> is not specified.
4948<I>digit</I> is closed after being duplicated to <I>n</I>.
4949<P>
4950
4951Similarly, the redirection operator
4952<DL COMPACT><DT><DD>
4953<P>
4954
4955[<I>n</I>]<B>&gt;&amp;</B><I>digit</I><B>-</B>
4956</DL>
4957
4958<P>
4959
4960moves the file descriptor <I>digit</I> to file descriptor
4961<I>n</I>,
4962
4963or the standard output (file descriptor 1) if <I>n</I> is not specified.
4964<A NAME="lbBS">&nbsp;</A>
4965<H4>Opening File Descriptors for Reading and Writing</H4>
4966
4967<P>
4968
4969The redirection operator
4970<DL COMPACT><DT><DD>
4971<P>
4972
4973[<I>n</I>]<B>&lt;&gt;</B><I>word</I>
4974</DL>
4975
4976<P>
4977
4978causes the file whose name is the expansion of
4979<I>word</I>
4980
4981to be opened for both reading and writing on file descriptor
4982<I>n</I>,
4983
4984or on file descriptor 0 if
4985<I>n</I>
4986
4987is not specified. If the file does not exist, it is created.
4988<A NAME="lbBT">&nbsp;</A>
4989<H3>ALIASES</H3>
4990
4991<I>Aliases</I> allow a string to be substituted for a word when it is used
4992as the first word of a simple command.
4993The shell maintains a list of aliases that may be set and unset with the
4994<B>alias</B>
4995
4996and
4997<B>unalias</B>
4998
4999builtin commands (see
5000<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5001
5002</FONT>
5003below).
5004The first word of each simple command, if unquoted,
5005is checked to see if it has an
5006alias. If so, that word is replaced by the text of the alias.
5007The characters <B>/</B>, <B>$</B>, <B>`</B>, and <B>=</B> and
5008any of the shell <I>metacharacters</I> or quoting characters
5009listed above may not appear in an alias name.
5010The replacement text may contain any valid shell input,
5011including shell metacharacters.
5012The first word of the replacement text is tested
5013for aliases, but a word that is identical to an alias being expanded
5014is not expanded a second time.
5015This means that one may alias
5016<B>ls</B>
5017
5018to
5019<B>ls -F</B>,
5020
5021for instance, and
5022<B>bash</B>
5023
5024does not try to recursively expand the replacement text.
5025If the last character of the alias value is a
5026<I>blank</I>,
5027
5028then the next command
5029word following the alias is also checked for alias expansion.
5030<P>
5031
5032Aliases are created and listed with the
5033<B>alias</B>
5034
5035command, and removed with the
5036<B>unalias</B>
5037
5038command.
5039<P>
5040
5041There is no mechanism for using arguments in the replacement text.
5042If arguments are needed, a shell function should be used (see
5043<FONT SIZE=-1><B>FUNCTIONS</B>
5044
5045</FONT>
5046below).
5047<P>
5048
5049Aliases are not expanded when the shell is not interactive, unless
5050the
5051<B>expand_aliases</B>
5052
5053shell option is set using
5054<B>shopt</B>
5055
5056(see the description of
5057<B>shopt</B>
5058
5059under
5060<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B></FONT>
5061below).
5062<P>
5063
5064The rules concerning the definition and use of aliases are
5065somewhat confusing.
5066<B>Bash</B>
5067
5068always reads at least one complete line
5069of input before executing any
5070of the commands on that line. Aliases are expanded when a
5071command is read, not when it is executed. Therefore, an
5072alias definition appearing on the same line as another
5073command does not take effect until the next line of input is read.
5074The commands following the alias definition
5075on that line are not affected by the new alias.
5076This behavior is also an issue when functions are executed.
5077Aliases are expanded when a function definition is read,
5078not when the function is executed, because a function definition
5079is itself a compound command. As a consequence, aliases
5080defined in a function are not available until after that
5081function is executed. To be safe, always put
5082alias definitions on a separate line, and do not use
5083<B>alias</B>
5084
5085in compound commands.
5086<P>
5087
5088For almost every purpose, aliases are superseded by
5089shell functions.
5090<A NAME="lbBU">&nbsp;</A>
5091<H3>FUNCTIONS</H3>
5092
5093A shell function, defined as described above under
5094<FONT SIZE=-1><B>SHELL GRAMMAR</B>,
5095
5096</FONT>
5097stores a series of commands for later execution.
5098When the name of a shell function is used as a simple command name,
5099the list of commands associated with that function name is executed.
5100Functions are executed in the context of the
5101current shell; no new process is created to interpret
5102them (contrast this with the execution of a shell script).
5103When a function is executed, the arguments to the
5104function become the positional parameters
5105during its execution.
5106The special parameter
5107<B>#</B>
5108
495aee44 5109is updated to reflect the change. Special parameter <B>0</B>
17345e5a
JA
5110is unchanged.
5111The first element of the
5112<FONT SIZE=-1><B>FUNCNAME</B>
5113
5114</FONT>
5115variable is set to the name of the function while the function
5116is executing.
0001803f
CR
5117<P>
5118
17345e5a
JA
5119All other aspects of the shell execution
5120environment are identical between a function and its caller
0001803f 5121with these exceptions: the
17345e5a
JA
5122<FONT SIZE=-1><B>DEBUG</B>
5123
5124</FONT>
5125and
5126<B>RETURN</B>
5127
5128traps (see the description of the
5129<B>trap</B>
5130
5131builtin under
5132<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5133
5134</FONT>
5135below) are not inherited unless the function has been given the
5136<B>trace</B> attribute (see the description of the
5137<FONT SIZE=-1><B>declare</B>
5138
5139</FONT>
5140builtin below) or the
5141<B>-o functrace</B> shell option has been enabled with
5142the <B>set</B> builtin
0001803f
CR
5143(in which case all functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps),
5144and the
5145<FONT SIZE=-1><B>ERR</B>
5146
5147</FONT>
5148trap is not inherited unless the <B>-o errtrace</B> shell option has
5149been enabled.
17345e5a
JA
5150<P>
5151
5152Variables local to the function may be declared with the
5153<B>local</B>
5154
5155builtin command. Ordinarily, variables and their values
5156are shared between the function and its caller.
5157<P>
5158
495aee44
CR
5159The <B>FUNCNEST</B> variable, if set to a numeric value greater
5160than 0, defines a maximum function nesting level. Function
5161invocations that exceed the limit cause the entire command to
5162abort.
5163<P>
5164
17345e5a
JA
5165If the builtin command
5166<B>return</B>
5167
5168is executed in a function, the function completes and
5169execution resumes with the next command after the function
5170call.
5171Any command associated with the <B>RETURN</B> trap is executed
5172before execution resumes.
5173When a function completes, the values of the
5174positional parameters and the special parameter
5175<B>#</B>
5176
5177are restored to the values they had prior to the function's
5178execution.
5179<P>
5180
5181Function names and definitions may be listed with the
5182<B>-f</B>
5183
5184option to the
5185<B>declare</B>
5186
5187or
5188<B>typeset</B>
5189
5190builtin commands. The
5191<B>-F</B>
5192
5193option to
5194<B>declare</B>
5195
5196or
5197<B>typeset</B>
5198
5199will list the function names only
5200(and optionally the source file and line number, if the <B>extdebug</B>
5201shell option is enabled).
5202Functions may be exported so that subshells
5203automatically have them defined with the
5204<B>-f</B>
5205
5206option to the
5207<B>export</B>
5208
5209builtin.
5210A function definition may be deleted using the <B>-f</B> option to
5211the
5212<B>unset</B>
5213
5214builtin.
5215Note that shell functions and variables with the same name may result
5216in multiple identically-named entries in the environment passed to the
5217shell's children.
5218Care should be taken in cases where this may cause a problem.
5219<P>
5220
495aee44
CR
5221Functions may be recursive.
5222The <B>FUNCNEST</B> variable may be used to limit the depth of the
5223function call stack and restrict the number of function invocations.
5224By default, no limit is imposed on the number of recursive calls.
17345e5a
JA
5225<A NAME="lbBV">&nbsp;</A>
5226<H3>ARITHMETIC EVALUATION</H3>
5227
5228The shell allows arithmetic expressions to be evaluated, under
5229certain circumstances (see the <B>let</B> and <B>declare</B> builtin
5230commands and <B>Arithmetic Expansion</B>).
5231Evaluation is done in fixed-width integers with no check for overflow,
5232though division by 0 is trapped and flagged as an error.
5233The operators and their precedence, associativity, and values
5234are the same as in the C language.
5235The following list of operators is grouped into levels of
5236equal-precedence operators.
5237The levels are listed in order of decreasing precedence.
5238<P>
5239
5240
5241<DL COMPACT>
5242<DT><B></B><I>id</I>++ <I>id</I>--
5243
5244<DD>
5245variable post-increment and post-decrement
5246<DT><B>++</B><I>id</I> --<I>id</I>
5247
5248<DD>
5249variable pre-increment and pre-decrement
5250<DT><B>- +</B>
5251
5252<DD>
5253unary minus and plus
5254<DT><B>! ~</B>
5255
5256<DD>
5257logical and bitwise negation
5258<DT><B>**</B>
5259
5260<DD>
5261exponentiation
5262<DT><B>* / %</B>
5263
5264<DD>
5265multiplication, division, remainder
5266<DT><B>+ -</B>
5267
5268<DD>
5269addition, subtraction
5270<DT><B>&lt;&lt; &gt;&gt;</B>
5271
5272<DD>
5273left and right bitwise shifts
5274<DT><B>&lt;= &gt;= &lt; &gt;</B>
5275
5276<DD>
5277comparison
5278<DT><B>== !=</B>
5279
5280<DD>
5281equality and inequality
5282<DT><B>&amp;</B>
5283
5284<DD>
5285bitwise AND
5286<DT><B>^</B>
5287
5288<DD>
5289bitwise exclusive OR
5290<DT><B>|</B>
5291
5292<DD>
5293bitwise OR
5294<DT><B>&amp;&amp;</B>
5295
5296<DD>
5297logical AND
5298<DT><B>||</B>
5299
5300<DD>
5301logical OR
5302<DT><B></B><I>expr</I>?<I>expr</I>:<I>expr</I>
5303
5304<DD>
5305conditional operator
5306<DT><B>= *= /= %= += -= &lt;&lt;= &gt;&gt;= &amp;= ^= |=</B>
5307
5308<DD>
5309assignment
5310<DT><B></B><I>expr1</I> , <I>expr2</I>
5311
5312<DD>
5313comma
5314
5315</DL>
5316<P>
5317
5318Shell variables are allowed as operands; parameter expansion is
5319performed before the expression is evaluated.
5320Within an expression, shell variables may also be referenced by name
5321without using the parameter expansion syntax.
5322A shell variable that is null or unset evaluates to 0 when referenced
5323by name without using the parameter expansion syntax.
5324The value of a variable is evaluated as an arithmetic expression
5325when it is referenced, or when a variable which has been given the
5326<I>integer</I> attribute using <B>declare -i</B> is assigned a value.
5327A null value evaluates to 0.
495aee44 5328A shell variable need not have its <I>integer</I> attribute
17345e5a
JA
5329turned on to be used in an expression.
5330<P>
5331
5332Constants with a leading 0 are interpreted as octal numbers.
5333A leading 0x or 0X denotes hexadecimal.
495aee44 5334Otherwise, numbers take the form [<I>base#</I>]n, where the optional <I>base</I>
17345e5a
JA
5335is a decimal number between 2 and 64 representing the arithmetic
5336base, and <I>n</I> is a number in that base.
5337If <I>base#</I> is omitted, then base 10 is used.
ac50fbac
CR
5338When specifying <I>n</I>,
5339the digits greater&lt; than 9 are represented by the lowercase letters,
17345e5a
JA
5340the uppercase letters, @, and _, in that order.
5341If <I>base</I> is less than or equal to 36, lowercase and uppercase
5342letters may be used interchangeably to represent numbers between 10
5343and 35.
5344<P>
5345
5346Operators are evaluated in order of precedence. Sub-expressions in
5347parentheses are evaluated first and may override the precedence
5348rules above.
5349<A NAME="lbBW">&nbsp;</A>
5350<H3>CONDITIONAL EXPRESSIONS</H3>
5351
5352Conditional expressions are used by the <B>[[</B> compound command and
5353the <B>test</B> and <B>[</B> builtin commands to test file attributes
5354and perform string and arithmetic comparisons.
5355Expressions are formed from the following unary or binary primaries.
5356If any <I>file</I> argument to one of the primaries is of the form
5357<I>/dev/fd/n</I>, then file descriptor <I>n</I> is checked.
5358If the <I>file</I> argument to one of the primaries is one of
5359<I>/dev/stdin</I>, <I>/dev/stdout</I>, or <I>/dev/stderr</I>, file
5360descriptor 0, 1, or 2, respectively, is checked.
5361<P>
5362
5363Unless otherwise specified, primaries that operate on files follow symbolic
5364links and operate on the target of the link, rather than the link itself.
5365<P>
5366
0001803f 5367
495aee44 5368When used with <B>[[</B>, the <B>&lt;</B> and <B>&gt;</B> operators sort
0001803f 5369lexicographically using the current locale.
495aee44 5370The <B>test</B> command sorts using ASCII ordering.
0001803f
CR
5371<P>
5372
17345e5a
JA
5373<DL COMPACT>
5374<DT><B>-a </B><I>file</I>
5375
5376<DD>
5377True if <I>file</I> exists.
5378<DT><B>-b </B><I>file</I>
5379
5380<DD>
5381True if <I>file</I> exists and is a block special file.
5382<DT><B>-c </B><I>file</I>
5383
5384<DD>
5385True if <I>file</I> exists and is a character special file.
5386<DT><B>-d </B><I>file</I>
5387
5388<DD>
5389True if <I>file</I> exists and is a directory.
5390<DT><B>-e </B><I>file</I>
5391
5392<DD>
5393True if <I>file</I> exists.
5394<DT><B>-f </B><I>file</I>
5395
5396<DD>
5397True if <I>file</I> exists and is a regular file.
5398<DT><B>-g </B><I>file</I>
5399
5400<DD>
5401True if <I>file</I> exists and is set-group-id.
5402<DT><B>-h </B><I>file</I>
5403
5404<DD>
5405True if <I>file</I> exists and is a symbolic link.
5406<DT><B>-k </B><I>file</I>
5407
5408<DD>
5409True if <I>file</I> exists and its ``sticky'' bit is set.
5410<DT><B>-p </B><I>file</I>
5411
5412<DD>
5413True if <I>file</I> exists and is a named pipe (FIFO).
5414<DT><B>-r </B><I>file</I>
5415
5416<DD>
5417True if <I>file</I> exists and is readable.
5418<DT><B>-s </B><I>file</I>
5419
5420<DD>
5421True if <I>file</I> exists and has a size greater than zero.
5422<DT><B>-t </B><I>fd</I>
5423
5424<DD>
5425True if file descriptor
5426<I>fd</I>
5427
5428is open and refers to a terminal.
5429<DT><B>-u </B><I>file</I>
5430
5431<DD>
5432True if <I>file</I> exists and its set-user-id bit is set.
5433<DT><B>-w </B><I>file</I>
5434
5435<DD>
5436True if <I>file</I> exists and is writable.
5437<DT><B>-x </B><I>file</I>
5438
5439<DD>
5440True if <I>file</I> exists and is executable.
17345e5a
JA
5441<DT><B>-G </B><I>file</I>
5442
5443<DD>
5444True if <I>file</I> exists and is owned by the effective group id.
5445<DT><B>-L </B><I>file</I>
5446
5447<DD>
5448True if <I>file</I> exists and is a symbolic link.
17345e5a
JA
5449<DT><B>-N </B><I>file</I>
5450
5451<DD>
5452True if <I>file</I> exists and has been modified since it was last read.
495aee44
CR
5453<DT><B>-O </B><I>file</I>
5454
5455<DD>
5456True if <I>file</I> exists and is owned by the effective user id.
5457<DT><B>-S </B><I>file</I>
5458
5459<DD>
5460True if <I>file</I> exists and is a socket.
5461<DT><I>file1</I> <B>-ef</B> <I>file2</I><DD>
5462True if <I>file1</I> and <I>file2</I> refer to the same device and
5463inode numbers.
17345e5a
JA
5464<DT><I>file1</I> -<B>nt</B> <I>file2</I><DD>
5465True if <I>file1</I> is newer (according to modification date) than <I>file2</I>,
5466or if <I>file1</I> exists and file2 does not.
5467<DT><I>file1</I> -<B>ot</B> <I>file2</I><DD>
5468True if <I>file1</I> is older than <I>file2</I>, or if <I>file2</I> exists
5469and <I>file1</I> does not.
17345e5a
JA
5470<DT><B>-o </B><I>optname</I>
5471
5472<DD>
495aee44 5473True if the shell option
17345e5a
JA
5474<I>optname</I>
5475
5476is enabled.
5477See the list of options under the description of the
5478<B>-o</B>
5479
5480option to the
5481<B>set</B>
5482
5483builtin below.
495aee44
CR
5484<DT><B>-v </B><I>varname</I>
5485
5486<DD>
5487True if the shell variable
5488<I>varname</I>
5489
5490is set (has been assigned a value).
ac50fbac
CR
5491<DT><B>-R </B><I>varname</I>
5492
5493<DD>
5494True if the shell variable
5495<I>varname</I>
5496
5497is set and is a name reference.
17345e5a
JA
5498<DT><B>-z </B><I>string</I>
5499
5500<DD>
5501True if the length of <I>string</I> is zero.
5502<DT><I>string</I><DD>
5503
5504<DT><B>-n </B><I>string</I>
5505
5506<DD>
5507
5508True if the length of
5509<I>string</I>
5510
5511is non-zero.
5512<DT><I>string1</I> <B>==</B> <I>string2</I><DD>
0001803f
CR
5513
5514<DT><I>string1</I> <B>=</B> <I>string2</I><DD>
5515
5516True if the strings are equal. <B>=</B> should be used
5517with the <B>test</B> command for POSIX conformance.
ac50fbac
CR
5518When used with the <B>[[</B> command, this performs pattern matching as
5519described above (<B>Compound Commands</B>).
17345e5a
JA
5520<DT><I>string1</I> <B>!=</B> <I>string2</I><DD>
5521True if the strings are not equal.
5522<DT><I>string1</I> <B>&lt;</B> <I>string2</I><DD>
0001803f 5523True if <I>string1</I> sorts before <I>string2</I> lexicographically.
17345e5a 5524<DT><I>string1</I> <B>&gt;</B> <I>string2</I><DD>
0001803f 5525True if <I>string1</I> sorts after <I>string2</I> lexicographically.
17345e5a
JA
5526<DT><I>arg1</I> <B>OP</B> <I>arg2</I>
5527
5528<DD>
5529<FONT SIZE=-1><B>OP</B>
5530
5531</FONT>
5532is one of
5533<B>-eq</B>,
5534
5535<B>-ne</B>,
5536
5537<B>-lt</B>,
5538
5539<B>-le</B>,
5540
5541<B>-gt</B>,
5542
5543or
5544<B>-ge</B>.
5545
5546These arithmetic binary operators return true if <I>arg1</I>
5547is equal to, not equal to, less than, less than or equal to,
5548greater than, or greater than or equal to <I>arg2</I>, respectively.
5549<I>Arg1</I>
5550
5551and
5552<I>arg2</I>
5553
5554may be positive or negative integers.
5555
5556</DL>
5557<A NAME="lbBX">&nbsp;</A>
5558<H3>SIMPLE COMMAND EXPANSION</H3>
5559
5560When a simple command is executed, the shell performs the following
5561expansions, assignments, and redirections, from left to right.
5562<DL COMPACT>
5563<DT>1.<DD>
5564The words that the parser has marked as variable assignments (those
5565preceding the command name) and redirections are saved for later
5566processing.
5567<DT>2.<DD>
5568The words that are not variable assignments or redirections are
5569expanded. If any words remain after expansion, the first word
5570is taken to be the name of the command and the remaining words are
5571the arguments.
5572<DT>3.<DD>
5573Redirections are performed as described above under
5574<FONT SIZE=-1><B>REDIRECTION</B>.
5575
5576</FONT>
5577<DT>4.<DD>
5578The text after the <B>=</B> in each variable assignment undergoes tilde
5579expansion, parameter expansion, command substitution, arithmetic expansion,
5580and quote removal before being assigned to the variable.
5581</DL>
5582<P>
5583
5584If no command name results, the variable assignments affect the current
5585shell environment. Otherwise, the variables are added to the environment
5586of the executed command and do not affect the current shell environment.
5587If any of the assignments attempts to assign a value to a readonly variable,
5588an error occurs, and the command exits with a non-zero status.
5589<P>
5590
5591If no command name results, redirections are performed, but do not
5592affect the current shell environment. A redirection error causes the
5593command to exit with a non-zero status.
5594<P>
5595
5596If there is a command name left after expansion, execution proceeds as
5597described below. Otherwise, the command exits. If one of the expansions
5598contained a command substitution, the exit status of the command is
5599the exit status of the last command substitution performed. If there
5600were no command substitutions, the command exits with a status of zero.
5601<A NAME="lbBY">&nbsp;</A>
5602<H3>COMMAND EXECUTION</H3>
5603
5604After a command has been split into words, if it results in a
5605simple command and an optional list of arguments, the following
5606actions are taken.
5607<P>
5608
5609If the command name contains no slashes, the shell attempts to
5610locate it. If there exists a shell function by that name, that
5611function is invoked as described above in
5612<FONT SIZE=-1><B>FUNCTIONS</B>.
5613
5614</FONT>
5615If the name does not match a function, the shell searches for
5616it in the list of shell builtins. If a match is found, that
5617builtin is invoked.
5618<P>
5619
5620If the name is neither a shell function nor a builtin,
5621and contains no slashes,
5622<B>bash</B>
5623
5624searches each element of the
5625<FONT SIZE=-1><B>PATH</B>
5626
5627</FONT>
5628for a directory containing an executable file by that name.
5629<B>Bash</B>
5630
5631uses a hash table to remember the full pathnames of executable
5632files (see
5633<B>hash</B>
5634
5635under
5636<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5637
5638</FONT>
5639below).
5640A full search of the directories in
5641<FONT SIZE=-1><B>PATH</B>
5642
5643</FONT>
5644is performed only if the command is not found in the hash table.
5645If the search is unsuccessful, the shell searches for a defined shell
5646function named <B>command_not_found_handle</B>.
5647If that function exists, it is invoked with the original command and
5648the original command's arguments as its arguments, and the function's
5649exit status becomes the exit status of the shell.
5650If that function is not defined, the shell prints an error
5651message and returns an exit status of 127.
5652<P>
5653
5654If the search is successful, or if the command name contains
5655one or more slashes, the shell executes the named program in a
5656separate execution environment.
5657Argument 0 is set to the name given, and the remaining arguments
5658to the command are set to the arguments given, if any.
5659<P>
5660
5661If this execution fails because the file is not in executable
5662format, and the file is not a directory, it is assumed to be
5663a <I>shell script</I>, a file
5664containing shell commands. A subshell is spawned to execute
5665it. This subshell reinitializes itself, so
5666that the effect is as if a new shell had been invoked
5667to handle the script, with the exception that the locations of
5668commands remembered by the parent (see
5669<B>hash</B>
5670
5671below under
5672<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>)</FONT>
5673are retained by the child.
5674<P>
5675
5676If the program is a file beginning with
5677<B>#!</B>,
5678
5679the remainder of the first line specifies an interpreter
5680for the program. The shell executes the
5681specified interpreter on operating systems that do not
5682handle this executable format themselves. The arguments to the
5683interpreter consist of a single optional argument following the
5684interpreter name on the first line of the program, followed
5685by the name of the program, followed by the command
5686arguments, if any.
5687<A NAME="lbBZ">&nbsp;</A>
5688<H3>COMMAND EXECUTION ENVIRONMENT</H3>
5689
5690The shell has an <I>execution environment</I>, which consists of the
5691following:
17345e5a
JA
5692<DL COMPACT>
5693<DT>*<DD>
5694open files inherited by the shell at invocation, as modified by
5695redirections supplied to the <B>exec</B> builtin
5696<DT>*<DD>
5697the current working directory as set by <B>cd</B>, <B>pushd</B>, or
5698<B>popd</B>, or inherited by the shell at invocation
5699<DT>*<DD>
5700the file creation mode mask as set by <B>umask</B> or inherited from
5701the shell's parent
5702<DT>*<DD>
5703current traps set by <B>trap</B>
5704<DT>*<DD>
5705shell parameters that are set by variable assignment or with <B>set</B>
5706or inherited from the shell's parent in the environment
5707<DT>*<DD>
5708shell functions defined during execution or inherited from the shell's
5709parent in the environment
5710<DT>*<DD>
5711options enabled at invocation (either by default or with command-line
5712arguments) or by <B>set</B>
5713<DT>*<DD>
5714options enabled by <B>shopt</B>
5715<DT>*<DD>
5716shell aliases defined with <B>alias</B>
5717<DT>*<DD>
5718various process IDs, including those of background jobs, the value
0001803f
CR
5719of <B>$$</B>, and the value of
5720<FONT SIZE=-1><B>PPID</B>
5721
5722</FONT>
17345e5a
JA
5723</DL>
5724<P>
5725
5726When a simple command other than a builtin or shell function
5727is to be executed, it
5728is invoked in a separate execution environment that consists of
5729the following. Unless otherwise noted, the values are inherited
5730from the shell.
0001803f 5731
17345e5a
JA
5732<DL COMPACT>
5733<DT>*<DD>
5734the shell's open files, plus any modifications and additions specified
5735by redirections to the command
5736<DT>*<DD>
5737the current working directory
5738<DT>*<DD>
5739the file creation mode mask
5740<DT>*<DD>
5741shell variables and functions marked for export, along with variables
5742exported for the command, passed in the environment
5743<DT>*<DD>
5744traps caught by the shell are reset to the values inherited from the
5745shell's parent, and traps ignored by the shell are ignored
5746</DL>
5747<P>
5748
5749A command invoked in this separate environment cannot affect the
5750shell's execution environment.
5751<P>
5752
5753Command substitution, commands grouped with parentheses,
5754and asynchronous commands are invoked in a
5755subshell environment that is a duplicate of the shell environment,
5756except that traps caught by the shell are reset to the values
5757that the shell inherited from its parent at invocation. Builtin
5758commands that are invoked as part of a pipeline are also executed in a
5759subshell environment. Changes made to the subshell environment
5760cannot affect the shell's execution environment.
5761<P>
5762
5763Subshells spawned to execute command substitutions inherit the value of
495aee44
CR
5764the <B>-e</B> option from the parent shell. When not in <I>posix</I> mode,
5765<B>bash</B> clears the <B>-e</B> option in such subshells.
17345e5a
JA
5766<P>
5767
5768If a command is followed by a <B>&amp;</B> and job control is not active, the
5769default standard input for the command is the empty file <I>/dev/null</I>.
5770Otherwise, the invoked command inherits the file descriptors of the calling
5771shell as modified by redirections.
5772<A NAME="lbCA">&nbsp;</A>
5773<H3>ENVIRONMENT</H3>
5774
5775When a program is invoked it is given an array of strings
5776called the
5777<I>environment</I>.
5778
5779This is a list of
5780<I>name</I>-<I>value</I> pairs, of the form
5781<I>name</I>=value.
5782
5783<P>
5784
5785The shell provides several ways to manipulate the environment.
5786On invocation, the shell scans its own environment and
5787creates a parameter for each name found, automatically marking
5788it for
5789<I>export</I>
5790
5791to child processes. Executed commands inherit the environment.
5792The
5793<B>export</B>
5794
5795and
5796<B>declare -x</B>
5797
5798commands allow parameters and functions to be added to and
5799deleted from the environment. If the value of a parameter
5800in the environment is modified, the new value becomes part
5801of the environment, replacing the old. The environment
5802inherited by any executed command consists of the shell's
5803initial environment, whose values may be modified in the shell,
5804less any pairs removed by the
5805<B>unset</B>
5806
5807command, plus any additions via the
5808<B>export</B>
5809
5810and
5811<B>declare -x</B>
5812
5813commands.
5814<P>
5815
5816The environment for any
5817<I>simple command</I>
5818
5819or function may be augmented temporarily by prefixing it with
5820parameter assignments, as described above in
5821<FONT SIZE=-1><B>PARAMETERS</B>.
5822
5823</FONT>
5824These assignment statements affect only the environment seen
5825by that command.
5826<P>
5827
5828If the
5829<B>-k</B>
5830
5831option is set (see the
5832<B>set</B>
5833
5834builtin command below), then
5835<I>all</I>
5836
5837parameter assignments are placed in the environment for a command,
5838not just those that precede the command name.
5839<P>
5840
5841When
5842<B>bash</B>
5843
5844invokes an external command, the variable
5845<B>_</B>
5846
ac50fbac 5847is set to the full filename of the command and passed to that
17345e5a
JA
5848command in its environment.
5849<A NAME="lbCB">&nbsp;</A>
5850<H3>EXIT STATUS</H3>
5851
5852<P>
5853
5854The exit status of an executed command is the value returned by the
5855<I>waitpid</I> system call or equivalent function. Exit statuses
5856fall between 0 and 255, though, as explained below, the shell may
5857use values above 125 specially. Exit statuses from shell builtins and
5858compound commands are also limited to this range. Under certain
5859circumstances, the shell will use special values to indicate specific
5860failure modes.
5861<P>
5862
5863For the shell's purposes, a command which exits with a
5864zero exit status has succeeded. An exit status of zero
5865indicates success. A non-zero exit status indicates failure.
5866When a command terminates on a fatal signal <I>N</I>, <B>bash</B> uses
5867the value of 128+<I>N</I> as the exit status.
5868<P>
5869
5870If a command is not found, the child process created to
5871execute it returns a status of 127. If a command is found
5872but is not executable, the return status is 126.
5873<P>
5874
5875If a command fails because of an error during expansion or redirection,
5876the exit status is greater than zero.
5877<P>
5878
5879Shell builtin commands return a status of 0 (<I>true</I>) if
5880successful, and non-zero (<I>false</I>) if an error occurs
5881while they execute.
5882All builtins return an exit status of 2 to indicate incorrect usage.
5883<P>
5884
5885<B>Bash</B> itself returns the exit status of the last command
5886executed, unless a syntax error occurs, in which case it exits
5887with a non-zero value. See also the <B>exit</B> builtin
5888command below.
5889<A NAME="lbCC">&nbsp;</A>
5890<H3>SIGNALS</H3>
5891
5892When <B>bash</B> is interactive, in the absence of any traps, it ignores
5893<FONT SIZE=-1><B>SIGTERM</B>
5894
5895</FONT>
5896(so that <B>kill 0</B> does not kill an interactive shell),
5897and
5898<FONT SIZE=-1><B>SIGINT</B>
5899
5900</FONT>
5901is caught and handled (so that the <B>wait</B> builtin is interruptible).
5902In all cases, <B>bash</B> ignores
5903<FONT SIZE=-1><B>SIGQUIT</B>.
5904
5905</FONT>
5906If job control is in effect,
5907<B>bash</B>
5908
5909ignores
5910<FONT SIZE=-1><B>SIGTTIN</B>,
5911
5912</FONT>
5913<FONT SIZE=-1><B>SIGTTOU</B>,
5914
5915</FONT>
5916and
5917<FONT SIZE=-1><B>SIGTSTP</B>.
5918
5919</FONT>
5920<P>
5921
5922Non-builtin commands run by <B>bash</B> have signal handlers
5923set to the values inherited by the shell from its parent.
5924When job control is not in effect, asynchronous commands
5925ignore
5926<FONT SIZE=-1><B>SIGINT</B>
5927
5928</FONT>
5929and
5930<FONT SIZE=-1><B>SIGQUIT</B>
5931
5932</FONT>
5933in addition to these inherited handlers.
5934Commands run as a result of command substitution ignore the
5935keyboard-generated job control signals
5936<FONT SIZE=-1><B>SIGTTIN</B>,
5937
5938</FONT>
5939<FONT SIZE=-1><B>SIGTTOU</B>,
5940
5941</FONT>
5942and
5943<FONT SIZE=-1><B>SIGTSTP</B>.
5944
5945</FONT>
5946<P>
5947
5948The shell exits by default upon receipt of a
5949<FONT SIZE=-1><B>SIGHUP</B>.
5950
5951</FONT>
5952Before exiting, an interactive shell resends the
5953<FONT SIZE=-1><B>SIGHUP</B>
5954
5955</FONT>
5956to all jobs, running or stopped.
5957Stopped jobs are sent
5958<FONT SIZE=-1><B>SIGCONT</B>
5959
5960</FONT>
5961to ensure that they receive the
5962<FONT SIZE=-1><B>SIGHUP</B>.
5963
5964</FONT>
5965To prevent the shell from
5966sending the signal to a particular job, it should be removed from the
5967jobs table with the
5968<B>disown</B>
5969
5970builtin (see
5971<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
5972
5973</FONT>
5974below) or marked
5975to not receive
5976<FONT SIZE=-1><B>SIGHUP</B>
5977
5978</FONT>
5979using
5980<B>disown -h</B>.
5981
5982<P>
5983
5984If the
5985<B>huponexit</B>
5986
5987shell option has been set with
5988<B>shopt</B>,
5989
5990<B>bash</B>
5991
5992sends a
5993<FONT SIZE=-1><B>SIGHUP</B>
5994
5995</FONT>
5996to all jobs when an interactive login shell exits.
5997<P>
5998
5999If <B>bash</B> is waiting for a command to complete and receives a signal
6000for which a trap has been set, the trap will not be executed until
6001the command completes.
6002When <B>bash</B> is waiting for an asynchronous command via the <B>wait</B>
6003builtin, the reception of a signal for which a trap has been set will
6004cause the <B>wait</B> builtin to return immediately with an exit status
6005greater than 128, immediately after which the trap is executed.
6006<A NAME="lbCD">&nbsp;</A>
6007<H3>JOB CONTROL</H3>
6008
6009<I>Job control</I>
6010
6011refers to the ability to selectively stop (<I>suspend</I>)
6012the execution of processes and continue (<I>resume</I>)
6013their execution at a later point. A user typically employs
6014this facility via an interactive interface supplied jointly
0001803f 6015by the operating system kernel's terminal driver and
17345e5a
JA
6016<B>bash</B>.
6017
6018<P>
6019
6020The shell associates a
6021<I>job</I>
6022
6023with each pipeline. It keeps a table of currently executing
6024jobs, which may be listed with the
6025<B>jobs</B>
6026
6027command. When
6028<B>bash</B>
6029
6030starts a job asynchronously (in the
6031<I>background</I>),
6032
6033it prints a line that looks like:
6034<DL COMPACT><DT><DD>
6035<P>
6036
6037[1] 25647
6038</DL>
6039
6040<P>
6041
6042indicating that this job is job number 1 and that the process ID
6043of the last process in the pipeline associated with this job is 25647.
6044All of the processes in a single pipeline are members of the same job.
6045<B>Bash</B>
6046
6047uses the
6048<I>job</I>
6049
6050abstraction as the basis for job control.
6051<P>
6052
6053To facilitate the implementation of the user interface to job
6054control, the operating system maintains the notion of a <I>current terminal
6055process group ID</I>. Members of this process group (processes whose
6056process group ID is equal to the current terminal process group ID)
6057receive keyboard-generated signals such as
6058<FONT SIZE=-1><B>SIGINT</B>.
6059
6060</FONT>
6061These processes are said to be in the
6062<I>foreground</I>.
6063
6064<I>Background</I>
6065
6066processes are those whose process group ID differs from the terminal's;
6067such processes are immune to keyboard-generated signals.
0001803f
CR
6068Only foreground processes are allowed to read from or, if the
6069user so specifies with <TT>stty tostop</TT>, write to the
6070terminal.
6071Background processes which attempt to read from (write to when
6072<TT>stty tostop</TT> is in effect) the
17345e5a
JA
6073terminal are sent a
6074<FONT SIZE=-1><B>SIGTTIN (SIGTTOU)</B>
6075
6076</FONT>
0001803f 6077signal by the kernel's terminal driver,
17345e5a
JA
6078which, unless caught, suspends the process.
6079<P>
6080
6081If the operating system on which
6082<B>bash</B>
6083
6084is running supports
6085job control,
6086<B>bash</B>
6087
6088contains facilities to use it.
6089Typing the
6090<I>suspend</I>
6091
6092character (typically
6093<B>^Z</B>,
6094
6095Control-Z) while a process is running
6096causes that process to be stopped and returns control to
6097<B>bash</B>.
6098
6099Typing the
6100<I>delayed suspend</I>
6101
6102character (typically
6103<B>^Y</B>,
6104
6105Control-Y) causes the process to be stopped when it
6106attempts to read input from the terminal, and control to
6107be returned to
6108<B>bash</B>.
6109
6110The user may then manipulate the state of this job, using the
6111<B>bg</B>
6112
6113command to continue it in the background, the
6114<B>fg</B>
6115
6116command to continue it in the foreground, or
6117the
6118<B>kill</B>
6119
6120command to kill it. A <B>^Z</B> takes effect immediately,
6121and has the additional side effect of causing pending output
6122and typeahead to be discarded.
6123<P>
6124
6125There are a number of ways to refer to a job in the shell.
6126The character
6127<B>%</B>
6128
6129introduces a job specification (<I>jobspec</I>). Job number
6130<I>n</I>
6131
6132may be referred to as
6133<B>%n</B>.
6134
6135A job may also be referred to using a prefix of the name used to
6136start it, or using a substring that appears in its command line.
6137For example,
6138<B>%ce</B>
6139
6140refers to a stopped
6141<B>ce</B>
6142
6143job. If a prefix matches more than one job,
6144<B>bash</B>
6145
6146reports an error. Using
6147<B>%?ce</B>,
6148
6149on the other hand, refers to any job containing the string
6150<B>ce</B>
6151
6152in its command line. If the substring matches more than one job,
6153<B>bash</B>
6154
6155reports an error. The symbols
6156<B>%%</B>
6157
6158and
6159<B>%+</B>
6160
6161refer to the shell's notion of the
6162<I>current job</I>,
6163
6164which is the last job stopped while it was in
6165the foreground or started in the background.
6166The
6167<I>previous job</I>
6168
6169may be referenced using
6170<B>%-</B>.
6171
6172If there is only a single job, <B>%+</B> and <B>%-</B> can both be used
6173to refer to that job.
6174In output pertaining to jobs (e.g., the output of the
6175<B>jobs</B>
6176
6177command), the current job is always flagged with a
6178<B>+</B>,
6179
6180and the previous job with a
6181<B>-</B>.
6182
6183A single % (with no accompanying job specification) also refers to the
6184current job.
6185<P>
6186
6187Simply naming a job can be used to bring it into the
6188foreground:
6189<B>%1</B>
6190
6191is a synonym for
6192<B>``fg %1''</B>,
6193bringing job 1 from the background into the foreground.
6194Similarly,
6195<B>``%1 &amp;''</B>
6196
6197resumes job 1 in the background, equivalent to
6198<B>``bg %1''</B>.
6199<P>
6200
6201The shell learns immediately whenever a job changes state.
6202Normally,
6203<B>bash</B>
6204
6205waits until it is about to print a prompt before reporting
6206changes in a job's status so as to not interrupt
6207any other output. If the
6208<B>-b</B>
6209
6210option to the
6211<B>set</B>
6212
6213builtin command
6214is enabled,
6215<B>bash</B>
6216
6217reports such changes immediately.
6218Any trap on
6219<FONT SIZE=-1><B>SIGCHLD</B>
6220
6221</FONT>
6222is executed for each child that exits.
6223<P>
6224
6225If an attempt to exit
6226<B>bash</B>
6227
6228is made while jobs are stopped (or, if the <B>checkjobs</B> shell option has
6229been enabled using the <B>shopt</B> builtin, running), the shell prints a
6230warning message, and, if the <B>checkjobs</B> option is enabled, lists the
6231jobs and their statuses.
6232The
6233<B>jobs</B>
6234
6235command may then be used to inspect their status.
6236If a second attempt to exit is made without an intervening command,
6237the shell does not print another warning, and any stopped
6238jobs are terminated.
6239<A NAME="lbCE">&nbsp;</A>
6240<H3>PROMPTING</H3>
6241
6242When executing interactively,
6243<B>bash</B>
6244
6245displays the primary prompt
6246<FONT SIZE=-1><B>PS1</B>
6247
6248</FONT>
6249when it is ready to read a command, and the secondary prompt
6250<FONT SIZE=-1><B>PS2</B>
6251
6252</FONT>
6253when it needs more input to complete a command.
6254<B>Bash</B>
6255
6256allows these prompt strings to be customized by inserting a number of
6257backslash-escaped special characters that are decoded as follows:
6258<DL COMPACT><DT><DD>
6259
6260<DL COMPACT>
6261<DT><B>\a</B>
6262
6263<DD>
6264an ASCII bell character (07)
6265<DT><B>\d</B>
6266
6267<DD>
6268the date in &quot;Weekday Month Date&quot; format (e.g., &quot;Tue May 26&quot;)
6269<DT><B>\D{</B><I>format</I>}
6270
6271<DD>
6272the <I>format</I> is passed to <I>strftime</I>(3) and the result is inserted
6273into the prompt string; an empty <I>format</I> results in a locale-specific
6274time representation. The braces are required
6275<DT><B>\e</B>
6276
6277<DD>
6278an ASCII escape character (033)
6279<DT><B>\h</B>
6280
6281<DD>
6282the hostname up to the first `.'
6283<DT><B>\H</B>
6284
6285<DD>
6286the hostname
6287<DT><B>\j</B>
6288
6289<DD>
6290the number of jobs currently managed by the shell
6291<DT><B>\l</B>
6292
6293<DD>
6294the basename of the shell's terminal device name
6295<DT><B>\n</B>
6296
6297<DD>
6298newline
6299<DT><B>\r</B>
6300
6301<DD>
6302carriage return
6303<DT><B>\s</B>
6304
6305<DD>
6306the name of the shell, the basename of
6307<B>$0</B>
6308
6309(the portion following the final slash)
6310<DT><B>\t</B>
6311
6312<DD>
6313the current time in 24-hour HH:MM:SS format
6314<DT><B>\T</B>
6315
6316<DD>
6317the current time in 12-hour HH:MM:SS format
6318<DT><B>\@</B>
6319
6320<DD>
6321the current time in 12-hour am/pm format
6322<DT><B>\A</B>
6323
6324<DD>
6325the current time in 24-hour HH:MM format
6326<DT><B>\u</B>
6327
6328<DD>
6329the username of the current user
6330<DT><B>\v</B>
6331
6332<DD>
6333the version of <B>bash</B> (e.g., 2.00)
6334<DT><B>\V</B>
6335
6336<DD>
6337the release of <B>bash</B>, version + patch level (e.g., 2.00.0)
6338<DT><B>\w</B>
6339
6340<DD>
0001803f
CR
6341the current working directory, with
6342<FONT SIZE=-1><B>$HOME</B>
6343
6344</FONT>
6345abbreviated with a tilde
6346(uses the value of the
6347<FONT SIZE=-1><B>PROMPT_DIRTRIM</B>
6348
6349</FONT>
6350variable)
17345e5a
JA
6351<DT><B>\W</B>
6352
6353<DD>
0001803f
CR
6354the basename of the current working directory, with
6355<FONT SIZE=-1><B>$HOME</B>
6356
6357</FONT>
17345e5a
JA
6358abbreviated with a tilde
6359<DT><B>\!</B>
6360
6361<DD>
6362the history number of this command
6363<DT><B>\#</B>
6364
6365<DD>
6366the command number of this command
6367<DT><B>\$</B>
6368
6369<DD>
6370if the effective UID is 0, a
6371<B>#</B>,
6372
6373otherwise a
6374<B>$</B>
6375
6376<DT><B>\</B><I>nnn</I>
6377
6378<DD>
6379the character corresponding to the octal number <I>nnn</I>
6380<DT><B>\\</B>
6381
6382<DD>
6383a backslash
6384<DT><B>\[</B>
6385
6386<DD>
6387begin a sequence of non-printing characters, which could be used to
6388embed a terminal control sequence into the prompt
6389<DT><B>\]</B>
6390
6391<DD>
6392end a sequence of non-printing characters
6393
6394</DL></DL>
6395
6396<P>
6397
6398The command number and the history number are usually different:
6399the history number of a command is its position in the history
6400list, which may include commands restored from the history file
6401(see
6402<FONT SIZE=-1><B>HISTORY</B>
6403
6404</FONT>
6405below), while the command number is the position in the sequence
6406of commands executed during the current shell session.
6407After the string is decoded, it is expanded via
6408parameter expansion, command substitution, arithmetic
6409expansion, and quote removal, subject to the value of the
6410<B>promptvars</B>
6411
6412shell option (see the description of the
6413<B>shopt</B>
6414
6415command under
6416<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6417
6418</FONT>
6419below).
6420<A NAME="lbCF">&nbsp;</A>
6421<H3>READLINE</H3>
6422
6423This is the library that handles reading input when using an interactive
6424shell, unless the
6425<B>--noediting</B>
6426
6427option is given at shell invocation.
6428Line editing is also used when using the <B>-e</B> option to the
6429<B>read</B> builtin.
495aee44 6430By default, the line editing commands are similar to those of Emacs.
17345e5a
JA
6431A vi-style line editing interface is also available.
6432Line editing can be enabled at any time using the
6433<B>-o emacs</B>
6434
6435or
6436<B>-o vi</B>
6437
6438options to the
6439<B>set</B>
6440
6441builtin (see
6442<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6443
6444</FONT>
6445below).
6446To turn off line editing after the shell is running, use the
6447<B>+o emacs</B>
6448
6449or
6450<B>+o vi</B>
6451
6452options to the
6453<B>set</B>
6454
6455builtin.
6456<A NAME="lbCG">&nbsp;</A>
6457<H4>Readline Notation</H4>
6458
6459<P>
6460
495aee44 6461In this section, the Emacs-style notation is used to denote
17345e5a
JA
6462keystrokes. Control keys are denoted by C-<I>key</I>, e.g., C-n
6463means Control-N. Similarly,
6464<I>meta</I>
6465
6466keys are denoted by M-<I>key</I>, so M-x means Meta-X. (On keyboards
6467without a
6468<I>meta</I>
6469
6470key, M-<I>x</I> means ESC <I>x</I>, i.e., press the Escape key
6471then the
6472<I>x</I>
6473
6474key. This makes ESC the <I>meta prefix</I>.
6475The combination M-C-<I>x</I> means ESC-Control-<I>x</I>,
6476or press the Escape key
6477then hold the Control key while pressing the
6478<I>x</I>
6479
6480key.)
6481<P>
6482
6483Readline commands may be given numeric
6484<I>arguments</I>,
6485
6486which normally act as a repeat count.
6487Sometimes, however, it is the sign of the argument that is significant.
6488Passing a negative argument to a command that acts in the forward
6489direction (e.g., <B>kill-line</B>) causes that command to act in a
6490backward direction.
6491Commands whose behavior with arguments deviates from this are noted
6492below.
6493<P>
6494
6495When a command is described as <I>killing</I> text, the text
6496deleted is saved for possible future retrieval
6497(<I>yanking</I>). The killed text is saved in a
6498<I>kill ring</I>. Consecutive kills cause the text to be
6499accumulated into one unit, which can be yanked all at once.
6500Commands which do not kill text separate the chunks of text
6501on the kill ring.
6502<A NAME="lbCH">&nbsp;</A>
6503<H4>Readline Initialization</H4>
6504
6505<P>
6506
6507Readline is customized by putting commands in an initialization
6508file (the <I>inputrc</I> file).
6509The name of this file is taken from the value of the
6510<FONT SIZE=-1><B>INPUTRC</B>
6511
6512</FONT>
6513variable. If that variable is unset, the default is
6514<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>.
6515
6516When a program which uses the readline library starts up, the
6517initialization file is read, and the key bindings and variables
6518are set.
6519There are only a few basic constructs allowed in the
6520readline initialization file.
6521Blank lines are ignored.
6522Lines beginning with a <B>#</B> are comments.
6523Lines beginning with a <B>$</B> indicate conditional constructs.
6524Other lines denote key bindings and variable settings.
6525<P>
6526
6527The default key-bindings may be changed with an
6528<I>inputrc </I>
6529
6530file.
6531Other programs that use this library may add their own commands
6532and bindings.
6533<P>
6534
6535For example, placing
6536<DL COMPACT><DT><DD>
6537<P>
6538
6539M-Control-u: universal-argument
6540</DL>
6541
6542or
6543<DL COMPACT><DT><DD>
6544C-Meta-u: universal-argument
6545</DL>
6546
6547into the
6548<I>inputrc</I>
6549
6550would make M-C-u execute the readline command
6551<I>universal-argument</I>.
6552
6553<P>
6554
6555The following symbolic character names are recognized:
6556<I>RUBOUT</I>,
6557
6558<I>DEL</I>,
6559
6560<I>ESC</I>,
6561
6562<I>LFD</I>,
6563
6564<I>NEWLINE</I>,
6565
6566<I>RET</I>,
6567
6568<I>RETURN</I>,
6569
6570<I>SPC</I>,
6571
6572<I>SPACE</I>,
6573
6574and
6575<I>TAB</I>.
6576
6577<P>
6578
6579In addition to command names, readline allows keys to be bound
6580to a string that is inserted when the key is pressed (a <I>macro</I>).
6581<A NAME="lbCI">&nbsp;</A>
6582<H4>Readline Key Bindings</H4>
6583
6584<P>
6585
6586The syntax for controlling key bindings in the
6587<I>inputrc</I>
6588
6589file is simple. All that is required is the name of the
6590command or the text of a macro and a key sequence to which
6591it should be bound. The name may be specified in one of two ways:
6592as a symbolic key name, possibly with <I>Meta-</I> or <I>Control-</I>
6593prefixes, or as a key sequence.
6594<P>
6595
6596When using the form <B>keyname</B>:<I>function-name</I> or <I>macro</I>,
6597<I>keyname</I>
6598
6599is the name of a key spelled out in English. For example:
6600<P>
6601<DL COMPACT><DT><DD>
6602Control-u: universal-argument
6603<BR>
6604
6605Meta-Rubout: backward-kill-word
6606<BR>
6607
6608Control-o: &quot;&gt; output&quot;
6609</DL>
6610
6611<P>
6612
6613In the above example,
6614<I>C-u</I>
6615
6616is bound to the function
6617<B>universal-argument</B>,
6618
6619<I>M-DEL</I>
6620
6621is bound to the function
6622<B>backward-kill-word</B>,
6623
6624and
6625<I>C-o</I>
6626
6627is bound to run the macro
6628expressed on the right hand side (that is, to insert the text
6629<TT>&gt; output</TT>
6630
6631into the line).
6632<P>
6633
6634In the second form, <B>&quot;keyseq&quot;</B>:<I>function-name</I> or <I>macro</I>,
6635<B>keyseq</B>
6636
6637differs from
6638<B>keyname</B>
6639
6640above in that strings denoting
6641an entire key sequence may be specified by placing the sequence
6642within double quotes. Some GNU Emacs style key escapes can be
6643used, as in the following example, but the symbolic character names
6644are not recognized.
6645<P>
6646<DL COMPACT><DT><DD>
6647&quot;\C-u&quot;: universal-argument
6648<BR>
6649
6650&quot;\C-x\C-r&quot;: re-read-init-file
6651<BR>
6652
6653&quot;\e[11~&quot;: &quot;Function Key 1&quot;
6654</DL>
6655
6656<P>
6657
6658In this example,
6659<I>C-u</I>
6660
6661is again bound to the function
6662<B>universal-argument</B>.
6663
6664<I>C-x C-r</I>
6665
6666is bound to the function
6667<B>re-read-init-file</B>,
6668
6669and
6670<I>ESC [ 1 1 ~</I>
6671
6672is bound to insert the text
6673<TT>Function Key 1</TT>.
6674
6675<P>
6676
6677The full set of GNU Emacs style escape sequences is
6678<DL COMPACT><DT><DD>
6679
6680<DL COMPACT>
6681<DT><B>\C-</B>
6682
6683<DD>
6684control prefix
6685<DT><B>\M-</B>
6686
6687<DD>
6688meta prefix
6689<DT><B>\e</B>
6690
6691<DD>
6692an escape character
6693<DT><B>\\</B>
6694
6695<DD>
6696backslash
6697<DT><B>\</B>
6698
6699<DD>
6700literal &quot;
6701<DT><B>\aq</B>
6702
6703<DD>
6704literal aq
6705</DL></DL>
6706
6707
6708<P>
6709
6710In addition to the GNU Emacs style escape sequences, a second
6711set of backslash escapes is available:
6712<DL COMPACT><DT><DD>
6713
6714<DL COMPACT>
6715<DT><B>\a</B>
6716
6717<DD>
6718alert (bell)
6719<DT><B>\b</B>
6720
6721<DD>
6722backspace
6723<DT><B>\d</B>
6724
6725<DD>
6726delete
6727<DT><B>\f</B>
6728
6729<DD>
6730form feed
6731<DT><B>\n</B>
6732
6733<DD>
6734newline
6735<DT><B>\r</B>
6736
6737<DD>
6738carriage return
6739<DT><B>\t</B>
6740
6741<DD>
6742horizontal tab
6743<DT><B>\v</B>
6744
6745<DD>
6746vertical tab
6747<DT><B>\</B><I>nnn</I>
6748
6749<DD>
6750the eight-bit character whose value is the octal value <I>nnn</I>
6751(one to three digits)
6752<DT><B>\x</B><I>HH</I>
6753
6754<DD>
6755the eight-bit character whose value is the hexadecimal value <I>HH</I>
6756(one or two hex digits)
6757</DL></DL>
6758
6759
6760<P>
6761
6762When entering the text of a macro, single or double quotes must
6763be used to indicate a macro definition.
6764Unquoted text is assumed to be a function name.
6765In the macro body, the backslash escapes described above are expanded.
6766Backslash will quote any other character in the macro text,
6767including &quot; and aq.
6768<P>
6769
6770<B>Bash</B>
6771
6772allows the current readline key bindings to be displayed or modified
6773with the
6774<B>bind</B>
6775
6776builtin command. The editing mode may be switched during interactive
6777use by using the
6778<B>-o</B>
6779
6780option to the
6781<B>set</B>
6782
6783builtin command (see
6784<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
6785
6786</FONT>
6787below).
6788<A NAME="lbCJ">&nbsp;</A>
6789<H4>Readline Variables</H4>
6790
6791<P>
6792
6793Readline has variables that can be used to further customize its
6794behavior. A variable may be set in the
6795<I>inputrc</I>
6796
6797file with a statement of the form
6798<DL COMPACT><DT><DD>
6799<P>
6800
6801<B>set</B> <I>variable-name</I> <I>value</I>
6802</DL>
6803
6804<P>
6805
6806Except where noted, readline variables can take the values
6807<B>On</B>
6808
6809or
6810<B>Off</B>
6811
6812(without regard to case).
6813Unrecognized variable names are ignored.
6814When a variable value is read, empty or null values, &quot;on&quot; (case-insensitive),
6815and &quot;1&quot; are equivalent to <B>On</B>. All other values are equivalent to
6816<B>Off</B>.
6817The variables and their default values are:
6818<P>
6819
6820
6821<DL COMPACT>
6822<DT><B>bell-style (audible)</B>
6823
6824<DD>
6825Controls what happens when readline wants to ring the terminal bell.
6826If set to <B>none</B>, readline never rings the bell. If set to
6827<B>visible</B>, readline uses a visible bell if one is available.
6828If set to <B>audible</B>, readline attempts to ring the terminal's bell.
6829<DT><B>bind-tty-special-chars (On)</B>
6830
6831<DD>
6832If set to <B>On</B>, readline attempts to bind the control characters
6833treated specially by the kernel's terminal driver to their readline
6834equivalents.
ac50fbac
CR
6835<DT><B>colored-stats (Off)</B>
6836
6837<DD>
6838If set to <B>On</B>, readline displays possible completions using different
6839colors to indicate their file type.
6840The color definitions are taken from the value of the <B>LS_COLORS</B>
6841environment variable.
17345e5a
JA
6842<DT><B>comment-begin (``#'')</B>
6843
6844<DD>
6845The string that is inserted when the readline
6846<B>insert-comment</B>
6847
6848command is executed.
6849This command is bound to
6850<B>M-#</B>
6851
6852in emacs mode and to
6853<B>#</B>
6854
6855in vi command mode.
6856<DT><B>completion-ignore-case (Off)</B>
6857
6858<DD>
6859If set to <B>On</B>, readline performs filename matching and completion
6860in a case-insensitive fashion.
6861<DT><B>completion-prefix-display-length (0)</B>
6862
6863<DD>
6864The length in characters of the common prefix of a list of possible
6865completions that is displayed without modification. When set to a
6866value greater than zero, common prefixes longer than this value are
6867replaced with an ellipsis when displaying possible completions.
6868<DT><B>completion-query-items (100)</B>
6869
6870<DD>
6871This determines when the user is queried about viewing
6872the number of possible completions
6873generated by the <B>possible-completions</B> command.
6874It may be set to any integer value greater than or equal to
6875zero. If the number of possible completions is greater than
6876or equal to the value of this variable, the user is asked whether
6877or not he wishes to view them; otherwise they are simply listed
6878on the terminal.
6879<DT><B>convert-meta (On)</B>
6880
6881<DD>
6882If set to <B>On</B>, readline will convert characters with the
6883eighth bit set to an ASCII key sequence
6884by stripping the eighth bit and prefixing an
6885escape character (in effect, using escape as the <I>meta prefix</I>).
6886<DT><B>disable-completion (Off)</B>
6887
6888<DD>
6889If set to <B>On</B>, readline will inhibit word completion. Completion
6890characters will be inserted into the line as if they had been
6891mapped to <B>self-insert</B>.
6892<DT><B>editing-mode (emacs)</B>
6893
6894<DD>
6895Controls whether readline begins with a set of key bindings similar
495aee44 6896to <I>Emacs</I> or <I>vi</I>.
17345e5a
JA
6897<B>editing-mode</B>
6898
6899can be set to either
6900<B>emacs</B>
6901
6902or
6903<B>vi</B>.
6904
0001803f
CR
6905<DT><B>echo-control-characters (On)</B>
6906
6907<DD>
6908When set to <B>On</B>, on operating systems that indicate they support it,
6909readline echoes a character corresponding to a signal generated from the
6910keyboard.
17345e5a
JA
6911<DT><B>enable-keypad (Off)</B>
6912
6913<DD>
6914When set to <B>On</B>, readline will try to enable the application
6915keypad when it is called. Some systems need this to enable the
6916arrow keys.
0001803f
CR
6917<DT><B>enable-meta-key (On)</B>
6918
6919<DD>
6920When set to <B>On</B>, readline will try to enable any meta modifier
6921key the terminal claims to support when it is called. On many terminals,
6922the meta key is used to send eight-bit characters.
17345e5a
JA
6923<DT><B>expand-tilde (Off)</B>
6924
6925<DD>
495aee44 6926If set to <B>On</B>, tilde expansion is performed when readline
17345e5a
JA
6927attempts word completion.
6928<DT><B>history-preserve-point (Off)</B>
6929
6930<DD>
495aee44 6931If set to <B>On</B>, the history code attempts to place point at the
17345e5a
JA
6932same location on each history line retrieved with <B>previous-history</B>
6933or <B>next-history</B>.
6934<DT><B>history-size (0)</B>
6935
6936<DD>
ac50fbac
CR
6937Set the maximum number of history entries saved in the history list.
6938If set to zero, any existing history entries are deleted and no new entries
6939are saved.
6940If set to a value less than zero, the number of history entries is not
6941limited.
6942By default, the number of history entries is not limited.
17345e5a
JA
6943<DT><B>horizontal-scroll-mode (Off)</B>
6944
6945<DD>
6946When set to <B>On</B>, makes readline use a single line for display,
6947scrolling the input horizontally on a single screen line when it
6948becomes longer than the screen width rather than wrapping to a new line.
6949<DT><B>input-meta (Off)</B>
6950
6951<DD>
6952If set to <B>On</B>, readline will enable eight-bit input (that is,
6953it will not strip the high bit from the characters it reads),
6954regardless of what the terminal claims it can support. The name
6955<B>meta-flag</B>
6956
6957is a synonym for this variable.
6958<DT><B>isearch-terminators (``C-[C-J'')</B>
6959
6960<DD>
6961The string of characters that should terminate an incremental
6962search without subsequently executing the character as a command.
6963If this variable has not been given a value, the characters
6964<I>ESC</I> and <I>C-J</I> will terminate an incremental search.
6965<DT><B>keymap (emacs)</B>
6966
6967<DD>
6968Set the current readline keymap. The set of valid keymap names is
6969<I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
6970vi-command</I>, and
6971<I>vi-insert</I>.
6972
6973<I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is
6974equivalent to <I>emacs-standard</I>. The default value is
6975<I>emacs</I>;
6976
6977the value of
6978<B>editing-mode</B>
6979
6980also affects the default keymap.
ac50fbac
CR
6981<DT><B>keyseq-timeout (500)</B>
6982
6983<DD>
6984Specifies the duration <I>readline</I> will wait for a character when reading an
6985ambiguous key sequence (one that can form a complete key sequence using
6986the input read so far, or can take additional input to complete a longer
6987key sequence).
6988If no input is received within the timeout, <I>readline</I> will use the shorter
6989but complete key sequence.
6990The value is specified in milliseconds, so a value of 1000 means that
6991<I>readline</I> will wait one second for additional input.
6992If this variable is set to a value less than or equal to zero, or to a
6993non-numeric value, <I>readline</I> will wait until another key is pressed to
6994decide which key sequence to complete.
17345e5a
JA
6995<DT><B>mark-directories (On)</B>
6996
6997<DD>
6998If set to <B>On</B>, completed directory names have a slash
6999appended.
7000<DT><B>mark-modified-lines (Off)</B>
7001
7002<DD>
7003If set to <B>On</B>, history lines that have been modified are displayed
7004with a preceding asterisk (<B>*</B>).
7005<DT><B>mark-symlinked-directories (Off)</B>
7006
7007<DD>
7008If set to <B>On</B>, completed names which are symbolic links to directories
7009have a slash appended (subject to the value of
7010<B>mark-directories</B>).
7011<DT><B>match-hidden-files (On)</B>
7012
7013<DD>
7014This variable, when set to <B>On</B>, causes readline to match files whose
7015names begin with a `.' (hidden files) when performing filename
495aee44
CR
7016completion.
7017If set to <B>Off</B>, the leading `.' must be
17345e5a 7018supplied by the user in the filename to be completed.
495aee44
CR
7019<DT><B>menu-complete-display-prefix (Off)</B>
7020
7021<DD>
7022If set to <B>On</B>, menu completion displays the common prefix of the
7023list of possible completions (which may be empty) before cycling through
7024the list.
17345e5a
JA
7025<DT><B>output-meta (Off)</B>
7026
7027<DD>
7028If set to <B>On</B>, readline will display characters with the
7029eighth bit set directly rather than as a meta-prefixed escape
7030sequence.
7031<DT><B>page-completions (On)</B>
7032
7033<DD>
7034If set to <B>On</B>, readline uses an internal <I>more</I>-like pager
7035to display a screenful of possible completions at a time.
7036<DT><B>print-completions-horizontally (Off)</B>
7037
7038<DD>
7039If set to <B>On</B>, readline will display completions with matches
7040sorted horizontally in alphabetical order, rather than down the screen.
7041<DT><B>revert-all-at-newline (Off)</B>
7042
7043<DD>
495aee44 7044If set to <B>On</B>, readline will undo all changes to history lines
17345e5a
JA
7045before returning when <B>accept-line</B> is executed. By default,
7046history lines may be modified and retain individual undo lists across
7047calls to <B>readline</B>.
7048<DT><B>show-all-if-ambiguous (Off)</B>
7049
7050<DD>
7051This alters the default behavior of the completion functions. If
7052set to
495aee44 7053<B>On</B>,
17345e5a
JA
7054
7055words which have more than one possible completion cause the
7056matches to be listed immediately instead of ringing the bell.
7057<DT><B>show-all-if-unmodified (Off)</B>
7058
7059<DD>
7060This alters the default behavior of the completion functions in
7061a fashion similar to <B>show-all-if-ambiguous</B>.
7062If set to
495aee44 7063<B>On</B>,
17345e5a
JA
7064
7065words which have more than one possible completion without any
7066possible partial completion (the possible completions don't share
7067a common prefix) cause the matches to be listed immediately instead
7068of ringing the bell.
ac50fbac
CR
7069<DT><B>show-mode-in-prompt (Off)</B>
7070
7071<DD>
7072If set to <B>On</B>, add a character to the beginning of the prompt
7073indicating the editing mode: emacs (@), vi command (:) or vi
7074insertion (+).
0001803f
CR
7075<DT><B>skip-completed-text (Off)</B>
7076
7077<DD>
7078If set to <B>On</B>, this alters the default completion behavior when
7079inserting a single match into the line. It's only active when
7080performing completion in the middle of a word. If enabled, readline
7081does not insert characters from the completion that match characters
7082after point in the word being completed, so portions of the word
7083following the cursor are not duplicated.
17345e5a
JA
7084<DT><B>visible-stats (Off)</B>
7085
7086<DD>
7087If set to <B>On</B>, a character denoting a file's type as reported
7088by <I>stat</I>(2) is appended to the filename when listing possible
7089completions.
7090
7091</DL>
7092<A NAME="lbCK">&nbsp;</A>
7093<H4>Readline Conditional Constructs</H4>
7094
7095<P>
7096
7097Readline implements a facility similar in spirit to the conditional
7098compilation features of the C preprocessor which allows key
7099bindings and variable settings to be performed as the result
7100of tests. There are four parser directives used.
7101<DL COMPACT>
7102<DT><B>$if</B><DD>
7103The
7104<B>$if</B>
7105
7106construct allows bindings to be made based on the
7107editing mode, the terminal being used, or the application using
7108readline. The text of the test extends to the end of the line;
7109no characters are required to isolate it.
7110<DL COMPACT><DT><DD>
7111<DL COMPACT>
7112<DT><B>mode</B><DD>
7113The <B>mode=</B> form of the <B>$if</B> directive is used to test
7114whether readline is in emacs or vi mode.
7115This may be used in conjunction
7116with the <B>set keymap</B> command, for instance, to set bindings in
7117the <I>emacs-standard</I> and <I>emacs-ctlx</I> keymaps only if
7118readline is starting out in emacs mode.
7119<DT><B>term</B><DD>
7120The <B>term=</B> form may be used to include terminal-specific
7121key bindings, perhaps to bind the key sequences output by the
7122terminal's function keys. The word on the right side of the
7123<B>=</B>
7124
7125is tested against the both full name of the terminal and the portion
7126of the terminal name before the first <B>-</B>. This allows
7127<I>sun</I>
7128
7129to match both
7130<I>sun</I>
7131
7132and
7133<I>sun-cmd</I>,
7134
7135for instance.
7136<DT><B>application</B><DD>
7137The <B>application</B> construct is used to include
7138application-specific settings. Each program using the readline
7139library sets the <I>application name</I>, and an initialization
7140file can test for a particular value.
7141This could be used to bind key sequences to functions useful for
7142a specific program. For instance, the following command adds a
495aee44 7143key sequence that quotes the current or previous word in <B>bash</B>:
17345e5a
JA
7144<P>
7145<DL COMPACT><DT><DD>
7146<PRE>
7147<B>$if</B> Bash
7148# Quote the current or previous word
7149&quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
7150<B>$endif</B>
7151</PRE>
7152
7153</DL>
7154
7155</DL></DL>
7156
7157<DT><B>$endif</B><DD>
7158This command, as seen in the previous example, terminates an
7159<B>$if</B> command.
7160<DT><B>$else</B><DD>
7161Commands in this branch of the <B>$if</B> directive are executed if
7162the test fails.
7163<DT><B>$include</B><DD>
7164This directive takes a single filename as an argument and reads commands
7165and bindings from that file. For example, the following directive
7166would read <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>:
7167<P>
7168<DL COMPACT><DT><DD>
7169<PRE>
7170<B>$include</B> <A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>
7171</PRE>
7172
7173</DL>
7174
7175</DL>
7176<A NAME="lbCL">&nbsp;</A>
7177<H4>Searching</H4>
7178
7179<P>
7180
7181Readline provides commands for searching through the command history
7182(see
7183<FONT SIZE=-1><B>HISTORY</B>
7184
7185</FONT>
7186below) for lines containing a specified string.
7187There are two search modes:
7188<I>incremental</I>
7189
7190and
7191<I>non-incremental</I>.
7192
7193<P>
7194
7195Incremental searches begin before the user has finished typing the
7196search string.
7197As each character of the search string is typed, readline displays
7198the next entry from the history matching the string typed so far.
7199An incremental search requires only as many characters as needed to
7200find the desired history entry.
7201The characters present in the value of the <B>isearch-terminators</B>
7202variable are used to terminate an incremental search.
7203If that variable has not been assigned a value the Escape and
7204Control-J characters will terminate an incremental search.
7205Control-G will abort an incremental search and restore the original
7206line.
7207When the search is terminated, the history entry containing the
7208search string becomes the current line.
7209<P>
7210
7211To find other matching entries in the history list, type Control-S or
7212Control-R as appropriate.
7213This will search backward or forward in the history for the next
7214entry matching the search string typed so far.
7215Any other key sequence bound to a readline command will terminate
7216the search and execute that command.
7217For instance, a <I>newline</I> will terminate the search and accept
7218the line, thereby executing the command from the history list.
7219<P>
7220
7221Readline remembers the last incremental search string. If two
7222Control-Rs are typed without any intervening characters defining a
7223new search string, any remembered search string is used.
7224<P>
7225
7226Non-incremental searches read the entire search string before starting
7227to search for matching history lines. The search string may be
7228typed by the user or be part of the contents of the current line.
7229<A NAME="lbCM">&nbsp;</A>
7230<H4>Readline Command Names</H4>
7231
7232<P>
7233
7234The following is a list of the names of the commands and the default
7235key sequences to which they are bound.
7236Command names without an accompanying key sequence are unbound by default.
7237In the following descriptions, <I>point</I> refers to the current cursor
7238position, and <I>mark</I> refers to a cursor position saved by the
7239<B>set-mark</B> command.
7240The text between the point and mark is referred to as the <I>region</I>.
7241<A NAME="lbCN">&nbsp;</A>
7242<H4>Commands for Moving</H4>
7243
7244<P>
7245
7246
7247<DL COMPACT>
7248<DT><B>beginning-of-line (C-a)</B>
7249
7250<DD>
7251Move to the start of the current line.
7252<DT><B>end-of-line (C-e)</B>
7253
7254<DD>
7255Move to the end of the line.
7256<DT><B>forward-char (C-f)</B>
7257
7258<DD>
7259Move forward a character.
7260<DT><B>backward-char (C-b)</B>
7261
7262<DD>
7263Move back a character.
7264<DT><B>forward-word (M-f)</B>
7265
7266<DD>
7267Move forward to the end of the next word. Words are composed of
7268alphanumeric characters (letters and digits).
7269<DT><B>backward-word (M-b)</B>
7270
7271<DD>
7272Move back to the start of the current or previous word.
7273Words are composed of alphanumeric characters (letters and digits).
7274<DT><B>shell-forward-word</B>
7275
7276<DD>
7277Move forward to the end of the next word.
7278Words are delimited by non-quoted shell metacharacters.
7279<DT><B>shell-backward-word</B>
7280
7281<DD>
7282Move back to the start of the current or previous word.
7283Words are delimited by non-quoted shell metacharacters.
7284<DT><B>clear-screen (C-l)</B>
7285
7286<DD>
7287Clear the screen leaving the current line at the top of the screen.
7288With an argument, refresh the current line without clearing the
7289screen.
7290<DT><B>redraw-current-line</B>
7291
7292<DD>
7293Refresh the current line.
7294
7295</DL>
7296<A NAME="lbCO">&nbsp;</A>
7297<H4>Commands for Manipulating the History</H4>
7298
7299<P>
7300
7301
7302<DL COMPACT>
7303<DT><B>accept-line (Newline, Return)</B>
7304
7305<DD>
7306Accept the line regardless of where the cursor is. If this line is
7307non-empty, add it to the history list according to the state of the
7308<FONT SIZE=-1><B>HISTCONTROL</B>
7309
7310</FONT>
7311variable. If the line is a modified history
7312line, then restore the history line to its original state.
7313<DT><B>previous-history (C-p)</B>
7314
7315<DD>
7316Fetch the previous command from the history list, moving back in
7317the list.
7318<DT><B>next-history (C-n)</B>
7319
7320<DD>
7321Fetch the next command from the history list, moving forward in the
7322list.
7323<DT><B>beginning-of-history (M-&lt;)</B>
7324
7325<DD>
7326Move to the first line in the history.
7327<DT><B>end-of-history (M-&gt;)</B>
7328
7329<DD>
7330Move to the end of the input history, i.e., the line currently being
7331entered.
7332<DT><B>reverse-search-history (C-r)</B>
7333
7334<DD>
7335Search backward starting at the current line and moving `up' through
7336the history as necessary. This is an incremental search.
7337<DT><B>forward-search-history (C-s)</B>
7338
7339<DD>
7340Search forward starting at the current line and moving `down' through
7341the history as necessary. This is an incremental search.
7342<DT><B>non-incremental-reverse-search-history (M-p)</B>
7343
7344<DD>
7345Search backward through the history starting at the current line
7346using a non-incremental search for a string supplied by the user.
7347<DT><B>non-incremental-forward-search-history (M-n)</B>
7348
7349<DD>
7350Search forward through the history using a non-incremental search for
7351a string supplied by the user.
7352<DT><B>history-search-forward</B>
7353
7354<DD>
7355Search forward through the history for the string of characters
7356between the start of the current line and the point.
7357This is a non-incremental search.
7358<DT><B>history-search-backward</B>
7359
7360<DD>
7361Search backward through the history for the string of characters
7362between the start of the current line and the point.
7363This is a non-incremental search.
7364<DT><B>yank-nth-arg (M-C-y)</B>
7365
7366<DD>
7367Insert the first argument to the previous command (usually
7368the second word on the previous line) at point.
7369With an argument
7370<I>n</I>,
7371
7372insert the <I>n</I>th word from the previous command (the words
7373in the previous command begin with word 0). A negative argument
7374inserts the <I>n</I>th word from the end of the previous command.
7375Once the argument <I>n</I> is computed, the argument is extracted
7376as if the &quot;!<I>n</I>&quot; history expansion had been specified.
7377<DT><B>yank-last-arg (M-., M-_)</B>
7378
7379<DD>
7380Insert the last argument to the previous command (the last word of
495aee44
CR
7381the previous history entry).
7382With a numeric argument, behave exactly like <B>yank-nth-arg</B>.
17345e5a 7383Successive calls to <B>yank-last-arg</B> move back through the history
495aee44
CR
7384list, inserting the last word (or the word specified by the argument to
7385the first call) of each line in turn.
7386Any numeric argument supplied to these successive calls determines
7387the direction to move through the history. A negative argument switches
7388the direction through the history (back or forward).
ac50fbac 7389The history expansion facilities are used to extract the last word,
17345e5a
JA
7390as if the &quot;!$&quot; history expansion had been specified.
7391<DT><B>shell-expand-line (M-C-e)</B>
7392
7393<DD>
7394Expand the line as the shell does. This
7395performs alias and history expansion as well as all of the shell
7396word expansions. See
7397<FONT SIZE=-1><B>HISTORY EXPANSION</B>
7398
7399</FONT>
7400below for a description of history expansion.
7401<DT><B>history-expand-line (M-^)</B>
7402
7403<DD>
7404Perform history expansion on the current line.
7405See
7406<FONT SIZE=-1><B>HISTORY EXPANSION</B>
7407
7408</FONT>
7409below for a description of history expansion.
7410<DT><B>magic-space</B>
7411
7412<DD>
7413Perform history expansion on the current line and insert a space.
7414See
7415<FONT SIZE=-1><B>HISTORY EXPANSION</B>
7416
7417</FONT>
7418below for a description of history expansion.
7419<DT><B>alias-expand-line</B>
7420
7421<DD>
7422Perform alias expansion on the current line.
7423See
7424<FONT SIZE=-1><B>ALIASES</B>
7425
7426</FONT>
7427above for a description of alias expansion.
7428<DT><B>history-and-alias-expand-line</B>
7429
7430<DD>
7431Perform history and alias expansion on the current line.
7432<DT><B>insert-last-argument (M-., M-_)</B>
7433
7434<DD>
7435A synonym for <B>yank-last-arg</B>.
7436<DT><B>operate-and-get-next (C-o)</B>
7437
7438<DD>
7439Accept the current line for execution and fetch the next line
7440relative to the current line from the history for editing. Any
7441argument is ignored.
7442<DT><B>edit-and-execute-command (C-xC-e)</B>
7443
7444<DD>
7445Invoke an editor on the current command line, and execute the result as shell
7446commands.
7447<B>Bash</B> attempts to invoke
7448<FONT SIZE=-1><B>$VISUAL</B>,
7449
7450</FONT>
7451<FONT SIZE=-1><B>$EDITOR</B>,
7452
7453</FONT>
7454and <I>emacs</I> as the editor, in that order.
7455
7456</DL>
7457<A NAME="lbCP">&nbsp;</A>
7458<H4>Commands for Changing Text</H4>
7459
7460<P>
7461
7462
7463<DL COMPACT>
ac50fbac 7464<DT><B></B><I>end-of-file</I> (usually C-d)
17345e5a
JA
7465
7466<DD>
ac50fbac
CR
7467The character indicating end-of-file as set, for example, by
7468<TT>stty</TT>.
7469
7470If this character is read when there are no characters
7471on the line, and point is at the beginning of the line, Readline
7472interprets it as the end of input and returns
17345e5a
JA
7473<FONT SIZE=-1><B>EOF</B>.
7474
7475</FONT>
ac50fbac
CR
7476<DT><B>delete-char (C-d)</B>
7477
7478<DD>
7479Delete the character at point.
7480If this function is bound to the
7481same character as the tty <B>EOF</B> character, as <B>C-d</B>
7482commonly is, see above for the effects.
17345e5a
JA
7483<DT><B>backward-delete-char (Rubout)</B>
7484
7485<DD>
7486Delete the character behind the cursor. When given a numeric argument,
7487save the deleted text on the kill ring.
7488<DT><B>forward-backward-delete-char</B>
7489
7490<DD>
7491Delete the character under the cursor, unless the cursor is at the
7492end of the line, in which case the character behind the cursor is
7493deleted.
7494<DT><B>quoted-insert (C-q, C-v)</B>
7495
7496<DD>
7497Add the next character typed to the line verbatim. This is
7498how to insert characters like <B>C-q</B>, for example.
7499<DT><B>tab-insert (C-v TAB)</B>
7500
7501<DD>
7502Insert a tab character.
7503<DT><B>self-insert (a,&nbsp;b,&nbsp;A,&nbsp;1,&nbsp;!,&nbsp;...)</B>
7504
7505<DD>
7506Insert the character typed.
7507<DT><B>transpose-chars (C-t)</B>
7508
7509<DD>
7510Drag the character before point forward over the character at point,
7511moving point forward as well.
7512If point is at the end of the line, then this transposes
7513the two characters before point.
7514Negative arguments have no effect.
7515<DT><B>transpose-words (M-t)</B>
7516
7517<DD>
7518Drag the word before point past the word after point,
7519moving point over that word as well.
7520If point is at the end of the line, this transposes
7521the last two words on the line.
7522<DT><B>upcase-word (M-u)</B>
7523
7524<DD>
7525Uppercase the current (or following) word. With a negative argument,
7526uppercase the previous word, but do not move point.
7527<DT><B>downcase-word (M-l)</B>
7528
7529<DD>
7530Lowercase the current (or following) word. With a negative argument,
7531lowercase the previous word, but do not move point.
7532<DT><B>capitalize-word (M-c)</B>
7533
7534<DD>
7535Capitalize the current (or following) word. With a negative argument,
7536capitalize the previous word, but do not move point.
7537<DT><B>overwrite-mode</B>
7538
7539<DD>
7540Toggle overwrite mode. With an explicit positive numeric argument,
7541switches to overwrite mode. With an explicit non-positive numeric
7542argument, switches to insert mode. This command affects only
7543<B>emacs</B> mode; <B>vi</B> mode does overwrite differently.
7544Each call to <I>readline()</I> starts in insert mode.
7545In overwrite mode, characters bound to <B>self-insert</B> replace
7546the text at point rather than pushing the text to the right.
7547Characters bound to <B>backward-delete-char</B> replace the character
7548before point with a space. By default, this command is unbound.
7549
7550</DL>
7551<A NAME="lbCQ">&nbsp;</A>
7552<H4>Killing and Yanking</H4>
7553
7554<P>
7555
7556
7557<DL COMPACT>
7558<DT><B>kill-line (C-k)</B>
7559
7560<DD>
7561Kill the text from point to the end of the line.
7562<DT><B>backward-kill-line (C-x Rubout)</B>
7563
7564<DD>
7565Kill backward to the beginning of the line.
7566<DT><B>unix-line-discard (C-u)</B>
7567
7568<DD>
7569Kill backward from point to the beginning of the line.
7570The killed text is saved on the kill-ring.
7571
7572<DT><B>kill-whole-line</B>
7573
7574<DD>
7575Kill all characters on the current line, no matter where point is.
7576<DT><B>kill-word (M-d)</B>
7577
7578<DD>
7579Kill from point to the end of the current word, or if between
7580words, to the end of the next word.
7581Word boundaries are the same as those used by <B>forward-word</B>.
7582<DT><B>backward-kill-word (M-Rubout)</B>
7583
7584<DD>
7585Kill the word behind point.
7586Word boundaries are the same as those used by <B>backward-word</B>.
7587<DT><B>shell-kill-word (M-d)</B>
7588
7589<DD>
7590Kill from point to the end of the current word, or if between
7591words, to the end of the next word.
7592Word boundaries are the same as those used by <B>shell-forward-word</B>.
7593<DT><B>shell-backward-kill-word (M-Rubout)</B>
7594
7595<DD>
7596Kill the word behind point.
7597Word boundaries are the same as those used by <B>shell-backward-word</B>.
7598<DT><B>unix-word-rubout (C-w)</B>
7599
7600<DD>
7601Kill the word behind point, using white space as a word boundary.
7602The killed text is saved on the kill-ring.
7603<DT><B>unix-filename-rubout</B>
7604
7605<DD>
7606Kill the word behind point, using white space and the slash character
7607as the word boundaries.
7608The killed text is saved on the kill-ring.
7609<DT><B>delete-horizontal-space (M-\)</B>
7610
7611<DD>
7612Delete all spaces and tabs around point.
7613<DT><B>kill-region</B>
7614
7615<DD>
7616Kill the text in the current region.
7617<DT><B>copy-region-as-kill</B>
7618
7619<DD>
7620Copy the text in the region to the kill buffer.
7621<DT><B>copy-backward-word</B>
7622
7623<DD>
7624Copy the word before point to the kill buffer.
7625The word boundaries are the same as <B>backward-word</B>.
7626<DT><B>copy-forward-word</B>
7627
7628<DD>
7629Copy the word following point to the kill buffer.
7630The word boundaries are the same as <B>forward-word</B>.
7631<DT><B>yank (C-y)</B>
7632
7633<DD>
7634Yank the top of the kill ring into the buffer at point.
7635<DT><B>yank-pop (M-y)</B>
7636
7637<DD>
7638Rotate the kill ring, and yank the new top. Only works following
7639<B>yank</B>
7640
7641or
7642<B>yank-pop</B>.
7643
7644
7645</DL>
7646<A NAME="lbCR">&nbsp;</A>
7647<H4>Numeric Arguments</H4>
7648
7649<P>
7650
7651
7652<DL COMPACT>
7653<DT><B>digit-argument (M-0, M-1, ..., M--)</B>
7654
7655<DD>
7656Add this digit to the argument already accumulating, or start a new
7657argument. M-- starts a negative argument.
7658<DT><B>universal-argument</B>
7659
7660<DD>
7661This is another way to specify an argument.
7662If this command is followed by one or more digits, optionally with a
7663leading minus sign, those digits define the argument.
7664If the command is followed by digits, executing
7665<B>universal-argument</B>
7666
7667again ends the numeric argument, but is otherwise ignored.
7668As a special case, if this command is immediately followed by a
7669character that is neither a digit or minus sign, the argument count
7670for the next command is multiplied by four.
7671The argument count is initially one, so executing this function the
7672first time makes the argument count four, a second time makes the
7673argument count sixteen, and so on.
7674
7675</DL>
7676<A NAME="lbCS">&nbsp;</A>
7677<H4>Completing</H4>
7678
7679<P>
7680
7681
7682<DL COMPACT>
7683<DT><B>complete (TAB)</B>
7684
7685<DD>
7686Attempt to perform completion on the text before point.
7687<B>Bash</B>
7688
7689attempts completion treating the text as a variable (if the
7690text begins with <B>$</B>), username (if the text begins with
7691<B>~</B>), hostname (if the text begins with <B>@</B>), or
7692command (including aliases and functions) in turn. If none
7693of these produces a match, filename completion is attempted.
7694<DT><B>possible-completions (M-?)</B>
7695
7696<DD>
7697List the possible completions of the text before point.
7698<DT><B>insert-completions (M-*)</B>
7699
7700<DD>
7701Insert all completions of the text before point
7702that would have been generated by
7703<B>possible-completions</B>.
7704<DT><B>menu-complete</B>
7705
7706<DD>
7707Similar to <B>complete</B>, but replaces the word to be completed
7708with a single match from the list of possible completions.
7709Repeated execution of <B>menu-complete</B> steps through the list
7710of possible completions, inserting each match in turn.
7711At the end of the list of completions, the bell is rung
7712(subject to the setting of <B>bell-style</B>)
7713and the original text is restored.
7714An argument of <I>n</I> moves <I>n</I> positions forward in the list
7715of matches; a negative argument may be used to move backward
7716through the list.
7717This command is intended to be bound to <B>TAB</B>, but is unbound
7718by default.
495aee44 7719<DT><B>menu-complete-backward</B>
0001803f
CR
7720
7721<DD>
7722Identical to <B>menu-complete</B>, but moves backward through the list
7723of possible completions, as if <B>menu-complete</B> had been given a
7724negative argument. This command is unbound by default.
17345e5a
JA
7725<DT><B>delete-char-or-list</B>
7726
7727<DD>
7728Deletes the character under the cursor if not at the beginning or
7729end of the line (like <B>delete-char</B>).
7730If at the end of the line, behaves identically to
7731<B>possible-completions</B>.
7732This command is unbound by default.
7733<DT><B>complete-filename (M-/)</B>
7734
7735<DD>
7736Attempt filename completion on the text before point.
7737<DT><B>possible-filename-completions (C-x /)</B>
7738
7739<DD>
7740List the possible completions of the text before point,
7741treating it as a filename.
7742<DT><B>complete-username (M-~)</B>
7743
7744<DD>
7745Attempt completion on the text before point, treating
7746it as a username.
7747<DT><B>possible-username-completions (C-x ~)</B>
7748
7749<DD>
7750List the possible completions of the text before point,
7751treating it as a username.
7752<DT><B>complete-variable (M-$)</B>
7753
7754<DD>
7755Attempt completion on the text before point, treating
7756it as a shell variable.
7757<DT><B>possible-variable-completions (C-x $)</B>
7758
7759<DD>
7760List the possible completions of the text before point,
7761treating it as a shell variable.
7762<DT><B>complete-hostname (M-@)</B>
7763
7764<DD>
7765Attempt completion on the text before point, treating
7766it as a hostname.
7767<DT><B>possible-hostname-completions (C-x @)</B>
7768
7769<DD>
7770List the possible completions of the text before point,
7771treating it as a hostname.
7772<DT><B>complete-command (M-!)</B>
7773
7774<DD>
7775Attempt completion on the text before point, treating
7776it as a command name. Command completion attempts to
7777match the text against aliases, reserved words, shell
7778functions, shell builtins, and finally executable filenames,
7779in that order.
7780<DT><B>possible-command-completions (C-x !)</B>
7781
7782<DD>
7783List the possible completions of the text before point,
7784treating it as a command name.
7785<DT><B>dynamic-complete-history (M-TAB)</B>
7786
7787<DD>
7788Attempt completion on the text before point, comparing
7789the text against lines from the history list for possible
7790completion matches.
7791<DT><B>dabbrev-expand</B>
7792
7793<DD>
7794Attempt menu completion on the text before point, comparing
7795the text against lines from the history list for possible
7796completion matches.
7797<DT><B>complete-into-braces (M-{)</B>
7798
7799<DD>
7800Perform filename completion and insert the list of possible completions
7801enclosed within braces so the list is available to the shell (see
7802<B>Brace Expansion</B>
7803
7804above).
7805
7806</DL>
7807<A NAME="lbCT">&nbsp;</A>
7808<H4>Keyboard Macros</H4>
7809
7810<P>
7811
7812
7813<DL COMPACT>
7814<DT><B>start-kbd-macro (C-x ()</B>
7815
7816<DD>
7817Begin saving the characters typed into the current keyboard macro.
7818<DT><B>end-kbd-macro (C-x ))</B>
7819
7820<DD>
7821Stop saving the characters typed into the current keyboard macro
7822and store the definition.
7823<DT><B>call-last-kbd-macro (C-x e)</B>
7824
7825<DD>
7826Re-execute the last keyboard macro defined, by making the characters
7827in the macro appear as if typed at the keyboard.
ac50fbac
CR
7828<DT><B>print-last-kbd-macro ()</B>
7829
7830<DD>
7831Print the last keyboard macro defined in a format suitable for the
7832<I>inputrc</I> file.
17345e5a
JA
7833
7834</DL>
7835<A NAME="lbCU">&nbsp;</A>
7836<H4>Miscellaneous</H4>
7837
7838<P>
7839
7840
7841<DL COMPACT>
7842<DT><B>re-read-init-file (C-x C-r)</B>
7843
7844<DD>
7845Read in the contents of the <I>inputrc</I> file, and incorporate
7846any bindings or variable assignments found there.
7847<DT><B>abort (C-g)</B>
7848
7849<DD>
7850Abort the current editing command and
7851ring the terminal's bell (subject to the setting of
7852<B>bell-style</B>).
7853
7854<DT><B>do-uppercase-version (M-a, M-b, M-</B><I>x</I>, ...)
7855
7856<DD>
7857If the metafied character <I>x</I> is lowercase, run the command
7858that is bound to the corresponding uppercase character.
7859<DT><B>prefix-meta (ESC)</B>
7860
7861<DD>
7862Metafy the next character typed.
7863<FONT SIZE=-1><B>ESC</B>
7864
7865</FONT>
7866<B>f</B>
7867
7868is equivalent to
7869<B>Meta-f</B>.
7870
7871<DT><B>undo (C-_, C-x C-u)</B>
7872
7873<DD>
7874Incremental undo, separately remembered for each line.
7875<DT><B>revert-line (M-r)</B>
7876
7877<DD>
7878Undo all changes made to this line. This is like executing the
7879<B>undo</B>
7880
7881command enough times to return the line to its initial state.
7882<DT><B>tilde-expand (M-&amp;)</B>
7883
7884<DD>
7885Perform tilde expansion on the current word.
7886<DT><B>set-mark (C-@, M-&lt;space&gt;)</B>
7887
7888<DD>
7889Set the mark to the point. If a
7890numeric argument is supplied, the mark is set to that position.
7891<DT><B>exchange-point-and-mark (C-x C-x)</B>
7892
7893<DD>
7894Swap the point with the mark. The current cursor position is set to
7895the saved position, and the old cursor position is saved as the mark.
7896<DT><B>character-search (C-])</B>
7897
7898<DD>
7899A character is read and point is moved to the next occurrence of that
7900character. A negative count searches for previous occurrences.
7901<DT><B>character-search-backward (M-C-])</B>
7902
7903<DD>
7904A character is read and point is moved to the previous occurrence of that
7905character. A negative count searches for subsequent occurrences.
495aee44 7906<DT><B>skip-csi-sequence</B>
0001803f
CR
7907
7908<DD>
7909Read enough characters to consume a multi-key sequence such as those
7910defined for keys like Home and End. Such sequences begin with a
7911Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
7912bound to &quot;\[&quot;, keys producing such sequences will have no effect
7913unless explicitly bound to a readline command, instead of inserting
7914stray characters into the editing buffer. This is unbound by default,
7915but usually bound to ESC-[.
17345e5a
JA
7916<DT><B>insert-comment (M-#)</B>
7917
7918<DD>
7919Without a numeric argument, the value of the readline
7920<B>comment-begin</B>
7921
7922variable is inserted at the beginning of the current line.
7923If a numeric argument is supplied, this command acts as a toggle: if
7924the characters at the beginning of the line do not match the value
7925of <B>comment-begin</B>, the value is inserted, otherwise
7926the characters in <B>comment-begin</B> are deleted from the beginning of
7927the line.
7928In either case, the line is accepted as if a newline had been typed.
7929The default value of
7930<B>comment-begin</B> causes this command to make the current line
7931a shell comment.
7932If a numeric argument causes the comment character to be removed, the line
7933will be executed by the shell.
7934<DT><B>glob-complete-word (M-g)</B>
7935
7936<DD>
7937The word before point is treated as a pattern for pathname expansion,
7938with an asterisk implicitly appended. This pattern is used to
ac50fbac 7939generate a list of matching filenames for possible completions.
17345e5a
JA
7940<DT><B>glob-expand-word (C-x *)</B>
7941
7942<DD>
7943The word before point is treated as a pattern for pathname expansion,
ac50fbac 7944and the list of matching filenames is inserted, replacing the word.
17345e5a
JA
7945If a numeric argument is supplied, an asterisk is appended before
7946pathname expansion.
7947<DT><B>glob-list-expansions (C-x g)</B>
7948
7949<DD>
7950The list of expansions that would have been generated by
7951<B>glob-expand-word</B>
7952
7953is displayed, and the line is redrawn.
7954If a numeric argument is supplied, an asterisk is appended before
7955pathname expansion.
7956<DT><B>dump-functions</B>
7957
7958<DD>
7959Print all of the functions and their key bindings to the
7960readline output stream. If a numeric argument is supplied,
7961the output is formatted in such a way that it can be made part
7962of an <I>inputrc</I> file.
7963<DT><B>dump-variables</B>
7964
7965<DD>
7966Print all of the settable readline variables and their values to the
7967readline output stream. If a numeric argument is supplied,
7968the output is formatted in such a way that it can be made part
7969of an <I>inputrc</I> file.
7970<DT><B>dump-macros</B>
7971
7972<DD>
7973Print all of the readline key sequences bound to macros and the
7974strings they output. If a numeric argument is supplied,
7975the output is formatted in such a way that it can be made part
7976of an <I>inputrc</I> file.
7977<DT><B>display-shell-version (C-x C-v)</B>
7978
7979<DD>
7980Display version information about the current instance of
7981<B>bash</B>.
7982
7983
7984</DL>
7985<A NAME="lbCV">&nbsp;</A>
7986<H4>Programmable Completion</H4>
7987
7988<P>
7989
7990When word completion is attempted for an argument to a command for
7991which a completion specification (a <I>compspec</I>) has been defined
7992using the <B>complete</B> builtin (see
7993<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
7994
7995</FONT>
7996below), the programmable completion facilities are invoked.
7997<P>
7998
7999First, the command name is identified.
0001803f
CR
8000If the command word is the empty string (completion attempted at the
8001beginning of an empty line), any compspec defined with
8002the <B>-E</B> option to <B>complete</B> is used.
17345e5a
JA
8003If a compspec has been defined for that command, the
8004compspec is used to generate the list of possible completions for the word.
8005If the command word is a full pathname, a compspec for the full
8006pathname is searched for first.
8007If no compspec is found for the full pathname, an attempt is made to
8008find a compspec for the portion following the final slash.
495aee44 8009If those searches do not result in a compspec, any compspec defined with
0001803f 8010the <B>-D</B> option to <B>complete</B> is used as the default.
17345e5a
JA
8011<P>
8012
8013Once a compspec has been found, it is used to generate the list of
8014matching words.
8015If a compspec is not found, the default <B>bash</B> completion as
8016described above under <B>Completing</B> is performed.
8017<P>
8018
8019First, the actions specified by the compspec are used.
8020Only matches which are prefixed by the word being completed are
8021returned.
8022When the
8023<B>-f</B>
8024
8025or
8026<B>-d</B>
8027
8028option is used for filename or directory name completion, the shell
8029variable
8030<FONT SIZE=-1><B>FIGNORE</B>
8031
8032</FONT>
8033is used to filter the matches.
8034<P>
8035
0001803f 8036Any completions specified by a pathname expansion pattern to the
17345e5a
JA
8037<B>-G</B> option are generated next.
8038The words generated by the pattern need not match the word
8039being completed.
8040The
8041<FONT SIZE=-1><B>GLOBIGNORE</B>
8042
8043</FONT>
8044shell variable is not used to filter the matches, but the
8045<FONT SIZE=-1><B>FIGNORE</B>
8046
8047</FONT>
8048variable is used.
8049<P>
8050
8051Next, the string specified as the argument to the <B>-W</B> option
8052is considered.
8053The string is first split using the characters in the
8054<FONT SIZE=-1><B>IFS</B>
8055
8056</FONT>
8057special variable as delimiters.
8058Shell quoting is honored.
8059Each word is then expanded using
8060brace expansion, tilde expansion, parameter and variable expansion,
8061command substitution, and arithmetic expansion,
8062as described above under
8063<FONT SIZE=-1><B>EXPANSION</B>.
8064
8065</FONT>
8066The results are split using the rules described above under
8067<B>Word Splitting</B>.
8068The results of the expansion are prefix-matched against the word being
8069completed, and the matching words become the possible completions.
8070<P>
8071
8072After these matches have been generated, any shell function or command
8073specified with the <B>-F</B> and <B>-C</B> options is invoked.
8074When the command or function is invoked, the
8075<FONT SIZE=-1><B>COMP_LINE</B>,
8076
8077</FONT>
8078<FONT SIZE=-1><B>COMP_POINT</B>,
8079
8080</FONT>
8081<FONT SIZE=-1><B>COMP_KEY</B>,
8082
8083</FONT>
8084and
8085<FONT SIZE=-1><B>COMP_TYPE</B>
8086
8087</FONT>
8088variables are assigned values as described above under
8089<B>Shell Variables</B>.
8090If a shell function is being invoked, the
8091<FONT SIZE=-1><B>COMP_WORDS</B>
8092
8093</FONT>
8094and
8095<FONT SIZE=-1><B>COMP_CWORD</B>
8096
8097</FONT>
8098variables are also set.
ac50fbac
CR
8099When the function or command is invoked,
8100the first argument (<B>$1</B>) is the name of the command whose arguments are
8101being completed,
8102the second argument (<B>$2</B>) is the word being completed,
8103and the third argument (<B>$3</B>) is the word preceding the word being
8104completed on the current command line.
17345e5a
JA
8105No filtering of the generated completions against the word being completed
8106is performed; the function or command has complete freedom in generating
8107the matches.
8108<P>
8109
8110Any function specified with <B>-F</B> is invoked first.
8111The function may use any of the shell facilities, including the
8112<B>compgen</B> builtin described below, to generate the matches.
8113It must put the possible completions in the
8114<FONT SIZE=-1><B>COMPREPLY</B>
8115
8116</FONT>
ac50fbac 8117array variable, one per array element.
17345e5a
JA
8118<P>
8119
8120Next, any command specified with the <B>-C</B> option is invoked
8121in an environment equivalent to command substitution.
8122It should print a list of completions, one per line, to the
8123standard output.
8124Backslash may be used to escape a newline, if necessary.
8125<P>
8126
8127After all of the possible completions are generated, any filter
8128specified with the <B>-X</B> option is applied to the list.
8129The filter is a pattern as used for pathname expansion; a <B>&amp;</B>
8130in the pattern is replaced with the text of the word being completed.
8131A literal <B>&amp;</B> may be escaped with a backslash; the backslash
8132is removed before attempting a match.
8133Any completion that matches the pattern will be removed from the list.
8134A leading <B>!</B> negates the pattern; in this case any completion
8135not matching the pattern will be removed.
8136<P>
8137
8138Finally, any prefix and suffix specified with the <B>-P</B> and <B>-S</B>
8139options are added to each member of the completion list, and the result is
8140returned to the readline completion code as the list of possible
8141completions.
8142<P>
8143
8144If the previously-applied actions do not generate any matches, and the
8145<B>-o dirnames</B> option was supplied to <B>complete</B> when the
8146compspec was defined, directory name completion is attempted.
8147<P>
8148
8149If the <B>-o plusdirs</B> option was supplied to <B>complete</B> when the
8150compspec was defined, directory name completion is attempted and any
8151matches are added to the results of the other actions.
8152<P>
8153
8154By default, if a compspec is found, whatever it generates is returned
8155to the completion code as the full set of possible completions.
8156The default <B>bash</B> completions are not attempted, and the readline
8157default of filename completion is disabled.
8158If the <B>-o bashdefault</B> option was supplied to <B>complete</B> when
8159the compspec was defined, the <B>bash</B> default completions are attempted
8160if the compspec generates no matches.
8161If the <B>-o default</B> option was supplied to <B>complete</B> when the
8162compspec was defined, readline's default completion will be performed
8163if the compspec (and, if attempted, the default <B>bash</B> completions)
8164generate no matches.
8165<P>
8166
8167When a compspec indicates that directory name completion is desired,
8168the programmable completion functions force readline to append a slash
8169to completed names which are symbolic links to directories, subject to
8170the value of the <B>mark-directories</B> readline variable, regardless
8171of the setting of the <B>mark-symlinked-directories</B> readline variable.
0001803f
CR
8172<P>
8173
8174There is some support for dynamically modifying completions. This is
8175most useful when used in combination with a default completion specified
8176with <B>complete -D</B>.
8177It's possible for shell functions executed as completion
8178handlers to indicate that completion should be retried by returning an
8179exit status of 124. If a shell function returns 124, and changes
8180the compspec associated with the command on which completion is being
8181attempted (supplied as the first argument when the function is executed),
8182programmable completion restarts from the beginning, with an
495aee44 8183attempt to find a new compspec for that command. This allows a set of
0001803f
CR
8184completions to be built dynamically as completion is attempted, rather than
8185being loaded all at once.
8186<P>
8187
8188For instance, assuming that there is a library of compspecs, each kept in a
8189file corresponding to the name of the command, the following default
8190completion function would load completions dynamically:
8191<P>
8192
8193<TT>_completion_loader()
8194<BR>
8195
8196{
8197<BR>
8198
8199<TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT>. &quot;/etc/bash_completion.d/$1.sh&quot; &gt;/dev/null 2&gt;&amp;1 &amp;&amp; return 124<BR>
8200<BR>
8201
8202}
8203<BR>
8204
ac50fbac 8205complete -D -F _completion_loader -o bashdefault -o default
0001803f
CR
8206<BR>
8207
8208</TT>
17345e5a
JA
8209<A NAME="lbCW">&nbsp;</A>
8210<H3>HISTORY</H3>
8211
8212When the
8213<B>-o history</B>
8214
8215option to the
8216<B>set</B>
8217
8218builtin is enabled, the shell provides access to the
8219<I>command history</I>,
8220the list of commands previously typed.
0001803f
CR
8221The value of the
8222<FONT SIZE=-1><B>HISTSIZE</B>
8223
8224</FONT>
8225variable is used as the
17345e5a
JA
8226number of commands to save in a history list.
8227The text of the last
8228<FONT SIZE=-1><B>HISTSIZE</B>
8229
8230</FONT>
8231commands (default 500) is saved. The shell
8232stores each command in the history list prior to parameter and
8233variable expansion (see
8234<FONT SIZE=-1><B>EXPANSION</B>
8235
8236</FONT>
8237above) but after history expansion is performed, subject to the
8238values of the shell variables
8239<FONT SIZE=-1><B>HISTIGNORE</B>
8240
8241</FONT>
8242and
8243<FONT SIZE=-1><B>HISTCONTROL</B>.
8244
8245</FONT>
8246<P>
8247
8248On startup, the history is initialized from the file named by
8249the variable
8250<FONT SIZE=-1><B>HISTFILE</B>
8251
8252</FONT>
8253(default <A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>).
8254The file named by the value of
8255<FONT SIZE=-1><B>HISTFILE</B>
8256
8257</FONT>
8258is truncated, if necessary, to contain no more than
8259the number of lines specified by the value of
8260<FONT SIZE=-1><B>HISTFILESIZE</B>.
8261
8262</FONT>
ac50fbac
CR
8263If <B>HISTFILESIZE</B> is unset, or set to null, a non-numeric value,
8264or a numeric value less than zero, the history file is not truncated.
17345e5a
JA
8265When the history file is read,
8266lines beginning with the history comment character followed immediately
8267by a digit are interpreted as timestamps for the preceding history line.
8268These timestamps are optionally displayed depending on the value of the
8269<FONT SIZE=-1><B>HISTTIMEFORMAT</B>
8270
8271</FONT>
8272variable.
ac50fbac 8273When a shell with history enabled exits, the last
17345e5a
JA
8274<FONT SIZE=-1><B>$HISTSIZE</B>
8275
8276</FONT>
8277lines are copied from the history list to
8278<FONT SIZE=-1><B>$HISTFILE</B>.
8279
8280</FONT>
8281If the
8282<B>histappend</B>
8283
8284shell option is enabled
8285(see the description of
8286<B>shopt</B>
8287
8288under
8289<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8290
8291</FONT>
8292below), the lines are appended to the history file,
8293otherwise the history file is overwritten.
8294If
8295<FONT SIZE=-1><B>HISTFILE</B>
8296
8297</FONT>
8298is unset, or if the history file is unwritable, the history is
8299not saved.
8300If the
0001803f
CR
8301<FONT SIZE=-1><B>HISTTIMEFORMAT</B>
8302
17345e5a
JA
8303</FONT>
8304variable is set, time stamps are written to the history file, marked
8305with the history comment character, so
8306they may be preserved across shell sessions.
8307This uses the history comment character to distinguish timestamps from
8308other history lines.
8309After saving the history, the history file is truncated
8310to contain no more than
8311<FONT SIZE=-1><B>HISTFILESIZE</B>
8312
8313</FONT>
8314lines. If
8315<FONT SIZE=-1><B>HISTFILESIZE</B>
8316
8317</FONT>
ac50fbac
CR
8318is unset, or set to null, a non-numeric value,
8319or a numeric value less than zero, the history file is not truncated.
17345e5a
JA
8320<P>
8321
8322The builtin command
8323<B>fc</B>
8324
8325(see
8326<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8327
8328</FONT>
8329below) may be used to list or edit and re-execute a portion of
8330the history list.
8331The
8332<B>history</B>
8333
8334builtin may be used to display or modify the history list and
8335manipulate the history file.
8336When using command-line editing, search commands
8337are available in each editing mode that provide access to the
8338history list.
8339<P>
8340
8341The shell allows control over which commands are saved on the history
8342list. The
8343<FONT SIZE=-1><B>HISTCONTROL</B>
8344
8345</FONT>
8346and
8347<FONT SIZE=-1><B>HISTIGNORE</B>
8348
8349</FONT>
8350variables may be set to cause the shell to save only a subset of the
8351commands entered.
8352The
8353<B>cmdhist</B>
8354
8355shell option, if enabled, causes the shell to attempt to save each
8356line of a multi-line command in the same history entry, adding
8357semicolons where necessary to preserve syntactic correctness.
8358The
8359<B>lithist</B>
8360
8361shell option causes the shell to save the command with embedded newlines
8362instead of semicolons. See the description of the
8363<B>shopt</B>
8364
8365builtin below under
8366<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8367
8368</FONT>
8369for information on setting and unsetting shell options.
8370<A NAME="lbCX">&nbsp;</A>
8371<H3>HISTORY EXPANSION</H3>
8372
8373<P>
8374
8375The shell supports a history expansion feature that
8376is similar to the history expansion in
8377<B>csh.</B>
8378
8379This section describes what syntax features are available. This
8380feature is enabled by default for interactive shells, and can be
8381disabled using the
8382<B>+H</B>
8383
8384option to the
8385<B>set</B>
8386
8387builtin command (see
8388<FONT SIZE=-1><B>SHELL BUILTIN COMMANDS</B>
8389
8390</FONT>
8391below). Non-interactive shells do not perform history expansion
8392by default.
8393<P>
8394
8395History expansions introduce words from the history list into
8396the input stream, making it easy to repeat commands, insert the
8397arguments to a previous command into the current input line, or
8398fix errors in previous commands quickly.
8399<P>
8400
8401History expansion is performed immediately after a complete line
8402is read, before the shell breaks it into words.
8403It takes place in two parts.
8404The first is to determine which line from the history list
8405to use during substitution.
8406The second is to select portions of that line for inclusion into
8407the current one.
8408The line selected from the history is the <I>event</I>,
8409and the portions of that line that are acted upon are <I>words</I>.
8410Various <I>modifiers</I> are available to manipulate the selected words.
8411The line is broken into words in the same fashion as when reading input,
8412so that several <I>metacharacter</I>-separated words surrounded by
8413quotes are considered one word.
8414History expansions are introduced by the appearance of the
8415history expansion character, which is <B>!</B> by default.
8416Only backslash (<B>\</B>) and single quotes can quote
8417the history expansion character.
8418<P>
8419
8420Several characters inhibit history expansion if found immediately
8421following the history expansion character, even if it is unquoted:
8422space, tab, newline, carriage return, and <B>=</B>.
8423If the <B>extglob</B> shell option is enabled, <B>(</B> will also
8424inhibit expansion.
8425<P>
8426
8427Several shell options settable with the
8428<B>shopt</B>
8429
8430builtin may be used to tailor the behavior of history expansion.
8431If the
8432<B>histverify</B>
8433
8434shell option is enabled (see the description of the
8435<B>shopt</B>
8436
0001803f 8437builtin below), and
17345e5a
JA
8438<B>readline</B>
8439
8440is being used, history substitutions are not immediately passed to
8441the shell parser.
8442Instead, the expanded line is reloaded into the
8443<B>readline</B>
8444
8445editing buffer for further modification.
8446If
8447<B>readline</B>
8448
8449is being used, and the
8450<B>histreedit</B>
8451
8452shell option is enabled, a failed history substitution will be reloaded
8453into the
8454<B>readline</B>
8455
8456editing buffer for correction.
8457The
8458<B>-p</B>
8459
8460option to the
8461<B>history</B>
8462
8463builtin command may be used to see what a history expansion will
8464do before using it.
8465The
8466<B>-s</B>
8467
8468option to the
8469<B>history</B>
8470
8471builtin may be used to add commands to the end of the history list
8472without actually executing them, so that they are available for
8473subsequent recall.
8474<P>
8475
8476The shell allows control of the various characters used by the
8477history expansion mechanism (see the description of
8478<B>histchars</B>
8479
8480above under
8481<B>Shell Variables</B>).
8482
8483The shell uses
8484the history comment character to mark history timestamps when
8485writing the history file.
8486<A NAME="lbCY">&nbsp;</A>
8487<H4>Event Designators</H4>
8488
8489<P>
8490
8491An event designator is a reference to a command line entry in the
8492history list.
495aee44
CR
8493Unless the reference is absolute, events are relative to the current
8494position in the history list.
17345e5a
JA
8495<P>
8496
8497
8498<DL COMPACT>
8499<DT><B>!</B>
8500
8501<DD>
8502Start a history substitution, except when followed by a
8503<B>blank</B>,
8504
8505newline, carriage return, =
8506or ( (when the <B>extglob</B> shell option is enabled using
8507the <B>shopt</B> builtin).
8508<DT><B>!</B><I>n</I>
8509
8510<DD>
8511Refer to command line
8512<I>n</I>.
8513
8514<DT><B>!-</B><I>n</I>
8515
8516<DD>
495aee44 8517Refer to the current command minus
17345e5a
JA
8518<I>n</I>.
8519
8520<DT><B>!!</B>
8521
8522<DD>
8523Refer to the previous command. This is a synonym for `!-1'.
8524<DT><B>!</B><I>string</I>
8525
8526<DD>
495aee44
CR
8527Refer to the most recent command preceding the current position in the
8528history list starting with
17345e5a
JA
8529<I>string</I>.
8530
8531<DT><B>!?</B><I>string</I><B>[?]</B>
8532
8533<DD>
ac50fbac 8534Refer to the most recent command preceding the current position in the
495aee44 8535history list containing
17345e5a
JA
8536<I>string</I>.
8537
8538The trailing <B>?</B> may be omitted if
8539<I>string</I>
8540
8541is followed immediately by a newline.
8542<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>
8543
8544<DD>
495aee44 8545Quick substitution. Repeat the previous command, replacing
17345e5a
JA
8546<I>string1</I>
8547
8548with
8549<I>string2</I>.
8550
8551Equivalent to
8552``!!:s/<I>string1</I>/<I>string2</I>/''
8553(see <B>Modifiers</B> below).
8554<DT><B>!#</B>
8555
8556<DD>
8557The entire command line typed so far.
8558
8559</DL>
8560<A NAME="lbCZ">&nbsp;</A>
8561<H4>Word Designators</H4>
8562
8563<P>
8564
8565Word designators are used to select desired words from the event.
8566A
8567<B>:</B>
8568
8569separates the event specification from the word designator.
8570It may be omitted if the word designator begins with a
8571<B>^</B>,
8572
8573<B>$</B>,
8574
8575<B>*</B>,
8576
8577<B>-</B>,
8578
8579or
8580<B>%</B>.
8581
8582Words are numbered from the beginning of the line,
8583with the first word being denoted by 0 (zero).
8584Words are inserted into the current line separated by single spaces.
8585<P>
8586
8587
8588<DL COMPACT>
8589<DT><B>0 (zero)</B>
8590
8591<DD>
8592The zeroth word. For the shell, this is the command
8593word.
8594<DT><I>n</I>
8595
8596<DD>
8597The <I>n</I>th word.
8598<DT><B>^</B>
8599
8600<DD>
8601The first argument. That is, word 1.
8602<DT><B>$</B>
8603
8604<DD>
ac50fbac
CR
8605The last word. This is usually the last argument, but will expand to the
8606zeroth word if there is only one word in the line.
17345e5a
JA
8607<DT><B>%</B>
8608
8609<DD>
8610The word matched by the most recent `?<I>string</I>?' search.
8611<DT><I>x</I><B>-</B>y
8612
8613<DD>
8614A range of words; `-<I>y</I>' abbreviates `0-<I>y</I>'.
8615<DT><B>*</B>
8616
8617<DD>
8618All of the words but the zeroth. This is a synonym
8619for `<I>1-$</I>'. It is not an error to use
8620<B>*</B>
8621
8622if there is just one
8623word in the event; the empty string is returned in that case.
8624<DT><B>x*</B>
8625
8626<DD>
8627Abbreviates <I>x-$</I>.
8628<DT><B>x-</B>
8629
8630<DD>
8631Abbreviates <I>x-$</I> like <B>x*</B>, but omits the last word.
8632
8633</DL>
8634<P>
8635
8636If a word designator is supplied without an event specification, the
8637previous command is used as the event.
8638<A NAME="lbDA">&nbsp;</A>
8639<H4>Modifiers</H4>
8640
8641<P>
8642
8643After the optional word designator, there may appear a sequence of
8644one or more of the following modifiers, each preceded by a `:'.
8645<P>
8646
8647
8648<P>
8649
8650<DL COMPACT>
8651<DT><B>h</B>
8652
8653<DD>
ac50fbac 8654Remove a trailing filename component, leaving only the head.
17345e5a
JA
8655<DT><B>t</B>
8656
8657<DD>
ac50fbac 8658Remove all leading filename components, leaving the tail.
17345e5a
JA
8659<DT><B>r</B>
8660
8661<DD>
8662Remove a trailing suffix of the form <I>.xxx</I>, leaving the
8663basename.
8664<DT><B>e</B>
8665
8666<DD>
8667Remove all but the trailing suffix.
8668<DT><B>p</B>
8669
8670<DD>
8671Print the new command but do not execute it.
8672<DT><B>q</B>
8673
8674<DD>
8675Quote the substituted words, escaping further substitutions.
8676<DT><B>x</B>
8677
8678<DD>
8679Quote the substituted words as with
8680<B>q</B>,
8681
8682but break into words at
8683<B>blanks</B>
8684
8685and newlines.
8686<DT><B>s/</B><I>old</I>/<I>new</I>/
8687
8688<DD>
8689Substitute
8690<I>new</I>
8691
8692for the first occurrence of
8693<I>old</I>
8694
8695in the event line. Any delimiter can be used in place of /. The
8696final delimiter is optional if it is the last character of the
8697event line. The delimiter may be quoted in
8698<I>old</I>
8699
8700and
8701<I>new</I>
8702
8703with a single backslash. If &amp; appears in
8704<I>new</I>,
8705
8706it is replaced by
8707<I>old</I>.
8708
8709A single backslash will quote the &amp;. If
8710<I>old</I>
8711
8712is null, it is set to the last
8713<I>old</I>
8714
8715substituted, or, if no previous history substitutions took place,
8716the last
8717<I>string</I>
8718
8719in a
8720<B>!?</B><I>string</I><B>[?]</B>
8721
8722search.
8723<DT><B>&amp;</B>
8724
8725<DD>
8726Repeat the previous substitution.
8727<DT><B>g</B>
8728
8729<DD>
8730Cause changes to be applied over the entire event line. This is
8731used in conjunction with `<B>:s</B>' (e.g., `<B>:gs/</B><I>old</I>/<I>new</I>/')
8732or `<B>:&amp;</B>'. If used with
8733`<B>:s</B>', any delimiter can be used
8734in place of /, and the final delimiter is optional
8735if it is the last character of the event line.
8736An <B>a</B> may be used as a synonym for <B>g</B>.
8737<DT><B>G</B>
8738
8739<DD>
8740Apply the following `<B>s</B>' modifier once to each word in the event line.
8741
8742</DL>
8743<A NAME="lbDB">&nbsp;</A>
8744<H3>SHELL BUILTIN COMMANDS</H3>
8745
8746
8747
8748<P>
8749
8750Unless otherwise noted, each builtin command documented in this
8751section as accepting options preceded by
8752<B>-</B>
8753
8754accepts
8755<B>--</B>
8756
8757to signify the end of the options.
0001803f
CR
8758The <B>:</B>, <B>true</B>, <B>false</B>, and <B>test</B> builtins
8759do not accept options and do not treat <B>--</B> specially.
8760The <B>exit</B>, <B>logout</B>, <B>break</B>, <B>continue</B>, <B>let</B>,
8761and <B>shift</B> builtins accept and process arguments beginning with
8762<B>-</B> without requiring <B>--</B>.
8763Other builtins that accept arguments but are not specified as accepting
8764options interpret arguments beginning with <B>-</B> as invalid options and
8765require <B>--</B> to prevent this interpretation.
17345e5a
JA
8766<P>
8767
8768<DL COMPACT>
8769<DT><B>:</B> [<I>arguments</I>]<DD>
8770
8771No effect; the command does nothing beyond expanding
8772<I>arguments</I>
8773
8774and performing any specified
8775redirections. A zero exit code is returned.
8776<DT><B> . </B> <I>filename</I> [<I>arguments</I>]<DD>
8777
8778<DT><B>source</B> <I>filename</I> [<I>arguments</I>]<DD>
8779
8780Read and execute commands from
8781<I>filename</I>
8782
8783in the current
8784shell environment and return the exit status of the last command
8785executed from
8786<I>filename</I>.
8787
8788If
8789<I>filename</I>
8790
ac50fbac 8791does not contain a slash, filenames in
17345e5a
JA
8792<FONT SIZE=-1><B>PATH</B>
8793
8794</FONT>
8795are used to find the directory containing
8796<I>filename</I>.
8797
8798The file searched for in
8799<FONT SIZE=-1><B>PATH</B>
8800
8801</FONT>
8802need not be executable.
8803When <B>bash</B> is not in <I>posix mode</I>, the current directory is
8804searched if no file is found in
8805<FONT SIZE=-1><B>PATH</B>.
8806
8807</FONT>
8808If the
8809<B>sourcepath</B>
8810
8811option to the
8812<B>shopt</B>
8813
8814builtin command is turned off, the
8815<FONT SIZE=-1><B>PATH</B>
8816
8817</FONT>
8818is not searched.
8819If any <I>arguments</I> are supplied, they become the positional
8820parameters when <I>filename</I> is executed. Otherwise the positional
8821parameters are unchanged.
8822The return status is the status of the last command exited within
8823the script (0 if no commands are executed), and false if
8824<I>filename</I>
8825
8826is not found or cannot be read.
8827<DT><B>alias</B> [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
8828<B>Alias</B> with no arguments or with the
8829<B>-p</B>
8830
8831option prints the list of aliases in the form
8832<B>alias</B> <I>name</I>=<I>value</I> on standard output.
8833When arguments are supplied, an alias is defined for
8834each <I>name</I> whose <I>value</I> is given.
8835A trailing space in <I>value</I> causes the next word to be
8836checked for alias substitution when the alias is expanded.
8837For each <I>name</I> in the argument list for which no <I>value</I>
8838is supplied, the name and value of the alias is printed.
8839<B>Alias</B> returns true unless a <I>name</I> is given for which
8840no alias has been defined.
8841<DT><B>bg</B> [<I>jobspec</I> ...]<DD>
8842Resume each suspended job <I>jobspec</I> in the background, as if it
8843had been started with
8844<B>&amp;</B>.
8845
8846If
8847<I>jobspec</I>
8848
8849is not present, the shell's notion of the <I>current job</I> is used.
8850<B>bg</B>
8851
8852<I>jobspec</I>
8853
8854returns 0 unless run when job control is disabled or, when run with
8855job control enabled, any specified <I>jobspec</I> was not found
8856or was started without job control.
ac50fbac 8857<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] [<B>-lpsvPSVX</B>]<DD>
17345e5a
JA
8858
8859<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>
8860<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-f</B> <I>filename</I><DD>
8861<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <B>-x</B> <I>keyseq</I>:<I>shell-command</I><DD>
8862<DT><B>bind</B> [<B>-m</B> <I>keymap</I>] <I>keyseq</I>:<I>function-name</I><DD>
8863<DT><B>bind</B> <I>readline-command</I><DD>
8864
8865Display current
8866<B>readline</B>
8867
8868key and function bindings, bind a key sequence to a
8869<B>readline</B>
8870
8871function or macro, or set a
8872<B>readline</B>
8873
8874variable.
8875Each non-option argument is a command as it would appear in
8876<I>.inputrc</I>,
8877
8878but each binding or command must be passed as a separate argument;
8879e.g., '&quot;\C-x\C-r&quot;: re-read-init-file'.
8880Options, if supplied, have the following meanings:
8881<DL COMPACT><DT><DD>
8882
8883<DL COMPACT>
8884<DT><B>-m </B><I>keymap</I>
8885
8886<DD>
8887Use
8888<I>keymap</I>
8889
8890as the keymap to be affected by the subsequent bindings.
8891Acceptable
8892<I>keymap</I>
8893
8894names are
8895<I>emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
8896vi-move, vi-command</I>, and
8897<I>vi-insert</I>.
8898
8899<I>vi</I> is equivalent to <I>vi-command</I>; <I>emacs</I> is
8900equivalent to <I>emacs-standard</I>.
8901<DT><B>-l</B>
8902
8903<DD>
8904List the names of all <B>readline</B> functions.
8905<DT><B>-p</B>
8906
8907<DD>
8908Display <B>readline</B> function names and bindings in such a way
8909that they can be re-read.
8910<DT><B>-P</B>
8911
8912<DD>
8913List current <B>readline</B> function names and bindings.
8914<DT><B>-s</B>
8915
8916<DD>
8917Display <B>readline</B> key sequences bound to macros and the strings
8918they output in such a way that they can be re-read.
8919<DT><B>-S</B>
8920
8921<DD>
8922Display <B>readline</B> key sequences bound to macros and the strings
8923they output.
8924<DT><B>-v</B>
8925
8926<DD>
8927Display <B>readline</B> variable names and values in such a way that they
8928can be re-read.
8929<DT><B>-V</B>
8930
8931<DD>
8932List current <B>readline</B> variable names and values.
8933<DT><B>-f </B><I>filename</I>
8934
8935<DD>
8936Read key bindings from <I>filename</I>.
8937<DT><B>-q </B><I>function</I>
8938
8939<DD>
8940Query about which keys invoke the named <I>function</I>.
8941<DT><B>-u </B><I>function</I>
8942
8943<DD>
8944Unbind all keys bound to the named <I>function</I>.
8945<DT><B>-r </B><I>keyseq</I>
8946
8947<DD>
8948Remove any current binding for <I>keyseq</I>.
8949<DT><B>-x </B><I>keyseq</I>:<I>shell-command</I>
8950
8951<DD>
8952Cause <I>shell-command</I> to be executed whenever <I>keyseq</I> is
8953entered.
8954When <I>shell-command</I> is executed, the shell sets the
0001803f 8955<FONT SIZE=-1><B>READLINE_LINE</B>
17345e5a 8956
0001803f 8957</FONT>
17345e5a 8958variable to the contents of the <B>readline</B> line buffer and the
0001803f 8959<FONT SIZE=-1><B>READLINE_POINT</B>
17345e5a 8960
0001803f 8961</FONT>
17345e5a
JA
8962variable to the current location of the insertion point.
8963If the executed command changes the value of
0001803f 8964<FONT SIZE=-1><B>READLINE_LINE</B>
17345e5a 8965
0001803f 8966</FONT>
17345e5a 8967or
0001803f 8968<FONT SIZE=-1><B>READLINE_POINT</B>,
17345e5a 8969
0001803f 8970</FONT>
17345e5a 8971those new values will be reflected in the editing state.
ac50fbac
CR
8972<DT><B>-X</B>
8973
8974<DD>
8975List all key sequences bound to shell commands and the associated commands
8976in a format that can be reused as input.
17345e5a
JA
8977
8978</DL>
8979<P>
8980
8981The return value is 0 unless an unrecognized option is given or an
8982error occurred.
8983</DL>
8984
8985<DT><B>break</B> [<I>n</I>]<DD>
8986Exit from within a
8987<B>for</B>,
8988
8989<B>while</B>,
8990
8991<B>until</B>,
8992
8993or
8994<B>select</B>
8995
8996loop. If <I>n</I> is specified, break <I>n</I> levels.
8997<I>n</I>
8998
8999must be >= 1. If
9000<I>n</I>
9001
9002is greater than the number of enclosing loops, all enclosing loops
9003are exited.
9004The return value is 0 unless <I>n</I> is not greater than or equal to 1.
9005<DT><B>builtin</B> <I>shell-builtin</I> [<I>arguments</I>]<DD>
9006Execute the specified shell builtin, passing it
9007<I>arguments</I>,
9008
9009and return its exit status.
9010This is useful when defining a
9011function whose name is the same as a shell builtin,
9012retaining the functionality of the builtin within the function.
9013The <B>cd</B> builtin is commonly redefined this way.
9014The return status is false if
9015<I>shell-builtin</I>
9016
9017is not a shell builtin command.
9018<DT><B>caller</B> [<I>expr</I>]<DD>
9019Returns the context of any active subroutine call (a shell function or
495aee44 9020a script executed with the <B>.</B> or <B>source</B> builtins).
17345e5a
JA
9021Without <I>expr</I>, <B>caller</B> displays the line number and source
9022filename of the current subroutine call.
9023If a non-negative integer is supplied as <I>expr</I>, <B>caller</B>
9024displays the line number, subroutine name, and source file corresponding
9025to that position in the current execution call stack. This extra
9026information may be used, for example, to print a stack trace. The
9027current frame is frame 0.
9028The return value is 0 unless the shell is not executing a subroutine
9029call or <I>expr</I> does not correspond to a valid position in the
9030call stack.
ac50fbac
CR
9031<DT><B>cd</B> [<B>-L</B>|[<B>-P</B> [<B>-e</B>]] [-@]] [<I>dir</I>]<DD>
9032Change the current directory to <I>dir</I>.
9033if <I>dir</I> is not supplied, the value of the
17345e5a
JA
9034<FONT SIZE=-1><B>HOME</B>
9035
9036</FONT>
ac50fbac
CR
9037shell variable is the default.
9038Any additional arguments following <I>dir</I> are ignored.
17345e5a
JA
9039The variable
9040<FONT SIZE=-1><B>CDPATH</B>
9041
9042</FONT>
9043defines the search path for the directory containing
ac50fbac
CR
9044<I>dir</I>:
9045
9046each directory name in
9047<FONT SIZE=-1><B>CDPATH</B>
17345e5a 9048
ac50fbac
CR
9049</FONT>
9050is searched for <I>dir</I>.
17345e5a
JA
9051Alternative directory names in
9052<FONT SIZE=-1><B>CDPATH</B>
9053
9054</FONT>
9055are separated by a colon (:). A null directory name in
9056<FONT SIZE=-1><B>CDPATH</B>
9057
9058</FONT>
9059is the same as the current directory, i.e., ``<B>.</B>''. If
9060<I>dir</I>
9061
9062begins with a slash (/),
9063then
9064<FONT SIZE=-1><B>CDPATH</B>
9065
9066</FONT>
9067is not used. The
9068<B>-P</B>
9069
ac50fbac
CR
9070option causes <B>cd</B> to use the physical directory structure
9071by resolving symbolic links while traversing <I>dir</I> and
9072before processing instances of <I>..</I> in <I>dir</I> (see also the
17345e5a
JA
9073<B>-P</B>
9074
9075option to the
9076<B>set</B>
9077
9078builtin command); the
9079<B>-L</B>
9080
ac50fbac
CR
9081option forces symbolic links to be followed by resolving the link
9082after processing instances of <I>..</I> in <I>dir</I>.
9083If <I>..</I> appears in <I>dir</I>, it is processed by removing the
9084immediately previous pathname component from <I>dir</I>, back to a slash
9085or the beginning of <I>dir</I>.
495aee44
CR
9086If the
9087<B>-e</B>
9088
9089option is supplied with
9090<B>-P</B>,
9091
9092and the current working directory cannot be successfully determined
9093after a successful directory change, <B>cd</B> will return an unsuccessful
9094status.
ac50fbac
CR
9095On systems that support it, the <B>-@</B> option presents the extended
9096attributes associated with a file as a directory.
495aee44 9097An argument of
17345e5a
JA
9098<B>-</B>
9099
ac50fbac
CR
9100is converted to
9101<FONT SIZE=-1><B>$OLDPWD</B>
17345e5a
JA
9102
9103</FONT>
ac50fbac 9104before the directory change is attempted.
0001803f
CR
9105If a non-empty directory name from
9106<FONT SIZE=-1><B>CDPATH</B>
9107
9108</FONT>
9109is used, or if
17345e5a
JA
9110<B>-</B> is the first argument, and the directory change is
9111successful, the absolute pathname of the new working directory is
9112written to the standard output.
9113The return value is true if the directory was successfully changed;
9114false otherwise.
9115<DT><B>command</B> [<B>-pVv</B>] <I>command</I> [<I>arg</I> ...]<DD>
9116Run
9117<I>command</I>
9118
9119with
9120<I>args</I>
9121
9122suppressing the normal shell function lookup. Only builtin
9123commands or commands found in the
9124<FONT SIZE=-1><B>PATH</B>
9125
9126</FONT>
9127are executed. If the
9128<B>-p</B>
9129
9130option is given, the search for
9131<I>command</I>
9132
9133is performed using a default value for
0001803f 9134<FONT SIZE=-1><B>PATH</B>
17345e5a 9135
0001803f 9136</FONT>
17345e5a
JA
9137that is guaranteed to find all of the standard utilities.
9138If either the
9139<B>-V</B>
9140
9141or
9142<B>-v</B>
9143
9144option is supplied, a description of
9145<I>command</I>
9146
9147is printed. The
9148<B>-v</B>
9149
ac50fbac 9150option causes a single word indicating the command or filename
17345e5a
JA
9151used to invoke
9152<I>command</I>
9153
9154to be displayed; the
9155<B>-V</B>
9156
9157option produces a more verbose description.
9158If the
9159<B>-V</B>
9160
9161or
9162<B>-v</B>
9163
9164option is supplied, the exit status is 0 if
9165<I>command</I>
9166
9167was found, and 1 if not. If neither option is supplied and
9168an error occurred or
9169<I>command</I>
9170
9171cannot be found, the exit status is 127. Otherwise, the exit status of the
9172<B>command</B>
9173
9174builtin is the exit status of
9175<I>command</I>.
9176
9177<DT><B>compgen</B> [<I>option</I>] [<I>word</I>]<DD>
9178Generate possible completion matches for <I>word</I> according to
9179the <I>option</I>s, which may be any option accepted by the
9180<B>complete</B>
9181
9182builtin with the exception of <B>-p</B> and <B>-r</B>, and write
9183the matches to the standard output.
9184When using the <B>-F</B> or <B>-C</B> options, the various shell variables
9185set by the programmable completion facilities, while available, will not
9186have useful values.
9187<P>
9188The matches will be generated in the same way as if the programmable
9189completion code had generated them directly from a completion specification
9190with the same flags.
9191If <I>word</I> is specified, only those completions matching <I>word</I>
9192will be displayed.
9193<P>
9194The return value is true unless an invalid option is supplied, or no
9195matches were generated.
0001803f 9196<DT><B>complete</B> [<B>-abcdefgjksuv</B>] [<B>-o</B> <I>comp-option</I>] [<B>-DE</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>
17345e5a
JA
9197<BR>
9198
9199[<B>-X</B> <I>filterpat</I>] [<B>-P</B> <I>prefix</I>] [<B>-S</B> <I>suffix</I>] <I>name</I> [<I>name ...</I>]
9200
0001803f 9201<DT><B>complete</B> <B>-pr</B> [<B>-DE</B>] [<I>name</I> ...]<DD>
17345e5a
JA
9202
9203Specify how arguments to each <I>name</I> should be completed.
9204If the <B>-p</B> option is supplied, or if no options are supplied,
9205existing completion specifications are printed in a way that allows
9206them to be reused as input.
9207The <B>-r</B> option removes a completion specification for
9208each <I>name</I>, or, if no <I>name</I>s are supplied, all
9209completion specifications.
0001803f
CR
9210The <B>-D</B> option indicates that the remaining options and actions should
9211apply to the ``default'' command completion; that is, completion attempted
9212on a command for which no completion has previously been defined.
17345e5a
JA
9213The <B>-E</B> option indicates that the remaining options and actions should
9214apply to ``empty'' command completion; that is, completion attempted on a
9215blank line.
9216<P>
9217The process of applying these completion specifications when word completion
9218is attempted is described above under <B>Programmable Completion</B>.
9219<P>
9220Other options, if specified, have the following meanings.
9221The arguments to the <B>-G</B>, <B>-W</B>, and <B>-X</B> options
9222(and, if necessary, the <B>-P</B> and <B>-S</B> options)
9223should be quoted to protect them from expansion before the
9224<B>complete</B>
9225
9226builtin is invoked.
9227<DL COMPACT><DT><DD>
9228
9229<DL COMPACT>
9230<DT><B>-o</B> <I>comp-option</I><DD>
9231The <I>comp-option</I> controls several aspects of the compspec's behavior
9232beyond the simple generation of completions.
9233<I>comp-option</I> may be one of:
9234<DL COMPACT><DT><DD>
9235<DL COMPACT>
9236<DT><B>bashdefault</B>
9237
9238<DD>
9239Perform the rest of the default <B>bash</B> completions if the compspec
9240generates no matches.
9241<DT><B>default</B>
9242
9243<DD>
9244Use readline's default filename completion if the compspec generates
9245no matches.
9246<DT><B>dirnames</B>
9247
9248<DD>
9249Perform directory name completion if the compspec generates no matches.
9250<DT><B>filenames</B>
9251
9252<DD>
9253Tell readline that the compspec generates filenames, so it can perform any
9254filename-specific processing (like adding a slash to directory names,
9255quoting special characters, or suppressing trailing spaces).
9256Intended to be used with shell functions.
ac50fbac
CR
9257<DT><B>noquote</B>
9258
9259<DD>
9260Tell readline not to quote the completed words if they are filenames
9261(quoting filenames is the default).
17345e5a
JA
9262<DT><B>nospace</B>
9263
9264<DD>
9265Tell readline not to append a space (the default) to words completed at
9266the end of the line.
9267<DT><B>plusdirs</B>
9268
9269<DD>
9270After any matches defined by the compspec are generated,
9271directory name completion is attempted and any
9272matches are added to the results of the other actions.
9273</DL></DL>
9274
9275<DT><B>-A</B> <I>action</I><DD>
9276The <I>action</I> may be one of the following to generate a list of possible
9277completions:
9278<DL COMPACT><DT><DD>
9279<DL COMPACT>
9280<DT><B>alias</B>
9281
9282<DD>
9283Alias names. May also be specified as <B>-a</B>.
9284<DT><B>arrayvar</B>
9285
9286<DD>
9287Array variable names.
9288<DT><B>binding</B>
9289
9290<DD>
9291<B>Readline</B> key binding names.
9292<DT><B>builtin</B>
9293
9294<DD>
9295Names of shell builtin commands. May also be specified as <B>-b</B>.
9296<DT><B>command</B>
9297
9298<DD>
9299Command names. May also be specified as <B>-c</B>.
9300<DT><B>directory</B>
9301
9302<DD>
9303Directory names. May also be specified as <B>-d</B>.
9304<DT><B>disabled</B>
9305
9306<DD>
9307Names of disabled shell builtins.
9308<DT><B>enabled</B>
9309
9310<DD>
9311Names of enabled shell builtins.
9312<DT><B>export</B>
9313
9314<DD>
9315Names of exported shell variables. May also be specified as <B>-e</B>.
9316<DT><B>file</B>
9317
9318<DD>
9319File names. May also be specified as <B>-f</B>.
9320<DT><B>function</B>
9321
9322<DD>
9323Names of shell functions.
9324<DT><B>group</B>
9325
9326<DD>
9327Group names. May also be specified as <B>-g</B>.
9328<DT><B>helptopic</B>
9329
9330<DD>
9331Help topics as accepted by the <B>help</B> builtin.
9332<DT><B>hostname</B>
9333
9334<DD>
9335Hostnames, as taken from the file specified by the
9336<FONT SIZE=-1><B>HOSTFILE</B>
9337
9338</FONT>
9339shell variable.
9340<DT><B>job</B>
9341
9342<DD>
9343Job names, if job control is active. May also be specified as <B>-j</B>.
9344<DT><B>keyword</B>
9345
9346<DD>
9347Shell reserved words. May also be specified as <B>-k</B>.
9348<DT><B>running</B>
9349
9350<DD>
9351Names of running jobs, if job control is active.
9352<DT><B>service</B>
9353
9354<DD>
9355Service names. May also be specified as <B>-s</B>.
9356<DT><B>setopt</B>
9357
9358<DD>
9359Valid arguments for the <B>-o</B> option to the <B>set</B> builtin.
9360<DT><B>shopt</B>
9361
9362<DD>
9363Shell option names as accepted by the <B>shopt</B> builtin.
9364<DT><B>signal</B>
9365
9366<DD>
9367Signal names.
9368<DT><B>stopped</B>
9369
9370<DD>
9371Names of stopped jobs, if job control is active.
9372<DT><B>user</B>
9373
9374<DD>
9375User names. May also be specified as <B>-u</B>.
9376<DT><B>variable</B>
9377
9378<DD>
9379Names of all shell variables. May also be specified as <B>-v</B>.
9380</DL></DL>
9381
17345e5a
JA
9382<DT><B>-C</B> <I>command</I><DD>
9383<I>command</I> is executed in a subshell environment, and its output is
9384used as the possible completions.
9385<DT><B>-F</B> <I>function</I><DD>
9386The shell function <I>function</I> is executed in the current shell
9387environment.
ac50fbac
CR
9388When the function is executed,
9389the first argument (<B>$1</B>) is the name of the command whose arguments are
9390being completed,
9391the second argument (<B>$2</B>) is the word being completed,
9392and the third argument (<B>$3</B>) is the word preceding the word being
9393completed on the current command line.
17345e5a
JA
9394When it finishes, the possible completions are retrieved from the value
9395of the
9396<FONT SIZE=-1><B>COMPREPLY</B>
9397
9398</FONT>
9399array variable.
495aee44
CR
9400<DT><B>-G</B> <I>globpat</I><DD>
9401The pathname expansion pattern <I>globpat</I> is expanded to generate
9402the possible completions.
9403<DT><B>-P</B> <I>prefix</I><DD>
9404<I>prefix</I> is added at the beginning of each possible completion
9405after all other options have been applied.
9406<DT><B>-S</B> <I>suffix</I><DD>
9407<I>suffix</I> is appended to each possible completion
9408after all other options have been applied.
9409<DT><B>-W</B> <I>wordlist</I><DD>
9410The <I>wordlist</I> is split using the characters in the
9411<FONT SIZE=-1><B>IFS</B>
9412
9413</FONT>
9414special variable as delimiters, and each resultant word is expanded.
9415The possible completions are the members of the resultant list which
9416match the word being completed.
17345e5a 9417<DT><B>-X</B> <I>filterpat</I><DD>
0001803f 9418<I>filterpat</I> is a pattern as used for pathname expansion.
17345e5a
JA
9419It is applied to the list of possible completions generated by the
9420preceding options and arguments, and each completion matching
9421<I>filterpat</I> is removed from the list.
9422A leading <B>!</B> in <I>filterpat</I> negates the pattern; in this
9423case, any completion not matching <I>filterpat</I> is removed.
17345e5a
JA
9424
9425</DL>
9426<P>
9427
9428The return value is true unless an invalid option is supplied, an option
9429other than <B>-p</B> or <B>-r</B> is supplied without a <I>name</I>
9430argument, an attempt is made to remove a completion specification for
9431a <I>name</I> for which no specification exists, or
9432an error occurs adding a completion specification.
9433</DL>
9434
0001803f 9435<DT><B>compopt</B> [<B>-o</B> <I>option</I>] [<B>-DE</B>] [<B>+o</B> <I>option</I>] [<I>name</I>]<DD>
17345e5a
JA
9436Modify completion options for each <I>name</I> according to the
9437<I>option</I>s, or for the
495aee44 9438currently-executing completion if no <I>name</I>s are supplied.
17345e5a
JA
9439If no <I>option</I>s are given, display the completion options for each
9440<I>name</I> or the current completion.
9441The possible values of <I>option</I> are those valid for the <B>complete</B>
9442builtin described above.
0001803f
CR
9443The <B>-D</B> option indicates that the remaining options should
9444apply to the ``default'' command completion; that is, completion attempted
9445on a command for which no completion has previously been defined.
9446The <B>-E</B> option indicates that the remaining options should
9447apply to ``empty'' command completion; that is, completion attempted on a
9448blank line.
17345e5a 9449<P>
17345e5a
JA
9450The return value is true unless an invalid option is supplied, an attempt
9451is made to modify the options for a <I>name</I> for which no completion
9452specification exists, or an output error occurs.
17345e5a
JA
9453<DT><B>continue</B> [<I>n</I>]<DD>
9454Resume the next iteration of the enclosing
9455<B>for</B>,
9456
9457<B>while</B>,
9458
9459<B>until</B>,
9460
9461or
9462<B>select</B>
9463
9464loop.
9465If
9466<I>n</I>
9467
9468is specified, resume at the <I>n</I>th enclosing loop.
9469<I>n</I>
9470
9471must be >= 1. If
9472<I>n</I>
9473
9474is greater than the number of enclosing loops, the last enclosing loop
9475(the ``top-level'' loop) is resumed.
9476The return value is 0 unless <I>n</I> is not greater than or equal to 1.
ac50fbac 9477<DT><B>declare</B> [<B>-aAfFgilnrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
17345e5a 9478
ac50fbac 9479<DT><B>typeset</B> [<B>-aAfFgilnrtux</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
17345e5a
JA
9480
9481Declare variables and/or give them attributes.
9482If no <I>name</I>s are given then display the values of variables.
9483The
9484<B>-p</B>
9485
9486option will display the attributes and values of each
9487<I>name</I>.
9488
9489When
9490<B>-p</B>
9491
ac50fbac
CR
9492is used with <I>name</I> arguments, additional options,
9493other than <B>-f</B> and <B>-F</B>, are ignored.
17345e5a
JA
9494When
9495<B>-p</B>
9496
9497is supplied without <I>name</I> arguments, it will display the attributes
9498and values of all variables having the attributes specified by the
9499additional options.
9500If no other options are supplied with <B>-p</B>, <B>declare</B> will display
9501the attributes and values of all shell variables. The <B>-f</B> option
9502will restrict the display to shell functions.
9503The
9504<B>-F</B>
9505
9506option inhibits the display of function definitions; only the
9507function name and attributes are printed.
9508If the <B>extdebug</B> shell option is enabled using <B>shopt</B>,
9509the source file name and line number where the function is defined
9510are displayed as well. The
9511<B>-F</B>
9512
9513option implies
9514<B>-f</B>.
9515
495aee44
CR
9516The
9517<B>-g</B>
9518
9519option forces variables to be created or modified at the global scope,
9520even when <B>declare</B> is executed in a shell function.
9521It is ignored in all other cases.
17345e5a
JA
9522The following options can
9523be used to restrict output to variables with the specified attribute or
9524to give variables attributes:
9525<DL COMPACT><DT><DD>
9526
9527<DL COMPACT>
9528<DT><B>-a</B>
9529
9530<DD>
9531Each <I>name</I> is an indexed array variable (see
9532<B>Arrays</B>
9533
9534above).
9535<DT><B>-A</B>
9536
9537<DD>
9538Each <I>name</I> is an associative array variable (see
9539<B>Arrays</B>
9540
9541above).
9542<DT><B>-f</B>
9543
9544<DD>
9545Use function names only.
9546<DT><B>-i</B>
9547
9548<DD>
9549The variable is treated as an integer; arithmetic evaluation (see
0001803f 9550<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
17345e5a
JA
9551
9552</FONT>
0001803f 9553above) is performed when the variable is assigned a value.
17345e5a
JA
9554<DT><B>-l</B>
9555
9556<DD>
9557When the variable is assigned a value, all upper-case characters are
9558converted to lower-case.
9559The upper-case attribute is disabled.
ac50fbac
CR
9560<DT><B>-n</B>
9561
9562<DD>
9563Give each <I>name</I> the <I>nameref</I> attribute, making
9564it a name reference to another variable.
9565That other variable is defined by the value of <I>name</I>.
9566All references and assignments to <I>name</I>, except for changing the
9567<B>-n</B> attribute itself, are performed on the variable referenced by
9568<I>name</I>'s value.
9569The <B>-n</B> attribute cannot be applied to array variables.
17345e5a
JA
9570<DT><B>-r</B>
9571
9572<DD>
9573Make <I>name</I>s readonly. These names cannot then be assigned values
9574by subsequent assignment statements or unset.
9575<DT><B>-t</B>
9576
9577<DD>
9578Give each <I>name</I> the <I>trace</I> attribute.
9579Traced functions inherit the <B>DEBUG</B> and <B>RETURN</B> traps from
9580the calling shell.
9581The trace attribute has no special meaning for variables.
9582<DT><B>-u</B>
9583
9584<DD>
9585When the variable is assigned a value, all lower-case characters are
9586converted to upper-case.
9587The lower-case attribute is disabled.
9588<DT><B>-x</B>
9589
9590<DD>
9591Mark <I>name</I>s for export to subsequent commands via the environment.
9592
9593</DL>
9594<P>
9595
9596Using `+' instead of `-'
9597turns off the attribute instead,
9598with the exceptions that <B>+a</B>
0001803f 9599may not be used to destroy an array variable and <B>+r</B> will not
17345e5a 9600remove the readonly attribute.
ac50fbac
CR
9601When used in a function,
9602<B>declare</B>
9603
9604and
9605<B>typeset</B>
9606
9607make each
9608<I>name</I> local, as with the
17345e5a
JA
9609<B>local</B>
9610
495aee44 9611command,
ac50fbac
CR
9612unless the <B>-g</B> option is supplied.
9613If a variable name is followed by =<I>value</I>, the value of
17345e5a 9614the variable is set to <I>value</I>.
ac50fbac
CR
9615When using <B>-a</B> or <B>-A</B> and the compound assignment syntax to
9616create array variables, additional attributes do not take effect until
9617subsequent assignments.
17345e5a
JA
9618The return value is 0 unless an invalid option is encountered,
9619an attempt is made to define a function using
9620
9621<TT>-f foo=bar</TT>,
9622an attempt is made to assign a value to a readonly variable,
9623an attempt is made to assign a value to an array variable without
9624using the compound assignment syntax (see
9625<B>Arrays</B>
9626
9627above), one of the <I>names</I> is not a valid shell variable name,
9628an attempt is made to turn off readonly status for a readonly variable,
9629an attempt is made to turn off array status for an array variable,
9630or an attempt is made to display a non-existent function with <B>-f</B>.
9631</DL>
9632
ac50fbac 9633<DT><B>dirs [-clpv</B>] [+<I>n</I>] [-<I>n</I>]
17345e5a
JA
9634
9635<DD>
9636Without options, displays the list of currently remembered directories.
9637The default display is on a single line with directory names separated
9638by spaces.
9639Directories are added to the list with the
9640<B>pushd</B>
9641
9642command; the
9643<B>popd</B>
9644
9645command removes entries from the list.
9646<DL COMPACT><DT><DD>
9647
9648<DL COMPACT>
17345e5a
JA
9649<DT><B>-c</B>
9650
9651<DD>
9652Clears the directory stack by deleting all of the entries.
9653<DT><B>-l</B>
9654
9655<DD>
ac50fbac
CR
9656Produces a listing using full pathnames;
9657the default listing format uses a tilde to denote the home directory.
17345e5a
JA
9658<DT><B>-p</B>
9659
9660<DD>
9661Print the directory stack with one entry per line.
9662<DT><B>-v</B>
9663
9664<DD>
9665Print the directory stack with one entry per line,
9666prefixing each entry with its index in the stack.
ac50fbac
CR
9667<DT><B>+</B><I>n</I><DD>
9668Displays the <I>n</I>th entry counting from the left of the list
9669shown by
9670<B>dirs</B>
9671
9672when invoked without options, starting with zero.
9673<DT><B>-</B><I>n</I><DD>
9674Displays the <I>n</I>th entry counting from the right of the list
9675shown by
9676<B>dirs</B>
9677
9678when invoked without options, starting with zero.
17345e5a
JA
9679
9680</DL>
9681<P>
9682
9683The return value is 0 unless an
9684invalid option is supplied or <I>n</I> indexes beyond the end
9685of the directory stack.
9686</DL>
9687
9688<DT><B>disown</B> [<B>-ar</B>] [<B>-h</B>] [<I>jobspec</I> ...]<DD>
ac50fbac 9689Without options, remove each
17345e5a
JA
9690<I>jobspec</I>
9691
ac50fbac 9692from the table of active jobs.
17345e5a
JA
9693If
9694<I>jobspec</I>
9695
ac50fbac
CR
9696is not present, and neither the <B>-a</B> nor the <B>-r</B> option
9697is supplied, the <I>current job</I> is used.
17345e5a
JA
9698If the <B>-h</B> option is given, each
9699<I>jobspec</I>
9700
9701is not removed from the table, but is marked so that
9702<FONT SIZE=-1><B>SIGHUP</B>
9703
9704</FONT>
9705is not sent to the job if the shell receives a
9706<FONT SIZE=-1><B>SIGHUP</B>.
9707
9708</FONT>
9709If no
9710<I>jobspec</I>
9711
17345e5a
JA
9712is supplied, the
9713<B>-a</B>
9714
9715option means to remove or mark all jobs; the
9716<B>-r</B>
9717
9718option without a
9719<I>jobspec</I>
9720
9721argument restricts operation to running jobs.
9722The return value is 0 unless a
9723<I>jobspec</I>
9724
9725does not specify a valid job.
9726<DT><B>echo</B> [<B>-neE</B>] [<I>arg</I> ...]<DD>
9727Output the <I>arg</I>s, separated by spaces, followed by a newline.
ac50fbac 9728The return status is 0 unless a write error occurs.
17345e5a
JA
9729If <B>-n</B> is specified, the trailing newline is
9730suppressed. If the <B>-e</B> option is given, interpretation of
9731the following backslash-escaped characters is enabled. The
9732<B>-E</B>
9733
9734option disables the interpretation of these escape characters,
9735even on systems where they are interpreted by default.
9736The <B>xpg_echo</B> shell option may be used to
9737dynamically determine whether or not <B>echo</B> expands these
9738escape characters by default.
9739<B>echo</B>
9740
9741does not interpret <B>--</B> to mean the end of options.
9742<B>echo</B>
9743
9744interprets the following escape sequences:
9745<DL COMPACT><DT><DD>
9746
9747<DL COMPACT>
9748<DT><B>\a</B>
9749
9750<DD>
9751alert (bell)
9752<DT><B>\b</B>
9753
9754<DD>
9755backspace
9756<DT><B>\c</B>
9757
9758<DD>
9759suppress further output
9760<DT><B>\e</B>
9761
495aee44
CR
9762<DD>
9763<DT><B>\E</B>
9764
17345e5a
JA
9765<DD>
9766an escape character
9767<DT><B>\f</B>
9768
9769<DD>
9770form feed
9771<DT><B>\n</B>
9772
9773<DD>
9774new line
9775<DT><B>\r</B>
9776
9777<DD>
9778carriage return
9779<DT><B>\t</B>
9780
9781<DD>
9782horizontal tab
9783<DT><B>\v</B>
9784
9785<DD>
9786vertical tab
9787<DT><B>\\</B>
9788
9789<DD>
9790backslash
9791<DT><B>\0</B><I>nnn</I>
9792
9793<DD>
9794the eight-bit character whose value is the octal value <I>nnn</I>
9795(zero to three octal digits)
9796<DT><B>\x</B><I>HH</I>
9797
9798<DD>
9799the eight-bit character whose value is the hexadecimal value <I>HH</I>
9800(one or two hex digits)
495aee44
CR
9801<DT><B>\u</B><I>HHHH</I>
9802
9803<DD>
9804the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
9805<I>HHHH</I> (one to four hex digits)
9806<DT><B>\U</B><I>HHHHHHHH</I>
9807
9808<DD>
9809the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
9810<I>HHHHHHHH</I> (one to eight hex digits)
17345e5a
JA
9811
9812</DL></DL>
9813
9814<DT><B>enable</B> [<B>-a</B>] [<B>-dnps</B>] [<B>-f</B> <I>filename</I>] [<I>name</I> ...]<DD>
9815Enable and disable builtin shell commands.
9816Disabling a builtin allows a disk command which has the same name
9817as a shell builtin to be executed without specifying a full pathname,
9818even though the shell normally searches for builtins before disk commands.
9819If <B>-n</B> is used, each <I>name</I>
9820is disabled; otherwise,
9821<I>names</I> are enabled. For example, to use the
9822<B>test</B>
9823
9824binary found via the
9825<FONT SIZE=-1><B>PATH</B>
9826
9827</FONT>
9828instead of the shell builtin version, run
9829<TT>enable -n test</TT>.
9830
9831The
9832<B>-f</B>
9833
9834option means to load the new builtin command
9835<I>name</I>
9836
9837from shared object
9838<I>filename</I>,
9839
9840on systems that support dynamic loading. The
9841<B>-d</B>
9842
9843option will delete a builtin previously loaded with
9844<B>-f</B>.
9845
9846If no <I>name</I> arguments are given, or if the
9847<B>-p</B>
9848
9849option is supplied, a list of shell builtins is printed.
9850With no other option arguments, the list consists of all enabled
9851shell builtins.
9852If <B>-n</B> is supplied, only disabled builtins are printed.
9853If <B>-a</B> is supplied, the list printed includes all builtins, with an
9854indication of whether or not each is enabled.
9855If <B>-s</B> is supplied, the output is restricted to the POSIX
9856<I>special</I> builtins.
9857The return value is 0 unless a
9858<I>name</I>
9859
9860is not a shell builtin or there is an error loading a new builtin
9861from a shared object.
9862<DT><B>eval</B> [<I>arg</I> ...]<DD>
9863The <I>arg</I>s are read and concatenated together into a single
9864command. This command is then read and executed by the shell, and
9865its exit status is returned as the value of
9866<B>eval</B>.
9867
9868If there are no
9869<I>args</I>,
9870
9871or only null arguments,
9872<B>eval</B>
9873
9874returns 0.
9875<DT><B>exec</B> [<B>-cl</B>] [<B>-a</B> <I>name</I>] [<I>command</I> [<I>arguments</I>]]<DD>
9876If
9877<I>command</I>
9878
9879is specified, it replaces the shell.
9880No new process is created. The
9881<I>arguments</I>
9882
9883become the arguments to <I>command</I>.
9884If the
9885<B>-l</B>
9886
9887option is supplied,
9888the shell places a dash at the beginning of the zeroth argument passed to
9889<I>command</I>.
9890
9891This is what
9892<I>login</I>(1)
9893
9894does. The
9895<B>-c</B>
9896
9897option causes
9898<I>command</I>
9899
9900to be executed with an empty environment. If
9901<B>-a</B>
9902
9903is supplied, the shell passes
9904<I>name</I>
9905
ac50fbac
CR
9906as the zeroth argument to the executed command.
9907If
17345e5a
JA
9908<I>command</I>
9909
9910cannot be executed for some reason, a non-interactive shell exits,
ac50fbac 9911unless the
17345e5a
JA
9912<B>execfail</B>
9913
ac50fbac
CR
9914shell option
9915is enabled. In that case, it returns failure.
17345e5a
JA
9916An interactive shell returns failure if the file cannot be executed.
9917If
9918<I>command</I>
9919
9920is not specified, any redirections take effect in the current shell,
9921and the return status is 0. If there is a redirection error, the
9922return status is 1.
9923<DT><B>exit</B> [<I>n</I>]<DD>
9924Cause the shell to exit
9925with a status of <I>n</I>. If
9926<I>n</I>
9927
9928is omitted, the exit status
9929is that of the last command executed.
9930A trap on
9931<FONT SIZE=-1><B>EXIT</B>
9932
9933</FONT>
9934is executed before the shell terminates.
9935<DT><B>export</B> [<B>-fn</B>] [<I>name</I>[=<I>word</I>]] ...<DD>
9936
9937<DT><B>export -p</B>
9938
9939<DD>
9940
9941The supplied
9942<I>names</I>
9943
9944are marked for automatic export to the environment of
9945subsequently executed commands. If the
9946<B>-f</B>
9947
9948option is given,
9949the
9950<I>names</I>
9951
9952refer to functions.
9953If no
9954<I>names</I>
9955
9956are given, or if the
9957<B>-p</B>
9958
9959option is supplied, a list
ac50fbac 9960of names of all exported variables is printed.
17345e5a
JA
9961The
9962<B>-n</B>
9963
9964option causes the export property to be removed from each
9965<I>name</I>.
9966If a variable name is followed by =<I>word</I>, the value of
9967the variable is set to <I>word</I>.
9968<B>export</B>
9969
9970returns an exit status of 0 unless an invalid option is
9971encountered,
9972one of the <I>names</I> is not a valid shell variable name, or
9973<B>-f</B>
9974
9975is supplied with a
9976<I>name</I>
9977
9978that is not a function.
9979<DT><B>fc</B> [<B>-e</B> <I>ename</I>] [<B>-lnr</B>] [<I>first</I>] [<I>last</I>]<DD>
9980
9981<DT><B>fc</B> <B>-s</B> [<I>pat</I>=<I>rep</I>] [<I>cmd</I>]<DD>
9982
ac50fbac 9983The first form selects a range of commands from
17345e5a
JA
9984<I>first</I>
9985
9986to
9987<I>last</I>
9988
ac50fbac 9989from the history list and displays or edits and re-executes them.
17345e5a
JA
9990<I>First</I>
9991
9992and
9993<I>last</I>
9994
9995may be specified as a string (to locate the last command beginning
9996with that string) or as a number (an index into the history list,
9997where a negative number is used as an offset from the current
9998command number). If
9999<I>last</I>
10000
10001is not specified it is set to
10002the current command for listing (so that
10003
10004<TT>fc -l -10</TT>
10005prints the last 10 commands) and to
10006<I>first</I>
10007
10008otherwise.
10009If
10010<I>first</I>
10011
10012is not specified it is set to the previous
10013command for editing and -16 for listing.
10014<P>
10015The
10016<B>-n</B>
10017
10018option suppresses
10019the command numbers when listing. The
10020<B>-r</B>
10021
10022option reverses the order of
10023the commands. If the
10024<B>-l</B>
10025
10026option is given,
10027the commands are listed on
10028standard output. Otherwise, the editor given by
10029<I>ename</I>
10030
10031is invoked
10032on a file containing those commands. If
10033<I>ename</I>
10034
10035is not given, the
10036value of the
10037<FONT SIZE=-1><B>FCEDIT</B>
10038
10039</FONT>
10040variable is used, and
10041the value of
10042<FONT SIZE=-1><B>EDITOR</B>
10043
10044</FONT>
10045if
10046<FONT SIZE=-1><B>FCEDIT</B>
10047
10048</FONT>
10049is not set. If neither variable is set,
10050
10051<I>vi</I>
10052
10053is used. When editing is complete, the edited commands are
10054echoed and executed.
10055<P>
10056In the second form, <I>command</I> is re-executed after each instance
10057of <I>pat</I> is replaced by <I>rep</I>.
ac50fbac 10058<I>Command</I> is intepreted the same as <I>first</I> above.
17345e5a
JA
10059A useful alias to use with this is
10060
10061<TT>r='fc -s'</TT>,
10062so that typing
10063
10064<TT>r cc</TT>
10065runs the last command beginning with
10066
10067<TT>cc</TT>
10068and typing
10069
10070<TT>r</TT>
10071re-executes the last command.
10072<P>
10073If the first form is used, the return value is 0 unless an invalid
10074option is encountered or
10075<I>first</I>
10076
10077or
10078<I>last</I>
10079
10080specify history lines out of range.
10081If the
10082<B>-e</B>
10083
10084option is supplied, the return value is the value of the last
10085command executed or failure if an error occurs with the temporary
10086file of commands. If the second form is used, the return status
10087is that of the command re-executed, unless
10088<I>cmd</I>
10089
10090does not specify a valid history line, in which case
10091<B>fc</B>
10092
10093returns failure.
10094<DT><B>fg</B> [<I>jobspec</I>]<DD>
10095Resume
10096<I>jobspec</I>
10097
10098in the foreground, and make it the current job.
10099If
10100<I>jobspec</I>
10101
10102is not present, the shell's notion of the <I>current job</I> is used.
10103The return value is that of the command placed into the foreground,
10104or failure if run when job control is disabled or, when run with
10105job control enabled, if
10106<I>jobspec</I>
10107
10108does not specify a valid job or
10109<I>jobspec</I>
10110
10111specifies a job that was started without job control.
10112<DT><B>getopts</B> <I>optstring</I> <I>name</I> [<I>args</I>]<DD>
10113<B>getopts</B>
10114
10115is used by shell procedures to parse positional parameters.
10116<I>optstring</I>
10117
10118contains the option characters to be recognized; if a character
10119is followed by a colon, the option is expected to have an
10120argument, which should be separated from it by white space.
10121The colon and question mark characters may not be used as
10122option characters.
10123Each time it is invoked,
10124<B>getopts</B>
10125
10126places the next option in the shell variable
10127<I>name</I>,
10128
10129initializing
10130<I>name</I>
10131
10132if it does not exist,
10133and the index of the next argument to be processed into the
10134variable
10135<FONT SIZE=-1><B>OPTIND</B>.
10136
10137</FONT>
10138<FONT SIZE=-1><B>OPTIND</B>
10139
10140</FONT>
10141is initialized to 1 each time the shell or a shell script
10142is invoked. When an option requires an argument,
10143<B>getopts</B>
10144
10145places that argument into the variable
10146<FONT SIZE=-1><B>OPTARG</B>.
10147
10148</FONT>
10149The shell does not reset
10150<FONT SIZE=-1><B>OPTIND</B>
10151
10152</FONT>
10153automatically; it must be manually reset between multiple
10154calls to
10155<B>getopts</B>
10156
10157within the same shell invocation if a new set of parameters
10158is to be used.
10159<P>
10160When the end of options is encountered, <B>getopts</B> exits with a
10161return value greater than zero.
0001803f
CR
10162<FONT SIZE=-1><B>OPTIND</B>
10163
10164</FONT>
10165is set to the index of the first non-option argument,
495aee44 10166and <I>name</I> is set to ?.
17345e5a
JA
10167<P>
10168<B>getopts</B>
10169
10170normally parses the positional parameters, but if more arguments are
10171given in
10172<I>args</I>,
10173
10174<B>getopts</B>
10175
10176parses those instead.
10177<P>
10178<B>getopts</B>
10179
10180can report errors in two ways. If the first character of
10181<I>optstring</I>
10182
10183is a colon,
10184<I>silent</I>
10185
ac50fbac 10186error reporting is used. In normal operation, diagnostic messages
17345e5a
JA
10187are printed when invalid options or missing option arguments are
10188encountered.
10189If the variable
10190<FONT SIZE=-1><B>OPTERR</B>
10191
10192</FONT>
10193is set to 0, no error messages will be displayed, even if the first
10194character of
10195<I>optstring</I>
10196
10197is not a colon.
10198<P>
10199If an invalid option is seen,
10200<B>getopts</B>
10201
10202places ? into
10203<I>name</I>
10204
10205and, if not silent,
10206prints an error message and unsets
10207<FONT SIZE=-1><B>OPTARG</B>.
10208
10209</FONT>
10210If
10211<B>getopts</B>
10212
10213is silent,
10214the option character found is placed in
10215<FONT SIZE=-1><B>OPTARG</B>
10216
10217</FONT>
10218and no diagnostic message is printed.
10219<P>
10220If a required argument is not found, and
10221<B>getopts</B>
10222
10223is not silent,
10224a question mark (<B>?</B>) is placed in
10225<I>name</I>,
10226
10227<FONT SIZE=-1><B>OPTARG</B>
10228
10229</FONT>
10230is unset, and a diagnostic message is printed.
10231If
10232<B>getopts</B>
10233
10234is silent, then a colon (<B>:</B>) is placed in
10235<I>name</I>
10236
10237and
10238<FONT SIZE=-1><B>OPTARG</B>
10239
10240</FONT>
10241is set to the option character found.
10242<P>
10243<B>getopts</B>
10244
10245returns true if an option, specified or unspecified, is found.
10246It returns false if the end of options is encountered or an
10247error occurs.
10248<DT><B>hash</B> [<B>-lr</B>] [<B>-p</B> <I>filename</I>] [<B>-dt</B>] [<I>name</I>]<DD>
495aee44
CR
10249Each time <B>hash</B> is invoked,
10250the full pathname of the command
10251<I>name</I>
17345e5a 10252
495aee44 10253is determined by searching
17345e5a
JA
10254the directories in
10255<B>$PATH</B>
10256
495aee44 10257and remembered. Any previously-remembered pathname is discarded.
17345e5a
JA
10258If the
10259<B>-p</B>
10260
10261option is supplied, no path search is performed, and
10262<I>filename</I>
10263
ac50fbac 10264is used as the full filename of the command.
17345e5a
JA
10265The
10266<B>-r</B>
10267
10268option causes the shell to forget all
10269remembered locations.
10270The
10271<B>-d</B>
10272
10273option causes the shell to forget the remembered location of each <I>name</I>.
10274If the
10275<B>-t</B>
10276
10277option is supplied, the full pathname to which each <I>name</I> corresponds
10278is printed. If multiple <I>name</I> arguments are supplied with <B>-t</B>,
10279the <I>name</I> is printed before the hashed full pathname.
10280The
10281<B>-l</B>
10282
10283option causes output to be displayed in a format that may be reused as input.
10284If no arguments are given, or if only <B>-l</B> is supplied,
10285information about remembered commands is printed.
10286The return status is true unless a
10287<I>name</I>
10288
10289is not found or an invalid option is supplied.
10290<DT><B>help</B> [<B>-dms</B>] [<I>pattern</I>]<DD>
10291Display helpful information about builtin commands. If
10292<I>pattern</I>
10293
10294is specified,
10295<B>help</B>
10296
10297gives detailed help on all commands matching
10298<I>pattern</I>;
10299
10300otherwise help for all the builtins and shell control structures
10301is printed.
10302<DL COMPACT><DT><DD>
10303
10304<DL COMPACT>
10305<DT><B>-d</B>
10306
10307<DD>
10308Display a short description of each <I>pattern</I>
0001803f 10309<DT><B>-m</B>
17345e5a
JA
10310
10311<DD>
10312Display the description of each <I>pattern</I> in a manpage-like format
10313<DT><B>-s</B>
10314
10315<DD>
10316Display only a short usage synopsis for each <I>pattern</I>
10317
ac50fbac
CR
10318</DL>
10319<P>
17345e5a
JA
10320
10321The return status is 0 unless no command matches
10322<I>pattern</I>.
10323
ac50fbac
CR
10324</DL>
10325
17345e5a
JA
10326<DT><B>history [</B><I>n</I>]<DD>
10327
10328<DT><B>history</B> <B>-c</B><DD>
10329<DT><B>history -d</B> <I>offset</I><DD>
10330<DT><B>history</B> <B>-anrw</B> [<I>filename</I>]<DD>
10331<DT><B>history</B> <B>-p</B> <I>arg</I> [<I>arg ...</I>]<DD>
10332<DT><B>history</B> <B>-s</B> <I>arg</I> [<I>arg ...</I>]<DD>
10333
10334With no options, display the command
10335history list with line numbers. Lines listed
10336with a
10337<B>*</B>
10338
10339have been modified. An argument of
10340<I>n</I>
10341
10342lists only the last
10343<I>n</I>
10344
10345lines.
0001803f
CR
10346If the shell variable
10347<FONT SIZE=-1><B>HISTTIMEFORMAT</B>
10348
10349</FONT>
10350is set and not null,
17345e5a
JA
10351it is used as a format string for <I>strftime</I>(3) to display
10352the time stamp associated with each displayed history entry.
10353No intervening blank is printed between the formatted time stamp
10354and the history line.
10355If <I>filename</I> is supplied, it is used as the
10356name of the history file; if not, the value of
10357<FONT SIZE=-1><B>HISTFILE</B>
10358
10359</FONT>
10360is used. Options, if supplied, have the following meanings:
10361<DL COMPACT><DT><DD>
10362
10363<DL COMPACT>
10364<DT><B>-c</B>
10365
10366<DD>
10367Clear the history list by deleting all the entries.
10368<DT><B>-d</B> <I>offset</I><DD>
10369Delete the history entry at position <I>offset</I>.
10370<DT><B>-a</B>
10371
10372<DD>
10373Append the ``new'' history lines (history lines entered since the
10374beginning of the current <B>bash</B> session) to the history file.
10375<DT><B>-n</B>
10376
10377<DD>
10378Read the history lines not already read from the history
10379file into the current history list. These are lines
10380appended to the history file since the beginning of the
10381current <B>bash</B> session.
10382<DT><B>-r</B>
10383
10384<DD>
10385Read the contents of the history file
ac50fbac 10386and append them to the current history list.
17345e5a
JA
10387<DT><B>-w</B>
10388
10389<DD>
ac50fbac 10390Write the current history list to the history file, overwriting the
17345e5a
JA
10391history file's contents.
10392<DT><B>-p</B>
10393
10394<DD>
10395Perform history substitution on the following <I>args</I> and display
10396the result on the standard output.
10397Does not store the results in the history list.
10398Each <I>arg</I> must be quoted to disable normal history expansion.
10399<DT><B>-s</B>
10400
10401<DD>
10402Store the
10403<I>args</I>
10404
10405in the history list as a single entry. The last command in the
10406history list is removed before the
10407<I>args</I>
10408
10409are added.
10410
10411</DL>
10412<P>
10413
0001803f
CR
10414If the
10415<FONT SIZE=-1><B>HISTTIMEFORMAT</B>
10416
10417</FONT>
10418variable is set, the time stamp information
17345e5a
JA
10419associated with each history entry is written to the history file,
10420marked with the history comment character.
10421When the history file is read, lines beginning with the history
10422comment character followed immediately by a digit are interpreted
10423as timestamps for the previous history line.
10424The return value is 0 unless an invalid option is encountered, an
10425error occurs while reading or writing the history file, an invalid
10426<I>offset</I> is supplied as an argument to <B>-d</B>, or the
10427history expansion supplied as an argument to <B>-p</B> fails.
10428</DL>
10429
10430<DT><B>jobs</B> [<B>-lnprs</B>] [ <I>jobspec</I> ... ]<DD>
10431
10432<DT><B>jobs</B> <B>-x</B> <I>command</I> [ <I>args</I> ... ]<DD>
10433
10434The first form lists the active jobs. The options have the following
10435meanings:
10436<DL COMPACT><DT><DD>
10437
10438<DL COMPACT>
10439<DT><B>-l</B>
10440
10441<DD>
10442List process IDs
10443in addition to the normal information.
17345e5a
JA
10444<DT><B>-n</B>
10445
10446<DD>
10447Display information only about jobs that have changed status since
10448the user was last notified of their status.
495aee44
CR
10449<DT><B>-p</B>
10450
10451<DD>
10452List only the process ID of the job's process group
10453leader.
17345e5a
JA
10454<DT><B>-r</B>
10455
10456<DD>
ac50fbac 10457Display only running jobs.
17345e5a
JA
10458<DT><B>-s</B>
10459
10460<DD>
ac50fbac 10461Display only stopped jobs.
17345e5a
JA
10462
10463</DL>
10464<P>
10465
10466If
10467<I>jobspec</I>
10468
10469is given, output is restricted to information about that job.
10470The return status is 0 unless an invalid option is encountered
10471or an invalid
10472<I>jobspec</I>
10473
10474is supplied.
10475<P>
10476
10477If the
10478<B>-x</B>
10479
10480option is supplied,
10481<B>jobs</B>
10482
10483replaces any
10484<I>jobspec</I>
10485
10486found in
10487<I>command</I>
10488
10489or
10490<I>args</I>
10491
10492with the corresponding process group ID, and executes
10493<I>command</I>
10494
10495passing it
10496<I>args</I>,
10497
10498returning its exit status.
10499</DL>
10500
10501<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>
10502
10503<DT><B>kill</B> <B>-l</B> [<I>sigspec</I> | <I>exit_status</I>]<DD>
10504
10505Send the signal named by
10506<I>sigspec</I>
10507
10508or
10509<I>signum</I>
10510
10511to the processes named by
10512<I>pid</I>
10513
10514or
10515<I>jobspec</I>.
10516
10517<I>sigspec</I>
10518
10519is either a case-insensitive signal name such as
10520<FONT SIZE=-1><B>SIGKILL</B>
10521
10522</FONT>
10523(with or without the
10524<FONT SIZE=-1><B>SIG</B>
10525
10526</FONT>
10527prefix) or a signal number;
10528<I>signum</I>
10529
10530is a signal number.
10531If
10532<I>sigspec</I>
10533
10534is not present, then
10535<FONT SIZE=-1><B>SIGTERM</B>
10536
10537</FONT>
10538is assumed.
10539An argument of
10540<B>-l</B>
10541
10542lists the signal names.
10543If any arguments are supplied when
10544<B>-l</B>
10545
10546is given, the names of the signals corresponding to the arguments are
10547listed, and the return status is 0.
10548The <I>exit_status</I> argument to
10549<B>-l</B>
10550
10551is a number specifying either a signal number or the exit status of
10552a process terminated by a signal.
10553<B>kill</B>
10554
10555returns true if at least one signal was successfully sent, or false
10556if an error occurs or an invalid option is encountered.
10557<DT><B>let</B> <I>arg</I> [<I>arg</I> ...]<DD>
10558Each
10559<I>arg</I>
10560
10561is an arithmetic expression to be evaluated (see
0001803f 10562<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
17345e5a
JA
10563
10564</FONT>
0001803f 10565above).
17345e5a
JA
10566If the last
10567<I>arg</I>
10568
10569evaluates to 0,
10570<B>let</B>
10571
10572returns 1; 0 is returned otherwise.
10573<DT><B>local</B> [<I>option</I>] [<I>name</I>[=<I>value</I>] ...]<DD>
10574For each argument, a local variable named
10575<I>name </I>
10576
10577is created, and assigned
10578<I>value</I>.
10579
10580The <I>option</I> can be any of the options accepted by <B>declare</B>.
10581When
10582<B>local</B>
10583
10584is used within a function, it causes the variable
10585<I>name</I>
10586
10587to have a visible scope restricted to that function and its children.
10588With no operands,
10589<B>local</B>
10590
10591writes a list of local variables to the standard output. It is
10592an error to use
10593<B>local</B>
10594
10595when not within a function. The return status is 0 unless
10596<B>local</B>
10597
10598is used outside a function, an invalid
10599<I>name</I>
10600
10601is supplied, or
10602<I>name</I> is a readonly variable.
10603<DT><B>logout</B>
10604
10605<DD>
10606Exit a login shell.
10607<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>
10608
10609<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>
10610
0001803f 10611Read lines from the standard input into the indexed array variable
17345e5a
JA
10612<I>array</I>,
10613
10614or from file descriptor
10615<I>fd</I>
10616
10617if the
10618<B>-u</B>
10619
10620option is supplied.
0001803f
CR
10621The variable
10622<FONT SIZE=-1><B>MAPFILE</B>
10623
10624</FONT>
10625is the default <I>array</I>.
17345e5a
JA
10626Options, if supplied, have the following meanings:
10627<DL COMPACT><DT><DD>
10628
10629<DL COMPACT>
10630<DT><B>-n</B>
10631
10632<DD>
10633Copy at most
10634<I>count</I>
10635
10636lines. If <I>count</I> is 0, all lines are copied.
10637<DT><B>-O</B>
10638
10639<DD>
10640Begin assigning to
10641<I>array</I>
10642
10643at index
10644<I>origin</I>.
10645
10646The default index is 0.
10647<DT><B>-s</B>
10648
10649<DD>
10650Discard the first <I>count</I> lines read.
10651<DT><B>-t</B>
10652
10653<DD>
0001803f 10654Remove a trailing newline from each line read.
17345e5a
JA
10655<DT><B>-u</B>
10656
10657<DD>
10658Read lines from file descriptor <I>fd</I> instead of the standard input.
10659<DT><B>-C</B>
10660
10661<DD>
10662Evaluate
10663<I>callback</I>
10664
10665each time <I>quantum</I> lines are read. The <B>-c</B> option specifies
10666<I>quantum</I>.
10667
10668<DT><B>-c</B>
10669
10670<DD>
10671Specify the number of lines read between each call to
10672<I>callback</I>.
10673
10674
10675</DL>
10676<P>
10677
10678If
10679<B>-C</B>
10680
10681is specified without
10682<B>-c</B>,
10683
10684the default quantum is 5000.
10685When <I>callback</I> is evaluated, it is supplied the index of the next
495aee44
CR
10686array element to be assigned and the line to be assigned to that element
10687as additional arguments.
17345e5a
JA
10688<I>callback</I> is evaluated after the line is read but before the
10689array element is assigned.
10690<P>
10691
10692If not supplied with an explicit origin, <B>mapfile</B> will clear <I>array</I>
10693before assigning to it.
10694<P>
10695
10696<B>mapfile</B> returns successfully unless an invalid option or option
0001803f
CR
10697argument is supplied, <I>array</I> is invalid or unassignable, or if
10698<I>array</I> is not an indexed array.
17345e5a
JA
10699</DL>
10700
10701<DT><B>popd</B> [-<B>n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
10702Removes entries from the directory stack. With no arguments,
10703removes the top directory from the stack, and performs a
10704<B>cd</B>
10705
10706to the new top directory.
10707Arguments, if supplied, have the following meanings:
10708<DL COMPACT><DT><DD>
10709
10710<DL COMPACT>
10711<DT><B>-n</B>
10712
10713<DD>
10714Suppresses the normal change of directory when removing directories
10715from the stack, so that only the stack is manipulated.
10716<DT><B>+</B><I>n</I><DD>
10717Removes the <I>n</I>th entry counting from the left of the list
10718shown by
10719<B>dirs</B>,
10720
10721starting with zero. For example:
10722
10723<TT>popd +0</TT>
10724removes the first directory,
10725
10726<TT>popd +1</TT>
10727the second.
10728<DT><B>-</B><I>n</I><DD>
10729Removes the <I>n</I>th entry counting from the right of the list
10730shown by
10731<B>dirs</B>,
10732
10733starting with zero. For example:
10734
10735<TT>popd -0</TT>
10736removes the last directory,
10737
10738<TT>popd -1</TT>
10739the next to last.
10740
10741</DL>
10742<P>
10743
10744If the
10745<B>popd</B>
10746
10747command is successful, a
10748<B>dirs</B>
10749
10750is performed as well, and the return status is 0.
10751<B>popd</B>
10752
10753returns false if an invalid option is encountered, the directory stack
10754is empty, a non-existent directory stack entry is specified, or the
10755directory change fails.
10756</DL>
10757
10758<DT><B>printf</B> [<B>-v</B> <I>var</I>] <I>format</I> [<I>arguments</I>]<DD>
10759Write the formatted <I>arguments</I> to the standard output under the
10760control of the <I>format</I>.
495aee44
CR
10761The <B>-v</B> option causes the output to be assigned to the variable
10762<I>var</I> rather than being printed to the standard output.
10763<P>
17345e5a
JA
10764The <I>format</I> is a character string which contains three types of objects:
10765plain characters, which are simply copied to standard output, character
10766escape sequences, which are converted and copied to the standard output, and
10767format specifications, each of which causes printing of the next successive
10768<I>argument</I>.
495aee44
CR
10769In addition to the standard <I>printf</I>(1) format specifications,
10770<B>printf</B> interprets the following extensions:
10771<DL COMPACT><DT><DD>
10772
10773<DL COMPACT>
10774<DT><B>%b</B>
10775
10776<DD>
10777causes
17345e5a
JA
10778<B>printf</B> to expand backslash escape sequences in the corresponding
10779<I>argument</I> (except that <B>\c</B> terminates output, backslashes in
10780<B>\aq</B>, <B>\&quot;</B>, and <B>\?</B> are not removed, and octal escapes
495aee44
CR
10781beginning with <B>\0</B> may contain up to four digits).
10782<DT><B>%q</B>
10783
10784<DD>
10785causes <B>printf</B> to output the corresponding
17345e5a 10786<I>argument</I> in a format that can be reused as shell input.
495aee44
CR
10787<DT><B>%(</B><I>datefmt</I>)T
10788
10789<DD>
10790causes <B>printf</B> to output the date-time string resulting from using
ac50fbac
CR
10791<I>datefmt</I> as a format string for <I>strftime</I>(3).
10792The corresponding <I>argument</I> is an integer representing the number of
10793seconds since the epoch.
10794Two special argument values may be used: -1 represents the current
495aee44 10795time, and -2 represents the time the shell was invoked.
ac50fbac
CR
10796If no argument is specified, conversion behaves as if -1 had been given.
10797This is an exception to the usual <B>printf</B> behavior.
495aee44
CR
10798
10799</DL>
17345e5a 10800<P>
495aee44
CR
10801
10802Arguments to non-string format specifiers are treated as C constants,
10803except that a leading plus or minus sign is allowed, and if the leading
10804character is a single or double quote, the value is the ASCII value of
10805the following character.
17345e5a 10806<P>
495aee44 10807
17345e5a
JA
10808The <I>format</I> is reused as necessary to consume all of the <I>arguments</I>.
10809If the <I>format</I> requires more <I>arguments</I> than are supplied, the
10810extra format specifications behave as if a zero value or null string, as
495aee44
CR
10811appropriate, had been supplied.
10812The return value is zero on success, non-zero on failure.
10813</DL>
10814
17345e5a
JA
10815<DT><B>pushd</B> [<B>-n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
10816
10817<DT><B>pushd</B> [<B>-n</B>] [<I>dir</I>]<DD>
10818
10819Adds a directory to the top of the directory stack, or rotates
10820the stack, making the new top of the stack the current working
10821directory. With no arguments, exchanges the top two directories
10822and returns 0, unless the directory stack is empty.
10823Arguments, if supplied, have the following meanings:
10824<DL COMPACT><DT><DD>
10825
10826<DL COMPACT>
10827<DT><B>-n</B>
10828
10829<DD>
10830Suppresses the normal change of directory when adding directories
10831to the stack, so that only the stack is manipulated.
10832<DT><B>+</B><I>n</I><DD>
10833Rotates the stack so that the <I>n</I>th directory
10834(counting from the left of the list shown by
10835<B>dirs</B>,
10836
10837starting with zero)
10838is at the top.
10839<DT><B>-</B><I>n</I><DD>
10840Rotates the stack so that the <I>n</I>th directory
10841(counting from the right of the list shown by
10842<B>dirs</B>,
10843
10844starting with zero) is at the top.
10845<DT><I>dir</I>
10846
10847<DD>
10848Adds
10849<I>dir</I>
10850
10851to the directory stack at the top, making it the
ac50fbac
CR
10852new current working directory as if it had been supplied as the argument
10853to the <B>cd</B> builtin.
17345e5a
JA
10854
10855</DL>
10856<P>
10857
10858If the
10859<B>pushd</B>
10860
10861command is successful, a
10862<B>dirs</B>
10863
10864is performed as well.
10865If the first form is used,
10866<B>pushd</B>
10867
10868returns 0 unless the cd to
10869<I>dir</I>
10870
10871fails. With the second form,
10872<B>pushd</B>
10873
10874returns 0 unless the directory stack is empty,
10875a non-existent directory stack element is specified,
10876or the directory change to the specified new current directory
10877fails.
10878</DL>
10879
10880<DT><B>pwd</B> [<B>-LP</B>]<DD>
10881Print the absolute pathname of the current working directory.
10882The pathname printed contains no symbolic links if the
10883<B>-P</B>
10884
10885option is supplied or the
10886<B>-o physical</B>
10887
10888option to the
10889<B>set</B>
10890
10891builtin command is enabled.
10892If the
10893<B>-L</B>
10894
10895option is used, the pathname printed may contain symbolic links.
10896The return status is 0 unless an error occurs while
10897reading the name of the current directory or an
10898invalid option is supplied.
0001803f 10899<DT><B>read</B> [<B>-ers</B>] [<B>-a</B> <I>aname</I>] [<B>-d</B> <I>delim</I>] [<B>-i</B> <I>text</I>] [<B>-n</B> <I>nchars</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>
17345e5a
JA
10900One line is read from the standard input, or from the file descriptor
10901<I>fd</I> supplied as an argument to the <B>-u</B> option, and the first word
10902is assigned to the first
10903<I>name</I>,
10904
10905the second word to the second
10906<I>name</I>,
10907
10908and so on, with leftover words and their intervening separators assigned
10909to the last
10910<I>name</I>.
10911
10912If there are fewer words read from the input stream than names,
10913the remaining names are assigned empty values.
10914The characters in
10915<FONT SIZE=-1><B>IFS</B>
10916
10917</FONT>
ac50fbac
CR
10918are used to split the line into words using the same rules the shell
10919uses for expansion (described above under <B>Word Splitting</B>).
17345e5a
JA
10920The backslash character (<B>\</B>) may be used to remove any special
10921meaning for the next character read and for line continuation.
10922Options, if supplied, have the following meanings:
10923<DL COMPACT><DT><DD>
10924
10925<DL COMPACT>
10926<DT><B>-a </B><I>aname</I>
10927
10928<DD>
10929The words are assigned to sequential indices
10930of the array variable
10931<I>aname</I>,
10932
10933starting at 0.
10934<I>aname</I>
10935
10936is unset before any new values are assigned.
10937Other <I>name</I> arguments are ignored.
10938<DT><B>-d </B><I>delim</I>
10939
10940<DD>
10941The first character of <I>delim</I> is used to terminate the input line,
10942rather than newline.
10943<DT><B>-e</B>
10944
10945<DD>
10946If the standard input
10947is coming from a terminal,
10948<B>readline</B>
10949
10950(see
10951<FONT SIZE=-1><B>READLINE</B>
10952
10953</FONT>
10954above) is used to obtain the line.
10955Readline uses the current (or default, if line editing was not previously
10956active) editing settings.
10957<DT><B>-i </B><I>text</I>
10958
10959<DD>
10960If
10961<B>readline</B>
10962
10963is being used to read the line, <I>text</I> is placed into the editing
10964buffer before editing begins.
10965<DT><B>-n </B><I>nchars</I>
10966
10967<DD>
10968<B>read</B> returns after reading <I>nchars</I> characters rather than
0001803f
CR
10969waiting for a complete line of input, but honor a delimiter if fewer
10970than <I>nchars</I> characters are read before the delimiter.
10971<DT><B>-N </B><I>nchars</I>
10972
10973<DD>
10974<B>read</B> returns after reading exactly <I>nchars</I> characters rather
10975than waiting for a complete line of input, unless EOF is encountered or
10976<B>read</B> times out.
10977Delimiter characters encountered in the input are
10978not treated specially and do not cause <B>read</B> to return until
10979<I>nchars</I> characters are read.
17345e5a
JA
10980<DT><B>-p </B><I>prompt</I>
10981
10982<DD>
10983Display <I>prompt</I> on standard error, without a
10984trailing newline, before attempting to read any input. The prompt
10985is displayed only if input is coming from a terminal.
10986<DT><B>-r</B>
10987
10988<DD>
10989Backslash does not act as an escape character.
10990The backslash is considered to be part of the line.
10991In particular, a backslash-newline pair may not be used as a line
10992continuation.
10993<DT><B>-s</B>
10994
10995<DD>
10996Silent mode. If input is coming from a terminal, characters are
10997not echoed.
10998<DT><B>-t </B><I>timeout</I>
10999
11000<DD>
11001Cause <B>read</B> to time out and return failure if a complete line of
ac50fbac
CR
11002input (or a specified number of characters)
11003is not read within <I>timeout</I> seconds.
17345e5a
JA
11004<I>timeout</I> may be a decimal number with a fractional portion following
11005the decimal point.
11006This option is only effective if <B>read</B> is reading input from a
11007terminal, pipe, or other special file; it has no effect when reading
11008from regular files.
ac50fbac
CR
11009If <B>read</B> times out, <B>read</B> saves any partial input read into
11010the specified variable <I>name</I>.
11011If <I>timeout</I> is 0, <B>read</B> returns immediately, without trying to
11012read any data. The exit status is 0 if input is available on
11013the specified file descriptor, non-zero otherwise.
17345e5a
JA
11014The exit status is greater than 128 if the timeout is exceeded.
11015<DT><B>-u </B><I>fd</I>
11016
11017<DD>
11018Read input from file descriptor <I>fd</I>.
11019
11020</DL>
11021<P>
11022
11023If no
11024<I>names</I>
11025
11026are supplied, the line read is assigned to the variable
11027<FONT SIZE=-1><B>REPLY</B>.
11028
11029</FONT>
11030The return code is zero, unless end-of-file is encountered, <B>read</B>
ac50fbac
CR
11031times out (in which case the return code is greater than 128),
11032a variable assignment error (such as assigning to a readonly variable) occurs,
11033or an invalid file descriptor is supplied as the argument to <B>-u</B>.
17345e5a
JA
11034</DL>
11035
ac50fbac 11036<DT><B>readonly</B> [<B>-aAf</B>] [<B>-p</B>] [<I>name</I>[=<I>word</I>] ...]<DD>
17345e5a
JA
11037
11038The given
11039<I>names</I> are marked readonly; the values of these
11040<I>names</I>
11041
11042may not be changed by subsequent assignment.
11043If the
11044<B>-f</B>
11045
11046option is supplied, the functions corresponding to the
11047<I>names</I> are so
11048marked.
11049The
11050<B>-a</B>
11051
11052option restricts the variables to indexed arrays; the
11053<B>-A</B>
11054
11055option restricts the variables to associative arrays.
ac50fbac
CR
11056If both options are supplied,
11057<B>-A</B>
11058
11059takes precedence.
17345e5a
JA
11060If no
11061<I>name</I>
11062
11063arguments are given, or if the
11064<B>-p</B>
11065
11066option is supplied, a list of all readonly names is printed.
ac50fbac
CR
11067The other options may be used to restrict the output to a subset of
11068the set of readonly names.
17345e5a
JA
11069The
11070<B>-p</B>
11071
11072option causes output to be displayed in a format that
11073may be reused as input.
11074If a variable name is followed by =<I>word</I>, the value of
11075the variable is set to <I>word</I>.
11076The return status is 0 unless an invalid option is encountered,
11077one of the
11078<I>names</I>
11079
11080is not a valid shell variable name, or
11081<B>-f</B>
11082
11083is supplied with a
11084<I>name</I>
11085
11086that is not a function.
11087<DT><B>return</B> [<I>n</I>]<DD>
ac50fbac
CR
11088Causes a function to stop executing and return the value specified by
11089<I>n</I>
17345e5a 11090
ac50fbac 11091to its caller.
17345e5a
JA
11092If
11093<I>n</I>
11094
11095is omitted, the return status is that of the last command
ac50fbac
CR
11096executed in the function body. If
11097<B>return</B>
11098
11099is used outside a function,
17345e5a
JA
11100but during execution of a script by the
11101<B>.</B>
11102
11103(<B>source</B>) command, it causes the shell to stop executing
11104that script and return either
11105<I>n</I>
11106
11107or the exit status of the last command executed within the
ac50fbac
CR
11108script as the exit status of the script.
11109If <I>n</I> is supplied, the return value is its least significant
111108 bits.
11111The return status is non-zero if
11112<B>return</B>
11113
11114is supplied a non-numeric argument, or
11115is used outside a
11116function and not during execution of a script by <B>.</B> or <B>source</B>.
17345e5a
JA
11117Any command associated with the <B>RETURN</B> trap is executed
11118before execution resumes after the function or script.
495aee44 11119<DT><B>set</B> [<B>--abefhkmnptuvxBCEHPT</B>] [<B>-o</B> <I>option-name</I>] [<I>arg</I> ...]<DD>
17345e5a 11120
495aee44 11121<DT><B>set</B> [<B>+abefhkmnptuvxBCEHPT</B>] [<B>+o</B> <I>option-name</I>] [<I>arg</I> ...]<DD>
17345e5a
JA
11122
11123Without options, the name and value of each shell variable are displayed
11124in a format that can be reused as input
11125for setting or resetting the currently-set variables.
11126Read-only variables cannot be reset.
ac50fbac 11127In <I>posix</I> mode, only shell variables are listed.
17345e5a
JA
11128The output is sorted according to the current locale.
11129When options are specified, they set or unset shell attributes.
11130Any arguments remaining after option processing are treated
11131as values for the positional parameters and are assigned, in order, to
11132<B>$1</B>,
11133
11134<B>$2</B>,
11135
11136<B>...</B>
11137
11138<B>$</B><I>n</I>.
11139
11140Options, if specified, have the following meanings:
11141<DL COMPACT><DT><DD>
11142
11143<DL COMPACT>
11144<DT><B>-a</B>
11145
11146<DD>
11147Automatically mark variables and functions which are modified or
11148created for export to the environment of subsequent commands.
11149<DT><B>-b</B>
11150
11151<DD>
11152Report the status of terminated background jobs
11153immediately, rather than before the next primary prompt. This is
11154effective only when job control is enabled.
11155<DT><B>-e</B>
11156
11157<DD>
ac50fbac
CR
11158Exit immediately if a
11159<I>pipeline</I> (which may consist of a single <I>simple command</I>),
11160a <I>list</I>,
11161or a <I>compound command</I>
11162(see
17345e5a
JA
11163<FONT SIZE=-1><B>SHELL GRAMMAR</B>
11164
11165</FONT>
ac50fbac 11166above), exits with a non-zero status.
17345e5a
JA
11167The shell does not exit if the
11168command that fails is part of the command list immediately following a
11169<B>while</B>
11170
11171or
11172<B>until</B>
11173
11174keyword,
0001803f 11175part of the test following the
17345e5a
JA
11176<B>if</B>
11177
0001803f
CR
11178or
11179<B>elif</B>
11180
11181reserved words, part of any command executed in a
17345e5a
JA
11182<B>&amp;&amp;</B>
11183
11184or
11185<B>||</B>
11186
0001803f 11187list except the command following the final <B>&amp;&amp;</B> or <B>||</B>,
17345e5a
JA
11188any command in a pipeline but the last,
11189or if the command's return value is
0001803f 11190being inverted with
17345e5a
JA
11191<B>!</B>.
11192
ac50fbac
CR
11193If a compound command other than a subshell
11194returns a non-zero status because a command failed
11195while <B>-e</B> was being ignored, the shell does not exit.
17345e5a 11196A trap on <B>ERR</B>, if set, is executed before the shell exits.
0001803f
CR
11197This option applies to the shell environment and each subshell environment
11198separately (see
11199<FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B>
11200
11201</FONT>
11202above), and may cause
11203subshells to exit before executing all the commands in the subshell.
ac50fbac
CR
11204<P>
11205
11206
11207If a compound command or shell function executes in a context
11208where <B>-e</B> is being ignored,
11209none of the commands executed within the compound command or function body
11210will be affected by the <B>-e</B> setting, even if <B>-e</B> is set
11211and a command returns a failure status.
11212If a compound command or shell function sets <B>-e</B> while executing in
11213a context where <B>-e</B> is ignored, that setting will not have any
11214effect until the compound command or the command containing the function
11215call completes.
17345e5a
JA
11216<DT><B>-f</B>
11217
11218<DD>
11219Disable pathname expansion.
11220<DT><B>-h</B>
11221
11222<DD>
11223Remember the location of commands as they are looked up for execution.
11224This is enabled by default.
11225<DT><B>-k</B>
11226
11227<DD>
11228All arguments in the form of assignment statements
11229are placed in the environment for a command, not just
11230those that precede the command name.
11231<DT><B>-m</B>
11232
11233<DD>
11234Monitor mode. Job control is enabled. This option is on
11235by default for interactive shells on systems that support
11236it (see
11237<FONT SIZE=-1><B>JOB CONTROL</B>
11238
11239</FONT>
ac50fbac
CR
11240above).
11241All processes run in a separate process group.
11242When a background job completes, the shell prints a line
11243containing its exit status.
17345e5a
JA
11244<DT><B>-n</B>
11245
11246<DD>
11247Read commands but do not execute them. This may be used to
11248check a shell script for syntax errors. This is ignored by
11249interactive shells.
11250<DT><B>-o </B><I>option-name</I>
11251
11252<DD>
11253The <I>option-name</I> can be one of the following:
11254<DL COMPACT><DT><DD>
11255<DL COMPACT>
11256<DT><B>allexport</B>
11257
11258<DD>
11259Same as
11260<B>-a</B>.
11261
11262<DT><B>braceexpand</B>
11263
11264<DD>
11265Same as
11266<B>-B</B>.
11267
11268<DT><B>emacs</B>
11269
11270<DD>
11271Use an emacs-style command line editing interface. This is enabled
11272by default when the shell is interactive, unless the shell is started
11273with the
11274<B>--noediting</B>
11275
11276option.
11277This also affects the editing interface used for <B>read -e</B>.
0001803f 11278<DT><B>errexit</B>
17345e5a
JA
11279
11280<DD>
11281Same as
0001803f 11282<B>-e</B>.
17345e5a 11283
0001803f 11284<DT><B>errtrace</B>
17345e5a
JA
11285
11286<DD>
11287Same as
0001803f 11288<B>-E</B>.
17345e5a 11289
0001803f 11290<DT><B>functrace</B>
17345e5a
JA
11291
11292<DD>
11293Same as
0001803f 11294<B>-T</B>.
17345e5a
JA
11295
11296<DT><B>hashall</B>
11297
11298<DD>
11299Same as
11300<B>-h</B>.
11301
11302<DT><B>histexpand</B>
11303
11304<DD>
11305Same as
11306<B>-H</B>.
11307
11308<DT><B>history</B>
11309
11310<DD>
11311Enable command history, as described above under
11312<FONT SIZE=-1><B>HISTORY</B>.
11313
11314</FONT>
11315This option is on by default in interactive shells.
11316<DT><B>ignoreeof</B>
11317
11318<DD>
11319The effect is as if the shell command
11320<TT>IGNOREEOF=10</TT>
11321
11322had been executed
11323(see
11324<B>Shell Variables</B>
11325
11326above).
11327<DT><B>keyword</B>
11328
11329<DD>
11330Same as
11331<B>-k</B>.
11332
11333<DT><B>monitor</B>
11334
11335<DD>
11336Same as
11337<B>-m</B>.
11338
11339<DT><B>noclobber</B>
11340
11341<DD>
11342Same as
11343<B>-C</B>.
11344
11345<DT><B>noexec</B>
11346
11347<DD>
11348Same as
11349<B>-n</B>.
11350
11351<DT><B>noglob</B>
11352
11353<DD>
11354Same as
11355<B>-f</B>.
11356
11357<DT><B>nolog</B>
11358
11359<DD>
11360Currently ignored.
11361<DT><B>notify</B>
11362
11363<DD>
11364Same as
11365<B>-b</B>.
11366
11367<DT><B>nounset</B>
11368
11369<DD>
11370Same as
11371<B>-u</B>.
11372
11373<DT><B>onecmd</B>
11374
11375<DD>
11376Same as
11377<B>-t</B>.
11378
11379<DT><B>physical</B>
11380
11381<DD>
11382Same as
11383<B>-P</B>.
11384
11385<DT><B>pipefail</B>
11386
11387<DD>
11388If set, the return value of a pipeline is the value of the last
11389(rightmost) command to exit with a non-zero status, or zero if all
11390commands in the pipeline exit successfully.
11391This option is disabled by default.
11392<DT><B>posix</B>
11393
11394<DD>
11395Change the behavior of
11396<B>bash</B>
11397
11398where the default operation differs
11399from the POSIX standard to match the standard (<I>posix mode</I>).
ac50fbac
CR
11400See
11401<FONT SIZE=-1><B>SEE ALSO</B>
11402
11403</FONT>
11404below for a reference to a document that details how posix mode affects
11405bash's behavior.
17345e5a
JA
11406<DT><B>privileged</B>
11407
11408<DD>
11409Same as
11410<B>-p</B>.
11411
11412<DT><B>verbose</B>
11413
11414<DD>
11415Same as
11416<B>-v</B>.
11417
11418<DT><B>vi</B>
11419
11420<DD>
11421Use a vi-style command line editing interface.
11422This also affects the editing interface used for <B>read -e</B>.
11423<DT><B>xtrace</B>
11424
11425<DD>
11426Same as
11427<B>-x</B>.
11428
11429<P>
11430</DL>
11431<P>
11432
11433If
11434<B>-o</B>
11435
11436is supplied with no <I>option-name</I>, the values of the current options are
11437printed.
11438If
11439<B>+o</B>
11440
11441is supplied with no <I>option-name</I>, a series of
11442<B>set</B>
11443
11444commands to recreate the current option settings is displayed on
11445the standard output.
11446</DL>
11447
11448<DT><B>-p</B>
11449
11450<DD>
11451Turn on
11452<I>privileged</I>
11453
11454mode. In this mode, the
11455<FONT SIZE=-1><B>$ENV</B>
11456
11457</FONT>
11458and
11459<FONT SIZE=-1><B>$BASH_ENV</B>
11460
11461</FONT>
11462files are not processed, shell functions are not inherited from the
11463environment, and the
11464<FONT SIZE=-1><B>SHELLOPTS</B>,
11465
11466</FONT>
0001803f
CR
11467<FONT SIZE=-1><B>BASHOPTS</B>,
11468
11469</FONT>
11470<FONT SIZE=-1><B>CDPATH</B>,
17345e5a 11471
0001803f 11472</FONT>
17345e5a 11473and
0001803f 11474<FONT SIZE=-1><B>GLOBIGNORE</B>
17345e5a 11475
0001803f 11476</FONT>
17345e5a
JA
11477variables, if they appear in the environment, are ignored.
11478If the shell is started with the effective user (group) id not equal to the
11479real user (group) id, and the <B>-p</B> option is not supplied, these actions
11480are taken and the effective user id is set to the real user id.
11481If the <B>-p</B> option is supplied at startup, the effective user id is
11482not reset.
11483Turning this option off causes the effective user
11484and group ids to be set to the real user and group ids.
11485<DT><B>-t</B>
11486
11487<DD>
11488Exit after reading and executing one command.
11489<DT><B>-u</B>
11490
11491<DD>
0001803f
CR
11492Treat unset variables and parameters other than the special
11493parameters &quot;@&quot; and &quot;*&quot; as an error when performing
17345e5a 11494parameter expansion. If expansion is attempted on an
0001803f 11495unset variable or parameter, the shell prints an error message, and,
17345e5a
JA
11496if not interactive, exits with a non-zero status.
11497<DT><B>-v</B>
11498
11499<DD>
11500Print shell input lines as they are read.
11501<DT><B>-x</B>
11502
11503<DD>
11504After expanding each <I>simple command</I>,
11505<B>for</B> command, <B>case</B> command, <B>select</B> command, or
11506arithmetic <B>for</B> command, display the expanded value of
11507<FONT SIZE=-1><B>PS4</B>,
11508
11509</FONT>
11510followed by the command and its expanded arguments
11511or associated word list.
11512<DT><B>-B</B>
11513
11514<DD>
11515The shell performs brace expansion (see
11516<B>Brace Expansion</B>
11517
11518above). This is on by default.
11519<DT><B>-C</B>
11520
11521<DD>
11522If set,
11523<B>bash</B>
11524
11525does not overwrite an existing file with the
11526<B>&gt;</B>,
11527
11528<B>&gt;&amp;</B>,
11529
11530and
11531<B>&lt;&gt;</B>
11532
11533redirection operators. This may be overridden when
11534creating output files by using the redirection operator
11535<B>&gt;|</B>
11536
11537instead of
11538<B>&gt;</B>.
11539
11540<DT><B>-E</B>
11541
11542<DD>
11543If set, any trap on <B>ERR</B> is inherited by shell functions, command
11544substitutions, and commands executed in a subshell environment.
11545The <B>ERR</B> trap is normally not inherited in such cases.
11546<DT><B>-H</B>
11547
11548<DD>
11549Enable
11550<B>!</B>
11551
11552style history substitution. This option is on by
11553default when the shell is interactive.
11554<DT><B>-P</B>
11555
11556<DD>
ac50fbac 11557If set, the shell does not resolve symbolic links when executing
17345e5a
JA
11558commands such as
11559<B>cd</B>
11560
11561that change the current working directory. It uses the
11562physical directory structure instead. By default,
11563<B>bash</B>
11564
11565follows the logical chain of directories when performing commands
11566which change the current directory.
11567<DT><B>-T</B>
11568
11569<DD>
11570If set, any traps on <B>DEBUG</B> and <B>RETURN</B> are inherited by shell
11571functions, command substitutions, and commands executed in a
11572subshell environment.
11573The <B>DEBUG</B> and <B>RETURN</B> traps are normally not inherited
11574in such cases.
11575<DT><B>--</B>
11576
11577<DD>
11578If no arguments follow this option, then the positional parameters are
11579unset. Otherwise, the positional parameters are set to the
11580<I>arg</I>s, even if some of them begin with a
11581<B>-</B>.
11582
11583<DT><B>-</B>
11584
11585<DD>
11586Signal the end of options, cause all remaining <I>arg</I>s to be
11587assigned to the positional parameters. The
11588<B>-x</B>
11589
11590and
11591<B>-v</B>
11592
11593options are turned off.
11594If there are no <I>arg</I>s,
11595the positional parameters remain unchanged.
11596
11597</DL>
11598<P>
11599
11600The options are off by default unless otherwise noted.
11601Using + rather than - causes these options to be turned off.
11602The options can also be specified as arguments to an invocation of
11603the shell.
11604The current set of options may be found in
11605<B>$-</B>.
11606
11607The return status is always true unless an invalid option is encountered.
11608</DL>
11609
11610<DT><B>shift</B> [<I>n</I>]<DD>
11611The positional parameters from <I>n</I>+1 ... are renamed to
11612<B>$1</B>
11613
11614<B>....</B>
11615
11616Parameters represented by the numbers <B>$#</B>
11617down to <B>$#</B>-<I>n</I>+1 are unset.
11618<I>n</I>
11619
11620must be a non-negative number less than or equal to <B>$#</B>.
11621If
11622<I>n</I>
11623
11624is 0, no parameters are changed.
11625If
11626<I>n </I>
11627
11628is not given, it is assumed to be 1.
11629If
11630<I>n</I>
11631
11632is greater than <B>$#</B>, the positional parameters are not changed.
11633The return status is greater than zero if
11634<I>n</I>
11635
11636is greater than
11637<B>$#</B>
11638
11639or less than zero; otherwise 0.
11640<DT><B>shopt</B> [<B>-pqsu</B>] [<B>-o</B>] [<I>optname</I> ...]<DD>
ac50fbac
CR
11641Toggle the values of settings controlling optional shell behavior.
11642The settings can be either those listed below, or, if the
11643<B>-o</B>
11644
11645option is used, those available with the
11646<B>-o</B>
11647
11648option to the <B>set</B> builtin command.
17345e5a
JA
11649With no options, or with the
11650<B>-p</B>
11651
11652option, a list of all settable options is displayed, with
11653an indication of whether or not each is set.
11654The <B>-p</B> option causes output to be displayed in a form that
11655may be reused as input.
11656Other options have the following meanings:
11657<DL COMPACT><DT><DD>
11658
11659<DL COMPACT>
11660<DT><B>-s</B>
11661
11662<DD>
11663Enable (set) each <I>optname</I>.
11664<DT><B>-u</B>
11665
11666<DD>
11667Disable (unset) each <I>optname</I>.
11668<DT><B>-q</B>
11669
11670<DD>
11671Suppresses normal output (quiet mode); the return status indicates
11672whether the <I>optname</I> is set or unset.
11673If multiple <I>optname</I> arguments are given with
11674<B>-q</B>,
11675
11676the return status is zero if all <I>optnames</I> are enabled; non-zero
11677otherwise.
11678<DT><B>-o</B>
11679
11680<DD>
11681Restricts the values of <I>optname</I> to be those defined for the
11682<B>-o</B>
11683
11684option to the
11685<B>set</B>
11686
11687builtin.
11688
11689</DL>
11690<P>
11691
11692If either
11693<B>-s</B>
11694
11695or
11696<B>-u</B>
11697
ac50fbac
CR
11698is used with no <I>optname</I> arguments,
11699<B>shopt</B>
11700
11701shows only those options which are set or unset, respectively.
17345e5a
JA
11702Unless otherwise noted, the <B>shopt</B> options are disabled (unset)
11703by default.
11704<P>
11705
11706The return status when listing options is zero if all <I>optnames</I>
11707are enabled, non-zero otherwise. When setting or unsetting options,
11708the return status is zero unless an <I>optname</I> is not a valid shell
11709option.
11710<P>
11711
11712The list of <B>shopt</B> options is:
11713<P>
11714
11715
11716
11717<DL COMPACT>
11718<DT><B>autocd</B>
11719
11720<DD>
11721If set, a command name that is the name of a directory is executed as if
11722it were the argument to the <B>cd</B> command.
11723This option is only used by interactive shells.
11724<DT><B>cdable_vars</B>
11725
11726<DD>
11727If set, an argument to the
11728<B>cd</B>
11729
11730builtin command that
11731is not a directory is assumed to be the name of a variable whose
11732value is the directory to change to.
11733<DT><B>cdspell</B>
11734
11735<DD>
11736If set, minor errors in the spelling of a directory component in a
11737<B>cd</B>
11738
11739command will be corrected.
11740The errors checked for are transposed characters,
11741a missing character, and one character too many.
ac50fbac 11742If a correction is found, the corrected filename is printed,
17345e5a
JA
11743and the command proceeds.
11744This option is only used by interactive shells.
11745<DT><B>checkhash</B>
11746
11747<DD>
11748If set, <B>bash</B> checks that a command found in the hash
11749table exists before trying to execute it. If a hashed command no
11750longer exists, a normal path search is performed.
11751<DT><B>checkjobs</B>
11752
11753<DD>
11754If set, <B>bash</B> lists the status of any stopped and running jobs before
11755exiting an interactive shell. If any jobs are running, this causes
11756the exit to be deferred until a second exit is attempted without an
0001803f
CR
11757intervening command (see
11758<FONT SIZE=-1><B>JOB CONTROL</B>
11759
11760</FONT>
11761above). The shell always
17345e5a
JA
11762postpones exiting if any jobs are stopped.
11763<DT><B>checkwinsize</B>
11764
11765<DD>
11766If set, <B>bash</B> checks the window size after each command
11767and, if necessary, updates the values of
11768<FONT SIZE=-1><B>LINES</B>
11769
11770</FONT>
11771and
11772<FONT SIZE=-1><B>COLUMNS</B>.
11773
11774</FONT>
11775<DT><B>cmdhist</B>
11776
11777<DD>
11778If set,
11779<B>bash</B>
11780
11781attempts to save all lines of a multiple-line
11782command in the same history entry. This allows
11783easy re-editing of multi-line commands.
11784<DT><B>compat31</B>
11785
11786<DD>
11787If set,
11788<B>bash</B>
11789
11790changes its behavior to that of version 3.1 with respect to quoted
ac50fbac
CR
11791arguments to the <B>[[</B> conditional command's <B>=~</B> operator
11792and locale-specific string comparison when using the <B>[[</B>
495aee44
CR
11793conditional command's <B>&lt;</B> and <B>&gt;</B> operators.
11794Bash versions prior to bash-4.1 use ASCII collation and
11795<I>strcmp</I>(3);
11796
ac50fbac 11797bash-4.1 and later use the current locale's collation sequence and
495aee44
CR
11798<I>strcoll</I>(3).
11799
ac50fbac
CR
11800<DT><B>compat32</B>
11801
11802<DD>
11803If set,
11804<B>bash</B>
11805
11806changes its behavior to that of version 3.2 with respect to
11807locale-specific string comparison when using the <B>[[</B>
11808conditional command's <B>&lt;</B> and <B>&gt;</B> operators (see previous item).
0001803f
CR
11809<DT><B>compat40</B>
11810
11811<DD>
11812If set,
11813<B>bash</B>
11814
11815changes its behavior to that of version 4.0 with respect to locale-specific
495aee44 11816string comparison when using the <B>[[</B>
ac50fbac
CR
11817conditional command's <B>&lt;</B> and <B>&gt;</B> operators (see description of
11818<B>compat31</B>)
0001803f 11819and the effect of interrupting a command list.
ac50fbac
CR
11820Bash versions 4.0 and later interrupt the list as if the shell received the
11821interrupt; previous versions continue with the next command in the list.
495aee44
CR
11822<DT><B>compat41</B>
11823
11824<DD>
495aee44
CR
11825If set,
11826<B>bash</B>,
11827
ac50fbac 11828when in <I>posix</I> mode, treats a single quote in a double-quoted
495aee44
CR
11829parameter expansion as a special character. The single quotes must match
11830(an even number) and the characters between the single quotes are considered
11831quoted. This is the behavior of posix mode through version 4.1.
11832The default bash behavior remains as in previous versions.
ac50fbac
CR
11833<DT><B>compat42</B>
11834
11835<DD>
11836If set,
11837<B>bash</B>
11838
11839does not process the replacement string in the pattern substitution word
11840expansion using quote removal.
11841<DT><B>complete_fullquote</B>
11842
11843<DD>
11844If set,
11845<B>bash</B>
11846
11847quotes all shell metacharacters in filenames and directory names when
11848performing completion.
11849If not set,
11850<B>bash</B>
11851
11852removes metacharacters such as the dollar sign from the set of
11853characters that will be quoted in completed filenames
11854when these metacharacters appear in shell variable references in words to be
11855completed.
11856This means that dollar signs in variable names that expand to directories
11857will not be quoted;
11858however, any dollar signs appearing in filenames will not be quoted, either.
11859This is active only when bash is using backslashes to quote completed
11860filenames.
11861This variable is set by default, which is the default bash behavior in
11862versions through 4.2.
11863<DT><B>direxpand</B>
11864
11865<DD>
11866If set,
11867<B>bash</B>
11868
11869replaces directory names with the results of word expansion when performing
11870filename completion. This changes the contents of the readline editing
11871buffer.
11872If not set,
11873<B>bash</B>
11874
11875attempts to preserve what the user typed.
17345e5a
JA
11876<DT><B>dirspell</B>
11877
11878<DD>
11879If set,
11880<B>bash</B>
11881
11882attempts spelling correction on directory names during word completion
11883if the directory name initially supplied does not exist.
11884<DT><B>dotglob</B>
11885
11886<DD>
11887If set,
11888<B>bash</B>
11889
11890includes filenames beginning with a `.' in the results of pathname
11891expansion.
11892<DT><B>execfail</B>
11893
11894<DD>
11895If set, a non-interactive shell will not exit if
11896it cannot execute the file specified as an argument to the
11897<B>exec</B>
11898
11899builtin command. An interactive shell does not exit if
11900<B>exec</B>
11901
11902fails.
11903<DT><B>expand_aliases</B>
11904
11905<DD>
11906If set, aliases are expanded as described above under
11907<FONT SIZE=-1><B>ALIASES</B>.
11908
11909</FONT>
11910This option is enabled by default for interactive shells.
11911<DT><B>extdebug</B>
11912
11913<DD>
11914If set, behavior intended for use by debuggers is enabled:
11915<DL COMPACT><DT><DD>
11916<DL COMPACT>
11917<DT><B>1.</B>
11918
11919<DD>
11920The <B>-F</B> option to the <B>declare</B> builtin displays the source
11921file name and line number corresponding to each function name supplied
11922as an argument.
11923<DT><B>2.</B>
11924
11925<DD>
11926If the command run by the <B>DEBUG</B> trap returns a non-zero value, the
11927next command is skipped and not executed.
11928<DT><B>3.</B>
11929
11930<DD>
11931If the command run by the <B>DEBUG</B> trap returns a value of 2, and the
11932shell is executing in a subroutine (a shell function or a shell script
11933executed by the <B>.</B> or <B>source</B> builtins), a call to
11934<B>return</B> is simulated.
11935<DT><B>4.</B>
11936
11937<DD>
0001803f
CR
11938<FONT SIZE=-1><B>BASH_ARGC</B>
11939
11940</FONT>
11941and
11942<FONT SIZE=-1><B>BASH_ARGV</B>
11943
11944</FONT>
11945are updated as described in their descriptions above.
17345e5a
JA
11946<DT><B>5.</B>
11947
11948<DD>
11949Function tracing is enabled: command substitution, shell functions, and
11950subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
11951<B>DEBUG</B> and <B>RETURN</B> traps.
11952<DT><B>6.</B>
11953
11954<DD>
11955Error tracing is enabled: command substitution, shell functions, and
11956subshells invoked with <B>(</B> <I>command</I> <B>)</B> inherit the
495aee44 11957<B>ERR</B> trap.
17345e5a
JA
11958</DL></DL>
11959
11960<DT><B>extglob</B>
11961
11962<DD>
11963If set, the extended pattern matching features described above under
11964<B>Pathname Expansion</B> are enabled.
11965<DT><B>extquote</B>
11966
11967<DD>
11968If set, <B>$</B>aq<I>string</I>aq and <B>$</B>&quot;<I>string</I>&quot; quoting is
11969performed within <B>${</B><I>parameter</I><B>}</B> expansions
11970enclosed in double quotes. This option is enabled by default.
11971<DT><B>failglob</B>
11972
11973<DD>
11974If set, patterns which fail to match filenames during pathname expansion
11975result in an expansion error.
11976<DT><B>force_fignore</B>
11977
11978<DD>
0001803f
CR
11979If set, the suffixes specified by the
11980<FONT SIZE=-1><B>FIGNORE</B>
11981
11982</FONT>
11983shell variable
17345e5a
JA
11984cause words to be ignored when performing word completion even if
11985the ignored words are the only possible completions.
11986See
11987<FONT SIZE=-1><B>SHELL VARIABLES</B></FONT>
0001803f
CR
11988above for a description of
11989<FONT SIZE=-1><B>FIGNORE</B>.
11990
11991</FONT>
17345e5a 11992This option is enabled by default.
ac50fbac
CR
11993<DT><B>globasciiranges</B>
11994
11995<DD>
11996If set, range expressions used in pattern matching bracket expressions (see
11997<FONT SIZE=-1><B>Pattern Matching</B>
11998
11999</FONT>
12000above) behave as if in the traditional C locale when performing
12001comparisons. That is, the current locale's collating sequence
12002is not taken into account, so
12003<B>b</B>
12004
12005will not collate between
12006<B>A</B>
12007
12008and
12009<B>B</B>,
12010
12011and upper-case and lower-case ASCII characters will collate together.
17345e5a
JA
12012<DT><B>globstar</B>
12013
12014<DD>
0001803f 12015If set, the pattern <B>**</B> used in a pathname expansion context will
ac50fbac 12016match all files and zero or more directories and subdirectories.
17345e5a
JA
12017If the pattern is followed by a <B>/</B>, only directories and
12018subdirectories match.
12019<DT><B>gnu_errfmt</B>
12020
12021<DD>
12022If set, shell error messages are written in the standard GNU error
12023message format.
12024<DT><B>histappend</B>
12025
12026<DD>
12027If set, the history list is appended to the file named by the value
12028of the
0001803f 12029<FONT SIZE=-1><B>HISTFILE</B>
17345e5a 12030
0001803f 12031</FONT>
17345e5a
JA
12032variable when the shell exits, rather than overwriting the file.
12033<DT><B>histreedit</B>
12034
12035<DD>
12036If set, and
12037<B>readline</B>
12038
12039is being used, a user is given the opportunity to re-edit a
12040failed history substitution.
12041<DT><B>histverify</B>
12042
12043<DD>
12044If set, and
12045<B>readline</B>
12046
12047is being used, the results of history substitution are not immediately
12048passed to the shell parser. Instead, the resulting line is loaded into
12049the <B>readline</B> editing buffer, allowing further modification.
12050<DT><B>hostcomplete</B>
12051
12052<DD>
12053If set, and
12054<B>readline</B>
12055
12056is being used, <B>bash</B> will attempt to perform hostname completion when a
12057word containing a <B>@</B> is being completed (see
12058<B>Completing</B>
12059
12060under
12061<FONT SIZE=-1><B>READLINE</B>
12062
12063</FONT>
12064above).
12065This is enabled by default.
12066<DT><B>huponexit</B>
12067
12068<DD>
12069If set, <B>bash</B> will send
12070<FONT SIZE=-1><B>SIGHUP</B>
12071
12072</FONT>
12073to all jobs when an interactive login shell exits.
12074<DT><B>interactive_comments</B>
12075
12076<DD>
12077If set, allow a word beginning with
12078<B>#</B>
12079
12080to cause that word and all remaining characters on that
12081line to be ignored in an interactive shell (see
12082<FONT SIZE=-1><B>COMMENTS</B>
12083
12084</FONT>
12085above). This option is enabled by default.
495aee44
CR
12086<DT><B>lastpipe</B>
12087
12088<DD>
12089If set, and job control is not active, the shell runs the last command of
12090a pipeline not executed in the background in the current shell environment.
17345e5a
JA
12091<DT><B>lithist</B>
12092
12093<DD>
12094If set, and the
12095<B>cmdhist</B>
12096
12097option is enabled, multi-line commands are saved to the history with
12098embedded newlines rather than using semicolon separators where possible.
12099<DT><B>login_shell</B>
12100
12101<DD>
12102The shell sets this option if it is started as a login shell (see
12103<FONT SIZE=-1><B>INVOCATION</B>
12104
12105</FONT>
12106above).
12107The value may not be changed.
12108<DT><B>mailwarn</B>
12109
12110<DD>
12111If set, and a file that <B>bash</B> is checking for mail has been
12112accessed since the last time it was checked, the message ``The mail in
12113<I>mailfile</I> has been read'' is displayed.
12114<DT><B>no_empty_cmd_completion</B>
12115
12116<DD>
12117If set, and
12118<B>readline</B>
12119
12120is being used,
12121<B>bash</B>
12122
0001803f
CR
12123will not attempt to search the
12124<FONT SIZE=-1><B>PATH</B>
12125
12126</FONT>
12127for possible completions when
17345e5a
JA
12128completion is attempted on an empty line.
12129<DT><B>nocaseglob</B>
12130
12131<DD>
12132If set,
12133<B>bash</B>
12134
12135matches filenames in a case-insensitive fashion when performing pathname
12136expansion (see
12137<B>Pathname Expansion</B>
12138
12139above).
12140<DT><B>nocasematch</B>
12141
12142<DD>
12143If set,
12144<B>bash</B>
12145
12146matches patterns in a case-insensitive fashion when performing matching
12147while executing <B>case</B> or <B>[[</B> conditional commands.
12148<DT><B>nullglob</B>
12149
12150<DD>
12151If set,
12152<B>bash</B>
12153
12154allows patterns which match no
12155files (see
12156<B>Pathname Expansion</B>
12157
12158above)
12159to expand to a null string, rather than themselves.
12160<DT><B>progcomp</B>
12161
12162<DD>
12163If set, the programmable completion facilities (see
12164<B>Programmable Completion</B> above) are enabled.
12165This option is enabled by default.
12166<DT><B>promptvars</B>
12167
12168<DD>
12169If set, prompt strings undergo
12170parameter expansion, command substitution, arithmetic
12171expansion, and quote removal after being expanded as described in
12172<FONT SIZE=-1><B>PROMPTING</B>
12173
12174</FONT>
12175above. This option is enabled by default.
12176<DT><B>restricted_shell</B>
12177
12178<DD>
12179The shell sets this option if it is started in restricted mode (see
12180<FONT SIZE=-1><B>RESTRICTED SHELL</B>
12181
12182</FONT>
12183below).
12184The value may not be changed.
12185This is not reset when the startup files are executed, allowing
12186the startup files to discover whether or not a shell is restricted.
12187<DT><B>shift_verbose</B>
12188
12189<DD>
12190If set, the
12191<B>shift</B>
12192
12193builtin prints an error message when the shift count exceeds the
12194number of positional parameters.
12195<DT><B>sourcepath</B>
12196
12197<DD>
12198If set, the
12199<B>source</B> (<B>.</B>) builtin uses the value of
12200<FONT SIZE=-1><B>PATH</B>
12201
12202</FONT>
12203to find the directory containing the file supplied as an argument.
12204This option is enabled by default.
12205<DT><B>xpg_echo</B>
12206
12207<DD>
12208If set, the <B>echo</B> builtin expands backslash-escape sequences
12209by default.
12210</DL></DL>
12211
ac50fbac 12212
17345e5a
JA
12213<DT><B>suspend</B> [<B>-f</B>]<DD>
12214Suspend the execution of this shell until it receives a
12215<FONT SIZE=-1><B>SIGCONT</B>
12216
12217</FONT>
12218signal. A login shell cannot be suspended; the
12219<B>-f</B>
12220
12221option can be used to override this and force the suspension.
12222The return status is 0 unless the shell is a login shell and
12223<B>-f</B>
12224
12225is not supplied, or if job control is not enabled.
12226<DT><B>test</B> <I>expr</I><DD>
12227
12228<DT><B>[</B> <I>expr</I> <B>]</B><DD>
ac50fbac 12229Return a status of 0 (true) or 1 (false) depending on
17345e5a
JA
12230the evaluation of the conditional expression
12231<I>expr</I>.
12232
12233Each operator and operand must be a separate argument.
12234Expressions are composed of the primaries described above under
12235<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>.
12236
12237</FONT>
12238<B>test</B> does not accept any options, nor does it accept and ignore
12239an argument of <B>--</B> as signifying the end of options.
12240<P>
12241
12242
12243Expressions may be combined using the following operators, listed
12244in decreasing order of precedence.
12245The evaluation depends on the number of arguments; see below.
495aee44 12246Operator precedence is used when there are five or more arguments.
17345e5a
JA
12247<DL COMPACT><DT><DD>
12248
12249<DL COMPACT>
12250<DT><B>! </B><I>expr</I>
12251
12252<DD>
12253True if
12254<I>expr</I>
12255
12256is false.
12257<DT><B>( </B><I>expr</I> )
12258
12259<DD>
12260Returns the value of <I>expr</I>.
12261This may be used to override the normal precedence of operators.
12262<DT><I>expr1</I> -<B>a</B> <I>expr2</I><DD>
12263True if both
12264<I>expr1</I>
12265
12266and
12267<I>expr2</I>
12268
12269are true.
12270<DT><I>expr1</I> -<B>o</B> <I>expr2</I><DD>
12271True if either
12272<I>expr1</I>
12273
12274or
12275<I>expr2</I>
12276
12277is true.
12278
12279</DL>
12280<P>
12281
12282<B>test</B> and <B>[</B> evaluate conditional
12283expressions using a set of rules based on the number of arguments.
12284<P>
12285
12286
12287
12288<DL COMPACT>
12289<DT>0 arguments<DD>
12290The expression is false.
12291<DT>1 argument<DD>
12292The expression is true if and only if the argument is not null.
12293<DT>2 arguments<DD>
12294If the first argument is <B>!</B>, the expression is true if and
12295only if the second argument is null.
12296If the first argument is one of the unary conditional operators listed above
12297under
12298<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
12299
12300</FONT>
12301the expression is true if the unary test is true.
12302If the first argument is not a valid unary conditional operator, the expression
12303is false.
12304<DT>3 arguments<DD>
495aee44 12305The following conditions are applied in the order listed.
17345e5a
JA
12306If the second argument is one of the binary conditional operators listed above
12307under
12308<FONT SIZE=-1><B>CONDITIONAL EXPRESSIONS</B>,
12309
12310</FONT>
12311the result of the expression is the result of the binary test using
12312the first and third arguments as operands.
12313The <B>-a</B> and <B>-o</B> operators are considered binary operators
12314when there are three arguments.
12315If the first argument is <B>!</B>, the value is the negation of
12316the two-argument test using the second and third arguments.
12317If the first argument is exactly <B>(</B> and the third argument is
12318exactly <B>)</B>, the result is the one-argument test of the second
12319argument.
12320Otherwise, the expression is false.
12321<DT>4 arguments<DD>
12322If the first argument is <B>!</B>, the result is the negation of
12323the three-argument expression composed of the remaining arguments.
12324Otherwise, the expression is parsed and evaluated according to
12325precedence using the rules listed above.
12326<DT>5 or more arguments<DD>
12327The expression is parsed and evaluated according to precedence
12328using the rules listed above.
495aee44
CR
12329<P>
12330
12331
12332</DL>
12333<P>
12334
12335When used with <B>test</B> or <B>[</B>, the <B>&lt;</B> and <B>&gt;</B> operators
12336sort lexicographically using ASCII ordering.
12337</DL>
17345e5a
JA
12338
12339
12340<DT><B>times</B>
12341
12342<DD>
12343Print the accumulated user and system times for the shell and
12344for processes run from the shell. The return status is 0.
12345<DT><B>trap</B> [<B>-lp</B>] [[<I>arg</I>] <I>sigspec</I> ...]<DD>
12346The command
12347<I>arg</I>
12348
12349is to be read and executed when the shell receives
12350signal(s)
12351<I>sigspec</I>.
12352
12353If
12354<I>arg</I>
12355
12356is absent (and there is a single <I>sigspec</I>) or
12357<B>-</B>,
12358
12359each specified signal is
12360reset to its original disposition (the value it had
12361upon entrance to the shell).
12362If
12363<I>arg</I>
12364
12365is the null string the signal specified by each
12366<I>sigspec</I>
12367
12368is ignored by the shell and by the commands it invokes.
12369If
12370<I>arg</I>
12371
12372is not present and
12373<B>-p</B>
12374
12375has been supplied, then the trap commands associated with each
12376<I>sigspec</I>
12377
12378are displayed.
12379If no arguments are supplied or if only
12380<B>-p</B>
12381
12382is given,
12383<B>trap</B>
12384
12385prints the list of commands associated with each signal.
12386The
12387<B>-l</B>
12388
12389option causes the shell to print a list of signal names and
12390their corresponding numbers.
12391Each
12392<I>sigspec</I>
12393
12394is either
12395a signal name defined in &lt;<I>signal.h</I>&gt;, or a signal number.
495aee44
CR
12396Signal names are case insensitive and the
12397<FONT SIZE=-1><B>SIG</B>
12398
12399</FONT>
12400prefix is optional.
0001803f
CR
12401<P>
12402
12403
17345e5a
JA
12404If a
12405<I>sigspec</I>
12406
12407is
12408<FONT SIZE=-1><B>EXIT</B>
12409
12410</FONT>
12411(0) the command
12412<I>arg</I>
12413
12414is executed on exit from the shell.
12415If a
12416<I>sigspec</I>
12417
12418is
12419<FONT SIZE=-1><B>DEBUG</B>,
12420
12421</FONT>
12422the command
12423<I>arg</I>
12424
12425is executed before every <I>simple command</I>, <I>for</I> command,
12426<I>case</I> command, <I>select</I> command, every arithmetic <I>for</I>
12427command, and before the first command executes in a shell function (see
12428<FONT SIZE=-1><B>SHELL GRAMMAR</B>
12429
12430</FONT>
12431above).
12432Refer to the description of the <B>extdebug</B> option to the
12433<B>shopt</B> builtin for details of its effect on the <B>DEBUG</B> trap.
12434If a
12435<I>sigspec</I>
12436
0001803f
CR
12437is
12438<FONT SIZE=-1><B>RETURN</B>,
12439
12440</FONT>
12441the command
12442<I>arg</I>
12443
495aee44
CR
12444is executed each time a shell function or a script executed with
12445the <B>.</B> or <B>source</B> builtins finishes executing.
0001803f
CR
12446<P>
12447
12448
12449If a
12450<I>sigspec</I>
12451
17345e5a
JA
12452is
12453<FONT SIZE=-1><B>ERR</B>,
12454
12455</FONT>
12456the command
12457<I>arg</I>
12458
ac50fbac
CR
12459is executed whenever a
12460a pipeline (which may consist of a single simple
12461command), a list, or a compound command returns a
12462non-zero exit status,
17345e5a
JA
12463subject to the following conditions.
12464The
12465<FONT SIZE=-1><B>ERR</B>
12466
12467</FONT>
12468trap is not executed if the failed
12469command is part of the command list immediately following a
12470<B>while</B>
12471
12472or
12473<B>until</B>
12474
12475keyword,
12476part of the test in an
12477<I>if</I>
12478
12479statement, part of a command executed in a
12480<B>&amp;&amp;</B>
12481
12482or
12483<B>||</B>
12484
ac50fbac
CR
12485list except the command following the final <B>&amp;&amp;</B> or <B>||</B>,
12486any command in a pipeline but the last,
12487or if the command's return value is
12488being inverted using
17345e5a
JA
12489<B>!</B>.
12490
ac50fbac 12491These are the same conditions obeyed by the <B>errexit</B> (<B>-e</B>) option.
0001803f 12492<P>
17345e5a 12493
17345e5a 12494
17345e5a
JA
12495Signals ignored upon entry to the shell cannot be trapped or reset.
12496Trapped signals that are not being ignored are reset to their original
0001803f 12497values in a subshell or subshell environment when one is created.
17345e5a
JA
12498The return status is false if any
12499<I>sigspec</I>
12500
12501is invalid; otherwise
12502<B>trap</B>
12503
12504returns true.
12505<DT><B>type</B> [<B>-aftpP</B>] <I>name</I> [<I>name</I> ...]<DD>
12506With no options,
12507indicate how each
12508<I>name</I>
12509
12510would be interpreted if used as a command name.
12511If the
12512<B>-t</B>
12513
12514option is used,
12515<B>type</B>
12516
12517prints a string which is one of
12518<I>alias</I>,
12519
12520<I>keyword</I>,
12521
12522<I>function</I>,
12523
12524<I>builtin</I>,
12525
12526or
12527<I>file </I>
12528
12529if
12530<I>name</I>
12531
12532is an alias, shell reserved word, function, builtin, or disk file,
12533respectively.
12534If the
12535<I>name</I>
12536
12537is not found, then nothing is printed, and an exit status of false
12538is returned.
12539If the
12540<B>-p</B>
12541
12542option is used,
12543<B>type</B>
12544
12545either returns the name of the disk file
12546that would be executed if
12547<I>name</I>
12548
12549were specified as a command name,
12550or nothing if
12551<TT>type -t name</TT>
12552
12553would not return
12554<I>file</I>.
12555
12556The
12557<B>-P</B>
12558
12559option forces a
12560<FONT SIZE=-1><B>PATH</B>
12561
12562</FONT>
12563search for each <I>name</I>, even if
12564<TT>type -t name</TT>
12565
12566would not return
12567<I>file</I>.
12568
12569If a command is hashed,
12570<B>-p</B>
12571
12572and
12573<B>-P</B>
12574
ac50fbac 12575print the hashed value, which is not necessarily the file that appears
17345e5a
JA
12576first in
12577<FONT SIZE=-1><B>PATH</B>.
12578
12579</FONT>
12580If the
12581<B>-a</B>
12582
12583option is used,
12584<B>type</B>
12585
12586prints all of the places that contain
12587an executable named
12588<I>name</I>.
12589
12590This includes aliases and functions,
12591if and only if the
12592<B>-p</B>
12593
12594option is not also used.
12595The table of hashed commands is not consulted
12596when using
12597<B>-a</B>.
12598
12599The
12600<B>-f</B>
12601
12602option suppresses shell function lookup, as with the <B>command</B> builtin.
12603<B>type</B>
12604
12605returns true if all of the arguments are found, false if
12606any are not found.
12607<DT><B>ulimit</B> [<B>-HSTabcdefilmnpqrstuvx</B> [<I>limit</I>]]<DD>
12608Provides control over the resources available to the shell and to
12609processes started by it, on systems that allow such control.
12610The <B>-H</B> and <B>-S</B> options specify that the hard or soft limit is
12611set for the given resource.
12612A hard limit cannot be increased by a non-root user once it is set;
12613a soft limit may be increased up to the value of the hard limit.
12614If neither <B>-H</B> nor <B>-S</B> is specified, both the soft and hard
12615limits are set.
12616The value of
12617<I>limit</I>
12618
12619can be a number in the unit specified for the resource
12620or one of the special values
12621<B>hard</B>,
12622
12623<B>soft</B>,
12624
12625or
12626<B>unlimited</B>,
12627
12628which stand for the current hard limit, the current soft limit, and
12629no limit, respectively.
12630If
12631<I>limit</I>
12632
12633is omitted, the current value of the soft limit of the resource is
12634printed, unless the <B>-H</B> option is given. When more than one
12635resource is specified, the limit name and unit are printed before the value.
12636Other options are interpreted as follows:
12637<DL COMPACT><DT><DD>
12638
12639<DL COMPACT>
12640<DT><B>-a</B>
12641
12642<DD>
12643All current limits are reported
12644<DT><B>-b</B>
12645
12646<DD>
12647The maximum socket buffer size
12648<DT><B>-c</B>
12649
12650<DD>
12651The maximum size of core files created
12652<DT><B>-d</B>
12653
12654<DD>
12655The maximum size of a process's data segment
12656<DT><B>-e</B>
12657
12658<DD>
12659The maximum scheduling priority (&quot;nice&quot;)
12660<DT><B>-f</B>
12661
12662<DD>
12663The maximum size of files written by the shell and its children
12664<DT><B>-i</B>
12665
12666<DD>
12667The maximum number of pending signals
12668<DT><B>-l</B>
12669
12670<DD>
12671The maximum size that may be locked into memory
12672<DT><B>-m</B>
12673
12674<DD>
0001803f 12675The maximum resident set size (many systems do not honor this limit)
17345e5a
JA
12676<DT><B>-n</B>
12677
12678<DD>
12679The maximum number of open file descriptors (most systems do not
12680allow this value to be set)
12681<DT><B>-p</B>
12682
12683<DD>
12684The pipe size in 512-byte blocks (this may not be set)
12685<DT><B>-q</B>
12686
12687<DD>
12688The maximum number of bytes in POSIX message queues
12689<DT><B>-r</B>
12690
12691<DD>
12692The maximum real-time scheduling priority
12693<DT><B>-s</B>
12694
12695<DD>
12696The maximum stack size
12697<DT><B>-t</B>
12698
12699<DD>
12700The maximum amount of cpu time in seconds
12701<DT><B>-u</B>
12702
12703<DD>
12704The maximum number of processes available to a single user
12705<DT><B>-v</B>
12706
12707<DD>
495aee44
CR
12708The maximum amount of virtual memory available to the shell and, on
12709some systems, to its children
17345e5a
JA
12710<DT><B>-x</B>
12711
12712<DD>
12713The maximum number of file locks
12714<DT><B>-T</B>
12715
12716<DD>
12717The maximum number of threads
12718
12719</DL>
12720<P>
12721
12722If
12723<I>limit</I>
12724
ac50fbac 12725is given, and the
17345e5a
JA
12726<B>-a</B>
12727
ac50fbac
CR
12728option is not used,
12729<I>limit</I> is the new value of the specified resource.
17345e5a
JA
12730If no option is given, then
12731<B>-f</B>
12732
12733is assumed. Values are in 1024-byte increments, except for
12734<B>-t</B>,
12735
ac50fbac 12736which is in seconds;
17345e5a
JA
12737<B>-p</B>,
12738
ac50fbac 12739which is in units of 512-byte blocks;
17345e5a
JA
12740and
12741<B>-T</B>,
12742
12743<B>-b</B>,
12744
12745<B>-n</B>,
12746
12747and
12748<B>-u</B>,
12749
12750which are unscaled values.
12751The return status is 0 unless an invalid option or argument is supplied,
12752or an error occurs while setting a new limit.
12753</DL>
12754
12755<DT><B>umask</B> [<B>-p</B>] [<B>-S</B>] [<I>mode</I>]<DD>
12756The user file-creation mask is set to
12757<I>mode</I>.
12758
12759If
12760<I>mode</I>
12761
12762begins with a digit, it
12763is interpreted as an octal number; otherwise
12764it is interpreted as a symbolic mode mask similar
12765to that accepted by
12766<I>chmod</I>(1).
12767
12768If
12769<I>mode</I>
12770
12771is omitted, the current value of the mask is printed.
12772The
12773<B>-S</B>
12774
12775option causes the mask to be printed in symbolic form; the
12776default output is an octal number.
12777If the
12778<B>-p</B>
12779
12780option is supplied, and
12781<I>mode</I>
12782
12783is omitted, the output is in a form that may be reused as input.
12784The return status is 0 if the mode was successfully changed or if
12785no <I>mode</I> argument was supplied, and false otherwise.
12786<DT><B>unalias</B> [-<B>a</B>] [<I>name</I> ...]<DD>
12787Remove each <I>name</I> from the list of defined aliases. If
12788<B>-a</B>
12789
12790is supplied, all alias definitions are removed. The return
12791value is true unless a supplied
12792<I>name</I>
12793
12794is not a defined alias.
ac50fbac 12795<DT><B>unset</B> [-<B>fv</B>] [-<B>n</B>] [<I>name</I> ...]<DD>
17345e5a
JA
12796For each
12797<I>name</I>,
12798
12799remove the corresponding variable or function.
ac50fbac 12800If the
17345e5a
JA
12801<B>-v</B>
12802
12803option is given, each
12804<I>name</I>
12805
ac50fbac 12806refers to a shell variable, and that variable is removed.
17345e5a
JA
12807Read-only variables may not be unset.
12808If
12809<B>-f</B>
12810
12811is specified, each
12812<I>name</I>
12813
12814refers to a shell function, and the function definition
12815is removed.
ac50fbac
CR
12816If the
12817<B>-n</B>
12818
12819option is supplied, and <I>name</I> is a variable with the <I>nameref</I>
12820attribute, <I>name</I> will be unset rather than the variable it
12821references.
12822<B>-n</B> has no effect if the <B>-f</B> option is supplied.
12823If no options are supplied, each <I>name</I> refers to a variable; if
12824there is no variable by that name, any function with that name is
12825unset.
17345e5a
JA
12826Each unset variable or function is removed from the environment
12827passed to subsequent commands.
12828If any of
0001803f
CR
12829<FONT SIZE=-1><B>COMP_WORDBREAKS</B>,
12830
12831</FONT>
17345e5a
JA
12832<FONT SIZE=-1><B>RANDOM</B>,
12833
12834</FONT>
12835<FONT SIZE=-1><B>SECONDS</B>,
12836
12837</FONT>
12838<FONT SIZE=-1><B>LINENO</B>,
12839
12840</FONT>
12841<FONT SIZE=-1><B>HISTCMD</B>,
12842
12843</FONT>
12844<FONT SIZE=-1><B>FUNCNAME</B>,
12845
12846</FONT>
12847<FONT SIZE=-1><B>GROUPS</B>,
12848
12849</FONT>
12850or
12851<FONT SIZE=-1><B>DIRSTACK</B>
12852
12853</FONT>
12854are unset, they lose their special properties, even if they are
12855subsequently reset. The exit status is true unless a
12856<I>name</I>
12857
12858is readonly.
ac50fbac
CR
12859<DT><B>wait</B> [<B>-n</B>] [<I>n ...</I>]<DD>
12860Wait for each specified child process and return its termination status.
17345e5a
JA
12861Each
12862<I>n</I>
12863
12864may be a process
12865ID or a job specification; if a job spec is given, all processes
12866in that job's pipeline are waited for. If
12867<I>n</I>
12868
12869is not given, all currently active child processes
ac50fbac
CR
12870are waited for, and the return status is zero.
12871If the <B>-n</B> option is supplied, <B>wait</B> waits for any job to
12872terminate and returns its exit status.
12873If
17345e5a
JA
12874<I>n</I>
12875
12876specifies a non-existent process or job, the return status is
12877127. Otherwise, the return status is the exit status of the last
12878process or job waited for.
12879
12880
12881</DL>
12882<A NAME="lbDC">&nbsp;</A>
12883<H3>RESTRICTED SHELL</H3>
12884
12885
12886
12887<P>
12888
12889If
12890<B>bash</B>
12891
12892is started with the name
12893<B>rbash</B>,
12894
12895or the
12896<B>-r</B>
12897
12898option is supplied at invocation,
12899the shell becomes restricted.
12900A restricted shell is used to
12901set up an environment more controlled than the standard shell.
12902It behaves identically to
12903<B>bash</B>
12904
12905with the exception that the following are disallowed or not performed:
12906<DL COMPACT>
12907<DT>*<DD>
12908changing directories with <B>cd</B>
12909<DT>*<DD>
12910setting or unsetting the values of
0001803f 12911<FONT SIZE=-1><B>SHELL</B>,
17345e5a 12912
0001803f
CR
12913</FONT>
12914<FONT SIZE=-1><B>PATH</B>,
17345e5a 12915
0001803f
CR
12916</FONT>
12917<FONT SIZE=-1><B>ENV</B>,
17345e5a 12918
0001803f 12919</FONT>
17345e5a 12920or
0001803f 12921<FONT SIZE=-1><B>BASH_ENV</B>
17345e5a 12922
0001803f 12923</FONT>
17345e5a
JA
12924<DT>*<DD>
12925specifying command names containing
12926<B>/</B>
12927
12928<DT>*<DD>
ac50fbac 12929specifying a filename containing a
17345e5a
JA
12930<B>/</B>
12931
12932as an argument to the
12933<B>.</B>
12934
12935builtin command
12936<DT>*<DD>
495aee44 12937specifying a filename containing a slash as an argument to the
17345e5a
JA
12938<B>-p</B>
12939
12940option to the
12941<B>hash</B>
12942
12943builtin command
12944<DT>*<DD>
12945importing function definitions from the shell environment at startup
12946<DT>*<DD>
0001803f
CR
12947parsing the value of
12948<FONT SIZE=-1><B>SHELLOPTS</B>
12949
12950</FONT>
12951from the shell environment at startup
17345e5a
JA
12952<DT>*<DD>
12953redirecting output using the &gt;, &gt;|, &lt;&gt;, &gt;&amp;, &amp;&gt;, and &gt;&gt; redirection operators
12954<DT>*<DD>
12955using the
12956<B>exec</B>
12957
12958builtin command to replace the shell with another command
12959<DT>*<DD>
12960adding or deleting builtin commands with the
12961<B>-f</B>
12962
12963and
12964<B>-d</B>
12965
12966options to the
12967<B>enable</B>
12968
12969builtin command
12970<DT>*<DD>
495aee44 12971using the <B>enable</B> builtin command to enable disabled shell builtins
17345e5a
JA
12972<DT>*<DD>
12973specifying the
12974<B>-p</B>
12975
12976option to the
12977<B>command</B>
12978
12979builtin command
12980<DT>*<DD>
12981turning off restricted mode with
12982<B>set +r</B> or <B>set +o restricted</B>.
12983</DL>
12984<P>
12985
12986These restrictions are enforced after any startup files are read.
12987<P>
12988
12989
12990 When a command that is found to be a shell script is executed
12991(see
12992<FONT SIZE=-1><B>COMMAND EXECUTION</B>
12993
12994</FONT>
12995
12996above),
12997
12998<B>rbash</B>
12999
13000turns off any restrictions in the shell spawned to execute the
13001script.
13002
13003
13004<A NAME="lbDD">&nbsp;</A>
13005<H3>SEE ALSO</H3>
13006
13007
13008<DL COMPACT>
13009<DT><I>Bash Reference Manual</I>, Brian Fox and Chet Ramey<DD>
13010<DT><I>The Gnu Readline Library</I>, Brian Fox and Chet Ramey<DD>
13011<DT><I>The Gnu History Library</I>, Brian Fox and Chet Ramey<DD>
ac50fbac
CR
13012<DT><I>Portable Operating System Interface (POSIX) Part 2: Shell and Utilities</I>, IEEE --<DD>
13013<A HREF="http://pubs.opengroup.org/onlinepubs/9699919799/">http://pubs.opengroup.org/onlinepubs/9699919799/</A>
13014<DT><A HREF="http://tiswww.case.edu/~chet/bash/POSIX">http://tiswww.case.edu/~chet/bash/POSIX</A> -- a description of posix mode<DD>
17345e5a
JA
13015<DT><I>sh</I>(1), <I>ksh</I>(1), <I>csh</I>(1)<DD>
13016<DT><I>emacs</I>(1), <I>vi</I>(1)<DD>
13017<DT><I>readline</I>(3)<DD>
13018
13019</DL>
13020<A NAME="lbDE">&nbsp;</A>
13021<H3>FILES</H3>
13022
13023
13024<DL COMPACT>
13025<DT>
13026<A HREF="file:/bin/bash"><I>/bin/bash</I></A>
13027
13028<DD>
13029The <B>bash</B> executable
13030<DT>
13031<A HREF="file:/etc/profile"><I>/etc/profile</I></A>
13032
13033<DD>
13034The systemwide initialization file, executed for login shells
13035<DT>
13036<A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>
13037
13038<DD>
13039The personal initialization file, executed for login shells
13040<DT>
13041<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>
13042
13043<DD>
13044The individual per-interactive-shell startup file
13045<DT>
13046<A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>
13047
13048<DD>
13049The individual login shell cleanup file, executed when a login shell exits
13050<DT>
13051<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>
13052
13053<DD>
13054Individual <I>readline</I> initialization file
13055
13056</DL>
13057<A NAME="lbDF">&nbsp;</A>
13058<H3>AUTHORS</H3>
13059
13060Brian Fox, Free Software Foundation
13061<BR>
13062
13063<A HREF="mailto:bfox@gnu.org">bfox@gnu.org</A>
13064<P>
13065
13066Chet Ramey, Case Western Reserve University
13067<BR>
13068
0001803f 13069<A HREF="mailto:chet.ramey@case.edu">chet.ramey@case.edu</A>
17345e5a
JA
13070<A NAME="lbDG">&nbsp;</A>
13071<H3>BUG REPORTS</H3>
13072
13073If you find a bug in
13074<B>bash,</B>
13075
13076you should report it. But first, you should
13077make sure that it really is a bug, and that it appears in the latest
13078version of
13079<B>bash</B>.
13080
13081The latest version is always available from
495aee44 13082<I><A HREF="ftp://ftp.gnu.org/pub/gnu/bash/">ftp://ftp.gnu.org/pub/gnu/bash/</A></I>.
17345e5a
JA
13083<P>
13084
13085Once you have determined that a bug actually exists, use the
13086<I>bashbug</I>
13087
13088command to submit a bug report.
13089If you have a fix, you are encouraged to mail that as well!
13090Suggestions and `philosophical' bug reports may be mailed
13091to <I><A HREF="mailto:bug-bash@gnu.org">bug-bash@gnu.org</A></I> or posted to the Usenet
13092newsgroup
13093<A HREF="news:gnu.bash.bug">gnu.bash.bug</A>.
13094
13095<P>
13096
13097ALL bug reports should include:
13098<P>
13099
13100
13101<DL COMPACT>
13102<DT>The version number of <B>bash</B><DD>
13103<DT>The hardware and operating system<DD>
13104<DT>The compiler used to compile<DD>
13105<DT>A description of the bug behaviour<DD>
13106<DT>A short script or `recipe' which exercises the bug<DD>
13107
13108</DL>
13109<P>
13110
13111<I>bashbug</I>
13112
13113inserts the first three items automatically into the template
13114it provides for filing a bug report.
13115<P>
13116
13117Comments and bug reports concerning
13118this manual page should be directed to
ac50fbac 13119<I><A HREF="mailto:chet.ramey@case.edu">chet.ramey@case.edu</A></I>.
17345e5a
JA
13120
13121<A NAME="lbDH">&nbsp;</A>
13122<H3>BUGS</H3>
13123
13124<P>
13125
13126It's too big and too slow.
13127<P>
13128
13129There are some subtle differences between
13130<B>bash</B>
13131
13132and traditional versions of
13133<B>sh</B>,
13134
13135mostly because of the
13136<FONT SIZE=-1><B>POSIX</B>
13137
13138</FONT>
13139specification.
13140<P>
13141
13142Aliases are confusing in some uses.
13143<P>
13144
13145Shell builtin commands and functions are not stoppable/restartable.
13146<P>
13147
13148Compound commands and command sequences of the form `a ; b ; c'
13149are not handled gracefully when process suspension is attempted.
13150When a process is stopped, the shell immediately executes the next
13151command in the sequence.
13152It suffices to place the sequence of commands between
13153parentheses to force it into a subshell, which may be stopped as
13154a unit.
13155<P>
13156
13157Array variables may not (yet) be exported.
13158<P>
13159
13160There may be only one active coprocess at a time.
13161
13162
13163
13164<HR>
13165<TABLE WIDTH=100%>
13166<TR>
ac50fbac 13167<TH ALIGN=LEFT width=33%>GNU Bash 4.3<TH ALIGN=CENTER width=33%>2014 February 2<TH ALIGN=RIGHT width=33%>BASH(1)
17345e5a
JA
13168</TR>
13169</TABLE>
13170<HR>
13171<A NAME="index">&nbsp;</A><H2>Index</H2>
13172<DL>
13173<DT><A HREF="#lbAB">NAME</A><DD>
13174<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
13175<DT><A HREF="#lbAD">COPYRIGHT</A><DD>
13176<DT><A HREF="#lbAE">DESCRIPTION</A><DD>
13177<DT><A HREF="#lbAF">OPTIONS</A><DD>
13178<DT><A HREF="#lbAG">ARGUMENTS</A><DD>
13179<DT><A HREF="#lbAH">INVOCATION</A><DD>
13180<DT><A HREF="#lbAI">DEFINITIONS</A><DD>
13181<DT><A HREF="#lbAJ">RESERVED WORDS</A><DD>
13182<DT><A HREF="#lbAK">SHELL GRAMMAR</A><DD>
13183<DL>
13184<DT><A HREF="#lbAL">Simple Commands</A><DD>
13185<DT><A HREF="#lbAM">Pipelines</A><DD>
13186<DT><A HREF="#lbAN">Lists</A><DD>
13187<DT><A HREF="#lbAO">Compound Commands</A><DD>
13188<DT><A HREF="#lbAP">Coprocesses</A><DD>
13189<DT><A HREF="#lbAQ">Shell Function Definitions</A><DD>
13190</DL>
13191<DT><A HREF="#lbAR">COMMENTS</A><DD>
13192<DT><A HREF="#lbAS">QUOTING</A><DD>
13193<DT><A HREF="#lbAT">PARAMETERS</A><DD>
13194<DL>
13195<DT><A HREF="#lbAU">Positional Parameters</A><DD>
13196<DT><A HREF="#lbAV">Special Parameters</A><DD>
13197<DT><A HREF="#lbAW">Shell Variables</A><DD>
13198<DT><A HREF="#lbAX">Arrays</A><DD>
13199</DL>
13200<DT><A HREF="#lbAY">EXPANSION</A><DD>
13201<DL>
13202<DT><A HREF="#lbAZ">Brace Expansion</A><DD>
13203<DT><A HREF="#lbBA">Tilde Expansion</A><DD>
13204<DT><A HREF="#lbBB">Parameter Expansion</A><DD>
13205<DT><A HREF="#lbBC">Command Substitution</A><DD>
13206<DT><A HREF="#lbBD">Arithmetic Expansion</A><DD>
13207<DT><A HREF="#lbBE">Process Substitution</A><DD>
13208<DT><A HREF="#lbBF">Word Splitting</A><DD>
13209<DT><A HREF="#lbBG">Pathname Expansion</A><DD>
13210<DT><A HREF="#lbBH">Quote Removal</A><DD>
13211</DL>
13212<DT><A HREF="#lbBI">REDIRECTION</A><DD>
13213<DL>
13214<DT><A HREF="#lbBJ">Redirecting Input</A><DD>
13215<DT><A HREF="#lbBK">Redirecting Output</A><DD>
13216<DT><A HREF="#lbBL">Appending Redirected Output</A><DD>
13217<DT><A HREF="#lbBM">Redirecting Standard Output and Standard Error</A><DD>
13218<DT><A HREF="#lbBN">Appending Standard Output and Standard Error</A><DD>
13219<DT><A HREF="#lbBO">Here Documents</A><DD>
13220<DT><A HREF="#lbBP">Here Strings</A><DD>
13221<DT><A HREF="#lbBQ">Duplicating File Descriptors</A><DD>
13222<DT><A HREF="#lbBR">Moving File Descriptors</A><DD>
13223<DT><A HREF="#lbBS">Opening File Descriptors for Reading and Writing</A><DD>
13224</DL>
13225<DT><A HREF="#lbBT">ALIASES</A><DD>
13226<DT><A HREF="#lbBU">FUNCTIONS</A><DD>
13227<DT><A HREF="#lbBV">ARITHMETIC EVALUATION</A><DD>
13228<DT><A HREF="#lbBW">CONDITIONAL EXPRESSIONS</A><DD>
13229<DT><A HREF="#lbBX">SIMPLE COMMAND EXPANSION</A><DD>
13230<DT><A HREF="#lbBY">COMMAND EXECUTION</A><DD>
13231<DT><A HREF="#lbBZ">COMMAND EXECUTION ENVIRONMENT</A><DD>
13232<DT><A HREF="#lbCA">ENVIRONMENT</A><DD>
13233<DT><A HREF="#lbCB">EXIT STATUS</A><DD>
13234<DT><A HREF="#lbCC">SIGNALS</A><DD>
13235<DT><A HREF="#lbCD">JOB CONTROL</A><DD>
13236<DT><A HREF="#lbCE">PROMPTING</A><DD>
13237<DT><A HREF="#lbCF">READLINE</A><DD>
13238<DL>
13239<DT><A HREF="#lbCG">Readline Notation</A><DD>
13240<DT><A HREF="#lbCH">Readline Initialization</A><DD>
13241<DT><A HREF="#lbCI">Readline Key Bindings</A><DD>
13242<DT><A HREF="#lbCJ">Readline Variables</A><DD>
13243<DT><A HREF="#lbCK">Readline Conditional Constructs</A><DD>
13244<DT><A HREF="#lbCL">Searching</A><DD>
13245<DT><A HREF="#lbCM">Readline Command Names</A><DD>
13246<DT><A HREF="#lbCN">Commands for Moving</A><DD>
13247<DT><A HREF="#lbCO">Commands for Manipulating the History</A><DD>
13248<DT><A HREF="#lbCP">Commands for Changing Text</A><DD>
13249<DT><A HREF="#lbCQ">Killing and Yanking</A><DD>
13250<DT><A HREF="#lbCR">Numeric Arguments</A><DD>
13251<DT><A HREF="#lbCS">Completing</A><DD>
13252<DT><A HREF="#lbCT">Keyboard Macros</A><DD>
13253<DT><A HREF="#lbCU">Miscellaneous</A><DD>
13254<DT><A HREF="#lbCV">Programmable Completion</A><DD>
13255</DL>
13256<DT><A HREF="#lbCW">HISTORY</A><DD>
13257<DT><A HREF="#lbCX">HISTORY EXPANSION</A><DD>
13258<DL>
13259<DT><A HREF="#lbCY">Event Designators</A><DD>
13260<DT><A HREF="#lbCZ">Word Designators</A><DD>
13261<DT><A HREF="#lbDA">Modifiers</A><DD>
13262</DL>
13263<DT><A HREF="#lbDB">SHELL BUILTIN COMMANDS</A><DD>
13264<DT><A HREF="#lbDC">RESTRICTED SHELL</A><DD>
13265<DT><A HREF="#lbDD">SEE ALSO</A><DD>
13266<DT><A HREF="#lbDE">FILES</A><DD>
13267<DT><A HREF="#lbDF">AUTHORS</A><DD>
13268<DT><A HREF="#lbDG">BUG REPORTS</A><DD>
13269<DT><A HREF="#lbDH">BUGS</A><DD>
13270</DL>
13271<HR>
13272This document was created by man2html from bash.1.<BR>
ac50fbac 13273Time: 24 February 2014 08:28:34 EST
17345e5a
JA
13274</BODY>
13275</HTML>